diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-03-24 10:38:07 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-03-24 10:38:07 +0400 |
commit | ab4a2aaf4a4b2b4e416aa1f113b30362cbe0dec3 (patch) | |
tree | 81af4c18519181490074508dbe9a8d515eab634f /source | |
parent | 5a90ea77bc1333efe4e1e54984a080550ed3f707 (diff) |
style cleanup: follow style guide for formatting of if/for/while loops, and else if's
Diffstat (limited to 'source')
367 files changed, 22225 insertions, 21483 deletions
diff --git a/source/blender/blenpluginapi/intern/pluginapi.c b/source/blender/blenpluginapi/intern/pluginapi.c index b81facfac7e..02166c466fa 100644 --- a/source/blender/blenpluginapi/intern/pluginapi.c +++ b/source/blender/blenpluginapi/intern/pluginapi.c @@ -186,7 +186,7 @@ LIBEXPORT int ispic(char * name) } /* still the same name */ -/* void (*ditherfunc)(struct ImBuf *, short, short){} */ +/* void (*ditherfunc)(struct ImBuf *, short, short) {} */ LIBEXPORT struct ImBuf *scaleImBuf(struct ImBuf *ib, short nx, diff --git a/source/blender/bmesh/operators/bmo_dissolve.c b/source/blender/bmesh/operators/bmo_dissolve.c index 4685b0a2ede..76180355304 100644 --- a/source/blender/bmesh/operators/bmo_dissolve.c +++ b/source/blender/bmesh/operators/bmo_dissolve.c @@ -437,7 +437,8 @@ void dummy_exec(BMesh *bm, BMOperator *op) BM_face_kill(bm, f); BM_edge_kill(bm, fe); } - } /* else if (f->len == 3) { + } + /* else if (f->len == 3) { BMEdge *ed[3]; BMVert *vt[3]; BMLoop *lp[3]; diff --git a/source/blender/bmesh/operators/bmo_extrude.c b/source/blender/bmesh/operators/bmo_extrude.c index 32acd99a260..3048be925d9 100644 --- a/source/blender/bmesh/operators/bmo_extrude.c +++ b/source/blender/bmesh/operators/bmo_extrude.c @@ -131,7 +131,7 @@ static void bm_extrude_copy_face_loop_attributes(BMesh *bm, BMFace *f, BMEdge *e if (l2 == l) { l2 = newedge->l; - if(l2 != l) { + if (l2 != l) { BM_elem_attrs_copy(bm, bm, l2->f, l->f); BM_elem_attrs_copy(bm, bm, l2, l); diff --git a/source/blender/bmesh/tools/BME_bevel.c b/source/blender/bmesh/tools/BME_bevel.c index 78d02ee387a..3b8337f46ae 100644 --- a/source/blender/bmesh/tools/BME_bevel.c +++ b/source/blender/bmesh/tools/BME_bevel.c @@ -847,17 +847,17 @@ static void bevel_init_edges(BMesh *bm, int options, BME_TransData_Head *td) BM_ITER(e, &iter, bm, BM_EDGES_OF_MESH, NULL) { weight = 0.0; if (!BMO_elem_flag_test(bm, e, BME_BEVEL_NONMAN)) { - if(options & BME_BEVEL_SELECT) { - if(BM_elem_flag_test(e, BM_ELEM_SELECT)) weight = 1.0; + if (options & BME_BEVEL_SELECT) { + if (BM_elem_flag_test(e, BM_ELEM_SELECT)) weight = 1.0; } - else if(options & BME_BEVEL_WEIGHT) { + else if (options & BME_BEVEL_WEIGHT) { weight = BM_elem_float_data_get(&bm->edata, e, CD_BWEIGHT); } else { weight = 1.0; } - if(weight > 0.0) { + if (weight > 0.0) { BMO_elem_flag_enable(bm, e, BME_BEVEL_BEVEL); BMO_elem_flag_enable(bm, e->v1, BME_BEVEL_BEVEL); BMO_elem_flag_enable(bm, e->v2, BME_BEVEL_BEVEL); @@ -869,9 +869,9 @@ static void bevel_init_edges(BMesh *bm, int options, BME_TransData_Head *td) /* clean up edges with 2 faces that share more than one edg */ BM_ITER(e, &iter, bm, BM_EDGES_OF_MESH, NULL) { - if(BMO_elem_flag_test(bm, e, BME_BEVEL_BEVEL)) { + if (BMO_elem_flag_test(bm, e, BME_BEVEL_BEVEL)) { count = BM_face_share_edge_count(e->l->f, e->l->radial_next->f); - if(count > 1) BMO_elem_flag_disable(bm, e, BME_BEVEL_BEVEL); + if (count > 1) BMO_elem_flag_disable(bm, e, BME_BEVEL_BEVEL); } } } @@ -887,7 +887,7 @@ static BMesh *BME_bevel_initialize(BMesh *bm, int options, int UNUSED(defgrp_ind /* tag non-manifold geometr */ BM_ITER(v, &iter, bm, BM_VERTS_OF_MESH, NULL) { BMO_elem_flag_enable(bm, v, BME_BEVEL_ORIG); - if(v->e) { + if (v->e) { BME_assign_transdata(td, bm, v, v->co, v->co, NULL, NULL, 0, -1, -1, NULL); if (!BM_vert_is_manifold(v)) { BMO_elem_flag_enable(bm, v, BME_BEVEL_NONMAN); @@ -910,7 +910,7 @@ static BMesh *BME_bevel_initialize(BMesh *bm, int options, int UNUSED(defgrp_ind BMO_elem_flag_enable(bm, e->v2, BME_BEVEL_NONMAN); BMO_elem_flag_enable(bm, e, BME_BEVEL_NONMAN); } - if(BMO_elem_flag_test(bm, e->v1, BME_BEVEL_NONMAN) || BMO_elem_flag_test(bm, e->v2, BME_BEVEL_NONMAN)) { + if (BMO_elem_flag_test(bm, e->v1, BME_BEVEL_NONMAN) || BMO_elem_flag_test(bm, e->v2, BME_BEVEL_NONMAN)) { BMO_elem_flag_enable(bm, e, BME_BEVEL_NONMAN); } } @@ -919,7 +919,7 @@ static BMesh *BME_bevel_initialize(BMesh *bm, int options, int UNUSED(defgrp_ind BMO_elem_flag_enable(bm, f, BME_BEVEL_ORIG); } - if(options & BME_BEVEL_VERT) { + if (options & BME_BEVEL_VERT) { bevel_init_verts(bm, options, td); } else { @@ -980,30 +980,30 @@ static BMesh *BME_bevel_mesh(BMesh *bm, float value, int UNUSED(res), int option /* bevel poly */ BM_ITER(f, &iter, bm, BM_FACES_OF_MESH, NULL) { - if(BMO_elem_flag_test(bm, f, BME_BEVEL_ORIG)) { + if (BMO_elem_flag_test(bm, f, BME_BEVEL_ORIG)) { BME_bevel_poly(bm, f, value, options, td); } } /* get rid of beveled edge */ BM_ITER(e, &iter, bm, BM_EDGES_OF_MESH, NULL) { - if(BMO_elem_flag_test(bm, e, BME_BEVEL_BEVEL) && BMO_elem_flag_test(bm, e, BME_BEVEL_ORIG)) { + if (BMO_elem_flag_test(bm, e, BME_BEVEL_BEVEL) && BMO_elem_flag_test(bm, e, BME_BEVEL_ORIG)) { BM_faces_join_pair(bm, e->l->f, e->l->radial_next->f, e); } } /* link up corners and cli */ BM_ITER(v, &iter, bm, BM_VERTS_OF_MESH, NULL) { - if(BMO_elem_flag_test(bm, v, BME_BEVEL_ORIG) && BMO_elem_flag_test(bm, v, BME_BEVEL_BEVEL)) { + if (BMO_elem_flag_test(bm, v, BME_BEVEL_ORIG) && BMO_elem_flag_test(bm, v, BME_BEVEL_BEVEL)) { curedge = v->e; do { l = curedge->l; l2 = l->radial_next; - if(l->v != v) l = l->next; - if(l2->v != v) l2 = l2->next; - if(l->f->len > 3) + if (l->v != v) l = l->next; + if (l2->v != v) l2 = l2->next; + if (l->f->len > 3) BM_face_split(bm, l->f, l->next->v, l->prev->v, &l, l->e, FALSE); /* clip this corner off */ - if(l2->f->len > 3) + if (l2->f->len > 3) BM_face_split(bm, l2->f, l2->next->v, l2->prev->v, &l, l2->e, FALSE); /* clip this corner off */ curedge = bmesh_disk_edge_next(curedge, v); } while (curedge != v->e); @@ -1013,7 +1013,7 @@ static BMesh *BME_bevel_mesh(BMesh *bm, float value, int UNUSED(res), int option /* Debug print, remov */ BM_ITER(f, &iter, bm, BM_FACES_OF_MESH, NULL) { - if(f->len == 2) { + if (f->len == 2) { printf("warning"); } } diff --git a/source/blender/collada/AnimationExporter.cpp b/source/blender/collada/AnimationExporter.cpp index 5b1ad604b50..d6eb406ced7 100644 --- a/source/blender/collada/AnimationExporter.cpp +++ b/source/blender/collada/AnimationExporter.cpp @@ -548,7 +548,8 @@ void AnimationExporter::add_source_parameters(COLLADASW::SourceBase::ParameterNa if ( transform ) { param.push_back("TRANSFORM"); - }else{ //assumes if axis isn't specified all axises are added + } + else { //assumes if axis isn't specified all axises are added param.push_back("X"); param.push_back("Y"); param.push_back("Z"); @@ -592,7 +593,8 @@ void AnimationExporter::get_source_values(BezTriple *bezt, COLLADASW::InputSeman } else if (rotation) { values[1] = RAD2DEGF(bezt->vec[0][1]); - } else { + } + else { values[1] = bezt->vec[0][1]; } break; @@ -607,7 +609,8 @@ void AnimationExporter::get_source_values(BezTriple *bezt, COLLADASW::InputSeman } else if (rotation) { values[1] = RAD2DEGF(bezt->vec[2][1]); - } else { + } + else { values[1] = bezt->vec[2][1]; } break; @@ -858,9 +861,11 @@ std::string AnimationExporter::create_interpolation_source(FCurve *fcu, const st if (fcu->bezt[i].ipo==BEZT_IPO_BEZ) { source.appendValues(BEZIER_NAME); *has_tangents = true; - } else if (fcu->bezt[i].ipo==BEZT_IPO_CONST) { + } + else if (fcu->bezt[i].ipo==BEZT_IPO_CONST) { source.appendValues(STEP_NAME); - } else { // BEZT_IPO_LIN + } + else { // BEZT_IPO_LIN source.appendValues(LINEAR_NAME); } } diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp index b85e9e2fd01..4ad79e0b309 100644 --- a/source/blender/collada/DocumentImporter.cpp +++ b/source/blender/collada/DocumentImporter.cpp @@ -1015,9 +1015,11 @@ bool DocumentImporter::writeLight( const COLLADAFW::Light* light ) else if(IS_EQ(quadatt, 0.0f) && linatt > 0.0f) { att1 = linatt; d = (1.0f/linatt); - } else if (IS_EQ(constatt, 1.0f)) { + } + else if (IS_EQ(constatt, 1.0f)) { att1 = 1.0f; - } else { + } + else { // assuming point light (const att = 1.0); att1 = 1.0f; } diff --git a/source/blender/collada/EffectExporter.cpp b/source/blender/collada/EffectExporter.cpp index 7ada149cde9..0dbd44f2b73 100644 --- a/source/blender/collada/EffectExporter.cpp +++ b/source/blender/collada/EffectExporter.cpp @@ -138,7 +138,8 @@ void EffectsExporter::operator()(Material *ma, Object *ob) // for now set phong in case spec shader is not blinn writePhong(ep, ma); } - } else { + } + else { if(ma->diff_shader == MA_DIFF_LAMBERT) { writeLambert(ep, ma); } diff --git a/source/blender/collada/MeshImporter.cpp b/source/blender/collada/MeshImporter.cpp index 10fae7e2c1b..2539756dbdf 100644 --- a/source/blender/collada/MeshImporter.cpp +++ b/source/blender/collada/MeshImporter.cpp @@ -917,7 +917,8 @@ Object *MeshImporter::create_mesh_object(COLLADAFW::Node *node, COLLADAFW::Insta texture_face = assign_material_to_geom(mat_array[i], uid_material_map, ob, geom_uid, &color_texture, layername, texture_face, material_texture_mapping_map, i); - } else { + } + else { fprintf(stderr, "invalid referenced material for %s\n", mat_array[i].getName().c_str()); } } 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; a<sys->totface; a++, face++) { + for (a=0, face=sys->faces; a<sys->totface; 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; a<sys->totface; a++, face++) + if (sys->areaweights) + for (a=0, face=sys->faces; a<sys->totface; a++, face++) laplacian_triangle_area(sys, (*face)[0], (*face)[1], (*face)[2]); - for(a=0; a<totvert; a++) { - if(sys->areaweights) { - if(sys->varea[a] != 0.0f) + for (a=0; a<totvert; a++) { + if (sys->areaweights) { + 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; a<totface; a++, face++) + for (a=0, face=sys->faces; a<totface; a++, face++) laplacian_triangle_weights(sys, a, (*face)[0], (*face)[1], (*face)[2]); MEM_freeN(sys->faces); 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; a<sys->totvert; a++) { - if(sys->vpinned[a]) { + if (index >= 0) { + for (a=0; a<sys->totvert; 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; a<totface; a++) { + for (a=0; a<totface; a++) { MFace *mf = mface+a; float bb[6]; @@ -454,7 +454,7 @@ static void heat_ray_tree_create(LaplacianSystem *sys) DO_MINMAX(verts[mf->v1], 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; j<sys->heat.numsource; j++) { + for (j=0; j<sys->heat.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; j<sys->heat.numsource; j++) - if(heat_source_closest(sys, vertex, j)) + for (j=0; j<sys->heat.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; a<sys->totface; a++, face++) { + for (a=0, face=sys->faces; a<sys->totface; 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; a<sys->totvert; a++) + for (a=0; a<sys->totvert; 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; a<totvert; a++) + for (a=0; a<totvert; a++) laplacian_add_vertex(sys, sys->heat.verts[a], 0); - for(a=0, mf=mface; a<totface; a++, mf++) { + for (a=0, mf=mface; a<totface; a++, mf++) { laplacian_add_triangle(sys, mf->v1, 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; a<totvert; a++) + for (a=0; a<totvert; a++) heat_set_H(sys, a); } @@ -639,10 +639,10 @@ static float heat_limit_weight(float weight) { float t; - if(weight < WEIGHT_LIMIT_END) { + if (weight < WEIGHT_LIMIT_END) { return 0.0f; } - else if(weight < WEIGHT_LIMIT_START) { + else if (weight < WEIGHT_LIMIT_START) { t= (weight - WEIGHT_LIMIT_END)/(WEIGHT_LIMIT_START - WEIGHT_LIMIT_END); return t*WEIGHT_LIMIT_START; } @@ -667,15 +667,15 @@ void heat_bone_weighting(Object *ob, Mesh *me, float (*verts)[3], int numsource, *err_str= NULL; /* count triangles and create mask */ - if( (use_face_sel= (me->editflag & 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; a<me->totvert; a++) + for (a=0; a<me->totvert; a++) vertsflipped[a] = mesh_get_x_mirror_vert(ob, a); } /* compute weights per bone */ - for(j=0; j<numsource; j++) { - if(!selected[j]) + for (j=0; j<numsource; j++) { + if (!selected[j]) continue; firstsegment= (j == 0 || dgrouplist[j-1] != dgrouplist[j]); @@ -731,13 +731,13 @@ void heat_bone_weighting(Object *ob, Mesh *me, float (*verts)[3], int numsource, bbone= !(firstsegment && lastsegment); /* clear weights */ - if(bbone && firstsegment) { - for(a=0; a<me->totvert; a++) { - if(mask && !mask[a]) + if (bbone && firstsegment) { + for (a=0; a<me->totvert; 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; a<me->totvert; a++) - if(heat_source_closest(sys, a, j)) + for (a=0; a<me->totvert; 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; a<me->totvert; a++) { - if(mask && !mask[a]) + for (a=0; a<me->totvert; 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; a<me->totvert; a++) { - if(mask && !mask[a]) + if (bbone && lastsegment) { + for (a=0; a<me->totvert; 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; a<sys->totvert; a++) - if(!sys->vpinned[a]) + for (a=0; a<sys->totvert; 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; f<totface; f++, mface++) { + for (f=0; f<totface; f++, mface++) { copy_v3_v3(face[0], mdb->cagecos[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; a<size*size*size; a++) - if(tag[a]==MESHDEFORM_TAG_UNTYPED) + for (a=0; a<size*size*size; a++) + if (tag[a]==MESHDEFORM_TAG_UNTYPED) tag[a]= MESHDEFORM_TAG_INTERIOR; #if 0 { int tb, ti, te, ts; tb= ti= te= ts= 0; - for(a=0; a<size*size*size; a++) - if(tag[a]==MESHDEFORM_TAG_BOUNDARY) + for (a=0; a<size*size*size; a++) + if (tag[a]==MESHDEFORM_TAG_BOUNDARY) tb++; - else if(tag[a]==MESHDEFORM_TAG_INTERIOR) + else if (tag[a]==MESHDEFORM_TAG_INTERIOR) ti++; - else if(tag[a]==MESHDEFORM_TAG_EXTERIOR) { + else if (tag[a]==MESHDEFORM_TAG_EXTERIOR) { te++; - if(mdb->semibound[a]) + if (mdb->semibound[a]) ts++; } @@ -1432,8 +1432,8 @@ static float meshdeform_boundary_phi(MeshDeformBind *UNUSED(mdb), MDefBoundIsect { int a; - for(a=0; a<isect->nvert; a++) - if(isect->v[a] == cagevert) + for (a=0; a<isect->nvert; 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; a<mdb->size3; a++) + for (a=0, totvar=0; a<mdb->size3; 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; z<mdb->size; z++) - for(y=0; y<mdb->size; y++) - for(x=0; x<mdb->size; x++) + for (z=0; z<mdb->size; z++) + for (y=0; y<mdb->size; y++) + for (x=0; x<mdb->size; x++) meshdeform_matrix_add_cell(mdb, x, y, z); /* solve for each cage vert */ - for(a=0; a<mdb->totcagevert; a++) { - if(a != 0) { + for (a=0; a<mdb->totcagevert; a++) { + if (a != 0) { nlBegin(NL_SYSTEM); nlBegin(NL_MATRIX); } /* fill in right hand side and solve */ - for(z=0; z<mdb->size; z++) - for(y=0; y<mdb->size; y++) - for(x=0; x<mdb->size; x++) + for (z=0; z<mdb->size; z++) + for (y=0; y<mdb->size; y++) + for (x=0; x<mdb->size; 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; z<mdb->size; z++) - for(y=0; y<mdb->size; y++) - for(x=0; x<mdb->size; x++) + if (nlSolveAdvanced(NULL, NL_TRUE)) { + for (z=0; z<mdb->size; z++) + for (y=0; y<mdb->size; y++) + for (x=0; x<mdb->size; x++) meshdeform_matrix_add_semibound_phi(mdb, x, y, z, a); - for(z=0; z<mdb->size; z++) - for(y=0; y<mdb->size; y++) - for(x=0; x<mdb->size; x++) + for (z=0; z<mdb->size; z++) + for (y=0; y<mdb->size; y++) + for (x=0; x<mdb->size; x++) meshdeform_matrix_add_exterior_phi(mdb, x, y, z, a); - for(b=0; b<mdb->size3; b++) { - if(mdb->tag[b] != MESHDEFORM_TAG_EXTERIOR) + for (b=0; b<mdb->size3; 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; b<mdb->totvert; b++) { - if(mdb->inside[b]) { + for (b=0; b<mdb->totvert; 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; b<mdb->size3; b++) { - if(mdb->phi[b] >= MESHDEFORM_MIN_INFLUENCE) { + for (b=0; b<mdb->size3; 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; b<mdb->size3; b++) - if(mdb->tag[b] != MESHDEFORM_TAG_EXTERIOR) - if(fabs(mdb->totalphi[b] - 1.0f) > 1e-4) + for (b=0; b<mdb->size3; 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; a<mdb->totcagevert; a++) + for (a=0; a<mdb->totcagevert; 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; a<mdb->totvert; a++) { + for (a=0; a<mdb->totvert; 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; a<mdb->size3; a++) + for (a=0; a<mdb->size3; a++) mdb->tag[a]= MESHDEFORM_TAG_UNTYPED; /* detect intersections and tag boundary cells */ - for(z=0; z<mdb->size; z++) - for(y=0; y<mdb->size; y++) - for(x=0; x<mdb->size; x++) + for (z=0; z<mdb->size; z++) + for (y=0; y<mdb->size; y++) + for (x=0; x<mdb->size; x++) meshdeform_add_intersections(mdb, x, y, z); /* compute exterior and interior tags */ meshdeform_bind_floodfill(mdb); - for(z=0; z<mdb->size; z++) - for(y=0; y<mdb->size; y++) - for(x=0; x<mdb->size; x++) + for (z=0; z<mdb->size; z++) + for (y=0; y<mdb->size; y++) + for (x=0; x<mdb->size; 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; a<mdb->size3; a++) - for(inf=mdb->dyngrid[a]; inf; inf=inf->next) + for (a=0; a<mdb->size3; 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; a<mdb->size3; a++) { + for (a=0; a<mdb->size3; 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; b<cell->totinfluence; b++, mdinf++) + for (b=0; b<cell->totinfluence; 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; a<totface; a++, mf++) { + for (tottri=0, a=0, mf=mface; a<totface; a++, mf++) { tottri++; - if(mf->v4) 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; j<mdb->totcagevert; j++) { + for (j=0; j<mdb->totcagevert; j++) { /* fill right hand side */ laplacian_begin_solve(sys, -1); - for(a=0; a<totvert; a++) - if(heat_source_closest(sys, a, j)) + for (a=0; a<totvert; 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; a<totvert; a++) { + for (a=0; a<totvert; a++) { solution= laplacian_system_get_solution(a); weight= heat_limit_weight(solution); - if(weight > 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; a<mdb.totcagevert; a++) + for (a=0; a<mdb.totcagevert; a++) copy_v3_v3(mdb.cagecos[a], mvert[a].co); - for(a=0; a<mdb.totvert; a++) + for (a=0; a<mdb.totvert; a++) mul_v3_m4v3(mdb.vertexcos[a], mdb.cagemat, vertexcos + a*3); /* solve */ #if 0 - if(mmd->mode == 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; a<mdb.totcagevert; a++) + for (a=0; a<mdb.totcagevert; a++) mul_m4_v3(mmd->object->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;a<num;a++) printf("knotu %d: %f\n", a, nu->knotsu[a]); + for (a=0;a<num;a++) printf("knotu %d: %f\n", a, nu->knotsu[a]); } - if(nu->knotsv) { + if (nu->knotsv) { num= KNOTSV(nu); - for(a=0;a<num;a++) printf("knotv %d: %f\n", a, nu->knotsv[a]); + for (a=0;a<num;a++) printf("knotv %d: %f\n", a, nu->knotsv[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; b<nu->pntsv; b++) { + for (b=0; b<nu->pntsv; 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; b<nu->pntsv; b++) { + for (b=0; b<nu->pntsv; b++) { sel= 0; - for(a=0; a<nu->pntsu; a++, bp++) { - if(bp->f1 & flag) sel++; + for (a=0; a<nu->pntsu; 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; a<nu->pntsu; a++) { + for (a=0; a<nu->pntsu; a++) { sel= 0; bp= nu->bp+a; - for(b=0; b<nu->pntsv; b++, bp+=nu->pntsu) { - if(bp->f1 & flag) sel++; + for (b=0; b<nu->pntsv; 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; b<nu->pntsv; b++) { + for (b=0; b<nu->pntsv; b++) { sel= 0; - for(a=0; a<nu->pntsu; a++, bp++) { - if(bp->f1 & flag) sel++; + for (a=0; a<nu->pntsu; 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; b<nu->pntsv; b++) { - if((bp->f1 & flag)==0) { + for (b=0; b<nu->pntsv; 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; a<nu->pntsu; a++) { + for (a=0; a<nu->pntsu; a++) { bp= nu->bp+a; sel= 0; - for(b=0; b<nu->pntsv; b++, bp+=nu->pntsu) { - if(bp->f1 & flag) sel++; + for (b=0; b<nu->pntsv; 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; b<nu->pntsv; b++) { - for(a=0; a<nu->pntsu; a++, bp++) { - if((bp->f1 & flag)==0) { + for (b=0; b<nu->pntsv; b++) { + for (a=0; a<nu->pntsu; 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; a<nu->pntsv; a++) { - if(v==0) { + for (a=0; a<nu->pntsv; 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; a<nu->pntsu; a++) { + for (a=0; a<nu->pntsu; 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; a<nu->pntsu; a++) { + for (a=0; a<nu->pntsu; 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; a<nu->pntsv; a++) { - for(b=0; b<nu->pntsu; b++, bp++) { - if(bp->f1 & flag) usel[b]++; + for (a=0; a<nu->pntsv; a++) { + for (b=0; b<nu->pntsu; b++, bp++) { + if (bp->f1 & flag) usel[b]++; } } newu= 0; newv= 0; - for(a=0; a<nu->pntsu; a++) { - if(usel[a]) { - if(newv==0 || usel[a]==newv) { + for (a=0; a<nu->pntsu; 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; a<nu->pntsv; a++) { - for(b=0; b<nu->pntsu; b++, bp1++) { - if(bp1->f1 & flag) { + for (a=0; a<nu->pntsv; a++) { + for (b=0; b<nu->pntsu; 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; a<nu->pntsu; a++, bezt++) { - if(bezt->f2 & SELECT) + for (nu= editnurb->first; nu; nu= nu->next) { + if (nu->bezt) { + for (bezt=nu->bezt, a=0; a<nu->pntsu; a++, bezt++) { + if (bezt->f2 & SELECT) bezt->weight= weight; } } - else if(nu->bp) { - for(bp=nu->bp, a=0; a<nu->pntsu*nu->pntsv; a++, bp++) { - if(bp->f1 & SELECT) + else if (nu->bp) { + for (bp=nu->bp, a=0; a<nu->pntsu*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; a<nu->pntsu; a++, bezt++) { - if(bezt->f2 & SELECT) + for (nu= editnurb->first; nu; nu= nu->next) { + if (nu->bezt) { + for (bezt=nu->bezt, a=0; a<nu->pntsu; a++, bezt++) { + if (bezt->f2 & SELECT) bezt->radius= radius; } } - else if(nu->bp) { - for(bp=nu->bp, a=0; a<nu->pntsu*nu->pntsv; a++, bp++) { - if(bp->f1 & SELECT) + else if (nu->bp) { + for (bp=nu->bp, a=0; a<nu->pntsu*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; a<nu->pntsu-1; a++, bezt++) { - if(bezt->f2 & SELECT) { - for(i=0; i<3; i++) { + for (bezt=nu->bezt+1, a=1; a<nu->pntsu-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; a<nu->pntsu-1; a++, bp++) { - if(bp->f1 & SELECT) { - for(i=0; i<3; i++) { + for (bp=nu->bp+1, a=1; a<nu->pntsu-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; a<nu->pntsu; a++, bezt++) { - if(bezt->f2 & SELECT) { + for (bezt=nu->bezt+last_sel, a=last_sel; a<nu->pntsu; 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; a<nu->pntsu; a++, bezt++) { - if((bezt->f2 & SELECT)==0) { + for (bezt=nu->bezt+(start_sel+1), a=start_sel+1; a<nu->pntsu; 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; a<nu->pntsu; a++, bp++) { - if(bp->f1 & SELECT) { + for (bp=nu->bp+last_sel, a=last_sel; a<nu->pntsu; 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; a<nu->pntsu; a++, bp++) { - if((bp->f1 & SELECT)==0) { + for (bp=nu->bp+(start_sel+1), a=start_sel+1; a<nu->pntsu; 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; a<nu->pntsv; a++) { - for(b=0; b<nu->pntsu; b++) { - if(bp->f1 & SELECT) { + for (a=0; a<nu->pntsv; a++) { + for (b=0; b<nu->pntsu; 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; a<nu->pntsv; a++) { - for(b=0; b<nu->pntsu; b++) { + for (a=0; a<nu->pntsv; a++) { + for (b=0; b<nu->pntsu; b++) { *bpn= *bp; keyIndex_updateBP(editnurb, bp, bpn, 1); bpn++; bp++; - if(b<nu->pntsu-1) { + if (b<nu->pntsu-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; a<nu->pntsv; a++) { + for (a=1; a<nu->pntsv; 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; a<nu->pntsv-1; a++) { - if(vsel[a]==nu->pntsu && vsel[a+1]==nu->pntsu) sel+=number_cuts; + for (a=0; a<nu->pntsv-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; a<nu->pntsv; a++) { - for(b=0; b<nu->pntsu; b++) { + for (a=0; a<nu->pntsv; a++) { + for (b=0; b<nu->pntsu; b++) { *bpn= *bp; keyIndex_updateBP(editnurb, bp, bpn, 1); bpn++; bp++; } - if( (a<nu->pntsv-1) && vsel[a]==nu->pntsu && vsel[a+1]==nu->pntsu ) { + if ( (a<nu->pntsv-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; b<nu->pntsu; b++) { + for (b=0; b<nu->pntsu; 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; a<nu->pntsu-1; a++) { - if(usel[a]==nu->pntsv && usel[a+1]==nu->pntsv) sel+=number_cuts; + for (a=0; a<nu->pntsu-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; a<nu->pntsv; a++) { - for(b=0; b<nu->pntsu; b++) { + for (a=0; a<nu->pntsv; a++) { + for (b=0; b<nu->pntsu; b++) { *bpn= *bp; keyIndex_updateBP(editnurb, bp, bpn, 1); bpn++; bp++; - if( (b<nu->pntsu-1) && usel[b]==nu->pntsv && usel[b+1]==nu->pntsv ) { + if ( (b<nu->pntsu-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; v<nu->pntsv; v++) { - for(u=0; u<nu->pntsu; u++, bp1++) { + for (v=0; v<nu->pntsv; v++) { + for (u=0; u<nu->pntsu; 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; v<nu->pntsv-1; v++, bp+=nu->pntsu) { - if(v) if(bp->f1 & SELECT) return 1; + for (v=0; v<nu->pntsv-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(dist<headdist) { + if (dist<headdist) { headdist= dist; headdo= nustest; } dist= len_v3v3(nustest->vec, ((NurbSort *)nsortbase.last)->vec); - if(dist<taildist) { + if (dist<taildist) { taildist= dist; taildo= nustest; } nustest= nustest->next; } - if(headdist<taildist) { + if (headdist<taildist) { BLI_remlink(&nbase, headdo); BLI_addhead(&nsortbase, headdo); } @@ -3732,23 +3766,23 @@ static void merge_2_nurb(wmOperator *op, ListBase *editnurb, Nurb *nu1, Nurb *nu /* first nurbs: u = resolu-1 selected */ - if( is_u_selected(nu1, nu1->pntsu-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; v<nu1->pntsv; v++, bp1+=nu1->pntsu, bp2+=nu2->pntsu) { + for (v=0; v<nu1->pntsv; 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; v<nu1->pntsv; v++, bp1+=nu1->pntsu, bp2-=nu2->pntsu) { + for (v=0; v<nu1->pntsv; 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->orderu<nu1->pntsu) nu1->orderu++; - if(nu1->orderv<3 && nu1->orderv<nu1->pntsv) nu1->orderv++; + if (nu1->orderu<3 && nu1->orderu<nu1->pntsu) nu1->orderu++; + if (nu1->orderv<3 && nu1->orderv<nu1->pntsv) nu1->orderv++; temp= nu1->bp; nu1->bp= MEM_mallocN(nu1->pntsu*nu1->pntsv*sizeof(BPoint), "mergeBP"); bp= nu1->bp; bp1= temp; - for(v=0; v<nu1->pntsv; v++) { + for (v=0; v<nu1->pntsv; v++) { /* switch direction? */ - if(len1<len2) bp2= nu2->bp + v*nu2->pntsu; + if (len1<len2) bp2= nu2->bp + v*nu2->pntsu; else bp2= nu2->bp + (nu1->pntsv-v-1)*nu2->pntsu; - for(u=0; u<nu1->pntsu; u++, bp++) { - if(u<origu) { + for (u=0; u<nu1->pntsu; u++, bp++) { + if (u<origu) { *bp= *bp1; bp1++; select_bpoint(bp, SELECT, 1, HIDDEN); } @@ -3829,7 +3863,7 @@ static void merge_2_nurb(wmOperator *op, ListBase *editnurb, Nurb *nu1, Nurb *nu } } - if(nu1->type == 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; a<nu2->pntsu; a++, fp++) { - if(nu2->knotsu) + for (a=0; a<nu2->pntsu; 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; v<nu->pntsv; v++) { - for(u=0; u<nu->pntsu; u++, bp++) { - if(bp==cu->lastsel) { - if(bp->f1 & SELECT) { + for (v=0; v<nu->pntsv; v++) { + for (u=0; u<nu->pntsu; 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; a<nu->pntsv; a++) { - for(b=0; b<nu->pntsu; b++, bp++) { - if(direction) { - if(a==v) select_bpoint(bp, SELECT, 1, VISIBLE); + for (a=0; a<nu->pntsv; a++) { + for (b=0; b<nu->pntsu; 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;a<nu->pntsu;a++) { - if( BEZSELECTED_HIDDENHANDLES(cu, bezt) ) { + for (a=0;a<nu->pntsu;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;a<nu->pntsu;a++) { - if( bp->f1 & SELECT ) { + for (a=0;a<nu->pntsu;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; a<nu->pntsu-1; a++) { - if( BEZSELECTED_HIDDENHANDLES(cu, bezt) ) { + for (a=0; a<nu->pntsu-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; a<nu->pntsu-1; a++) { - if( bp->f1 & SELECT ) { + for (a=0; a<nu->pntsu-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->len<MAXTEXT-1) { + if (cu->len<MAXTEXT-1) { EditFont *ef= cu->editfont; 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+filelen<MAXTEXT) { + if (cu->len+filelen<MAXTEXT) { int tmplen; wchar_t *mem = MEM_callocN((sizeof(wchar_t)*filelen)+(4*sizeof(wchar_t)), "temporary"); tmplen = BLI_strncpy_wchar_from_utf8(mem, strp, filelen + 1); @@ -398,7 +398,7 @@ static int paste_file_exec(bContext *C, wmOperator *op) static int paste_file_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { - if(RNA_struct_property_is_set(op->ptr, "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->len<MAXTEXT && a<totline; tmp=tmp->next, a++) + for (tmp=firstline, a=0; cu->len<MAXTEXT && a<totline; tmp=tmp->next, 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->len<MAXTEXT && a<totline; tmp=tmp->next, a++) { + for (tmp=firstline, a=0; cu->len<MAXTEXT && a<totline; tmp=tmp->next, 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->pos<cu->len) { - 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->pos<cu->len) { + 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;x<cu->len;x++) + for (x=cu->pos;x<cu->len;x++) ef->textbuf[x]= ef->textbuf[x+1]; - for(x=cu->pos;x<cu->len;x++) + for (x=cu->pos;x<cu->len;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; a<len; a++) + for (a=0; a<len; a++) insert_into_textbuf(obedit, inserted_text[a]); MEM_freeN(inserted_text); @@ -1223,28 +1223,28 @@ static int insert_text_invoke(bContext *C, wmOperator *op, wmEvent *evt) int event= evt->type, 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->len<MAXTEXT-1) { - if(alt) { + else if (cu->len<MAXTEXT-1) { + if (alt) { /* might become obsolete, apple has default values for this, other OS's too? */ - 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; + 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<<i; prec_min= i; } @@ -482,12 +482,12 @@ static int ui_but_float_precision(uiBut *but, double value) dec_flag= (dec_flag >> (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; a<tot; a++) + for (a=0; a<tot; a++) vec[a]= RNA_property_float_get_index(&but->rnapoin, 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 && slen<UI_MAX_NAME_STR-2) { - if(but->str[slen-1]!=' ') { + if (slen>0 && slen<UI_MAX_NAME_STR-2) { + if (but->str[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; i<totitem; i++) { - if(!item[i].identifier[0]) { - if(item[i].name) + for (i=0; i<totitem; i++) { + if (!item[i].identifier[0]) { + if (item[i].name) BLI_dynstr_appendf(dynstr, "|%s%%l", item[i].name); else BLI_dynstr_append(dynstr, "|%l"); } - else if(item[i].icon) + else if (item[i].icon) BLI_dynstr_appendf(dynstr, "|%s %%i%d %%x%d", item[i].name, item[i].icon, item[i].value); else BLI_dynstr_appendf(dynstr, "|%s %%x%d", item[i].name, item[i].value); - if(value == item[i].value) + if (value == item[i].value) icon= item[i].icon; } str= BLI_dynstr_get_cstring(dynstr); @@ -2688,13 +2688,13 @@ static uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, const char *s freestr= 1; } - else if(ELEM(type, ROW, LISTROW) && proptype == PROP_ENUM) { + else if (ELEM(type, ROW, LISTROW) && proptype == PROP_ENUM) { EnumPropertyItem *item; int i, totitem, free; RNA_property_enum_items_gettexted(block->evil_C, ptr, prop, &item, &totitem, &free); - for(i=0; i<totitem; i++) { - if(item[i].identifier[0] && item[i].value == (int)max) { + for (i=0; i<totitem; i++) { + if (item[i].identifier[0] && item[i].value == (int)max) { str= item[i].name; icon= item[i].icon; } @@ -2713,44 +2713,44 @@ static uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, const char *s } } - if(!tip && proptype != PROP_ENUM) + if (!tip && proptype != PROP_ENUM) tip= RNA_property_ui_description(prop); - if(min == max || a1 == -1 || a2 == -1) { - if(proptype == PROP_INT) { + if (min == max || a1 == -1 || a2 == -1) { + if (proptype == PROP_INT) { int hardmin, hardmax, softmin, softmax, step; RNA_property_int_range(ptr, prop, &hardmin, &hardmax); RNA_property_int_ui_range(ptr, prop, &softmin, &softmax, &step); - if(!ELEM(type, ROW, LISTROW) && min == max) { + if (!ELEM(type, ROW, LISTROW) && min == max) { min= hardmin; max= hardmax; } - if(a1 == -1) + if (a1 == -1) a1= step; - if(a2 == -1) + if (a2 == -1) a2= 0; } - else if(proptype == PROP_FLOAT) { + else if (proptype == PROP_FLOAT) { float hardmin, hardmax, softmin, softmax, step, precision; RNA_property_float_range(ptr, prop, &hardmin, &hardmax); RNA_property_float_ui_range(ptr, prop, &softmin, &softmax, &step, &precision); - if(!ELEM(type, ROW, LISTROW) && min == max) { + if (!ELEM(type, ROW, LISTROW) && min == max) { min= hardmin; max= hardmax; } - if(a1 == -1) + if (a1 == -1) a1= step; - if(a2 == -1) + if (a2 == -1) a2= precision; } - else if(proptype == PROP_STRING) { + else if (proptype == PROP_STRING) { min= 0; max= RNA_property_string_maxlength(prop); - if(max == 0) /* interface code should ideally support unlimited length */ + if (max == 0) /* interface code should ideally support unlimited length */ max= UI_MAX_DRAW_STR; } } @@ -2761,12 +2761,12 @@ static uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, const char *s but->rnapoin= *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; a<autocpl->maxlen-1; a++) { - if(startname[a]==0 || startname[a]!=name[a]) + for (a=0; a<autocpl->maxlen-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; a<autocpl->maxlen-1; a++) { - if(name[a] == 0) { + for (a=0; a<autocpl->maxlen-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; a<coba->tot; a++, cbd++) { + for (a=0; a<coba->tot; 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; a<cuma->totpoint; a++) { - if(cmp[a].flag & SELECT) + for (a=0; a<cuma->totpoint; 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; y<height; y++) { + for (y= 0; y<height; y++) { for (x= 0; x<width; x++) { float src_x= scalex*(x)+margin-off_x; float src_y= scaley*(y)+margin-off_y; @@ -1506,14 +1506,14 @@ void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wc glGetIntegerv(GL_VIEWPORT, scissor); glScissor(ar->winrct.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' && i<UI_MAX_DRAW_STR) { buf[i++]=*p; @@ -1121,8 +1123,8 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data, /* numeric value */ if ELEM4(but->type, 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' && i<UI_MAX_DRAW_STR-1) { @@ -1560,8 +1562,8 @@ static int ui_textedit_copypaste(uiBut *but, uiHandleButtonData *data, int paste for (y=0; y<strlen(buf); y++) { /* add contents of buffer */ - if(len+1 < data->maxlen) { - 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<temp) temp--; + if (!ui_is_but_float(but)) { + if (f<temp) temp--; else temp++; - if(temp>=softmin && temp<=softmax) + if (temp>=softmin && temp<=softmax) data->value= temp; else data->cancel= 1; } else { - if(f<tempf) tempf -= 0.01f; + if (f<tempf) tempf -= 0.01f; else tempf += 0.01f; - if(tempf>=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; a<coba->tot; a++, cbd++) { + for (a=0, cbd= coba->data; a<coba->tot; 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(xco<mindist) { + if (a==coba->cur) xco+= 5; // selected one disadvantage + if (xco<mindist) { coba->cur= 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; a<cuma->totpoint; a++) { - if(cmp[a].flag & SELECT) { + for (a=0; a<cuma->totpoint; 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; a<cuma->totpoint; a++) { + for (a=0; a<cuma->totpoint; 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; a<cuma->totpoint; a++) - if(cmp[a].x == fx) + for (a=0; a<cuma->totpoint; 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; a<cuma->totpoint; a++) + if (event->shift == FALSE) { + for (a=0; a<cuma->totpoint; 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; a<cuma->totpoint; a++) + if (event->shift == FALSE) { + for (a=0; a<cuma->totpoint; 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, "<blender icons>"); - 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; y<ICON_GRID_ROWS; y++) { for (x=0; x<ICON_GRID_COLS; x++) { def_internal_icon(bbuf, BIFICONID_FIRST + y*ICON_GRID_COLS + x, @@ -604,21 +604,21 @@ static void init_iconfile_list(struct ListBase *list) list->first = 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; i<totfile; i++) { - if( (dir[i].type & S_IFREG) ) { + for (i=0; i<totfile; i++) { + if ( (dir[i].type & S_IFREG) ) { char *filename = dir[i].relname; - if(BLI_testextensie(filename, ".png")) { + if (BLI_testextensie(filename, ".png")) { /* loading all icons on file start is overkill & slows startup * its possible they change size after blender load anyway. */ #if 0 @@ -631,7 +631,7 @@ static void init_iconfile_list(struct ListBase *list) BLI_join_dirfile(iconfilestr, sizeof(iconfilestr), icondir, filename); bbuf= IMB_loadiffname(iconfilestr, IB_rect); - if(bbuf) { + if (bbuf) { ifilex = bbuf->x; 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; i<len; i++) - if(i != index) + for (i=0; i<len; i++) + if (i != index) RNA_property_boolean_set_index(ptr, prop, i, 0); RNA_property_update(C, ptr, prop); - for(cbut=but->block->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; b<cols; b++) { + for (b=0; b<cols; b++) { uiBlockBeginAlign(block); - for(a=0; a<colbuts; a++) { - if(layer_used & (1<<(a+b*colbuts))) icon= ICON_LAYER_USED; + for (a=0; a<colbuts; a++) { + if (layer_used & (1<<(a+b*colbuts))) icon= ICON_LAYER_USED; else icon= ICON_BLANK1; but = uiDefAutoButR(block, ptr, prop, a+b*colbuts, "", icon, x + butw*a, y+buth, butw, buth); - if(subtype == PROP_LAYER_MEMBER) + if (subtype == PROP_LAYER_MEMBER) uiButSetFunc(but, ui_layer_but_cb, but, SET_INT_IN_POINTER(a+b*colbuts)); } - for(a=0; a<colbuts; a++) { - if(layer_used & (1<<(a+len/2+b*colbuts))) icon= ICON_LAYER_USED; + for (a=0; a<colbuts; a++) { + if (layer_used & (1<<(a+len/2+b*colbuts))) icon= ICON_LAYER_USED; else icon= ICON_BLANK1; but = uiDefAutoButR(block, ptr, prop, a+len/2+b*colbuts, "", icon, x + butw*a, y, butw, buth); - if(subtype == PROP_LAYER_MEMBER) + if (subtype == PROP_LAYER_MEMBER) uiButSetFunc(but, ui_layer_but_cb, but, SET_INT_IN_POINTER(a+len/2+b*colbuts)); } uiBlockEndAlign(block); @@ -405,7 +405,7 @@ static void ui_item_array(uiLayout *layout, uiBlock *block, const char *name, in x += colbuts*butw + style->buttonspacex; } } - 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; a<len; a++) { + for (a=0; a<len; a++) { col= a % dim_size[0]; row= a / dim_size[0]; but = uiDefAutoButR(block, ptr, prop, a, "", ICON_NONE, x + w*col, y+(dim_size[1]*UI_UNIT_Y)-(row*UI_UNIT_Y), w, UI_UNIT_Y); - if(slider && but->type==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; a<len; a++) { - if(!icon_only) str[0]= RNA_property_array_item_char(prop, a); - if(boolarr) icon= boolarr[a] ? ICON_CHECKBOX_HLT: ICON_CHECKBOX_DEHLT; + for (a=0; a<len; a++) { + if (!icon_only) str[0]= RNA_property_array_item_char(prop, a); + if (boolarr) icon= boolarr[a] ? ICON_CHECKBOX_HLT: ICON_CHECKBOX_DEHLT; but = uiDefAutoButR(block, ptr, prop, a, str, icon, 0, 0, w, UI_UNIT_Y); - 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(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; a<totitem; a++) { - if(!item[a].identifier[0]) + for (a=0; a<totitem; a++) { + if (!item[a].identifier[0]) continue; name= (!uiname || uiname[0])? item[a].name: ""; @@ -495,14 +495,14 @@ static void ui_item_enum_expand(uiLayout *layout, uiBlock *block, PointerRNA *pt value= item[a].value; itemw= ui_text_icon_width(block->curlayout, 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; i<totitem; i++) { - if(item[i].identifier[0]) { - if(properties) { + for (i=0; i<totitem; i++) { + if (item[i].identifier[0]) { + if (properties) { PointerRNA tptr; WM_operator_properties_create_ptr(&tptr, ot); - if(tptr.data) { + if (tptr.data) { IDP_FreeProperty(tptr.data); MEM_freeN(tptr.data); } @@ -823,8 +823,8 @@ void uiItemsFullEnumO(uiLayout *layout, const char *opname, const char *propname } } else { - if(item[i].name) { - if(i != 0) { + if (item[i].name) { + if (i != 0) { column= uiLayoutColumn(split, 0); /* inconsistent, but menus with labels do not look good flipped */ block->flag |= 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; i<totitem; i++) { - if(item[i].identifier[0]) { + for (i=0; i<totitem; i++) { + if (item[i].identifier[0]) { uiItemEnumR(column, item[i].name, ICON_NONE, ptr, propname, item[i].value); } else { - if(item[i].name) { - if(i != 0) { + if (item[i].name) { + if (i != 0) { column= uiLayoutColumn(split, 0); /* inconsistent, but menus with labels do not look good flipped */ block->flag |= 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; a<tot; a++, ps++) + for (ps=panelsort, a=0; a<tot; a++, ps++) ps->orig->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; a<tot-1; a++, ps++) { + for (a=0; a<tot-1; a++, ps++) { psnext= ps+1; - if(align==BUT_VERTICAL) { + if (align==BUT_VERTICAL) { psnext->pa->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; a<tot; a++, ps++) { - if((ps->pa->flag & PNL_SELECT)==0) { - if((ps->orig->ofsx != ps->pa->ofsx) || (ps->orig->ofsy != ps->pa->ofsy)) { + for (a=0; a<tot; a++, ps++) { + if ((ps->pa->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(; i<md->nitems-1; i++) { - if(md->items[i+1].retval != -1) { + for (; i<md->nitems-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; i<totitem; i++) { - if(item[i].identifier[0] && item[i].value == value) { - if(item[i].description && item[i].description[0]) { + for (i=0; i<totitem; i++) { + if (item[i].identifier[0] && item[i].value == value) { + if (item[i].description && item[i].description[0]) { BLI_snprintf(data->lines[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; a<data->totline; a++) { + for (a=0, fontw=0, fonth=0; a<data->totline; 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; a<data->items.totitem; a++) { + for (a=0; a<data->items.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; a<data->items.totitem; a++) { + for (a=0; a<data->items.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; a<data->items.totitem; a++) { + for (a=0; a<data->items.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; a<data->items.totitem; a++) { + for (a=0; a<data->items.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; x1<data->items.maxitem; x1++) + for (x1=0; x1<data->items.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; x1<items->maxitem; x1++) + for (x1=0; x1<items->maxitem; 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; x1<items->totitem; x1++) - if(strcmp(but->drawstr, items->names[x1])==0) + else if (items->more==0) { + for (x1= 0; x1<items->totitem; 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*columns<md->nitems) + while (rows*columns<md->nitems) 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; a<md->nitems; a++, entry++) { - if(entry->sepr && entry->str[0]) { + for (a=0; a<md->nitems; 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; a<md->nitems; a++) { - if(a == column_end) { + for (a=0; a<md->nitems; 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; b<md->nitems; b++) { + for (b=a+1; b<md->nitems; 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; a<md->nitems; a++) { + for (a=0; a<md->nitems; 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; a<coba->tot; a++) { + for (a=0; a<coba->tot; a++) { data_tmp[a]= coba->data[coba->tot - (a + 1)]; } - for(a=0; a<coba->tot; a++) { + for (a=0; a<coba->tot; 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; a<CM_TOT; a++) + for (a=0; a<CM_TOT; a++) curvemap_reset(cumap->cm+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 <none>", 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 && i<pa->list_scroll+items) + if (i >= pa->list_scroll && i<pa->list_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; a<totvert; a++) { + for (a=0; a<totvert; a++) { copy_v2_v2(quad_strip[a*2], wtb->outer_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; a<totvert; a++) { + for (a=0; a<totvert; a++) { quad_strip[a*2][0]= wtb->outer_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; a<wtb->totvert; a++) { + for (a=0; a<wtb->totvert; 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; a<wtb->totvert; a++) { + for (a=0; a<wtb->totvert; 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; a<wtb->totvert; a++, col_pt += 4) { + for (a=0; a<wtb->totvert; 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(; start<v2d->cur.xmax; start+=step) { + for (; start<v2d->cur.xmax; start+=step) { glVertex2f(start, v2d->cur.ymin); glVertex2f(start, v2d->cur.ymax); } start= v2d->cur.ymin - (float)fmod(v2d->cur.ymin, step); - for(; start<v2d->cur.ymax; start+=step) { + for (; start<v2d->cur.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; a<me->totpoly; a++, mf++) { - if(mf->flag & ME_HIDE); - else if(mf->flag & ME_FACE_SEL) { + for (a=0; a<me->totpoly; 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; a<me->totpoly; a++, mf++) { - if(mf->flag & ME_HIDE) + for (a=0; a<me->totpoly; 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; a<me->totpoly; a++, mf++) - if(linkflag[a]) + if (mode==0 || mode==2) { + for (a=0, mf=me->mpoly; a<me->totpoly; 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; a<me->totpoly; a++, mf++) - if(linkflag[a] && (mf->flag & ME_FACE_SEL)) + else if (mode==1) { + for (a=0, mf=me->mpoly; a<me->totpoly; a++, mf++) + if (linkflag[a] && (mf->flag & ME_FACE_SEL)) break; if (a<me->totpoly) { - for(a=0, mf=me->mpoly; a<me->totpoly; a++, mf++) - if(linkflag[a]) + for (a=0, mf=me->mpoly; a<me->totpoly; a++, mf++) + if (linkflag[a]) mf->flag &= ~ME_FACE_SEL; } else { - for(a=0, mf=me->mpoly; a<me->totpoly; a++, mf++) - if(linkflag[a]) + for (a=0, mf=me->mpoly; a<me->totpoly; 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; i<totvert; i++, dm_mv++) { orig_index= index_array[i]; - if(orig_index != ORIGINDEX_NONE) { + if (orig_index != ORIGINDEX_NONE) { dm_mv->flag= 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; a<me->totedge; a++, medge++) { + for (a=0, medge=me->medge; a<me->totedge; 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; a<totvert; a++) { + for (a=1; a<totvert; a++) { if (topo_hash_prev[a-1] != topo_hash_prev[a]) { tot_unique++; } @@ -879,14 +879,14 @@ void ED_mesh_mirrtopo_init(Mesh *me, const int ob_mode, MirrTopoStore_t *mesh_to /* since we are looping through verts, initialize these values here too */ index_lookup = MEM_mallocN(totvert * sizeof(*index_lookup), "mesh_topo_lookup"); - if(em) { + if (em) { if (skip_em_vert_array_init == FALSE) { EDBM_init_index_arrays(em,1, 0, 0); } } - for(a=0; a<totvert; a++) { + for (a=0; a<totvert; a++) { topo_pairs[a].hash = topo_hash[a]; topo_pairs[a].v_index = a; @@ -901,11 +901,11 @@ void ED_mesh_mirrtopo_init(Mesh *me, const int ob_mode, MirrTopoStore_t *mesh_to /* Get the pairs out of the sorted hashes, note, totvert+1 means we can use the previous 2, * but you cant ever access the last 'a' index of MirrTopoPairs */ - for(a=2; a <= totvert; a++) { + for (a=2; a <= totvert; a++) { /* printf("I %d %ld %d\n", (a-last), MirrTopoPairs[a ].hash, MirrTopoPairs[a ].v_index ); */ if ((a==totvert) || (topo_pairs[a-1].hash != topo_pairs[a].hash)) { if (a-last==2) { - if(em) { + if (em) { index_lookup[topo_pairs[a-1].v_index] = (intptr_t)EDBM_get_vert_for_index(em, topo_pairs[a-2].v_index); index_lookup[topo_pairs[a-2].v_index] = (intptr_t)EDBM_get_vert_for_index(em, topo_pairs[a-1].v_index); } @@ -917,7 +917,7 @@ void ED_mesh_mirrtopo_init(Mesh *me, const int ob_mode, MirrTopoStore_t *mesh_to last = a; } } - if(em) { + if (em) { if (skip_em_vert_array_init == FALSE) { EDBM_free_index_arrays(em); } diff --git a/source/blender/editors/mesh/editmesh_add.c b/source/blender/editors/mesh/editmesh_add.c index 74160b3f2de..d816d33c9df 100644 --- a/source/blender/editors/mesh/editmesh_add.c +++ b/source/blender/editors/mesh/editmesh_add.c @@ -98,7 +98,9 @@ static void make_prim_init(bContext *C, const char *idname, ED_object_enter_editmode(C, EM_DO_UNDO|EM_IGNORE_LAYER); /* rare cases the active layer is messed up */ *state = 1; } - else DAG_id_tag_update(&obedit->id, 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; i<len; i++, mvert++) + for (i=0; i<len; i++, mvert++) mvert->flag |= 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; i<len; i++, medge++) + for (i=0; i<len; i++, medge++) medge->flag= 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; i<len; i++, mface++) + for (i=0; i<len; i++, mface++) mface->flag= 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; i<len; i++, mpoly++) + for (i=0; i<len; i++, mpoly++) mpoly->flag= 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; i<nfaces; i++) { + for (i= 0; i<nfaces; i++) { MFace *mf= &mface[i]; - if(mf->v4) + 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; i<curnverts; i++) { + for (i= 0; i<curnverts; i++) { MVert *v= &mvert[i]; copy_v3_v3(co, v->co); @@ -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; i<curnfaces; i++) { + for (i= 0; i<curnfaces; i++) { MFace *mf= &mface[i]; tri[0]= basenverts + mf->v1; @@ -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; i<nverts; i++) { + for (i= 0; i<nverts; i++) { v= &verts[3*i]; co[0]= bmin[0] + v[0]*cs; co[1]= bmin[1] + v[1]*ch; @@ -351,7 +351,7 @@ static Object *createRepresentation(bContext *C, struct recast_polyMesh *pmesh, dverts= recast_polyMeshDetailGetVerts(dmesh, NULL); tris= recast_polyMeshDetailGetTris(dmesh, NULL); - for(i= 0; i<nmeshes; i++) { + for (i= 0; i<nmeshes; i++) { int uniquevbase= em->bm->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; j<ndv; j++) { + for (j= nv; j<ndv; j++) { copy_v3_v3(co, &dverts[3*(vbase + j)]); SWAP(float, co[1], co[2]); BM_vert_create(em->bm, 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; j<trinum; j++) { + for (j= 0; j<trinum; j++) { unsigned char *tri= &tris[4*(tribase+j)]; BMFace *newFace; int *polygonIdx; - for(k= 0; k<3; k++) { - if(tri[k]<nv) + for (k= 0; k<3; k++) { + if (tri[k]<nv) face[k] = p[tri[k]]; /* shared vertex */ else face[k] = uniquevbase+tri[k]-nv; /* unique vertex */ @@ -410,7 +410,7 @@ static Object *createRepresentation(bContext *C, struct recast_polyMesh *pmesh, ED_object_exit_editmode(C, EM_FREEDATA); WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, obedit); - if(createob) { + if (createob) { obedit->gameflag&= ~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; i<numfaces; i++) { - if(indices[i]==freeIdx) + for (i = 0; i<numfaces; i++) { + if (indices[i]==freeIdx) freeIdx++; - else if(indices[i]>freeIdx) + 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; a<ob->totcol; a++) { + for (a=0; a<ob->totcol; 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; b<totcol; b++) { - if(ma == matar[b]) break; + for (b=0; b<totcol; b++) { + if (ma == matar[b]) break; } - if(b==totcol) { + if (b==totcol) { matar[b]= ma; - if(ma) { + if (ma) { id_us_plus(&ma->id); } 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; i<me->totvert; i++) { - for(j=0; j<dvert[i].totweight; j++) { + if (dvert) { + for (i=0; i<me->totvert; i++) { + for (j=0; j<dvert[i].totweight; j++) { /* Find the old vertex group */ odg = BLI_findlink(&base->object->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; a<me->totedge; a++, medge++) { + for (a=0; a<me->totedge; 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; a<me->totloop; a++, mloop++) { + for (a=0; a<me->totloop; 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; b<totcol; b++) { - if(ma == matar[b]) { + for (b=0; b<totcol; b++) { + if (ma == matar[b]) { matmap[a-1]= b; break; } @@ -444,7 +444,7 @@ int join_mesh_exec(bContext *C, wmOperator *op) CustomData_merge(&me->pdata, &pdata, CD_MASK_MESH, CD_DEFAULT, totpoly); CustomData_copy_data(&me->pdata, &pdata, 0, polyofs, me->totpoly); - for(a=0; a<me->totpoly; a++, mpoly++) { + for (a=0; a<me->totpoly; 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; a<MOC_NODE_RES; a++) { - if((*bt)->index[a]==index) + for (a=0; a<MOC_NODE_RES; a++) { + if ((*bt)->index[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; a<MOC_NODE_RES; a++) { - if((*bt)->index[a]) { + for (a=0; a<MOC_NODE_RES; a++) { + if ((*bt)->index[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; a<me->totvert; a++, mvert++) + for (a=0, mvert= me->mvert; a<me->totvert; 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; a<me->totvert; a++, mvert++) + for (a=0, mvert= me->mvert; a<me->totvert; 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; a<MOC_RES*MOC_RES*MOC_RES; a++, bt++) { - if(*bt) mesh_octree_free_node(bt); + for (a=0, bt=MeshOctree.table; a<MOC_RES*MOC_RES*MOC_RES; a++, bt++) { + if (*bt) mesh_octree_free_node(bt); } MEM_freeN(MeshOctree.table); MeshOctree.table= NULL; @@ -871,15 +871,15 @@ MirrTopoStore_t mesh_topo_store= {NULL, -1. -1, -1}; /* note, is supposed return -1 on error, which callers are currently checking for, but is not used so far */ int mesh_mirrtopo_table(Object *ob, char mode) { - if(mode=='u') { /* use table */ + if (mode=='u') { /* use table */ if (ED_mesh_mirrtopo_recalc_check(ob->data, 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; a<me->totvert; a++, mv++) + for (a=0, mv=mvert; a<me->totvert; 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; a<me->totface; a++, mf++) + for (a=0, mf=mface; a<me->totface; a++, mf++) BLI_ghash_insert(fhash, mf, mf); - for(a=0, mf=mface; a<me->totface; a++, mf++) { + for (a=0, mf=mface; a<me->totface; 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; a<hits; a++) { + while (ml) { + for (a=0; a<hits; a++) { /* index converted for gl stuff */ - if(ml->selcol1==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; a<MAX_MTEX; a++) { - if(ma->mtex[a]) { + if (dupflag & USER_DUP_TEX) { + for (a=0; a<MAX_MTEX; a++) { + if (ma->mtex[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; a<newob->totcol; a++) id_us_plus((ID *)me->mat[a]); + for (a=0; a<newob->totcol; 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; a<obn->totcol; a++) { + if (dupflag & USER_DUP_MAT) { + for (a=0; a<obn->totcol; 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; a<obn->totcol; a++) { + if (matarar) { + for (a=0; a<obn->totcol; 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<w && y>=0 && y<h) { - if((bake_rast->texels[y*w+x])==0) { + if (x>=0 && x<w && y>=0 && y<h) { + if ((bake_rast->texels[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; y<y1; y++) { + for (y= y0; y<y1; y++) { /*-b(x-x0) + a(y-y0) = 0 */ int iXl, iXr, x; float x_l= s_stable!=0 ? (s0_s + (((s1_s-s0_s)*(y-t0_s))/(t1_s-t0_s))) : s0_s; float x_r= l_stable!=0 ? (s0_l + (((s1_l-s0_l)*(y-t0_l))/(t1_l-t0_l))) : s0_l; - if(is_mid_right!=0) + if (is_mid_right!=0) SWAP(float, x_l, x_r); iXl= (int)ceilf(x_l); iXr= (int)ceilf(x_r); - if(iXr>0 && iXl<w) { + if (iXr>0 && iXl<w) { iXl= iXl<0?0:iXl; iXr= iXr>=w?w:iXr; - for(x= iXl; x<iXr; x++) + for (x= iXl; x<iXr; x++) set_rast_triangle(bake_rast, x, y); } } @@ -318,19 +321,20 @@ static void bake_rasterize(const MBakeRast *bake_rast, const float st0_in[2], co int is_mid_right= 0, ylo, yhi, yhi_beg; /* skip degenerates */ - if((slo==smi && tlo==tmi) || (slo==shi && tlo==thi) || (smi==shi && tmi==thi)) + if ((slo==smi && tlo==tmi) || (slo==shi && tlo==thi) || (smi==shi && tmi==thi)) return; /* sort by T */ - if(tlo>tmi && 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; f<tot_face; f++) { + for (f= 0; f<tot_face; f++) { MTFace *mtfate= &mtface[f]; int verts[3][2], nr_tris, t; - if(multiresbake_test_break(bkr)) + if (multiresbake_test_break(bkr)) break; - if(mtfate->tpage!=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; t<nr_tris; t++) { + for (t= 0; t<nr_tris; t++) { data.i0 = verts[0][t]; data.i1 = verts[1][t]; data.i2 = verts[2][t]; @@ -428,17 +432,17 @@ static void do_multires_bake(MultiresBakeRender *bkr, Image* ima, MPassKnownData bkr->baked_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; x<ibuf->x; x++) { - for(y =0; y<ibuf->y; y++) { + for (x= 0; x<ibuf->x; x++) { + for (y =0; y<ibuf->y; 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(len<height_data->height_min) height_data->height_min= len; - if(len>height_data->height_max) height_data->height_max= len; + if (len<height_data->height_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; a<totface; a++) + for (a= 0; a<totface; a++) mtface[a].tpage->id.flag&= ~LIB_DOIT; - for(a= 0; a<totface; a++) { + for (a= 0; a<totface; a++) { Image *ima= mtface[a].tpage; - if((ima->id.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; a<totface; a++) + for (a= 0; a<totface; a++) mtface[a].tpage->id.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; a<totface; a++) + for (a= 0; a<totface; a++) mtface[a].tpage->id.flag&= ~LIB_DOIT; - for(a= 0; a<totface; a++) { + for (a= 0; a<totface; a++) { Image *ima= mtface[a].tpage; - if((ima->id.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; a<totface; a++) + for (a= 0; a<totface; a++) mtface[a].tpage->id.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; b<MAX_MTEX; b++) { - if(ma->mtex[b] && ma->mtex[b]->tex) { + if (ma) { + for (b=0; b<MAX_MTEX; b++) { + if (ma->mtex[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(index<hmd->totindex-1) index++; + if (index<hmd->totindex-1) index++; } nr++; - if(nr == hmd->indexar[index]) { + if (nr == hmd->indexar[index]) { bezt->f2 |= SELECT; - if(index<hmd->totindex-1) index++; + if (index<hmd->totindex-1) index++; } nr++; - if(nr == hmd->indexar[index]) { + if (nr == hmd->indexar[index]) { bezt->f3 |= SELECT; - if(index<hmd->totindex-1) index++; + if (index<hmd->totindex-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(index<hmd->totindex-1) index++; + if (index<hmd->totindex-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(temp<data->dist) { + if (temp<data->dist) { 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; a<totpart; a++) { + for (a=0; a<totpart; a++) { key= cache[a]; - if(key->steps > 0) { + if (key->steps > 0) { totvert+= key->steps+1; totedge+= key->steps; } } cache= psys->childcache; - for(a=0; a<totchild; a++) { + for (a=0; a<totchild; a++) { key= cache[a]; - if(key->steps > 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; a<totpart; a++) { + for (a=0; a<totpart; a++) { key= cache[a]; kmax= key->steps; - 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; a<totchild; a++) { + for (a=0; a<totchild; a++) { key=cache[a]; kmax=key->steps; - 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<<a)); RNA_boolean_set_array(op->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; a<ob->totcol; a++) { + for (a=0; a<ob->totcol; 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; a<totcol; a++) { + for (a=0; a<totcol; a++) { id= (ID *)matar[a]; - if(id && id->lib == 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; a<MAX_MTEX; a++) { - if(la->mtex[a]) { + for (a=0; a<MAX_MTEX; a++) { + if (la->mtex[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; b<MAX_MTEX; b++) { - if(ma->mtex[b] && (tex= ma->mtex[b]->tex)) { - if(tex->id.us>1) { + if (do_textures) { + for (b=0; b<MAX_MTEX; b++) { + if (ma->mtex[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; b<MAX_MTEX; b++) { - if(ma->mtex[b] && ma->mtex[b]->tex) { + for (ma= bmain->mat.first; ma; ma=ma->id.next) { + if (ma->id.flag & LIB_NEW) { + for (b=0; b<MAX_MTEX; b++) { + if (ma->mtex[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; b<MAX_MTEX; b++) { - if(la->mtex[b] && la->mtex[b]->tex) { + for (la= bmain->lamp.first; la; la=la->id.next) { + if (la->id.flag & LIB_NEW) { + for (b=0; b<MAX_MTEX; b++) { + if (la->mtex[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; b<MAX_MTEX; b++) { - if(wo->mtex[b] && wo->mtex[b]->tex) { + for (wo= bmain->world.first; wo; wo=wo->id.next) { + if (wo->id.flag & LIB_NEW) { + for (b=0; b<MAX_MTEX; b++) { + if (wo->mtex[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; a<MAX_MTEX; a++) - if(ma->mtex[a]) + for (ma=bmain->mat.first; ma; ma=ma->id.next) + if (ma->id.flag & LIB_NEW) + for (a=0; a<MAX_MTEX; a++) + if (ma->mtex[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; b<MAX_MTEX; b++) - if(ma->mtex[b] && ma->mtex[b]->tex) + for (b=0; b<MAX_MTEX; b++) + if (ma->mtex[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; a<ob->totcol; a++) { + if (matarar) { + for (a=0; a<ob->totcol; 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; b<MAX_MTEX; b++) - if(la->mtex[b] && la->mtex[b]->tex) + for (b=0; b<MAX_MTEX; b++) + if (la->mtex[b] && la->mtex[b]->tex) id_make_local(&la->mtex[b]->tex->id, 0); } else { - for(a=0; a<ob->totcol; a++) { + for (a=0; a<ob->totcol; a++) { ma= ob->mat[a]; - if(ma) + if (ma) make_local_makelocalmaterial(ma); } matarar= (Material ***)give_matarar(ob); - if(matarar) { - for(a=0; a<ob->totcol; a++) { + if (matarar) { + for (a=0; a<ob->totcol; 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; b<MAX_MTEX; b++) { - if(mat1->mtex[b]) { - if(tex==mat1->mtex[b]->tex) { + else if (mat1 && nr==4) { + for (b=0; b<MAX_MTEX; b++) { + if (mat1->mtex[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; i1<me->totvert; i1++, mv++) { + for (i1=0, mv=me->mvert; i1<me->totvert; 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; w<lt->pntsw; w++) { - for(v=0; v<lt->pntsv; v++) { - for(u=0; u<pntsu_half; u++) { + for (w=0; w<lt->pntsw; w++) { + for (v=0; v<lt->pntsv; v++) { + for (u=0; u<pntsu_half; u++) { int u_inv= (lt->pntsu - 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; a<me->totvert; a++, mvert++) + for (a=0; a<me->totvert; 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; a<kb->totelem; a++, fp+=3) + for (a=0; a<kb->totelem; 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; i<dvert_tot; i++, dvf++, dv++) { - if((*dv)->dw) + for (i=0; i<dvert_tot; i++, dvf++, dv++) { + if ((*dv)->dw) 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; a<tot; a++, bp++, dv++) { + for (a=0, bp= lt->def; a<tot; a++, bp++, dv++) { if (defvert_find_index(dv, def_nr)) { if (select) bp->f1 |= 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; w<lt->pntsw; w++) { - for(v=0; v<lt->pntsv; v++) { - for(u=0; u<pntsu_half; u++) { + for (w=0; w<lt->pntsw; w++) { + for (v=0; v<lt->pntsv; v++) { + for (u=0; u<pntsu_half; u++) { int u_inv= (lt->pntsu - 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; a<PSYS_TOT_VG; a++) + for (psys=ob->particlesystem.first; psys; psys=psys->next) { + for (a=0; a<PSYS_TOT_VG; a++) psys->vgroup[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; i<id; i++) map[i]=i; - for(i=id+1; i<defbase_tot; i++) map[i]=i-1; + for (i=1; i<id; i++) map[i]=i; + for (i=id+1; i<defbase_tot; i++) map[i]=i-1; vgroup_remap_update_users(ob, map); MEM_freeN(map); @@ -1704,18 +1708,18 @@ static void vgroup_delete_object_mode(Object *ob, bDeformGroup *dg) ED_vgroup_give_array(ob->data, &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; i<tot; i++, bp++) { - if(allverts || (bp->f1 & SELECT)) { + for (i=0, bp= lt->def; i<tot; i++, bp++) { + if (allverts || (bp->f1 & 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; i<dvert->totweight; i++) - if(dvert->dw[i].def_nr > dg_index) + if (dvert) + for (i=0; i<dvert->totweight; 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; a<tot; a++, bp++, dvert++) { - for(i=0; i<dvert->totweight; i++){ - if(dvert->dw[i].def_nr > dg_index) + for (a=0, bp= lt->def; a<tot; a++, bp++, dvert++) { + for (i=0; i<dvert->totweight; 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; a<tot; a++, bp++, dv++) { - if(bp->f1 & SELECT) { + for (a=0, bp= lt->def; a<tot; a++, bp++, dv++) { + if (bp->f1 & 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; i<defbase_tot; i++) + for (i=0; i<defbase_tot; i++) sort_map[i]++; sort_map_update[0]= 0; @@ -2882,7 +2886,8 @@ static int vgroup_move_exec(bContext *C, wmOperator *op) BLI_remlink(&ob->defbase, 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; p<edit->totpoint; p++, point++) -#define LOOP_VISIBLE_POINTS for(p=0, point=edit->points; p<edit->totpoint; p++, point++) if(!(point->flag & PEP_HIDE)) -#define LOOP_SELECTED_POINTS for(p=0, point=edit->points; p<edit->totpoint; p++, point++) if(point_is_selected(point)) -#define LOOP_UNSELECTED_POINTS for(p=0, point=edit->points; p<edit->totpoint; p++, point++) if(!point_is_selected(point)) -#define LOOP_EDITED_POINTS for(p=0, point=edit->points; p<edit->totpoint; p++, point++) if(point->flag & PEP_EDIT_RECALC) -#define LOOP_TAGGED_POINTS for(p=0, point=edit->points; p<edit->totpoint; p++, point++) if(point->flag & PEP_TAG) -#define LOOP_KEYS for(k=0, key=point->keys; k<point->totkey; k++, key++) -#define LOOP_VISIBLE_KEYS for(k=0, key=point->keys; k<point->totkey; k++, key++) if(!(key->flag & PEK_HIDE)) -#define LOOP_SELECTED_KEYS for(k=0, key=point->keys; k<point->totkey; k++, key++) if((key->flag & PEK_SELECT) && !(key->flag & PEK_HIDE)) -#define LOOP_TAGGED_KEYS for(k=0, key=point->keys; k<point->totkey; k++, key++) if(key->flag & PEK_TAG) +#define LOOP_POINTS for (p=0, point=edit->points; p<edit->totpoint; p++, point++) +#define LOOP_VISIBLE_POINTS for (p=0, point=edit->points; p<edit->totpoint; p++, point++) if(!(point->flag & PEP_HIDE)) +#define LOOP_SELECTED_POINTS for (p=0, point=edit->points; p<edit->totpoint; p++, point++) if(point_is_selected(point)) +#define LOOP_UNSELECTED_POINTS for (p=0, point=edit->points; p<edit->totpoint; p++, point++) if(!point_is_selected(point)) +#define LOOP_EDITED_POINTS for (p=0, point=edit->points; p<edit->totpoint; p++, point++) if(point->flag & PEP_EDIT_RECALC) +#define LOOP_TAGGED_POINTS for (p=0, point=edit->points; p<edit->totpoint; p++, point++) if(point->flag & PEP_TAG) +#define LOOP_KEYS for (k=0, key=point->keys; k<point->totkey; k++, key++) +#define LOOP_VISIBLE_KEYS for (k=0, key=point->keys; k<point->totkey; k++, key++) if(!(key->flag & PEK_HIDE)) +#define LOOP_SELECTED_KEYS for (k=0, key=point->keys; k<point->totkey; k++, key++) if((key->flag & PEK_SELECT) && !(key->flag & PEK_HIDE)) +#define LOOP_TAGGED_KEYS for (k=0, key=point->keys; k<point->totkey; 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; k<mpa->totkey; k++, mkey++, mhkey++) { + for (k=0; k<mpa->totkey; 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; k<pa->totkey; k++, hkey++, mhkey++, key++, mkey++) { + for (k=0; k<pa->totkey; 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(dot<dist_1st) { + if (dot>0.0f) { + if (dot<dist_1st) { normalize_v3(dvec); mul_v3_fl(dvec,dist_1st-dot); add_v3_v3(key->co, 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; j<point->totkey; j++) { + for (j=1; j<point->totkey; 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(; k<point->totkey; k++, key++) { - if(k) { + for (; k<point->totkey; 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; k<point->totkey-1; k++, key++) { + for (k=0; k<point->totkey-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; i<totface; i++, vec+=6, nor+=6) { + for (i=0; i<totface; i++, vec+=6, nor+=6) { MFace *mface=dm->getTessFaceData(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++; k<data->totrekey-1; k++,key++) { + for (k=1,key++; k<data->totrekey-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; k<pa->totkey; k++, key++, ekey++) { + for (k=0, key=pa->hair; k<pa->totkey; 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; k<pa->totkey; k++, key++, ekey++) { + for (k=0, key=pa->hair, ekey=edit->points[pa_index].keys; k<pa->totkey; 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; i<psys->totpart; i++, pa++, point++) { - if(point->flag & PEP_TAG) { - if(point->keys) + for (i=0; i<psys->totpart; 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; k<pa->totkey-1; k++,ekey++) { - if(ekey->flag&PEK_SELECT && (ekey+1)->flag&PEK_SELECT) + for (k=0, ekey=point->keys; k<pa->totkey-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; k<pa->totkey-1; k++, key++, ekey++) { + for (k=0, ekey=point->keys; k<pa->totkey-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<totn; n++) { + for (n=0; n<totn; n++) { /* this needs a custom threshold still */ - if(nearest[n].index > 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; p<totpart; p++, point++) { + for (p=0, point=edit->points; p<totpart; p++, point++) { pa = psys->particles + 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; k<newpa->totkey; k++, hkey++, key++) { + for (k=0, hkey=newpa->hair; k<newpa->totkey; 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; i<totface; i++,mface++){ - if(vert_cos){ + for (i=0; i<totface; i++,mface++) { + if (vert_cos) { copy_v3_v3(v1,vert_cos+3*mface->v1); 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; i<number; i++) { - if(number>1) { + for (i=0; i<number; i++) { + if (number>1) { 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; i<totpart; i++, pa++) { + for (i=0, pa=psys->particles; i<totpart; i++, pa++) { psys_particle_on_dm(psmd->dm,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; i<newtotpart; i++, pa++, point++) { + for (i=totpart; i<newtotpart; i++, pa++, point++) { memcpy(pa, add_pars + i - totpart, sizeof(ParticleData)); pa->hair= 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; k<pa->totkey; k++, hkey++, key++) { + for (k=0, hkey=pa->hair; k<pa->totkey; 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; w<maxw; w++) { + for (w=0; w<maxw; w++) { weight[w]= (float)pow(2.0, (double)(-6.0f * ptn[w].dist / maxd)); totw += weight[w]; } - for(;w<3; w++) { + for (;w<3; w++) { weight[w]= 0.0f; } - for(w=0; w<maxw; w++) + for (w=0; w<maxw; w++) weight[w] /= totw; ppa= psys->particles+ptn[0].index; - for(k=0; k<pset->totaddkey; k++) { + for (k=0; k<pset->totaddkey; 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; k<pset->totaddkey; k++, hkey++) { + for (k=0, hkey=pa->hair; k<pset->totaddkey; 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; k<pset->totaddkey; k++, hkey++) { + for (k=0, hkey=pa->hair; k<pset->totaddkey; 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; i<undo->totpoint; i++, point++) { - if(undo->particles && (undo->particles + i)->hair) + for (i=0, point=undo->points; i<undo->totpoint; 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; i<edit->totpoint; i++, pa++) + for (i=0; i<edit->totpoint; 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; i<BPHYS_TOT_DATA; i++) + for (; pm; pm=pm->next) { + for (i=0; i<BPHYS_TOT_DATA; i++) pm->data[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; i<edit->totpoint; i++, point++) { + for (i=0; i<edit->totpoint; 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; i<BPHYS_TOT_DATA; i++) + for (; pm; pm=pm->next) { + for (i=0; i<BPHYS_TOT_DATA; i++) pm->data[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; i<psys->totpart; i++,pa++) { - if(point) { + for (i=0, pa=psys->particles; i<psys->totpart; 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; k<pa->totkey; k++,key++) { + for (k=0,key=pa->hair; k<pa->totkey; 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; i<psys->totpart; i++,pa++) { + for (i=0, pa= psys->particles; i<psys->totpart; 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; k<pa->totkey; k++,key++) { + for (k=0,key=pa->hair; k<pa->totkey; 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; i<channelSize;i++) { + for (i=0; i<channelSize;i++) { fprintf(file," "); - for(j=0;j<=entries;j++) { // also print time value + for (j=0;j<=entries;j++) { // also print time value fprintf(file," %f ", channel[i*(entries+1)+j] ); - if(j==entries-1){ fprintf(file," "); } + if (j==entries-1) { fprintf(file," "); } } fprintf(file," \n"); } @@ -298,7 +302,7 @@ static void set_vertex_channel(float *channel, float time, struct Scene *scene, } /* fill frame of channel with vertex locations */ - for(j=0; j < (3*numVerts); j++) { + for (j=0; j < (3*numVerts); j++) { channel[i*framesize + j] = verts[j]; } channel[i*framesize + framesize-1] = time; @@ -468,7 +472,7 @@ static void fluid_init_all_channels(bContext *C, Object *UNUSED(fsDomain), Fluid /* init euler rotation values and convert to elbeem format */ /* get the rotation from ob->obmat 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(CFRA<oglrender->nfra) { + while (CFRA<oglrender->nfra) { 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<<MA_FLAT; } @@ -338,7 +338,7 @@ static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPre } else { sce->lay= 1<<mat->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<<MA_TEXTURE; - for(base= sce->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<<MA_ATMOS; sce->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<<MA_SKY; sce->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; a<MAX_MTEX; a++) { + for (a=0; a<MAX_MTEX; a++) { MTex *mtex= sp->matcopy->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; a<size; a++, cp+=4) + for (a=0; a<size; a++, cp+=4) cp[3]= alpha; } @@ -888,13 +889,13 @@ static void icon_preview_startjob(void *customdata, short *stop, short *do_updat ID *id= sp->id; 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<<act); ma->septex &= ~(1<<act); @@ -604,7 +604,7 @@ static int texture_slot_move(bContext *C, wmOperator *op) } } else { /* Down */ - if(act < MAX_MTEX-1) { + if (act < MAX_MTEX-1) { mtexswap = mtex_ar[act]; mtex_ar[act] = mtex_ar[act+1]; mtex_ar[act+1] = mtexswap; @@ -613,7 +613,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<<act); ma->septex &= ~(1<<act); @@ -686,7 +686,7 @@ static int envmap_save_exec(bContext *C, wmOperator *op) RNA_string_get(op->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; a<tot; a++) - if(mtex[a] && mtex[a]->tex == tex) + for (a=0; a<tot; a++) + if (mtex[a] && mtex[a]->tex == 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.x<sizex-1) sa->totrct.xmax = sa->v4->vec.x-1-rt; + if (sa->v4->vec.x<sizex-1) sa->totrct.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.y<sizey-1) sa->totrct.ymax = sa->v2->vec.y-1-rt; + if (sa->v2->vec.y<sizey-1) sa->totrct.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<tex_w) + if (subpart_w<tex_w) glTexSubImage2D(GL_TEXTURE_2D, 0, subpart_w, 0, 1, subpart_h, GL_RGBA, GL_FLOAT, &f_rect[subpart_y*offset_y*img_w*4 + (subpart_x*offset_x+subpart_w-1)*4]); - if(subpart_h<tex_h) + if (subpart_h<tex_h) glTexSubImage2D(GL_TEXTURE_2D, 0, 0, subpart_h, subpart_w, 1, GL_RGBA, GL_FLOAT, &f_rect[(subpart_y*offset_y+subpart_h-1)*img_w*4 + subpart_x*offset_x*4]); - if(subpart_w<tex_w && subpart_h<tex_h) + if (subpart_w<tex_w && subpart_h<tex_h) glTexSubImage2D(GL_TEXTURE_2D, 0, subpart_w, subpart_h, 1, 1, GL_RGBA, GL_FLOAT, &f_rect[(subpart_y*offset_y+subpart_h-1)*img_w*4 + (subpart_x*offset_x+subpart_w-1)*4]); } else { glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, subpart_w, subpart_h, GL_RGBA, GL_UNSIGNED_BYTE, &uc_rect[subpart_y*offset_y*img_w*4 + subpart_x*offset_x*4]); - if(subpart_w<tex_w) + if (subpart_w<tex_w) glTexSubImage2D(GL_TEXTURE_2D, 0, subpart_w, 0, 1, subpart_h, GL_RGBA, GL_UNSIGNED_BYTE, &uc_rect[subpart_y*offset_y*img_w*4 + (subpart_x*offset_x+subpart_w-1)*4]); - if(subpart_h<tex_h) + if (subpart_h<tex_h) glTexSubImage2D(GL_TEXTURE_2D, 0, 0, subpart_h, subpart_w, 1, GL_RGBA, GL_UNSIGNED_BYTE, &uc_rect[(subpart_y*offset_y+subpart_h-1)*img_w*4 + subpart_x*offset_x*4]); - if(subpart_w<tex_w && subpart_h<tex_h) + if (subpart_w<tex_w && subpart_h<tex_h) glTexSubImage2D(GL_TEXTURE_2D, 0, subpart_w, subpart_h, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &uc_rect[(subpart_y*offset_y+subpart_h-1)*img_w*4 + (subpart_x*offset_x+subpart_w-1)*4]); } @@ -608,27 +609,28 @@ void glaDrawPixelsSafe(float x, float y, int img_w, int img_h, int row_w, int fo /* Don't use safe RasterPos (slower) if we can avoid it. */ if (rast_x>=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(height<width) { + if (height<width) { h = height/8; w = height/4; } @@ -753,10 +753,10 @@ static void draw_horizontal_join_shape(ScrArea *sa, char dir) points[9].x = sa->v4->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(height<width) { + if (height<width) { h = height/4; w = height/8; } @@ -825,10 +825,10 @@ static void draw_vertical_join_shape(ScrArea *sa, char dir) points[9].x = sa->v1->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(x2<sizex-1) + if (x2<sizex-1) sdrawline(x2+a, y1, x2+a, y2); /* left border area */ - if(x1>0) /* 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(y2<sizey-1) + if (y2<sizey-1) sdrawline(x1, y2+a, x2, y2+a); /* bottom border area */ - if(y1>0) + 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.x<win->sizex-1) { + if ((dir=='v') && v1->vec.x>0 && v1->vec.x<win->sizex-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.y<win->sizey-1) { + if ((dir=='h') && v1->vec.y>0 && v1->vec.y<win->sizey-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; y<croph; y++, to+=cropw, from+=ibuf->x) + if (cropw > 0 && croph > 0) { + for (y=0; y<croph; y++, to+=cropw, from+=ibuf->x) 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)<FILE_MAX-5) + if (scene->r.scemode & R_EXTENSION) + if (strlen(path)<FILE_MAX-5) BKE_add_image_extension(path, scene->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; a<tot; a++) + for (a=0; a<tot; a++) IMB_rectblend(ibufb, ibuf, region[a].destx, region[a].desty, region[a].srcx, region[a].srcy, region[a].width, region[a].height, IMB_BLEND_COPY_RGB); @@ -4385,17 +4390,17 @@ static int imapaint_paint_op(void *state, ImBuf *ibufb, const float lastpos[2], imapaint_convert_brushco(ibufb, pos, bpos); /* lift from canvas */ - if(s->tool == 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; a<tot; a++) { + for (a=0; a<tot; a++) { imapaint_dirty_region(s->image, 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] ) { - if( cp[a]<ct[a] ) cp[a]= ct[a]; - else if( cp[a]>co[a] ) cp[a]= co[a]; + for (a=0; a<4; a++) { + if ( ct[a]<co[a] ) { + if ( cp[a]<ct[a] ) cp[a]= ct[a]; + else if ( cp[a]>co[a] ) cp[a]= co[a]; } else { - if( cp[a]<co[a] ) cp[a]= co[a]; - else if( cp[a]>ct[a] ) cp[a]= ct[a]; + if ( cp[a]<co[a] ) cp[a]= co[a]; + else 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 && i<defbase_tot; i++, dg= dg->next) { - if(groups[i]) { + for (dg= vc.obact->defbase.first; dg && i<defbase_tot; i++, dg= dg->next) { + 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; index<totindex; index++) { - if(indexar[index] && indexar[index]<=me->totpoly) { + if (wp->flag & VP_COLINDEX) { + for (index=0; index<totindex; index++) { + if (indexar[index] && indexar[index]<=me->totpoly) { 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; index<totindex; index++) { - if(indexar[index] && indexar[index]<=me->totpoly) { + if ((me->editflag & ME_EDIT_PAINT_MASK) && me->mpoly) { + for (index=0; index<totindex; index++) { + if (indexar[index] && indexar[index]<=me->totpoly) { 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; index<totindex; index++) { - if(indexar[index] && indexar[index]<=me->totpoly) { + for (index=0; index<totindex; index++) { + if (indexar[index] && indexar[index]<=me->totpoly) { 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; i<mpoly->totloop; 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; index<totindex; index++) { + for (index=0; index<totindex; index++) { - if(indexar[index] && indexar[index]<=me->totpoly) { + 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; i<PSYS_TOT_VG; i++) { - if(psys->vgroup[i]==ob->actdef) { + for (psys= ob->particlesystem.first; psys; psys= psys->next) { + for (i=0; i<PSYS_TOT_VG; i++) { + if (psys->vgroup[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; index<totindex; index++) { - if(indexar[index] && indexar[index]<=me->totpoly) { + if (vp->flag & VP_COLINDEX) { + for (index=0; index<totindex; index++) { + if (indexar[index] && indexar[index]<=me->totpoly) { 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; index<totindex; index++) { - if(indexar[index] && indexar[index]<=me->totpoly) { + if ((me->editflag & ME_EDIT_PAINT_MASK) && me->mpoly) { + for (index=0; index<totindex; index++) { + if (indexar[index] && indexar[index]<=me->totpoly) { 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; index<totindex; index++) { + for (index=0; index<totindex; index++) { - if(indexar[index] && indexar[index]<=me->totpoly) { + 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; n<totnode; n++) { + for (n=0; n<totnode; n++) { PBVHVertexIter vd; SculptBrushTest test; SculptUndoNode *unode; @@ -812,9 +813,9 @@ static void calc_area_normal(Sculpt *sd, Object *ob, float an[3], PBVHNode **nod unode = sculpt_undo_push_node(ob, nodes[n], SCULPT_UNDO_COORDS); sculpt_brush_test_init(ss, &test); - if(ss->cache->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; n<totnode; n++) { - if(ss->multires) { + for (n=0; n<totnode; n++) { + if (ss->multires) { 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; n<totnode; n++) { + for (n=0; n<totnode; n++) { PBVHVertexIter vd; SculptBrushTest test; float (*proxy)[3]; @@ -1154,7 +1155,7 @@ static void do_draw_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode) mul_v3_v3fl(proxy[vd.i], offset, fade); - if(vd.mvert) + if (vd.mvert) vd.mvert->flag |= 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; n<totnode; n++) { + for (n=0; n<totnode; n++) { PBVHVertexIter vd; SculptBrushTest test; float (*proxy)[3]; @@ -1203,7 +1204,7 @@ static void do_crease_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod 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)) { /* 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; n<totnode; n++) { + for (n=0; n<totnode; n++) { PBVHVertexIter vd; SculptBrushTest test; float (*proxy)[3]; @@ -1245,7 +1246,7 @@ static void do_pinch_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)) { 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; n<totnode; n++) { + for (n=0; n<totnode; n++) { PBVHVertexIter vd; SculptUndoNode* unode; SculptBrushTest test; @@ -1306,13 +1307,13 @@ static void do_grab_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], 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; n<totnode; n++) { + for (n=0; n<totnode; n++) { PBVHVertexIter vd; SculptUndoNode* unode; SculptBrushTest test; @@ -1501,7 +1502,7 @@ static void do_rotate_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod 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); @@ -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; n<totnode; n++) { + for (n=0; n<totnode; n++) { PBVHVertexIter vd; SculptBrushTest test; SculptUndoNode *unode; @@ -1554,7 +1555,7 @@ static void do_layer_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, 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; n<totnode; n++) { + for (n=0; n<totnode; n++) { PBVHVertexIter vd; SculptBrushTest test; float (*proxy)[3]; @@ -1606,18 +1607,18 @@ static void do_inflate_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totno 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, 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; n<totnode; n++) { + for (n=0; n<totnode; n++) { PBVHVertexIter vd; SculptBrushTest test; SculptUndoNode *unode; @@ -1647,9 +1648,9 @@ static void calc_flatten_center(Sculpt *sd, Object *ob, PBVHNode **nodes, int to unode = sculpt_undo_push_node(ob, nodes[n], SCULPT_UNDO_COORDS); sculpt_brush_test_init(ss, &test); - if(ss->cache->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; n<totnode; n++) { + for (n=0; n<totnode; n++) { PBVHVertexIter vd; SculptBrushTest test; SculptUndoNode *unode; @@ -1712,9 +1713,9 @@ static void calc_area_normal_and_flatten_center(Sculpt *sd, Object *ob, unode = sculpt_undo_push_node(ob, nodes[n], SCULPT_UNDO_COORDS); sculpt_brush_test_init(ss, &test); - if(ss->cache->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; n<totnode; n++) { + for (n=0; n<totnode; n++) { SculptUndoNode *unode; unode= sculpt_undo_get_node(nodes[n]); - if(unode) { + if (unode) { PBVHVertexIter vd; BLI_pbvh_vertex_iter_begin(ss->pbvh, 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; i<unode->totvert; i++) { - if(ss->modifiers_active) sculpt_undo_restore_deformed(ss, unode, i, index[i], vertCos[index[i]]); + for (i=0; i<unode->totvert; 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; i<unode->totvert; i++) { - if(ss->modifiers_active) sculpt_undo_restore_deformed(ss, unode, i, index[i], mvert[index[i]].co); + } + else { + for (i=0; i<unode->totvert; 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; j<unode->totgrid; j++) { + for (j=0; j<unode->totgrid; j++) { grid= grids[unode->grids[j]]; - for(i=0; i<gridsize*gridsize; i++, co++) + for (i=0; i<gridsize*gridsize; i++, co++) swap_v3_v3(grid[i].co, co[0]); } } @@ -175,16 +180,16 @@ static int sculpt_undo_restore_hidden(bContext *C, DerivedMesh *dm, SculptSession *ss = ob->sculpt; int i; - if(unode->maxvert) { + if (unode->maxvert) { MVert *mvert= ss->mvert; - for(i=0; i<unode->totvert; i++) { + for (i=0; i<unode->totvert; 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; i<unode->totgrid; i++) { + for (i=0; i<unode->totgrid; 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; i<unode->totgrid; i++) { - if(unode->grid_hidden[i]) + if (unode->grid_hidden) { + for (i=0; i<unode->totgrid; 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; a<path->len; a++) { + for (a=0; a<path->len; a++) { ptr= &path->ptr[a]; - if(RNA_struct_is_a(ptr->type, type)) { + if (RNA_struct_is_a(ptr->type, type)) { 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; a<path->len; a++) { + for (a=0; a<path->len; a++) { ptr= &path->ptr[a]; - if(RNA_struct_is_a(ptr->type, type)) + if (RNA_struct_is_a(ptr->type, type)) return ptr; } @@ -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; a<BCONTEXT_TOT; a++) { - if(buttons_context_path(C, path, a, pflag)) { + for (a=0; a<BCONTEXT_TOT; a++) { + if (buttons_context_path(C, path, a, pflag)) { flag |= (1<<a); /* setting icon for data context */ - if(a == BCONTEXT_DATA) { + if (a == BCONTEXT_DATA) { ptr= &path->ptr[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; a<BCONTEXT_TOT; a++) { - if(flag & (1 << a)) { + for (a=0; a<BCONTEXT_TOT; a++) { + if (flag & (1 << a)) { sbuts->mainb= 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; a<path->len; a++) { + for (a=0; a<path->len; 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; a<MAX_MTEX; a++) { + for (a=0; a<MAX_MTEX; a++) { mtex = psys->part->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; i<cb->track->markersnr; i++) + for (i=0; i<cb->track->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; a<totseg; a++) { + for (a= 0; a<totseg; a++) { float x1, x2; x1= (points[a*2]-sfra)/(efra-sfra+1)*ar->winx; @@ -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(a<track->markersnr) { - if(track->markers[a].framenr>=i) + while (a<track->markersnr) { + if (track->markers[a].framenr>=i) break; - if(a<track->markersnr-1 && track->markers[a+1].framenr>i) + if (a<track->markersnr-1 && track->markers[a+1].framenr>i) break; a++; } - if(a<track->markersnr) marker= &track->markers[a]; + if (a<track->markersnr) 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(a<n) { - if(cameras[a].framenr==i) { + while (a<n) { + if (cameras[a].framenr==i) { ok= 1; break; } - else if(cameras[a].framenr>i) { + 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; i<b; i++) { - if(i!=curindex) + for (i= a; i<b; i++) { + if (i!=curindex) glVertex2f(path[i][0], path[i][1]); } glEnd(); @@ -338,7 +343,7 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin glLineWidth(3.0f); glBegin(GL_LINE_STRIP); - for(i= a; i<b; i++) + for (i= a; i<b; i++) glVertex2f(path[i][0], path[i][1]); glEnd(); glLineWidth(1.0f); @@ -346,14 +351,14 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin UI_ThemeColor(TH_PATH_BEFORE); - if(TRACK_VIEW_SELECTED(sc, track)) { + if (TRACK_VIEW_SELECTED(sc, track)) { glPointSize(3.0f); glBegin(GL_POINTS); - for(i= a; i<b; i++) { - if(i==count+1) + for (i= a; i<b; i++) { + if (i==count+1) UI_ThemeColor(TH_PATH_AFTER); - if(i!=curindex) + if (i!=curindex) glVertex2f(path[i][0], path[i][1]); } glEnd(); @@ -362,8 +367,8 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin UI_ThemeColor(TH_PATH_BEFORE); glBegin(GL_LINE_STRIP); - for(i= a; i<b; i++) { - if(i==count+1) + for (i= a; i<b; i++) { + if (i==count+1) UI_ThemeColor(TH_PATH_AFTER); glVertex2f(path[i][0], path[i][1]); @@ -383,7 +388,7 @@ static void draw_marker_outline(SpaceClip *sc, MovieTrackingTrack *track, MovieT px[0]= 1.0f/width/sc->zoom; 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; i<stroke->totpoints-1; i++) { + for (i= 0; i<stroke->totpoints-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; i<reconstruction->camnr; i++) { + for (i= 0; i<reconstruction->camnr; 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 || d<data->min_dist) { + if (data->track==NULL || d<data->min_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 || d<data->min_dist) { + if (data->marker==NULL || d<data->min_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(a<act_track->markersnr) { + while (a<act_track->markersnr) { 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; i<track->markersnr; i++) { + for (i= 0; i<track->markersnr; 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; i<track->markersnr; i++) { + for (i= 0; i<track->markersnr; 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; a<track->markersnr; a++) + for (a= 0; a<track->markersnr; 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; a<data->track->markersnr; a++) + for (a= 0; a<data->track->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; a<data->track->markersnr; a++) + for (a= 0; a<data->track->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 || dist<mindist) { + if (track==NULL || dist<mindist) { track= cur; mindist= dist; } @@ -755,19 +766,20 @@ static int mouse_select(bContext *C, float co[2], int extend) track= find_nearest_track(sc, tracksbase, co); - if(track) { + if (track) { int area= track_mouse_area(sc, co, track); - if(!extend || !TRACK_VIEW_SELECTED(sc, track)) + if (!extend || !TRACK_VIEW_SELECTED(sc, track)) area= TRACK_AREA_ALL; - if(extend && TRACK_AREA_SELECTED(track, area)) { - if(track==act_track) + if (extend && TRACK_AREA_SELECTED(track, area)) { + if (track==act_track) BKE_tracking_deselect_track(track, area); else clip->tracking.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(curfra<efra) return 0; + if (backwards) { + if (curfra<efra) return 0; } else { - if(curfra>efra) 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<markersnr; a++) { + for (a= 0; a<markersnr; a++) { int end= 0; - if(prev==-1) { - if((markers[a].flag&MARKER_DISABLED)==0) + if (prev==-1) { + if ((markers[a].flag&MARKER_DISABLED)==0) prev= a; else start_disabled= 1; } - if(prev >= 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; i<numfiles; i++) { if (filelist_is_selected(sfile->files, 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; i<numfiles; i++) { if (filelist_is_selected(sfile->files, 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; i<filelist_numfiles(sfile->files); 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) && (idx<numfiles) ) { @@ -1356,7 +1362,8 @@ static int file_rename_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; } @@ -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; num<filelist->numfiles; num++, file++) { + for (num=0; num<filelist->numfiles; 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; num<filelist->numfiles; num++, file++) { - if(BLO_has_bfile_extension(file->relname)) { + for (num=0; num<filelist->numfiles; 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; i<nnames; i++, l= l->next) { 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; a<filelist->numfiles; a++) { + for (a=0; a<filelist->numfiles; 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; i<nentries; ++i) { + for (i= 0; i<nentries; ++i) { struct direntry* file = filelist_file(sfile->files, 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; slot<IMA_MAX_RENDER_SLOT; slot++) + for (slot=0; slot<IMA_MAX_RENDER_SLOT; slot++) a += sprintf(str+a, "|Slot %d %%x%d", slot+1, slot); return str; @@ -378,15 +378,15 @@ static char *layer_menu(RenderResult *rr, short *UNUSED(curlay)) a= strlen(str); /* compo result */ - if(rr->rectf) { + 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->layer<tot-1) { + if (iuser->layer<tot-1) { iuser->layer++; 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->pass<tot-1) { + if (iuser->pass<tot-1) { iuser->pass++; 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]<bias) + else if (rect_float[a]<bias) rectf[a]= 1.0f; else { rectf[a]= 1.0f - (rect_float[a]-bias)*scale; @@ -512,22 +512,22 @@ static void draw_image_buffer(SpaceImage *sima, ARegion *ar, Scene *scene, Image UI_view2d_to_region_no_clip(&ar->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; y<heigth; y++) { + for (y=0; y<heigth; y++) { memcpy(rp, rt, len*4); rt+= ibuf->x; 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; x<xmax; x++) { + for (x=xmin; x<xmax; x++) { int y; - for(y=ymin; y<ymax; y++) { - if(ima && (ima->tpageflag & IMA_TILES)) + for (y=ymin; y<ymax; y++) { + if (ima && (ima->tpageflag & 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; a<IMA_MAX_RENDER_SLOT; a++) { + for (a=1; a<IMA_MAX_RENDER_SLOT; a++) { slot= (cur + (use_reverse ? -a:a))%IMA_MAX_RENDER_SLOT; - if(slot<0) slot+=IMA_MAX_RENDER_SLOT; + if (slot<0) slot+=IMA_MAX_RENDER_SLOT; - if(ima->renders[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<tot-1; i++) - for(b=0; b<LINK_RESOL-1; b++) - if(isect_line_line_v2(mcoords[i], mcoords[i+1], coord_array[b], coord_array[b+1]) > 0) + if (ui_link_bezier_points(&rectlink, coord_array, LINK_RESOL)) { + for (i=0; i<tot-1; i++) + for (b=0; b<LINK_RESOL-1; b++) + if (isect_line_line_v2(mcoords[i], mcoords[i+1], coord_array[b], coord_array[b+1]) > 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; a<obcount; a++) { + for (a=0; a<obcount; a++) { ob= (Object *)idar[a]; propcount+= BLI_countlist(&ob->prop); 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; a<obcount; a++) { + for (a=0; a<obcount; a++) { ob= (Object *)idar[a]; prop= ob->prop.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; nr<propcount; nr++) { - if(names[nr]!=str && strcmp( names[nr], str )==0 ) { + for (nr=0; nr<propcount; nr++) { + if (names[nr]!=str && strcmp( names[nr], str )==0 ) { BLI_newname(str, +1); } } @@ -208,19 +208,19 @@ static void old_sca_move_sensor(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) { 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; a<sens->totlinks; a++) { - if(sens->links[a]) { + for (a=0; a<sens->totlinks; 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; a<cont->totlinks; a++) { - if(cont->links[a]) { + for (a=0; a<cont->totlinks; 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; a<sens->totlinks; a++) { - if(sens->links[a]) { + for (a=0; a<sens->totlinks; 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; a<cont->totlinks; a++) { - if(cont->links[a]) { + for (a=0; a<cont->totlinks; 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; a<count; a++) { + for (a=0; a<count; a++) { ob= (Object *)idar[a]; - if(event==0 || event==2) ob->scaflag |= 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; a<count; a++) { + for (a=0; a<count; a++) { ob= (Object *)idar[a]; sens= ob->sensors.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; a<count; a++) { + for (a=0; a<count; a++) { ob= (Object *)idar[a]; - if(event==0 || event==2) ob->scaflag |= 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; a<count; a++) { + for (a=0; a<count; a++) { ob= (Object *)idar[a]; cont= ob->controllers.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; a<count; a++) { + for (a=0; a<count; a++) { ob= (Object *)idar[a]; - if(event==0 || event==2) ob->scaflag |= 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; a<count; a++) { + for (a=0; a<count; a++) { ob= (Object *)idar[a]; act= ob->actuators.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; a<count; a++) { + for (a=0; a<count; a++) { bActuator *act; bSensor *sens; bController *cont; @@ -4543,7 +4552,7 @@ static void logic_buttons_new(bContext *C, ARegion *ar) uiItemR(row, &logic_ptr, "show_controllers_active_object", 0, "Act", ICON_NONE); uiItemR(row, &logic_ptr, "show_controllers_linked_controller", 0, "Link", ICON_NONE); - for(a=0; a<count; a++) { + for (a=0; a<count; a++) { bController *cont; PointerRNA ptr; uiLayout *split, *subsplit, *col; @@ -4552,7 +4561,7 @@ static void logic_buttons_new(bContext *C, ARegion *ar) ob= (Object *)idar[a]; /* only draw the controller common header if "use_visible" */ - if( (ob->scavisflag & 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; a<count; a++) { + for (a=0; a<count; a++) { bSensor *sens; PointerRNA ptr; ob= (Object *)idar[a]; /* only draw the sensor common header if "use_visible" */ - if((ob->scavisflag & 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; a<count; a++) { + for (a=0; a<count; a++) { bActuator *act; PointerRNA ptr; ob= (Object *)idar[a]; /* only draw the actuator common header if "use_visible" */ - if( (ob->scavisflag & 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; a<count; a++) { + for (a=0; a<count; a++) { ob= (Object *)idar[a]; act= ob->actuators.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; a<count; a++) { + for (a=0; a<count; a++) { unsigned int controller_state_mask = 0; /* store a bitmask for states that are used */ ob= (Object *)idar[a]; // uiClearButLock(); // uiSetButLock(object_is_libdata(ob), ERROR_LIBDATA_MESSAGE); - if( (ob->scavisflag & 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; a<count; a++) { + for (a=0; a<count; a++) { ob= (Object *)idar[a]; // uiClearButLock(); // uiSetButLock(object_is_libdata(ob), ERROR_LIBDATA_MESSAGE); - if( (ob->scavisflag & 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; a<count; a++) { + for (a=0; a<count; a++) { ob= (Object *)idar[a]; // uiClearButLock(); // uiSetButLock(object_is_libdata(ob), ERROR_LIBDATA_MESSAGE); - if( (ob->scavisflag & 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->custom1<node->custom2) + if (node->custom1<node->custom2) 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; i<LINK_RESOL; i++) { + for (i=0; i<LINK_RESOL; i++) { UI_ThemeColorBlend(th_col1, th_col2, spline_step); glVertex2fv(coord_array[i]); @@ -2547,7 +2552,7 @@ void node_draw_link_bezier(View2D *v2d, SpaceNode *snode, bNodeLink *link, int t else { UI_ThemeColor(th_col1); glBegin(GL_LINE_STRIP); - for(i=0; i<=LINK_RESOL; i++) { + for (i=0; i<=LINK_RESOL; i++) { glVertex2fv(coord_array[i]); } glEnd(); @@ -2562,21 +2567,21 @@ void node_draw_link_bezier(View2D *v2d, SpaceNode *snode, bNodeLink *link, int t static void node_link_straight_points(View2D *UNUSED(v2d), SpaceNode *snode, bNodeLink *link, float coord_array[][2]) { - if(link->fromsock) { + 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; y<prv->ymax; y+=tile*2) { - for(x=prv->xmin; x<prv->xmax; x+=tile*2) { + for (y=prv->ymin; y<prv->ymax; y+=tile*2) { + for (x=prv->xmin; x<prv->xmax; 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; y<prv->ymax; y+=tile*2) { - for(x=prv->xmin+tile; x<prv->xmax; x+=tile*2) { + for (y=prv->ymin+tile; y<prv->ymax; y+=tile*2) { + for (x=prv->xmin+tile; x<prv->xmax; 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<tot-1; i++) - for(b=0; b<LINK_RESOL; b++) - if(isect_line_line_v2(mcoords[i], mcoords[i+1], coord_array[b], coord_array[b+1]) > 0) + for (i=0; i<tot-1; i++) + for (b=0; b<LINK_RESOL; b++) + if (isect_line_line_v2(mcoords[i], mcoords[i+1], coord_array[b], coord_array[b+1]) > 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<<tselem->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(miny<v2d->tot.ymin) miny = v2d->tot.ymin; + if (miny<v2d->tot.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]<te->ys+UI_UNIT_Y) { + if (mval[1]>te->ys && mval[1]<te->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]<te->ys+UI_UNIT_Y) { + if (mval[1]>te->ys && mval[1]<te->ys+UI_UNIT_Y) { TreeStoreElem *tselem= TREESTORE(te); /* name and first icon */ - if(mval[0]>te->xs+UI_UNIT_X && mval[0]<te->xend) { + if (mval[0]>te->xs+UI_UNIT_X && mval[0]<te->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]<te->ys+UI_UNIT_Y) { + if (mval[1]>te->ys && mval[1]<te->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]<te->xs+UI_UNIT_X) + if ((te->flag & TE_ICONROW)==0) { // hidden icon, no open/close + if ( mval[0]>te->xs && mval[0]<te->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]<te->xend) { + else if (mval[0]>te->xs+UI_UNIT_X && mval[0]<te->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; a<totcol; a++) { - if(a==te->index && matar[a]) { + for (a=0; a<totcol; a++) { + if (a==te->index && 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; a<MAX_MTEX; a++) { - if(a==te->index && mtex[a]) { - if(mtex[a]->tex) { + for (a=0; a<MAX_MTEX; a++) { + if (a==te->index && 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]<te->ys+UI_UNIT_Y) { + if (mval[1]>te->ys && mval[1]<te->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; a<ts->usedelem; a++, tselem++) tselem->used= 0; + for (a=0, tselem= ts->data; a<ts->usedelem; 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; a<ts->usedelem; a++, tselem++) { - if(tselem->id==NULL) unused++; + for (a=0, tselem= ts->data; a<ts->usedelem; 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; a<ts->usedelem; a++, tselem++) { - if(tselem->id) { + for (a=0, tselem= ts->data; a<ts->usedelem; 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; a<ts->usedelem; a++, tselem++) { - if(tselem->id==id && tselem->used==0) { - if((type==0 && tselem->type==0) ||(tselem->type==type && tselem->nr==nr)) { + for (a=0; a<ts->usedelem; 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; a<ts->usedelem; 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; a<ts->usedelem; 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; a<ob->totcol; a++) + for (a=0; a<ob->totcol; 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; a<me->totcol; a++) + for (a=0; a<me->totcol; a++) outliner_add_element(soops, &te->subtree, me->mat[a], te, 0, a); /* could do tfaces with image links, but the images are not grouped nicely. * would require going over all tfaces, sort images in use. etc... */ @@ -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; a<cu->totcol; a++) + for (a=0; a<cu->totcol; 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; a<mb->totcol; a++) + for (a=0; a<mb->totcol; 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; a<MAX_MTEX; a++) { - if(ma->mtex[a]) outliner_add_element(soops, &te->subtree, ma->mtex[a]->tex, te, 0, a); + for (a=0; a<MAX_MTEX; a++) { + if (ma->mtex[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; a<MAX_MTEX; a++) { - if(la->mtex[a]) outliner_add_element(soops, &te->subtree, la->mtex[a]->tex, te, 0, a); + for (a=0; a<MAX_MTEX; a++) { + if (la->mtex[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; a<MAX_MTEX; a++) { - if(wrld->mtex[a]) outliner_add_element(soops, &te->subtree, wrld->mtex[a]->tex, te, 0, a); + for (a=0; a<MAX_MTEX; a++) { + if (wrld->mtex[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; a<tot; a++) + if (TSELEM_OPEN(tselem,soops)) { + for (a=0; a<tot; a++) outliner_add_element(soops, &te->subtree, (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; a<tot; a++) { + if (TSELEM_OPEN(tselem,soops)) { + for (a=0; a<tot; a++) { RNA_property_collection_lookup_int(ptr, prop, a, &pptr); outliner_add_element(soops, &te->subtree, (void*)&pptr, te, TSE_RNA_STRUCT, a); } } - else if(tot) + else if (tot) te->flag |= TE_LAZY_CLOSED; } - else if(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; a<tot; a++) + if (TSELEM_OPEN(tselem,soops)) { + for (a=0; a<tot; a++) outliner_add_element(soops, &te->subtree, (void*)ptr, te, TSE_RNA_ARRAY_ELEM, a); } - else if(tot) + else if (tot) te->flag |= TE_LAZY_CLOSED; } } - else if(type == TSE_RNA_ARRAY_ELEM) { + 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; skip<totelem; skip++, tp++) - if(tp->idcode) break; + for (tp= tear, skip=0; skip<totelem; skip++, tp++) + if (tp->idcode) break; - if(skip<totelem) + if (skip<totelem) qsort(tear+skip, totelem-skip, sizeof(tTreeSort), treesort_alpha); lb->first=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(x1<v2d->cur.xmin) x1= v2d->cur.xmin; - else if(x1>v2d->cur.xmax) x1= v2d->cur.xmax; - if(x2<v2d->cur.xmin) x2= v2d->cur.xmin; - else if(x2>v2d->cur.xmax) x2= v2d->cur.xmax; + if (x1<v2d->cur.xmin) x1= v2d->cur.xmin; + else if (x1>v2d->cur.xmax) x1= v2d->cur.xmax; + if (x2<v2d->cur.xmin) x2= v2d->cur.xmin; + else if (x2>v2d->cur.xmax) x2= v2d->cur.xmax; /* nice text here would require changing the view matrix for texture text */ - if( (x2-x1) / pixelx > 32) { + 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<cursin) cursin += chars-1; + if (linep==linein && i<cursin) cursin += chars-1; ch= ' '; } else { chars= 1; } - while(chars--) { - if(i-start>=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<cursin) cursin += chars-1; + if (i<cursin) cursin += chars-1; ch= ' '; } else chars= 1; - while(chars--) { - if(i-start>=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; i<cur && line[i]; i += BLI_str_utf8_size(line + i)) { - if(line[i]=='\t') + for (i=0; i<cur && line[i]; i += BLI_str_utf8_size(line + i)) { + if (line[i]=='\t') a += st->tabnumber-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; a<end; a++, ma+=BLI_str_utf8_size(str+ma)) { - if(st->showsyntax && format) format_draw_color(format[a]); + for (a=start, ma=mstart; a<end; 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); } 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->lineno<topi) continue; + if (marker->lineno<topi) continue; line= BLI_findlink(&text->lines, 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; i<y2; i++) { + for (i=y1+1; i<y2; i++) { glBegin(GL_LINES); glVertex2i(x, y); glVertex2i(ar->winx, 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; i<SUGG_LIST_SIZE && item; i++, item=item->next) { + for (i=0; i<SUGG_LIST_SIZE && item; i++, item=item->next) { 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; i<tol; i++) + for (i=froml+1; i<tol; i++) glRecti(x-4, y, ar->winx, 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(c<linep->len) { - if(linep->format && linep->format[fc] != 'l' && linep->format[fc] != '#') { + while (linep) { + while (c<linep->len) { + 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; i<st->top && tmp; i++) { - if(st->showsyntax && !tmp->format) + for (i= 0; i<st->top && 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 && i<st->viewlines && tmp; i++, tmp= tmp->next) { - if(st->showsyntax && !tmp->format) + for (i=0; y>0 && i<st->viewlines && 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->lineno<lineno || (mrk->lineno==lineno && mrk->start <= text->curc))) + while (mrk && (mrk->lineno<lineno || (mrk->lineno==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(offl<visible_lines-1) { + if (offl<visible_lines-1) { *charp= text_get_cursor_rel(st, ar, *linep, offl+1, col); newl= BLI_findindex(&text->lines, 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]<st->txtbar.xmax) { - if(mval[1]>=st->txtbar.ymin && mval[1]<=st->txtbar.ymax) { + if (mval[0]>st->txtbar.xmin && mval[0]<st->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]<ar->winy-TXT_SCROLL_SPACE) { - if(mval[1]<st->txtbar.ymin) zone= SCROLLHANDLE_MIN_OUTSIDE; + else if (mval[1]>TXT_SCROLL_SPACE && mval[1]<ar->winy-TXT_SCROLL_SPACE) { + if (mval[1]<st->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(x<w) *charp= flatten_index_to_offset(st, (*linep)->line, x); + if (x<w) *charp= flatten_index_to_offset(st, (*linep)->line, 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]<ar->winy-2)) + if (!(mval[0]>2 && mval[0]<(TXT_OFFSET + TEXTXLOC) && mval[1]>2 && mval[1]<ar->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]<x || x+w<mval[0] || mval[1]<y-h || y<mval[1]) + if (mval[0]<x || x+w<mval[0] || mval[1]<y-h || y<mval[1]) return 0; /* Work out which of the items is at the top 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); /* 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; i<skipleft; i++) + for (i=0; i<skipleft; i++) txt_move_left(text, 0); - for(i=0; i<over; i++) + for (i=0; i<over; i++) txt_move_left(text, 1); txt_insert_buf(text, sel->name); - for(i=0; i<skipleft; i++) + for (i=0; i<skipleft; i++) txt_move_right(text, 0); texttool_text_clear(); @@ -196,78 +196,78 @@ static short UNUSED_FUNCTION(do_texttools)(SpaceText *st, char ascii, unsigned s ARegion *ar= NULL; // XXX int qual= 0; // XXX int draw=0, tools=0, swallow=0, scroll=1; - if(!texttool_text_is_active(st->text)) 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;i<t->total;i++,td++) { + for (i=1;i<t->total;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; a<t->total; a++, tob++) { + for (a=0, tob= t->data; a<t->total; 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; i<t->total; i++, td++, tdx++) { + for (i=0; i<t->total; 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; a<nu->pntsu; 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; a<nu->pntsu; 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; a<nu->pntsu; a++, bezt++) { - if(bezt->hide==0) { + for (a=0, bezt= nu->bezt; a<nu->pntsu; 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; i<edit->totpoint; i++, point++) { + for (i=0, point=edit->points; i<edit->totpoint; i++, point++) { point->flag &= ~PEP_TRANSFORM; transformparticle= 0; - if((point->flag & PEP_HIDE)==0) { - for(k=0, key=point->keys; k<point->totkey; 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; k<point->totkey; 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; i<edit->totpoint; i++, point++) { + for (i=0, point=edit->points; i<edit->totpoint; 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; k<point->totkey; k++, key++) { - if(key->flag & PEK_USE_WCO) { + for (k=0, key=point->keys; k<point->totkey; 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; i<edit->totpoint; i++, point++, td++) { - if(!(point->flag & PEP_TRANSFORM)) continue; + for (i=0, point=edit->points; i<edit->totpoint; 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; k<point->totkey; k++, key++) { + for (k=0, key=point->keys; k<point->totkey; 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; a<t->total; a++, td++) { + for (a=0, td= t->data2d; a<t->total; 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; a<t->total; a++, td++, td2d++) { + for (a=0, td= t->data, td2d= t->data2d; a<t->total; 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; a<t->total; a++, td++, td2d++) { + for (a=0, td= t->data, td2d= t->data2d; a<t->total; 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; a<t->total; a++, td++) { + for (a=0, td= t->data2d; a<t->total; 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; a<t->total; a++, td++) { + for (a=0, td= t->data; a<t->total; 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; a<t->total; a++, td++) { + for (a=0; a<t->total; 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; a<t->total; a++, td++) { + for (a=0; a<t->total; 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; a<t->total; a++, td++) { + for (a=0; a<t->total; 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; a<t->total; a++, td++) { + for (a=0; a<t->total; 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; a<t->total; a++, td++) { + for (a=0; a<t->total; 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; a<t->total; a++, td++) { + for (a=0; a<t->total; 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; a<t->total; 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; a<t->total; 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; a<tdt->markersnr; a++) + for (a= 0; a<tdt->markersnr; 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; a<tdt->markersnr; a++) + for (a= 0; a<tdt->markersnr; a++) add_v2_v2v2(tdt->markers[a].pos, tdt->smarkers[a], d2); negate_v2_v2(td2d->loc2d, d); } } - 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; a<t->total; a++, td++) { + for (a=0, td= t->data; a<t->total; 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; a<edit->totpoint; a++,point++) { - if(point->flag & PEP_HIDE) continue; + for (a=0; a<edit->totpoint; a++,point++) { + if (point->flag & PEP_HIDE) continue; - for(k=0, ek=point->keys; k<point->totkey; k++, ek++) { - if(ek->flag & PEK_SELECT) { + for (k=0, ek=point->keys; k<point->totkey; 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; a<hits; a++) { + for (a=0; a<hits; a++) { dep= buffer[4*a + 1]; val= buffer[4*a + 3]; - if(val==MAN_TRANS_C) return MAN_TRANS_C; - else if(val==MAN_SCALE_C) return MAN_SCALE_C; + if (val==MAN_TRANS_C) return MAN_TRANS_C; + else if (val==MAN_SCALE_C) return MAN_SCALE_C; else { - if(val & MAN_ROT_C) { - if(minvalrot==0 || dep<mindeprot) { + if (val & MAN_ROT_C) { + if (minvalrot==0 || dep<mindeprot) { mindeprot= dep; minvalrot= val; } } else { - if(minval==0 || dep<mindep) { + if (minval==0 || dep<mindep) { mindep= dep; minval= val; } @@ -1605,7 +1605,7 @@ static int manipulator_selectbuf(ScrArea *sa, ARegion *ar, const int mval[2], fl } } - if(minval) + if (minval) return minval; else return minvalrot; @@ -1624,26 +1624,26 @@ int BIF_do_manipulator(bContext *C, struct wmEvent *event, wmOperator *op) int val; int shift = event->shift; - 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; i<me->totvert; i++, mvert++) + for (i=0; i<me->totvert; 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; i<me->totface; i++, mface++) { + for (i=0; i<me->totface; 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; a<numVerts; a++) + for (a=0; a<numVerts; a++) unit_m3(defmats[a]); } @@ -359,11 +359,11 @@ int editbmesh_get_first_deform_matrices(Scene *scene, Object *ob, BMEditMesh *em break; } - for(; md && i <= cageIndex; md = md->next, 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; a<numVerts; a++) + for (a=0; a<numVerts; a++) unit_m3(defmats[a]); } - if(mti->deformMatrices) 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; i<me->totvert; i++) { + for (i=0; i<me->totvert; 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; a<numVerts; a++) + for (a=0; a<numVerts; a++) unit_m3((*deformmats)[a]); } } diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c index 15dced2f448..fcf95047414 100644 --- a/source/blender/editors/util/ed_util.c +++ b/source/blender/editors/util/ed_util.c @@ -75,14 +75,14 @@ void ED_editors_init(bContext *C) /* toggle on modes for objects that were saved with these enabled. for * e.g. linked objects we have to ensure that they are actually the * active object in this scene. */ - for(ob=bmain->object.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<nverts; a++) { + for (a=0; a<nverts; a++) { /* check face not hidden and not tagged */ iterv1= uv_vertex_map_get(vmap, efa, a); iterv2= uv_vertex_map_get(vmap, efa, (a+1)%nverts); @@ -1068,8 +1068,8 @@ static int select_edgeloop(Scene *scene, Image *ima, BMEditMesh *em, NearestHit continue; /* check if vertex is tagged and has right valence */ - if(iterv1->flag || iterv2->flag) { - if(uv_edge_tag_faces(em, iterv1, iterv2, &starttotf)) { + if (iterv1->flag || iterv2->flag) { + if (uv_edge_tag_faces(em, iterv1, iterv2, &starttotf)) { looking= 1; BMO_elem_flag_enable(em->bm, efa, EFA_F1_FLAG); @@ -1090,8 +1090,8 @@ static int select_edgeloop(Scene *scene, Image *ima, BMEditMesh *em, NearestHit iterv1->flag= 1; iterv2->flag= 1; - if(extend) { - if(uvedit_uv_selected(em, scene, hit->l)) + if (extend) { + if (uvedit_uv_selected(em, scene, hit->l)) select= 0; else select= 1; @@ -1104,8 +1104,8 @@ static int select_edgeloop(Scene *scene, Image *ima, BMEditMesh *em, NearestHit BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) { iterv1= uv_vertex_map_get(vmap, efa, a); - if(iterv1->flag) { - if(select) uvedit_uv_select(em, scene, l); + if (iterv1->flag) { + if (select) uvedit_uv_select(em, scene, l); else uvedit_uv_deselect(em, scene, l); } @@ -1138,17 +1138,17 @@ static void select_linked(Scene *scene, Image *ima, BMEditMesh *em, float limit[ EDBM_init_index_arrays(em, 0, 0, 1); /* we can use this too */ vmap= EDBM_make_uv_vert_map(em, 1, 1, limit); - if(vmap == NULL) + if (vmap == NULL) return; stack= MEM_mallocN(sizeof(*stack)*(em->bm->totface+1), "UvLinkStack"); flag= MEM_callocN(sizeof(*flag)*em->bm->totface, "UvLinkFlag"); - if(!hit) { + if (!hit) { BM_ITER_INDEX(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL, a) { 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_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) { luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV); @@ -1166,7 +1166,7 @@ static void select_linked(Scene *scene, Image *ima, BMEditMesh *em, float limit[ else { a = 0; BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { - if(efa == hit->efa) { + if (efa == hit->efa) { stack[stacksize]= a; stacksize++; flag[a]= 1; @@ -1185,7 +1185,7 @@ static void select_linked(Scene *scene, Image *ima, BMEditMesh *em, float limit[ j = 0; BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { - if(j==a) + if (j==a) break; j++; @@ -1199,17 +1199,17 @@ static void select_linked(Scene *scene, Image *ima, BMEditMesh *em, float limit[ startv= vlist; - for(iterv=vlist; iterv; iterv=iterv->next) { - if(iterv->separate) + for (iterv=vlist; iterv; iterv=iterv->next) { + if (iterv->separate) startv= iterv; - if(iterv->f == a) + if (iterv->f == a) break; } - for(iterv=startv; iterv; iterv=iterv->next) { - if((startv != iterv) && (iterv->separate)) + for (iterv=startv; iterv; iterv=iterv->next) { + if ((startv != iterv) && (iterv->separate)) break; - else if(!flag[iterv->f]) { + else if (!flag[iterv->f]) { flag[iterv->f]= 1; stack[stacksize]= iterv->f; stacksize++; @@ -1220,7 +1220,7 @@ static void select_linked(Scene *scene, Image *ima, BMEditMesh *em, float limit[ } } - if(!extend) { + if (!extend) { a = 0; BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) { @@ -1255,7 +1255,7 @@ static void select_linked(Scene *scene, Image *ima, BMEditMesh *em, float limit[ a++; } - if(efa) { + if (efa) { a = 0; BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { if (!flag[a]) { @@ -1341,14 +1341,14 @@ static void weld_align_uv(bContext *C, int tool) INIT_MINMAX2(min, max); - if(tool == 'a') { + if (tool == 'a') { BMFace *efa; BMLoop *l; 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) { @@ -1364,13 +1364,13 @@ static void weld_align_uv(bContext *C, int tool) uvedit_center(scene, ima, obedit, cent, 0); - if(tool == 'x' || tool == 'w') { + if (tool == 'x' || tool == 'w') { BMFace *efa; BMLoop *l; 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) { @@ -1383,13 +1383,13 @@ static void weld_align_uv(bContext *C, int tool) } } - if(tool == 'y' || tool == 'w') { + if (tool == 'y' || tool == 'w') { BMFace *efa; BMLoop *l; 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) { @@ -1402,7 +1402,7 @@ static void weld_align_uv(bContext *C, int tool) } } - if(tool == 's' || tool == 't' || tool == 'u') { + if (tool == 's' || tool == 't' || tool == 'u') { BMEdge *eed; BMLoop *l; BMVert *eve; @@ -1606,7 +1606,7 @@ static void select_all_perform(bContext *C, int action) em = BMEdit_FromObject(obedit); ima = CTX_data_edit_image(C); - if(ts->uv_flag & UV_SYNC_SELECTION) { + if (ts->uv_flag & UV_SYNC_SELECTION) { switch (action) { case SEL_TOGGLE: @@ -1629,7 +1629,7 @@ static void select_all_perform(bContext *C, int action) 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) { @@ -1647,7 +1647,7 @@ static void select_all_perform(bContext *C, int action) 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) { @@ -1704,16 +1704,16 @@ static int sticky_select(float *limit, int hitv[4], int v, float *hituv[4], floa /* this function test if some vertex needs to selected * in addition to the existing ones due to sticky select */ - if(sticky == SI_STICKY_DISABLE) + if (sticky == SI_STICKY_DISABLE) return 0; - for(i=0; i<hitlen; i++) { - if(hitv[i] == v) { - if(sticky == SI_STICKY_LOC) { - if(fabsf(hituv[i][0]-uv[0]) < limit[0] && fabsf(hituv[i][1]-uv[1]) < limit[1]) + for (i=0; i<hitlen; i++) { + if (hitv[i] == v) { + if (sticky == SI_STICKY_LOC) { + if (fabsf(hituv[i][0]-uv[0]) < limit[0] && fabsf(hituv[i][1]-uv[1]) < limit[1]) return 1; } - else if(sticky == SI_STICKY_VERTEX) + else if (sticky == SI_STICKY_VERTEX) return 1; } } @@ -1752,12 +1752,12 @@ static int mouse_select(bContext *C, float co[2], int extend, int loop) uvedit_pixel_to_float(sima, penalty, 5.0f / sima->zoom); /* retrieve operation mode */ - if(ts->uv_flag & UV_SYNC_SELECTION) { + if (ts->uv_flag & UV_SYNC_SELECTION) { sync= 1; - if(ts->selectmode & SCE_SELECT_FACE) + if (ts->selectmode & SCE_SELECT_FACE) selectmode= UV_SELECT_FACE; - else if(ts->selectmode & SCE_SELECT_EDGE) + else if (ts->selectmode & SCE_SELECT_EDGE) selectmode= UV_SELECT_EDGE; else selectmode= UV_SELECT_VERTEX; @@ -1771,10 +1771,10 @@ static int mouse_select(bContext *C, float co[2], int extend, int loop) } /* find nearest element */ - if(loop) { + if (loop) { /* find edge */ uv_find_nearest_edge(scene, ima, em, co, &hit); - if(hit.efa == NULL) { + if (hit.efa == NULL) { BLI_array_free(hitv); BLI_array_free(hituv); return OPERATOR_CANCELLED; @@ -1782,10 +1782,10 @@ static int mouse_select(bContext *C, float co[2], int extend, int loop) hitlen = 0; } - else if(selectmode == UV_SELECT_VERTEX) { + else if (selectmode == UV_SELECT_VERTEX) { /* find vertex */ uv_find_nearest_vert(scene, ima, em, co, penalty, &hit); - if(hit.efa == NULL) { + if (hit.efa == NULL) { BLI_array_free(hitv); BLI_array_free(hituv); return OPERATOR_CANCELLED; @@ -1794,7 +1794,7 @@ static int mouse_select(bContext *C, float co[2], int extend, int loop) /* mark 1 vertex as being hit */ BLI_array_growitems(hitv, hit.efa->len); BLI_array_growitems(hituv, hit.efa->len); - for(i=0; i<hit.efa->len; i++) { + for (i=0; i<hit.efa->len; i++) { hitv[i]= 0xFFFFFFFF; } @@ -1803,10 +1803,10 @@ static int mouse_select(bContext *C, float co[2], int extend, int loop) hitlen = hit.efa->len; } - else if(selectmode == UV_SELECT_EDGE) { + else if (selectmode == UV_SELECT_EDGE) { /* find edge */ uv_find_nearest_edge(scene, ima, em, co, &hit); - if(hit.efa == NULL) { + if (hit.efa == NULL) { BLI_array_free(hitv); BLI_array_free(hituv); return OPERATOR_CANCELLED; @@ -1828,10 +1828,10 @@ static int mouse_select(bContext *C, float co[2], int extend, int loop) hitlen = hit.efa->len; } - else if(selectmode == UV_SELECT_FACE) { + else if (selectmode == UV_SELECT_FACE) { /* find face */ find_nearest_uv_face(scene, ima, em, co, &hit); - if(hit.efa == NULL) { + if (hit.efa == NULL) { BLI_array_free(hitv); BLI_array_free(hituv); return OPERATOR_CANCELLED; @@ -1854,10 +1854,10 @@ static int mouse_select(bContext *C, float co[2], int extend, int loop) hitlen = hit.efa->len; } - else if(selectmode == UV_SELECT_ISLAND) { + else if (selectmode == UV_SELECT_ISLAND) { uv_find_nearest_vert(scene, ima, em, co, NULL, &hit); - if(hit.efa==NULL) { + if (hit.efa==NULL) { BLI_array_free(hitv); BLI_array_free(hituv); return OPERATOR_CANCELLED; @@ -1873,16 +1873,16 @@ static int mouse_select(bContext *C, float co[2], int extend, int loop) } /* do selection */ - if(loop) { + if (loop) { flush= select_edgeloop(scene, ima, em, &hit, limit, extend); } - else if(selectmode == UV_SELECT_ISLAND) { + else if (selectmode == UV_SELECT_ISLAND) { select_linked(scene, ima, em, limit, &hit, extend); } - else if(extend) { - if(selectmode == UV_SELECT_VERTEX) { + else if (extend) { + if (selectmode == UV_SELECT_VERTEX) { /* (de)select uv vertex */ - if(uvedit_uv_selected(em, scene, hit.l)) { + if (uvedit_uv_selected(em, scene, hit.l)) { uvedit_uv_deselect(em, scene, hit.l); select= 0; } @@ -1892,9 +1892,9 @@ static int mouse_select(bContext *C, float co[2], int extend, int loop) } flush = 1; } - else if(selectmode == UV_SELECT_EDGE) { + else if (selectmode == UV_SELECT_EDGE) { /* (de)select edge */ - if(uvedit_edge_selected(em, scene, hit.l)) { + if (uvedit_edge_selected(em, scene, hit.l)) { uvedit_edge_deselect(em, scene, hit.l); select= 0; } @@ -1904,9 +1904,9 @@ static int mouse_select(bContext *C, float co[2], int extend, int loop) } flush = 1; } - else if(selectmode == UV_SELECT_FACE) { + else if (selectmode == UV_SELECT_FACE) { /* (de)select face */ - if(uvedit_face_selected(scene, em, hit.efa)) { + if (uvedit_face_selected(scene, em, hit.efa)) { uvedit_face_deselect(scene, em, hit.efa); select= 0; } @@ -1918,20 +1918,20 @@ static int mouse_select(bContext *C, float co[2], int extend, int loop) } /* (de)select sticky uv nodes */ - if(sticky != SI_STICKY_DISABLE) { + if (sticky != SI_STICKY_DISABLE) { BM_mesh_elem_index_ensure(em->bm, BM_VERT); /* deselect */ - if(select==0) { + if (select==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) { luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV); - if(sticky_select(limit, hitv, BM_elem_index_get(l->v), hituv, luv->uv, sticky, hitlen)) + if (sticky_select(limit, hitv, BM_elem_index_get(l->v), hituv, luv->uv, sticky, hitlen)) uvedit_uv_deselect(em, scene, l); } } @@ -1941,12 +1941,12 @@ static int mouse_select(bContext *C, float co[2], int extend, int loop) else { 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); - if(sticky_select(limit, hitv, BM_elem_index_get(l->v), hituv, luv->uv, sticky, hitlen)) + if (sticky_select(limit, hitv, BM_elem_index_get(l->v), hituv, luv->uv, sticky, hitlen)) uvedit_uv_select(em, scene, l); } } @@ -1961,33 +1961,33 @@ static int mouse_select(bContext *C, float co[2], int extend, int loop) uvedit_face_deselect(scene, em, efa); } - if(selectmode == UV_SELECT_VERTEX) { + if (selectmode == UV_SELECT_VERTEX) { /* select vertex */ uvedit_uv_select(em, scene, hit.l); flush= 1; } - else if(selectmode == UV_SELECT_EDGE) { + else if (selectmode == UV_SELECT_EDGE) { /* select edge */ uvedit_edge_select(em, scene, hit.l); flush= 1; } - else if(selectmode == UV_SELECT_FACE) { + else if (selectmode == UV_SELECT_FACE) { /* select face */ uvedit_face_select(scene, em, hit.efa); } /* select sticky uvs */ - if(sticky != SI_STICKY_DISABLE) { + if (sticky != SI_STICKY_DISABLE) { 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) { - if(sticky == SI_STICKY_DISABLE) continue; + if (sticky == SI_STICKY_DISABLE) continue; luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV); - if(sticky_select(limit, hitv, BM_elem_index_get(l->v), hituv, luv->uv, sticky, hitlen)) + if (sticky_select(limit, hitv, BM_elem_index_get(l->v), hituv, luv->uv, sticky, hitlen)) uvedit_uv_select(em, scene, l); flush= 1; @@ -1998,11 +1998,11 @@ static int mouse_select(bContext *C, float co[2], int extend, int loop) #if 0 /* BM_elem_select_set API handles all of this? */ - if(sync) { + if (sync) { /* flush for mesh selection */ - if(ts->selectmode != SCE_SELECT_FACE) { - if(flush==1) EDBM_select_flush(em); - else if(flush==-1) EDBM_deselect_flush(em); + if (ts->selectmode != SCE_SELECT_FACE) { + if (flush==1) EDBM_select_flush(em); + else if (flush==-1) EDBM_deselect_flush(em); } } #else @@ -2122,7 +2122,7 @@ static int select_linked_internal(bContext *C, wmOperator *op, wmEvent *event, i NearestHit hit, *hit_p= NULL; - if(ts->uv_flag & UV_SYNC_SELECTION) { + if (ts->uv_flag & UV_SYNC_SELECTION) { BKE_report(op->reports, RPT_ERROR, "Can't select linked when sync selection is enabled"); return OPERATOR_CANCELLED; } @@ -2130,10 +2130,10 @@ static int select_linked_internal(bContext *C, wmOperator *op, wmEvent *event, i extend= RNA_boolean_get(op->ptr, "extend"); uvedit_pixel_to_float(sima, limit, 0.05f); - if(pick) { + if (pick) { float co[2]; - if(event) { + if (event) { /* invoke */ ARegion *ar= CTX_wm_region(C); @@ -2225,7 +2225,7 @@ static int unlink_selection_exec(bContext *C, wmOperator *op) MTexPoly *tf; MLoopUV *luv; - if(ts->uv_flag & UV_SYNC_SELECTION) { + if (ts->uv_flag & UV_SYNC_SELECTION) { BKE_report(op->reports, RPT_ERROR, "Can't unlink selection when sync selection is enabled"); return OPERATOR_CANCELLED; } @@ -2234,7 +2234,7 @@ static int unlink_selection_exec(bContext *C, wmOperator *op) int desel = 0; 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) { @@ -2297,7 +2297,7 @@ static void uv_faces_do_sticky(bContext *C, SpaceImage *sima, Scene *scene, Obje BMIter iter, liter; /* MTexPoly *tf; */ - if((ts->uv_flag & UV_SYNC_SELECTION)==0 && sima->sticky == SI_STICKY_VERTEX) { + if ((ts->uv_flag & UV_SYNC_SELECTION)==0 && sima->sticky == SI_STICKY_VERTEX) { /* Tag all verts as untouched, then touch the ones that have a face center * in the loop and select all MLoopUV's that use a touched vert. */ BMVert *eve; @@ -2328,7 +2328,7 @@ static void uv_faces_do_sticky(bContext *C, SpaceImage *sima, Scene *scene, Obje } } } - else if((ts->uv_flag & UV_SYNC_SELECTION)==0 && sima->sticky == SI_STICKY_LOC) { + else if ((ts->uv_flag & UV_SYNC_SELECTION)==0 && sima->sticky == SI_STICKY_LOC) { BMFace *efa_vlist; /* MTexPoly *tf_vlist; */ /* UNUSED */ UvMapVert *start_vlist=NULL, *vlist_iter; @@ -2346,10 +2346,10 @@ static void uv_faces_do_sticky(bContext *C, SpaceImage *sima, Scene *scene, Obje /* verts are numbered above in make_uv_vert_map_EM, make sure this stays true! */ /* BMESH_TODO - why keep this commented? - campbell */ #if 0 - for(a=0, eve= em->verts.first; eve; a++, eve= eve->next) + for (a=0, eve= em->verts.first; eve; a++, eve= eve->next) eve->tmp.l = a; #endif - if(vmap == NULL) { + if (vmap == NULL) { return; } @@ -2359,7 +2359,7 @@ static void uv_faces_do_sticky(bContext *C, SpaceImage *sima, Scene *scene, Obje /* tf = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY); */ /* UNUSED */ BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) { - if(select) + if (select) uvedit_uv_select(em, scene, l); else uvedit_uv_deselect(em, scene, l); @@ -2367,10 +2367,10 @@ static void uv_faces_do_sticky(bContext *C, SpaceImage *sima, Scene *scene, Obje vlist_iter= EDBM_get_uv_map_vert(vmap, BM_elem_index_get(l->v)); while (vlist_iter) { - if(vlist_iter->separate) + if (vlist_iter->separate) start_vlist = vlist_iter; - if(efa_index == vlist_iter->f) + if (efa_index == vlist_iter->f) break; vlist_iter = vlist_iter->next; @@ -2379,14 +2379,14 @@ static void uv_faces_do_sticky(bContext *C, SpaceImage *sima, Scene *scene, Obje vlist_iter = start_vlist; while (vlist_iter) { - if(vlist_iter != start_vlist && vlist_iter->separate) + if (vlist_iter != start_vlist && vlist_iter->separate) break; - if(efa_index != vlist_iter->f) { + if (efa_index != vlist_iter->f) { efa_vlist = EDBM_get_face_for_index(em, vlist_iter->f); /* tf_vlist = CustomData_bmesh_get(&em->bm->pdata, efa_vlist->head.data, CD_MTEXPOLY); */ /* UNUSED */ - if(select) + if (select) uvedit_uv_select(em, scene, BM_iter_at_index(em->bm, BM_LOOPS_OF_FACE, efa_vlist, vlist_iter->tfindex)); else uvedit_uv_deselect(em, scene, BM_iter_at_index(em->bm, BM_LOOPS_OF_FACE, efa_vlist, vlist_iter->tfindex)); @@ -2403,7 +2403,7 @@ static void uv_faces_do_sticky(bContext *C, SpaceImage *sima, Scene *scene, Obje else { /* SI_STICKY_DISABLE or ts->uv_flag & UV_SYNC_SELECTION */ BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { if (BM_elem_flag_test(efa, BM_ELEM_TAG)) { - if(select) + if (select) uvedit_face_select(scene, em, efa); else uvedit_face_deselect(scene, em, efa); @@ -2444,16 +2444,16 @@ static int border_select_exec(bContext *C, wmOperator *op) pinned= RNA_boolean_get(op->ptr, "pinned"); extend= RNA_boolean_get(op->ptr, "extend"); - if(!extend) + if (!extend) select_all_perform(C, SEL_DESELECT); - if(ts->uv_flag & UV_SYNC_SELECTION) + if (ts->uv_flag & UV_SYNC_SELECTION) faces= (ts->selectmode == SCE_SELECT_FACE); else faces= (ts->uv_selectmode == UV_SELECT_FACE); /* do actual selection */ - if(faces && !pinned) { + if (faces && !pinned) { /* handle face selection mode */ float cent[2]; @@ -2464,9 +2464,9 @@ static int border_select_exec(bContext *C, wmOperator *op) BM_elem_flag_disable(efa, BM_ELEM_TAG); 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)) { poly_uv_center(em, efa, cent); - if(BLI_in_rctf(&rectf, cent[0], cent[1])) { + if (BLI_in_rctf(&rectf, cent[0], cent[1])) { BM_elem_flag_enable(efa, BM_ELEM_TAG); change = 1; } @@ -2474,7 +2474,7 @@ static int border_select_exec(bContext *C, wmOperator *op) } /* (de)selects all tagged faces and deals with sticky modes */ - if(change) + if (change) uv_faces_do_sticky(C, sima, scene, obedit, select); } else { @@ -2483,22 +2483,23 @@ static int border_select_exec(bContext *C, wmOperator *op) 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); - if(!pinned || (ts->uv_flag & UV_SYNC_SELECTION) ) { + if (!pinned || (ts->uv_flag & UV_SYNC_SELECTION) ) { /* UV_SYNC_SELECTION - can't do pinned selection */ - if(BLI_in_rctf(&rectf, luv->uv[0], luv->uv[1])) { - if(select) uvedit_uv_select(em, scene, l); + if (BLI_in_rctf(&rectf, luv->uv[0], luv->uv[1])) { + if (select) uvedit_uv_select(em, scene, l); else uvedit_uv_deselect(em, scene, l); } - } else if(pinned) { + } + else if (pinned) { if ((luv->flag & MLOOPUV_PINNED) && BLI_in_rctf(&rectf, luv->uv[0], luv->uv[1])) { - if(select) uvedit_uv_select(em, scene, l); + if (select) uvedit_uv_select(em, scene, l); else uvedit_uv_deselect(em, scene, l); } } @@ -2506,12 +2507,12 @@ static int border_select_exec(bContext *C, wmOperator *op) } } - if(change) { + if (change) { /* make sure newly selected vert selection is updated*/ #if 0 /* BM_elem_select_set API handles all of this? */ - if(ts->uv_flag & UV_SYNC_SELECTION) { - if(ts->selectmode != SCE_SELECT_FACE) { - if(select) EDBM_select_flush(em); + if (ts->uv_flag & UV_SYNC_SELECTION) { + if (ts->selectmode != SCE_SELECT_FACE) { + if (select) EDBM_select_flush(em); else EDBM_deselect_flush(em); } } @@ -2563,8 +2564,8 @@ static void select_uv_inside_ellipse(BMEditMesh *em, SpaceImage *UNUSED(sima), S y= (uv[1] - offset[1])*ell[1]; r2 = x*x + y*y; - if(r2 < 1.0f) { - if(select) uvedit_uv_select(em, scene, l); + if (r2 < 1.0f) { + if (select) uvedit_uv_select(em, scene, l); else uvedit_uv_deselect(em, scene, l); } } @@ -2609,7 +2610,7 @@ static int circle_select_exec(bContext *C, wmOperator *op) } #if 0 //I think the BM_elem_select_set api stuff handles all this as necessary? - if(select) EM_select_flush(em); + if (select) EM_select_flush(em); else EM_deselect_flush(em); #endif WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data); @@ -2680,7 +2681,7 @@ static int snap_cursor_exec(bContext *C, wmOperator *op) break; } - if(!change) + if (!change) return OPERATOR_CANCELLED; WM_event_add_notifier(C, NC_SPACE|ND_SPACE_IMAGE, sima); @@ -2723,11 +2724,11 @@ static int snap_uvs_to_cursor(Scene *scene, Image *ima, Object *obedit, SpaceIma BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { tface= CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY); - if(!uvedit_face_visible(scene, ima, efa, tface)) + if (!uvedit_face_visible(scene, ima, efa, tface)) continue; BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) { - if(uvedit_uv_selected(em, scene, l)) { + if (uvedit_uv_selected(em, scene, l)) { luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV); copy_v2_v2(luv->uv, sima->cursor); change= 1; @@ -2765,10 +2766,11 @@ static int snap_uvs_to_adjacent_unselected(Scene *scene, Image *ima, Object *obe * get unique indices and to count how much to malloc */ BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { tface= CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY); - if(!uvedit_face_visible(scene, ima, efa, tface)) { + if (!uvedit_face_visible(scene, ima, efa, tface)) { BM_elem_flag_disable(efa, BM_ELEM_TAG); continue; - } else { + } + else { BM_elem_flag_enable(efa, BM_ELEM_TAG); } @@ -2791,7 +2793,7 @@ static int snap_uvs_to_adjacent_unselected(Scene *scene, Image *ima, Object *obe continue; tface= CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY); - if(!uvedit_face_visible(scene, ima, efa, tface)) + if (!uvedit_face_visible(scene, ima, efa, tface)) continue; BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) { @@ -2805,7 +2807,7 @@ static int snap_uvs_to_adjacent_unselected(Scene *scene, Image *ima, Object *obe } /* no other verts selected, bail out */ - if(!change) { + if (!change) { MEM_freeN(coords); MEM_freeN(usercount); return change; @@ -2817,7 +2819,7 @@ static int snap_uvs_to_adjacent_unselected(Scene *scene, Image *ima, Object *obe continue; tface= CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY); - if(!uvedit_face_visible(scene, ima, efa, tface)) + if (!uvedit_face_visible(scene, ima, efa, tface)) continue; BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) { @@ -2854,7 +2856,7 @@ static int snap_uvs_to_pixels(SpaceImage *sima, Scene *scene, Object *obedit) BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { tface= CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY); - if(!uvedit_face_visible(scene, ima, efa, tface)) + if (!uvedit_face_visible(scene, ima, efa, tface)) continue; BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) { @@ -2890,7 +2892,7 @@ static int snap_selection_exec(bContext *C, wmOperator *op) break; } - if(!change) + if (!change) return OPERATOR_CANCELLED; uvedit_live_unwrap_update(sima, scene, obedit); @@ -2939,16 +2941,17 @@ static int pin_exec(bContext *C, wmOperator *op) BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { tface= CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY); - if(!uvedit_face_visible(scene, ima, efa, tface)) + if (!uvedit_face_visible(scene, ima, efa, tface)) continue; BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) { luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV); - if(!clear) { + if (!clear) { if (uvedit_uv_selected(em, scene, l)) luv->flag |= MLOOPUV_PINNED; - } else { + } + else { if (uvedit_uv_selected(em, scene, l)) luv->flag &= ~MLOOPUV_PINNED; } @@ -2992,7 +2995,7 @@ static int select_pinned_exec(bContext *C, wmOperator *UNUSED(op)) BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { tface= CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY); - if(!uvedit_face_visible(scene, ima, efa, tface)) + if (!uvedit_face_visible(scene, ima, efa, tface)) continue; BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) { @@ -3037,7 +3040,7 @@ static int hide_exec(bContext *C, wmOperator *op) int swap = RNA_boolean_get(op->ptr, "unselected"); int facemode= sima ? sima->flag & SI_SELACTFACE : 0; - if(ts->uv_flag & UV_SYNC_SELECTION) { + if (ts->uv_flag & UV_SYNC_SELECTION) { EDBM_hide_mesh(em, swap); WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data); @@ -3073,7 +3076,8 @@ static int hide_exec(bContext *C, wmOperator *op) BM_elem_select_set(em->bm, efa, FALSE); uvedit_face_deselect(scene, em, efa); } - } else if(em->selectmode == SCE_SELECT_FACE) { + } + else if (em->selectmode == SCE_SELECT_FACE) { /*check if a UV is selected*/ BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) { luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV); @@ -3082,7 +3086,8 @@ static int hide_exec(bContext *C, wmOperator *op) } luv->flag &= ~MLOOPUV_VERTSEL; } - } else { + } + else { 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_VERTSEL) { @@ -3134,14 +3139,14 @@ static int reveal_exec(bContext *C, wmOperator *UNUSED(op)) int stickymode= sima ? (sima->sticky != SI_STICKY_DISABLE) : 1; /* call the mesh function if we are in mesh sync sel */ - if(ts->uv_flag & UV_SYNC_SELECTION) { + if (ts->uv_flag & UV_SYNC_SELECTION) { EDBM_reveal_mesh(em); WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data); return OPERATOR_FINISHED; } - if(facemode) { - if(em->selectmode == SCE_SELECT_FACE) { + if (facemode) { + if (em->selectmode == SCE_SELECT_FACE) { BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN) && !BM_elem_flag_test(efa, BM_ELEM_SELECT)) { BM_elem_select_set(em->bm, efa, TRUE); @@ -3154,7 +3159,7 @@ static int reveal_exec(bContext *C, wmOperator *UNUSED(op)) } else { /* enable adjacent faces to have disconnected UV selections if sticky is disabled */ - if(!stickymode) { + if (!stickymode) { BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN) && !BM_elem_flag_test(efa, BM_ELEM_SELECT)) { int totsel=0; @@ -3172,7 +3177,8 @@ static int reveal_exec(bContext *C, wmOperator *UNUSED(op)) } } } - } else { + } + else { BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN) && !BM_elem_flag_test(efa, BM_ELEM_SELECT)) { BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) { @@ -3187,7 +3193,8 @@ static int reveal_exec(bContext *C, wmOperator *UNUSED(op)) } } } - } else if(em->selectmode == SCE_SELECT_FACE) { + } + else if (em->selectmode == SCE_SELECT_FACE) { BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN) && !BM_elem_flag_test(efa, BM_ELEM_SELECT)) { BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) { @@ -3198,7 +3205,8 @@ static int reveal_exec(bContext *C, wmOperator *UNUSED(op)) BM_elem_select_set(em->bm, efa, TRUE); } } - } else { + } + else { BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN) && !BM_elem_flag_test(efa, BM_ELEM_SELECT)) { BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) { @@ -3238,7 +3246,7 @@ static int set_2d_cursor_exec(bContext *C, wmOperator *op) SpaceImage *sima = CTX_wm_space_image(C); float location[2]; - if(!sima) + if (!sima) return OPERATOR_CANCELLED; RNA_float_get_array(op->ptr, "location", location); @@ -3290,7 +3298,7 @@ static int set_tile_exec(bContext *C, wmOperator *op) RNA_int_get_array(op->ptr, "tile", tile); - if(uvedit_set_tile(obedit, ima, tile[0] + ima->xrep*tile[1])) { + if (uvedit_set_tile(obedit, ima, tile[0] + ima->xrep*tile[1])) { WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); WM_event_add_notifier(C, NC_SPACE|ND_SPACE_IMAGE, NULL); @@ -3308,12 +3316,12 @@ static int set_tile_invoke(bContext *C, wmOperator *op, wmEvent *event) float fx, fy; int tile[2]; - if(!ima || !(ima->tpageflag & IMA_TILES)) + if (!ima || !(ima->tpageflag & IMA_TILES)) return OPERATOR_CANCELLED; 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) { fx= fx*ima->xrep; fy= fy*ima->yrep; @@ -3364,7 +3372,7 @@ static int seams_from_islands_exec(bContext *C, wmOperator *op) em = me->edit_btmesh; bm = em->bm; - if(!EDBM_texFaceCheck(em)) { + if (!EDBM_texFaceCheck(em)) { return OPERATOR_CANCELLED; } @@ -3390,34 +3398,34 @@ static int seams_from_islands_exec(bContext *C, wmOperator *op) UvMapVert *mv2cache = NULL, *mv2sep = NULL; mvinit1 = vmap->vert[BM_elem_index_get(editedge->v1)]; - if(mark_seams) + if (mark_seams) BM_elem_flag_disable(editedge, BM_ELEM_SEAM); - for(mv1 = mvinit1; mv1 && !faces_separated; mv1 = mv1->next) { - if(mv1->separate && commonFaces) + for (mv1 = mvinit1; mv1 && !faces_separated; mv1 = mv1->next) { + if (mv1->separate && commonFaces) v1coincident = 0; separated2 = 0; efa1 = EDBM_get_face_for_index(em, mv1->f); mvinit2 = vmap->vert[BM_elem_index_get(editedge->v2)]; - for(mv2 = mvinit2; mv2; mv2 = mv2->next) { - if(mv2->separate) + for (mv2 = mvinit2; mv2; mv2 = mv2->next) { + if (mv2->separate) mv2sep = mv2; efa2 = EDBM_get_face_for_index(em, mv2->f); - if(efa1 == efa2) { + if (efa1 == efa2) { /* if v1 is not coincident no point in comparing */ - if(v1coincident) { + if (v1coincident) { /* have we found previously anything? */ - if(mv2cache) { + if (mv2cache) { /* flag seam unless proved to be coincident with previous hit */ separated2 = 1; - for(mviter = mv2cache; mviter; mviter = mviter->next) { - if(mviter->separate && mviter != mv2cache) + for (mviter = mv2cache; mviter; mviter = mviter->next) { + if (mviter->separate && mviter != mv2cache) break; /* coincident with previous hit, do not flag seam */ - if(mviter == mv2) + if (mviter == mv2) separated2 = 0; } } @@ -3430,7 +3438,7 @@ static int seams_from_islands_exec(bContext *C, wmOperator *op) else separated1 = 1; - if(separated1 || separated2) { + if (separated1 || separated2) { faces_separated = 1; break; } @@ -3438,10 +3446,10 @@ static int seams_from_islands_exec(bContext *C, wmOperator *op) } } - if(faces_separated) { - if(mark_seams) + if (faces_separated) { + if (mark_seams) BM_elem_flag_enable(editedge, BM_ELEM_SEAM); - if(mark_sharp) + if (mark_sharp) BM_elem_flag_disable(editedge, BM_ELEM_SMOOTH); } } @@ -3490,7 +3498,7 @@ static int mark_seam_exec(bContext *C, wmOperator *UNUSED(op)) BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { BM_ITER(loop, &liter, bm, BM_LOOPS_OF_FACE, efa) { - if(uvedit_edge_selected(em, scene, loop)) { + if (uvedit_edge_selected(em, scene, loop)) { BM_elem_flag_enable(loop, BM_ELEM_SEAM); } } @@ -3498,7 +3506,7 @@ static int mark_seam_exec(bContext *C, wmOperator *UNUSED(op)) me->drawflag |= ME_DRAWSEAMS; - if(scene->toolsettings->edge_mode_live_unwrap) + if (scene->toolsettings->edge_mode_live_unwrap) ED_unwrap_lscm(scene, ob, FALSE); DAG_id_tag_update(&me->id, 0); diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.c b/source/blender/editors/uvedit/uvedit_parametrizer.c index d6035b08fd6..7d388e6206c 100644 --- a/source/blender/editors/uvedit/uvedit_parametrizer.c +++ b/source/blender/editors/uvedit/uvedit_parametrizer.c @@ -800,12 +800,12 @@ static PBool p_edge_implicit_seam(PEdge *e, PEdge *ep) uvp2 = ep->orig_uv; } - if((fabsf(uv1[0]-uvp1[0]) > limit[0]) || (fabsf(uv1[1]-uvp1[1]) > limit[1])) { + if ((fabsf(uv1[0]-uvp1[0]) > limit[0]) || (fabsf(uv1[1]-uvp1[1]) > limit[1])) { e->flag |= PEDGE_SEAM; ep->flag |= PEDGE_SEAM; return P_TRUE; } - if((fabsf(uv2[0]-uvp2[0]) > limit[0]) || (fabsf(uv2[1]-uvp2[1]) > limit[1])) { + if ((fabsf(uv2[0]-uvp2[0]) > limit[0]) || (fabsf(uv2[1]-uvp2[1]) > limit[1])) { e->flag |= PEDGE_SEAM; ep->flag |= PEDGE_SEAM; return P_TRUE; @@ -866,7 +866,7 @@ static PBool p_edge_connect_pair(PHandle *handle, PEdge *e, PEdge ***stack, PBoo { PEdge *pair = NULL; - if(!e->pair && p_edge_has_pair(handle, e, &pair, impl)) { + if (!e->pair && p_edge_has_pair(handle, e, &pair, impl)) { if (e->vert == pair->vert) p_face_flip(pair->face); @@ -1162,7 +1162,7 @@ static void p_chart_boundaries(PChart *chart, int *nboundaries, PEdge **outer) be->flag |= PEDGE_DONE; len += p_edge_length(be); be = be->next->vert->edge; - } while(be != e); + } while (be != e); if (outer && (len > maxlen)) { *outer = e; @@ -1213,7 +1213,7 @@ static void p_chart_fill_boundary(PChart *chart, PEdge *be, int nedges) e->u.heaplink = BLI_heap_insert(heap, angle, e); e = p_boundary_edge_next(e); - } while(e != be); + } while (e != be); if (nedges == 2) { /* no real boundary, but an isolated seam */ @@ -1297,7 +1297,7 @@ static void p_chart_fill_boundaries(PChart *chart, PEdge *outer) be->flag |= PEDGE_FILLED; be = be->next->vert->edge; nedges++; - } while(be != e); + } while (be != e); if (e != outer) p_chart_fill_boundary(chart, e, nedges); @@ -2847,7 +2847,7 @@ static PBool p_chart_symmetry_pins(PChart *chart, PEdge *outer, PVert **pin1, PV lastbe = be; be = nextbe; - } while(be != outer); + } while (be != outer); /* make sure we also count a series of splits over the starting point */ if (cure && (cure != outer)) { @@ -3180,7 +3180,7 @@ static void p_stretch_pin_boundary(PChart *chart) { PVert *v; - for(v=chart->verts; v; v=v->nextlink) + for (v=chart->verts; v; v=v->nextlink) if (v->edge->pair == NULL) v->flag |= PVERT_PIN; else @@ -3261,8 +3261,8 @@ static void p_chart_stretch_minimize(PChart *chart, RNG *rng) float orig_stretch, low, stretch_low, high, stretch_high, mid, stretch; float orig_uv[2], dir[2], random_angle, trusted_radius; - for(v=chart->verts; v; v=v->nextlink) { - if((v->flag & PVERT_PIN) || !(v->flag & PVERT_SELECT)) + for (v=chart->verts; v; v=v->nextlink) { + if ((v->flag & PVERT_PIN) || !(v->flag & PVERT_SELECT)) continue; orig_stretch = p_stretch_compute_vertex(v); @@ -3313,7 +3313,7 @@ static void p_chart_stretch_minimize(PChart *chart, RNG *rng) } /* no luck, stretch has increased, reset to old values */ - if(stretch >= orig_stretch) + if (stretch >= orig_stretch) copy_v2_v2(v->uv, orig_uv); } } @@ -3357,7 +3357,7 @@ static PBool p_chart_convex_hull(PChart *chart, PVert ***verts, int *nverts, int do { npoints++; e = p_boundary_edge_next(e); - } while(e != be); + } while (e != be); p = points = (PVert**)MEM_mallocN(sizeof(PVert*)*npoints*2, "PCHullpoints"); U = (PVert**)MEM_mallocN(sizeof(PVert*)*npoints, "PCHullU"); @@ -3368,7 +3368,7 @@ static PBool p_chart_convex_hull(PChart *chart, PVert ***verts, int *nverts, int *p = e->vert; p++; e = p_boundary_edge_next(e); - } while(e != be); + } while (e != be); qsort(points, npoints, sizeof(PVert*), p_compare_geometric_uv); @@ -3792,7 +3792,7 @@ static void p_smooth(PChart *chart) nwheel++; e = e->next->next->pair; - } while(e && (e != v->edge)); + } while (e && (e != v->edge)); v->u.distortion /= nwheel; } @@ -4344,7 +4344,7 @@ void param_pack(ParamHandle *handle, float margin) if (phandle->ncharts == 0) return; - if(phandle->aspx != phandle->aspy) + if (phandle->aspx != phandle->aspy) param_scale(handle, 1.0f/phandle->aspx, 1.0f/phandle->aspy); /* we may not use all these boxes */ @@ -4372,11 +4372,11 @@ void param_pack(ParamHandle *handle, float margin) box->h = chart->u.pack.size[1] + trans[1]; box->index = i; /* warning this index skips PCHART_NOPACK boxes */ - if(margin>0.0f) + if (margin>0.0f) area += sqrt(box->w*box->h); } - if(margin>0.0f) { + if (margin>0.0f) { /* multiply the margin by the area to give predictable results not dependent on UV scale, * ...Without using the area running pack multiple times also gives a bad feedback loop. * multiply by 0.1 so the margin value from the UI can be from 0.0 to 1.0 but not give a massive margin */ @@ -4417,7 +4417,7 @@ void param_pack(ParamHandle *handle, float margin) } MEM_freeN(boxarray); - if(phandle->aspx != phandle->aspy) + if (phandle->aspx != phandle->aspy) param_scale(handle, phandle->aspx, phandle->aspy); } diff --git a/source/blender/editors/uvedit/uvedit_smart_stitch.c b/source/blender/editors/uvedit/uvedit_smart_stitch.c index ad96142ae86..af87f4d4b07 100644 --- a/source/blender/editors/uvedit/uvedit_smart_stitch.c +++ b/source/blender/editors/uvedit/uvedit_smart_stitch.c @@ -185,24 +185,24 @@ static StitchPreviewer * stitch_preview_init(void) /* destructor...yeah this should be C++ :) */ static void stitch_preview_delete(void) { - if(_stitch_preview) { - if(_stitch_preview->preview_polys){ + if (_stitch_preview) { + if (_stitch_preview->preview_polys) { MEM_freeN(_stitch_preview->preview_polys); _stitch_preview->preview_polys = NULL; } - if(_stitch_preview->uvs_per_polygon){ + if (_stitch_preview->uvs_per_polygon) { MEM_freeN(_stitch_preview->uvs_per_polygon); _stitch_preview->uvs_per_polygon = NULL; } - if(_stitch_preview->preview_stitchable){ + if (_stitch_preview->preview_stitchable) { MEM_freeN(_stitch_preview->preview_stitchable); _stitch_preview->preview_stitchable = NULL; } - if(_stitch_preview->preview_unstitchable){ + if (_stitch_preview->preview_unstitchable) { MEM_freeN(_stitch_preview->preview_unstitchable); _stitch_preview->preview_unstitchable = NULL; } - if(_stitch_preview->static_tris){ + if (_stitch_preview->static_tris) { MEM_freeN(_stitch_preview->static_tris); _stitch_preview->static_tris = NULL; } @@ -229,7 +229,7 @@ static void stitch_update_header(StitchState *stitch_state, bContext *C) char msg[HEADER_LENGTH]; ScrArea *sa= CTX_wm_area(C); - if(sa) { + if (sa) { BLI_snprintf(msg, HEADER_LENGTH, str, stitch_state->snap_islands? "On" : "Off", stitch_state->midpoints? "On": "Off", @@ -242,9 +242,10 @@ static void stitch_update_header(StitchState *stitch_state, bContext *C) static int getNumOfIslandUvs(UvElementMap *elementMap, int island) { - if(island == elementMap->totalIslands-1){ + if (island == elementMap->totalIslands-1) { return elementMap->totalUVs - elementMap->islandIndices[island]; - }else{ + } + else { return elementMap->islandIndices[island+1] - elementMap->islandIndices[island]; } } @@ -268,14 +269,14 @@ static int stitch_check_uvs_stitchable(UvElement *element, UvElement *element_it float limit; int do_limit; - if(element_iter == element){ + if (element_iter == element) { return 0; } limit = state->limit_dist; do_limit = state->use_limit; - if(do_limit){ + if (do_limit) { MLoopUV *luv_orig, *luv_iter; BMLoop *l_orig, *l_iter; @@ -285,19 +286,23 @@ static int stitch_check_uvs_stitchable(UvElement *element, UvElement *element_it l_iter = element_iter->l; luv_iter = CustomData_bmesh_get(&state->em->bm->ldata, l_iter->head.data, CD_MLOOPUV); - if(fabs(luv_orig->uv[0] - luv_iter->uv[0]) < limit - && fabs(luv_orig->uv[1] - luv_iter->uv[1]) < limit){ + if (fabs(luv_orig->uv[0] - luv_iter->uv[0]) < limit + && fabs(luv_orig->uv[1] - luv_iter->uv[1]) < limit) { return 1; - }else + } + else { return 0; - }else + } + } + else { return 1; + } } static int stitch_check_uvs_state_stitchable(UvElement *element, UvElement *element_iter, StitchState *state) { - if((state->snap_islands && element->island == element_iter->island) || + if ((state->snap_islands && element->island == element_iter->island) || (!state->midpoints && element->island == element_iter->island)) return 0; @@ -311,12 +316,12 @@ static void stitch_calculate_island_snapping(StitchState *state, PreviewPosition int i; UvElement *element; - for(i = 0; i < state->element_map->totalIslands; i++){ - if(island_stitch_data[i].addedForPreview){ + for (i = 0; i < state->element_map->totalIslands; i++) { + if (island_stitch_data[i].addedForPreview) { int numOfIslandUVs = 0, j; /* check to avoid divide by 0 */ - if(island_stitch_data[i].num_rot_elements>0){ + if (island_stitch_data[i].num_rot_elements>0) { island_stitch_data[i].rotation /= island_stitch_data[i].num_rot_elements; island_stitch_data[i].medianPoint[0] /= island_stitch_data[i].numOfElements; island_stitch_data[i].medianPoint[1] /= island_stitch_data[i].numOfElements; @@ -325,16 +330,16 @@ static void stitch_calculate_island_snapping(StitchState *state, PreviewPosition island_stitch_data[i].translation[1] /= island_stitch_data[i].numOfElements; numOfIslandUVs = getNumOfIslandUvs(state->element_map, i); element = &state->element_map->buf[state->element_map->islandIndices[i]]; - for(j = 0; j < numOfIslandUVs; j++, element++){ + for (j = 0; j < numOfIslandUVs; j++, element++) { /* stitchable uvs have already been processed, don't process */ - if(!(element->flag & STITCH_PROCESSED)){ + if (!(element->flag & STITCH_PROCESSED)) { MLoopUV *luv; BMLoop *l; l = element->l; luv = CustomData_bmesh_get(&state->em->bm->ldata, l->head.data, CD_MLOOPUV); - if(final){ + if (final) { stitch_uv_rotate(island_stitch_data[i].rotation, island_stitch_data[i].medianPoint, luv->uv); @@ -410,7 +415,7 @@ static void stitch_island_calculate_vert_rotation(UvElement *element, StitchStat float rotation = 0; BMLoop *l; - if(element->island == state->static_island && !state->midpoints) + if (element->island == state->static_island && !state->midpoints) return; l = element->l; @@ -419,8 +424,8 @@ static void stitch_island_calculate_vert_rotation(UvElement *element, StitchStat element_iter = state->element_map->vert[index]; - for(; element_iter; element_iter = element_iter->next){ - if(element_iter->separate && stitch_check_uvs_state_stitchable(element, element_iter, state)){ + for (; element_iter; element_iter = element_iter->next) { + if (element_iter->separate && stitch_check_uvs_state_stitchable(element, element_iter, state)) { int index_tmp1, index_tmp2; float normal[2]; /* easily possible*/ @@ -437,7 +442,7 @@ static void stitch_island_calculate_vert_rotation(UvElement *element, StitchStat } } - if(state->midpoints) + if (state->midpoints) rotation /= 2.0; island_stitch_data[element->island].num_rot_elements++; island_stitch_data[element->island].rotation += rotation; @@ -446,26 +451,26 @@ static void stitch_island_calculate_vert_rotation(UvElement *element, StitchStat static void stitch_state_delete(StitchState *stitch_state) { - if(stitch_state){ - if(stitch_state->element_map){ + if (stitch_state) { + if (stitch_state->element_map) { EDBM_free_uv_element_map(stitch_state->element_map); } - if(stitch_state->uvs){ + if (stitch_state->uvs) { MEM_freeN(stitch_state->uvs); } - if(stitch_state->selection_stack){ + if (stitch_state->selection_stack) { MEM_freeN(stitch_state->selection_stack); } - if(stitch_state->tris_per_island){ + if (stitch_state->tris_per_island) { MEM_freeN(stitch_state->tris_per_island); } - if(stitch_state->map){ + if (stitch_state->map) { MEM_freeN(stitch_state->map); } - if(stitch_state->normals){ + if (stitch_state->normals) { MEM_freeN(stitch_state->normals); } - if(stitch_state->edges){ + if (stitch_state->edges) { MEM_freeN(stitch_state->edges); } MEM_freeN(stitch_state); @@ -486,12 +491,12 @@ static void determine_uv_stitchability(UvElement *element, StitchState *state, I vert_index = BM_elem_index_get(l->v); element_iter = state->element_map->vert[vert_index]; - for(; element_iter; element_iter = element_iter->next){ - if(element_iter->separate){ - if(element_iter == element){ + for (; element_iter; element_iter = element_iter->next) { + if (element_iter->separate) { + if (element_iter == element) { continue; } - if(stitch_check_uvs_stitchable(element, element_iter, state)){ + if (stitch_check_uvs_stitchable(element, element_iter, state)) { island_stitch_data[element_iter->island].stitchableCandidate = 1; island_stitch_data[element->island].stitchableCandidate = 1; element->flag |= STITCH_STITCHABLE_CANDIDATE; @@ -506,7 +511,7 @@ static void stitch_set_face_preview_buffer_position(BMFace *efa, StitchPreviewer { int index = BM_elem_index_get(efa); - if(preview_position[index].data_position == STITCH_NO_PREVIEW) { + if (preview_position[index].data_position == STITCH_NO_PREVIEW) { preview_position[index].data_position = preview->preview_uvs*2; preview_position[index].polycount_position = preview->num_polys++; preview->preview_uvs += efa->len; @@ -516,27 +521,27 @@ static void stitch_set_face_preview_buffer_position(BMFace *efa, StitchPreviewer /* setup face preview for all coincident uvs and their faces */ static void stitch_setup_face_preview_for_uv_group(UvElement *element, StitchState *state, IslandStitchData *island_stitch_data, - PreviewPosition *preview_position){ + PreviewPosition *preview_position) { StitchPreviewer *preview = uv_get_stitch_previewer(); /* static island does not change so returning immediately */ - if(state->snap_islands && !state->midpoints && state->static_island == element->island) + if (state->snap_islands && !state->midpoints && state->static_island == element->island) return; - if(state->snap_islands){ + if (state->snap_islands) { island_stitch_data[element->island].addedForPreview = 1; } do { stitch_set_face_preview_buffer_position(element->face, preview, preview_position); element = element->next; - } while(element && !element->separate); + } while (element && !element->separate); } /* checks if uvs are indeed stitchable and registers so that they can be shown in preview */ static void stitch_validate_stichability (UvElement *element, StitchState *state, IslandStitchData *island_stitch_data, - PreviewPosition *preview_position){ + PreviewPosition *preview_position) { UvElement *element_iter; StitchPreviewer *preview; int vert_index; @@ -549,12 +554,12 @@ static void stitch_validate_stichability (UvElement *element, StitchState *state preview = uv_get_stitch_previewer(); element_iter = state->element_map->vert[vert_index]; - for(; element_iter; element_iter = element_iter->next){ - if(element_iter->separate){ - if(element_iter == element) + for (; element_iter; element_iter = element_iter->next) { + if (element_iter->separate) { + if (element_iter == element) continue; - if(stitch_check_uvs_state_stitchable(element, element_iter, state)){ - if((element_iter->island == state->static_island) || (element->island == state->static_island)){ + if (stitch_check_uvs_state_stitchable(element, element_iter, state)) { + if ((element_iter->island == state->static_island) || (element->island == state->static_island)) { element->flag |= STITCH_STITCHABLE; preview->num_stitchable++; stitch_setup_face_preview_for_uv_group(element, state, island_stitch_data, preview_position); @@ -565,7 +570,7 @@ static void stitch_validate_stichability (UvElement *element, StitchState *state } /* this can happen if the uvs to be stitched are not on a stitchable island */ - if(!(element->flag & STITCH_STITCHABLE)){ + if (!(element->flag & STITCH_STITCHABLE)) { preview->num_unstitchable++; } } @@ -589,17 +594,17 @@ static int stitch_process_data(StitchState *state, Scene *scene, int final) /* cleanup previous preview */ stitch_preview_delete(); preview = stitch_preview_init(); - if(preview == NULL) + if (preview == NULL) return 0; preview_position = MEM_mallocN(state->em->bm->totface*sizeof(*preview_position), "stitch_face_preview_position"); /* each face holds its position in the preview buffer in tmp. -1 is uninitialized */ - for(i = 0; i < state->em->bm->totface; i++){ + for (i = 0; i < state->em->bm->totface; i++) { preview_position[i].data_position = STITCH_NO_PREVIEW; } island_stitch_data = MEM_callocN(sizeof(*island_stitch_data)*state->element_map->totalIslands, "stitch_island_data"); - if(!island_stitch_data){ + if (!island_stitch_data) { return 0; } @@ -610,27 +615,28 @@ static int stitch_process_data(StitchState *state, Scene *scene, int final) * First determine stitchability of uvs * *****************************************/ - for(i = 0; i < state->selection_size; i++){ + for (i = 0; i < state->selection_size; i++) { UvElement *element = state->selection_stack[i]; determine_uv_stitchability(element, state, island_stitch_data); } /* set static island to one that is added for preview */ state->static_island %= state->element_map->totalIslands; - while(!(island_stitch_data[state->static_island].stitchableCandidate)){ + while (!(island_stitch_data[state->static_island].stitchableCandidate)) { state->static_island++; state->static_island %= state->element_map->totalIslands; /* this is entirely possible if for example limit stitching with no stitchable verts or no selection */ - if(state->static_island == previous_island) + if (state->static_island == previous_island) break; } - for(i = 0; i < state->selection_size; i++){ + for (i = 0; i < state->selection_size; i++) { UvElement *element = state->selection_stack[i]; - if(element->flag & STITCH_STITCHABLE_CANDIDATE){ + if (element->flag & STITCH_STITCHABLE_CANDIDATE) { element->flag &= ~STITCH_STITCHABLE_CANDIDATE; stitch_validate_stichability(element, state, island_stitch_data, preview_position); - }else{ + } + else { /* add to preview for unstitchable */ preview->num_unstitchable++; } @@ -639,14 +645,14 @@ static int stitch_process_data(StitchState *state, Scene *scene, int final) /***************************************** * Setup preview for stitchable islands * *****************************************/ - if(state->snap_islands){ - for(i = 0; i < state->element_map->totalIslands; i++){ - if(island_stitch_data[i].addedForPreview){ + if (state->snap_islands) { + for (i = 0; i < state->element_map->totalIslands; i++) { + if (island_stitch_data[i].addedForPreview) { int numOfIslandUVs = 0, j; UvElement *element; numOfIslandUVs = getNumOfIslandUvs(state->element_map, i); element = &state->element_map->buf[state->element_map->islandIndices[i]]; - for(j = 0; j < numOfIslandUVs; j++, element++){ + for (j = 0; j < numOfIslandUVs; j++, element++) { stitch_set_face_preview_buffer_position(element->face, preview, preview_position); } } @@ -656,7 +662,7 @@ static int stitch_process_data(StitchState *state, Scene *scene, int final) /********************************************************************* * Setup the preview buffers and fill them with the appropriate data * *********************************************************************/ - if(!final){ + if (!final) { BMIter liter; BMLoop *l; MLoopUV *luv; @@ -672,7 +678,7 @@ static int stitch_process_data(StitchState *state, Scene *scene, int final) preview->num_static_tris = state->tris_per_island[state->static_island]; /* will cause cancel and freeing of all data structures so OK */ - if(!preview->preview_polys || !preview->preview_stitchable || !preview->preview_unstitchable){ + if (!preview->preview_polys || !preview->preview_stitchable || !preview->preview_unstitchable) { return 0; } @@ -681,11 +687,11 @@ static int stitch_process_data(StitchState *state, Scene *scene, int final) /* just to test if face was added for processing. uvs of inselected vertices will return NULL */ UvElement *element = ED_get_uv_element(state->element_map, efa, BM_FACE_FIRST_LOOP(efa)); - if(element){ + if (element) { int numoftris = efa->len - 2; int index = BM_elem_index_get(efa); int face_preview_pos = preview_position[index].data_position; - if(face_preview_pos != STITCH_NO_PREVIEW){ + if (face_preview_pos != STITCH_NO_PREVIEW) { preview->uvs_per_polygon[preview_position[index].polycount_position] = efa->len; BM_ITER_INDEX(l, &liter, state->em->bm, BM_LOOPS_OF_FACE, efa, i) { luv = CustomData_bmesh_get(&state->em->bm->ldata, l->head.data, CD_MLOOPUV); @@ -693,12 +699,12 @@ static int stitch_process_data(StitchState *state, Scene *scene, int final) } } - if(element->island == state->static_island){ + if (element->island == state->static_island) { BMLoop *fl = BM_FACE_FIRST_LOOP(efa); MLoopUV *fuv = CustomData_bmesh_get(&state->em->bm->ldata, fl->head.data, CD_MLOOPUV); BM_ITER_INDEX(l, &liter, state->em->bm, BM_LOOPS_OF_FACE, efa, i) { - if(i < numoftris){ + if (i < numoftris) { /* using next since the first uv is already accounted for */ BMLoop *lnext = l->next; MLoopUV *luvnext = CustomData_bmesh_get(&state->em->bm->ldata, lnext->next->head.data, CD_MLOOPUV); @@ -708,16 +714,19 @@ static int stitch_process_data(StitchState *state, Scene *scene, int final) memcpy(preview->static_tris + buffer_index + 2, luv->uv, 2*sizeof(float)); memcpy(preview->static_tris + buffer_index + 4, luvnext->uv, 2*sizeof(float)); buffer_index += 6; - }else break; + } + else { + break; + } } } } } /* fill the appropriate preview buffers */ - for(i = 0; i < state->total_separate_uvs; i++){ + for (i = 0; i < state->total_separate_uvs; i++) { UvElement *element = (UvElement *)state->uvs[i]; - if(element->flag & STITCH_STITCHABLE){ + if (element->flag & STITCH_STITCHABLE) { l = element->l; luv = CustomData_bmesh_get(&state->em->bm->ldata, l->head.data, CD_MLOOPUV); @@ -725,7 +734,7 @@ static int stitch_process_data(StitchState *state, Scene *scene, int final) stitchBufferIndex++; } - else if(element->flag & STITCH_SELECTED){ + else if (element->flag & STITCH_SELECTED) { l = element->l; luv = CustomData_bmesh_get(&state->em->bm->ldata, l->head.data, CD_MLOOPUV); @@ -743,9 +752,9 @@ static int stitch_process_data(StitchState *state, Scene *scene, int final) uvfinal_map = MEM_mallocN(state->element_map->totalUVs*sizeof(*uvfinal_map), "stitch_uv_final_map"); /* first pass, calculate final position for stitchable uvs of the static island */ - for(i = 0; i < state->selection_size; i++){ + for (i = 0; i < state->selection_size; i++) { UvElement *element = state->selection_stack[i]; - if(element->flag & STITCH_STITCHABLE){ + if (element->flag & STITCH_STITCHABLE) { BMLoop *l; MLoopUV *luv; UvElement *element_iter; @@ -759,20 +768,21 @@ static int stitch_process_data(StitchState *state, Scene *scene, int final) copy_v2_v2(final_position[i].uv, luv->uv); final_position[i].count = 1; - if(state->snap_islands && element->island == state->static_island && !stitch_midpoints) + if (state->snap_islands && element->island == state->static_island && !stitch_midpoints) continue; element_iter = state->element_map->vert[BM_elem_index_get(l->v)]; - for(;element_iter; element_iter = element_iter->next){ - if(element_iter->separate){ - if(stitch_check_uvs_state_stitchable(element, element_iter, state)){ + for (;element_iter; element_iter = element_iter->next) { + if (element_iter->separate) { + if (stitch_check_uvs_state_stitchable(element, element_iter, state)) { l = element_iter->l; luv = CustomData_bmesh_get(&state->em->bm->ldata, l->head.data, CD_MLOOPUV); - if(stitch_midpoints){ + if (stitch_midpoints) { add_v2_v2(final_position[i].uv, luv->uv); final_position[i].count++; - }else if(element_iter->island == state->static_island){ + } + else if (element_iter->island == state->static_island) { /* if multiple uvs on the static island exist, * last checked remains. to disambiguate we need to limit or use * edge stitch */ @@ -782,17 +792,17 @@ static int stitch_process_data(StitchState *state, Scene *scene, int final) } } } - if(stitch_midpoints){ + if (stitch_midpoints) { final_position[i].uv[0] /= final_position[i].count; final_position[i].uv[1] /= final_position[i].count; } } /* second pass, calculate island rotation and translation before modifying any uvs */ - if(state->snap_islands){ - for(i = 0; i < state->selection_size; i++){ + if (state->snap_islands) { + for (i = 0; i < state->selection_size; i++) { UvElement *element = state->selection_stack[i]; - if(element->flag & STITCH_STITCHABLE){ + if (element->flag & STITCH_STITCHABLE) { BMLoop *l; MLoopUV *luv; @@ -810,18 +820,18 @@ static int stitch_process_data(StitchState *state, Scene *scene, int final) } /* only calculate rotation when an edge has been fully selected */ - for(i = 0; i < state->total_boundary_edges; i++){ + for (i = 0; i < state->total_boundary_edges; i++) { UvEdge *edge = state->edges+i; - if((state->uvs[edge->uv1]->flag & STITCH_STITCHABLE) && (state->uvs[edge->uv2]->flag & STITCH_STITCHABLE)){ + if ((state->uvs[edge->uv1]->flag & STITCH_STITCHABLE) && (state->uvs[edge->uv2]->flag & STITCH_STITCHABLE)) { stitch_island_calculate_edge_rotation(edge, state, final_position, uvfinal_map, island_stitch_data); island_stitch_data[state->uvs[edge->uv1]->island].use_edge_rotation = 1; } } - for(i = 0; i < state->selection_size; i++){ + for (i = 0; i < state->selection_size; i++) { UvElement *element = state->selection_stack[i]; - if(!island_stitch_data[element->island].use_edge_rotation){ - if(element->flag & STITCH_STITCHABLE){ + if (!island_stitch_data[element->island].use_edge_rotation) { + if (element->flag & STITCH_STITCHABLE) { stitch_island_calculate_vert_rotation(element, state, island_stitch_data); } } @@ -830,9 +840,9 @@ static int stitch_process_data(StitchState *state, Scene *scene, int final) } /* third pass, propagate changes to coincident uvs */ - for(i = 0; i < state->selection_size; i++){ + for (i = 0; i < state->selection_size; i++) { UvElement *element = state->selection_stack[i]; - if(element->flag & STITCH_STITCHABLE){ + if (element->flag & STITCH_STITCHABLE) { UvElement *element_iter = element; /* propagate to coincident uvs */ do { @@ -844,30 +854,31 @@ static int stitch_process_data(StitchState *state, Scene *scene, int final) element_iter->flag |= STITCH_PROCESSED; /* either flush to preview or to the MTFace, if final */ - if(final){ + if (final) { copy_v2_v2(luv->uv, final_position[i].uv); uvedit_uv_select(state->em, scene, l); - }else { + } + else { int face_preview_pos = preview_position[BM_elem_index_get(element_iter->face)].data_position; - if(face_preview_pos != STITCH_NO_PREVIEW){ + if (face_preview_pos != STITCH_NO_PREVIEW) { copy_v2_v2(preview->preview_polys + face_preview_pos + 2*element_iter->tfindex, final_position[i].uv); } } /* end of calculations, keep only the selection flag */ - if( (!state->snap_islands) || ((!stitch_midpoints) && (element_iter->island == state->static_island))) { + if ( (!state->snap_islands) || ((!stitch_midpoints) && (element_iter->island == state->static_island))) { element_iter->flag &= STITCH_SELECTED; } element_iter = element_iter->next; - } while(element_iter && !element_iter->separate); + } while (element_iter && !element_iter->separate); } } /* final pass, calculate Island translation/rotation if needed */ - if(state->snap_islands){ + if (state->snap_islands) { stitch_calculate_island_snapping(state, preview_position, preview, island_stitch_data, final); } @@ -893,7 +904,7 @@ static int uv_edge_compare(const void *a, const void *b) UvEdge *edge1 = (UvEdge *)a; UvEdge *edge2 = (UvEdge *)b; - if((edge1->uv1 == edge2->uv1) && (edge1->uv2 == edge2->uv2)){ + if ((edge1->uv1 == edge2->uv1) && (edge1->uv2 == edge2->uv2)) { return 0; } return 1; @@ -911,23 +922,24 @@ static void stitch_select_uv(UvElement *element, StitchState *state, int always_ element_iter = state->element_map->vert[BM_elem_index_get(l->v)]; /* first deselect all common uvs */ - for(; element_iter; element_iter = element_iter->next){ - if(element_iter->separate){ + for (; element_iter; element_iter = element_iter->next) { + if (element_iter->separate) { /* only separators go to selection */ - if(element_iter->flag & STITCH_SELECTED){ + if (element_iter->flag & STITCH_SELECTED) { int i; - if(always_select) + if (always_select) continue; element_iter->flag &= ~STITCH_SELECTED; - for(i = 0; i < state->selection_size; i++){ - if(selection_stack[i] == element_iter){ + for (i = 0; i < state->selection_size; i++) { + if (selection_stack[i] == element_iter) { (state->selection_size)--; selection_stack[i] = selection_stack[state->selection_size]; break; } } - }else{ + } + else { element_iter->flag |= STITCH_SELECTED; selection_stack[state->selection_size++] = element_iter; } @@ -977,7 +989,7 @@ static int stitch_init(bContext *C, wmOperator *op) op->customdata = state; - if(!state) + if (!state) return 0; /* initialize state */ @@ -988,12 +1000,13 @@ static int stitch_init(bContext *C, wmOperator *op) state->static_island = RNA_int_get(op->ptr, "static_island"); state->midpoints = RNA_boolean_get(op->ptr, "midpoint_snap"); /* in uv synch selection, all uv's are visible */ - if(ts->uv_flag & UV_SYNC_SELECTION){ + if (ts->uv_flag & UV_SYNC_SELECTION) { state->element_map = EDBM_make_uv_element_map(state->em, 0, 1); - }else{ + } + else { state->element_map = EDBM_make_uv_element_map(state->em, 1, 1); } - if(!state->element_map){ + if (!state->element_map) { stitch_state_delete(state); return 0; } @@ -1003,8 +1016,8 @@ static int stitch_init(bContext *C, wmOperator *op) state->static_island %= state->element_map->totalIslands; /* Count 'unique' uvs */ - for(i = 0; i < state->element_map->totalUVs; i++){ - if(state->element_map->buf[i].separate){ + for (i = 0; i < state->element_map->totalUVs; i++) { + if (state->element_map->buf[i].separate) { counter++; } } @@ -1023,7 +1036,7 @@ static int stitch_init(bContext *C, wmOperator *op) edgeHash = BLI_ghash_new(uv_edge_hash, uv_edge_compare, "stitch_edge_hash"); all_edges = MEM_mallocN(sizeof(*all_edges)*state->element_map->totalUVs, "stitch_all_edges"); - if(!state->selection_stack || !state->uvs || !map || !edgeHash || !all_edges){ + if (!state->selection_stack || !state->uvs || !map || !edgeHash || !all_edges) { stitch_state_delete(state); return 0; } @@ -1031,10 +1044,10 @@ static int stitch_init(bContext *C, wmOperator *op) /* So that we can use this as index for the UvElements */ counter = -1; /* initialize the unique UVs and map */ - for(i = 0; i < em->bm->totvert; i++){ + for (i = 0; i < em->bm->totvert; i++) { UvElement *element = state->element_map->vert[i]; - for(; element; element = element->next){ - if(element->separate){ + for (; element; element = element->next) { + if (element->separate) { counter++; state->uvs[counter] = element; } @@ -1061,20 +1074,20 @@ static int stitch_init(bContext *C, wmOperator *op) all_edges[counter].element = element; /* using an order policy, sort uvs according to address space. This avoids * Having two different UvEdges with the same uvs on different positions */ - if(offset1 < offset2){ + if (offset1 < offset2) { all_edges[counter].uv1 = offset1; all_edges[counter].uv2 = offset2; } - else{ + else { all_edges[counter].uv1 = offset2; all_edges[counter].uv2 = offset1; } - if(BLI_ghash_haskey(edgeHash, &all_edges[counter])){ + if (BLI_ghash_haskey(edgeHash, &all_edges[counter])) { char *flag = BLI_ghash_lookup(edgeHash, &all_edges[counter]); *flag = 0; } - else{ + else { BLI_ghash_insert(edgeHash, &all_edges[counter], &(all_edges[counter].flag)); all_edges[counter].flag = STITCH_BOUNDARY; } @@ -1086,14 +1099,14 @@ static int stitch_init(bContext *C, wmOperator *op) ghi = BLI_ghashIterator_new(edgeHash); total_edges = 0; /* fill the edges with data */ - for(; !BLI_ghashIterator_isDone(ghi); BLI_ghashIterator_step(ghi)){ + for (; !BLI_ghashIterator_isDone(ghi); BLI_ghashIterator_step(ghi)) { UvEdge *edge = ((UvEdge *)BLI_ghashIterator_getKey(ghi)); - if(edge->flag & STITCH_BOUNDARY){ + if (edge->flag & STITCH_BOUNDARY) { total_edges++; } } state->edges = edges = MEM_mallocN(sizeof(*edges)*total_edges, "stitch_edges"); - if(!ghi || !edges){ + if (!ghi || !edges) { MEM_freeN(all_edges); stitch_state_delete(state); return 0; @@ -1102,9 +1115,9 @@ static int stitch_init(bContext *C, wmOperator *op) state->total_boundary_edges = total_edges; /* fill the edges with data */ - for(i = 0, BLI_ghashIterator_init(ghi, edgeHash); !BLI_ghashIterator_isDone(ghi); BLI_ghashIterator_step(ghi)){ + for (i = 0, BLI_ghashIterator_init(ghi, edgeHash); !BLI_ghashIterator_isDone(ghi); BLI_ghashIterator_step(ghi)) { UvEdge *edge = ((UvEdge *)BLI_ghashIterator_getKey(ghi)); - if(edge->flag & STITCH_BOUNDARY){ + if (edge->flag & STITCH_BOUNDARY) { edges[i++] = *((UvEdge *)BLI_ghashIterator_getKey(ghi)); } } @@ -1123,7 +1136,7 @@ static int stitch_init(bContext *C, wmOperator *op) * a point "inside" the island, that can be provided by * the opposite uv for a quad, or the next uv for a triangle. */ - for(i = 0; i < total_edges; i++){ + for (i = 0; i < total_edges; i++) { float normal[2]; stitch_calculate_edge_normal(em, edges + i, normal); @@ -1140,7 +1153,7 @@ static int stitch_init(bContext *C, wmOperator *op) state->selection_size = 0; /* Load old selection if redoing operator with different settings */ - if(RNA_struct_property_is_set(op->ptr, "selection")){ + if (RNA_struct_property_is_set(op->ptr, "selection")) { int faceIndex, elementIndex; UvElement *element; @@ -1159,11 +1172,12 @@ static int stitch_init(bContext *C, wmOperator *op) /* Clear the selection */ RNA_collection_clear(op->ptr, "selection"); - } else { + } + else { BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { i = 0; BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) { - if(uvedit_uv_selected(em, scene, l)){ + if (uvedit_uv_selected(em, scene, l)) { UvElement *element = ED_get_uv_element(state->element_map, efa, l); stitch_select_uv(element, state, 1); } @@ -1176,19 +1190,19 @@ static int stitch_init(bContext *C, wmOperator *op) state->tris_per_island = MEM_mallocN(sizeof(*state->tris_per_island)*state->element_map->totalIslands, "stitch island tris"); - for(i = 0; i < state->element_map->totalIslands; i++){ + for (i = 0; i < state->element_map->totalIslands; i++) { state->tris_per_island[i] = 0; } BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { UvElement *element = ED_get_uv_element(state->element_map, efa, BM_FACE_FIRST_LOOP(efa)); - if(element){ + if (element) { state->tris_per_island[element->island] += (efa->len > 2)? efa->len-2 : 0; } } - if(!stitch_process_data(state, scene, 0)){ + if (!stitch_process_data(state, scene, 0)) { stitch_state_delete(state); return 0; } @@ -1200,7 +1214,7 @@ static int stitch_init(bContext *C, wmOperator *op) static int stitch_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { Object *obedit = CTX_data_edit_object(C); - if(!stitch_init(C, op)) + if (!stitch_init(C, op)) return OPERATOR_CANCELLED; WM_event_add_modal_handler(C, op); @@ -1222,7 +1236,7 @@ static void stitch_exit(bContext *C, wmOperator *op, int finished) stitch_state = (StitchState *)op->customdata; - if(finished){ + if (finished) { int i; RNA_float_set(op->ptr, "limit", stitch_state->limit_dist); @@ -1232,7 +1246,7 @@ static void stitch_exit(bContext *C, wmOperator *op, int finished) RNA_boolean_set(op->ptr, "midpoint_snap", stitch_state->midpoints); /* Store selection for re-execution of stitch */ - for(i = 0; i < stitch_state->selection_size; i++){ + for (i = 0; i < stitch_state->selection_size; i++) { PointerRNA itemptr; UvElement *element = stitch_state->selection_stack[i]; @@ -1247,7 +1261,7 @@ static void stitch_exit(bContext *C, wmOperator *op, int finished) uvedit_live_unwrap_update(sima, scene, obedit); } - if(sa) + if (sa) ED_area_headerprint(sa, NULL); DAG_id_tag_update(obedit->data, 0); @@ -1271,12 +1285,13 @@ static int stitch_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); - if(!stitch_init(C, op)) + if (!stitch_init(C, op)) return OPERATOR_CANCELLED; - if(stitch_process_data((StitchState *)op->customdata, scene, 1)){ + if (stitch_process_data((StitchState *)op->customdata, scene, 1)) { stitch_exit(C, op, 1); return OPERATOR_FINISHED; - }else { + } + else { return stitch_cancel(C, op); } } @@ -1311,7 +1326,7 @@ static int stitch_modal(bContext *C, wmOperator *op, wmEvent *event) stitch_state = (StitchState *)op->customdata; - switch(event->type){ + switch(event->type) { case MIDDLEMOUSE: return OPERATOR_PASS_THROUGH; @@ -1321,11 +1336,11 @@ static int stitch_modal(bContext *C, wmOperator *op, wmEvent *event) case LEFTMOUSE: - if(event->shift && (U.flag & USER_LMOUSESELECT)){ - if(event->val == KM_RELEASE){ + if (event->shift && (U.flag & USER_LMOUSESELECT)) { + if (event->val == KM_RELEASE) { stitch_select(C, scene, event, stitch_state); - if(!stitch_process_data(stitch_state, scene, 0)){ + if (!stitch_process_data(stitch_state, scene, 0)) { return stitch_cancel(C, op); } } @@ -1333,7 +1348,7 @@ static int stitch_modal(bContext *C, wmOperator *op, wmEvent *event) } case PADENTER: case RETKEY: - if(stitch_process_data(stitch_state, scene, 1)){ + if (stitch_process_data(stitch_state, scene, 1)) { stitch_exit(C, op, 1); return OPERATOR_FINISHED; } @@ -1344,35 +1359,36 @@ static int stitch_modal(bContext *C, wmOperator *op, wmEvent *event) /* Increase limit */ case PADPLUSKEY: case WHEELUPMOUSE: - if(event->alt){ + if (event->alt) { stitch_state->limit_dist += 0.01; - if(!stitch_process_data(stitch_state, scene, 0)){ + if (!stitch_process_data(stitch_state, scene, 0)) { return stitch_cancel(C, op); } break; } - else{ + else { return OPERATOR_PASS_THROUGH; } /* Decrease limit */ case PADMINUS: case WHEELDOWNMOUSE: - if(event->alt){ + if (event->alt) { stitch_state->limit_dist -= 0.01; stitch_state->limit_dist = MAX2(0.01, stitch_state->limit_dist); - if(!stitch_process_data(stitch_state, scene, 0)){ + if (!stitch_process_data(stitch_state, scene, 0)) { return stitch_cancel(C, op); } break; - }else{ + } + else { return OPERATOR_PASS_THROUGH; } /* Use Limit (Default off)*/ case LKEY: - if(event->val == KM_PRESS){ + if (event->val == KM_PRESS) { stitch_state->use_limit = !stitch_state->use_limit; - if(!stitch_process_data(stitch_state, scene, 0)){ + if (!stitch_process_data(stitch_state, scene, 0)) { return stitch_cancel(C, op); } break; @@ -1380,11 +1396,11 @@ static int stitch_modal(bContext *C, wmOperator *op, wmEvent *event) return OPERATOR_RUNNING_MODAL; case IKEY: - if(event->val == KM_PRESS){ + if (event->val == KM_PRESS) { stitch_state->static_island++; stitch_state->static_island %= stitch_state->element_map->totalIslands; - if(!stitch_process_data(stitch_state, scene, 0)){ + if (!stitch_process_data(stitch_state, scene, 0)) { return stitch_cancel(C, op); } break; @@ -1392,9 +1408,9 @@ static int stitch_modal(bContext *C, wmOperator *op, wmEvent *event) return OPERATOR_RUNNING_MODAL; case MKEY: - if(event->val == KM_PRESS){ + if (event->val == KM_PRESS) { stitch_state->midpoints = !stitch_state->midpoints; - if(!stitch_process_data(stitch_state, scene, 0)){ + if (!stitch_process_data(stitch_state, scene, 0)) { return stitch_cancel(C, op); } } @@ -1402,13 +1418,13 @@ static int stitch_modal(bContext *C, wmOperator *op, wmEvent *event) /* Select geometry*/ case RIGHTMOUSE: - if(!event->shift){ + if (!event->shift) { return stitch_cancel(C, op); } - if(event->val == KM_RELEASE && !(U.flag & USER_LMOUSESELECT)){ + if (event->val == KM_RELEASE && !(U.flag & USER_LMOUSESELECT)) { stitch_select(C, scene, event, stitch_state); - if(!stitch_process_data(stitch_state, scene, 0)){ + if (!stitch_process_data(stitch_state, scene, 0)) { return stitch_cancel(C, op); } break; @@ -1417,13 +1433,14 @@ static int stitch_modal(bContext *C, wmOperator *op, wmEvent *event) /* snap islands on/off */ case SKEY: - if(event->val == KM_PRESS){ + if (event->val == KM_PRESS) { stitch_state->snap_islands = !stitch_state->snap_islands; - if(!stitch_process_data(stitch_state, scene, 0)){ + if (!stitch_process_data(stitch_state, scene, 0)) { return stitch_cancel(C, op); } break; - } else + } + else return OPERATOR_RUNNING_MODAL; default: diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c index 94879ff8e7f..107a92fd3ef 100644 --- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c +++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c @@ -98,33 +98,33 @@ static int ED_uvedit_ensure_uvs(bContext *C, Scene *scene, Object *obedit) SpaceLink *slink; SpaceImage *sima; - if(ED_uvedit_test(obedit)) { + if (ED_uvedit_test(obedit)) { return 1; } - if(em && em->bm->totface && !CustomData_has_layer(&em->bm->pdata, CD_MTEXPOLY)) { + if (em && em->bm->totface && !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); } - if(!ED_uvedit_test(obedit)) { + if (!ED_uvedit_test(obedit)) { return 0; } ima= CTX_data_edit_image(C); - if(!ima) { + if (!ima) { /* no image in context in the 3d view, we find first image window .. */ sc= CTX_wm_screen(C); - for(sa=sc->areabase.first; sa; sa=sa->next) { + for (sa=sc->areabase.first; sa; sa=sa->next) { slink= sa->spacedata.first; - if(slink->spacetype == SPACE_IMAGE) { + if (slink->spacetype == SPACE_IMAGE) { sima= (SpaceImage*)slink; ima= sima->image; - if(ima) { - if(ima->type==IMA_TYPE_R_RESULT || ima->type==IMA_TYPE_COMPOSITE) + if (ima) { + if (ima->type==IMA_TYPE_R_RESULT || ima->type==IMA_TYPE_COMPOSITE) ima= NULL; else break; @@ -133,7 +133,7 @@ static int ED_uvedit_ensure_uvs(bContext *C, Scene *scene, Object *obedit) } } - if(ima) + if (ima) ED_uvedit_assign_image(bmain, scene, obedit, ima, NULL); /* select new UV's */ @@ -156,11 +156,11 @@ static int uvedit_have_selection(Scene *scene, BMEditMesh *em, short implicit) /* verify if we have any selected uv's before unwrapping, * so we can cancel the operator early */ BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { - if(scene->toolsettings->uv_flag & UV_SYNC_SELECTION) { - if(BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) + if (scene->toolsettings->uv_flag & UV_SYNC_SELECTION) { + if (BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) continue; } - else if(BM_elem_flag_test(efa, BM_ELEM_HIDDEN) || !BM_elem_flag_test(efa, BM_ELEM_SELECT)) + else if (BM_elem_flag_test(efa, BM_ELEM_HIDDEN) || !BM_elem_flag_test(efa, BM_ELEM_SELECT)) continue; BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) { @@ -194,16 +194,16 @@ static ParamHandle *construct_param_handle(Scene *scene, BMEditMesh *em, handle = param_construct_begin(); - if(correct_aspect) { + if (correct_aspect) { efa = BM_active_face_get(em->bm, TRUE); - if(efa) { + if (efa) { float aspx, aspy; tf= CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY); ED_image_uv_aspect(tf->tpage, &aspx, &aspy); - if(aspx!=aspy) + if (aspx!=aspy) param_aspect_ratio(handle, aspx, aspy); } } @@ -222,7 +222,7 @@ static ParamHandle *construct_param_handle(Scene *scene, BMEditMesh *em, float *uv[4]; int lsel; - if((BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) || (sel && BM_elem_flag_test(efa, BM_ELEM_SELECT)==0)) + if ((BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) || (sel && BM_elem_flag_test(efa, BM_ELEM_SELECT)==0)) continue; /* tf= (MTexPoly *)CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY); */ /* UNUSED */ @@ -305,9 +305,9 @@ static ParamHandle *construct_param_handle(Scene *scene, BMEditMesh *em, BLI_end_edgefill(); } - if(!implicit) { + if (!implicit) { BM_ITER(eed, &iter, em->bm, BM_EDGES_OF_MESH, NULL) { - if(BM_elem_flag_test(eed, BM_ELEM_SEAM)) { + if (BM_elem_flag_test(eed, BM_ELEM_SEAM)) { ParamKey vkeys[2]; vkeys[0] = (ParamKey)BM_elem_index_get(eed->v1); vkeys[1] = (ParamKey)BM_elem_index_get(eed->v2); @@ -332,11 +332,11 @@ static void texface_from_original_index(BMFace *efa, int index, float **uv, Para *pin = 0; *select = 1; - if(index == ORIGINDEX_NONE) + if (index == ORIGINDEX_NONE) return; BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) { - if(BM_elem_index_get(l->v) == index) { + if (BM_elem_index_get(l->v) == index) { luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV); *uv = luv->uv; *pin = (luv->flag & MLOOPUV_PINNED)? 1 : 0; @@ -376,17 +376,17 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene, BMEditMesh *e handle = param_construct_begin(); - if(correct_aspect) { + if (correct_aspect) { editFace = BM_active_face_get(em->bm, TRUE); - if(editFace) { + if (editFace) { MTexPoly *tf; float aspx, aspy; tf= CustomData_bmesh_get(&em->bm->pdata, editFace->head.data, CD_MTEXPOLY); ED_image_uv_aspect(tf->tpage, &aspx, &aspy); - if(aspx!=aspy) + if (aspx!=aspy) param_aspect_ratio(handle, aspx, aspy); } } @@ -419,13 +419,13 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene, BMEditMesh *e EDBM_init_index_arrays(em, 0, 1, 1); /* map subsurfed faces to original editFaces */ - for(i = 0; i < numOfFaces; i++) + for (i = 0; i < numOfFaces; i++) faceMap[i] = EDBM_get_face_for_index(em, origFaceIndices[i]); edgeMap = MEM_mallocN(numOfEdges*sizeof(BMEdge *), "unwrap_edit_edge_map"); /* map subsurfed edges to original editEdges */ - for(i = 0; i < numOfEdges; i++) { + for (i = 0; i < numOfEdges; i++) { /* not all edges correspond to an old edge */ edgeMap[i] = (origEdgeIndices[i] != -1)? EDBM_get_edge_for_index(em, origEdgeIndices[i]) : NULL; @@ -434,7 +434,7 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene, BMEditMesh *e EDBM_free_index_arrays(em); /* Prepare and feed faces to the solver */ - for(i = 0; i < numOfFaces; i++) { + for (i = 0; i < numOfFaces; i++) { ParamKey key, vkeys[4]; ParamBool pin[4], select[4]; float *co[4]; @@ -443,12 +443,12 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene, BMEditMesh *e face = subsurfedFaces+i; - if(scene->toolsettings->uv_flag & UV_SYNC_SELECTION) { - if(BM_elem_flag_test(origFace, BM_ELEM_HIDDEN)) + if (scene->toolsettings->uv_flag & UV_SYNC_SELECTION) { + if (BM_elem_flag_test(origFace, BM_ELEM_HIDDEN)) continue; } else { - if(BM_elem_flag_test(origFace, BM_ELEM_HIDDEN) || (sel && !BM_elem_flag_test(origFace, BM_ELEM_SELECT))) + if (BM_elem_flag_test(origFace, BM_ELEM_HIDDEN) || (sel && !BM_elem_flag_test(origFace, BM_ELEM_SELECT))) continue; } @@ -475,8 +475,8 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene, BMEditMesh *e } /* these are calculated from original mesh too */ - for(edge = subsurfedEdges, i = 0; i < numOfEdges; i++, edge++) { - if((edgeMap[i] != NULL) && BM_elem_flag_test(edgeMap[i], BM_ELEM_SEAM)) { + for (edge = subsurfedEdges, i = 0; i < numOfEdges; i++, edge++) { + if ((edgeMap[i] != NULL) && BM_elem_flag_test(edgeMap[i], BM_ELEM_SEAM)) { ParamKey vkeys[2]; vkeys[0] = (ParamKey)edge->v1; vkeys[1] = (ParamKey)edge->v2; @@ -516,7 +516,7 @@ static int minimize_stretch_init(bContext *C, wmOperator *op) int fill_holes = RNA_boolean_get(op->ptr, "fill_holes"); short implicit = 1; - if(!uvedit_have_selection(scene, em, implicit)) { + if (!uvedit_have_selection(scene, em, implicit)) { return 0; } @@ -531,7 +531,7 @@ static int minimize_stretch_init(bContext *C, wmOperator *op) ms->lasttime= PIL_check_seconds_timer(); param_stretch_begin(ms->handle); - if(ms->blend != 0.0f) + if (ms->blend != 0.0f) param_stretch_blend(ms->handle, ms->blend); op->customdata= ms; @@ -550,12 +550,12 @@ static void minimize_stretch_iteration(bContext *C, wmOperator *op, int interact ms->i++; RNA_int_set(op->ptr, "iterations", ms->i); - if(interactive && (PIL_check_seconds_timer() - ms->lasttime > 0.5)) { + if (interactive && (PIL_check_seconds_timer() - ms->lasttime > 0.5)) { char str[100]; param_flush(ms->handle); - if(sa) { + if (sa) { BLI_snprintf(str, sizeof(str), "Minimize Stretch. Blend %.2f", ms->blend); ED_area_headerprint(sa, str); } @@ -572,12 +572,12 @@ static void minimize_stretch_exit(bContext *C, wmOperator *op, int cancel) MinStretch *ms= op->customdata; ScrArea *sa= CTX_wm_area(C); - if(sa) + if (sa) ED_area_headerprint(sa, NULL); - if(ms->timer) + if (ms->timer) WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), ms->timer); - if(cancel) + if (cancel) param_flush_restore(ms->handle); else param_flush(ms->handle); @@ -596,11 +596,11 @@ static int minimize_stretch_exec(bContext *C, wmOperator *op) { int i, iterations; - if(!minimize_stretch_init(C, op)) + if (!minimize_stretch_init(C, op)) return OPERATOR_CANCELLED; iterations= RNA_int_get(op->ptr, "iterations"); - for(i=0; i<iterations; i++) + for (i=0; i<iterations; i++) minimize_stretch_iteration(C, op, 0); minimize_stretch_exit(C, op, 0); @@ -611,7 +611,7 @@ static int minimize_stretch_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED( { MinStretch *ms; - if(!minimize_stretch_init(C, op)) + if (!minimize_stretch_init(C, op)) return OPERATOR_CANCELLED; minimize_stretch_iteration(C, op, 1); @@ -639,7 +639,7 @@ static int minimize_stretch_modal(bContext *C, wmOperator *op, wmEvent *event) return OPERATOR_FINISHED; case PADPLUSKEY: case WHEELUPMOUSE: - if(ms->blend < 0.95f) { + if (ms->blend < 0.95f) { ms->blend += 0.1f; ms->lasttime= 0.0f; RNA_float_set(op->ptr, "blend", ms->blend); @@ -648,7 +648,7 @@ static int minimize_stretch_modal(bContext *C, wmOperator *op, wmEvent *event) break; case PADMINUS: case WHEELDOWNMOUSE: - if(ms->blend > 0.05f) { + if (ms->blend > 0.05f) { ms->blend -= 0.1f; ms->lasttime= 0.0f; RNA_float_set(op->ptr, "blend", ms->blend); @@ -656,17 +656,17 @@ static int minimize_stretch_modal(bContext *C, wmOperator *op, wmEvent *event) } break; case TIMER: - if(ms->timer == event->customdata) { + if (ms->timer == event->customdata) { double start= PIL_check_seconds_timer(); do { minimize_stretch_iteration(C, op, 1); - } while(PIL_check_seconds_timer() - start < 0.01); + } while (PIL_check_seconds_timer() - start < 0.01); } break; } - if(ms->iterations && ms->i >= ms->iterations) { + if (ms->iterations && ms->i >= ms->iterations) { minimize_stretch_exit(C, op, 0); return OPERATOR_FINISHED; } @@ -712,11 +712,11 @@ static int pack_islands_exec(bContext *C, wmOperator *op) ParamHandle *handle; short implicit = 1; - if(!uvedit_have_selection(scene, em, implicit)) { + if (!uvedit_have_selection(scene, em, implicit)) { return OPERATOR_CANCELLED; } - if(RNA_struct_property_is_set(op->ptr, "margin")) { + if (RNA_struct_property_is_set(op->ptr, "margin")) { scene->toolsettings->uvcalc_margin= RNA_float_get(op->ptr, "margin"); } else { @@ -759,7 +759,7 @@ static int average_islands_scale_exec(bContext *C, wmOperator *UNUSED(op)) ParamHandle *handle; short implicit = 1; - if(!uvedit_have_selection(scene, em, implicit)) { + if (!uvedit_have_selection(scene, em, implicit)) { return OPERATOR_CANCELLED; } @@ -797,11 +797,11 @@ void ED_uvedit_live_unwrap_begin(Scene *scene, Object *obedit) short fillholes = scene->toolsettings->uvcalc_flag & UVCALC_FILLHOLES; short use_subsurf = scene->toolsettings->uvcalc_flag & UVCALC_USESUBSURF; - if(!ED_uvedit_test(obedit)) { + if (!ED_uvedit_test(obedit)) { return; } - if(use_subsurf) + if (use_subsurf) liveHandle = construct_param_handle_subsurfed(scene, em, fillholes, 0, 1); else liveHandle = construct_param_handle(scene, em, 0, fillholes, 0, 1); @@ -811,7 +811,7 @@ void ED_uvedit_live_unwrap_begin(Scene *scene, Object *obedit) void ED_uvedit_live_unwrap_re_solve(void) { - if(liveHandle) { + if (liveHandle) { param_lscm_solve(liveHandle); param_flush(liveHandle); } @@ -819,9 +819,9 @@ void ED_uvedit_live_unwrap_re_solve(void) void ED_uvedit_live_unwrap_end(short cancel) { - if(liveHandle) { + if (liveHandle) { param_lscm_end(liveHandle); - if(cancel) + if (cancel) param_flush_restore(liveHandle); param_delete(liveHandle); liveHandle = NULL; @@ -854,7 +854,7 @@ static void uv_map_transform_center(Scene *scene, View3D *v3d, float *result, max[0]= max[1]= max[2]= -1e20f; 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)) { BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) { DO_MINMAX(l->v->co, min, max); } @@ -887,20 +887,20 @@ static void uv_map_rotation_matrix(float result[][4], RegionView3D *rv3d, Object int k; /* get rotation of the current view matrix */ - if(rv3d) + if (rv3d) copy_m4_m4(viewmatrix, rv3d->viewmat); else unit_m4(viewmatrix); /* but shifting */ - for(k=0; k<4; k++) + for (k=0; k<4; k++) viewmatrix[3][k] =0.0f; /* get rotation of the current object matrix */ copy_m4_m4(rotobj,ob->obmat); /* but shifting */ - for(k=0; k<4; k++) + for (k=0; k<4; k++) rotobj[3][k] =0.0f; zero_m4(rotup); @@ -943,18 +943,18 @@ static void uv_map_transform(bContext *C, wmOperator *op, float center[3], float uv_map_transform_center(scene, v3d, center, obedit, em); - if(direction == VIEW_ON_EQUATOR) { + if (direction == VIEW_ON_EQUATOR) { upangledeg= 90.0f; sideangledeg= 0.0f; } else { upangledeg= 0.0f; - if(align == POLAR_ZY) sideangledeg= 0.0f; + if (align == POLAR_ZY) sideangledeg= 0.0f; else sideangledeg= 90.0f; } /* be compatible to the "old" sphere/cylinder mode */ - if(direction == ALIGN_TO_OBJECT) + if (direction == ALIGN_TO_OBJECT) unit_m4(rotmat); else uv_map_rotation_matrix(rotmat, rv3d, obedit, upangledeg, sideangledeg, radius); @@ -979,7 +979,7 @@ static void uv_transform_properties(wmOperatorType *ot, int radius) "Direction of the sphere or cylinder"); RNA_def_enum(ot->srna, "align", align_items, VIEW_ON_EQUATOR, "Align", "How to determine rotation around the pole"); - if(radius) + if (radius) RNA_def_float(ot->srna, "radius", 1.0f, 0.0f, FLT_MAX, "Radius", "Radius of the sphere or cylinder", 0.0001f, 100.0f); } @@ -999,10 +999,10 @@ static void correct_uv_aspect(BMEditMesh *em) ED_image_uv_aspect(tf->tpage, &aspx, &aspy); } - if(aspx == aspy) + if (aspx == aspy) return; - if(aspx > aspy) { + if (aspx > aspy) { scale= aspy/aspx; BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { @@ -1054,10 +1054,10 @@ static void uv_map_clip_correct(BMEditMesh *em, wmOperator *op) int scale_to_bounds= RNA_boolean_get(op->ptr, "scale_to_bounds"); /* correct for image aspect ratio */ - if(correct_aspect) + if (correct_aspect) correct_uv_aspect(em); - if(scale_to_bounds) { + if (scale_to_bounds) { INIT_MINMAX2(min, max); BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { @@ -1074,9 +1074,9 @@ static void uv_map_clip_correct(BMEditMesh *em, wmOperator *op) dx= (max[0]-min[0]); dy= (max[1]-min[1]); - if(dx > 0.0f) + if (dx > 0.0f) dx= 1.0f/dx; - if(dy > 0.0f) + if (dy > 0.0f) dy= 1.0f/dy; BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { @@ -1091,7 +1091,7 @@ static void uv_map_clip_correct(BMEditMesh *em, wmOperator *op) } } } - else if(clip_to_bounds) { + else if (clip_to_bounds) { /* clipping and wrapping */ BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { if (!BM_elem_flag_test(efa, BM_ELEM_SELECT)) @@ -1118,7 +1118,7 @@ void ED_unwrap_lscm(Scene *scene, Object *obedit, const short sel) const short correct_aspect= !(scene->toolsettings->uvcalc_flag & UVCALC_NO_ASPECT_CORRECT); const short use_subsurf = scene->toolsettings->uvcalc_flag & UVCALC_USESUBSURF; - if(use_subsurf) + if (use_subsurf) handle = construct_param_handle_subsurfed(scene, em, fill_holes, sel, correct_aspect); else handle= construct_param_handle(scene, em, 0, fill_holes, sel, correct_aspect); @@ -1147,17 +1147,17 @@ static int unwrap_exec(bContext *C, wmOperator *op) float obsize[3], unitsize[3] = {1.0f, 1.0f, 1.0f}; short implicit= 0; - if(!uvedit_have_selection(scene, em, implicit)) { + if (!uvedit_have_selection(scene, em, implicit)) { return OPERATOR_CANCELLED; } /* add uvs if they don't exist yet */ - if(!ED_uvedit_ensure_uvs(C, scene, obedit)) { + if (!ED_uvedit_ensure_uvs(C, scene, obedit)) { return OPERATOR_CANCELLED; } mat4_to_size(obsize, obedit->obmat); - if(!compare_v3v3(obsize, unitsize, 1e-4f)) + if (!compare_v3v3(obsize, unitsize, 1e-4f)) BKE_report(op->reports, RPT_INFO, "Object scale is not 1.0. Unwrap will operate on a non-scaled version of the mesh."); /* remember last method for live unwrap */ @@ -1165,13 +1165,13 @@ static int unwrap_exec(bContext *C, wmOperator *op) scene->toolsettings->uv_subsurf_level = subsurf_level; - if(fill_holes) scene->toolsettings->uvcalc_flag |= UVCALC_FILLHOLES; + if (fill_holes) scene->toolsettings->uvcalc_flag |= UVCALC_FILLHOLES; else scene->toolsettings->uvcalc_flag &= ~UVCALC_FILLHOLES; - if(correct_aspect) scene->toolsettings->uvcalc_flag &= ~UVCALC_NO_ASPECT_CORRECT; + if (correct_aspect) scene->toolsettings->uvcalc_flag &= ~UVCALC_NO_ASPECT_CORRECT; else scene->toolsettings->uvcalc_flag |= UVCALC_NO_ASPECT_CORRECT; - if(use_subsurf) scene->toolsettings->uvcalc_flag |= UVCALC_USESUBSURF; + if (use_subsurf) scene->toolsettings->uvcalc_flag |= UVCALC_USESUBSURF; else scene->toolsettings->uvcalc_flag &= ~UVCALC_USESUBSURF; /* execute unwrap */ @@ -1230,7 +1230,7 @@ static int uv_from_view_exec(bContext *C, wmOperator *op) float rotmat[4][4]; /* add uvs if they don't exist yet */ - if(!ED_uvedit_ensure_uvs(C, scene, obedit)) { + if (!ED_uvedit_ensure_uvs(C, scene, obedit)) { return OPERATOR_CANCELLED; } @@ -1239,7 +1239,7 @@ static int uv_from_view_exec(bContext *C, wmOperator *op) camera= v3d->camera->data; } - if(RNA_boolean_get(op->ptr, "orthographic")) { + if (RNA_boolean_get(op->ptr, "orthographic")) { uv_map_rotation_matrix(rotmat, rv3d, obedit, 90.0f, 0.0f, 1.0f); BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { @@ -1255,7 +1255,7 @@ static int uv_from_view_exec(bContext *C, wmOperator *op) else if (camera) { struct UvCameraInfo *uci= project_camera_info(v3d->camera, obedit->obmat, scene->r.xsch, scene->r.ysch); - if(uci) { + if (uci) { BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { if (!BM_elem_flag_test(efa, BM_ELEM_SELECT)) continue; @@ -1295,7 +1295,7 @@ static int uv_from_view_poll(bContext *C) { RegionView3D *rv3d= CTX_wm_region_view3d(C); - if(!ED_operator_uvmap(C)) + if (!ED_operator_uvmap(C)) return 0; return (rv3d != NULL); @@ -1364,7 +1364,7 @@ static void uv_sphere_project(float target[2], float source[3], float center[3], map_to_sphere( &target[0], &target[1],pv[0], pv[1], pv[2]); /* split line is always zero */ - if(target[0] >= 1.0f) + if (target[0] >= 1.0f) target[0] -= 1.0f; } @@ -1386,14 +1386,14 @@ static void uv_map_mirror(BMEditMesh *em, BMFace *efa, MTexPoly *UNUSED(tf)) } mi = 0; - for(i=1; i<efa->len; i++) - if(uvs[i][0] > uvs[mi][0]) + for (i=1; i<efa->len; i++) + if (uvs[i][0] > uvs[mi][0]) mi = i; - for(i=0; i<efa->len; i++) { - if(i != mi) { + for (i=0; i<efa->len; i++) { + if (i != mi) { dx = uvs[mi][0] - uvs[i][0]; - if(dx > 0.5f) uvs[i][0] += 1.0f; + if (dx > 0.5f) uvs[i][0] += 1.0f; } } @@ -1413,7 +1413,7 @@ static int sphere_project_exec(bContext *C, wmOperator *op) float center[3], rotmat[4][4]; /* add uvs if they don't exist yet */ - if(!ED_uvedit_ensure_uvs(C, scene, obedit)) { + if (!ED_uvedit_ensure_uvs(C, scene, obedit)) { return OPERATOR_CANCELLED; } @@ -1469,7 +1469,7 @@ static void uv_cylinder_project(float target[2], float source[3], float center[3 map_to_tube( &target[0], &target[1],pv[0], pv[1], pv[2]); /* split line is always zero */ - if(target[0] >= 1.0f) + if (target[0] >= 1.0f) target[0] -= 1.0f; } @@ -1486,7 +1486,7 @@ static int cylinder_project_exec(bContext *C, wmOperator *op) float center[3], rotmat[4][4]; /* add uvs if they don't exist yet */ - if(!ED_uvedit_ensure_uvs(C, scene, obedit)) { + if (!ED_uvedit_ensure_uvs(C, scene, obedit)) { return OPERATOR_CANCELLED; } @@ -1546,7 +1546,7 @@ static int cube_project_exec(bContext *C, wmOperator *op) int cox, coy; /* add uvs if they don't exist yet */ - if(!ED_uvedit_ensure_uvs(C, scene, obedit)) { + if (!ED_uvedit_ensure_uvs(C, scene, obedit)) { return OPERATOR_CANCELLED; } diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c index 8698f036491..bf4df2e9b0a 100644 --- a/source/blender/gpu/intern/gpu_buffers.c +++ b/source/blender/gpu/intern/gpu_buffers.c @@ -98,7 +98,7 @@ static GPUBufferPool *gpu_buffer_pool_new(void) GPUBufferPool *pool; /* enable VBOs if supported */ - if(useVBOs == -1) + if (useVBOs == -1) useVBOs = (GLEW_ARB_vertex_buffer_object ? 1 : 0); pool = MEM_callocN(sizeof(GPUBufferPool), "GPUBuffer"); @@ -115,15 +115,15 @@ static void gpu_buffer_pool_remove_index(GPUBufferPool *pool, int index) { int i; - if(!pool || index < 0 || index >= pool->totbuf) + if (!pool || index < 0 || index >= pool->totbuf) return; /* shift entries down, overwriting the buffer at `index' */ - for(i = index; i < pool->totbuf - 1; i++) + for (i = index; i < pool->totbuf - 1; i++) pool->buffers[i] = pool->buffers[i+1]; /* clear the last entry */ - if(pool->totbuf > 0) + if (pool->totbuf > 0) pool->buffers[pool->totbuf - 1] = NULL; pool->totbuf--; @@ -134,15 +134,15 @@ static void gpu_buffer_pool_delete_last(GPUBufferPool *pool) { GPUBuffer *last; - if(pool->totbuf <= 0) + if (pool->totbuf <= 0) return; /* get the last entry */ - if(!(last = pool->buffers[pool->totbuf - 1])) + if (!(last = pool->buffers[pool->totbuf - 1])) return; /* delete the buffer's data */ - if(useVBOs) + if (useVBOs) glDeleteBuffersARB(1, &last->id); else MEM_freeN(last->pointer); @@ -157,7 +157,7 @@ static void gpu_buffer_pool_delete_last(GPUBufferPool *pool) GPUBuffers */ static void gpu_buffer_pool_free(GPUBufferPool *pool) { - if(!pool) + if (!pool) return; while(pool->totbuf) @@ -171,7 +171,7 @@ static GPUBufferPool *gpu_buffer_pool = NULL; static GPUBufferPool *gpu_get_global_buffer_pool(void) { /* initialize the pool */ - if(!gpu_buffer_pool) + if (!gpu_buffer_pool) gpu_buffer_pool = gpu_buffer_pool_new(); return gpu_buffer_pool; @@ -201,21 +201,21 @@ GPUBuffer *GPU_buffer_alloc(int size) /* check the global buffer pool for a recently-deleted buffer that is at least as big as the request, but not more than twice as big */ - for(i = 0; i < pool->totbuf; i++) { + for (i = 0; i < pool->totbuf; i++) { bufsize = pool->buffers[i]->size; /* check for an exact size match */ - if(bufsize == size) { + if (bufsize == size) { bestfit = i; break; } /* smaller buffers won't fit data and buffers at least twice as big are a waste of memory */ - else if(bufsize > size && size > (bufsize / 2)) { + else if (bufsize > size && size > (bufsize / 2)) { /* is it closer to the required size than the last appropriate buffer found. try to save memory */ - if(bestfit == -1 || pool->buffers[bestfit]->size > bufsize) { + if (bestfit == -1 || pool->buffers[bestfit]->size > bufsize) { bestfit = i; } } @@ -223,7 +223,7 @@ GPUBuffer *GPU_buffer_alloc(int size) /* if an acceptable buffer was found in the pool, remove it from the pool and return it */ - if(bestfit != -1) { + if (bestfit != -1) { buf = pool->buffers[bestfit]; gpu_buffer_pool_remove_index(pool, bestfit); return buf; @@ -233,7 +233,7 @@ GPUBuffer *GPU_buffer_alloc(int size) buf = MEM_callocN(sizeof(GPUBuffer), "GPUBuffer"); buf->size = size; - if(useVBOs == 1) { + if (useVBOs == 1) { /* create a new VBO and initialize it to the requested size */ glGenBuffersARB(1, &buf->id); @@ -252,7 +252,7 @@ GPUBuffer *GPU_buffer_alloc(int size) gpu_buffer_pool_delete_last(pool); buf->pointer = MEM_mallocN(size, "GPUBuffer.pointer"); } - if(!buf->pointer) + if (!buf->pointer) return NULL; } @@ -267,7 +267,7 @@ void GPU_buffer_free(GPUBuffer *buffer) GPUBufferPool *pool; int i; - if(!buffer) + if (!buffer) return; pool = gpu_get_global_buffer_pool(); @@ -276,7 +276,7 @@ void GPU_buffer_free(GPUBuffer *buffer) if we are in the main thread. for e.g. rendering or baking it can happen that we are in other thread and can't call OpenGL, in that case cleanup will be done GPU_buffer_pool_free_unused */ - if(BLI_thread_is_main()) { + if (BLI_thread_is_main()) { /* in main thread, safe to decrease size of pool back down to MAX_FREE_GPU_BUFFERS */ while(pool->totbuf >= MAX_FREE_GPU_BUFFERS) @@ -285,7 +285,7 @@ void GPU_buffer_free(GPUBuffer *buffer) else { /* outside of main thread, can't safely delete the buffer, so increase pool size */ - if(pool->maxsize == pool->totbuf) { + if (pool->maxsize == pool->totbuf) { pool->maxsize += MAX_FREE_GPU_BUFFERS; pool->buffers = MEM_reallocN(pool->buffers, sizeof(GPUBuffer*) * pool->maxsize); @@ -293,7 +293,7 @@ void GPU_buffer_free(GPUBuffer *buffer) } /* shift pool entries up by one */ - for(i = pool->totbuf; i > 0; i--) + for (i = pool->totbuf; i > 0; i--) pool->buffers[i] = pool->buffers[i-1]; /* insert the buffer into the beginning of the pool */ @@ -316,9 +316,9 @@ static void gpu_drawobject_add_vert_point(GPUDrawObject *gdo, int vert_index, in lnk = &gdo->vert_points[vert_index]; /* if first link is in use, add a new link at the end */ - if(lnk->point_index != -1) { + if (lnk->point_index != -1) { /* get last link */ - for(; lnk->next; lnk = lnk->next); + for (; lnk->next; lnk = lnk->next); /* add a new link from the pool */ lnk = lnk->next = &gdo->vert_points_mem[gdo->vert_points_usage]; @@ -336,7 +336,7 @@ static void gpu_drawobject_add_triangle(GPUDrawObject *gdo, int v1, int v2, int v3) { int i, v[3] = {v1, v2, v3}; - for(i = 0; i < 3; i++) + for (i = 0; i < 3; i++) gpu_drawobject_add_vert_point(gdo, v[i], base_point_index + i); gdo->triangle_to_mface[base_point_index / 3] = face_index; } @@ -357,14 +357,14 @@ static void gpu_drawobject_init_vert_points(GPUDrawObject *gdo, MFace *f, int to /* build a map from the original material indices to the new GPUBufferMaterial indices */ - for(i = 0; i < gdo->totmaterial; i++) + for (i = 0; i < gdo->totmaterial; i++) mat_orig_to_new[gdo->materials[i].mat_nr] = i; /* -1 indicates the link is not yet used */ - for(i = 0; i < gdo->totvert; i++) + for (i = 0; i < gdo->totvert; i++) gdo->vert_points[i].point_index = -1; - for(i = 0; i < totface; i++, f++) { + for (i = 0; i < totface; i++, f++) { mat = &gdo->materials[mat_orig_to_new[f->mat_nr]]; /* add triangle */ @@ -373,7 +373,7 @@ static void gpu_drawobject_init_vert_points(GPUDrawObject *gdo, MFace *f, int to mat->totpoint += 3; /* add second triangle for quads */ - if(f->v4) { + if (f->v4) { gpu_drawobject_add_triangle(gdo, mat->start + mat->totpoint, i, f->v3, f->v4, f->v1); mat->totpoint += 3; @@ -381,8 +381,8 @@ static void gpu_drawobject_init_vert_points(GPUDrawObject *gdo, MFace *f, int to } /* map any unused vertices to loose points */ - for(i = 0; i < gdo->totvert; i++) { - if(gdo->vert_points[i].point_index == -1) { + for (i = 0; i < gdo->totvert; i++) { + if (gdo->vert_points[i].point_index == -1) { gdo->vert_points[i].point_index = gdo->tot_triangle_point + gdo->tot_loose_point; gdo->tot_loose_point++; } @@ -404,7 +404,7 @@ GPUDrawObject *GPU_drawobject_new( DerivedMesh *dm ) /* get the number of points used by each material, treating each quad as two triangles */ memset(points_per_mat, 0, sizeof(int)*MAX_MATERIALS); - for(i = 0; i < totface; i++) + for (i = 0; i < totface; i++) points_per_mat[mface[i].mat_nr] += mface[i].v4 ? 6 : 3; /* create the GPUDrawObject */ @@ -413,8 +413,8 @@ GPUDrawObject *GPU_drawobject_new( DerivedMesh *dm ) gdo->totedge = dm->getNumEdges(dm); /* count the number of materials used by this DerivedMesh */ - for(i = 0; i < MAX_MATERIALS; i++) { - if(points_per_mat[i] > 0) + for (i = 0; i < MAX_MATERIALS; i++) { + if (points_per_mat[i] > 0) gdo->totmaterial++; } @@ -423,8 +423,8 @@ GPUDrawObject *GPU_drawobject_new( DerivedMesh *dm ) "GPUDrawObject.materials"); /* initialize the materials array */ - for(i = 0, curmat = 0, curpoint = 0; i < MAX_MATERIALS; i++) { - if(points_per_mat[i] > 0) { + for (i = 0, curmat = 0, curpoint = 0; i < MAX_MATERIALS; i++) { + if (points_per_mat[i] > 0) { gdo->materials[curmat].start = curpoint; gdo->materials[curmat].totpoint = 0; gdo->materials[curmat].mat_nr = i; @@ -449,7 +449,7 @@ void GPU_drawobject_free(DerivedMesh *dm) { GPUDrawObject *gdo; - if(!dm || !(gdo = dm->drawObject)) + if (!dm || !(gdo = dm->drawObject)) return; MEM_freeN(gdo->materials); @@ -486,16 +486,16 @@ static GPUBuffer *gpu_buffer_setup(DerivedMesh *dm, GPUDrawObject *object, pool = gpu_get_global_buffer_pool(); /* alloc a GPUBuffer; fall back to legacy mode on failure */ - if(!(buffer = GPU_buffer_alloc(size))) + if (!(buffer = GPU_buffer_alloc(size))) dm->drawObject->legacy = 1; /* nothing to do for legacy mode */ - if(dm->drawObject->legacy) + if (dm->drawObject->legacy) return NULL; cur_index_per_mat = MEM_mallocN(sizeof(int)*object->totmaterial, "GPU_buffer_setup.cur_index_per_mat"); - for(i = 0; i < object->totmaterial; i++) { + for (i = 0; i < object->totmaterial; i++) { /* for each material, the current index to copy data to */ cur_index_per_mat[i] = object->materials[i].start * vector_size; @@ -504,7 +504,7 @@ static GPUBuffer *gpu_buffer_setup(DerivedMesh *dm, GPUDrawObject *object, mat_orig_to_new[object->materials[i].mat_nr] = i; } - if(useVBOs) { + if (useVBOs) { success = 0; while(!success) { @@ -514,7 +514,7 @@ static GPUBuffer *gpu_buffer_setup(DerivedMesh *dm, GPUDrawObject *object, glBufferDataARB(target, buffer->size, NULL, GL_STATIC_DRAW_ARB); /* attempt to map the buffer */ - if(!(varray = glMapBufferARB(target, GL_WRITE_ONLY_ARB))) { + if (!(varray = glMapBufferARB(target, GL_WRITE_ONLY_ARB))) { /* failed to map the buffer; delete it */ GPU_buffer_free(buffer); gpu_buffer_pool_delete_last(pool); @@ -522,14 +522,14 @@ static GPUBuffer *gpu_buffer_setup(DerivedMesh *dm, GPUDrawObject *object, /* try freeing an entry from the pool and reallocating the buffer */ - if(pool->totbuf > 0) { + if (pool->totbuf > 0) { gpu_buffer_pool_delete_last(pool); buffer = GPU_buffer_alloc(size); } /* allocation still failed; fall back to legacy mode */ - if(!buffer) { + if (!buffer) { dm->drawObject->legacy = 1; success = 1; } @@ -540,7 +540,7 @@ static GPUBuffer *gpu_buffer_setup(DerivedMesh *dm, GPUDrawObject *object, } /* check legacy fallback didn't happen */ - if(dm->drawObject->legacy == 0) { + if (dm->drawObject->legacy == 0) { uploaded = GL_FALSE; /* attempt to upload the data to the VBO */ while(uploaded == GL_FALSE) { @@ -555,7 +555,7 @@ static GPUBuffer *gpu_buffer_setup(DerivedMesh *dm, GPUDrawObject *object, } else { /* VBO not supported, use vertex array fallback */ - if(buffer->pointer) { + if (buffer->pointer) { varray = buffer->pointer; (*copy_f)(dm, varray, cur_index_per_mat, mat_orig_to_new, user); } @@ -579,7 +579,7 @@ static void GPU_buffer_copy_vertex(DerivedMesh *dm, float *varray, int *index, i f = dm->getTessFaceArray(dm); totface= dm->getNumTessFaces(dm); - for(i = 0; i < totface; i++, f++) { + for (i = 0; i < totface; i++, f++) { start = index[mat_orig_to_new[f->mat_nr]]; /* v1 v2 v3 */ @@ -588,7 +588,7 @@ static void GPU_buffer_copy_vertex(DerivedMesh *dm, float *varray, int *index, i copy_v3_v3(&varray[start+6], mvert[f->v3].co); index[mat_orig_to_new[f->mat_nr]] += 9; - if(f->v4) { + if (f->v4) { /* v3 v4 v1 */ copy_v3_v3(&varray[start+9], mvert[f->v3].co); copy_v3_v3(&varray[start+12], mvert[f->v4].co); @@ -599,8 +599,8 @@ static void GPU_buffer_copy_vertex(DerivedMesh *dm, float *varray, int *index, i /* copy loose points */ j = dm->drawObject->tot_triangle_point*3; - for(i = 0; i < dm->drawObject->totvert; i++) { - if(dm->drawObject->vert_points[i].point_index >= dm->drawObject->tot_triangle_point) { + for (i = 0; i < dm->drawObject->totvert; i++) { + if (dm->drawObject->vert_points[i].point_index >= dm->drawObject->tot_triangle_point) { copy_v3_v3(&varray[j],mvert[i].co); j+=3; } @@ -618,31 +618,31 @@ static void GPU_buffer_copy_normal(DerivedMesh *dm, float *varray, int *index, i MFace *f = dm->getTessFaceArray(dm); totface= dm->getNumTessFaces(dm); - for(i = 0; i < totface; i++, f++) { + for (i = 0; i < totface; i++, f++) { const int smoothnormal = (f->flag & ME_SMOOTH); start = index[mat_orig_to_new[f->mat_nr]]; index[mat_orig_to_new[f->mat_nr]] += f->v4 ? 18 : 9; - if(smoothnormal) { + if (smoothnormal) { /* copy vertex normal */ normal_short_to_float_v3(&varray[start], mvert[f->v1].no); normal_short_to_float_v3(&varray[start+3], mvert[f->v2].no); normal_short_to_float_v3(&varray[start+6], mvert[f->v3].no); - if(f->v4) { + if (f->v4) { normal_short_to_float_v3(&varray[start+9], mvert[f->v3].no); normal_short_to_float_v3(&varray[start+12], mvert[f->v4].no); normal_short_to_float_v3(&varray[start+15], mvert[f->v1].no); } } - else if(nors) { + else if (nors) { /* copy cached face normal */ copy_v3_v3(&varray[start], &nors[i*3]); copy_v3_v3(&varray[start+3], &nors[i*3]); copy_v3_v3(&varray[start+6], &nors[i*3]); - if(f->v4) { + if (f->v4) { copy_v3_v3(&varray[start+9], &nors[i*3]); copy_v3_v3(&varray[start+12], &nors[i*3]); copy_v3_v3(&varray[start+15], &nors[i*3]); @@ -650,7 +650,7 @@ static void GPU_buffer_copy_normal(DerivedMesh *dm, float *varray, int *index, i } else { /* calculate face normal */ - if(f->v4) + if (f->v4) normal_quad_v3(f_no, mvert[f->v1].co, mvert[f->v2].co, mvert[f->v3].co, mvert[f->v4].co); else normal_tri_v3(f_no, mvert[f->v1].co, mvert[f->v2].co, mvert[f->v3].co); @@ -659,7 +659,7 @@ static void GPU_buffer_copy_normal(DerivedMesh *dm, float *varray, int *index, i copy_v3_v3(&varray[start+3], f_no); copy_v3_v3(&varray[start+6], f_no); - if(f->v4) { + if (f->v4) { copy_v3_v3(&varray[start+9], f_no); copy_v3_v3(&varray[start+12], f_no); copy_v3_v3(&varray[start+15], f_no); @@ -676,12 +676,12 @@ static void GPU_buffer_copy_uv(DerivedMesh *dm, float *varray, int *index, int * MTFace *mtface; MFace *f; - if(!(mtface = DM_get_tessface_data_layer(dm, CD_MTFACE))) + if (!(mtface = DM_get_tessface_data_layer(dm, CD_MTFACE))) return; f = dm->getTessFaceArray(dm); totface = dm->getNumTessFaces(dm); - for(i = 0; i < totface; i++, f++) { + for (i = 0; i < totface; i++, f++) { start = index[mat_orig_to_new[f->mat_nr]]; /* v1 v2 v3 */ @@ -690,7 +690,7 @@ static void GPU_buffer_copy_uv(DerivedMesh *dm, float *varray, int *index, int * copy_v2_v2(&varray[start+4],mtface[i].uv[2]); index[mat_orig_to_new[f->mat_nr]] += 6; - if(f->v4) { + if (f->v4) { /* v3 v4 v1 */ copy_v2_v2(&varray[start+6],mtface[i].uv[2]); copy_v2_v2(&varray[start+8],mtface[i].uv[3]); @@ -709,7 +709,7 @@ static void GPU_buffer_copy_color3(DerivedMesh *dm, float *varray_, int *index, MFace *f = dm->getTessFaceArray(dm); totface= dm->getNumTessFaces(dm); - for(i=0; i < totface; i++, f++) { + for (i=0; i < totface; i++, f++) { int start = index[mat_orig_to_new[f->mat_nr]]; /* v1 v2 v3 */ @@ -718,7 +718,7 @@ static void GPU_buffer_copy_color3(DerivedMesh *dm, float *varray_, int *index, copy_v3_v3_char(&varray[start+6], &mcol[i*12+6]); index[mat_orig_to_new[f->mat_nr]] += 9; - if(f->v4) { + if (f->v4) { /* v3 v4 v1 */ copy_v3_v3_char(&varray[start+9], &mcol[i*12+6]); copy_v3_v3_char(&varray[start+12], &mcol[i*12+9]); @@ -744,7 +744,7 @@ static void GPU_buffer_copy_mcol(DerivedMesh *dm, float *varray_, int *index, in MFace *f = dm->getTessFaceArray(dm); totface= dm->getNumTessFaces(dm); - for(i=0; i < totface; i++, f++) { + for (i=0; i < totface; i++, f++) { int start = index[mat_orig_to_new[f->mat_nr]]; /* v1 v2 v3 */ @@ -753,7 +753,7 @@ static void GPU_buffer_copy_mcol(DerivedMesh *dm, float *varray_, int *index, in copy_mcol_uc3(&varray[start+6], &mcol[i*16+8]); index[mat_orig_to_new[f->mat_nr]] += 9; - if(f->v4) { + if (f->v4) { /* v3 v4 v1 */ copy_mcol_uc3(&varray[start+9], &mcol[i*16+8]); copy_mcol_uc3(&varray[start+12], &mcol[i*16+12]); @@ -772,7 +772,7 @@ static void GPU_buffer_copy_edge(DerivedMesh *dm, float *varray_, int *UNUSED(in medge = dm->getEdgeArray(dm); totedge = dm->getNumEdges(dm); - for(i = 0; i < totedge; i++, medge++) { + for (i = 0; i < totedge; i++, medge++) { varray[i*2] = dm->drawObject->vert_points[medge->v1].point_index; varray[i*2+1] = dm->drawObject->vert_points[medge->v2].point_index; } @@ -783,10 +783,10 @@ static void GPU_buffer_copy_uvedge(DerivedMesh *dm, float *varray, int *UNUSED(i MTFace *tf = DM_get_tessface_data_layer(dm, CD_MTFACE); int i, j=0; - if(!tf) + if (!tf) return; - for(i = 0; i < dm->numTessFaceData; i++, tf++) { + for (i = 0; i < dm->numTessFaceData; i++, tf++) { MFace mf; dm->getTessFace(dm,i,&mf); @@ -796,11 +796,12 @@ static void GPU_buffer_copy_uvedge(DerivedMesh *dm, float *varray, int *UNUSED(i copy_v2_v2(&varray[j+4],tf->uv[1]); copy_v2_v2(&varray[j+6],tf->uv[2]); - if(!mf.v4) { + if (!mf.v4) { copy_v2_v2(&varray[j+8],tf->uv[2]); copy_v2_v2(&varray[j+10],tf->uv[0]); j+=12; - } else { + } + else { copy_v2_v2(&varray[j+8],tf->uv[2]); copy_v2_v2(&varray[j+10],tf->uv[3]); @@ -820,10 +821,10 @@ static MCol *gpu_buffer_color_type(DerivedMesh *dm) type = CD_ID_MCOL; c = DM_get_tessface_data_layer(dm, type); - if(!c) { + if (!c) { type = CD_PREVIEW_MCOL; c = DM_get_tessface_data_layer(dm, type); - if(!c) { + if (!c) { type = CD_MCOL; c = DM_get_tessface_data_layer(dm, type); } @@ -914,12 +915,12 @@ static GPUBuffer *gpu_buffer_setup_type(DerivedMesh *dm, GPUBufferType type) ts = &gpu_buffer_type_settings[type]; /* special handling for MCol and UV buffers */ - if(type == GPU_BUFFER_COLOR) { - if(!(user_data = gpu_buffer_color_type(dm))) + if (type == GPU_BUFFER_COLOR) { + if (!(user_data = gpu_buffer_color_type(dm))) return NULL; } - else if(type == GPU_BUFFER_UV) { - if(!DM_get_tessface_data_layer(dm, CD_MTFACE)) + else if (type == GPU_BUFFER_UV) { + if (!DM_get_tessface_data_layer(dm, CD_MTFACE)) return NULL; } @@ -936,11 +937,11 @@ static GPUBuffer *gpu_buffer_setup_common(DerivedMesh *dm, GPUBufferType type) { GPUBuffer **buf; - if(!dm->drawObject) + if (!dm->drawObject) dm->drawObject = GPU_drawobject_new(dm); buf = gpu_drawobject_buffer_from_type(dm->drawObject, type); - if(!(*buf)) + if (!(*buf)) *buf = gpu_buffer_setup_type(dm, type); return *buf; @@ -948,11 +949,11 @@ static GPUBuffer *gpu_buffer_setup_common(DerivedMesh *dm, GPUBufferType type) void GPU_vertex_setup(DerivedMesh *dm) { - if(!gpu_buffer_setup_common(dm, GPU_BUFFER_VERTEX)) + if (!gpu_buffer_setup_common(dm, GPU_BUFFER_VERTEX)) return; glEnableClientState(GL_VERTEX_ARRAY); - if(useVBOs) { + if (useVBOs) { glBindBufferARB(GL_ARRAY_BUFFER_ARB, dm->drawObject->points->id); glVertexPointer(3, GL_FLOAT, 0, 0); } @@ -965,11 +966,11 @@ void GPU_vertex_setup(DerivedMesh *dm) void GPU_normal_setup(DerivedMesh *dm) { - if(!gpu_buffer_setup_common(dm, GPU_BUFFER_NORMAL)) + if (!gpu_buffer_setup_common(dm, GPU_BUFFER_NORMAL)) return; glEnableClientState(GL_NORMAL_ARRAY); - if(useVBOs) { + if (useVBOs) { glBindBufferARB(GL_ARRAY_BUFFER_ARB, dm->drawObject->normals->id); glNormalPointer(GL_FLOAT, 0, 0); } @@ -982,11 +983,11 @@ void GPU_normal_setup(DerivedMesh *dm) void GPU_uv_setup(DerivedMesh *dm) { - if(!gpu_buffer_setup_common(dm, GPU_BUFFER_UV)) + if (!gpu_buffer_setup_common(dm, GPU_BUFFER_UV)) return; glEnableClientState(GL_TEXTURE_COORD_ARRAY); - if(useVBOs) { + if (useVBOs) { glBindBufferARB(GL_ARRAY_BUFFER_ARB, dm->drawObject->uv->id); glTexCoordPointer(2, GL_FLOAT, 0, 0); } @@ -999,11 +1000,11 @@ void GPU_uv_setup(DerivedMesh *dm) void GPU_color_setup(DerivedMesh *dm) { - if(!gpu_buffer_setup_common(dm, GPU_BUFFER_COLOR)) + if (!gpu_buffer_setup_common(dm, GPU_BUFFER_COLOR)) return; glEnableClientState(GL_COLOR_ARRAY); - if(useVBOs) { + if (useVBOs) { glBindBufferARB(GL_ARRAY_BUFFER_ARB, dm->drawObject->colors->id); glColorPointer(3, GL_UNSIGNED_BYTE, 0, 0); } @@ -1016,14 +1017,14 @@ void GPU_color_setup(DerivedMesh *dm) void GPU_edge_setup(DerivedMesh *dm) { - if(!gpu_buffer_setup_common(dm, GPU_BUFFER_EDGE)) + if (!gpu_buffer_setup_common(dm, GPU_BUFFER_EDGE)) return; - if(!gpu_buffer_setup_common(dm, GPU_BUFFER_VERTEX)) + if (!gpu_buffer_setup_common(dm, GPU_BUFFER_VERTEX)) return; glEnableClientState(GL_VERTEX_ARRAY); - if(useVBOs) { + if (useVBOs) { glBindBufferARB(GL_ARRAY_BUFFER_ARB, dm->drawObject->points->id); glVertexPointer(3, GL_FLOAT, 0, 0); } @@ -1033,7 +1034,7 @@ void GPU_edge_setup(DerivedMesh *dm) GLStates |= GPU_BUFFER_VERTEX_STATE; - if(useVBOs) + if (useVBOs) glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, dm->drawObject->edges->id); GLStates |= GPU_BUFFER_ELEMENT_STATE; @@ -1041,11 +1042,11 @@ void GPU_edge_setup(DerivedMesh *dm) void GPU_uvedge_setup(DerivedMesh *dm) { - if(!gpu_buffer_setup_common(dm, GPU_BUFFER_UVEDGE)) + if (!gpu_buffer_setup_common(dm, GPU_BUFFER_UVEDGE)) return; glEnableClientState(GL_VERTEX_ARRAY); - if(useVBOs) { + if (useVBOs) { glBindBufferARB(GL_ARRAY_BUFFER_ARB, dm->drawObject->uvedges->id); glVertexPointer(2, GL_FLOAT, 0, 0); } @@ -1078,9 +1079,9 @@ int GPU_attrib_element_size(GPUAttrib data[], int numdata) { int i, elementsize = 0; - for(i = 0; i < numdata; i++) { + for (i = 0; i < numdata; i++) { int typesize = GPU_typesize(data[i].type); - if(typesize != 0) + if (typesize != 0) elementsize += typesize*data[i].size; } return elementsize; @@ -1092,8 +1093,8 @@ void GPU_interleaved_attrib_setup(GPUBuffer *buffer, GPUAttrib data[], int numda int elementsize; intptr_t offset = 0; - for(i = 0; i < MAX_GPU_ATTRIB_DATA; i++) { - if(attribData[i].index != -1) { + for (i = 0; i < MAX_GPU_ATTRIB_DATA; i++) { + if (attribData[i].index != -1) { glDisableVertexAttribArrayARB(attribData[i].index); } else @@ -1101,9 +1102,9 @@ void GPU_interleaved_attrib_setup(GPUBuffer *buffer, GPUAttrib data[], int numda } elementsize = GPU_attrib_element_size(data, numdata); - if(useVBOs) { + if (useVBOs) { glBindBufferARB(GL_ARRAY_BUFFER_ARB, buffer->id); - for(i = 0; i < numdata; i++) { + for (i = 0; i < numdata; i++) { glEnableVertexAttribArrayARB(data[i].index); glVertexAttribPointerARB(data[i].index, data[i].size, data[i].type, GL_FALSE, elementsize, (void *)offset); @@ -1116,7 +1117,7 @@ void GPU_interleaved_attrib_setup(GPUBuffer *buffer, GPUAttrib data[], int numda attribData[numdata].index = -1; } else { - for(i = 0; i < numdata; i++) { + for (i = 0; i < numdata; i++) { glEnableVertexAttribArrayARB(data[i].index); glVertexAttribPointerARB(data[i].index, data[i].size, data[i].type, GL_FALSE, elementsize, (char *)buffer->pointer + offset); @@ -1130,16 +1131,16 @@ void GPU_buffer_unbind(void) { int i; - if(GLStates & GPU_BUFFER_VERTEX_STATE) + if (GLStates & GPU_BUFFER_VERTEX_STATE) glDisableClientState(GL_VERTEX_ARRAY); - if(GLStates & GPU_BUFFER_NORMAL_STATE) + if (GLStates & GPU_BUFFER_NORMAL_STATE) glDisableClientState(GL_NORMAL_ARRAY); - if(GLStates & GPU_BUFFER_TEXCOORD_STATE) + if (GLStates & GPU_BUFFER_TEXCOORD_STATE) glDisableClientState(GL_TEXTURE_COORD_ARRAY); - if(GLStates & GPU_BUFFER_COLOR_STATE) + if (GLStates & GPU_BUFFER_COLOR_STATE) glDisableClientState(GL_COLOR_ARRAY); - if(GLStates & GPU_BUFFER_ELEMENT_STATE) { - if(useVBOs) { + if (GLStates & GPU_BUFFER_ELEMENT_STATE) { + if (useVBOs) { glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0); } } @@ -1147,15 +1148,15 @@ void GPU_buffer_unbind(void) GPU_BUFFER_TEXCOORD_STATE | GPU_BUFFER_COLOR_STATE | GPU_BUFFER_ELEMENT_STATE); - for(i = 0; i < MAX_GPU_ATTRIB_DATA; i++) { - if(attribData[i].index != -1) { + for (i = 0; i < MAX_GPU_ATTRIB_DATA; i++) { + if (attribData[i].index != -1) { glDisableVertexAttribArrayARB(attribData[i].index); } else break; } - if(useVBOs) + if (useVBOs) glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); } @@ -1164,7 +1165,7 @@ void GPU_buffer_unbind(void) like it will just needlessly overwrite? --nicholas */ void GPU_color3_upload(DerivedMesh *dm, unsigned char *data) { - if(dm->drawObject == 0) + if (dm->drawObject == 0) dm->drawObject = GPU_drawobject_new(dm); GPU_buffer_free(dm->drawObject->colors); @@ -1175,13 +1176,13 @@ void GPU_color3_upload(DerivedMesh *dm, unsigned char *data) void GPU_color_switch(int mode) { - if(mode) { - if(!(GLStates & GPU_BUFFER_COLOR_STATE)) + if (mode) { + if (!(GLStates & GPU_BUFFER_COLOR_STATE)) glEnableClientState(GL_COLOR_ARRAY); GLStates |= GPU_BUFFER_COLOR_STATE; } else { - if(GLStates & GPU_BUFFER_COLOR_STATE) + if (GLStates & GPU_BUFFER_COLOR_STATE) glDisableClientState(GL_COLOR_ARRAY); GLStates &= (!GPU_BUFFER_COLOR_STATE); } @@ -1192,10 +1193,10 @@ void GPU_color_switch(int mode) int GPU_buffer_legacy(DerivedMesh *dm) { int test= (U.gameflags & USER_DISABLE_VBO); - if(test) + if (test) return 1; - if(dm->drawObject == 0) + if (dm->drawObject == 0) dm->drawObject = GPU_drawobject_new(dm); return dm->drawObject->legacy; } @@ -1204,10 +1205,10 @@ void *GPU_buffer_lock(GPUBuffer *buffer) { float *varray; - if(!buffer) + if (!buffer) return 0; - if(useVBOs) { + if (useVBOs) { glBindBufferARB(GL_ARRAY_BUFFER_ARB, buffer->id); varray = glMapBufferARB(GL_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB); return varray; @@ -1221,10 +1222,10 @@ void *GPU_buffer_lock_stream(GPUBuffer *buffer) { float *varray; - if(!buffer) + if (!buffer) return 0; - if(useVBOs) { + if (useVBOs) { glBindBufferARB(GL_ARRAY_BUFFER_ARB, buffer->id); /* discard previous data, avoid stalling gpu */ glBufferDataARB(GL_ARRAY_BUFFER_ARB, buffer->size, 0, GL_STREAM_DRAW_ARB); @@ -1238,8 +1239,8 @@ void *GPU_buffer_lock_stream(GPUBuffer *buffer) void GPU_buffer_unlock(GPUBuffer *buffer) { - if(useVBOs) { - if(buffer) { + if (useVBOs) { + if (buffer) { /* note: this operation can fail, could return an error code from this function? */ glUnmapBufferARB(GL_ARRAY_BUFFER_ARB); @@ -1296,7 +1297,7 @@ void GPU_update_mesh_buffers(GPU_Buffers *buffers, MVert *mvert, VertexBufferFormat *vert_data; int i; - if(buffers->vert_buf) { + if (buffers->vert_buf) { /* Build VBO */ glBindBufferARB(GL_ARRAY_BUFFER_ARB, buffers->vert_buf); glBufferDataARB(GL_ARRAY_BUFFER_ARB, @@ -1304,8 +1305,8 @@ void GPU_update_mesh_buffers(GPU_Buffers *buffers, MVert *mvert, NULL, GL_STATIC_DRAW_ARB); vert_data = glMapBufferARB(GL_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB); - if(vert_data) { - for(i = 0; i < totvert; ++i) { + if (vert_data) { + for (i = 0; i < totvert; ++i) { MVert *v = mvert + vert_indices[i]; VertexBufferFormat *out = vert_data + i; @@ -1339,16 +1340,16 @@ GPU_Buffers *GPU_build_mesh_buffers(int (*face_vert_indices)[4], buffers->index_type = GL_UNSIGNED_SHORT; /* Count the number of visible triangles */ - for(i = 0, tottri = 0; i < totface; ++i) { + for (i = 0, tottri = 0; i < totface; ++i) { const MFace *f = &mface[face_indices[i]]; - if(!paint_is_face_hidden(f, mvert)) + if (!paint_is_face_hidden(f, mvert)) tottri += f->v4 ? 2 : 1; } - if(GLEW_ARB_vertex_buffer_object && !(U.gameflags & USER_DISABLE_VBO)) + if (GLEW_ARB_vertex_buffer_object && !(U.gameflags & USER_DISABLE_VBO)) glGenBuffersARB(1, &buffers->index_buf); - if(buffers->index_buf) { + if (buffers->index_buf) { /* Generate index buffer object */ glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, buffers->index_buf); glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, @@ -1356,21 +1357,21 @@ GPU_Buffers *GPU_build_mesh_buffers(int (*face_vert_indices)[4], /* Fill the triangle buffer */ tri_data = glMapBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB); - if(tri_data) { - for(i = 0; i < totface; ++i) { + if (tri_data) { + for (i = 0; i < totface; ++i) { const MFace *f = mface + face_indices[i]; int v[3]; /* Skip hidden faces */ - if(paint_is_face_hidden(f, mvert)) + if (paint_is_face_hidden(f, mvert)) continue; v[0]= 0; v[1]= 1; v[2]= 2; - for(j = 0; j < (f->v4 ? 2 : 1); ++j) { - for(k = 0; k < 3; ++k) { + for (j = 0; j < (f->v4 ? 2 : 1); ++j) { + for (k = 0; k < 3; ++k) { *tri_data = face_vert_indices[i][v[k]]; ++tri_data; } @@ -1389,7 +1390,7 @@ GPU_Buffers *GPU_build_mesh_buffers(int (*face_vert_indices)[4], glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0); } - if(buffers->index_buf) + if (buffers->index_buf) glGenBuffersARB(1, &buffers->vert_buf); buffers->tot_tri = tottri; @@ -1410,7 +1411,7 @@ void GPU_update_grid_buffers(GPU_Buffers *buffers, DMGridData **grids, totvert= gridsize*gridsize*totgrid; /* Build VBO */ - if(buffers->vert_buf) { + if (buffers->vert_buf) { int smooth = grid_flag_mats[grid_indices[0]].flag & ME_SMOOTH; glBindBufferARB(GL_ARRAY_BUFFER_ARB, buffers->vert_buf); @@ -1418,17 +1419,17 @@ void GPU_update_grid_buffers(GPU_Buffers *buffers, DMGridData **grids, sizeof(DMGridData) * totvert, NULL, GL_STATIC_DRAW_ARB); vert_data = glMapBufferARB(GL_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB); - if(vert_data) { - for(i = 0; i < totgrid; ++i) { + if (vert_data) { + for (i = 0; i < totgrid; ++i) { DMGridData *grid= grids[grid_indices[i]]; memcpy(vert_data, grid, sizeof(DMGridData)*gridsize*gridsize); - if(!smooth) { + if (!smooth) { /* for flat shading, recalc normals and set the last vertex of each quad in the index buffer to have the flat normal as that is what opengl will use */ - for(j = 0; j < gridsize-1; ++j) { - for(k = 0; k < gridsize-1; ++k) { + for (j = 0; j < gridsize-1; ++j) { + for (k = 0; k < gridsize-1; ++k) { float fno[3]; normal_quad_v3(fno, grid[(j+1)*gridsize + k].co, @@ -1472,14 +1473,14 @@ static int gpu_count_grid_quads(BLI_bitmap *grid_hidden, /* grid hidden layer is present, so have to check each grid for visiblity */ - for(i = 0, totquad = 0; i < totgrid; i++) { + for (i = 0, totquad = 0; i < totgrid; i++) { const BLI_bitmap gh = grid_hidden[grid_indices[i]]; - if(gh) { + if (gh) { /* grid hidden are present, have to check each element */ - for(y = 0; y < gridsize-1; y++) { - for(x = 0; x < gridsize-1; x++) { - if(!paint_is_grid_face_hidden(gh, gridsize, x, y)) + for (y = 0; y < gridsize-1; y++) { + for (x = 0; x < gridsize-1; x++) { + if (!paint_is_grid_face_hidden(gh, gridsize, x, y)) totquad++; } } @@ -1506,16 +1507,16 @@ static int gpu_count_grid_quads(BLI_bitmap *grid_hidden, /* Fill the quad buffer */ \ quad_data = glMapBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, \ GL_WRITE_ONLY_ARB); \ - if(quad_data) { \ - for(i = 0; i < totgrid; ++i) { \ + if (quad_data) { \ + for (i = 0; i < totgrid; ++i) { \ BLI_bitmap gh = NULL; \ - if(grid_hidden) \ + if (grid_hidden) \ gh = grid_hidden[(grid_indices)[i]]; \ \ - for(j = 0; j < gridsize-1; ++j) { \ - for(k = 0; k < gridsize-1; ++k) { \ + for (j = 0; j < gridsize-1; ++j) { \ + for (k = 0; k < gridsize-1; ++k) { \ /* Skip hidden grid face */ \ - if(gh && \ + if (gh && \ paint_is_grid_face_hidden(gh, \ gridsize, k, j)) \ continue; \ @@ -1552,14 +1553,14 @@ static GLuint gpu_get_grid_buffer(int gridsize, GLenum *index_type, unsigned *to /* VBO is disabled; delete the previous buffer (if it exists) and return an invalid handle */ - if(!GLEW_ARB_vertex_buffer_object || (U.gameflags & USER_DISABLE_VBO)) { - if(buffer) + if (!GLEW_ARB_vertex_buffer_object || (U.gameflags & USER_DISABLE_VBO)) { + if (buffer) glDeleteBuffersARB(1, &buffer); return 0; } /* VBO is already built */ - if(buffer && prev_gridsize == gridsize) { + if (buffer && prev_gridsize == gridsize) { *index_type = prev_index_type; *totquad = prev_totquad; return buffer; @@ -1567,12 +1568,12 @@ static GLuint gpu_get_grid_buffer(int gridsize, GLenum *index_type, unsigned *to /* Build new VBO */ glGenBuffersARB(1, &buffer); - if(buffer) { + if (buffer) { *totquad= (gridsize-1)*(gridsize-1); glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, buffer); - if(gridsize * gridsize < USHRT_MAX) { + if (gridsize * gridsize < USHRT_MAX) { *index_type = GL_UNSIGNED_SHORT; FILL_QUAD_BUFFER(unsigned short, *totquad, buffer); } @@ -1605,19 +1606,19 @@ GPU_Buffers *GPU_build_grid_buffers(int *grid_indices, int totgrid, /* Count the number of quads */ totquad= gpu_count_grid_quads(grid_hidden, grid_indices, totgrid, gridsize); - if(totquad == fully_visible_totquad) { + if (totquad == fully_visible_totquad) { buffers->index_buf = gpu_get_grid_buffer(gridsize, &buffers->index_type, &buffers->tot_quad); buffers->has_hidden = 0; } - else if(GLEW_ARB_vertex_buffer_object && !(U.gameflags & USER_DISABLE_VBO)) { + else if (GLEW_ARB_vertex_buffer_object && !(U.gameflags & USER_DISABLE_VBO)) { /* Build new VBO */ glGenBuffersARB(1, &buffers->index_buf); - if(buffers->index_buf) { + if (buffers->index_buf) { buffers->tot_quad= totquad; glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, buffers->index_buf); - if(totgrid * gridsize * gridsize < USHRT_MAX) { + if (totgrid * gridsize * gridsize < USHRT_MAX) { buffers->index_type = GL_UNSIGNED_SHORT; FILL_QUAD_BUFFER(unsigned short, totquad, buffers->index_buf); } @@ -1633,7 +1634,7 @@ GPU_Buffers *GPU_build_grid_buffers(int *grid_indices, int totgrid, } /* Build coord/normal VBO */ - if(buffers->index_buf) + if (buffers->index_buf) glGenBuffersARB(1, &buffers->vert_buf); return buffers; @@ -1646,18 +1647,18 @@ static void gpu_draw_buffers_legacy_mesh(GPU_Buffers *buffers, int smooth) const MVert *mvert = buffers->mvert; int i, j; - for(i = 0; i < buffers->totface; ++i) { + for (i = 0; i < buffers->totface; ++i) { MFace *f = buffers->mface + buffers->face_indices[i]; int S = f->v4 ? 4 : 3; unsigned int *fv = &f->v1; - if(paint_is_face_hidden(f, buffers->mvert)) + if (paint_is_face_hidden(f, buffers->mvert)) continue; glBegin((f->v4)? GL_QUADS: GL_TRIANGLES); - if(smooth) { - for(j = 0; j < S; j++) { + if (smooth) { + for (j = 0; j < S; j++) { glNormal3sv(mvert[fv[j]].no); glVertex3fv(mvert[fv[j]].co); } @@ -1666,7 +1667,7 @@ static void gpu_draw_buffers_legacy_mesh(GPU_Buffers *buffers, int smooth) float fno[3]; /* calculate face normal */ - if(f->v4) { + if (f->v4) { normal_quad_v3(fno, mvert[fv[0]].co, mvert[fv[1]].co, mvert[fv[2]].co, mvert[fv[3]].co); } @@ -1674,7 +1675,7 @@ static void gpu_draw_buffers_legacy_mesh(GPU_Buffers *buffers, int smooth) normal_tri_v3(fno, mvert[fv[0]].co, mvert[fv[1]].co, mvert[fv[2]].co); glNormal3fv(fno); - for(j = 0; j < S; j++) + for (j = 0; j < S; j++) glVertex3fv(mvert[fv[j]].co); } @@ -1686,18 +1687,18 @@ static void gpu_draw_buffers_legacy_grids(GPU_Buffers *buffers, int smooth) { int i, j, x, y, gridsize = buffers->gridsize; - for(i = 0; i < buffers->totgrid; ++i) { + for (i = 0; i < buffers->totgrid; ++i) { int g = buffers->grid_indices[i]; const DMGridData *grid = buffers->grids[g]; BLI_bitmap gh = buffers->grid_hidden[g]; /* TODO: could use strips with hiding as well */ - if(gh) { + if (gh) { glBegin(GL_QUADS); - for(y = 0; y < gridsize-1; y++) { - for(x = 0; x < gridsize-1; x++) { + for (y = 0; y < gridsize-1; y++) { + for (x = 0; x < gridsize-1; x++) { const DMGridData *e[4] = { &grid[y*gridsize + x], &grid[(y+1)*gridsize + x], @@ -1706,11 +1707,11 @@ static void gpu_draw_buffers_legacy_grids(GPU_Buffers *buffers, int smooth) }; /* skip face if any of its corners are hidden */ - if(paint_is_grid_face_hidden(gh, gridsize, x, y)) + if (paint_is_grid_face_hidden(gh, gridsize, x, y)) continue; - if(smooth) { - for(j = 0; j < 4; j++) { + if (smooth) { + for (j = 0; j < 4; j++) { glNormal3fv(e[j]->no); glVertex3fv(e[j]->co); } @@ -1720,7 +1721,7 @@ static void gpu_draw_buffers_legacy_grids(GPU_Buffers *buffers, int smooth) normal_quad_v3(fno, e[0]->co, e[1]->co, e[2]->co, e[3]->co); glNormal3fv(fno); - for(j = 0; j < 4; j++) + for (j = 0; j < 4; j++) glVertex3fv(e[j]->co); } } @@ -1728,10 +1729,10 @@ static void gpu_draw_buffers_legacy_grids(GPU_Buffers *buffers, int smooth) glEnd(); } - else if(smooth) { - for(y = 0; y < gridsize-1; y++) { + else if (smooth) { + for (y = 0; y < gridsize-1; y++) { glBegin(GL_QUAD_STRIP); - for(x = 0; x < gridsize; x++) { + for (x = 0; x < gridsize; x++) { const DMGridData *a = &grid[y*gridsize + x]; const DMGridData *b = &grid[(y+1)*gridsize + x]; @@ -1744,13 +1745,13 @@ static void gpu_draw_buffers_legacy_grids(GPU_Buffers *buffers, int smooth) } } else { - for(y = 0; y < gridsize-1; y++) { + for (y = 0; y < gridsize-1; y++) { glBegin(GL_QUAD_STRIP); - for(x = 0; x < gridsize; x++) { + for (x = 0; x < gridsize; x++) { const DMGridData *a = &grid[y*gridsize + x]; const DMGridData *b = &grid[(y+1)*gridsize + x]; - if(x > 0) { + if (x > 0) { const DMGridData *c = &grid[y*gridsize + x-1]; const DMGridData *d = &grid[(y+1)*gridsize + x-1]; float fno[3]; @@ -1771,34 +1772,34 @@ void GPU_draw_buffers(GPU_Buffers *buffers, DMSetMaterial setMaterial) { int smooth = 0; - if(buffers->totface) { + if (buffers->totface) { const MFace *f = &buffers->mface[buffers->face_indices[0]]; - if(!setMaterial(f->mat_nr+1, NULL)) + if (!setMaterial(f->mat_nr+1, NULL)) return; smooth = f->flag & ME_SMOOTH; glShadeModel(smooth ? GL_SMOOTH: GL_FLAT); } - else if(buffers->totgrid) { + else if (buffers->totgrid) { const DMFlagMat *f = &buffers->grid_flag_mats[buffers->grid_indices[0]]; - if(!setMaterial(f->mat_nr+1, NULL)) + if (!setMaterial(f->mat_nr+1, NULL)) return; smooth = f->flag & ME_SMOOTH; glShadeModel(smooth ? GL_SMOOTH: GL_FLAT); } - if(buffers->vert_buf && buffers->index_buf) { + if (buffers->vert_buf && buffers->index_buf) { glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_NORMAL_ARRAY); glBindBufferARB(GL_ARRAY_BUFFER_ARB, buffers->vert_buf); glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, buffers->index_buf); - if(buffers->tot_quad) { + if (buffers->tot_quad) { unsigned offset = 0; int i, last = buffers->has_hidden ? 1 : buffers->totgrid; - for(i = 0; i < last; i++) { + for (i = 0; i < last; i++) { glVertexPointer(3, GL_FLOAT, sizeof(DMGridData), offset + (char*)offsetof(DMGridData, co)); glNormalPointer(GL_FLOAT, sizeof(DMGridData), offset + (char*)offsetof(DMGridData, no)); @@ -1821,20 +1822,20 @@ void GPU_draw_buffers(GPU_Buffers *buffers, DMSetMaterial setMaterial) glDisableClientState(GL_NORMAL_ARRAY); } /* fallbacks if we are out of memory or VBO is disabled */ - else if(buffers->totface) { + else if (buffers->totface) { gpu_draw_buffers_legacy_mesh(buffers, smooth); } - else if(buffers->totgrid) { + else if (buffers->totgrid) { gpu_draw_buffers_legacy_grids(buffers, smooth); } } void GPU_free_buffers(GPU_Buffers *buffers) { - if(buffers) { - if(buffers->vert_buf) + if (buffers) { + if (buffers->vert_buf) glDeleteBuffersARB(1, &buffers->vert_buf); - if(buffers->index_buf && (buffers->tot_tri || buffers->has_hidden)) + if (buffers->index_buf && (buffers->tot_tri || buffers->has_hidden)) glDeleteBuffersARB(1, &buffers->index_buf); MEM_freeN(buffers); diff --git a/source/blender/gpu/intern/gpu_codegen.c b/source/blender/gpu/intern/gpu_codegen.c index 07d7568ab95..76291aef584 100644 --- a/source/blender/gpu/intern/gpu_codegen.c +++ b/source/blender/gpu/intern/gpu_codegen.c @@ -77,8 +77,8 @@ static GHash *FUNCTION_HASH= NULL; static int gpu_str_prefix(const char *str, const char *prefix) { - while(*str && *prefix) { - if(*str != *prefix) + while (*str && *prefix) { + if (*str != *prefix) return 0; str++; @@ -93,11 +93,11 @@ static char *gpu_str_skip_token(char *str, char *token, int max) int len = 0; /* skip a variable/function name */ - while(*str) { - if(ELEM7(*str, ' ', '(', ')', ',', '\t', '\n', '\r')) + while (*str) { + if (ELEM7(*str, ' ', '(', ')', ',', '\t', '\n', '\r')) break; else { - if(token && len < max-1) { + if (token && len < max-1) { *token= *str; token++; len++; @@ -106,13 +106,13 @@ static char *gpu_str_skip_token(char *str, char *token, int max) } } - if(token) + if (token) *token= '\0'; /* skip the next special characters: * note the missing ')' */ - while(*str) { - if(ELEM6(*str, ' ', '(', ',', '\t', '\n', '\r')) + while (*str) { + if (ELEM6(*str, ' ', '(', ',', '\t', '\n', '\r')) str++; else break; @@ -126,38 +126,38 @@ static void gpu_parse_functions_string(GHash *hash, char *code) GPUFunction *function; int i, type, qual; - while((code = strstr(code, "void "))) { + while ((code = strstr(code, "void "))) { function = MEM_callocN(sizeof(GPUFunction), "GPUFunction"); code = gpu_str_skip_token(code, NULL, 0); code = gpu_str_skip_token(code, function->name, MAX_FUNCTION_NAME); /* get parameters */ - while(*code && *code != ')') { + while (*code && *code != ')') { /* test if it's an input or output */ qual = FUNCTION_QUAL_IN; - if(gpu_str_prefix(code, "out ")) + if (gpu_str_prefix(code, "out ")) qual = FUNCTION_QUAL_OUT; - if(gpu_str_prefix(code, "inout ")) + if (gpu_str_prefix(code, "inout ")) qual = FUNCTION_QUAL_INOUT; - if((qual != FUNCTION_QUAL_IN) || gpu_str_prefix(code, "in ")) + if ((qual != FUNCTION_QUAL_IN) || gpu_str_prefix(code, "in ")) code = gpu_str_skip_token(code, NULL, 0); /* test for type */ type= 0; - for(i=1; i<=16; i++) { - if(GPU_DATATYPE_STR[i] && gpu_str_prefix(code, GPU_DATATYPE_STR[i])) { + for (i=1; i<=16; i++) { + if (GPU_DATATYPE_STR[i] && gpu_str_prefix(code, GPU_DATATYPE_STR[i])) { type= i; break; } } - if(!type && gpu_str_prefix(code, "sampler2DShadow")) + if (!type && gpu_str_prefix(code, "sampler2DShadow")) type= GPU_SHADOW2D; - if(!type && gpu_str_prefix(code, "sampler2D")) + if (!type && gpu_str_prefix(code, "sampler2D")) type= GPU_TEX2D; - if(type) { + if (type) { /* add paramater */ code = gpu_str_skip_token(code, NULL, 0); code = gpu_str_skip_token(code, NULL, 0); @@ -171,7 +171,7 @@ static void gpu_parse_functions_string(GHash *hash, char *code) } } - if(function->name[0] == '\0' || function->totparam == 0) { + if (function->name[0] == '\0' || function->totparam == 0) { fprintf(stderr, "GPU functions parse error.\n"); MEM_freeN(function); break; @@ -194,27 +194,27 @@ static char *gpu_generate_function_prototyps(GHash *hash) * generated code, to avoid have to add the actual code & recompile all */ ghi = BLI_ghashIterator_new(hash); - for(; !BLI_ghashIterator_isDone(ghi); BLI_ghashIterator_step(ghi)) { + for (; !BLI_ghashIterator_isDone(ghi); BLI_ghashIterator_step(ghi)) { name = BLI_ghashIterator_getValue(ghi); function = BLI_ghashIterator_getValue(ghi); BLI_dynstr_appendf(ds, "void %s(", name); - for(a=0; a<function->totparam; a++) { - if(function->paramqual[a] == FUNCTION_QUAL_OUT) + for (a=0; a<function->totparam; a++) { + if (function->paramqual[a] == FUNCTION_QUAL_OUT) BLI_dynstr_append(ds, "out "); - else if(function->paramqual[a] == FUNCTION_QUAL_INOUT) + else if (function->paramqual[a] == FUNCTION_QUAL_INOUT) BLI_dynstr_append(ds, "inout "); - if(function->paramtype[a] == GPU_TEX2D) + if (function->paramtype[a] == GPU_TEX2D) BLI_dynstr_append(ds, "sampler2D"); - else if(function->paramtype[a] == GPU_SHADOW2D) + else if (function->paramtype[a] == GPU_SHADOW2D) BLI_dynstr_append(ds, "sampler2DShadow"); else BLI_dynstr_append(ds, GPU_DATATYPE_STR[function->paramtype[a]]); //BLI_dynstr_appendf(ds, " param%d", a); - if(a != function->totparam-1) + if (a != function->totparam-1) BLI_dynstr_append(ds, ", "); } BLI_dynstr_append(ds, ");\n"); @@ -231,7 +231,7 @@ static char *gpu_generate_function_prototyps(GHash *hash) GPUFunction *GPU_lookup_function(const char *name) { - if(!FUNCTION_HASH) { + if (!FUNCTION_HASH) { FUNCTION_HASH = BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp, "GPU_lookup_function gh"); gpu_parse_functions_string(FUNCTION_HASH, glsl_material_library); /*FUNCTION_PROTOTYPES = gpu_generate_function_prototyps(FUNCTION_HASH); @@ -250,15 +250,15 @@ void GPU_codegen_exit(void) { extern Material defmaterial; // render module abuse... - if(defmaterial.gpumaterial.first) + if (defmaterial.gpumaterial.first) GPU_material_free(&defmaterial); - if(FUNCTION_HASH) { + if (FUNCTION_HASH) { BLI_ghash_free(FUNCTION_HASH, NULL, (GHashValFreeFP)MEM_freeN); FUNCTION_HASH = NULL; } - if(glsl_material_library) { + if (glsl_material_library) { MEM_freeN(glsl_material_library); glsl_material_library = NULL; } @@ -324,9 +324,9 @@ static void codegen_print_datatype(DynStr *ds, int type, float *data) BLI_dynstr_appendf(ds, "%s(", GPU_DATATYPE_STR[type]); - for(i=0; i<type; i++) { + for (i=0; i<type; i++) { BLI_dynstr_appendf(ds, "%f", data[i]); - if(i == type-1) + if (i == type-1) BLI_dynstr_append(ds, ")"); else BLI_dynstr_append(ds, ", "); @@ -337,7 +337,7 @@ static int codegen_input_has_texture(GPUInput *input) { if (input->link) return 0; - else if(input->ima) + else if (input->ima) return 1; else return input->tex != NULL; @@ -345,21 +345,21 @@ static int codegen_input_has_texture(GPUInput *input) const char *GPU_builtin_name(GPUBuiltin builtin) { - if(builtin == GPU_VIEW_MATRIX) + if (builtin == GPU_VIEW_MATRIX) return "unfviewmat"; - else if(builtin == GPU_OBJECT_MATRIX) + else if (builtin == GPU_OBJECT_MATRIX) return "unfobmat"; - else if(builtin == GPU_INVERSE_VIEW_MATRIX) + else if (builtin == GPU_INVERSE_VIEW_MATRIX) return "unfinvviewmat"; - else if(builtin == GPU_INVERSE_OBJECT_MATRIX) + else if (builtin == GPU_INVERSE_OBJECT_MATRIX) return "unfinvobmat"; - else if(builtin == GPU_VIEW_POSITION) + else if (builtin == GPU_VIEW_POSITION) return "varposition"; - else if(builtin == GPU_VIEW_NORMAL) + else if (builtin == GPU_VIEW_NORMAL) return "varnormal"; - else if(builtin == GPU_OBCOLOR) + else if (builtin == GPU_OBCOLOR) return "unfobcolor"; - else if(builtin == GPU_AUTO_BUMPSCALE) + else if (builtin == GPU_AUTO_BUMPSCALE) return "unfobautobumpscale"; else return ""; @@ -397,7 +397,7 @@ static void codegen_set_unique_ids(ListBase *nodes) else input->texid = GET_INT_FROM_POINTER(BLI_ghash_lookup(bindhash, input->link)); } - else if(input->ima) { + else if (input->ima) { /* input is texture from image, assign only one texid per buffer to avoid sampling the same texture twice */ if (!BLI_ghash_haskey(bindhash, input->ima)) { @@ -421,7 +421,7 @@ static void codegen_set_unique_ids(ListBase *nodes) /* make sure this pixel is defined exactly once */ if (input->source == GPU_SOURCE_TEX_PIXEL) { - if(input->ima) { + if (input->ima) { if (!BLI_ghash_haskey(definehash, input->ima)) { input->definetex = 1; BLI_ghash_insert(definehash, input->ima, SET_INT_IN_POINTER(input->texid)); @@ -463,13 +463,13 @@ static void codegen_print_uniforms_functions(DynStr *ds, ListBase *nodes) (input->textype == GPU_TEX2D)? "sampler2D": "sampler2DShadow", input->texid); } - else if(input->source == GPU_SOURCE_BUILTIN) { + else if (input->source == GPU_SOURCE_BUILTIN) { /* only define each builting uniform/varying once */ - if(!(builtins & input->builtin)) { + if (!(builtins & input->builtin)) { builtins |= input->builtin; name = GPU_builtin_name(input->builtin); - if(gpu_str_prefix(name, "unf")) { + if (gpu_str_prefix(name, "unf")) { BLI_dynstr_appendf(ds, "uniform %s %s;\n", GPU_DATATYPE_STR[input->type], name); } @@ -480,7 +480,7 @@ static void codegen_print_uniforms_functions(DynStr *ds, ListBase *nodes) } } else if (input->source == GPU_SOURCE_VEC_UNIFORM) { - if(input->dynamicvec) { + if (input->dynamicvec) { /* only create uniforms for dynamic vectors */ BLI_dynstr_appendf(ds, "uniform %s unf%d;\n", GPU_DATATYPE_STR[input->type], input->id); @@ -549,10 +549,10 @@ static void codegen_call_functions(DynStr *ds, ListBase *nodes, GPUOutput *final codegen_convert_datatype(ds, input->link->output->type, input->type, "tmp", input->link->output->id); } - else if(input->source == GPU_SOURCE_BUILTIN) + else if (input->source == GPU_SOURCE_BUILTIN) BLI_dynstr_appendf(ds, "%s", GPU_builtin_name(input->builtin)); - else if(input->source == GPU_SOURCE_VEC_UNIFORM) { - if(input->dynamicvec) + else if (input->source == GPU_SOURCE_VEC_UNIFORM) { + if (input->dynamicvec) BLI_dynstr_appendf(ds, "unf%d", input->id); else BLI_dynstr_appendf(ds, "cons%d", input->id); @@ -631,7 +631,7 @@ static char *code_generate_vertex(ListBase *nodes) for (node=nodes->first; node; node=node->next) for (input=node->inputs.first; input; input=input->next) if (input->source == GPU_SOURCE_ATTRIB && input->attribfirst) { - if(input->attribtype == CD_TANGENT) { /* silly exception */ + if (input->attribtype == CD_TANGENT) { /* silly exception */ BLI_dynstr_appendf(ds, "\tvar%d.xyz = normalize((gl_ModelViewMatrix * vec4(att%d.xyz, 0)).xyz);\n", input->attribid, input->attribid); BLI_dynstr_appendf(ds, "\tvar%d.w = att%d.w;\n", input->attribid, input->attribid); } @@ -660,12 +660,12 @@ void GPU_code_generate_glsl_lib(void) DynStr *ds; /* only initialize the library once */ - if(glsl_material_library) + if (glsl_material_library) return; ds = BLI_dynstr_new(); - if(GPU_bicubic_bump_support()){ + if (GPU_bicubic_bump_support()) { BLI_dynstr_append(ds, "/* These are needed for high quality bump mapping */\n" "#version 130\n" "#extension GL_ARB_texture_query_lod: enable\n" @@ -697,7 +697,7 @@ static void GPU_nodes_extract_dynamic_inputs(GPUPass *pass, ListBase *nodes) memset(inputs, 0, sizeof(*inputs)); - if(!shader) + if (!shader) return; GPU_shader_bind(shader); @@ -709,7 +709,7 @@ static void GPU_nodes_extract_dynamic_inputs(GPUPass *pass, ListBase *nodes) /* attributes don't need to be bound, they already have * an id that the drawing functions will use */ - if(input->source == GPU_SOURCE_ATTRIB || + if (input->source == GPU_SOURCE_ATTRIB || input->source == GPU_SOURCE_BUILTIN) continue; @@ -721,18 +721,18 @@ static void GPU_nodes_extract_dynamic_inputs(GPUPass *pass, ListBase *nodes) /* pass non-dynamic uniforms to opengl */ extract = 0; - if(input->ima || input->tex) { + if (input->ima || input->tex) { if (input->bindtex) extract = 1; } - else if(input->dynamicvec) + else if (input->dynamicvec) extract = 1; - if(extract) + if (extract) input->shaderloc = GPU_shader_get_uniform(shader, input->shadername); /* extract nodes */ - if(extract) { + if (extract) { BLI_remlink(&node->inputs, input); BLI_addtail(inputs, input); } @@ -758,7 +758,7 @@ void GPU_pass_bind(GPUPass *pass, double time, int mipmap) if (input->ima) input->tex = GPU_texture_from_blender(input->ima, input->iuser, time, mipmap); - if(input->tex && input->bindtex) { + if (input->tex && input->bindtex) { GPU_texture_bind(input->tex, input->texid); GPU_shader_uniform_texture(shader, input->shaderloc, input->tex); } @@ -776,7 +776,7 @@ void GPU_pass_update_uniforms(GPUPass *pass) /* pass dynamic inputs to opengl, others were removed */ for (input=inputs->first; input; input=input->next) - if(!(input->ima || input->tex)) + if (!(input->ima || input->tex)) GPU_shader_uniform_vector(shader, input->shaderloc, input->type, 1, input->dynamicvec); } @@ -791,7 +791,7 @@ void GPU_pass_unbind(GPUPass *pass) return; for (input=inputs->first; input; input=input->next) { - if(input->tex && input->bindtex) + if (input->tex && input->bindtex) GPU_texture_unbind(input->tex); if (input->ima) @@ -848,14 +848,14 @@ static void gpu_node_input_link(GPUNode *node, GPUNodeLink *link, int type) GPUNode *outnode; const char *name; - if(link->output) { + if (link->output) { outnode = link->output->node; name = outnode->name; - if(strcmp(name, "set_value")==0 || strcmp(name, "set_rgb")==0) { + if (strcmp(name, "set_value")==0 || strcmp(name, "set_rgb")==0) { input = MEM_dupallocN(outnode->inputs.first); input->type = type; - if(input->link) + if (input->link) input->link->users++; BLI_addtail(&node->inputs, input); return; @@ -865,7 +865,7 @@ static void gpu_node_input_link(GPUNode *node, GPUNodeLink *link, int type) input = MEM_callocN(sizeof(GPUInput), "GPUInput"); input->node = node; - if(link->builtin) { + if (link->builtin) { /* builtin uniform */ input->type = type; input->source = GPU_SOURCE_BUILTIN; @@ -873,14 +873,14 @@ static void gpu_node_input_link(GPUNode *node, GPUNodeLink *link, int type) MEM_freeN(link); } - else if(link->output) { + else if (link->output) { /* link to a node output */ input->type = type; input->source = GPU_SOURCE_TEX_PIXEL; input->link = link; link->users++; } - else if(link->dynamictex) { + else if (link->dynamictex) { /* dynamic texture, GPUTexture is updated/deleted externally */ input->type = type; input->source = GPU_SOURCE_TEX; @@ -892,7 +892,7 @@ static void gpu_node_input_link(GPUNode *node, GPUNodeLink *link, int type) input->dynamicdata = link->ptr2; MEM_freeN(link); } - else if(link->texture) { + else if (link->texture) { /* small texture created on the fly, like for colorbands */ input->type = GPU_VEC4; input->source = GPU_SOURCE_TEX; @@ -905,7 +905,7 @@ static void gpu_node_input_link(GPUNode *node, GPUNodeLink *link, int type) MEM_freeN(link->ptr1); MEM_freeN(link); } - else if(link->image) { + else if (link->image) { /* blender image */ input->type = GPU_VEC4; input->source = GPU_SOURCE_TEX; @@ -916,7 +916,7 @@ static void gpu_node_input_link(GPUNode *node, GPUNodeLink *link, int type) input->textype = GPU_TEX2D; MEM_freeN(link); } - else if(link->attribtype) { + else if (link->attribtype) { /* vertex attribute */ input->type = type; input->source = GPU_SOURCE_ATTRIB; @@ -931,7 +931,7 @@ static void gpu_node_input_link(GPUNode *node, GPUNodeLink *link, int type) input->source = GPU_SOURCE_VEC_UNIFORM; memcpy(input->vec, link->ptr1, type*sizeof(float)); - if(link->dynamic) { + if (link->dynamic) { input->dynamicvec= link->ptr1; input->dynamictype= link->dynamictype; input->dynamicdata= link->ptr2; @@ -946,7 +946,7 @@ static void gpu_node_input_socket(GPUNode *node, GPUNodeStack *sock) { GPUNodeLink *link; - if(sock->link) { + if (sock->link) { gpu_node_input_link(node, sock->link, sock->type); } else { @@ -979,10 +979,10 @@ static void GPU_inputs_free(ListBase *inputs) { GPUInput *input; - for(input=inputs->first; input; input=input->next) { - if(input->link) + for (input=inputs->first; input; input=input->next) { + if (input->link) GPU_node_link_free(input->link); - else if(input->tex && !input->dynamictex) + else if (input->tex && !input->dynamictex) GPU_texture_free(input->tex); } @@ -1029,16 +1029,16 @@ static void gpu_nodes_get_vertex_attributes(ListBase *nodes, GPUVertexAttribs *a memset(attribs, 0, sizeof(*attribs)); - for(node=nodes->first; node; node=node->next) { - for(input=node->inputs.first; input; input=input->next) { - if(input->source == GPU_SOURCE_ATTRIB) { - for(a=0; a<attribs->totlayer; a++) { - if(attribs->layer[a].type == input->attribtype && + for (node=nodes->first; node; node=node->next) { + for (input=node->inputs.first; input; input=input->next) { + if (input->source == GPU_SOURCE_ATTRIB) { + for (a=0; a<attribs->totlayer; a++) { + if (attribs->layer[a].type == input->attribtype && strcmp(attribs->layer[a].name, input->attribname) == 0) break; } - if(a == attribs->totlayer && a < GPU_MAX_ATTRIB) { + if (a == attribs->totlayer && a < GPU_MAX_ATTRIB) { input->attribid = attribs->totlayer++; input->attribfirst = 1; @@ -1061,9 +1061,9 @@ static void gpu_nodes_get_builtin_flag(ListBase *nodes, int *builtin) *builtin= 0; - for(node=nodes->first; node; node=node->next) - for(input=node->inputs.first; input; input=input->next) - if(input->source == GPU_SOURCE_BUILTIN) + for (node=nodes->first; node; node=node->next) + for (input=node->inputs.first; input; input=input->next) + if (input->source == GPU_SOURCE_BUILTIN) *builtin |= input->builtin; } @@ -1163,7 +1163,7 @@ int GPU_link(GPUMaterial *mat, const char *name, ...) int i; function = GPU_lookup_function(name); - if(!function) { + if (!function) { fprintf(stderr, "GPU failed to find function %s\n", name); return 0; } @@ -1171,8 +1171,8 @@ int GPU_link(GPUMaterial *mat, const char *name, ...) node = GPU_node_begin(name); va_start(params, name); - for(i=0; i<function->totparam; i++) { - if(function->paramqual[i] != FUNCTION_QUAL_IN) { + for (i=0; i<function->totparam; i++) { + if (function->paramqual[i] != FUNCTION_QUAL_IN) { linkptr= va_arg(params, GPUNodeLink**); GPU_node_output(node, function->paramtype[i], "", linkptr); } @@ -1199,7 +1199,7 @@ int GPU_stack_link(GPUMaterial *mat, const char *name, GPUNodeStack *in, GPUNode int i, totin, totout; function = GPU_lookup_function(name); - if(!function) { + if (!function) { fprintf(stderr, "GPU failed to find function %s\n", name); return 0; } @@ -1208,24 +1208,24 @@ int GPU_stack_link(GPUMaterial *mat, const char *name, GPUNodeStack *in, GPUNode totin = 0; totout = 0; - if(in) { - for(i = 0; in[i].type != GPU_NONE; i++) { + if (in) { + for (i = 0; in[i].type != GPU_NONE; i++) { gpu_node_input_socket(node, &in[i]); totin++; } } - if(out) { - for(i = 0; out[i].type != GPU_NONE; i++) { + if (out) { + for (i = 0; out[i].type != GPU_NONE; i++) { GPU_node_output(node, out[i].type, out[i].name, &out[i].link); totout++; } } va_start(params, out); - for(i=0; i<function->totparam; i++) { - if(function->paramqual[i] != FUNCTION_QUAL_IN) { - if(totout == 0) { + for (i=0; i<function->totparam; i++) { + if (function->paramqual[i] != FUNCTION_QUAL_IN) { + if (totout == 0) { linkptr= va_arg(params, GPUNodeLink**); GPU_node_output(node, function->paramtype[i], "", linkptr); } @@ -1233,9 +1233,9 @@ int GPU_stack_link(GPUMaterial *mat, const char *name, GPUNodeStack *in, GPUNode totout--; } else { - if(totin == 0) { + if (totin == 0) { link= va_arg(params, GPUNodeLink*); - if(link->socket) + if (link->socket) gpu_node_input_socket(node, link->socket); else gpu_node_input_link(node, link, function->paramtype[i]); @@ -1259,11 +1259,11 @@ int GPU_link_changed(GPUNodeLink *link) GPUInput *input; const char *name; - if(link->output) { + if (link->output) { node = link->output->node; name = node->name; - if(strcmp(name, "set_value")==0 || strcmp(name, "set_rgb")==0) { + if (strcmp(name, "set_value")==0 || strcmp(name, "set_rgb")==0) { input = node->inputs.first; return (input->link != NULL); } @@ -1281,16 +1281,16 @@ static void gpu_nodes_tag(GPUNodeLink *link) GPUNode *node; GPUInput *input; - if(!link->output) + if (!link->output) return; node = link->output->node; - if(node->tag) + if (node->tag) return; node->tag= 1; - for(input=node->inputs.first; input; input=input->next) - if(input->link) + for (input=node->inputs.first; input; input=input->next) + if (input->link) gpu_nodes_tag(input->link); } @@ -1298,15 +1298,15 @@ static void gpu_nodes_prune(ListBase *nodes, GPUNodeLink *outlink) { GPUNode *node, *next; - for(node=nodes->first; node; node=node->next) + for (node=nodes->first; node; node=node->next) node->tag= 0; gpu_nodes_tag(outlink); - for(node=nodes->first; node; node=next) { + for (node=nodes->first; node; node=next) { next = node->next; - if(!node->tag) { + if (!node->tag) { BLI_remlink(nodes, node); GPU_node_free(node); } diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index a5d6c374a42..01f000e3314 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -154,28 +154,28 @@ void GPU_render_text(MTFace *tface, int mode, uv[2][1] = (tface->uv[2][1] - centery) * sizey + transy; glBegin(GL_POLYGON); - if(glattrib >= 0) glVertexAttrib2fvARB(glattrib, uv[0]); + if (glattrib >= 0) glVertexAttrib2fvARB(glattrib, uv[0]); else glTexCoord2fv(uv[0]); - if(col) gpu_mcol(col[0]); + if (col) gpu_mcol(col[0]); glVertex3f(sizex * v1[0] + movex, sizey * v1[1] + movey, v1[2]); - if(glattrib >= 0) glVertexAttrib2fvARB(glattrib, uv[1]); + if (glattrib >= 0) glVertexAttrib2fvARB(glattrib, uv[1]); else glTexCoord2fv(uv[1]); - if(col) gpu_mcol(col[1]); + if (col) gpu_mcol(col[1]); glVertex3f(sizex * v2[0] + movex, sizey * v2[1] + movey, v2[2]); - if(glattrib >= 0) glVertexAttrib2fvARB(glattrib, uv[2]); + if (glattrib >= 0) glVertexAttrib2fvARB(glattrib, uv[2]); else glTexCoord2fv(uv[2]); - if(col) gpu_mcol(col[2]); + if (col) gpu_mcol(col[2]); glVertex3f(sizex * v3[0] + movex, sizey * v3[1] + movey, v3[2]); - if(v4) { + if (v4) { uv[3][0] = (tface->uv[3][0] - centerx) * sizex + transx; uv[3][1] = (tface->uv[3][1] - centery) * sizey + transy; - if(glattrib >= 0) glVertexAttrib2fvARB(glattrib, uv[3]); + if (glattrib >= 0) glVertexAttrib2fvARB(glattrib, uv[3]); else glTexCoord2fv(uv[3]); - if(col) gpu_mcol(col[3]); + if (col) gpu_mcol(col[3]); glVertex3f(sizex * v4[0] + movex, sizey * v4[1] + movey, v4[2]); } glEnd(); @@ -263,16 +263,16 @@ static GLenum gpu_get_mipmap_filter(int mag) { /* linearmipmap is off by default *when mipmapping is off, * use unfiltered display */ - if(mag) { - if(GTS.linearmipmap || GTS.domipmap) + if (mag) { + if (GTS.linearmipmap || GTS.domipmap) return GL_LINEAR; else return GL_NEAREST; } else { - if(GTS.linearmipmap) + if (GTS.linearmipmap) return GL_LINEAR_MIPMAP_LINEAR; - else if(GTS.domipmap) + else if (GTS.domipmap) return GL_LINEAR_MIPMAP_NEAREST; else return GL_NEAREST; @@ -305,10 +305,10 @@ static void gpu_make_repbind(Image *ima) ImBuf *ibuf; ibuf = BKE_image_get_ibuf(ima, NULL); - if(ibuf==NULL) + if (ibuf==NULL) return; - if(ima->repbind) { + if (ima->repbind) { glDeleteTextures(ima->totbind, (GLuint *)ima->repbind); MEM_freeN(ima->repbind); ima->repbind= NULL; @@ -317,19 +317,19 @@ static void gpu_make_repbind(Image *ima) ima->totbind= ima->xrep*ima->yrep; - if(ima->totbind>1) + if (ima->totbind>1) ima->repbind= MEM_callocN(sizeof(int)*ima->totbind, "repbind"); } static void gpu_clear_tpage(void) { - if(GTS.lasttface==NULL) + if (GTS.lasttface==NULL) return; GTS.lasttface= NULL; GTS.curtile= 0; GTS.curima= NULL; - if(GTS.curtilemode!=0) { + if (GTS.curtilemode!=0) { glMatrixMode(GL_TEXTURE); glLoadIdentity(); glMatrixMode(GL_MODELVIEW); @@ -348,17 +348,17 @@ static void gpu_clear_tpage(void) static void gpu_set_alpha_blend(GPUBlendMode alphablend) { - if(alphablend == GPU_BLEND_SOLID) { + if (alphablend == GPU_BLEND_SOLID) { glDisable(GL_BLEND); glDisable(GL_ALPHA_TEST); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); } - else if(alphablend==GPU_BLEND_ADD) { + else if (alphablend==GPU_BLEND_ADD) { glEnable(GL_BLEND); glBlendFunc(GL_ONE, GL_ONE); glDisable(GL_ALPHA_TEST); } - else if(ELEM(alphablend, GPU_BLEND_ALPHA, GPU_BLEND_ALPHA_SORT)) { + else if (ELEM(alphablend, GPU_BLEND_ALPHA, GPU_BLEND_ALPHA_SORT)) { glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -366,7 +366,7 @@ static void gpu_set_alpha_blend(GPUBlendMode alphablend) * turn off alpha test in this case */ /* added after 2.45 to clip alpha */ - if(U.glalphaclip == 1.0f) { + if (U.glalphaclip == 1.0f) { glDisable(GL_ALPHA_TEST); } else { @@ -374,7 +374,7 @@ static void gpu_set_alpha_blend(GPUBlendMode alphablend) glAlphaFunc(GL_GREATER, U.glalphaclip); } } - else if(alphablend==GPU_BLEND_CLIP) { + else if (alphablend==GPU_BLEND_CLIP) { glDisable(GL_BLEND); glEnable(GL_ALPHA_TEST); glAlphaFunc(GL_GREATER, 0.5f); @@ -384,7 +384,7 @@ static void gpu_set_alpha_blend(GPUBlendMode alphablend) static void gpu_verify_alpha_blend(int alphablend) { /* verify alpha blending modes */ - if(GTS.alphablend == alphablend) + if (GTS.alphablend == alphablend) return; gpu_set_alpha_blend(alphablend); @@ -427,83 +427,83 @@ int GPU_verify_image(Image *ima, ImageUser *iuser, int tftile, int compare, int GTS.tileYRep = 0; /* setting current tile according to frame */ - if(ima && (ima->tpageflag & IMA_TWINANIM)) + if (ima && (ima->tpageflag & IMA_TWINANIM)) GTS.tile= ima->lastframe; else GTS.tile= tftile; GTS.tile = MAX2(0, GTS.tile); - if(ima) { + if (ima) { GTS.tileXRep = ima->xrep; GTS.tileYRep = ima->yrep; } /* if same image & tile, we're done */ - if(compare && ima == GTS.curima && GTS.curtile == GTS.tile && + if (compare && ima == GTS.curima && GTS.curtile == GTS.tile && GTS.tilemode == GTS.curtilemode && GTS.curtileXRep == GTS.tileXRep && GTS.curtileYRep == GTS.tileYRep) return (ima != NULL); /* if tiling mode or repeat changed, change texture matrix to fit */ - if(GTS.tilemode!=GTS.curtilemode || GTS.curtileXRep!=GTS.tileXRep || + if (GTS.tilemode!=GTS.curtilemode || GTS.curtileXRep!=GTS.tileXRep || GTS.curtileYRep != GTS.tileYRep) { glMatrixMode(GL_TEXTURE); glLoadIdentity(); - if(ima && (ima->tpageflag & IMA_TILES)) + if (ima && (ima->tpageflag & IMA_TILES)) glScalef(ima->xrep, ima->yrep, 1.0); glMatrixMode(GL_MODELVIEW); } /* check if we have a valid image */ - if(ima==NULL || ima->ok==0) + if (ima==NULL || ima->ok==0) return 0; /* check if we have a valid image buffer */ ibuf= BKE_image_get_ibuf(ima, iuser); - if(ibuf==NULL) + if (ibuf==NULL) return 0; - if(ibuf->rect_float) { - if(U.use_16bit_textures) { + if (ibuf->rect_float) { + if (U.use_16bit_textures) { /* use high precision textures. This is relatively harmless because OpenGL gives us * a high precision format only if it is available */ use_high_bit_depth = TRUE; } /* TODO unneeded when float images are correctly treated as linear always */ - if(ibuf->profile == IB_PROFILE_LINEAR_RGB) + if (ibuf->profile == IB_PROFILE_LINEAR_RGB) do_color_management = TRUE; - if(ibuf->rect==NULL) + if (ibuf->rect==NULL) IMB_rect_from_float(ibuf); } /* currently, tpage refresh is used by ima sequences */ - if(ima->tpageflag & IMA_TPAGE_REFRESH) { + if (ima->tpageflag & IMA_TPAGE_REFRESH) { GPU_free_image(ima); ima->tpageflag &= ~IMA_TPAGE_REFRESH; } - if(GTS.tilemode) { + if (GTS.tilemode) { /* tiled mode */ - if(ima->repbind==NULL) gpu_make_repbind(ima); - if(GTS.tile>=ima->totbind) GTS.tile= 0; + if (ima->repbind==NULL) gpu_make_repbind(ima); + if (GTS.tile>=ima->totbind) GTS.tile= 0; /* this happens when you change repeat buttons */ - if(ima->repbind) bind= &ima->repbind[GTS.tile]; + if (ima->repbind) bind= &ima->repbind[GTS.tile]; else bind= &ima->bindcode; - if(*bind==0) { + if (*bind==0) { texwindx= ibuf->x/ima->xrep; texwindy= ibuf->y/ima->yrep; - if(GTS.tile>=ima->xrep*ima->yrep) + if (GTS.tile>=ima->xrep*ima->yrep) GTS.tile= ima->xrep*ima->yrep-1; texwinsy= GTS.tile / ima->xrep; @@ -515,8 +515,8 @@ int GPU_verify_image(Image *ima, ImageUser *iuser, int tftile, int compare, int tpx= texwindx; tpy= texwindy; - if(use_high_bit_depth) { - if(do_color_management) { + if (use_high_bit_depth) { + if (do_color_management) { srgb_frect = MEM_mallocN(ibuf->x*ibuf->y*sizeof(float)*4, "floar_buf_col_cor"); IMB_buffer_float_from_float(srgb_frect, ibuf->rect_float, ibuf->channels, IB_PROFILE_SRGB, ibuf->profile, 0, @@ -536,12 +536,12 @@ int GPU_verify_image(Image *ima, ImageUser *iuser, int tftile, int compare, int /* regular image mode */ bind= &ima->bindcode; - if(*bind==0) { + if (*bind==0) { tpx= ibuf->x; tpy= ibuf->y; rect= ibuf->rect; - if(use_high_bit_depth) { - if(do_color_management) { + if (use_high_bit_depth) { + if (do_color_management) { frect = srgb_frect = MEM_mallocN(ibuf->x*ibuf->y*sizeof(*srgb_frect)*4, "floar_buf_col_cor"); IMB_buffer_float_from_float(srgb_frect, ibuf->rect_float, ibuf->channels, IB_PROFILE_SRGB, ibuf->profile, 0, @@ -555,7 +555,7 @@ int GPU_verify_image(Image *ima, ImageUser *iuser, int tftile, int compare, int } } - if(*bind != 0) { + if (*bind != 0) { /* enable opengl drawing with textures */ glBindTexture(GL_TEXTURE_2D, *bind); return *bind; @@ -566,7 +566,7 @@ int GPU_verify_image(Image *ima, ImageUser *iuser, int tftile, int compare, int /* for tiles, copy only part of image into buffer */ if (GTS.tilemode) { - if(use_high_bit_depth) { + if (use_high_bit_depth) { float *frectrow, *ftilerectrow; ftilerect= MEM_mallocN(rectw*recth*sizeof(*ftilerect), "tilerect"); @@ -602,7 +602,7 @@ int GPU_verify_image(Image *ima, ImageUser *iuser, int tftile, int compare, int rectw= smaller_pow2_limit(rectw); recth= smaller_pow2_limit(recth); - if(use_high_bit_depth) { + if (use_high_bit_depth) { fscalerect= MEM_mallocN(rectw*recth*sizeof(*fscalerect)*4, "fscalerect"); gluScaleImage(GL_RGBA, tpx, tpy, GL_FLOAT, frect, rectw, recth, GL_FLOAT, fscalerect); @@ -621,7 +621,7 @@ int GPU_verify_image(Image *ima, ImageUser *iuser, int tftile, int compare, int glBindTexture( GL_TEXTURE_2D, *bind); if (!(gpu_get_mipmap() && mipmap)) { - if(use_high_bit_depth) + if (use_high_bit_depth) glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16, rectw, recth, 0, GL_RGBA, GL_FLOAT, frect); else glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, rectw, recth, 0, GL_RGBA, GL_UNSIGNED_BYTE, rect); @@ -629,7 +629,7 @@ int GPU_verify_image(Image *ima, ImageUser *iuser, int tftile, int compare, int glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gpu_get_mipmap_filter(1)); } else { - if(use_high_bit_depth) + if (use_high_bit_depth) gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA16, rectw, recth, GL_RGBA, GL_FLOAT, frect); else gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, rectw, recth, GL_RGBA, GL_UNSIGNED_BYTE, rect); @@ -677,7 +677,7 @@ int GPU_set_tpage(MTFace *tface, int mipmap, int alphablend) Image *ima; /* check if we need to clear the state */ - if(tface==NULL) { + if (tface==NULL) { gpu_clear_tpage(); return 0; } @@ -688,7 +688,7 @@ int GPU_set_tpage(MTFace *tface, int mipmap, int alphablend) gpu_verify_alpha_blend(alphablend); gpu_verify_reflection(ima); - if(GPU_verify_image(ima, NULL, tface->tile, 1, mipmap)) { + if (GPU_verify_image(ima, NULL, tface->tile, 1, mipmap)) { GTS.curtile= GTS.tile; GTS.curima= GTS.ima; GTS.curtilemode= GTS.tilemode; @@ -725,13 +725,13 @@ void GPU_paint_set_mipmap(int mipmap) { Image* ima; - if(!GTS.domipmap) + if (!GTS.domipmap) return; - if(mipmap) { - for(ima=G.main->image.first; ima; ima=ima->id.next) { - if(ima->bindcode) { - if(ima->tpageflag & IMA_MIPMAP_COMPLETE) { + if (mipmap) { + for (ima=G.main->image.first; ima; ima=ima->id.next) { + if (ima->bindcode) { + if (ima->tpageflag & IMA_MIPMAP_COMPLETE) { glBindTexture(GL_TEXTURE_2D, ima->bindcode); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gpu_get_mipmap_filter(0)); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gpu_get_mipmap_filter(1)); @@ -745,8 +745,8 @@ void GPU_paint_set_mipmap(int mipmap) } else { - for(ima=G.main->image.first; ima; ima=ima->id.next) { - if(ima->bindcode) { + for (ima=G.main->image.first; ima; ima=ima->id.next) { + if (ima->bindcode) { glBindTexture(GL_TEXTURE_2D, ima->bindcode); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gpu_get_mipmap_filter(1)); @@ -779,7 +779,7 @@ void GPU_paint_update_image(Image *ima, int x, int y, int w, int h, int mipmap) glGetIntegerv(GL_UNPACK_SKIP_ROWS, &skip_rows); /* if color correction is needed, we must update the part that needs updating. */ - if(ibuf->rect_float && (!U.use_16bit_textures || (ibuf->profile == IB_PROFILE_LINEAR_RGB))) { + if (ibuf->rect_float && (!U.use_16bit_textures || (ibuf->profile == IB_PROFILE_LINEAR_RGB))) { float *buffer = MEM_mallocN(w*h*sizeof(float)*4, "temp_texpaint_float_buf"); IMB_partial_rect_from_float(ibuf, buffer, x, y, w, h); @@ -789,7 +789,7 @@ void GPU_paint_update_image(Image *ima, int x, int y, int w, int h, int mipmap) MEM_freeN(buffer); - if(ima->tpageflag & IMA_MIPMAP_COMPLETE) + if (ima->tpageflag & IMA_MIPMAP_COMPLETE) ima->tpageflag &= ~IMA_MIPMAP_COMPLETE; return; @@ -801,7 +801,7 @@ void GPU_paint_update_image(Image *ima, int x, int y, int w, int h, int mipmap) glPixelStorei(GL_UNPACK_SKIP_PIXELS, x); glPixelStorei(GL_UNPACK_SKIP_ROWS, y); - if(ibuf->rect_float) + if (ibuf->rect_float) glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, w, h, GL_RGBA, GL_FLOAT, ibuf->rect_float); else @@ -812,7 +812,7 @@ void GPU_paint_update_image(Image *ima, int x, int y, int w, int h, int mipmap) glPixelStorei(GL_UNPACK_SKIP_PIXELS, skip_pixels); glPixelStorei(GL_UNPACK_SKIP_ROWS, skip_rows); - if(ima->tpageflag & IMA_MIPMAP_COMPLETE) + if (ima->tpageflag & IMA_MIPMAP_COMPLETE) ima->tpageflag &= ~IMA_MIPMAP_COMPLETE; } } @@ -821,15 +821,15 @@ void GPU_update_images_framechange(void) { Image *ima; - for(ima=G.main->image.first; ima; ima=ima->id.next) { - if(ima->tpageflag & IMA_TWINANIM) { - if(ima->twend >= ima->xrep*ima->yrep) + for (ima=G.main->image.first; ima; ima=ima->id.next) { + if (ima->tpageflag & IMA_TWINANIM) { + if (ima->twend >= ima->xrep*ima->yrep) ima->twend= ima->xrep*ima->yrep-1; /* check: is bindcode not in the array? free. (to do) */ ima->lastframe++; - if(ima->lastframe > ima->twend) + if (ima->lastframe > ima->twend) ima->lastframe= ima->twsta; } } @@ -850,8 +850,8 @@ int GPU_update_image_time(Image *ima, double time) if (ima->lastupdate > (float)time) ima->lastupdate=(float)time; - if(ima->tpageflag & IMA_TWINANIM) { - if(ima->twend >= ima->xrep*ima->yrep) ima->twend= ima->xrep*ima->yrep-1; + if (ima->tpageflag & IMA_TWINANIM) { + if (ima->twend >= ima->xrep*ima->yrep) ima->twend= ima->xrep*ima->yrep-1; /* check: is the bindcode not in the array? Then free. (still to do) */ @@ -862,8 +862,8 @@ int GPU_update_image_time(Image *ima, double time) newframe = ima->lastframe+inc; - if(newframe > (int)ima->twend) { - if(ima->twend-ima->twsta != 0) + if (newframe > (int)ima->twend) { + if (ima->twend-ima->twsta != 0) newframe = (int)ima->twsta-1 + (newframe-ima->twend)%(ima->twend-ima->twsta); else newframe = ima->twsta; @@ -878,12 +878,12 @@ int GPU_update_image_time(Image *ima, double time) void GPU_free_smoke(SmokeModifierData *smd) { - if(smd->type & MOD_SMOKE_TYPE_DOMAIN && smd->domain) { - if(smd->domain->tex) + if (smd->type & MOD_SMOKE_TYPE_DOMAIN && smd->domain) { + if (smd->domain->tex) GPU_texture_free(smd->domain->tex); smd->domain->tex = NULL; - if(smd->domain->tex_shadow) + if (smd->domain->tex_shadow) GPU_texture_free(smd->domain->tex_shadow); smd->domain->tex_shadow = NULL; } @@ -892,9 +892,9 @@ void GPU_free_smoke(SmokeModifierData *smd) void GPU_create_smoke(SmokeModifierData *smd, int highres) { #ifdef WITH_SMOKE - if(smd->type & MOD_SMOKE_TYPE_DOMAIN && !smd->domain->tex && !highres) + if (smd->type & MOD_SMOKE_TYPE_DOMAIN && !smd->domain->tex && !highres) smd->domain->tex = GPU_texture_create_3D(smd->domain->res[0], smd->domain->res[1], smd->domain->res[2], smoke_get_density(smd->domain->fluid)); - else if(smd->type & MOD_SMOKE_TYPE_DOMAIN && !smd->domain->tex && highres) + else if (smd->type & MOD_SMOKE_TYPE_DOMAIN && !smd->domain->tex && highres) smd->domain->tex = GPU_texture_create_3D(smd->domain->res_wt[0], smd->domain->res_wt[1], smd->domain->res_wt[2], smoke_turbulence_get_density(smd->domain->wt)); smd->domain->tex_shadow = GPU_texture_create_3D(smd->domain->res[0], smd->domain->res[1], smd->domain->res[2], smd->domain->shadow); @@ -920,13 +920,13 @@ void GPU_free_unused_buffers(void) { Image *ima; - if(!BLI_thread_is_main()) + if (!BLI_thread_is_main()) return; BLI_lock_thread(LOCK_OPENGL); /* images */ - for(ima=image_free_queue.first; ima; ima=ima->id.next) + for (ima=image_free_queue.first; ima; ima=ima->id.next) GPU_free_image(ima); BLI_freelistN(&image_free_queue); @@ -940,25 +940,25 @@ void GPU_free_unused_buffers(void) void GPU_free_image(Image *ima) { - if(!BLI_thread_is_main()) { + if (!BLI_thread_is_main()) { gpu_queue_image_for_free(ima); return; } /* free regular image binding */ - if(ima->bindcode) { + if (ima->bindcode) { glDeleteTextures(1, (GLuint *)&ima->bindcode); ima->bindcode= 0; } /* free glsl image binding */ - if(ima->gputexture) { + if (ima->gputexture) { GPU_texture_free(ima->gputexture); ima->gputexture= NULL; } /* free repeated image binding */ - if(ima->repbind) { + if (ima->repbind) { glDeleteTextures(ima->totbind, (GLuint *)ima->repbind); MEM_freeN(ima->repbind); @@ -972,8 +972,8 @@ void GPU_free_images(void) { Image* ima; - if(G.main) - for(ima=G.main->image.first; ima; ima=ima->id.next) + if (G.main) + for (ima=G.main->image.first; ima; ima=ima->id.next) GPU_free_image(ima); } @@ -982,9 +982,9 @@ void GPU_free_images_anim(void) { Image* ima; - if(G.main) - for(ima=G.main->image.first; ima; ima=ima->id.next) - if(ELEM(ima->source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE)) + if (G.main) + for (ima=G.main->image.first; ima; ima=ima->id.next) + if (ELEM(ima->source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE)) GPU_free_image(ima); } @@ -1025,11 +1025,11 @@ static struct GPUMaterialState { /* fixed function material, alpha handed by caller */ static void gpu_material_to_fixed(GPUMaterialFixed *smat, const Material *bmat, const int gamma, const Object *ob, const int new_shading_nodes) { - if(new_shading_nodes || bmat->mode & MA_SHLESS) { + if (new_shading_nodes || bmat->mode & MA_SHLESS) { copy_v3_v3(smat->diff, &bmat->r); smat->diff[3]= 1.0; - if(gamma) + if (gamma) linearrgb_to_srgb_v3_v3(smat->diff, smat->diff); zero_v4(smat->spec); @@ -1039,14 +1039,14 @@ static void gpu_material_to_fixed(GPUMaterialFixed *smat, const Material *bmat, mul_v3_v3fl(smat->diff, &bmat->r, bmat->ref + bmat->emit); smat->diff[3]= 1.0; /* caller may set this to bmat->alpha */ - if(bmat->shade_flag & MA_OBCOLOR) + if (bmat->shade_flag & MA_OBCOLOR) mul_v3_v3(smat->diff, ob->col); mul_v3_v3fl(smat->spec, &bmat->specr, bmat->spec); smat->spec[3]= 1.0; /* always 1 */ smat->hard= CLAMPIS(bmat->har, 0, 128); - if(gamma) { + if (gamma) { linearrgb_to_srgb_v3_v3(smat->diff, smat->diff); linearrgb_to_srgb_v3_v3(smat->spec, smat->spec); } @@ -1055,10 +1055,10 @@ static void gpu_material_to_fixed(GPUMaterialFixed *smat, const Material *bmat, static Material *gpu_active_node_material(Material *ma) { - if(ma && ma->use_nodes && ma->nodetree) { + if (ma && ma->use_nodes && ma->nodetree) { bNode *node= nodeGetActiveID(ma->nodetree, ID_MA); - if(node) + if (node) return (Material *)node->id; else return NULL; @@ -1096,10 +1096,10 @@ void GPU_begin_object_materials(View3D *v3d, RegionView3D *rv3d, Scene *scene, O * for solid we don't use transparency at all. */ GMS.use_alpha_pass = (do_alpha_after != NULL); GMS.is_alpha_pass = (v3d && v3d->transp); - if(GMS.use_alpha_pass) + if (GMS.use_alpha_pass) *do_alpha_after = 0; - if(GMS.totmat > FIXEDMAT) { + if (GMS.totmat > FIXEDMAT) { GMS.matbuf= MEM_callocN(sizeof(GPUMaterialFixed)*GMS.totmat, "GMS.matbuf"); GMS.gmatbuf= MEM_callocN(sizeof(*GMS.gmatbuf)*GMS.totmat, "GMS.matbuf"); GMS.alphablend= MEM_callocN(sizeof(*GMS.alphablend)*GMS.totmat, "GMS.matbuf"); @@ -1111,13 +1111,13 @@ void GPU_begin_object_materials(View3D *v3d, RegionView3D *rv3d, Scene *scene, O } /* no materials assigned? */ - if(ob->totcol==0) { + if (ob->totcol==0) { gpu_material_to_fixed(&GMS.matbuf[0], &defmaterial, 0, ob, new_shading_nodes); /* do material 1 too, for displists! */ memcpy(&GMS.matbuf[1], &GMS.matbuf[0], sizeof(GPUMaterialFixed)); - if(glsl) { + if (glsl) { GMS.gmatbuf[0]= &defmaterial; GPU_material_from_blender(GMS.gscene, &defmaterial); } @@ -1126,16 +1126,16 @@ void GPU_begin_object_materials(View3D *v3d, RegionView3D *rv3d, Scene *scene, O } /* setup materials */ - for(a=1; a<=ob->totcol; a++) { + for (a=1; a<=ob->totcol; a++) { /* find a suitable material */ ma= give_current_material(ob, a); - if(!glsl && !new_shading_nodes) ma= gpu_active_node_material(ma); - if(ma==NULL) ma= &defmaterial; + if (!glsl && !new_shading_nodes) ma= gpu_active_node_material(ma); + if (ma==NULL) ma= &defmaterial; /* create glsl material if requested */ gpumat = (glsl)? GPU_material_from_blender(GMS.gscene, ma): NULL; - if(gpumat) { + if (gpumat) { /* do glsl only if creating it succeed, else fallback */ GMS.gmatbuf[a]= ma; alphablend = GPU_material_alpha_blend(gpumat, ob->col); @@ -1144,7 +1144,7 @@ void GPU_begin_object_materials(View3D *v3d, RegionView3D *rv3d, Scene *scene, O /* fixed function opengl materials */ gpu_material_to_fixed(&GMS.matbuf[a], ma, gamma, ob, new_shading_nodes); - if(GMS.use_alpha_pass) { + if (GMS.use_alpha_pass) { GMS.matbuf[a].diff[3]= ma->alpha; alphablend = (ma->alpha == 1.0f)? GPU_BLEND_SOLID: GPU_BLEND_ALPHA; } @@ -1156,8 +1156,8 @@ void GPU_begin_object_materials(View3D *v3d, RegionView3D *rv3d, Scene *scene, O /* setting do_alpha_after = 1 indicates this object needs to be * drawn in a second alpha pass for improved blending */ - if(do_alpha_after && !GMS.is_alpha_pass) - if(ELEM3(alphablend, GPU_BLEND_ALPHA, GPU_BLEND_ADD, GPU_BLEND_ALPHA_SORT)) + if (do_alpha_after && !GMS.is_alpha_pass) + if (ELEM3(alphablend, GPU_BLEND_ALPHA, GPU_BLEND_ADD, GPU_BLEND_ALPHA_SORT)) *do_alpha_after= 1; GMS.alphablend[a]= alphablend; @@ -1174,7 +1174,7 @@ int GPU_enable_material(int nr, void *attribs) GPUBlendMode alphablend; /* no GPU_begin_object_materials, use default material */ - if(!GMS.matbuf) { + if (!GMS.matbuf) { float diff[4], spec[4]; memset(&GMS, 0, sizeof(GMS)); @@ -1193,19 +1193,19 @@ int GPU_enable_material(int nr, void *attribs) } /* prevent index to use un-initialized array items */ - if(nr>=GMS.totmat) + if (nr>=GMS.totmat) nr= 0; - if(gattribs) + if (gattribs) memset(gattribs, 0, sizeof(*gattribs)); /* keep current material */ - if(nr==GMS.lastmatnr) + if (nr==GMS.lastmatnr) return GMS.lastretval; /* unbind glsl material */ - if(GMS.gboundmat) { - if(GMS.is_alpha_pass) glDepthMask(0); + if (GMS.gboundmat) { + if (GMS.is_alpha_pass) glDepthMask(0); GPU_material_unbind(GPU_material_from_blender(GMS.gscene, GMS.gboundmat)); GMS.gboundmat= NULL; } @@ -1214,19 +1214,19 @@ int GPU_enable_material(int nr, void *attribs) GMS.lastmatnr = nr; GMS.lastretval = 1; - if(GMS.use_alpha_pass) { + if (GMS.use_alpha_pass) { GMS.lastretval = ELEM(GMS.alphablend[nr], GPU_BLEND_SOLID, GPU_BLEND_CLIP); - if(GMS.is_alpha_pass) + if (GMS.is_alpha_pass) GMS.lastretval = !GMS.lastretval; } else GMS.lastretval = !GMS.is_alpha_pass; - if(GMS.lastretval) { + if (GMS.lastretval) { /* for alpha pass, use alpha blend */ alphablend = GMS.alphablend[nr]; - if(gattribs && GMS.gmatbuf[nr]) { + if (gattribs && GMS.gmatbuf[nr]) { /* bind glsl material and get attributes */ Material *mat = GMS.gmatbuf[nr]; float auto_bump_scale; @@ -1241,10 +1241,10 @@ int GPU_enable_material(int nr, void *attribs) /* for glsl use alpha blend mode, unless it's set to solid and * we are already drawing in an alpha pass */ - if(mat->game.alpha_blend != GPU_BLEND_SOLID) + if (mat->game.alpha_blend != GPU_BLEND_SOLID) alphablend= mat->game.alpha_blend; - if(GMS.is_alpha_pass) glDepthMask(1); + if (GMS.is_alpha_pass) glDepthMask(1); } else { /* or do fixed function opengl material */ @@ -1262,7 +1262,7 @@ int GPU_enable_material(int nr, void *attribs) void GPU_set_material_alpha_blend(int alphablend) { - if(GMS.lastalphablend == alphablend) + if (GMS.lastalphablend == alphablend) return; gpu_set_alpha_blend(alphablend); @@ -1279,8 +1279,8 @@ void GPU_disable_material(void) GMS.lastmatnr= -1; GMS.lastretval= 1; - if(GMS.gboundmat) { - if(GMS.is_alpha_pass) glDepthMask(0); + if (GMS.gboundmat) { + if (GMS.is_alpha_pass) glDepthMask(0); GPU_material_unbind(GPU_material_from_blender(GMS.gscene, GMS.gboundmat)); GMS.gboundmat= NULL; } @@ -1292,7 +1292,7 @@ void GPU_end_object_materials(void) { GPU_disable_material(); - if(GMS.matbuf && GMS.matbuf != GMS.matbuf_fixed) { + if (GMS.matbuf && GMS.matbuf != GMS.matbuf_fixed) { MEM_freeN(GMS.matbuf); MEM_freeN(GMS.gmatbuf); MEM_freeN(GMS.alphablend); @@ -1303,7 +1303,7 @@ void GPU_end_object_materials(void) GMS.alphablend= NULL; /* resetting the texture matrix after the glScale needed for tiled textures */ - if(GTS.tilemode) { + if (GTS.tilemode) { glMatrixMode(GL_TEXTURE); glLoadIdentity(); glMatrixMode(GL_MODELVIEW); @@ -1318,7 +1318,7 @@ int GPU_default_lights(void) int a, count = 0; /* initialize */ - if(U.light[0].flag==0 && U.light[1].flag==0 && U.light[2].flag==0) { + if (U.light[0].flag==0 && U.light[1].flag==0 && U.light[2].flag==0) { U.light[0].flag= 1; U.light[0].vec[0]= -0.3; U.light[0].vec[1]= 0.3; U.light[0].vec[2]= 0.9; U.light[0].col[0]= 0.8; U.light[0].col[1]= 0.8; U.light[0].col[2]= 0.8; @@ -1340,9 +1340,9 @@ int GPU_default_lights(void) glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_FALSE); - for(a=0; a<8; a++) { - if(a<3) { - if(U.light[a].flag) { + for (a=0; a<8; a++) { + if (a<3) { + if (U.light[a].flag) { glEnable(GL_LIGHT0+a); normalize_v3_v3(position, U.light[a].vec); @@ -1386,7 +1386,7 @@ int GPU_scene_object_lights(Scene *scene, Object *ob, int lay, float viewmat[][4 float position[4], direction[4], energy[4]; /* disable all lights */ - for(count=0; count<8; count++) + for (count=0; count<8; count++) glDisable(GL_LIGHT0+count); /* view direction for specular is not compute correct by default in @@ -1395,11 +1395,11 @@ int GPU_scene_object_lights(Scene *scene, Object *ob, int lay, float viewmat[][4 count= 0; - for(base=scene->base.first; base; base=base->next) { - if(base->object->type!=OB_LAMP) + for (base=scene->base.first; base; base=base->next) { + if (base->object->type!=OB_LAMP) continue; - if(!(base->lay & lay) || !(base->lay & ob->lay)) + if (!(base->lay & lay) || !(base->lay & ob->lay)) continue; la= base->object->data; @@ -1410,7 +1410,7 @@ int GPU_scene_object_lights(Scene *scene, Object *ob, int lay, float viewmat[][4 where_is_object_simul(scene, base->object); - if(la->type==LA_SUN) { + if (la->type==LA_SUN) { /* sun lamp */ copy_v3_v3(direction, base->object->obmat[2]); direction[3]= 0.0; @@ -1427,7 +1427,7 @@ int GPU_scene_object_lights(Scene *scene, Object *ob, int lay, float viewmat[][4 glLightf(GL_LIGHT0+count, GL_LINEAR_ATTENUATION, la->att1/la->dist); glLightf(GL_LIGHT0+count, GL_QUADRATIC_ATTENUATION, la->att2/(la->dist*la->dist)); - if(la->type==LA_SPOT) { + if (la->type==LA_SPOT) { /* spot lamp */ negate_v3_v3(direction, base->object->obmat[2]); glLightfv(GL_LIGHT0+count, GL_SPOT_DIRECTION, direction); @@ -1449,7 +1449,7 @@ int GPU_scene_object_lights(Scene *scene, Object *ob, int lay, float viewmat[][4 glPopMatrix(); count++; - if(count==8) + if (count==8) break; } @@ -1511,9 +1511,9 @@ void GPU_state_init(void) glDepthRange(0.0, 1.0); a= 0; - for(x=0; x<32; x++) { - for(y=0; y<4; y++) { - if( (x) & 1) pat[a++]= 0x88; + for (x=0; x<32; x++) { + for (y=0; y<4; y++) { + if ( (x) & 1) pat[a++]= 0x88; else pat[a++]= 0x22; } } @@ -1543,7 +1543,7 @@ static void gpu_get_print(const char *name, GLenum type) glGetFloatv(type, value); printf("%s: ", name); - for(a=0; a<16; a++) + for (a=0; a<16; a++) printf("%.2f ", value[a]); printf("\n"); } diff --git a/source/blender/gpu/intern/gpu_extensions.c b/source/blender/gpu/intern/gpu_extensions.c index e1d6f64f661..846ee2850be 100644 --- a/source/blender/gpu/intern/gpu_extensions.c +++ b/source/blender/gpu/intern/gpu_extensions.c @@ -99,7 +99,7 @@ void GPU_extensions_init(void) const char *vendor, *renderer; /* can't avoid calling this multiple times, see wm_window_add_ghostwindow */ - if(gpu_extensions_init) return; + if (gpu_extensions_init) return; gpu_extensions_init= 1; glewInit(); @@ -123,38 +123,38 @@ void GPU_extensions_init(void) vendor = (const char*)glGetString(GL_VENDOR); renderer = (const char*)glGetString(GL_RENDERER); - if(strstr(vendor, "ATI")) { + if (strstr(vendor, "ATI")) { GG.device = GPU_DEVICE_ATI; GG.driver = GPU_DRIVER_OFFICIAL; } - else if(strstr(vendor, "NVIDIA")) { + else if (strstr(vendor, "NVIDIA")) { GG.device = GPU_DEVICE_NVIDIA; GG.driver = GPU_DRIVER_OFFICIAL; } - else if(strstr(vendor, "Intel") || + else if (strstr(vendor, "Intel") || /* src/mesa/drivers/dri/intel/intel_context.c */ strstr(renderer, "Mesa DRI Intel") || strstr(renderer, "Mesa DRI Mobile Intel")) { GG.device = GPU_DEVICE_INTEL; GG.driver = GPU_DRIVER_OFFICIAL; } - else if(strstr(renderer, "Mesa DRI R") || (strstr(renderer, "Gallium ") && strstr(renderer, " on ATI "))) { + else if (strstr(renderer, "Mesa DRI R") || (strstr(renderer, "Gallium ") && strstr(renderer, " on ATI "))) { GG.device = GPU_DEVICE_ATI; GG.driver = GPU_DRIVER_OPENSOURCE; } - else if(strstr(renderer, "Nouveau") || strstr(vendor, "nouveau")) { + else if (strstr(renderer, "Nouveau") || strstr(vendor, "nouveau")) { GG.device = GPU_DEVICE_NVIDIA; GG.driver = GPU_DRIVER_OPENSOURCE; } - else if(strstr(vendor, "Mesa")) { + else if (strstr(vendor, "Mesa")) { GG.device = GPU_DEVICE_SOFTWARE; GG.driver = GPU_DRIVER_SOFTWARE; } - else if(strstr(vendor, "Microsoft")) { + else if (strstr(vendor, "Microsoft")) { GG.device = GPU_DEVICE_SOFTWARE; GG.driver = GPU_DRIVER_SOFTWARE; } - else if(strstr(renderer, "Apple Software Renderer")) { + else if (strstr(renderer, "Apple Software Renderer")) { GG.device = GPU_DEVICE_SOFTWARE; GG.driver = GPU_DRIVER_SOFTWARE; } @@ -163,12 +163,12 @@ void GPU_extensions_init(void) GG.driver = GPU_DRIVER_ANY; } - if(GG.device == GPU_DEVICE_ATI) { + if (GG.device == GPU_DEVICE_ATI) { /* ATI 9500 to X2300 cards support NPoT textures poorly * Incomplete list http://dri.freedesktop.org/wiki/ATIRadeon * New IDs from MESA's src/gallium/drivers/r300/r300_screen.c */ - if(strstr(renderer, "R3") || strstr(renderer, "RV3") || + if (strstr(renderer, "R3") || strstr(renderer, "RV3") || strstr(renderer, "R4") || strstr(renderer, "RV4") || strstr(renderer, "RS4") || strstr(renderer, "RC4") || strstr(renderer, "R5") || strstr(renderer, "RV5") || @@ -205,7 +205,7 @@ int GPU_glsl_support(void) int GPU_non_power_of_two_support(void) { - if(GG.npotdisabled) + if (GG.npotdisabled) return 0; return GLEW_ARB_texture_non_power_of_two; @@ -260,7 +260,7 @@ static void GPU_print_framebuffer_error(GLenum status, char err_out[256]) break; } - if(err_out) { + if (err_out) { BLI_snprintf(err_out, 256, "GPUFrameBuffer: framebuffer incomplete error %d '%s'", (int)status, err); } @@ -318,7 +318,7 @@ static GPUTexture *GPU_texture_create_nD(int w, int h, int n, float *fpixels, in GLenum type, format, internalformat; void *pixels = NULL; - if(depth && !GLEW_ARB_depth_texture) + if (depth && !GLEW_ARB_depth_texture) return NULL; tex = MEM_callocN(sizeof(GPUTexture), "GPUTexture"); @@ -332,7 +332,7 @@ static GPUTexture *GPU_texture_create_nD(int w, int h, int n, float *fpixels, in glGenTextures(1, &tex->bindcode); if (!tex->bindcode) { - if(err_out) { + if (err_out) { BLI_snprintf(err_out, 256, "GPUTexture: texture create failed: %d", (int)glGetError()); } @@ -352,7 +352,7 @@ static GPUTexture *GPU_texture_create_nD(int w, int h, int n, float *fpixels, in tex->number = 0; glBindTexture(tex->target, tex->bindcode); - if(depth) { + if (depth) { type = GL_UNSIGNED_BYTE; format = GL_DEPTH_COMPONENT; internalformat = GL_DEPTH_COMPONENT; @@ -396,7 +396,7 @@ static GPUTexture *GPU_texture_create_nD(int w, int h, int n, float *fpixels, in if (pixels) MEM_freeN(pixels); - if(depth) { + if (depth) { glTexParameteri(tex->target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(tex->target, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(tex->target, GL_TEXTURE_COMPARE_MODE_ARB, GL_COMPARE_R_TO_TEXTURE); @@ -433,7 +433,7 @@ GPUTexture *GPU_texture_create_3D(int w, int h, int depth, float *fpixels) void *pixels = NULL; float vfBorderColor[4] = {0.0f, 0.0f, 0.0f, 0.0f}; - if(!GLEW_VERSION_1_2) + if (!GLEW_VERSION_1_2) return NULL; tex = MEM_callocN(sizeof(GPUTexture), "GPUTexture"); @@ -476,7 +476,7 @@ GPUTexture *GPU_texture_create_3D(int w, int h, int depth, float *fpixels) GPU_print_error("3D glTexImage3D"); if (fpixels) { - if(!GPU_non_power_of_two_support() && (w != tex->w || h != tex->h || depth != tex->depth)) { + if (!GPU_non_power_of_two_support() && (w != tex->w || h != tex->h || depth != tex->depth)) { /* clear first to avoid unitialized pixels */ float *zero= MEM_callocN(sizeof(float)*tex->w*tex->h*tex->depth, "zero"); glTexSubImage3D(tex->target, 0, 0, 0, 0, tex->w, tex->h, tex->depth, format, type, zero); @@ -516,13 +516,13 @@ GPUTexture *GPU_texture_from_blender(Image *ima, ImageUser *iuser, double time, GPU_update_image_time(ima, time); bindcode = GPU_verify_image(ima, iuser, 0, 0, mipmap); - if(ima->gputexture) { + if (ima->gputexture) { ima->gputexture->bindcode = bindcode; glBindTexture(GL_TEXTURE_2D, lastbindcode); return ima->gputexture; } - if(!bindcode) { + if (!bindcode) { glBindTexture(GL_TEXTURE_2D, lastbindcode); return NULL; } @@ -593,7 +593,7 @@ void GPU_texture_bind(GPUTexture *tex, int number) return; } - if(number == -1) + if (number == -1) return; GPU_print_error("Pre Texture Bind"); @@ -618,7 +618,7 @@ void GPU_texture_unbind(GPUTexture *tex) return; } - if(tex->number == -1) + if (tex->number == -1) return; GPU_print_error("Pre Texture Unbind"); @@ -714,7 +714,7 @@ int GPU_framebuffer_texture_attach(GPUFrameBuffer *fb, GPUTexture *tex, char err GLenum status; GLenum attachment; - if(tex->depth) + if (tex->depth) attachment = GL_DEPTH_ATTACHMENT_EXT; else attachment = GL_COLOR_ATTACHMENT0_EXT; @@ -725,7 +725,7 @@ int GPU_framebuffer_texture_attach(GPUFrameBuffer *fb, GPUTexture *tex, char err glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, attachment, tex->target, tex->bindcode, 0); - if(tex->depth) { + if (tex->depth) { glDrawBuffer(GL_NONE); glReadBuffer(GL_NONE); } @@ -742,7 +742,7 @@ int GPU_framebuffer_texture_attach(GPUFrameBuffer *fb, GPUTexture *tex, char err return 0; } - if(tex->depth) + if (tex->depth) fb->depthtex = tex; else fb->colortex = tex; @@ -756,15 +756,15 @@ void GPU_framebuffer_texture_detach(GPUFrameBuffer *fb, GPUTexture *tex) { GLenum attachment; - if(!tex->fb) + if (!tex->fb) return; - if(GG.currentfb != tex->fb->object) { + if (GG.currentfb != tex->fb->object) { glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, tex->fb->object); GG.currentfb = tex->fb->object; } - if(tex->depth) { + if (tex->depth) { fb->depthtex = NULL; attachment = GL_DEPTH_ATTACHMENT_EXT; } @@ -817,12 +817,12 @@ void GPU_framebuffer_texture_unbind(GPUFrameBuffer *UNUSED(fb), GPUTexture *UNUS void GPU_framebuffer_free(GPUFrameBuffer *fb) { - if(fb->depthtex) + if (fb->depthtex) GPU_framebuffer_texture_detach(fb, fb->depthtex); - if(fb->colortex) + if (fb->colortex) GPU_framebuffer_texture_detach(fb, fb->colortex); - if(fb->object) { + if (fb->object) { glDeleteFramebuffersEXT(1, &fb->object); if (GG.currentfb == fb->object) { @@ -863,29 +863,29 @@ GPUOffScreen *GPU_offscreen_create(int width, int height, char err_out[256]) ofs->h= height; ofs->fb = GPU_framebuffer_create(); - if(!ofs->fb) { + if (!ofs->fb) { GPU_offscreen_free(ofs); return NULL; } ofs->depth = GPU_texture_create_depth(width, height, err_out); - if(!ofs->depth) { + if (!ofs->depth) { GPU_offscreen_free(ofs); return NULL; } - if(!GPU_framebuffer_texture_attach(ofs->fb, ofs->depth, err_out)) { + if (!GPU_framebuffer_texture_attach(ofs->fb, ofs->depth, err_out)) { GPU_offscreen_free(ofs); return NULL; } ofs->color = GPU_texture_create_2D(width, height, NULL, err_out); - if(!ofs->color) { + if (!ofs->color) { GPU_offscreen_free(ofs); return NULL; } - if(!GPU_framebuffer_texture_attach(ofs->fb, ofs->color, err_out)) { + if (!GPU_framebuffer_texture_attach(ofs->fb, ofs->color, err_out)) { GPU_offscreen_free(ofs); return NULL; } @@ -897,11 +897,11 @@ GPUOffScreen *GPU_offscreen_create(int width, int height, char err_out[256]) void GPU_offscreen_free(GPUOffScreen *ofs) { - if(ofs->fb) + if (ofs->fb) GPU_framebuffer_free(ofs->fb); - if(ofs->color) + if (ofs->color) GPU_texture_free(ofs->color); - if(ofs->depth) + if (ofs->depth) GPU_texture_free(ofs->depth); MEM_freeN(ofs); @@ -942,7 +942,7 @@ static void shader_print_errors(const char *task, char *log, const char *code) fprintf(stderr, "GPUShader: %s error:\n", task); - if(G.f & G_DEBUG) { + if (G.f & G_DEBUG) { c = code; while ((c < end) && (pos = strchr(c, '\n'))) { fprintf(stderr, "%2d ", line); @@ -971,9 +971,9 @@ GPUShader *GPU_shader_create(const char *vertexcode, const char *fragcode, /*GPU shader = MEM_callocN(sizeof(GPUShader), "GPUShader"); - if(vertexcode) + if (vertexcode) shader->vertex = glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB); - if(fragcode) + if (fragcode) shader->fragment = glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB); shader->object = glCreateProgramObjectARB(); @@ -985,7 +985,7 @@ GPUShader *GPU_shader_create(const char *vertexcode, const char *fragcode, /*GPU return NULL; } - if(vertexcode) { + if (vertexcode) { glAttachObjectARB(shader->object, shader->vertex); glShaderSourceARB(shader->vertex, 1, (const char**)&vertexcode, NULL); @@ -1001,10 +1001,10 @@ GPUShader *GPU_shader_create(const char *vertexcode, const char *fragcode, /*GPU } } - if(fragcode) { + if (fragcode) { count = 0; - if(libcode) fragsource[count++] = libcode; - if(fragcode) fragsource[count++] = fragcode; + if (libcode) fragsource[count++] = libcode; + if (fragcode) fragsource[count++] = fragcode; glAttachObjectARB(shader->object, shader->fragment); glShaderSourceARB(shader->fragment, count, fragsource, NULL); @@ -1022,7 +1022,7 @@ GPUShader *GPU_shader_create(const char *vertexcode, const char *fragcode, /*GPU } #if 0 - if(lib && lib->lib) + if (lib && lib->lib) glAttachObjectARB(shader->object, lib->lib); #endif @@ -1113,7 +1113,7 @@ int GPU_shader_get_uniform(GPUShader *shader, const char *name) void GPU_shader_uniform_vector(GPUShader *UNUSED(shader), int location, int length, int arraysize, float *value) { - if(location == -1) + if (location == -1) return; GPU_print_error("Pre Uniform Vector"); @@ -1137,10 +1137,10 @@ void GPU_shader_uniform_texture(GPUShader *UNUSED(shader), int location, GPUText return; } - if(tex->number == -1) + if (tex->number == -1) return; - if(location == -1) + if (location == -1) return; GPU_print_error("Pre Uniform Texture"); diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c index 89b3a7d5f3f..efb931bf8e5 100644 --- a/source/blender/gpu/intern/gpu_material.c +++ b/source/blender/gpu/intern/gpu_material.c @@ -157,13 +157,13 @@ static void gpu_material_set_attrib_id(GPUMaterial *material) attribs= &material->attribs; pass= material->pass; - if(!pass) { + if (!pass) { attribs->totlayer = 0; return; } shader= GPU_pass_shader(pass); - if(!shader) { + if (!shader) { attribs->totlayer = 0; return; } @@ -172,11 +172,11 @@ static void gpu_material_set_attrib_id(GPUMaterial *material) * in case the attrib does not get a valid index back, it was probably * removed by the glsl compiler by dead code elimination */ - for(a=0, b=0; a<attribs->totlayer; a++) { + for (a=0, b=0; a<attribs->totlayer; a++) { BLI_snprintf(name, sizeof(name), "att%d", attribs->layer[a].attribid); attribs->layer[a].glindex = GPU_shader_get_attribute(shader, name); - if(attribs->layer[a].glindex >= 0) { + if (attribs->layer[a].glindex >= 0) { attribs->layer[b] = attribs->layer[a]; b++; } @@ -195,24 +195,24 @@ static int GPU_material_construct_end(GPUMaterial *material) material->pass = GPU_generate_pass(&material->nodes, outlink, &material->attribs, &material->builtins, material->ma->id.name); - if(!material->pass) + if (!material->pass) return 0; gpu_material_set_attrib_id(material); shader = GPU_pass_shader(material->pass); - if(material->builtins & GPU_VIEW_MATRIX) + if (material->builtins & GPU_VIEW_MATRIX) material->viewmatloc = GPU_shader_get_uniform(shader, GPU_builtin_name(GPU_VIEW_MATRIX)); - if(material->builtins & GPU_INVERSE_VIEW_MATRIX) + if (material->builtins & GPU_INVERSE_VIEW_MATRIX) material->invviewmatloc = GPU_shader_get_uniform(shader, GPU_builtin_name(GPU_INVERSE_VIEW_MATRIX)); - if(material->builtins & GPU_OBJECT_MATRIX) + if (material->builtins & GPU_OBJECT_MATRIX) material->obmatloc = GPU_shader_get_uniform(shader, GPU_builtin_name(GPU_OBJECT_MATRIX)); - if(material->builtins & GPU_INVERSE_OBJECT_MATRIX) + if (material->builtins & GPU_INVERSE_OBJECT_MATRIX) material->invobmatloc = GPU_shader_get_uniform(shader, GPU_builtin_name(GPU_INVERSE_OBJECT_MATRIX)); - if(material->builtins & GPU_OBCOLOR) + if (material->builtins & GPU_OBCOLOR) material->obcolloc = GPU_shader_get_uniform(shader, GPU_builtin_name(GPU_OBCOLOR)); - if(material->builtins & GPU_AUTO_BUMPSCALE) + if (material->builtins & GPU_AUTO_BUMPSCALE) material->obautobumpscaleloc = GPU_shader_get_uniform(shader, GPU_builtin_name(GPU_AUTO_BUMPSCALE)); return 1; } @@ -225,18 +225,18 @@ void GPU_material_free(Material *ma) LinkData *link; LinkData *nlink, *mlink, *next; - for(link=ma->gpumaterial.first; link; link=link->next) { + for (link=ma->gpumaterial.first; link; link=link->next) { GPUMaterial *material = link->data; - if(material->pass) + if (material->pass) GPU_pass_free(material->pass); - for(nlink=material->lamps.first; nlink; nlink=nlink->next) { + for (nlink=material->lamps.first; nlink; nlink=nlink->next) { GPULamp *lamp = nlink->data; - for(mlink=lamp->materials.first; mlink; mlink=next) { + for (mlink=lamp->materials.first; mlink; mlink=next) { next = mlink->next; - if(mlink->data == ma) + if (mlink->data == ma) BLI_freelinkN(&lamp->materials, mlink); } } @@ -251,15 +251,15 @@ void GPU_material_free(Material *ma) void GPU_material_bind(GPUMaterial *material, int oblay, int viewlay, double time, int mipmap) { - if(material->pass) { + if (material->pass) { LinkData *nlink; GPULamp *lamp; /* handle layer lamps */ - for(nlink=material->lamps.first; nlink; nlink=nlink->next) { + for (nlink=material->lamps.first; nlink; nlink=nlink->next) { lamp= nlink->data; - if(!lamp->hide && (lamp->lay & viewlay) && (!(lamp->mode & LA_LAYER) || (lamp->lay & oblay))) { + if (!lamp->hide && (lamp->lay & viewlay) && (!(lamp->mode & LA_LAYER) || (lamp->lay & oblay))) { lamp->dynenergy = lamp->energy; copy_v3_v3(lamp->dyncol, lamp->col); } @@ -276,53 +276,53 @@ void GPU_material_bind(GPUMaterial *material, int oblay, int viewlay, double tim void GPU_material_bind_uniforms(GPUMaterial *material, float obmat[][4], float viewmat[][4], float viewinv[][4], float obcol[4], float autobumpscale) { - if(material->pass) { + if (material->pass) { GPUShader *shader = GPU_pass_shader(material->pass); LinkData *nlink; GPULamp *lamp; float invmat[4][4], col[4]; /* handle builtins */ - if(material->builtins & GPU_VIEW_MATRIX) { + if (material->builtins & GPU_VIEW_MATRIX) { GPU_shader_uniform_vector(shader, material->viewmatloc, 16, 1, (float*)viewmat); } - if(material->builtins & GPU_INVERSE_VIEW_MATRIX) { + if (material->builtins & GPU_INVERSE_VIEW_MATRIX) { GPU_shader_uniform_vector(shader, material->invviewmatloc, 16, 1, (float*)viewinv); } - if(material->builtins & GPU_OBJECT_MATRIX) { + if (material->builtins & GPU_OBJECT_MATRIX) { GPU_shader_uniform_vector(shader, material->obmatloc, 16, 1, (float*)obmat); } - if(material->builtins & GPU_INVERSE_OBJECT_MATRIX) { + if (material->builtins & GPU_INVERSE_OBJECT_MATRIX) { invert_m4_m4(invmat, obmat); GPU_shader_uniform_vector(shader, material->invobmatloc, 16, 1, (float*)invmat); } - if(material->builtins & GPU_OBCOLOR) { + if (material->builtins & GPU_OBCOLOR) { copy_v4_v4(col, obcol); CLAMP(col[3], 0.0f, 1.0f); GPU_shader_uniform_vector(shader, material->obcolloc, 4, 1, col); } - if(material->builtins & GPU_AUTO_BUMPSCALE) { + if (material->builtins & GPU_AUTO_BUMPSCALE) { GPU_shader_uniform_vector(shader, material->obautobumpscaleloc, 1, 1, &autobumpscale); } /* update lamps */ - for(nlink=material->lamps.first; nlink; nlink=nlink->next) { + for (nlink=material->lamps.first; nlink; nlink=nlink->next) { lamp= nlink->data; - if(material->dynproperty & DYN_LAMP_VEC) { + if (material->dynproperty & DYN_LAMP_VEC) { copy_v3_v3(lamp->dynvec, lamp->vec); normalize_v3(lamp->dynvec); negate_v3(lamp->dynvec); mul_mat3_m4_v3(viewmat, lamp->dynvec); } - if(material->dynproperty & DYN_LAMP_CO) { + if (material->dynproperty & DYN_LAMP_CO) { copy_v3_v3(lamp->dynco, lamp->co); mul_m4_v3(viewmat, lamp->dynco); } - if(material->dynproperty & DYN_LAMP_IMAT) + if (material->dynproperty & DYN_LAMP_IMAT) mult_m4_m4m4(lamp->dynimat, lamp->imat, viewinv); - if(material->dynproperty & DYN_LAMP_PERSMAT) + if (material->dynproperty & DYN_LAMP_PERSMAT) mult_m4_m4m4(lamp->dynpersmat, lamp->persmat, viewinv); } @@ -350,7 +350,7 @@ void GPU_material_vertex_attributes(GPUMaterial *material, GPUVertexAttribs *att void GPU_material_output_link(GPUMaterial *material, GPUNodeLink *link) { - if(!material->outlink) + if (!material->outlink) material->outlink= link; } @@ -361,7 +361,7 @@ void GPU_material_enable_alpha(GPUMaterial *material) GPUBlendMode GPU_material_alpha_blend(GPUMaterial *material, float obcol[4]) { - if(material->alpha || (material->obcolalpha && obcol[3] < 1.0f)) + if (material->alpha || (material->obcolalpha && obcol[3] < 1.0f)) return GPU_BLEND_ALPHA; else return GPU_BLEND_SOLID; @@ -385,7 +385,7 @@ static GPUNodeLink *lamp_get_visibility(GPUMaterial *mat, GPULamp *lamp, GPUNode GPUNodeLink *visifac, *inpr; /* from get_lamp_visibility */ - if(lamp->type==LA_SUN || lamp->type==LA_HEMI) { + if (lamp->type==LA_SUN || lamp->type==LA_HEMI) { mat->dynproperty |= DYN_LAMP_VEC; GPU_link(mat, "lamp_visibility_sun_hemi", GPU_dynamic_uniform(lamp->dynvec, GPU_DYNAMIC_LAMP_DYNVEC, lamp->ob), lv, dist, &visifac); return visifac; @@ -394,7 +394,7 @@ static GPUNodeLink *lamp_get_visibility(GPUMaterial *mat, GPULamp *lamp, GPUNode mat->dynproperty |= DYN_LAMP_CO; GPU_link(mat, "lamp_visibility_other", GPU_builtin(GPU_VIEW_POSITION), GPU_dynamic_uniform(lamp->dynco, GPU_DYNAMIC_LAMP_DYNCO, lamp->ob), lv, dist, &visifac); - if(lamp->type==LA_AREA) + if (lamp->type==LA_AREA) return visifac; switch(lamp->falloff_type) @@ -421,11 +421,11 @@ static GPUNodeLink *lamp_get_visibility(GPUMaterial *mat, GPULamp *lamp, GPUNode break; } - if(lamp->mode & LA_SPHERE) + if (lamp->mode & LA_SPHERE) GPU_link(mat, "lamp_visibility_sphere", GPU_uniform(&lamp->dist), *dist, visifac, &visifac); - if(lamp->type == LA_SPOT) { - if(lamp->mode & LA_SQUARE) { + if (lamp->type == LA_SPOT) { + if (lamp->mode & LA_SQUARE) { mat->dynproperty |= DYN_LAMP_VEC|DYN_LAMP_IMAT; GPU_link(mat, "lamp_visibility_spot_square", GPU_dynamic_uniform(lamp->dynvec, GPU_DYNAMIC_LAMP_DYNVEC, lamp->ob), GPU_dynamic_uniform((float*)lamp->dynimat, GPU_DYNAMIC_LAMP_DYNIMAT, lamp->ob), *lv, &inpr); } @@ -511,9 +511,9 @@ static void ramp_diffuse_result(GPUShadeInput *shi, GPUNodeLink **diff) GPUMaterial *mat= shi->gpumat; GPUNodeLink *fac; - if(!(mat->scene->gm.flag & GAME_GLSL_NO_RAMPS)) { - if(ma->ramp_col) { - if(ma->rampin_col==MA_RAMP_IN_RESULT) { + if (!(mat->scene->gm.flag & GAME_GLSL_NO_RAMPS)) { + if (ma->ramp_col) { + if (ma->rampin_col==MA_RAMP_IN_RESULT) { GPU_link(mat, "ramp_rgbtobw", *diff, &fac); /* colorband + blend */ @@ -527,10 +527,10 @@ static void add_to_diffuse(GPUMaterial *mat, Material *ma, GPUShadeInput *shi, G { GPUNodeLink *fac, *tmp, *addcol; - if(!(mat->scene->gm.flag & GAME_GLSL_NO_RAMPS) && + if (!(mat->scene->gm.flag & GAME_GLSL_NO_RAMPS) && ma->ramp_col && (ma->mode & MA_RAMP_COL)) { /* MA_RAMP_IN_RESULT is exceptional */ - if(ma->rampin_col==MA_RAMP_IN_RESULT) { + if (ma->rampin_col==MA_RAMP_IN_RESULT) { addcol = shi->rgb; } else { @@ -567,7 +567,7 @@ static void ramp_spec_result(GPUShadeInput *shi, GPUNodeLink **spec) GPUMaterial *mat= shi->gpumat; GPUNodeLink *fac; - if(!(mat->scene->gm.flag & GAME_GLSL_NO_RAMPS) && + if (!(mat->scene->gm.flag & GAME_GLSL_NO_RAMPS) && ma->ramp_spec && ma->rampin_spec==MA_RAMP_IN_RESULT) { GPU_link(mat, "ramp_rgbtobw", *spec, &fac); @@ -585,7 +585,7 @@ static void do_specular_ramp(GPUShadeInput *shi, GPUNodeLink *is, GPUNodeLink *t *spec = shi->specrgb; /* MA_RAMP_IN_RESULT is exception */ - if(ma->ramp_spec && (ma->rampin_spec!=MA_RAMP_IN_RESULT)) { + if (ma->ramp_spec && (ma->rampin_spec!=MA_RAMP_IN_RESULT)) { /* input */ switch(ma->rampin_spec) { @@ -623,7 +623,7 @@ static void shade_one_light(GPUShadeInput *shi, GPUShadeResult *shr, GPULamp *la GPUNodeLink *outcol, *specfac, *t, *shadfac= NULL; float one = 1.0f; - if((lamp->mode & LA_ONLYSHADOW) && !(ma->mode & MA_SHADOW)) + if ((lamp->mode & LA_ONLYSHADOW) && !(ma->mode & MA_SHADOW)) return; vn= shi->vn; @@ -636,14 +636,14 @@ static void shade_one_light(GPUShadeInput *shi, GPUShadeResult *shr, GPULamp *la GPU_link(mat, "shade_inp", vn, lv, &inp); - if(lamp->mode & LA_NO_DIFF) { + if (lamp->mode & LA_NO_DIFF) { GPU_link(mat, "shade_is_no_diffuse", &is); } - else if(lamp->type == LA_HEMI) { + else if (lamp->type == LA_HEMI) { GPU_link(mat, "shade_is_hemi", inp, &is); } else { - if(lamp->type == LA_AREA) { + if (lamp->type == LA_AREA) { float area[4][4]= {{0.0f}}, areasize= 0.0f; mat->dynproperty |= DYN_LAMP_VEC|DYN_LAMP_CO; @@ -653,35 +653,35 @@ static void shade_one_light(GPUShadeInput *shi, GPUShadeResult *shr, GPULamp *la is= inp; /* Lambert */ - if(!(mat->scene->gm.flag & GAME_GLSL_NO_SHADERS)) { - if(ma->diff_shader==MA_DIFF_ORENNAYAR) + if (!(mat->scene->gm.flag & GAME_GLSL_NO_SHADERS)) { + if (ma->diff_shader==MA_DIFF_ORENNAYAR) GPU_link(mat, "shade_diffuse_oren_nayer", inp, vn, lv, view, GPU_uniform(&ma->roughness), &is); - else if(ma->diff_shader==MA_DIFF_TOON) + else if (ma->diff_shader==MA_DIFF_TOON) GPU_link(mat, "shade_diffuse_toon", vn, lv, view, GPU_uniform(&ma->param[0]), GPU_uniform(&ma->param[1]), &is); - else if(ma->diff_shader==MA_DIFF_MINNAERT) + else if (ma->diff_shader==MA_DIFF_MINNAERT) GPU_link(mat, "shade_diffuse_minnaert", inp, vn, view, GPU_uniform(&ma->darkness), &is); - else if(ma->diff_shader==MA_DIFF_FRESNEL) + else if (ma->diff_shader==MA_DIFF_FRESNEL) GPU_link(mat, "shade_diffuse_fresnel", vn, lv, view, GPU_uniform(&ma->param[0]), GPU_uniform(&ma->param[1]), &is); } } - if(!(mat->scene->gm.flag & GAME_GLSL_NO_SHADERS)) - if(ma->shade_flag & MA_CUBIC) + if (!(mat->scene->gm.flag & GAME_GLSL_NO_SHADERS)) + if (ma->shade_flag & MA_CUBIC) GPU_link(mat, "shade_cubic", is, &is); i = is; GPU_link(mat, "shade_visifac", i, visifac, shi->refl, &i); #if 0 - if(ma->mode & MA_TANGENT_VN) + if (ma->mode & MA_TANGENT_VN) GPU_link(mat, "shade_tangent_v_spec", GPU_attribute(CD_TANGENT, ""), &vn); #endif /* this replaces if(i > 0.0) conditional until that is supported */ // done in shade_visifac now, GPU_link(mat, "mtex_value_clamp_positive", i, &i); - if((ma->mode & MA_SHADOW) && GPU_lamp_has_shadow_buffer(lamp)) { - if(!(mat->scene->gm.flag & GAME_GLSL_NO_SHADOWS)) { + if ((ma->mode & MA_SHADOW) && GPU_lamp_has_shadow_buffer(lamp)) { + if (!(mat->scene->gm.flag & GAME_GLSL_NO_SHADOWS)) { mat->dynproperty |= DYN_LAMP_PERSMAT; GPU_link(mat, "test_shadowbuf", @@ -690,15 +690,15 @@ static void shade_one_light(GPUShadeInput *shi, GPUShadeResult *shr, GPULamp *la GPU_dynamic_uniform((float*)lamp->dynpersmat, GPU_DYNAMIC_LAMP_DYNPERSMAT, lamp->ob), GPU_uniform(&lamp->bias), inp, &shadfac); - if(lamp->mode & LA_ONLYSHADOW) { + if (lamp->mode & LA_ONLYSHADOW) { GPU_link(mat, "shade_only_shadow", i, shadfac, GPU_dynamic_uniform(&lamp->dynenergy, GPU_DYNAMIC_LAMP_DYNENERGY, lamp->ob), &shadfac); - if(!(lamp->mode & LA_NO_DIFF)) + if (!(lamp->mode & LA_NO_DIFF)) GPU_link(mat, "shade_only_shadow_diffuse", shadfac, shi->rgb, shr->diff, &shr->diff); - if(!(lamp->mode & LA_NO_SPEC)) + if (!(lamp->mode & LA_NO_SPEC)) GPU_link(mat, "shade_only_shadow_specular", shadfac, shi->specrgb, shr->spec, &shr->spec); @@ -710,7 +710,7 @@ static void shade_one_light(GPUShadeInput *shi, GPUShadeResult *shr, GPULamp *la GPU_link(mat, "math_multiply", i, shadfac, &i); } } - else if((mat->scene->gm.flag & GAME_GLSL_NO_SHADOWS) && (lamp->mode & LA_ONLYSHADOW)) { + else if ((mat->scene->gm.flag & GAME_GLSL_NO_SHADOWS) && (lamp->mode & LA_ONLYSHADOW)) { add_user_list(&mat->lamps, lamp); add_user_list(&lamp->materials, shi->gpumat->ma); return; @@ -718,40 +718,40 @@ static void shade_one_light(GPUShadeInput *shi, GPUShadeResult *shr, GPULamp *la else GPU_link(mat, "set_value", GPU_uniform(&one), &shadfac); - if(GPU_link_changed(shi->refl) || ma->ref != 0.0f) { - if(!(lamp->mode & LA_NO_DIFF)) { + if (GPU_link_changed(shi->refl) || ma->ref != 0.0f) { + if (!(lamp->mode & LA_NO_DIFF)) { GPUNodeLink *rgb; GPU_link(mat, "shade_mul_value", i, GPU_dynamic_uniform(lamp->dyncol, GPU_DYNAMIC_LAMP_DYNCOL, lamp->ob), &rgb); add_to_diffuse(mat, ma, shi, is, rgb, &shr->diff); } } - if(mat->scene->gm.flag & GAME_GLSL_NO_SHADERS); - else if(!(lamp->mode & LA_NO_SPEC) && !(lamp->mode & LA_ONLYSHADOW) && + if (mat->scene->gm.flag & GAME_GLSL_NO_SHADERS); + else if (!(lamp->mode & LA_NO_SPEC) && !(lamp->mode & LA_ONLYSHADOW) && (GPU_link_changed(shi->spec) || ma->spec != 0.0f)) { - if(lamp->type == LA_HEMI) { + if (lamp->type == LA_HEMI) { GPU_link(mat, "shade_hemi_spec", vn, lv, view, GPU_uniform(&ma->spec), shi->har, visifac, &t); GPU_link(mat, "shade_add_spec", t, GPU_dynamic_uniform(lamp->dyncol, GPU_DYNAMIC_LAMP_DYNCOL, lamp->ob), shi->specrgb, &outcol); GPU_link(mat, "shade_add_clamped", shr->spec, outcol, &shr->spec); } else { - if(ma->spec_shader==MA_SPEC_PHONG) + if (ma->spec_shader==MA_SPEC_PHONG) GPU_link(mat, "shade_phong_spec", vn, lv, view, shi->har, &specfac); - else if(ma->spec_shader==MA_SPEC_COOKTORR) + else if (ma->spec_shader==MA_SPEC_COOKTORR) GPU_link(mat, "shade_cooktorr_spec", vn, lv, view, shi->har, &specfac); - else if(ma->spec_shader==MA_SPEC_BLINN) + else if (ma->spec_shader==MA_SPEC_BLINN) GPU_link(mat, "shade_blinn_spec", vn, lv, view, GPU_uniform(&ma->refrac), shi->har, &specfac); - else if(ma->spec_shader==MA_SPEC_WARDISO) + else if (ma->spec_shader==MA_SPEC_WARDISO) GPU_link(mat, "shade_wardiso_spec", vn, lv, view, GPU_uniform(&ma->rms), &specfac); else GPU_link(mat, "shade_toon_spec", vn, lv, view, GPU_uniform(&ma->param[2]), GPU_uniform(&ma->param[3]), &specfac); - if(lamp->type==LA_AREA) + if (lamp->type==LA_AREA) GPU_link(mat, "shade_spec_area_inp", specfac, inp, &specfac); GPU_link(mat, "shade_spec_t", shadfac, shi->spec, visifac, specfac, &t); - if(ma->mode & MA_RAMP_SPEC) { + if (ma->mode & MA_RAMP_SPEC) { GPUNodeLink *spec; do_specular_ramp(shi, specfac, t, &spec); GPU_link(mat, "shade_add_spec", t, GPU_dynamic_uniform(lamp->dyncol, GPU_DYNAMIC_LAMP_DYNCOL, lamp->ob), spec, &outcol); @@ -775,12 +775,12 @@ static void material_lights(GPUShadeInput *shi, GPUShadeResult *shr) Scene *sce_iter; GPULamp *lamp; - for(SETLOOPER(shi->gpumat->scene, sce_iter, base)) { + for (SETLOOPER(shi->gpumat->scene, sce_iter, base)) { ob= base->object; - if(ob->type==OB_LAMP) { + if (ob->type==OB_LAMP) { lamp = GPU_lamp_from_blender(shi->gpumat->scene, ob, NULL); - if(lamp) + if (lamp) shade_one_light(shi, shr, lamp); } @@ -788,14 +788,14 @@ static void material_lights(GPUShadeInput *shi, GPUShadeResult *shr) DupliObject *dob; ListBase *lb = object_duplilist(shi->gpumat->scene, ob); - for(dob=lb->first; dob; dob=dob->next) { + for (dob=lb->first; dob; dob=dob->next) { Object *ob_iter = dob->ob; - if(ob_iter->type==OB_LAMP) { + if (ob_iter->type==OB_LAMP) { copy_m4_m4(ob_iter->obmat, dob->mat); lamp = GPU_lamp_from_blender(shi->gpumat->scene, ob_iter, ob); - if(lamp) + if (lamp) shade_one_light(shi, shr, lamp); } } @@ -924,33 +924,33 @@ static void do_material_tex(GPUShadeInput *shi) orn= texco_norm; /* go over texture slots */ - for(tex_nr=0; tex_nr<MAX_MTEX; tex_nr++) { + for (tex_nr=0; tex_nr<MAX_MTEX; tex_nr++) { /* separate tex switching */ - if(ma->septex & (1<<tex_nr)) continue; + if (ma->septex & (1<<tex_nr)) continue; - if(ma->mtex[tex_nr]) { + if (ma->mtex[tex_nr]) { mtex= ma->mtex[tex_nr]; tex= mtex->tex; - if(tex == NULL) continue; + if (tex == NULL) continue; /* which coords */ - if(mtex->texco==TEXCO_ORCO) + if (mtex->texco==TEXCO_ORCO) texco= texco_orco; - else if(mtex->texco==TEXCO_OBJECT) + else if (mtex->texco==TEXCO_OBJECT) texco= texco_object; - else if(mtex->texco==TEXCO_NORM) + else if (mtex->texco==TEXCO_NORM) texco= orn; - else if(mtex->texco==TEXCO_TANGENT) + else if (mtex->texco==TEXCO_TANGENT) texco= texco_object; - else if(mtex->texco==TEXCO_GLOB) + else if (mtex->texco==TEXCO_GLOB) texco= texco_global; - else if(mtex->texco==TEXCO_REFL) { + else if (mtex->texco==TEXCO_REFL) { GPU_link(mat, "texco_refl", shi->vn, shi->view, &shi->ref); texco= shi->ref; } - else if(mtex->texco==TEXCO_UV) { - if(1) { //!(texco_uv && strcmp(mtex->uvname, lastuvname) == 0)) { + else if (mtex->texco==TEXCO_UV) { + if (1) { //!(texco_uv && strcmp(mtex->uvname, lastuvname) == 0)) { GPU_link(mat, "texco_uv", GPU_attribute(CD_MTFACE, mtex->uvname), &texco_uv); /*lastuvname = mtex->uvname;*/ /*UNUSED*/ } @@ -960,98 +960,98 @@ static void do_material_tex(GPUShadeInput *shi) continue; /* in case of uv, this would just undo a multiplication in texco_uv */ - if(mtex->texco != TEXCO_UV) + if (mtex->texco != TEXCO_UV) GPU_link(mat, "mtex_2d_mapping", texco, &texco); - if(mtex->size[0] != 1.0f || mtex->size[1] != 1.0f || mtex->size[2] != 1.0f) + if (mtex->size[0] != 1.0f || mtex->size[1] != 1.0f || mtex->size[2] != 1.0f) GPU_link(mat, "mtex_mapping_size", texco, GPU_uniform(mtex->size), &texco); ofs[0] = mtex->ofs[0] + 0.5f - 0.5f*mtex->size[0]; ofs[1] = mtex->ofs[1] + 0.5f - 0.5f*mtex->size[1]; ofs[2] = 0.0f; - if(ofs[0] != 0.0f || ofs[1] != 0.0f || ofs[2] != 0.0f) + if (ofs[0] != 0.0f || ofs[1] != 0.0f || ofs[2] != 0.0f) GPU_link(mat, "mtex_mapping_ofs", texco, GPU_uniform(ofs), &texco); talpha = 0; - if(tex && tex->type == TEX_IMAGE && tex->ima) { + if (tex && tex->type == TEX_IMAGE && tex->ima) { GPU_link(mat, "mtex_image", texco, GPU_image(tex->ima, &tex->iuser), &tin, &trgb); rgbnor= TEX_RGB; - if(tex->imaflag & TEX_USEALPHA) + if (tex->imaflag & TEX_USEALPHA) talpha= 1; } else continue; /* texture output */ - if((rgbnor & TEX_RGB) && (mtex->texflag & MTEX_RGBTOINT)) { + if ((rgbnor & TEX_RGB) && (mtex->texflag & MTEX_RGBTOINT)) { GPU_link(mat, "mtex_rgbtoint", trgb, &tin); rgbnor -= TEX_RGB; } - if(mtex->texflag & MTEX_NEGATIVE) { - if(rgbnor & TEX_RGB) + if (mtex->texflag & MTEX_NEGATIVE) { + if (rgbnor & TEX_RGB) GPU_link(mat, "mtex_rgb_invert", trgb, &trgb); else GPU_link(mat, "mtex_value_invert", tin, &tin); } - if(mtex->texflag & MTEX_STENCIL) { - if(rgbnor & TEX_RGB) + if (mtex->texflag & MTEX_STENCIL) { + if (rgbnor & TEX_RGB) GPU_link(mat, "mtex_rgb_stencil", stencil, trgb, &stencil, &trgb); else GPU_link(mat, "mtex_value_stencil", stencil, tin, &stencil, &tin); } /* mapping */ - if(mtex->mapto & (MAP_COL+MAP_COLSPEC)) { + if (mtex->mapto & (MAP_COL+MAP_COLSPEC)) { /* stencil maps on the texture control slider, not texture intensity value */ - if((rgbnor & TEX_RGB)==0) { + if ((rgbnor & TEX_RGB)==0) { GPU_link(mat, "set_rgb", GPU_uniform(&mtex->r), &tcol); } else { GPU_link(mat, "set_rgba", trgb, &tcol); - if(mtex->mapto & MAP_ALPHA) + if (mtex->mapto & MAP_ALPHA) GPU_link(mat, "set_value", stencil, &tin); - else if(talpha) + else if (talpha) GPU_link(mat, "mtex_alpha_from_col", trgb, &tin); else GPU_link(mat, "set_value_one", &tin); } - if(tex->type==TEX_IMAGE) - if(gpu_do_color_management(mat)) + if (tex->type==TEX_IMAGE) + if (gpu_do_color_management(mat)) GPU_link(mat, "srgb_to_linearrgb", tcol, &tcol); - if(mtex->mapto & MAP_COL) { + if (mtex->mapto & MAP_COL) { GPUNodeLink *colfac; - if(mtex->colfac == 1.0f) colfac = stencil; + if (mtex->colfac == 1.0f) colfac = stencil; else GPU_link(mat, "math_multiply", GPU_uniform(&mtex->colfac), stencil, &colfac); texture_rgb_blend(mat, tcol, shi->rgb, tin, colfac, mtex->blendtype, &shi->rgb); } - if(!(mat->scene->gm.flag & GAME_GLSL_NO_EXTRA_TEX) && (mtex->mapto & MAP_COLSPEC)) { + if (!(mat->scene->gm.flag & GAME_GLSL_NO_EXTRA_TEX) && (mtex->mapto & MAP_COLSPEC)) { GPUNodeLink *colspecfac; - if(mtex->colspecfac == 1.0f) colspecfac = stencil; + if (mtex->colspecfac == 1.0f) colspecfac = stencil; else GPU_link(mat, "math_multiply", GPU_uniform(&mtex->colspecfac), stencil, &colspecfac); texture_rgb_blend(mat, tcol, shi->specrgb, tin, colspecfac, mtex->blendtype, &shi->specrgb); } } - if(!(mat->scene->gm.flag & GAME_GLSL_NO_EXTRA_TEX) && (mtex->mapto & MAP_NORM)) { - if(tex->type==TEX_IMAGE) { + if (!(mat->scene->gm.flag & GAME_GLSL_NO_EXTRA_TEX) && (mtex->mapto & MAP_NORM)) { + if (tex->type==TEX_IMAGE) { found_deriv_map = tex->imaflag & TEX_DERIVATIVEMAP; - if(tex->imaflag & TEX_NORMALMAP) { + if (tex->imaflag & TEX_NORMALMAP) { /* normalmap image */ GPU_link(mat, "mtex_normal", texco, GPU_image(tex->ima, &tex->iuser), &tnor ); - if(mtex->norfac < 0.0f) + if (mtex->norfac < 0.0f) GPU_link(mat, "mtex_negate_texnormal", tnor, &tnor); if (mtex->normapspace == MTEX_NSPACE_TANGENT) { @@ -1072,20 +1072,20 @@ static void do_material_tex(GPUShadeInput *shi) norfac = minf(fabsf(mtex->norfac), 1.0f); - if(norfac == 1.0f && !GPU_link_changed(stencil)) { + if (norfac == 1.0f && !GPU_link_changed(stencil)) { shi->vn = newnor; } else { tnorfac = GPU_uniform(&norfac); - if(GPU_link_changed(stencil)) + if (GPU_link_changed(stencil)) GPU_link(mat, "math_multiply", tnorfac, stencil, &tnorfac); GPU_link(mat, "mtex_blend_normal", tnorfac, shi->vn, newnor, &shi->vn); } } - else if( (mtex->texflag & (MTEX_3TAP_BUMP|MTEX_5TAP_BUMP|MTEX_BICUBIC_BUMP)) || found_deriv_map) { + else if ( (mtex->texflag & (MTEX_3TAP_BUMP|MTEX_5TAP_BUMP|MTEX_BICUBIC_BUMP)) || found_deriv_map) { /* ntap bumpmap image */ int iBumpSpace; float ima_x, ima_y; @@ -1099,16 +1099,16 @@ static void do_material_tex(GPUShadeInput *shi) GPUNodeLink *dBs, *dBt, *fDet; hScale = 0.1; // compatibility adjustment factor for all bumpspace types - if( mtex->texflag & MTEX_BUMP_TEXTURESPACE ) + if ( mtex->texflag & MTEX_BUMP_TEXTURESPACE ) hScale = 13.0f; // factor for scaling texspace bumps - else if(found_deriv_map!=0) + else if (found_deriv_map!=0) hScale = 1.0f; // resolve texture resolution - if( (mtex->texflag & MTEX_BUMP_TEXTURESPACE) || found_deriv_map ) { + if ( (mtex->texflag & MTEX_BUMP_TEXTURESPACE) || found_deriv_map ) { ImBuf *ibuf= BKE_image_get_ibuf(tex->ima, &tex->iuser); ima_x= 512.0f; ima_y= 512.f; // prevent calling textureSize, glsl 1.3 only - if(ibuf) { + if (ibuf) { ima_x= ibuf->x; ima_y= ibuf->y; aspect = ((float) ima_y) / ima_x; @@ -1127,13 +1127,13 @@ static void do_material_tex(GPUShadeInput *shi) tnorfac = GPU_uniform(&norfac); - if(found_deriv_map) + if (found_deriv_map) GPU_link(mat, "math_multiply", tnorfac, GPU_builtin(GPU_AUTO_BUMPSCALE), &tnorfac); - if(GPU_link_changed(stencil)) + if (GPU_link_changed(stencil)) GPU_link(mat, "math_multiply", tnorfac, stencil, &tnorfac); - if( !init_done ) { + if ( !init_done ) { // copy shi->vn to vNorg and vNacc, set magnitude to 1 GPU_link(mat, "mtex_bump_normals_init", shi->vn, &vNorg, &vNacc, &fPrevMagnitude); iBumpSpacePrev = 0; @@ -1141,17 +1141,17 @@ static void do_material_tex(GPUShadeInput *shi) } // find current bump space - if( mtex->texflag & MTEX_BUMP_OBJECTSPACE ) + if ( mtex->texflag & MTEX_BUMP_OBJECTSPACE ) iBumpSpace = 1; - else if( mtex->texflag & MTEX_BUMP_TEXTURESPACE ) + else if ( mtex->texflag & MTEX_BUMP_TEXTURESPACE ) iBumpSpace = 2; else iBumpSpace = 4; // ViewSpace // re-initialize if bump space changed - if( iBumpSpacePrev != iBumpSpace ) { + if ( iBumpSpacePrev != iBumpSpace ) { - if( mtex->texflag & MTEX_BUMP_OBJECTSPACE ) + if ( mtex->texflag & MTEX_BUMP_OBJECTSPACE ) GPU_link( mat, "mtex_bump_init_objspace", surf_pos, vNorg, GPU_builtin(GPU_VIEW_MATRIX), GPU_builtin(GPU_INVERSE_VIEW_MATRIX), GPU_builtin(GPU_OBJECT_MATRIX), GPU_builtin(GPU_INVERSE_OBJECT_MATRIX), @@ -1159,7 +1159,7 @@ static void do_material_tex(GPUShadeInput *shi) &fPrevMagnitude, &vNacc, &vR1, &vR2, &fDet ); - else if( mtex->texflag & MTEX_BUMP_TEXTURESPACE ) + else if ( mtex->texflag & MTEX_BUMP_TEXTURESPACE ) GPU_link( mat, "mtex_bump_init_texturespace", surf_pos, vNorg, fPrevMagnitude, vNacc, @@ -1177,25 +1177,26 @@ static void do_material_tex(GPUShadeInput *shi) } - if(found_deriv_map) { + if (found_deriv_map) { GPU_link( mat, "mtex_bump_deriv", texco, GPU_image(tex->ima, &tex->iuser), GPU_uniform(&ima_x), GPU_uniform(&ima_y), tnorfac, &dBs, &dBt ); } - else if( mtex->texflag & MTEX_3TAP_BUMP ) + else if ( mtex->texflag & MTEX_3TAP_BUMP ) GPU_link( mat, "mtex_bump_tap3", texco, GPU_image(tex->ima, &tex->iuser), tnorfac, &dBs, &dBt ); - else if( mtex->texflag & MTEX_5TAP_BUMP ) + else if ( mtex->texflag & MTEX_5TAP_BUMP ) GPU_link( mat, "mtex_bump_tap5", texco, GPU_image(tex->ima, &tex->iuser), tnorfac, &dBs, &dBt ); - else if( mtex->texflag & MTEX_BICUBIC_BUMP ){ - if(GPU_bicubic_bump_support()){ + else if ( mtex->texflag & MTEX_BICUBIC_BUMP ) { + if (GPU_bicubic_bump_support()) { GPU_link( mat, "mtex_bump_bicubic", texco, GPU_image(tex->ima, &tex->iuser), tnorfac, &dBs, &dBt ); - }else{ + } + else { GPU_link( mat, "mtex_bump_tap5", texco, GPU_image(tex->ima, &tex->iuser), tnorfac, &dBs, &dBt ); @@ -1203,14 +1204,15 @@ static void do_material_tex(GPUShadeInput *shi) } - if( mtex->texflag & MTEX_BUMP_TEXTURESPACE ) { + if ( mtex->texflag & MTEX_BUMP_TEXTURESPACE ) { float imag_tspace_dimension_y = aspect*imag_tspace_dimension_x; GPU_link( mat, "mtex_bump_apply_texspace", fDet, dBs, dBt, vR1, vR2, GPU_image(tex->ima, &tex->iuser), texco, GPU_uniform(&imag_tspace_dimension_x), GPU_uniform(&imag_tspace_dimension_y), vNacc, &vNacc, &shi->vn ); - } else + } + else GPU_link( mat, "mtex_bump_apply", fDet, dBs, dBt, vR1, vR2, vNacc, &vNacc, &shi->vn ); @@ -1221,64 +1223,64 @@ static void do_material_tex(GPUShadeInput *shi) GPU_link(mat, "vec_math_negate", shi->vn, &orn); } - if((mtex->mapto & MAP_VARS)) { - if(rgbnor & TEX_RGB) { - if(talpha) + if ((mtex->mapto & MAP_VARS)) { + if (rgbnor & TEX_RGB) { + if (talpha) GPU_link(mat, "mtex_alpha_from_col", trgb, &tin); else GPU_link(mat, "mtex_rgbtoint", trgb, &tin); } - if(!(mat->scene->gm.flag & GAME_GLSL_NO_EXTRA_TEX) && mtex->mapto & MAP_REF) { + if (!(mat->scene->gm.flag & GAME_GLSL_NO_EXTRA_TEX) && mtex->mapto & MAP_REF) { GPUNodeLink *difffac; - if(mtex->difffac == 1.0f) difffac = stencil; + if (mtex->difffac == 1.0f) difffac = stencil; else GPU_link(mat, "math_multiply", GPU_uniform(&mtex->difffac), stencil, &difffac); texture_value_blend(mat, GPU_uniform(&mtex->def_var), shi->refl, tin, difffac, mtex->blendtype, &shi->refl); GPU_link(mat, "mtex_value_clamp_positive", shi->refl, &shi->refl); } - if(!(mat->scene->gm.flag & GAME_GLSL_NO_EXTRA_TEX) && mtex->mapto & MAP_SPEC) { + if (!(mat->scene->gm.flag & GAME_GLSL_NO_EXTRA_TEX) && mtex->mapto & MAP_SPEC) { GPUNodeLink *specfac; - if(mtex->specfac == 1.0f) specfac = stencil; + if (mtex->specfac == 1.0f) specfac = stencil; else GPU_link(mat, "math_multiply", GPU_uniform(&mtex->specfac), stencil, &specfac); texture_value_blend(mat, GPU_uniform(&mtex->def_var), shi->spec, tin, specfac, mtex->blendtype, &shi->spec); GPU_link(mat, "mtex_value_clamp_positive", shi->spec, &shi->spec); } - if(!(mat->scene->gm.flag & GAME_GLSL_NO_EXTRA_TEX) && mtex->mapto & MAP_EMIT) { + if (!(mat->scene->gm.flag & GAME_GLSL_NO_EXTRA_TEX) && mtex->mapto & MAP_EMIT) { GPUNodeLink *emitfac; - if(mtex->emitfac == 1.0f) emitfac = stencil; + if (mtex->emitfac == 1.0f) emitfac = stencil; else GPU_link(mat, "math_multiply", GPU_uniform(&mtex->emitfac), stencil, &emitfac); texture_value_blend(mat, GPU_uniform(&mtex->def_var), shi->emit, tin, emitfac, mtex->blendtype, &shi->emit); GPU_link(mat, "mtex_value_clamp_positive", shi->emit, &shi->emit); } - if(!(mat->scene->gm.flag & GAME_GLSL_NO_EXTRA_TEX) && mtex->mapto & MAP_HAR) { + if (!(mat->scene->gm.flag & GAME_GLSL_NO_EXTRA_TEX) && mtex->mapto & MAP_HAR) { GPUNodeLink *hardfac; - if(mtex->hardfac == 1.0f) hardfac = stencil; + if (mtex->hardfac == 1.0f) hardfac = stencil; else GPU_link(mat, "math_multiply", GPU_uniform(&mtex->hardfac), stencil, &hardfac); GPU_link(mat, "mtex_har_divide", shi->har, &shi->har); texture_value_blend(mat, GPU_uniform(&mtex->def_var), shi->har, tin, hardfac, mtex->blendtype, &shi->har); GPU_link(mat, "mtex_har_multiply_clamp", shi->har, &shi->har); } - if(mtex->mapto & MAP_ALPHA) { + if (mtex->mapto & MAP_ALPHA) { GPUNodeLink *alphafac; - if(mtex->alphafac == 1.0f) alphafac = stencil; + if (mtex->alphafac == 1.0f) alphafac = stencil; else GPU_link(mat, "math_multiply", GPU_uniform(&mtex->alphafac), stencil, &alphafac); texture_value_blend(mat, GPU_uniform(&mtex->def_var), shi->alpha, tin, alphafac, mtex->blendtype, &shi->alpha); GPU_link(mat, "mtex_value_clamp", shi->alpha, &shi->alpha); } - if(!(mat->scene->gm.flag & GAME_GLSL_NO_EXTRA_TEX) && mtex->mapto & MAP_AMB) { + if (!(mat->scene->gm.flag & GAME_GLSL_NO_EXTRA_TEX) && mtex->mapto & MAP_AMB) { GPUNodeLink *ambfac; - if(mtex->ambfac == 1.0f) ambfac = stencil; + if (mtex->ambfac == 1.0f) ambfac = stencil; else GPU_link(mat, "math_multiply", GPU_uniform(&mtex->ambfac), stencil, &ambfac); texture_value_blend(mat, GPU_uniform(&mtex->def_var), shi->amb, tin, ambfac, mtex->blendtype, &shi->amb); @@ -1309,7 +1311,7 @@ void GPU_shadeinput_set(GPUMaterial *mat, Material *ma, GPUShadeInput *shi) GPU_link(mat, "set_value", GPU_uniform(&ma->amb), &shi->amb); GPU_link(mat, "shade_view", GPU_builtin(GPU_VIEW_POSITION), &shi->view); GPU_link(mat, "vcol_attribute", GPU_attribute(CD_MCOL, ""), &shi->vcol); - if(gpu_do_color_management(mat)) + if (gpu_do_color_management(mat)) GPU_link(mat, "srgb_to_linearrgb", shi->vcol, &shi->vcol); GPU_link(mat, "texco_refl", shi->vn, shi->view, &shi->ref); } @@ -1324,23 +1326,23 @@ void GPU_shaderesult_set(GPUShadeInput *shi, GPUShadeResult *shr) memset(shr, 0, sizeof(*shr)); - if(ma->mode & MA_VERTEXCOLP) + if (ma->mode & MA_VERTEXCOLP) shi->rgb = shi->vcol; do_material_tex(shi); - if((ma->mode & MA_TRANSP) && (ma->mode & MA_ZTRANSP)) + if ((ma->mode & MA_TRANSP) && (ma->mode & MA_ZTRANSP)) GPU_material_enable_alpha(mat); - if((mat->scene->gm.flag & GAME_GLSL_NO_LIGHTS) || (ma->mode & MA_SHLESS)) { + if ((mat->scene->gm.flag & GAME_GLSL_NO_LIGHTS) || (ma->mode & MA_SHLESS)) { shr->combined = shi->rgb; shr->alpha = shi->alpha; GPU_link(mat, "set_rgb", shi->rgb, &shr->diff); GPU_link(mat, "set_rgb_zero", &shr->spec); } else { - if(GPU_link_changed(shi->emit) || ma->emit != 0.0f) { - if((ma->mode & (MA_VERTEXCOL|MA_VERTEXCOLP))== MA_VERTEXCOL) { + if (GPU_link_changed(shi->emit) || ma->emit != 0.0f) { + if ((ma->mode & (MA_VERTEXCOL|MA_VERTEXCOLP))== MA_VERTEXCOL) { GPU_link(mat, "shade_add", shi->emit, shi->vcol, &emit); GPU_link(mat, "shade_mul", emit, shi->rgb, &shr->diff); } @@ -1357,9 +1359,9 @@ void GPU_shaderesult_set(GPUShadeInput *shi, GPUShadeResult *shr) shr->combined = shr->diff; shr->alpha = shi->alpha; - if(world) { + if (world) { /* exposure correction */ - if(world->exp!=0.0f || world->range!=1.0f) { + if (world->exp!=0.0f || world->range!=1.0f) { linfac= 1.0f + powf((2.0f*world->exp + 0.5f), -10); logfac= logf((linfac-1.0f)/linfac)/world->range; @@ -1373,26 +1375,26 @@ void GPU_shaderesult_set(GPUShadeInput *shi, GPUShadeResult *shr) } /* ambient color */ - if(world->ambr!=0.0f || world->ambg!=0.0f || world->ambb!=0.0f) { - if(GPU_link_changed(shi->amb) || ma->amb != 0.0f) + if (world->ambr!=0.0f || world->ambg!=0.0f || world->ambb!=0.0f) { + if (GPU_link_changed(shi->amb) || ma->amb != 0.0f) GPU_link(mat, "shade_maddf", shr->combined, GPU_uniform(&ma->amb), GPU_uniform(&world->ambr), &shr->combined); } } - if(ma->mode & MA_RAMP_COL) ramp_diffuse_result(shi, &shr->combined); - if(ma->mode & MA_RAMP_SPEC) ramp_spec_result(shi, &shr->spec); + if (ma->mode & MA_RAMP_COL) ramp_diffuse_result(shi, &shr->combined); + if (ma->mode & MA_RAMP_SPEC) ramp_spec_result(shi, &shr->spec); - if(GPU_link_changed(shi->spec) || ma->spec != 0.0f) + if (GPU_link_changed(shi->spec) || ma->spec != 0.0f) GPU_link(mat, "shade_add", shr->combined, shr->spec, &shr->combined); } GPU_link(mat, "mtex_alpha_to_col", shr->combined, shr->alpha, &shr->combined); - if(ma->shade_flag & MA_OBCOLOR) + if (ma->shade_flag & MA_OBCOLOR) GPU_link(mat, "shade_obcolor", shr->combined, GPU_builtin(GPU_OBCOLOR), &shr->combined); - if(world && (world->mode & WO_MIST) && !(ma->mode & MA_NOMIST)) { + if (world && (world->mode & WO_MIST) && !(ma->mode & MA_NOMIST)) { misttype = world->mistype; GPU_link(mat, "shade_mist_factor", GPU_builtin(GPU_VIEW_POSITION), @@ -1403,15 +1405,15 @@ void GPU_shaderesult_set(GPUShadeInput *shi, GPUShadeResult *shr) GPU_uniform(&world->horr), &shr->combined); } - if(!((ma->mode & MA_TRANSP) && (ma->mode & MA_ZTRANSP))) { - if(world && (GPU_link_changed(shr->alpha) || ma->alpha != 1.0f)) + if (!((ma->mode & MA_TRANSP) && (ma->mode & MA_ZTRANSP))) { + if (world && (GPU_link_changed(shr->alpha) || ma->alpha != 1.0f)) GPU_link(mat, "shade_world_mix", GPU_uniform(&world->horr), shr->combined, &shr->combined); GPU_link(mat, "shade_alpha_opaque", shr->combined, &shr->combined); } - if(ma->shade_flag & MA_OBCOLOR) { + if (ma->shade_flag & MA_OBCOLOR) { mat->obcolalpha = 1; GPU_link(mat, "shade_alpha_obcolor", shr->combined, GPU_builtin(GPU_OBCOLOR), &shr->combined); } @@ -1434,15 +1436,15 @@ GPUMaterial *GPU_material_from_blender(Scene *scene, Material *ma) GPUNodeLink *outlink; LinkData *link; - for(link=ma->gpumaterial.first; link; link=link->next) - if(((GPUMaterial*)link->data)->scene == scene) + for (link=ma->gpumaterial.first; link; link=link->next) + if (((GPUMaterial*)link->data)->scene == scene) return link->data; /* allocate material */ mat = GPU_material_construct_begin(ma); mat->scene = scene; - if(!(scene->gm.flag & GAME_GLSL_NO_NODES) && ma->nodetree && ma->use_nodes) { + if (!(scene->gm.flag & GAME_GLSL_NO_NODES) && ma->nodetree && ma->use_nodes) { /* create nodes */ ntreeGPUMaterialNodes(ma->nodetree, mat); } @@ -1452,9 +1454,9 @@ GPUMaterial *GPU_material_from_blender(Scene *scene, Material *ma) GPU_material_output_link(mat, outlink); } - if(!scene_use_new_shading_nodes(scene)) { - if(gpu_do_color_management(mat)) - if(mat->outlink) + if (!scene_use_new_shading_nodes(scene)) { + if (gpu_do_color_management(mat)) + if (mat->outlink) GPU_link(mat, "linearrgb_to_srgb", mat->outlink, &mat->outlink); } @@ -1478,12 +1480,12 @@ void GPU_materials_free(void) Material *ma; extern Material defmaterial; - for(ma=G.main->mat.first; ma; ma=ma->id.next) + for (ma=G.main->mat.first; ma; ma=ma->id.next) GPU_material_free(ma); GPU_material_free(&defmaterial); - for(ob=G.main->object.first; ob; ob=ob->id.next) + for (ob=G.main->object.first; ob; ob=ob->id.next) GPU_lamp_free(ob); } @@ -1508,7 +1510,7 @@ void GPU_lamp_update(GPULamp *lamp, int lay, int hide, float obmat[][4]) void GPU_lamp_update_colors(GPULamp *lamp, float r, float g, float b, float energy) { lamp->energy = energy; - if(lamp->mode & LA_NEG) lamp->energy= -lamp->energy; + if (lamp->mode & LA_NEG) lamp->energy= -lamp->energy; lamp->col[0]= r* lamp->energy; lamp->col[1]= g* lamp->energy; @@ -1529,7 +1531,7 @@ static void gpu_lamp_from_blender(Scene *scene, Object *ob, Object *par, Lamp *l lamp->type = la->type; lamp->energy = la->energy; - if(lamp->mode & LA_NEG) lamp->energy= -lamp->energy; + if (lamp->mode & LA_NEG) lamp->energy= -lamp->energy; lamp->col[0]= la->r*lamp->energy; lamp->col[1]= la->g*lamp->energy; @@ -1538,8 +1540,8 @@ static void gpu_lamp_from_blender(Scene *scene, Object *ob, Object *par, Lamp *l GPU_lamp_update(lamp, ob->lay, (ob->restrictflag & OB_RESTRICT_RENDER), ob->obmat); lamp->spotsi= la->spotsize; - if(lamp->mode & LA_HALO) - if(lamp->spotsi > 170.0f) + if (lamp->mode & LA_HALO) + if (lamp->spotsi > 170.0f) lamp->spotsi = 170.0f; lamp->spotsi= cosf((float)M_PI*lamp->spotsi/360.0f); lamp->spotbl= (1.0f - lamp->spotsi)*la->spotblend; @@ -1571,11 +1573,11 @@ static void gpu_lamp_from_blender(Scene *scene, Object *ob, Object *par, Lamp *l static void gpu_lamp_shadow_free(GPULamp *lamp) { - if(lamp->tex) { + if (lamp->tex) { GPU_texture_free(lamp->tex); lamp->tex= NULL; } - if(lamp->fb) { + if (lamp->fb) { GPU_framebuffer_free(lamp->fb); lamp->fb= NULL; } @@ -1587,10 +1589,10 @@ GPULamp *GPU_lamp_from_blender(Scene *scene, Object *ob, Object *par) GPULamp *lamp; LinkData *link; - for(link=ob->gpulamp.first; link; link=link->next) { + for (link=ob->gpulamp.first; link; link=link->next) { lamp = (GPULamp*)link->data; - if(lamp->par == par && lamp->scene == scene) + if (lamp->par == par && lamp->scene == scene) return link->data; } @@ -1603,21 +1605,21 @@ GPULamp *GPU_lamp_from_blender(Scene *scene, Object *ob, Object *par) la = ob->data; gpu_lamp_from_blender(scene, ob, par, la, lamp); - if(la->type==LA_SPOT && (la->mode & LA_SHAD_BUF)) { + if (la->type==LA_SPOT && (la->mode & LA_SHAD_BUF)) { /* opengl */ lamp->fb = GPU_framebuffer_create(); - if(!lamp->fb) { + if (!lamp->fb) { gpu_lamp_shadow_free(lamp); return lamp; } lamp->tex = GPU_texture_create_depth(lamp->size, lamp->size, NULL); - if(!lamp->tex) { + if (!lamp->tex) { gpu_lamp_shadow_free(lamp); return lamp; } - if(!GPU_framebuffer_texture_attach(lamp->fb, lamp->tex, NULL)) { + if (!GPU_framebuffer_texture_attach(lamp->fb, lamp->tex, NULL)) { gpu_lamp_shadow_free(lamp); return lamp; } @@ -1635,7 +1637,7 @@ void GPU_lamp_free(Object *ob) LinkData *nlink; Material *ma; - for(link=ob->gpulamp.first; link; link=link->next) { + for (link=ob->gpulamp.first; link; link=link->next) { lamp = link->data; while(lamp->materials.first) { @@ -1643,7 +1645,7 @@ void GPU_lamp_free(Object *ob) ma = nlink->data; BLI_freelinkN(&lamp->materials, nlink); - if(ma->gpumaterial.first) + if (ma->gpumaterial.first) GPU_material_free(ma); } @@ -1706,7 +1708,7 @@ void GPU_lamp_shadow_buffer_unbind(GPULamp *lamp) int GPU_lamp_shadow_layer(GPULamp *lamp) { - if(lamp->fb && lamp->tex && (lamp->mode & (LA_LAYER|LA_LAYER_SHADOW))) + if (lamp->fb && lamp->tex && (lamp->mode & (LA_LAYER|LA_LAYER_SHADOW))) return lamp->lay; else return -1; @@ -1739,19 +1741,19 @@ GPUShaderExport *GPU_shader_export(struct Scene *scene, struct Material *ma) GLint lastbindcode; int i, liblen, fraglen; - if(!GPU_glsl_support()) + if (!GPU_glsl_support()) return NULL; mat = GPU_material_from_blender(scene, ma); pass = (mat)? mat->pass: NULL; - if(pass && pass->fragmentcode && pass->vertexcode) { + if (pass && pass->fragmentcode && pass->vertexcode) { shader = MEM_callocN(sizeof(GPUShaderExport), "GPUShaderExport"); - for(input = pass->inputs.first; input; input = input->next) { + for (input = pass->inputs.first; input; input = input->next) { uniform = MEM_callocN(sizeof(GPUInputUniform), "GPUInputUniform"); - if(input->ima) { + if (input->ima) { /* image sampler uniform */ uniform->type = GPU_DYNAMIC_SAMPLER_2DIMAGE; uniform->datatype = GPU_DATA_1I; @@ -1759,7 +1761,7 @@ GPUShaderExport *GPU_shader_export(struct Scene *scene, struct Material *ma) uniform->texnumber = input->texid; BLI_strncpy(uniform->varname, input->shadername, sizeof(uniform->varname)); } - else if(input->tex) { + else if (input->tex) { /* generated buffer */ uniform->texnumber = input->texid; uniform->datatype = GPU_DATA_1I; @@ -1771,7 +1773,7 @@ GPUShaderExport *GPU_shader_export(struct Scene *scene, struct Material *ma) uniform->lamp = input->dynamicdata; break; case GPU_TEX2D: - if(GPU_texture_opengl_bindcode(input->tex)) { + if (GPU_texture_opengl_bindcode(input->tex)) { uniform->type = GPU_DYNAMIC_SAMPLER_2DBUFFER; glGetIntegerv(GL_TEXTURE_BINDING_2D, &lastbindcode); glBindTexture(GL_TEXTURE_2D, GPU_texture_opengl_bindcode(input->tex)); @@ -1807,19 +1809,19 @@ GPUShaderExport *GPU_shader_export(struct Scene *scene, struct Material *ma) break; } - if(uniform->type >= GPU_DYNAMIC_LAMP_FIRST && uniform->type <= GPU_DYNAMIC_LAMP_LAST) + if (uniform->type >= GPU_DYNAMIC_LAMP_FIRST && uniform->type <= GPU_DYNAMIC_LAMP_LAST) uniform->lamp = input->dynamicdata; } - if(uniform->type != GPU_DYNAMIC_NONE) + if (uniform->type != GPU_DYNAMIC_NONE) BLI_addtail(&shader->uniforms, uniform); else MEM_freeN(uniform); } /* process builtin uniform */ - for(i=0; builtins[i].gputype; i++) { - if(mat->builtins & builtins[i].gputype) { + for (i=0; builtins[i].gputype; i++) { + if (mat->builtins & builtins[i].gputype) { uniform = MEM_callocN(sizeof(GPUInputUniform), "GPUInputUniform"); uniform->type = builtins[i].dynamictype; uniform->datatype = builtins[i].datatype; @@ -1833,13 +1835,13 @@ GPUShaderExport *GPU_shader_export(struct Scene *scene, struct Material *ma) liblen = (pass->libcode) ? strlen(pass->libcode) : 0; fraglen = strlen(pass->fragmentcode); shader->fragment = (char *)MEM_mallocN(liblen+fraglen+1, "GPUFragShader"); - if(pass->libcode) + if (pass->libcode) memcpy(shader->fragment, pass->libcode, liblen); memcpy(&shader->fragment[liblen], pass->fragmentcode, fraglen); shader->fragment[liblen+fraglen] = 0; // export the attribute - for(i=0; i<mat->attribs.totlayer; i++) { + for (i=0; i<mat->attribs.totlayer; i++) { attribute = MEM_callocN(sizeof(GPUInputAttribute), "GPUInputAttribute"); attribute->type = mat->attribs.layer[i].type; attribute->number = mat->attribs.layer[i].glindex; @@ -1862,7 +1864,7 @@ GPUShaderExport *GPU_shader_export(struct Scene *scene, struct Material *ma) break; } - if(attribute->datatype != GPU_DATA_NONE) + if (attribute->datatype != GPU_DATA_NONE) BLI_addtail(&shader->attributes, attribute); else MEM_freeN(attribute); @@ -1879,19 +1881,19 @@ void GPU_free_shader_export(GPUShaderExport *shader) { GPUInputUniform *uniform; - if(shader == NULL) + if (shader == NULL) return; - for(uniform = shader->uniforms.first; uniform; uniform=uniform->next) - if(uniform->texpixels) + for (uniform = shader->uniforms.first; uniform; uniform=uniform->next) + if (uniform->texpixels) MEM_freeN(uniform->texpixels); BLI_freelistN(&shader->uniforms); BLI_freelistN(&shader->attributes); - if(shader->vertex) + if (shader->vertex) MEM_freeN(shader->vertex); - if(shader->fragment) + if (shader->fragment) MEM_freeN(shader->fragment); MEM_freeN(shader); diff --git a/source/blender/imbuf/intern/allocimbuf.c b/source/blender/imbuf/intern/allocimbuf.c index d85251a8ccb..2cfdd7bc324 100644 --- a/source/blender/imbuf/intern/allocimbuf.c +++ b/source/blender/imbuf/intern/allocimbuf.c @@ -51,8 +51,8 @@ void imb_freemipmapImBuf(ImBuf *ibuf) { int a; - for(a=1; a<ibuf->miptot; a++) { - if(ibuf->mipmap[a-1]) + for (a=1; a<ibuf->miptot; a++) { + if (ibuf->mipmap[a-1]) IMB_freeImBuf(ibuf->mipmap[a-1]); ibuf->mipmap[a-1]= NULL; } @@ -63,9 +63,9 @@ void imb_freemipmapImBuf(ImBuf *ibuf) /* any free rect frees mipmaps to be sure, creation is in render on first request */ void imb_freerectfloatImBuf(ImBuf *ibuf) { - if(ibuf==NULL) return; + if (ibuf==NULL) return; - if(ibuf->rect_float && (ibuf->mall & IB_rectfloat)) { + if (ibuf->rect_float && (ibuf->mall & IB_rectfloat)) { MEM_freeN(ibuf->rect_float); ibuf->rect_float=NULL; } @@ -79,9 +79,9 @@ void imb_freerectfloatImBuf(ImBuf *ibuf) /* any free rect frees mipmaps to be sure, creation is in render on first request */ void imb_freerectImBuf(ImBuf *ibuf) { - if(ibuf==NULL) return; + if (ibuf==NULL) return; - if(ibuf->rect && (ibuf->mall & IB_rect)) + if (ibuf->rect && (ibuf->mall & IB_rect)) MEM_freeN(ibuf->rect); ibuf->rect= NULL; @@ -94,12 +94,12 @@ void imb_freetilesImBuf(ImBuf *ibuf) { int tx, ty; - if(ibuf==NULL) return; + if (ibuf==NULL) return; - if(ibuf->tiles && (ibuf->mall & IB_tiles)) { - for(ty=0; ty<ibuf->ytiles; ty++) { - for(tx=0; tx<ibuf->xtiles; tx++) { - if(ibuf->tiles[ibuf->xtiles*ty + tx]) { + if (ibuf->tiles && (ibuf->mall & IB_tiles)) { + for (ty=0; ty<ibuf->ytiles; ty++) { + for (tx=0; tx<ibuf->xtiles; tx++) { + if (ibuf->tiles[ibuf->xtiles*ty + tx]) { imb_tile_cache_tile_free(ibuf, tx, ty); MEM_freeN(ibuf->tiles[ibuf->xtiles*ty + tx]); } @@ -115,9 +115,9 @@ void imb_freetilesImBuf(ImBuf *ibuf) static void freeencodedbufferImBuf(ImBuf *ibuf) { - if(ibuf==NULL) return; + if (ibuf==NULL) return; - if(ibuf->encodedbuffer && (ibuf->mall & IB_mem)) + if (ibuf->encodedbuffer && (ibuf->mall & IB_mem)) MEM_freeN(ibuf->encodedbuffer); ibuf->encodedbuffer = NULL; @@ -128,9 +128,9 @@ static void freeencodedbufferImBuf(ImBuf *ibuf) void IMB_freezbufImBuf(ImBuf *ibuf) { - if(ibuf==NULL) return; + if (ibuf==NULL) return; - if(ibuf->zbuf && (ibuf->mall & IB_zbuf)) + if (ibuf->zbuf && (ibuf->mall & IB_zbuf)) MEM_freeN(ibuf->zbuf); ibuf->zbuf= NULL; @@ -139,9 +139,9 @@ void IMB_freezbufImBuf(ImBuf *ibuf) void IMB_freezbuffloatImBuf(ImBuf *ibuf) { - if(ibuf==NULL) return; + if (ibuf==NULL) return; - if(ibuf->zbuf_float && (ibuf->mall & IB_zbuffloat)) + if (ibuf->zbuf_float && (ibuf->mall & IB_zbuffloat)) MEM_freeN(ibuf->zbuf_float); ibuf->zbuf_float= NULL; @@ -150,8 +150,8 @@ void IMB_freezbuffloatImBuf(ImBuf *ibuf) void IMB_freeImBuf(ImBuf *ibuf) { - if(ibuf) { - if(ibuf->refcounter > 0) { + if (ibuf) { + if (ibuf->refcounter > 0) { ibuf->refcounter--; } else { @@ -189,12 +189,12 @@ short addzbufImBuf(ImBuf *ibuf) { int size; - if(ibuf==NULL) return FALSE; + if (ibuf==NULL) return FALSE; IMB_freezbufImBuf(ibuf); size = ibuf->x *ibuf->y *sizeof(unsigned int); - if((ibuf->zbuf = MEM_mapallocN(size, "addzbufImBuf"))) { + if ((ibuf->zbuf = MEM_mapallocN(size, "addzbufImBuf"))) { ibuf->mall |= IB_zbuf; ibuf->flags |= IB_zbuf; return TRUE; @@ -207,12 +207,12 @@ short addzbuffloatImBuf(ImBuf *ibuf) { int size; - if(ibuf==NULL) return FALSE; + if (ibuf==NULL) return FALSE; IMB_freezbuffloatImBuf(ibuf); size = ibuf->x *ibuf->y *sizeof(float); - if((ibuf->zbuf_float = MEM_mapallocN(size, "addzbuffloatImBuf"))) { + if ((ibuf->zbuf_float = MEM_mapallocN(size, "addzbuffloatImBuf"))) { ibuf->mall |= IB_zbuffloat; ibuf->flags |= IB_zbuffloat; return TRUE; @@ -224,16 +224,16 @@ short addzbuffloatImBuf(ImBuf *ibuf) short imb_addencodedbufferImBuf(ImBuf *ibuf) { - if(ibuf==NULL) return FALSE; + if (ibuf==NULL) return FALSE; freeencodedbufferImBuf(ibuf); - if(ibuf->encodedbuffersize == 0) + if (ibuf->encodedbuffersize == 0) ibuf->encodedbuffersize = 10000; ibuf->encodedsize = 0; - if((ibuf->encodedbuffer = MEM_mallocN(ibuf->encodedbuffersize, "addencodedbufferImBuf"))) { + if ((ibuf->encodedbuffer = MEM_mallocN(ibuf->encodedbuffersize, "addencodedbufferImBuf"))) { ibuf->mall |= IB_mem; ibuf->flags |= IB_mem; return TRUE; @@ -248,22 +248,23 @@ short imb_enlargeencodedbufferImBuf(ImBuf *ibuf) unsigned int newsize, encodedsize; void *newbuffer; - if(ibuf==NULL) return FALSE; + if (ibuf==NULL) return FALSE; - if(ibuf->encodedbuffersize < ibuf->encodedsize) { + if (ibuf->encodedbuffersize < ibuf->encodedsize) { printf("imb_enlargeencodedbufferImBuf: error in parameters\n"); return FALSE; } newsize = 2 *ibuf->encodedbuffersize; - if(newsize < 10000) newsize = 10000; + if (newsize < 10000) newsize = 10000; newbuffer = MEM_mallocN(newsize, "enlargeencodedbufferImBuf"); - if(newbuffer == NULL) return FALSE; + if (newbuffer == NULL) return FALSE; - if(ibuf->encodedbuffer) { + if (ibuf->encodedbuffer) { memcpy(newbuffer, ibuf->encodedbuffer, ibuf->encodedsize); - } else { + } + else { ibuf->encodedsize = 0; } @@ -284,16 +285,16 @@ short imb_addrectfloatImBuf(ImBuf *ibuf) { int size; - if(ibuf==NULL) return FALSE; + if (ibuf==NULL) return FALSE; - if(ibuf->rect_float) + if (ibuf->rect_float) imb_freerectfloatImBuf(ibuf); /* frees mipmap too, hrm */ size = ibuf->x *ibuf->y; size = size *4 *sizeof(float); ibuf->channels= 4; - if((ibuf->rect_float = MEM_mapallocN(size, "imb_addrectfloatImBuf"))) { + if ((ibuf->rect_float = MEM_mapallocN(size, "imb_addrectfloatImBuf"))) { ibuf->mall |= IB_rectfloat; ibuf->flags |= IB_rectfloat; return TRUE; @@ -307,20 +308,20 @@ short imb_addrectImBuf(ImBuf *ibuf) { int size; - if(ibuf==NULL) return FALSE; + if (ibuf==NULL) return FALSE; /* don't call imb_freerectImBuf, it frees mipmaps, this call is used only too give float buffers display */ - if(ibuf->rect && (ibuf->mall & IB_rect)) + if (ibuf->rect && (ibuf->mall & IB_rect)) MEM_freeN(ibuf->rect); ibuf->rect= NULL; size = ibuf->x*ibuf->y; size = size*sizeof(unsigned int); - if((ibuf->rect = MEM_mapallocN(size, "imb_addrectImBuf"))) { + if ((ibuf->rect = MEM_mapallocN(size, "imb_addrectImBuf"))) { ibuf->mall |= IB_rect; ibuf->flags |= IB_rect; - if(ibuf->planes > 32) return (addzbufImBuf(ibuf)); + if (ibuf->planes > 32) return (addzbufImBuf(ibuf)); else return TRUE; } @@ -329,10 +330,10 @@ short imb_addrectImBuf(ImBuf *ibuf) short imb_addtilesImBuf(ImBuf *ibuf) { - if(ibuf==NULL) return FALSE; + if (ibuf==NULL) return FALSE; - if(!ibuf->tiles) - if((ibuf->tiles = MEM_callocN(sizeof(unsigned int*)*ibuf->xtiles*ibuf->ytiles, "imb_tiles"))) + if (!ibuf->tiles) + if ((ibuf->tiles = MEM_callocN(sizeof(unsigned int*)*ibuf->xtiles*ibuf->ytiles, "imb_tiles"))) ibuf->mall |= IB_tiles; return (ibuf->tiles != NULL); @@ -344,7 +345,7 @@ ImBuf *IMB_allocImBuf(unsigned int x, unsigned int y, uchar planes, unsigned int ibuf = MEM_callocN(sizeof(ImBuf), "ImBuf_struct"); - if(ibuf) { + if (ibuf) { ibuf->x= x; ibuf->y= y; ibuf->planes= planes; @@ -352,29 +353,29 @@ ImBuf *IMB_allocImBuf(unsigned int x, unsigned int y, uchar planes, unsigned int ibuf->channels= 4; /* float option, is set to other values when buffers get assigned */ ibuf->ppm[0]= ibuf->ppm[1]= 150.0 / 0.0254; /* 150dpi -> pixels-per-meter */ - if(flags & IB_rect) { - if(imb_addrectImBuf(ibuf)==FALSE) { + if (flags & IB_rect) { + if (imb_addrectImBuf(ibuf)==FALSE) { IMB_freeImBuf(ibuf); return NULL; } } - if(flags & IB_rectfloat) { - if(imb_addrectfloatImBuf(ibuf)==FALSE) { + if (flags & IB_rectfloat) { + if (imb_addrectfloatImBuf(ibuf)==FALSE) { IMB_freeImBuf(ibuf); return NULL; } } - if(flags & IB_zbuf) { - if(addzbufImBuf(ibuf)==FALSE) { + if (flags & IB_zbuf) { + if (addzbufImBuf(ibuf)==FALSE) { IMB_freeImBuf(ibuf); return NULL; } } - if(flags & IB_zbuffloat) { - if(addzbuffloatImBuf(ibuf)==FALSE) { + if (flags & IB_zbuffloat) { + if (addzbuffloatImBuf(ibuf)==FALSE) { IMB_freeImBuf(ibuf); return NULL; } @@ -390,27 +391,27 @@ ImBuf *IMB_dupImBuf(ImBuf *ibuf1) int flags = 0; int a, x, y; - if(ibuf1 == NULL) return NULL; + if (ibuf1 == NULL) return NULL; - if(ibuf1->rect) flags |= IB_rect; - if(ibuf1->rect_float) flags |= IB_rectfloat; + if (ibuf1->rect) flags |= IB_rect; + if (ibuf1->rect_float) flags |= IB_rectfloat; x = ibuf1->x; y = ibuf1->y; - if(ibuf1->flags & IB_fields) y *= 2; + if (ibuf1->flags & IB_fields) y *= 2; ibuf2 = IMB_allocImBuf(x, y, ibuf1->planes, flags); - if(ibuf2 == NULL) return NULL; + if (ibuf2 == NULL) return NULL; - if(flags & IB_rect) + if (flags & IB_rect) memcpy(ibuf2->rect, ibuf1->rect, x *y *sizeof(int)); - if(flags & IB_rectfloat) + if (flags & IB_rectfloat) memcpy(ibuf2->rect_float, ibuf1->rect_float, ibuf1->channels *x *y *sizeof(float)); - if(ibuf1->encodedbuffer) { + if (ibuf1->encodedbuffer) { ibuf2->encodedbuffersize = ibuf1->encodedbuffersize; - if(imb_addencodedbufferImBuf(ibuf2) == FALSE) { + if (imb_addencodedbufferImBuf(ibuf2) == FALSE) { IMB_freeImBuf(ibuf2); return NULL; } @@ -427,7 +428,7 @@ ImBuf *IMB_dupImBuf(ImBuf *ibuf1) tbuf.encodedbuffer = ibuf2->encodedbuffer; tbuf.zbuf= NULL; tbuf.zbuf_float= NULL; - for(a=0; a<IB_MIPMAP_LEVELS; a++) + for (a=0; a<IB_MIPMAP_LEVELS; a++) tbuf.mipmap[a]= NULL; // set malloc flag @@ -464,7 +465,7 @@ static MEM_CacheLimiterC **get_imbuf_cache_limiter(void) { static MEM_CacheLimiterC *c = NULL; - if(!c) + if (!c) c = new_MEM_CacheLimiter(imbuf_cache_destructor, NULL); return &c; diff --git a/source/blender/imbuf/intern/anim_movie.c b/source/blender/imbuf/intern/anim_movie.c index 2719f2e296b..5ef783fe968 100644 --- a/source/blender/imbuf/intern/anim_movie.c +++ b/source/blender/imbuf/intern/anim_movie.c @@ -135,21 +135,23 @@ static int an_stringdec(const char *string, char* head, char *tail, unsigned sho len=strlen(string); nume = len; - for(i=len-1;i>=0;i--){ + for (i=len-1;i>=0;i--) { if (string[i]==PATHSEPERATOR) break; if (isdigit(string[i])) { - if (found){ + if (found) { nums=i; - } else{ + } + else { nume=i; nums=i; found=TRUE; } - } else{ + } + else { if (found) break; } } - if (found){ + if (found) { strcpy(tail ,&string[nume+1]); strcpy(head, string); head[nums]= '\0'; @@ -188,7 +190,7 @@ static void free_anim_avi (struct anim *anim) anim->pgf = NULL; } - for (i = 0; i < anim->avistreams; i++){ + for (i = 0; i < anim->avistreams; i++) { AVIStreamRelease(anim->pavi[i]); } anim->avistreams = 0; @@ -315,7 +317,8 @@ static int startavi (struct anim *anim) lpbi = (LPBITMAPINFOHEADER)abFormat; anim->avi->header->Height = lpbi->biHeight; anim->avi->header->Width = lpbi->biWidth; - } else { + } + else { FIXCC(avis.fccHandler); FIXCC(avis.fccType); printf("Can't find AVI decoder for type : %4.4hs/%4.4hs\n", @@ -333,11 +336,13 @@ static int startavi (struct anim *anim) // if ((anim->avistreams == 0) || (firstvideo == -1)) { avierror = AVI_ERROR_FORMAT; - } else { + } + else { avierror = AVI_ERROR_NONE; anim->firstvideo = firstvideo; } - } else { + } + else { AVIFileExit(); } } @@ -386,7 +391,8 @@ static ImBuf * avi_fetchibuf (struct anim *anim, int position) //Oh brother... } } - } else { + } + else { #else if (1) { #endif @@ -442,11 +448,11 @@ static int startffmpeg(struct anim * anim) do_init_ffmpeg(); - if(av_open_input_file(&pFormatCtx, anim->name, NULL, 0, NULL)!=0) { + if (av_open_input_file(&pFormatCtx, anim->name, NULL, 0, NULL)!=0) { return -1; } - if(av_find_stream_info(pFormatCtx)<0) { + if (av_find_stream_info(pFormatCtx)<0) { av_close_input_file(pFormatCtx); return -1; } @@ -457,7 +463,7 @@ static int startffmpeg(struct anim * anim) /* Find the video stream */ videoStream = -1; - for(i = 0; i < pFormatCtx->nb_streams; i++) + for (i = 0; i < pFormatCtx->nb_streams; i++) if (pFormatCtx->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO) { if (streamcount > 0) { @@ -468,7 +474,7 @@ static int startffmpeg(struct anim * anim) break; } - if(videoStream==-1) { + if (videoStream==-1) { av_close_input_file(pFormatCtx); return -1; } @@ -477,14 +483,14 @@ static int startffmpeg(struct anim * anim) /* Find the decoder for the video stream */ pCodec = avcodec_find_decoder(pCodecCtx->codec_id); - if(pCodec == NULL) { + if (pCodec == NULL) { av_close_input_file(pFormatCtx); return -1; } pCodecCtx->workaround_bugs = 1; - if(avcodec_open(pCodecCtx, pCodec) < 0) { + if (avcodec_open(pCodecCtx, pCodec) < 0) { av_close_input_file(pFormatCtx); return -1; } @@ -554,7 +560,8 @@ static int startffmpeg(struct anim * anim) if (pCodecCtx->has_b_frames) { anim->preseek = 25; /* FIXME: detect gopsize ... */ - } else { + } + else { anim->preseek = 0; } @@ -588,7 +595,7 @@ static int startffmpeg(struct anim * anim) srcRange = srcRange || anim->pCodecCtx->color_range == AVCOL_RANGE_JPEG; inv_table = sws_getCoefficients(anim->pCodecCtx->colorspace); - if(sws_setColorspaceDetails(anim->img_convert_ctx, (int *)inv_table, srcRange, + if (sws_setColorspaceDetails(anim->img_convert_ctx, (int *)inv_table, srcRange, table, dstRange, brightness, contrast, saturation)) { printf("Warning: Could not set libswscale colorspace details.\n"); @@ -623,7 +630,7 @@ static void ffmpeg_postprocess(struct anim * anim) /* This means the data wasnt read properly, * this check stops crashing */ if (input->data[0]==0 && input->data[1]==0 - && input->data[2]==0 && input->data[3]==0){ + && input->data[2]==0 && input->data[3]==0) { fprintf(stderr, "ffmpeg_fetchibuf: " "data not read properly...\n"); return; @@ -646,7 +653,8 @@ static void ffmpeg_postprocess(struct anim * anim) anim->pCodecCtx->height) < 0) { filter_y = TRUE; - } else { + } + else { input = anim->pFrameDeinterlaced; } } @@ -701,7 +709,8 @@ static void ffmpeg_postprocess(struct anim * anim) } top -= 8 * w; } - } else { + } + else { int * dstStride = anim->pFrameRGB->linesize; uint8_t** dst = anim->pFrameRGB->data; int dstStride2[4] = { -dstStride[0], 0, 0, 0 }; @@ -735,7 +744,7 @@ static int ffmpeg_decode_video_frame(struct anim * anim) anim->next_packet.stream_index = -1; } - while((rval = av_read_frame(anim->pFormatCtx, &anim->next_packet)) >= 0) { + while ((rval = av_read_frame(anim->pFormatCtx, &anim->next_packet)) >= 0) { av_log(anim->pFormatCtx, AV_LOG_DEBUG, "%sREAD: strID=%d (VID: %d) dts=%lld pts=%lld " @@ -821,7 +830,8 @@ static void ffmpeg_decode_video_frame_scan( if (anim->next_pts == pts_to_search) { av_log(anim->pFormatCtx, AV_LOG_DEBUG, "SCAN HAPPY: we found our PTS!\n"); - } else { + } + else { av_log(anim->pFormatCtx, AV_LOG_ERROR, "SCAN UNHAPPY: PTS not matched!\n"); } @@ -900,7 +910,8 @@ static ImBuf * ffmpeg_fetchibuf(struct anim * anim, int position, tc_index, anim->curposition); pts_to_search = IMB_indexer_get_pts( tc_index, new_frame_index); - } else { + } + else { pts_to_search = (long long) floor(((double) position) / pts_time_base / frame_rate + 0.5); @@ -917,7 +928,7 @@ static ImBuf * ffmpeg_fetchibuf(struct anim * anim, int position, (long long int)pts_to_search,pts_time_base, frame_rate, st_time); if (anim->last_frame && - anim->last_pts <= pts_to_search && anim->next_pts > pts_to_search){ + anim->last_pts <= pts_to_search && anim->next_pts > pts_to_search) { av_log(anim->pFormatCtx, AV_LOG_DEBUG, "FETCH: frame repeat: last: %lld next: %lld\n", (long long int)anim->last_pts, @@ -935,7 +946,8 @@ static ImBuf * ffmpeg_fetchibuf(struct anim * anim, int position, "FETCH: within preseek interval (no index)\n"); ffmpeg_decode_video_frame_scan(anim, pts_to_search); - } else if (tc_index && + } + else if (tc_index && IMB_indexer_can_scan(tc_index, old_frame_index, new_frame_index)) { @@ -944,7 +956,8 @@ static ImBuf * ffmpeg_fetchibuf(struct anim * anim, int position, "(index tells us)\n"); ffmpeg_decode_video_frame_scan(anim, pts_to_search); - } else if (position != anim->curposition + 1) { + } + else if (position != anim->curposition + 1) { long long pos; int ret; @@ -969,14 +982,16 @@ static ImBuf * ffmpeg_fetchibuf(struct anim * anim, int position, -1, pos, AVSEEK_FLAG_BYTE); av_update_cur_dts(anim->pFormatCtx, v_st, dts); - } else { + } + else { av_log(anim->pFormatCtx, AV_LOG_DEBUG, "... using DTS pos\n"); ret = av_seek_frame(anim->pFormatCtx, anim->videoStream, dts, AVSEEK_FLAG_BACKWARD); } - } else { + } + else { pos = (long long) (position - anim->preseek) * AV_TIME_BASE / frame_rate; @@ -1021,10 +1036,12 @@ static ImBuf * ffmpeg_fetchibuf(struct anim * anim, int position, if (ret >= 0) { ffmpeg_decode_video_frame_scan(anim, pts_to_search); } - } else if (position == 0 && anim->curposition == -1) { + } + else if (position == 0 && anim->curposition == -1) { /* first frame without seeking special case... */ ffmpeg_decode_video_frame(anim); - } else { + } + else { av_log(anim->pFormatCtx, AV_LOG_DEBUG, "FETCH: no seek necessary, just continue...\n"); } diff --git a/source/blender/imbuf/intern/bmp.c b/source/blender/imbuf/intern/bmp.c index 1e13f5d913b..768aa518742 100644 --- a/source/blender/imbuf/intern/bmp.c +++ b/source/blender/imbuf/intern/bmp.c @@ -78,7 +78,8 @@ static int checkbmp(unsigned char *mem) if ((mem[0] == 'B') && (mem[1] == 'M')) { /* skip fileheader */ mem += BMP_FILEHEADER_SIZE; - } else { + } + else { } /* for systems where an int needs to be 4 bytes aligned */ @@ -138,7 +139,8 @@ struct ImBuf *imb_bmp_decode(unsigned char *mem, size_t size, int flags) if (flags & IB_test) { ibuf = IMB_allocImBuf(x, y, depth, 0); - } else { + } + else { ibuf = IMB_allocImBuf(x, y, depth, IB_rect); bmp = mem + skip; rect = (unsigned char *) ibuf->rect; @@ -154,7 +156,8 @@ struct ImBuf *imb_bmp_decode(unsigned char *mem, size_t size, int flags) rect += 4; bmp += 2; } - } else if (depth == 24) { + } + else if (depth == 24) { for (i = y; i > 0; i--) { int j; for (j = x ; j > 0; j--) { @@ -168,7 +171,8 @@ struct ImBuf *imb_bmp_decode(unsigned char *mem, size_t size, int flags) /* for 24-bit images, rows are padded to multiples of 4 */ bmp += x % 4; } - } else if (depth == 32) { + } + else if (depth == 32) { for (i = x * y; i > 0; i--) { rect[0] = bmp[2]; rect[1] = bmp[1]; diff --git a/source/blender/imbuf/intern/cache.c b/source/blender/imbuf/intern/cache.c index 3bac570da4e..ba9b118d185 100644 --- a/source/blender/imbuf/intern/cache.c +++ b/source/blender/imbuf/intern/cache.c @@ -106,8 +106,8 @@ static int imb_global_tile_cmp(const void *a_p, const void *b_p) const ImGlobalTile *a= a_p; const ImGlobalTile *b= b_p; - if(a->ibuf == b->ibuf && a->tx == b->tx && a->ty == b->ty) return 0; - else if(a->ibuf < b->ibuf || a->tx < b->tx || a->ty < b->ty) return -1; + if (a->ibuf == b->ibuf && a->tx == b->tx && a->ty == b->ty) return 0; + else if (a->ibuf < b->ibuf || a->tx < b->tx || a->ty < b->ty) return -1; else return 1; } @@ -123,8 +123,8 @@ static int imb_thread_tile_cmp(const void *a_p, const void *b_p) const ImThreadTile *a= a_p; const ImThreadTile *b= b_p; - if(a->ibuf == b->ibuf && a->tx == b->tx && a->ty == b->ty) return 0; - else if(a->ibuf < b->ibuf || a->tx < b->tx || a->ty < b->ty) return -1; + if (a->ibuf == b->ibuf && a->tx == b->tx && a->ty == b->ty) return 0; + else if (a->ibuf < b->ibuf || a->tx < b->tx || a->ty < b->ty) return -1; else return 1; } @@ -164,9 +164,9 @@ void imb_tile_cache_tile_free(ImBuf *ibuf, int tx, int ty) lookuptile.ty = ty; gtile= BLI_ghash_lookup(GLOBAL_CACHE.tilehash, &lookuptile); - if(gtile) { + if (gtile) { /* in case another thread is loading this */ - while(gtile->loading) + while (gtile->loading) ; BLI_ghash_remove(GLOBAL_CACHE.tilehash, gtile, NULL, NULL); @@ -189,7 +189,7 @@ static void imb_thread_cache_init(ImThreadTileCache *cache) cache->tilehash= BLI_ghash_new(imb_thread_tile_hash, imb_thread_tile_cmp, "imb_thread_cache_init gh"); /* pre-allocate all thread local tiles in unused list */ - for(a=0; a<IB_THREAD_CACHE_SIZE; a++) { + for (a=0; a<IB_THREAD_CACHE_SIZE; a++) { ttile= BLI_memarena_alloc(GLOBAL_CACHE.memarena, sizeof(ImThreadTile)); BLI_addtail(&cache->unused, ttile); } @@ -218,17 +218,17 @@ void imb_tile_cache_exit(void) ImGlobalTile *gtile; int a; - if(GLOBAL_CACHE.initialized) { - for(gtile=GLOBAL_CACHE.tiles.first; gtile; gtile=gtile->next) + if (GLOBAL_CACHE.initialized) { + for (gtile=GLOBAL_CACHE.tiles.first; gtile; gtile=gtile->next) imb_global_cache_tile_unload(gtile); - for(a=0; a<GLOBAL_CACHE.totthread; a++) + for (a=0; a<GLOBAL_CACHE.totthread; a++) imb_thread_cache_exit(&GLOBAL_CACHE.thread_cache[a]); - if(GLOBAL_CACHE.memarena) + if (GLOBAL_CACHE.memarena) BLI_memarena_free(GLOBAL_CACHE.memarena); - if(GLOBAL_CACHE.tilehash) + if (GLOBAL_CACHE.tilehash) BLI_ghash_free(GLOBAL_CACHE.tilehash, NULL, NULL); BLI_mutex_end(&GLOBAL_CACHE.mutex); @@ -246,7 +246,7 @@ void IMB_tile_cache_params(int totthread, int maxmem) totthread++; /* lazy initialize cache */ - if(GLOBAL_CACHE.totthread == totthread && GLOBAL_CACHE.maxmem == maxmem) + if (GLOBAL_CACHE.totthread == totthread && GLOBAL_CACHE.maxmem == maxmem) return; imb_tile_cache_exit(); @@ -261,7 +261,7 @@ void IMB_tile_cache_params(int totthread, int maxmem) GLOBAL_CACHE.maxmem= maxmem*1024*1024; GLOBAL_CACHE.totthread= totthread; - for(a=0; a<totthread; a++) + for (a=0; a<totthread; a++) imb_thread_cache_init(&GLOBAL_CACHE.thread_cache[a]); BLI_mutex_init(&GLOBAL_CACHE.mutex); @@ -275,7 +275,7 @@ static ImGlobalTile *imb_global_cache_get_tile(ImBuf *ibuf, int tx, int ty, ImGl BLI_mutex_lock(&GLOBAL_CACHE.mutex); - if(replacetile) + if (replacetile) replacetile->refcount--; /* find tile in global cache */ @@ -284,7 +284,7 @@ static ImGlobalTile *imb_global_cache_get_tile(ImBuf *ibuf, int tx, int ty, ImGl lookuptile.ty = ty; gtile= BLI_ghash_lookup(GLOBAL_CACHE.tilehash, &lookuptile); - if(gtile) { + if (gtile) { /* found tile. however it may be in the process of being loaded * by another thread, in that case we do stupid busy loop waiting * for the other thread to load the tile */ @@ -292,21 +292,21 @@ static ImGlobalTile *imb_global_cache_get_tile(ImBuf *ibuf, int tx, int ty, ImGl BLI_mutex_unlock(&GLOBAL_CACHE.mutex); - while(gtile->loading) + while (gtile->loading) ; } else { /* not found, let's load it from disk */ /* first check if we hit the memory limit */ - if(GLOBAL_CACHE.maxmem && GLOBAL_CACHE.totmem > GLOBAL_CACHE.maxmem) { + if (GLOBAL_CACHE.maxmem && GLOBAL_CACHE.totmem > GLOBAL_CACHE.maxmem) { /* find an existing tile to unload */ - for(gtile=GLOBAL_CACHE.tiles.last; gtile; gtile=gtile->prev) - if(gtile->refcount == 0 && gtile->loading == 0) + for (gtile=GLOBAL_CACHE.tiles.last; gtile; gtile=gtile->prev) + if (gtile->refcount == 0 && gtile->loading == 0) break; } - if(gtile) { + if (gtile) { /* found a tile to unload */ imb_global_cache_tile_unload(gtile); BLI_ghash_remove(GLOBAL_CACHE.tilehash, gtile, NULL, NULL); @@ -314,7 +314,7 @@ static ImGlobalTile *imb_global_cache_get_tile(ImBuf *ibuf, int tx, int ty, ImGl } else { /* allocate a new tile or reuse unused */ - if(GLOBAL_CACHE.unused.first) { + if (GLOBAL_CACHE.unused.first) { gtile= GLOBAL_CACHE.unused.first; BLI_remlink(&GLOBAL_CACHE.unused, gtile); } @@ -356,9 +356,9 @@ static unsigned int *imb_thread_cache_get_tile(ImThreadTileCache *cache, ImBuf * int toffs= ibuf->xtiles*ty + tx; /* test if it is already in our thread local cache */ - if((ttile=cache->tiles.first)) { + if ((ttile=cache->tiles.first)) { /* check last used tile before going to hash */ - if(ttile->ibuf == ibuf && ttile->tx == tx && ttile->ty == ty) + if (ttile->ibuf == ibuf && ttile->tx == tx && ttile->ty == ty) return ibuf->tiles[toffs]; /* find tile in hash */ @@ -366,7 +366,7 @@ static unsigned int *imb_thread_cache_get_tile(ImThreadTileCache *cache, ImBuf * lookuptile.tx = tx; lookuptile.ty = ty; - if((ttile=BLI_ghash_lookup(cache->tilehash, &lookuptile))) { + if ((ttile=BLI_ghash_lookup(cache->tilehash, &lookuptile))) { BLI_remlink(&cache->tiles, ttile); BLI_addhead(&cache->tiles, ttile); @@ -375,7 +375,7 @@ static unsigned int *imb_thread_cache_get_tile(ImThreadTileCache *cache, ImBuf * } /* not found, have to do slow lookup in global cache */ - if(cache->unused.first == NULL) { + if (cache->unused.first == NULL) { ttile= cache->tiles.last; replacetile= ttile->global; BLI_remlink(&cache->tiles, ttile); @@ -412,12 +412,12 @@ void IMB_tiles_to_rect(ImBuf *ibuf) unsigned int *to, *from; int a, tx, ty, y, w, h; - for(a=0; a<ibuf->miptot; a++) { + for (a=0; a<ibuf->miptot; a++) { mipbuf= IMB_getmipmap(ibuf, a); /* don't call imb_addrectImBuf, it frees all mipmaps */ - if(!mipbuf->rect) { - if((mipbuf->rect = MEM_mapallocN(ibuf->x*ibuf->y*sizeof(unsigned int), "imb_addrectImBuf"))) { + if (!mipbuf->rect) { + if ((mipbuf->rect = MEM_mapallocN(ibuf->x*ibuf->y*sizeof(unsigned int), "imb_addrectImBuf"))) { mipbuf->mall |= IB_rect; mipbuf->flags |= IB_rect; } @@ -425,8 +425,8 @@ void IMB_tiles_to_rect(ImBuf *ibuf) break; } - for(ty=0; ty<mipbuf->ytiles; ty++) { - for(tx=0; tx<mipbuf->xtiles; tx++) { + for (ty=0; ty<mipbuf->ytiles; ty++) { + for (tx=0; tx<mipbuf->xtiles; tx++) { /* acquire tile through cache, this assumes cache is initialized, * which it is always now but it's a weak assumption ... */ gtile= imb_global_cache_get_tile(mipbuf, tx, ty, NULL); @@ -439,7 +439,7 @@ void IMB_tiles_to_rect(ImBuf *ibuf) w= (tx == mipbuf->xtiles-1)? mipbuf->x - tx*mipbuf->tilex: mipbuf->tilex; h= (ty == mipbuf->ytiles-1)? mipbuf->y - ty*mipbuf->tiley: mipbuf->tiley; - for(y=0; y<h; y++) { + for (y=0; y<h; y++) { memcpy(to, from, sizeof(unsigned int)*w); from += mipbuf->tilex; to += mipbuf->x; diff --git a/source/blender/imbuf/intern/cineon/cineon_dpx.c b/source/blender/imbuf/intern/cineon/cineon_dpx.c index af964bb2bb3..c1222d3cea3 100644 --- a/source/blender/imbuf/intern/cineon/cineon_dpx.c +++ b/source/blender/imbuf/intern/cineon/cineon_dpx.c @@ -154,7 +154,7 @@ static int imb_save_dpx_cineon(ImBuf *ibuf, const char *filename, int use_cineon if (!logImage) return 0; - if(logImageSetByteConversion(logImage, &conversion)==0) { + if (logImageSetByteConversion(logImage, &conversion)==0) { printf("error setting args\n"); } @@ -184,7 +184,7 @@ static int imb_save_dpx_cineon(ImBuf *ibuf, const char *filename, int use_cineon MEM_freeN(line); - if(is_alloc) { + if (is_alloc) { MEM_freeN(fbuf); } @@ -204,7 +204,7 @@ int imb_is_cineon(unsigned char *buf) ImBuf *imb_loadcineon(unsigned char *mem, size_t size, int flags) { - if(imb_is_cineon(mem)) + if (imb_is_cineon(mem)) return imb_load_dpx_cineon(mem, 1, size, flags); return NULL; } @@ -221,7 +221,7 @@ int imb_is_dpx(unsigned char *buf) ImBuf *imb_loaddpx(unsigned char *mem, size_t size, int flags) { - if(imb_is_dpx(mem)) + if (imb_is_dpx(mem)) return imb_load_dpx_cineon(mem, 0, size, flags); return NULL; } diff --git a/source/blender/imbuf/intern/cineon/cineonlib.c b/source/blender/imbuf/intern/cineon/cineonlib.c index a10d8c67051..ae9f8e0fe97 100644 --- a/source/blender/imbuf/intern/cineon/cineonlib.c +++ b/source/blender/imbuf/intern/cineon/cineonlib.c @@ -136,7 +136,8 @@ fillCineonImageInfo(CineonFile* cineon, CineonImageInformation* imageInfo) { if (cineon->depth == 1) { fillCineonChannelInfo(cineon, &imageInfo->channel[0], 0); - } else if (cineon->depth == 3) { + } + else if (cineon->depth == 3) { fillCineonChannelInfo(cineon, &imageInfo->channel[0], 1); fillCineonChannelInfo(cineon, &imageInfo->channel[1], 2); fillCineonChannelInfo(cineon, &imageInfo->channel[2], 3); @@ -215,7 +216,8 @@ dumpCineonFormatInfo(CineonFormatInformation* formatInfo) { d_printf("Packing %d,", formatInfo->packing); if (formatInfo->packing & 0x80) { d_printf(" multi pixel,"); - } else { + } + else { d_printf(" single pixel,"); } switch (formatInfo->packing & 0x7F) { @@ -231,13 +233,15 @@ dumpCineonFormatInfo(CineonFormatInformation* formatInfo) { d_printf("Sign %d,", formatInfo->signage); if (formatInfo->signage) { d_printf(" signed\n"); - } else { + } + else { d_printf(" unsigned\n"); } d_printf("Sense %d,", formatInfo->signage); if (formatInfo->signage) { d_printf(" negative\n"); - } else { + } + else { d_printf(" positive\n"); } d_printf("End of line padding %ld\n", (intptr_t)ntohl(formatInfo->line_padding)); @@ -362,7 +366,7 @@ cineonGetRowBytes(CineonFile* cineon, unsigned short* row, int y) { /* extract required pixels */ for (pixelIndex = 0; pixelIndex < numPixels; ++pixelIndex) { - if(cineon->params.doLogarithm) + if (cineon->params.doLogarithm) row[pixelIndex] = cineon->lut10_16[cineon->pixelBuffer[pixelIndex]]; else row[pixelIndex] = cineon->pixelBuffer[pixelIndex] << 6; @@ -381,7 +385,7 @@ cineonSetRowBytes(CineonFile* cineon, const unsigned short* row, int y) { /* put new pixels into pixelBuffer */ for (pixelIndex = 0; pixelIndex < numPixels; ++pixelIndex) { - if(cineon->params.doLogarithm) + if (cineon->params.doLogarithm) cineon->pixelBuffer[pixelIndex] = cineon->lut16_16[row[pixelIndex]]; else cineon->pixelBuffer[pixelIndex] = row[pixelIndex] >> 6; @@ -604,7 +608,8 @@ int cineonIsMemFileCineon(unsigned char *mem) if (num != ntohl(CINEON_FILE_MAGIC)) { return 0; - } else return 1; + } + else return 1; } CineonFile* @@ -763,7 +768,8 @@ cineonCreate(const char* filename, int width, int height, int depth) { shortFilename = strrchr(filename, '/'); if (shortFilename == 0) { shortFilename = filename; - } else { + } + else { ++shortFilename; } diff --git a/source/blender/imbuf/intern/cineon/dpxlib.c b/source/blender/imbuf/intern/cineon/dpxlib.c index 01177b01178..c9b9901a495 100644 --- a/source/blender/imbuf/intern/cineon/dpxlib.c +++ b/source/blender/imbuf/intern/cineon/dpxlib.c @@ -142,7 +142,8 @@ fillDpxImageInfo( if (dpx->depth == 1) { fillDpxChannelInfo(dpx, &imageInfo->channel[0], 0); - } else if (dpx->depth == 3) { + } + else if (dpx->depth == 3) { fillDpxChannelInfo(dpx, &imageInfo->channel[0], 50); } } @@ -270,7 +271,8 @@ dpxGetRowBytes(DpxFile* dpx, unsigned short* row, int y) { dpx->pixelBuffer[pixelIndex+2] = t & 0x3ff; pixelIndex += 3; } - } else /* if (dpx->depth == 3) */ { + } + else /* if (dpx->depth == 3) */ { for (longIndex = 0; longIndex < readLongs; ++longIndex) { unsigned int t = ntohl(dpx->lineBuffer[longIndex]); t = t >> 2; @@ -286,7 +288,7 @@ dpxGetRowBytes(DpxFile* dpx, unsigned short* row, int y) { /* extract required pixels */ for (pixelIndex = 0; pixelIndex < numPixels; ++pixelIndex) { - if(dpx->params.doLogarithm) + if (dpx->params.doLogarithm) row[pixelIndex] = dpx->lut10_16[dpx->pixelBuffer[pixelIndex]]; else row[pixelIndex] = dpx->pixelBuffer[pixelIndex] << 6; @@ -329,7 +331,7 @@ dpxSetRowBytes(DpxFile* dpx, const unsigned short* row, int y) { /* put new pixels into pixelBuffer */ for (pixelIndex = 0; pixelIndex < numPixels; ++pixelIndex) { - if(dpx->params.doLogarithm) + if (dpx->params.doLogarithm) dpx->pixelBuffer[dpx->pixelBufferUsed + pixelIndex] = dpx->lut16_16[row[pixelIndex]]; else dpx->pixelBuffer[dpx->pixelBufferUsed + pixelIndex] = row[pixelIndex] >> 6; @@ -351,7 +353,8 @@ dpxSetRowBytes(DpxFile* dpx, const unsigned short* row, int y) { dpx->lineBuffer[longIndex] = htonl(t); pixelIndex += 3; } - } else { + } + else { for (longIndex = 0; longIndex < writeLongs; ++longIndex) { unsigned int t = dpx->pixelBuffer[pixelIndex+2] << 2 | (dpx->pixelBuffer[pixelIndex+1] << 12) | @@ -411,7 +414,8 @@ intern_dpxOpen(int mode, const char* bytestuff, int bufsize) { dpx->membuffer = 0; dpx->memcursor = 0; dpx->membuffersize = 0; - } else if (mode == LFMEMFILE) { + } + else if (mode == LFMEMFILE) { dpx->membuffer = (unsigned char *)bytestuff; dpx->memcursor = (unsigned char *)bytestuff; dpx->membuffersize = bufsize; @@ -625,7 +629,8 @@ dpxCreate(const char* filename, int width, int height, int depth) { shortFilename = strrchr(filename, '/'); if (shortFilename == 0) { shortFilename = filename; - } else { + } + else { ++shortFilename; } initDpxMainHeader(dpx, &header, shortFilename); diff --git a/source/blender/imbuf/intern/cineon/logImageLib.c b/source/blender/imbuf/intern/cineon/logImageLib.c index dc50d93bf18..f97df005fc8 100644 --- a/source/blender/imbuf/intern/cineon/logImageLib.c +++ b/source/blender/imbuf/intern/cineon/logImageLib.c @@ -56,7 +56,8 @@ logImageOpen(const char* filename, int cineon) { if (cineon) { return cineonOpen(filename); - } else { + } + else { return dpxOpen(filename); } return 0; @@ -67,7 +68,8 @@ logImageOpenFromMem(unsigned char *buffer, unsigned int size, int cineon) { if (cineon) { return cineonOpenFromMem(buffer, size); - } else { + } + else { return dpxOpenFromMem(buffer, size); } return 0; @@ -78,7 +80,8 @@ logImageCreate(const char* filename, int cineon, int width, int height, int dept { if (cineon) { return cineonCreate(filename, width, height, depth); - } else { + } + else { return dpxCreate(filename, width, height, depth); } return 0; @@ -171,7 +174,8 @@ logImageDump(const char* filename) #if 0 cineonDump(filename); #endif - } else if (magic == ntohl(DPX_FILE_MAGIC)) { + } + else if (magic == ntohl(DPX_FILE_MAGIC)) { dpxDump(filename); } } diff --git a/source/blender/imbuf/intern/cineon/logmemfile.c b/source/blender/imbuf/intern/cineon/logmemfile.c index 289dd0357a4..3db4241cc14 100644 --- a/source/blender/imbuf/intern/cineon/logmemfile.c +++ b/source/blender/imbuf/intern/cineon/logmemfile.c @@ -39,10 +39,12 @@ int logimage_fseek(void* logfile, intptr_t offsett, int origin) if (origin==SEEK_SET) { if (offset > file->membuffersize) return 1; file->memcursor = file->membuffer + offset; - } else if (origin==SEEK_END) { + } + else if (origin==SEEK_END) { if (offset > file->membuffersize) return 1; file->memcursor = (file->membuffer + file->membuffersize) - offset; - } else if (origin==SEEK_CUR) { + } + else if (origin==SEEK_CUR) { uintptr_t pos = (uintptr_t)file->membuffer - (uintptr_t)file->memcursor; if (pos + offset > file->membuffersize) return 1; if (pos < 0) return 1; diff --git a/source/blender/imbuf/intern/divers.c b/source/blender/imbuf/intern/divers.c index bd9b32e77f4..8f8c6311b30 100644 --- a/source/blender/imbuf/intern/divers.c +++ b/source/blender/imbuf/intern/divers.c @@ -118,7 +118,7 @@ DitherContext *create_dither_context(int w, float factor) di->error_buf= MEM_callocN(4*(w+1)*sizeof(int), "dithering error"); di->e= di->error_buf; - for(i=0; i<4; ++i) + for (i=0; i<4; ++i) di->v[i]= di->v0[i]= di->v1[i]= 1024.0f*(BLI_frand()-0.5f); return di; @@ -134,7 +134,7 @@ static void dither_finish_row(DitherContext *di) { int i; - for(i=0; i<4; i++) + for (i=0; i<4; i++) di->v[i]= di->v0[i]= di->v1[i] = 0; di->e= di->error_buf; @@ -200,114 +200,114 @@ void IMB_buffer_byte_from_float(uchar *rect_to, const float *rect_from, BLI_assert(profile_from != IB_PROFILE_NONE); BLI_init_srgb_conversion(); - if(dither) + if (dither) di= create_dither_context(width, dither); - for(y = 0; y < height; y++) { - if(channels_from == 1) { + for (y = 0; y < height; y++) { + if (channels_from == 1) { /* single channel input */ const float *from = rect_from + stride_from*y; uchar *to = rect_to + stride_to*y*4; - for(x = 0; x < width; x++, from++, to+=4) + for (x = 0; x < width; x++, from++, to+=4) to[0] = to[1] = to[2] = to[3] = FTOCHAR(from[0]); } - else if(channels_from == 3) { + else if (channels_from == 3) { /* RGB input */ const float *from = rect_from + stride_from*y*3; uchar *to = rect_to + stride_to*y*4; - if(profile_to == profile_from) { + if (profile_to == profile_from) { /* no color space conversion */ - for(x = 0; x < width; x++, from+=3, to+=4) { + for (x = 0; x < width; x++, from+=3, to+=4) { rgb_float_to_uchar(to, from); to[3] = 255; } } - else if(profile_to == IB_PROFILE_SRGB) { + else if (profile_to == IB_PROFILE_SRGB) { /* convert from linear to sRGB */ - for(x = 0; x < width; x++, from+=3, to+=4) { + for (x = 0; x < width; x++, from+=3, to+=4) { linearrgb_to_srgb_v3_v3(tmp, from); rgb_float_to_uchar(to, tmp); to[3] = 255; } } - else if(profile_to == IB_PROFILE_LINEAR_RGB) { + else if (profile_to == IB_PROFILE_LINEAR_RGB) { /* convert from sRGB to linear */ - for(x = 0; x < width; x++, from+=3, to+=4) { + for (x = 0; x < width; x++, from+=3, to+=4) { srgb_to_linearrgb_v3_v3(tmp, from); rgb_float_to_uchar(to, tmp); to[3] = 255; } } } - else if(channels_from == 4) { + else if (channels_from == 4) { /* RGBA input */ const float *from = rect_from + stride_from*y*4; uchar *to = rect_to + stride_to*y*4; - if(profile_to == profile_from) { + if (profile_to == profile_from) { /* no color space conversion */ - if(dither) { - for(x = 0; x < width; x++, from+=4, to+=4) + if (dither) { + for (x = 0; x < width; x++, from+=4, to+=4) float_to_byte_dither_v4(to, from, di); } else { - for(x = 0; x < width; x++, from+=4, to+=4) + for (x = 0; x < width; x++, from+=4, to+=4) rgba_float_to_uchar(to, from); } } - else if(profile_to == IB_PROFILE_SRGB) { + else if (profile_to == IB_PROFILE_SRGB) { /* convert from linear to sRGB */ unsigned short us[4]; - if(dither && predivide) { - for(x = 0; x < width; x++, from+=4, to+=4) { + if (dither && predivide) { + for (x = 0; x < width; x++, from+=4, to+=4) { linearrgb_to_srgb_ushort4_predivide(us, from); ushort_to_byte_dither_v4(to, us, di); } } - else if(dither) { - for(x = 0; x < width; x++, from+=4, to+=4) { + else if (dither) { + for (x = 0; x < width; x++, from+=4, to+=4) { linearrgb_to_srgb_ushort4(us, from); ushort_to_byte_dither_v4(to, us, di); } } - else if(predivide) { - for(x = 0; x < width; x++, from+=4, to+=4) { + else if (predivide) { + for (x = 0; x < width; x++, from+=4, to+=4) { linearrgb_to_srgb_ushort4_predivide(us, from); ushort_to_byte_v4(to, us); } } else { - for(x = 0; x < width; x++, from+=4, to+=4) { + for (x = 0; x < width; x++, from+=4, to+=4) { linearrgb_to_srgb_ushort4(us, from); ushort_to_byte_v4(to, us); } } } - else if(profile_to == IB_PROFILE_LINEAR_RGB) { + else if (profile_to == IB_PROFILE_LINEAR_RGB) { /* convert from sRGB to linear */ - if(dither && predivide) { - for(x = 0; x < width; x++, from+=4, to+=4) { + if (dither && predivide) { + for (x = 0; x < width; x++, from+=4, to+=4) { srgb_to_linearrgb_predivide_v4(tmp, from); float_to_byte_dither_v4(to, tmp, di); } } - else if(dither) { - for(x = 0; x < width; x++, from+=4, to+=4) { + else if (dither) { + for (x = 0; x < width; x++, from+=4, to+=4) { srgb_to_linearrgb_v4(tmp, from); float_to_byte_dither_v4(to, tmp, di); } } - else if(predivide) { - for(x = 0; x < width; x++, from+=4, to+=4) { + else if (predivide) { + for (x = 0; x < width; x++, from+=4, to+=4) { srgb_to_linearrgb_predivide_v4(tmp, from); rgba_float_to_uchar(to, tmp); } } else { - for(x = 0; x < width; x++, from+=4, to+=4) { + for (x = 0; x < width; x++, from+=4, to+=4) { srgb_to_linearrgb_v4(tmp, from); rgba_float_to_uchar(to, tmp); } @@ -315,11 +315,11 @@ void IMB_buffer_byte_from_float(uchar *rect_to, const float *rect_from, } } - if(dither) + if (dither) dither_finish_row(di); } - if(dither) + if (dither) clear_dither_context(di); } @@ -338,38 +338,38 @@ void IMB_buffer_float_from_byte(float *rect_to, const uchar *rect_from, BLI_init_srgb_conversion(); /* RGBA input */ - for(y = 0; y < height; y++) { + for (y = 0; y < height; y++) { const uchar *from = rect_from + stride_from*y*4; float *to = rect_to + stride_to*y*4; - if(profile_to == profile_from) { + if (profile_to == profile_from) { /* no color space conversion */ - for(x = 0; x < width; x++, from+=4, to+=4) + for (x = 0; x < width; x++, from+=4, to+=4) rgba_uchar_to_float(to, from); } - else if(profile_to == IB_PROFILE_LINEAR_RGB) { + else if (profile_to == IB_PROFILE_LINEAR_RGB) { /* convert sRGB to linear */ - if(predivide) { - for(x = 0; x < width; x++, from+=4, to+=4) { + if (predivide) { + for (x = 0; x < width; x++, from+=4, to+=4) { srgb_to_linearrgb_uchar4_predivide(to, from); } } else { - for(x = 0; x < width; x++, from+=4, to+=4) { + for (x = 0; x < width; x++, from+=4, to+=4) { srgb_to_linearrgb_uchar4(to, from); } } } - else if(profile_to == IB_PROFILE_SRGB) { + else if (profile_to == IB_PROFILE_SRGB) { /* convert linear to sRGB */ - if(predivide) { - for(x = 0; x < width; x++, from+=4, to+=4) { + if (predivide) { + for (x = 0; x < width; x++, from+=4, to+=4) { rgba_uchar_to_float(tmp, from); linearrgb_to_srgb_predivide_v4(to, tmp); } } else { - for(x = 0; x < width; x++, from+=4, to+=4) { + for (x = 0; x < width; x++, from+=4, to+=4) { rgba_uchar_to_float(tmp, from); linearrgb_to_srgb_v4(to, tmp); } @@ -389,74 +389,74 @@ void IMB_buffer_float_from_float(float *rect_to, const float *rect_from, BLI_assert(profile_to != IB_PROFILE_NONE); BLI_assert(profile_from != IB_PROFILE_NONE); - if(channels_from==1) { + if (channels_from==1) { /* single channel input */ - for(y = 0; y < height; y++) { + for (y = 0; y < height; y++) { const float *from = rect_from + stride_from*y; float *to = rect_to + stride_to*y*4; - for(x = 0; x < width; x++, from++, to+=4) + for (x = 0; x < width; x++, from++, to+=4) to[0] = to[1] = to[2] = to[3] = from[0]; } } - else if(channels_from == 3) { + else if (channels_from == 3) { /* RGB input */ - for(y = 0; y < height; y++) { + for (y = 0; y < height; y++) { const float *from = rect_from + stride_from*y*3; float *to = rect_to + stride_to*y*4; - if(profile_to == profile_from) { + if (profile_to == profile_from) { /* no color space conversion */ - for(x = 0; x < width; x++, from+=3, to+=4) { + for (x = 0; x < width; x++, from+=3, to+=4) { copy_v3_v3(to, from); to[3] = 1.0f; } } - else if(profile_to == IB_PROFILE_LINEAR_RGB) { + else if (profile_to == IB_PROFILE_LINEAR_RGB) { /* convert from sRGB to linear */ - for(x = 0; x < width; x++, from+=3, to+=4) { + for (x = 0; x < width; x++, from+=3, to+=4) { srgb_to_linearrgb_v3_v3(to, from); to[3] = 1.0f; } } - else if(profile_to == IB_PROFILE_SRGB) { + else if (profile_to == IB_PROFILE_SRGB) { /* convert from linear to sRGB */ - for(x = 0; x < width; x++, from+=3, to+=4) { + for (x = 0; x < width; x++, from+=3, to+=4) { linearrgb_to_srgb_v3_v3(to, from); to[3] = 1.0f; } } } } - else if(channels_from == 4) { + else if (channels_from == 4) { /* RGBA input */ - for(y = 0; y < height; y++) { + for (y = 0; y < height; y++) { const float *from = rect_from + stride_from*y*4; float *to = rect_to + stride_to*y*4; - if(profile_to == profile_from) { + if (profile_to == profile_from) { /* same profile, copy */ memcpy(to, from, sizeof(float)*4*width); } - else if(profile_to == IB_PROFILE_LINEAR_RGB) { + else if (profile_to == IB_PROFILE_LINEAR_RGB) { /* convert to sRGB to linear */ - if(predivide) { - for(x = 0; x < width; x++, from+=4, to+=4) + if (predivide) { + for (x = 0; x < width; x++, from+=4, to+=4) srgb_to_linearrgb_predivide_v4(to, from); } else { - for(x = 0; x < width; x++, from+=4, to+=4) + for (x = 0; x < width; x++, from+=4, to+=4) srgb_to_linearrgb_v4(to, from); } } - else if(profile_to == IB_PROFILE_SRGB) { + else if (profile_to == IB_PROFILE_SRGB) { /* convert from linear to sRGB */ - if(predivide) { - for(x = 0; x < width; x++, from+=4, to+=4) + if (predivide) { + for (x = 0; x < width; x++, from+=4, to+=4) linearrgb_to_srgb_predivide_v4(to, from); } else { - for(x = 0; x < width; x++, from+=4, to+=4) + for (x = 0; x < width; x++, from+=4, to+=4) linearrgb_to_srgb_v4(to, from); } } @@ -477,42 +477,42 @@ void IMB_buffer_byte_from_byte(uchar *rect_to, const uchar *rect_from, BLI_assert(profile_from != IB_PROFILE_NONE); /* always RGBA input */ - for(y = 0; y < height; y++) { + for (y = 0; y < height; y++) { const uchar *from = rect_from + stride_from*y*4; uchar *to = rect_to + stride_to*y*4; - if(profile_to == profile_from) { + if (profile_to == profile_from) { /* same profile, copy */ memcpy(to, from, sizeof(uchar)*4*width); } - else if(profile_to == IB_PROFILE_LINEAR_RGB) { + else if (profile_to == IB_PROFILE_LINEAR_RGB) { /* convert to sRGB to linear */ - if(predivide) { - for(x = 0; x < width; x++, from+=4, to+=4) { + if (predivide) { + for (x = 0; x < width; x++, from+=4, to+=4) { rgba_uchar_to_float(tmp, from); srgb_to_linearrgb_predivide_v4(tmp, tmp); rgba_float_to_uchar(to, tmp); } } else { - for(x = 0; x < width; x++, from+=4, to+=4) { + for (x = 0; x < width; x++, from+=4, to+=4) { rgba_uchar_to_float(tmp, from); srgb_to_linearrgb_v4(tmp, tmp); rgba_float_to_uchar(to, tmp); } } } - else if(profile_to == IB_PROFILE_SRGB) { + else if (profile_to == IB_PROFILE_SRGB) { /* convert from linear to sRGB */ - if(predivide) { - for(x = 0; x < width; x++, from+=4, to+=4) { + if (predivide) { + for (x = 0; x < width; x++, from+=4, to+=4) { rgba_uchar_to_float(tmp, from); linearrgb_to_srgb_predivide_v4(tmp, tmp); rgba_float_to_uchar(to, tmp); } } else { - for(x = 0; x < width; x++, from+=4, to+=4) { + for (x = 0; x < width; x++, from+=4, to+=4) { rgba_uchar_to_float(tmp, from); linearrgb_to_srgb_v4(tmp, tmp); rgba_float_to_uchar(to, tmp); @@ -530,17 +530,17 @@ void IMB_rect_from_float(ImBuf *ibuf) int profile_from; /* verify we have a float buffer */ - if(ibuf->rect_float==NULL) + if (ibuf->rect_float==NULL) return; /* create byte rect if it didn't exist yet */ - if(ibuf->rect==NULL) + if (ibuf->rect==NULL) imb_addrectImBuf(ibuf); /* determine profiles */ - if(ibuf->profile == IB_PROFILE_LINEAR_RGB) + if (ibuf->profile == IB_PROFILE_LINEAR_RGB) profile_from = IB_PROFILE_LINEAR_RGB; - else if(ELEM(ibuf->profile, IB_PROFILE_SRGB, IB_PROFILE_NONE)) + else if (ELEM(ibuf->profile, IB_PROFILE_SRGB, IB_PROFILE_NONE)) profile_from = IB_PROFILE_SRGB; else BLI_assert(0); @@ -563,17 +563,17 @@ void IMB_partial_rect_from_float(ImBuf *ibuf, float *buffer, int x, int y, int w int profile_from; /* verify we have a float buffer */ - if(ibuf->rect_float==NULL || buffer==NULL) + if (ibuf->rect_float==NULL || buffer==NULL) return; /* create byte rect if it didn't exist yet */ - if(ibuf->rect==NULL) + if (ibuf->rect==NULL) imb_addrectImBuf(ibuf); /* determine profiles */ - if(ibuf->profile == IB_PROFILE_LINEAR_RGB) + if (ibuf->profile == IB_PROFILE_LINEAR_RGB) profile_from = IB_PROFILE_LINEAR_RGB; - else if(ELEM(ibuf->profile, IB_PROFILE_SRGB, IB_PROFILE_NONE)) + else if (ELEM(ibuf->profile, IB_PROFILE_SRGB, IB_PROFILE_NONE)) profile_from = IB_PROFILE_SRGB; else BLI_assert(0); @@ -600,15 +600,15 @@ void IMB_float_from_rect(ImBuf *ibuf) int profile_from; /* verify if we byte and float buffers */ - if(ibuf->rect==NULL) + if (ibuf->rect==NULL) return; - if(ibuf->rect_float==NULL) - if(imb_addrectfloatImBuf(ibuf) == 0) + if (ibuf->rect_float==NULL) + if (imb_addrectfloatImBuf(ibuf) == 0) return; /* determine profiles */ - if(ibuf->profile == IB_PROFILE_NONE) + if (ibuf->profile == IB_PROFILE_NONE) profile_from = IB_PROFILE_LINEAR_RGB; else profile_from = IB_PROFILE_SRGB; @@ -624,7 +624,7 @@ void IMB_float_from_rect_simple(ImBuf *ibuf) { int predivide= (ibuf->flags & IB_cm_predivide); - if(ibuf->rect_float==NULL) + if (ibuf->rect_float==NULL) imb_addrectfloatImBuf(ibuf); IMB_buffer_float_from_byte(ibuf->rect_float, (uchar*)ibuf->rect, @@ -637,22 +637,22 @@ void IMB_convert_profile(ImBuf *ibuf, int profile) int predivide= (ibuf->flags & IB_cm_predivide); int profile_from, profile_to; - if(ibuf->profile == profile) + if (ibuf->profile == profile) return; /* determine profiles */ - if(ibuf->profile == IB_PROFILE_LINEAR_RGB) + if (ibuf->profile == IB_PROFILE_LINEAR_RGB) profile_from = IB_PROFILE_LINEAR_RGB; - else if(ELEM(ibuf->profile, IB_PROFILE_SRGB, IB_PROFILE_NONE)) + else if (ELEM(ibuf->profile, IB_PROFILE_SRGB, IB_PROFILE_NONE)) profile_from = IB_PROFILE_SRGB; else { BLI_assert(0); profile_from = IB_PROFILE_SRGB; /* dummy, should never happen */ } - if(profile == IB_PROFILE_LINEAR_RGB) + if (profile == IB_PROFILE_LINEAR_RGB) profile_to = IB_PROFILE_LINEAR_RGB; - else if(ELEM(profile, IB_PROFILE_SRGB, IB_PROFILE_NONE)) + else if (ELEM(profile, IB_PROFILE_SRGB, IB_PROFILE_NONE)) profile_to = IB_PROFILE_SRGB; else { BLI_assert(0); @@ -660,13 +660,13 @@ void IMB_convert_profile(ImBuf *ibuf, int profile) } /* do conversion */ - if(ibuf->rect_float) { + if (ibuf->rect_float) { IMB_buffer_float_from_float(ibuf->rect_float, ibuf->rect_float, 4, profile_to, profile_from, predivide, ibuf->x, ibuf->y, ibuf->x, ibuf->x); } - if(ibuf->rect) { + if (ibuf->rect) { IMB_buffer_byte_from_byte((uchar*)ibuf->rect, (uchar*)ibuf->rect, profile_to, profile_from, predivide, ibuf->x, ibuf->y, ibuf->x, ibuf->x); @@ -684,21 +684,21 @@ float *IMB_float_profile_ensure(ImBuf *ibuf, int profile, int *alloc) int profile_from, profile_to; /* determine profiles */ - if(ibuf->profile == IB_PROFILE_NONE) + if (ibuf->profile == IB_PROFILE_NONE) profile_from = IB_PROFILE_LINEAR_RGB; else profile_from = IB_PROFILE_SRGB; - if(profile == IB_PROFILE_NONE) + if (profile == IB_PROFILE_NONE) profile_to = IB_PROFILE_LINEAR_RGB; else profile_to = IB_PROFILE_SRGB; - if(profile_from == profile_to) { + if (profile_from == profile_to) { /* simple case, just allocate the buffer and return */ *alloc= 0; - if(ibuf->rect_float == NULL) + if (ibuf->rect_float == NULL) IMB_float_from_rect(ibuf); return ibuf->rect_float; @@ -708,7 +708,7 @@ float *IMB_float_profile_ensure(ImBuf *ibuf, int profile, int *alloc) float *fbuf= MEM_mallocN(ibuf->x * ibuf->y * sizeof(float) * 4, "IMB_float_profile_ensure"); *alloc= 1; - if(ibuf->rect_float == NULL) { + if (ibuf->rect_float == NULL) { IMB_buffer_float_from_byte(fbuf, (uchar*)ibuf->rect, profile_to, profile_from, predivide, ibuf->x, ibuf->y, ibuf->x, ibuf->x); @@ -732,13 +732,13 @@ void IMB_color_to_bw(ImBuf *ibuf) uchar *rct= (uchar*)ibuf->rect; int i; - if(rctf) { - for(i = ibuf->x * ibuf->y; i > 0; i--, rctf+=4) + if (rctf) { + for (i = ibuf->x * ibuf->y; i > 0; i--, rctf+=4) rctf[0]= rctf[1]= rctf[2]= rgb_to_grayscale(rctf); } - if(rct) { - for(i = ibuf->x * ibuf->y; i > 0; i--, rct+=4) + if (rct) { + for (i = ibuf->x * ibuf->y; i > 0; i--, rct+=4) rct[0]= rct[1]= rct[2]= rgb_to_grayscale_byte(rct); } } @@ -746,7 +746,7 @@ void IMB_color_to_bw(ImBuf *ibuf) void IMB_buffer_float_clamp(float *buf, int width, int height) { int i, total = width*height*4; - for(i = 0; i < total; i++){ + for (i = 0; i < total; i++) { buf[i] = MIN2(1.0, buf[i]); } } @@ -760,7 +760,7 @@ void IMB_saturation(ImBuf * ibuf, float sat) float *rctf= ibuf->rect_float; float hsv[3]; - if(rct) { + if (rct) { float rgb[3]; for (i = ibuf->x * ibuf->y; i > 0; i--, rct+=4) { rgb_uchar_to_float(rgb, rct); @@ -770,7 +770,7 @@ void IMB_saturation(ImBuf * ibuf, float sat) } } - if(rctf) { + if (rctf) { for (i = ibuf->x * ibuf->y; i > 0; i--, rctf+=4) { rgb_to_hsv(rctf[0], rctf[1], rctf[2], hsv, hsv+1, hsv+2); hsv_to_rgb(hsv[0], hsv[1] * sat, hsv[2], rctf, rctf+1, rctf+2); diff --git a/source/blender/imbuf/intern/filetype.c b/source/blender/imbuf/intern/filetype.c index c03736f4b0a..9ece4bd9f6d 100644 --- a/source/blender/imbuf/intern/filetype.c +++ b/source/blender/imbuf/intern/filetype.c @@ -94,8 +94,8 @@ void imb_filetypes_init(void) { ImFileType *type; - for(type=IMB_FILE_TYPES; type->is_a; type++) - if(type->init) + for (type=IMB_FILE_TYPES; type->is_a; type++) + if (type->init) type->init(); } @@ -103,8 +103,8 @@ void imb_filetypes_exit(void) { ImFileType *type; - for(type=IMB_FILE_TYPES; type->is_a; type++) - if(type->exit) + for (type=IMB_FILE_TYPES; type->is_a; type++) + if (type->exit) type->exit(); } diff --git a/source/blender/imbuf/intern/filter.c b/source/blender/imbuf/intern/filter.c index 0d821126492..a93f47db9a3 100644 --- a/source/blender/imbuf/intern/filter.c +++ b/source/blender/imbuf/intern/filter.c @@ -54,10 +54,10 @@ static void filtrow(unsigned char *point, int x) { unsigned int c1,c2,c3,error; - if (x>1){ + if (x>1) { c1 = c2 = *point; error = 2; - for(x--;x>0;x--){ + for (x--;x>0;x--) { c3 = point[4]; c1 += (c2<<1) + c3 + error; error = c1 & 3; @@ -74,9 +74,9 @@ static void filtrowf(float *point, int x) { float c1,c2,c3; - if (x>1){ + if (x>1) { c1 = c2 = *point; - for(x--;x>0;x--){ + for (x--;x>0;x--) { c3 = point[4]; c1 += (c2 * 2) + c3; *point = 0.25f*c1; @@ -95,11 +95,11 @@ static void filtcolum(unsigned char *point, int y, int skip) unsigned int c1,c2,c3,error; unsigned char *point2; - if (y>1){ + if (y>1) { c1 = c2 = *point; point2 = point; error = 2; - for(y--;y>0;y--){ + for (y--;y>0;y--) { point2 += skip; c3 = *point2; c1 += (c2<<1) + c3 +error; @@ -117,10 +117,10 @@ static void filtcolumf(float *point, int y, int skip) { float c1,c2,c3, *point2; - if (y>1){ + if (y>1) { c1 = c2 = *point; point2 = point; - for(y--;y>0;y--){ + for (y--;y>0;y--) { point2 += skip; c3 = *point2; c1 += (c2 * 2) + c3; @@ -146,7 +146,7 @@ void IMB_filtery(struct ImBuf *ibuf) y = ibuf->y; skip = x<<2; - for (;x>0;x--){ + for (;x>0;x--) { if (point) { if (ibuf->planes > 24) filtcolum(point,y,skip); point++; @@ -184,7 +184,7 @@ void imb_filterx(struct ImBuf *ibuf) y = ibuf->y; skip = (x<<2) - 3; - for (;y>0;y--){ + for (;y>0;y--) { if (point) { if (ibuf->planes > 24) filtrow(point,x); point++; @@ -216,7 +216,7 @@ void IMB_filterN(ImBuf *out, ImBuf *in) rowlen= in->x; - for(y=0; y<in->y; y++) { + for (y=0; y<in->y; y++) { /* setup rows */ row2= (char*)(in->rect + y*rowlen); row1= (y == 0)? row2: row2 - 4*rowlen; @@ -224,8 +224,8 @@ void IMB_filterN(ImBuf *out, ImBuf *in) cp= (char *)(out->rect + y*rowlen); - for(x=0; x<rowlen; x++) { - if(x == 0) { + for (x=0; x<rowlen; x++) { + if (x == 0) { r11 = row1; r21 = row1; r31 = row1; @@ -236,7 +236,7 @@ void IMB_filterN(ImBuf *out, ImBuf *in) r31 = row1-4; } - if(x == rowlen-1) { + if (x == rowlen-1) { r13 = row1; r23 = row1; r33 = row1; @@ -273,26 +273,27 @@ void IMB_mask_filter_extend(char *mask, int width, int height) /* make a copy, to prevent flooding */ temprect= MEM_dupallocN(mask); - for(y=1; y<=height; y++) { + for (y=1; y<=height; y++) { /* setup rows */ row1= (char *)(temprect + (y-2)*rowlen); row2= row1 + rowlen; row3= row2 + rowlen; - if(y==1) + if (y==1) row1= row2; - else if(y==height) + else if (y==height) row3= row2; - for(x=0; x<rowlen; x++) { + for (x=0; x<rowlen; x++) { if (mask[((y-1)*rowlen)+x]==0) { if (*row1 || *row2 || *row3 || *(row1+1) || *(row3+1) ) { mask[((y-1)*rowlen)+x] = FILTER_MASK_MARGIN; - } else if((x!=rowlen-1) && (*(row1+2) || *(row2+2) || *(row3+2)) ) { + } + else if ((x!=rowlen-1) && (*(row1+2) || *(row2+2) || *(row3+2)) ) { mask[((y-1)*rowlen)+x] = FILTER_MASK_MARGIN; } } - if(x!=0) { + if (x!=0) { row1++; row2++; row3++; } } @@ -305,18 +306,19 @@ void IMB_mask_clear(ImBuf *ibuf, char *mask, int val) { int x,y; if (ibuf->rect_float) { - for(x=0; x<ibuf->x; x++) { - for(y=0; y<ibuf->y; y++) { + for (x=0; x<ibuf->x; x++) { + for (y=0; y<ibuf->y; y++) { if (mask[ibuf->x*y + x] == val) { float *col= ibuf->rect_float + 4*(ibuf->x*y + x); col[0] = col[1] = col[2] = col[3] = 0.0f; } } } - } else { + } + else { /* char buffer */ - for(x=0; x<ibuf->x; x++) { - for(y=0; y<ibuf->y; y++) { + for (x=0; x<ibuf->x; x++) { + for (y=0; y<ibuf->y; y++) { if (mask[ibuf->x*y + x] == val) { char *col= (char *)(ibuf->rect + ibuf->x*y + x); col[0] = col[1] = col[2] = col[3] = 0; @@ -328,7 +330,7 @@ void IMB_mask_clear(ImBuf *ibuf, char *mask, int val) static int filter_make_index(const int x, const int y, const int w, const int h) { - if(x<0 || x>=w || y<0 || y>=h) return -1; /* return bad index */ + if (x<0 || x>=w || y<0 || y>=h) return -1; /* return bad index */ else return y*w+x; } @@ -336,13 +338,13 @@ static int check_pixel_assigned(const void *buffer, const char *mask, const int { int res = 0; - if(index>=0) { + if (index>=0) { const int alpha_index = depth*index+(depth-1); - if(mask!=NULL) { + if (mask!=NULL) { res = mask[index]!=0 ? 1 : 0; } - else if( (is_float && ((const float *) buffer)[alpha_index]!=0.0f) || + else if ( (is_float && ((const float *) buffer)[alpha_index]!=0.0f) || (!is_float && ((const unsigned char *) buffer)[alpha_index]!=0) ) { res=1; } @@ -375,8 +377,8 @@ void IMB_filter_extend(struct ImBuf *ibuf, char *mask, int filter) #if 0 k= 0; - for(i = -n; i <= n; i++) - for(j = -n; j <= n; j++) + for (i = -n; i <= n; i++) + for (j = -n; j <= n; j++) weight[k++] = sqrt((float) i * i + j * j); #endif @@ -385,16 +387,16 @@ void IMB_filter_extend(struct ImBuf *ibuf, char *mask, int filter) weight[6]=1; weight[7]=2; weight[8]=1; /* run passes */ - for(r = 0; cannot_early_out == 1 && r < filter; r++) { + for (r = 0; cannot_early_out == 1 && r < filter; r++) { int x, y; cannot_early_out = 0; - for(y= 0; y<height; y++) { - for(x= 0; x<width; x++) { + for (y= 0; y<height; y++) { + for (x= 0; x<width; x++) { const int index= filter_make_index(x, y, width, height); /* only update unassigned pixels */ - if(!check_pixel_assigned(srcbuf, srcmask, index, depth, is_float)) { + if (!check_pixel_assigned(srcbuf, srcmask, index, depth, is_float)) { float tmp[4]; float wsum=0; float acc[4]={0,0,0,0}; @@ -404,24 +406,24 @@ void IMB_filter_extend(struct ImBuf *ibuf, char *mask, int filter) check_pixel_assigned(srcbuf, srcmask, filter_make_index(x+1, y, width, height), depth, is_float) || check_pixel_assigned(srcbuf, srcmask, filter_make_index(x, y-1, width, height), depth, is_float) || check_pixel_assigned(srcbuf, srcmask, filter_make_index(x, y+1, width, height), depth, is_float)) { - for(i= -n; i<=n; i++) { - for(j=-n; j<=n; j++) { - if(i != 0 || j != 0) { + for (i= -n; i<=n; i++) { + for (j=-n; j<=n; j++) { + if (i != 0 || j != 0) { const int tmpindex= filter_make_index(x+i, y+j, width, height); - if(check_pixel_assigned(srcbuf, srcmask, tmpindex, depth, is_float)) { - if(is_float) { - for(c=0; c<depth; c++) + if (check_pixel_assigned(srcbuf, srcmask, tmpindex, depth, is_float)) { + if (is_float) { + for (c=0; c<depth; c++) tmp[c] = ((const float *) srcbuf)[depth*tmpindex+c]; } else { - for(c=0; c<depth; c++) + for (c=0; c<depth; c++) tmp[c] = (float) ((const unsigned char *) srcbuf)[depth*tmpindex+c]; } wsum+= weight[k]; - for(c=0; c<depth; c++) + for (c=0; c<depth; c++) acc[c]+= weight[k] * tmp[c]; } } @@ -429,21 +431,21 @@ void IMB_filter_extend(struct ImBuf *ibuf, char *mask, int filter) } } - if(wsum!=0) { - for(c=0; c<depth; c++) + if (wsum!=0) { + for (c=0; c<depth; c++) acc[c]/= wsum; - if(is_float) { - for(c=0; c<depth; c++) + if (is_float) { + for (c=0; c<depth; c++) ((float *) dstbuf)[depth*index+c] = acc[c]; } else { - for(c=0; c<depth; c++) { + for (c=0; c<depth; c++) { ((unsigned char *) dstbuf)[depth*index+c]= acc[c] > 255 ? 255 : (acc[c] < 0 ? 0 : ((unsigned char) (acc[c]+0.5f))); } } - if(dstmask!=NULL) dstmask[index]=FILTER_MASK_MARGIN; /* assigned */ + if (dstmask!=NULL) dstmask[index]=FILTER_MASK_MARGIN; /* assigned */ cannot_early_out = 1; } } @@ -453,12 +455,12 @@ void IMB_filter_extend(struct ImBuf *ibuf, char *mask, int filter) /* keep the original buffer up to date. */ memcpy(srcbuf, dstbuf, bsize); - if(dstmask!=NULL) memcpy(srcmask, dstmask, width*height); + if (dstmask!=NULL) memcpy(srcmask, dstmask, width*height); } /* free memory */ MEM_freeN(dstbuf); - if(dstmask!=NULL) MEM_freeN(dstmask); + if (dstmask!=NULL) MEM_freeN(dstmask); } /* threadsafe version, only recreates existing maps */ @@ -471,9 +473,9 @@ void IMB_remakemipmap(ImBuf *ibuf, int use_filter) while(curmap < IB_MIPMAP_LEVELS) { - if(ibuf->mipmap[curmap]) { + if (ibuf->mipmap[curmap]) { - if(use_filter) { + if (use_filter) { ImBuf *nbuf= IMB_allocImBuf(hbuf->x, hbuf->y, 32, IB_rect); IMB_filterN(nbuf, hbuf); imb_onehalf_no_alloc(ibuf->mipmap[curmap], nbuf); @@ -485,10 +487,10 @@ void IMB_remakemipmap(ImBuf *ibuf, int use_filter) ibuf->miptot= curmap+2; hbuf= ibuf->mipmap[curmap]; - if(hbuf) + if (hbuf) hbuf->miplevel= curmap+1; - if(!hbuf || (hbuf->x <= 2 && hbuf->y <= 2)) + if (!hbuf || (hbuf->x <= 2 && hbuf->y <= 2)) break; curmap++; @@ -506,7 +508,7 @@ void IMB_makemipmap(ImBuf *ibuf, int use_filter) ibuf->miptot= 1; while(curmap < IB_MIPMAP_LEVELS) { - if(use_filter) { + if (use_filter) { ImBuf *nbuf= IMB_allocImBuf(hbuf->x, hbuf->y, 32, IB_rect); IMB_filterN(nbuf, hbuf); ibuf->mipmap[curmap] = IMB_onehalf(nbuf); @@ -519,7 +521,7 @@ void IMB_makemipmap(ImBuf *ibuf, int use_filter) hbuf= ibuf->mipmap[curmap]; hbuf->miplevel= curmap+1; - if(hbuf->x <= 2 && hbuf->y <= 2) + if (hbuf->x <= 2 && hbuf->y <= 2) break; curmap++; @@ -537,18 +539,18 @@ void IMB_premultiply_rect(unsigned int *rect, char planes, int w, int h) char *cp; int x, y, val; - if(planes == 24) { /* put alpha at 255 */ + if (planes == 24) { /* put alpha at 255 */ cp= (char *)(rect); - for(y=0; y<h; y++) - for(x=0; x<w; x++, cp+=4) + for (y=0; y<h; y++) + for (x=0; x<w; x++, cp+=4) cp[3]= 255; } else { cp= (char *)(rect); - for(y=0; y<h; y++) { - for(x=0; x<w; x++, cp+=4) { + for (y=0; y<h; y++) { + for (x=0; x<w; x++, cp+=4) { val= cp[3]; cp[0]= (cp[0]*val)>>8; cp[1]= (cp[1]*val)>>8; @@ -563,17 +565,17 @@ void IMB_premultiply_rect_float(float *rect_float, char planes, int w, int h) float val, *cp; int x, y; - if(planes==24) { /* put alpha at 1.0 */ + if (planes==24) { /* put alpha at 1.0 */ cp= rect_float; - for(y=0; y<h; y++) - for(x=0; x<w; x++, cp+=4) + for (y=0; y<h; y++) + for (x=0; x<w; x++, cp+=4) cp[3]= 1.0; } else { cp= rect_float; - for(y=0; y<h; y++) { - for(x=0; x<w; x++, cp+=4) { + for (y=0; y<h; y++) { + for (x=0; x<w; x++, cp+=4) { val= cp[3]; cp[0]= cp[0]*val; cp[1]= cp[1]*val; @@ -586,13 +588,13 @@ void IMB_premultiply_rect_float(float *rect_float, char planes, int w, int h) void IMB_premultiply_alpha(ImBuf *ibuf) { - if(ibuf==NULL) + if (ibuf==NULL) return; - if(ibuf->rect) + if (ibuf->rect) IMB_premultiply_rect(ibuf->rect, ibuf->planes, ibuf->x, ibuf->y); - if(ibuf->rect_float) + if (ibuf->rect_float) IMB_premultiply_rect_float(ibuf->rect_float, ibuf->planes, ibuf->x, ibuf->y); } diff --git a/source/blender/imbuf/intern/imageprocess.c b/source/blender/imbuf/intern/imageprocess.c index 0462c998e44..85bd3137ddc 100644 --- a/source/blender/imbuf/intern/imageprocess.c +++ b/source/blender/imbuf/intern/imageprocess.c @@ -156,11 +156,11 @@ void bicubic_interpolation_color(struct ImBuf *in, unsigned char *outI, float *o wy[2] = P(b- 1); wy[3] = P(b- 2); - for(n= -1; n<= 2; n++){ + for (n= -1; n<= 2; n++) { x1= i+n; CLAMP(x1, 0, in->x-1); wx = P(n-a); - for(m= -1; m<= 2; m++){ + for (m= -1; m<= 2; m++) { y1= j+m; CLAMP(y1, 0, in->y-1); /* normally we could do this */ @@ -189,8 +189,8 @@ void bicubic_interpolation_color(struct ImBuf *in, unsigned char *outI, float *o #if 0 /* older, slower function, works the same as above */ - for(n= -1; n<= 2; n++){ - for(m= -1; m<= 2; m++){ + for (n= -1; n<= 2; n++) { + for (m= -1; m<= 2; m++) { x1= i+n; y1= j+m; if (x1>0 && x1 < in->x && y1>0 && y1<in->y) { @@ -338,11 +338,11 @@ void bilinear_interpolation_color_wrap(struct ImBuf *in, unsigned char *outI, fl if (x2<0 || x1>in->x-1 || y2<0 || y1>in->y-1) return; /* wrap interpolation pixels - main difference from bilinear_interpolation_color */ - if(x1<0)x1= in->x+x1; - if(y1<0)y1= in->y+y1; + if (x1<0)x1= in->x+x1; + if (y1<0)y1= in->y+y1; - if(x2>=in->x)x2= x2-in->x; - if(y2>=in->y)y2= y2-in->y; + if (x2>=in->x)x2= x2-in->x; + if (y2>=in->y)y2= y2-in->y; if (outF) { // sample including outside of edges of image @@ -423,7 +423,8 @@ void neareast_interpolation_color(struct ImBuf *in, unsigned char *outI, float * outF[2]= 0.0f; outF[3]= 0.0f; } - } else { + } + else { dataI= (unsigned char *)in->rect + in->x * y1 * 4 + 4*x1; if (outI) { outI[0]= dataI[0]; diff --git a/source/blender/imbuf/intern/indexer.c b/source/blender/imbuf/intern/indexer.c index dcbce6d028c..33ff769217d 100644 --- a/source/blender/imbuf/intern/indexer.c +++ b/source/blender/imbuf/intern/indexer.c @@ -122,7 +122,8 @@ void IMB_index_builder_proc_frame(anim_index_builder * fp, e.pts = pts; fp->proc_frame(fp, buffer, data_size, &e); - } else { + } + else { IMB_index_builder_add_entry(fp, frameno, seek_pos, seek_pos_dts, pts); } @@ -138,7 +139,8 @@ void IMB_index_builder_finish(anim_index_builder * fp, int rollback) if (rollback) { unlink(fp->temp_name); - } else { + } + else { unlink(fp->name); BLI_rename(fp->temp_name, fp->name); } @@ -260,14 +262,16 @@ int IMB_indexer_get_frame_index(struct anim_index * idx, int frameno) first = middle; ++first; len = len - half - 1; - } else { + } + else { len = half; } } if (first == idx->num_entries) { return idx->num_entries - 1; - } else { + } + else { return first; } } @@ -361,7 +365,8 @@ static void get_index_dir(struct anim * anim, char * index_dir) BLI_splitdirstring(index_dir, fname); BLI_join_dirfile(index_dir, FILE_MAXDIR, index_dir, "BL_proxy"); BLI_join_dirfile(index_dir, FILE_MAXDIR, index_dir, fname); - } else { + } + else { BLI_strncpy(index_dir, anim->index_dir, FILE_MAXDIR); } } @@ -505,7 +510,8 @@ static struct proxy_output_ctx * alloc_proxy_output_ffmpeg( if (rv->codec->pix_fmts) { rv->c->pix_fmt = rv->codec->pix_fmts[0]; - } else { + } + else { rv->c->pix_fmt = PIX_FMT_YUVJ420P; } @@ -633,7 +639,8 @@ static int add_to_proxy_output_ffmpeg( } return 1; - } else { + } + else { return 0; } } @@ -686,7 +693,8 @@ static void free_proxy_output_ffmpeg(struct proxy_output_ctx * ctx, if (rollback) { unlink(fname_tmp); - } else { + } + else { get_proxy_filename(ctx->anim, ctx->proxy_size, fname, FALSE); unlink(fname); @@ -731,7 +739,7 @@ static IndexBuildContext *index_ffmpeg_create_context(struct anim *anim, IMB_Tim memset(context->proxy_ctx, 0, sizeof(context->proxy_ctx)); memset(context->indexer, 0, sizeof(context->indexer)); - if(av_open_input_file(&context->iFormatCtx, anim->name, NULL, 0, NULL) != 0) { + if (av_open_input_file(&context->iFormatCtx, anim->name, NULL, 0, NULL) != 0) { MEM_freeN(context); return NULL; } @@ -747,7 +755,7 @@ static IndexBuildContext *index_ffmpeg_create_context(struct anim *anim, IMB_Tim /* Find the video stream */ context->videoStream = -1; for (i = 0; i < context->iFormatCtx->nb_streams; i++) - if(context->iFormatCtx->streams[i]->codec->codec_type + if (context->iFormatCtx->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO) { if (streamcount > 0) { streamcount--; @@ -919,7 +927,7 @@ static int index_rebuild_ffmpeg(FFmpegIndexBuilderContext *context, if (context->tcs_in_use & tc_types[i]) { int tc_frameno = frameno; - if(tc_types[i] == IMB_TC_RECORD_RUN_NO_GAPS) + if (tc_types[i] == IMB_TC_RECORD_RUN_NO_GAPS) tc_frameno = frameno_gapless; IMB_index_builder_proc_frame( @@ -1048,7 +1056,8 @@ static void index_rebuild_fallback_finish(FallbackIndexBuilderContext *context, if (stop) { unlink(fname_tmp); - } else { + } + else { unlink(fname); rename(fname_tmp, fname); } diff --git a/source/blender/imbuf/intern/indexer_dv.c b/source/blender/imbuf/intern/indexer_dv.c index 4ccd8ec464d..f0c38f6db06 100644 --- a/source/blender/imbuf/intern/indexer_dv.c +++ b/source/blender/imbuf/intern/indexer_dv.c @@ -139,7 +139,8 @@ static void parse_packet(indexer_dv_context * This, unsigned char * p) This->rec_curr_year = parse_bcd(&b, 8); if (This->rec_curr_year < 25) { This->rec_curr_year += 2000; - } else { + } + else { This->rec_curr_year += 1900; } This->got_record_date = 1; @@ -201,7 +202,7 @@ static void parse_audio_headers( { int i; - for(i = 0; i < 9; i++) { + for (i = 0; i < 9; i++) { if (target[3] != 0xff) { parse_packet(This, target + 3); } @@ -238,7 +239,8 @@ static void inc_frame(int * frame, time_t * t, int isPAL) if (isPAL && *frame >= 25) { (*t)++; *frame = 0; - } else if (!isPAL && *frame >= 30) { + } + else if (!isPAL && *frame >= 30) { (*t)++; *frame = 0; } @@ -308,7 +310,8 @@ static void proc_frame(indexer_dv_context * This, if (This->ref_time_read < 0) { This->ref_time_read = This->ref_time_read_new; This->curr_frame = 0; - } else { + } + else { if (This->ref_time_read_new - This->ref_time_read == 1) { This->curr_frame = 0; This->ref_time_read = This->ref_time_read_new; @@ -316,9 +319,11 @@ static void proc_frame(indexer_dv_context * This, fill_gap(This, isPAL); This->gap_frame = -1; } - } else if (This->ref_time_read_new == This->ref_time_read) { + } + else if (This->ref_time_read_new == This->ref_time_read) { // do nothing - } else { + } + else { This->gap_start = This->ref_time_read; This->gap_frame = This->curr_frame; This->ref_time_read = This->ref_time_read_new; @@ -347,7 +352,8 @@ static void indexer_dv_proc_frame(anim_index_builder * idx, if (This->curr_frame >= 0) { write_index(This, entry); inc_frame(&This->curr_frame, &This->ref_time_read, isPAL); - } else { + } + else { This->backbuffer[This->fsize++] = *entry; if (This->fsize >= 31) { int i; diff --git a/source/blender/imbuf/intern/iris.c b/source/blender/imbuf/intern/iris.c index 38fc6f92c83..b4f1415207e 100644 --- a/source/blender/imbuf/intern/iris.c +++ b/source/blender/imbuf/intern/iris.c @@ -216,8 +216,8 @@ static void test_endian_zbuf(struct ImBuf *ibuf) int len; int *zval; - if( BIG_LONG(1) == 1 ) return; - if(ibuf->zbuf == NULL) return; + if ( BIG_LONG(1) == 1 ) return; + if (ibuf->zbuf == NULL) return; len= ibuf->x*ibuf->y; zval= ibuf->zbuf; @@ -262,7 +262,7 @@ struct ImBuf *imb_loadiris(unsigned char *mem, size_t size, int flags) (void)size; /* unused */ - if(!imb_is_a_iris(mem)) return NULL; + if (!imb_is_a_iris(mem)) return NULL; /*printf("new iris\n");*/ @@ -270,14 +270,14 @@ struct ImBuf *imb_loadiris(unsigned char *mem, size_t size, int flags) file_offset = 0; readheader(inf, &image); - if(image.imagic != IMAGIC) { + if (image.imagic != IMAGIC) { fprintf(stderr,"longimagedata: bad magic number in image file\n"); return(NULL); } rle = ISRLE(image.type); bpp = BPP(image.type); - if(bpp != 1 && bpp != 2) { + if (bpp != 1 && bpp != 2) { fprintf(stderr,"longimagedata: image must have 1 or 2 byte per pix chan\n"); return(NULL); } @@ -313,7 +313,7 @@ struct ImBuf *imb_loadiris(unsigned char *mem, size_t size, int flags) } cur = starttab[y+z*ysize]; } - if(badorder) + if (badorder) break; } @@ -325,9 +325,9 @@ struct ImBuf *imb_loadiris(unsigned char *mem, size_t size, int flags) zbase = (unsigned int *)ibuf->zbuf; if (badorder) { - for(z=0; z<zsize; z++) { + for (z=0; z<zsize; z++) { lptr = base; - for(y=0; y<ysize; y++) { + for (y=0; y<ysize; y++) { file_offset = starttab[y+z*ysize]; rledat = file_data + file_offset; @@ -337,20 +337,21 @@ struct ImBuf *imb_loadiris(unsigned char *mem, size_t size, int flags) lptr += xsize; } } - } else { + } + else { lptr = base; zptr = zbase; - for(y=0; y<ysize; y++) { + for (y=0; y<ysize; y++) { - for(z=0; z<zsize; z++) { + for (z=0; z<zsize; z++) { file_offset = starttab[y+z*ysize]; rledat = file_data + file_offset; file_offset += lengthtab[y+z*ysize]; - if(z<4) expandrow((uchar *)lptr, rledat, 3-z); - else if(z<8) expandrow((uchar *)zptr, rledat, 7-z); + if (z<4) expandrow((uchar *)lptr, rledat, 3-z); + else if (z<8) expandrow((uchar *)zptr, rledat, 7-z); } lptr += xsize; zptr += xsize; @@ -358,16 +359,17 @@ struct ImBuf *imb_loadiris(unsigned char *mem, size_t size, int flags) } - } else { /* bpp == 2 */ + } + else { /* bpp == 2 */ ibuf = IMB_allocImBuf(xsize, ysize, 32, (flags & IB_rect)|IB_rectfloat); fbase = ibuf->rect_float; if (badorder) { - for(z=0; z<zsize; z++) { + for (z=0; z<zsize; z++) { fptr = fbase; - for(y=0; y<ysize; y++) { + for (y=0; y<ysize; y++) { file_offset = starttab[y+z*ysize]; rledat = file_data + file_offset; @@ -377,12 +379,13 @@ struct ImBuf *imb_loadiris(unsigned char *mem, size_t size, int flags) fptr += xsize * 4; } } - } else { + } + else { fptr = fbase; - for(y=0; y<ysize; y++) { + for (y=0; y<ysize; y++) { - for(z=0; z<zsize; z++) { + for (z=0; z<zsize; z++) { file_offset = starttab[y+z*ysize]; @@ -400,7 +403,8 @@ struct ImBuf *imb_loadiris(unsigned char *mem, size_t size, int flags) MEM_freeN(starttab); MEM_freeN(lengthtab); - } else { + } + else { if (bpp == 1) { ibuf = IMB_allocImBuf(xsize, ysize, 8 * zsize, IB_rect); @@ -412,12 +416,12 @@ struct ImBuf *imb_loadiris(unsigned char *mem, size_t size, int flags) file_offset = 512; rledat = file_data + file_offset; - for(z = 0; z < zsize; z++) { + for (z = 0; z < zsize; z++) { - if(z<4) lptr = base; - else if(z<8) lptr= zbase; + if (z<4) lptr = base; + else if (z<8) lptr= zbase; - for(y = 0; y < ysize; y++) { + for (y = 0; y < ysize; y++) { interleaverow((uchar *)lptr, rledat, 3-z, xsize); rledat += xsize; @@ -426,7 +430,8 @@ struct ImBuf *imb_loadiris(unsigned char *mem, size_t size, int flags) } } - } else { /* bpp == 2 */ + } + else { /* bpp == 2 */ ibuf = IMB_allocImBuf(xsize, ysize, 32, (flags & IB_rect)|IB_rectfloat); @@ -435,11 +440,11 @@ struct ImBuf *imb_loadiris(unsigned char *mem, size_t size, int flags) file_offset = 512; rledat = file_data + file_offset; - for(z = 0; z < zsize; z++) { + for (z = 0; z < zsize; z++) { fptr = fbase; - for(y = 0; y < ysize; y++) { + for (y = 0; y < ysize; y++) { interleaverow2(fptr, rledat, 3-z, xsize); rledat += xsize * 2; @@ -455,14 +460,15 @@ struct ImBuf *imb_loadiris(unsigned char *mem, size_t size, int flags) if (bpp == 1) { uchar * rect; - if (image.zsize == 1){ + if (image.zsize == 1) { rect = (uchar *) ibuf->rect; for (x = ibuf->x * ibuf->y; x > 0; x--) { rect[0] = 255; rect[1] = rect[2] = rect[3]; rect += 4; } - } else if (image.zsize == 2){ + } + else if (image.zsize == 2) { /* grayscale with alpha */ rect = (uchar *) ibuf->rect; for (x = ibuf->x * ibuf->y; x > 0; x--) { @@ -470,7 +476,8 @@ struct ImBuf *imb_loadiris(unsigned char *mem, size_t size, int flags) rect[1] = rect[2] = rect[3]; rect += 4; } - } else if (image.zsize == 3){ + } + else if (image.zsize == 3) { /* add alpha */ rect = (uchar *) ibuf->rect; for (x = ibuf->x * ibuf->y; x > 0; x--) { @@ -479,16 +486,18 @@ struct ImBuf *imb_loadiris(unsigned char *mem, size_t size, int flags) } } - } else { /* bpp == 2 */ + } + else { /* bpp == 2 */ - if (image.zsize == 1){ + if (image.zsize == 1) { fbase = ibuf->rect_float; for (x = ibuf->x * ibuf->y; x > 0; x--) { fbase[0] = 1; fbase[1] = fbase[2] = fbase[3]; fbase += 4; } - } else if (image.zsize == 2){ + } + else if (image.zsize == 2) { /* grayscale with alpha */ fbase = ibuf->rect_float; for (x = ibuf->x * ibuf->y; x > 0; x--) { @@ -496,7 +505,8 @@ struct ImBuf *imb_loadiris(unsigned char *mem, size_t size, int flags) fbase[1] = fbase[2] = fbase[3]; fbase += 4; } - } else if (image.zsize == 3){ + } + else if (image.zsize == 3) { /* add alpha */ fbase = ibuf->rect_float; for (x = ibuf->x * ibuf->y; x > 0; x--) { @@ -558,7 +568,7 @@ static void expandrow2(float *optr, unsigned char *iptr, int z) if ( !(count = (pixel & 0x7f)) ) return; - if(pixel & 0x80) { + if (pixel & 0x80) { while(count>=8) { optr[0*4] = ((iptr[0]<<8) | (iptr[1]<<0))/(float)0xFFFF; optr[1*4] = ((iptr[2]<<8) | (iptr[3]<<0))/(float)0xFFFF; @@ -577,7 +587,8 @@ static void expandrow2(float *optr, unsigned char *iptr, int z) iptr+=2; optr+=4; } - } else { + } + else { pixel_f = ((iptr[0]<<8) | (iptr[1]<<0))/(float)0xFFFF; iptr += 2; @@ -610,7 +621,7 @@ static void expandrow(unsigned char *optr, unsigned char *iptr, int z) pixel = *iptr++; if ( !(count = (pixel & 0x7f)) ) return; - if(pixel & 0x80) { + if (pixel & 0x80) { while(count>=8) { optr[0*4] = iptr[0]; optr[1*4] = iptr[1]; @@ -628,7 +639,8 @@ static void expandrow(unsigned char *optr, unsigned char *iptr, int z) *optr = *iptr++; optr+=4; } - } else { + } + else { pixel = *iptr++; while(count>=8) { optr[0*4] = pixel; @@ -675,7 +687,7 @@ static int output_iris(unsigned int *lptr, int xsize, int ysize, int zsize, cons goodwrite = 1; outf = BLI_fopen(name, "wb"); - if(!outf) return 0; + if (!outf) return 0; tablen = ysize*zsize*sizeof(int); @@ -689,7 +701,7 @@ static int output_iris(unsigned int *lptr, int xsize, int ysize, int zsize, cons memset(image, 0, sizeof(IMAGE)); image->imagic = IMAGIC; image->type = RLE(1); - if(zsize>1) + if (zsize>1) image->dim = 3; else image->dim = 2; @@ -710,14 +722,14 @@ static int output_iris(unsigned int *lptr, int xsize, int ysize, int zsize, cons len = compressrow((uchar *)lumbuf,rlebuf,CHANOFFSET(z),xsize); } else { - if(z<4) { + if (z<4) { len = compressrow((uchar *)lptr, rlebuf,CHANOFFSET(z),xsize); } - else if(z<8 && zptr) { + else if (z<8 && zptr) { len = compressrow((uchar *)zptr, rlebuf,CHANOFFSET(z-4),xsize); } } - if(len>rlebuflen) { + if (len>rlebuflen) { fprintf(stderr,"output_iris: rlebuf is too small - bad poop\n"); exit(1); } @@ -727,7 +739,7 @@ static int output_iris(unsigned int *lptr, int xsize, int ysize, int zsize, cons pos += len; } lptr += xsize; - if(zptr) zptr += xsize; + if (zptr) zptr += xsize; } fseek(outf,512,SEEK_SET); @@ -739,7 +751,7 @@ static int output_iris(unsigned int *lptr, int xsize, int ysize, int zsize, cons MEM_freeN(rlebuf); MEM_freeN(lumbuf); fclose(outf); - if(goodwrite) + if (goodwrite) return 1; else { fprintf(stderr,"output_iris: not enough space for image!!\n"); diff --git a/source/blender/imbuf/intern/jp2.c b/source/blender/imbuf/intern/jp2.c index 87450170c66..275d19d518c 100644 --- a/source/blender/imbuf/intern/jp2.c +++ b/source/blender/imbuf/intern/jp2.c @@ -157,7 +157,7 @@ struct ImBuf *imb_jp2_decode(unsigned char *mem, size_t size, int flags) opj_cio_close(cio); - if((image->numcomps * image->x1 * image->y1) == 0) { + if ((image->numcomps * image->x1 * image->y1) == 0) { fprintf(stderr,"\nError: invalid raw image parameters\n"); return NULL; } @@ -195,7 +195,7 @@ struct ImBuf *imb_jp2_decode(unsigned char *mem, size_t size, int flags) ibuf= IMB_allocImBuf(w, h, planes, use_float ? IB_rectfloat : IB_rect); if (ibuf==NULL) { - if(dinfo) + if (dinfo) opj_destroy_decompress(dinfo); return NULL; } @@ -217,7 +217,8 @@ struct ImBuf *imb_jp2_decode(unsigned char *mem, size_t size, int flags) else rect_float[3]= 1.0f; } - } else { + } + else { /* rgb or rgba 12bits+ */ for (i = 0; i < w * h; i++, rect_float+=4) { index = w * h - ((i) / (w) + 1) * w + (i) % (w); @@ -233,7 +234,8 @@ struct ImBuf *imb_jp2_decode(unsigned char *mem, size_t size, int flags) } } - } else { + } + else { unsigned char *rect= (unsigned char *)ibuf->rect; if (image->numcomps < 3) { @@ -248,7 +250,8 @@ struct ImBuf *imb_jp2_decode(unsigned char *mem, size_t size, int flags) else rect[3]= 255; } - } else { + } + else { /* 8bit rgb or rgba */ for (i = 0; i < w * h; i++, rect+=4) { int index = w * h - ((i) / (w) + 1) * w + (i) % (w); @@ -266,7 +269,7 @@ struct ImBuf *imb_jp2_decode(unsigned char *mem, size_t size, int flags) } /* free remaining structures */ - if(dinfo) { + if (dinfo) { opj_destroy_decompress(dinfo); } @@ -365,13 +368,13 @@ static void cinema_setup_encoder(opj_cparameters_t *parameters,opj_image_t *imag int i; float temp_rate; - switch (parameters->cp_cinema){ + switch (parameters->cp_cinema) { case CINEMA2K_24: case CINEMA2K_48: - if(parameters->numresolution > 6){ + if (parameters->numresolution > 6) { parameters->numresolution = 6; } - if (!((image->comps[0].w == 2048) || (image->comps[0].h == 1080))){ + if (!((image->comps[0].w == 2048) || (image->comps[0].h == 1080))) { fprintf(stdout,"Image coordinates %d x %d is not 2K compliant.\nJPEG Digital Cinema Profile-3 " "(2K profile) compliance requires that at least one of coordinates match 2048 x 1080\n", image->comps[0].w,image->comps[0].h); @@ -380,15 +383,16 @@ static void cinema_setup_encoder(opj_cparameters_t *parameters,opj_image_t *imag break; case CINEMA4K_24: - if(parameters->numresolution < 1){ - parameters->numresolution = 1; - }else if(parameters->numresolution > 7){ - parameters->numresolution = 7; - } - if (!((image->comps[0].w == 4096) || (image->comps[0].h == 2160))){ - fprintf(stdout,"Image coordinates %d x %d is not 4K compliant.\nJPEG Digital Cinema Profile-4" - "(4K profile) compliance requires that at least one of coordinates match 4096 x 2160\n", - image->comps[0].w,image->comps[0].h); + if (parameters->numresolution < 1) { + parameters->numresolution = 1; + } + else if (parameters->numresolution > 7) { + parameters->numresolution = 7; + } + if (!((image->comps[0].w == 4096) || (image->comps[0].h == 2160))) { + fprintf(stdout,"Image coordinates %d x %d is not 4K compliant.\nJPEG Digital Cinema Profile-4" + "(4K profile) compliance requires that at least one of coordinates match 4096 x 2160\n", + image->comps[0].w,image->comps[0].h); parameters->cp_rsiz = STD_RSIZ; } parameters->numpocs = initialise_4K_poc(parameters->POC,parameters->numresolution); @@ -398,21 +402,23 @@ static void cinema_setup_encoder(opj_cparameters_t *parameters,opj_image_t *imag break; } - switch (parameters->cp_cinema){ + switch (parameters->cp_cinema) { case CINEMA2K_24: case CINEMA4K_24: - for(i=0 ; i<parameters->tcp_numlayers ; i++){ + for (i=0 ; i<parameters->tcp_numlayers ; i++) { temp_rate = 0; - if (img_fol->rates[i]== 0){ + if (img_fol->rates[i]== 0) { parameters->tcp_rates[0]= ((float) (image->numcomps * image->comps[0].w * image->comps[0].h * image->comps[0].prec))/ (CINEMA_24_CS * 8 * image->comps[0].dx * image->comps[0].dy); - }else{ + } + else { temp_rate =((float) (image->numcomps * image->comps[0].w * image->comps[0].h * image->comps[0].prec))/ (img_fol->rates[i] * 8 * image->comps[0].dx * image->comps[0].dy); - if (temp_rate > CINEMA_24_CS ){ + if (temp_rate > CINEMA_24_CS ) { parameters->tcp_rates[i]= ((float) (image->numcomps * image->comps[0].w * image->comps[0].h * image->comps[0].prec))/ (CINEMA_24_CS * 8 * image->comps[0].dx * image->comps[0].dy); - }else{ + } + else { parameters->tcp_rates[i]= img_fol->rates[i]; } } @@ -421,18 +427,20 @@ static void cinema_setup_encoder(opj_cparameters_t *parameters,opj_image_t *imag break; case CINEMA2K_48: - for(i=0 ; i<parameters->tcp_numlayers ; i++){ + for (i=0 ; i<parameters->tcp_numlayers ; i++) { temp_rate = 0; - if (img_fol->rates[i]== 0){ + if (img_fol->rates[i]== 0) { parameters->tcp_rates[0]= ((float) (image->numcomps * image->comps[0].w * image->comps[0].h * image->comps[0].prec))/ (CINEMA_48_CS * 8 * image->comps[0].dx * image->comps[0].dy); - }else{ + } + else { temp_rate =((float) (image->numcomps * image->comps[0].w * image->comps[0].h * image->comps[0].prec))/ (img_fol->rates[i] * 8 * image->comps[0].dx * image->comps[0].dy); - if (temp_rate > CINEMA_48_CS ){ + if (temp_rate > CINEMA_48_CS ) { parameters->tcp_rates[0]= ((float) (image->numcomps * image->comps[0].w * image->comps[0].h * image->comps[0].prec))/ (CINEMA_48_CS * 8 * image->comps[0].dx * image->comps[0].dy); - }else{ + } + else { parameters->tcp_rates[i]= img_fol->rates[i]; } } @@ -477,9 +485,9 @@ static opj_image_t* ibuftoimage(ImBuf *ibuf, opj_cparameters_t *parameters) parameters->cp_cinema= CINEMA2K_24; } } - if (parameters->cp_cinema){ + if (parameters->cp_cinema) { img_fol.rates = (float*)MEM_mallocN(parameters->tcp_numlayers * sizeof(float), "jp2_rates"); - for(i=0; i< parameters->tcp_numlayers; i++){ + for (i=0; i< parameters->tcp_numlayers; i++) { img_fol.rates[i] = parameters->tcp_rates[i]; } cinema_parameters(parameters); @@ -508,7 +516,7 @@ static opj_image_t* ibuftoimage(ImBuf *ibuf, opj_cparameters_t *parameters) /* initialize image components */ memset(&cmptparm[0], 0, 4 * sizeof(opj_image_cmptparm_t)); - for(i = 0; i < numcomps; i++) { + for (i = 0; i < numcomps; i++) { cmptparm[i].prec = prec; cmptparm[i].bpp = prec; cmptparm[i].sgnd = 0; @@ -519,7 +527,7 @@ static opj_image_t* ibuftoimage(ImBuf *ibuf, opj_cparameters_t *parameters) } /* create the image */ image = opj_image_create(numcomps, &cmptparm[0], color_space); - if(!image) { + if (!image) { printf("Error: opj_image_create() failed\n"); return NULL; } @@ -545,9 +553,9 @@ static opj_image_t* ibuftoimage(ImBuf *ibuf, opj_cparameters_t *parameters) switch (prec) { case 8: /* Convert blenders float color channels to 8,12 or 16bit ints */ - for(y=h-1; y>=0; y--) { + for (y=h-1; y>=0; y--) { y_row = y*w; - for(x=0; x<w; x++, rect_float+=4) { + for (x=0; x<w; x++, rect_float+=4) { i = y_row + x; if (ibuf->profile == IB_PROFILE_LINEAR_RGB) @@ -565,9 +573,9 @@ static opj_image_t* ibuftoimage(ImBuf *ibuf, opj_cparameters_t *parameters) break; case 12: - for(y=h-1; y>=0; y--) { + for (y=h-1; y>=0; y--) { y_row = y*w; - for(x=0; x<w; x++, rect_float+=4) { + for (x=0; x<w; x++, rect_float+=4) { i = y_row + x; if (ibuf->profile == IB_PROFILE_LINEAR_RGB) @@ -584,9 +592,9 @@ static opj_image_t* ibuftoimage(ImBuf *ibuf, opj_cparameters_t *parameters) } break; case 16: - for(y=h-1; y>=0; y--) { + for (y=h-1; y>=0; y--) { y_row = y*w; - for(x=0; x<w; x++, rect_float+=4) { + for (x=0; x<w; x++, rect_float+=4) { i = y_row + x; if (ibuf->profile == IB_PROFILE_LINEAR_RGB) @@ -603,13 +611,14 @@ static opj_image_t* ibuftoimage(ImBuf *ibuf, opj_cparameters_t *parameters) } break; } - } else { + } + else { /* just use rect*/ switch (prec) { case 8: - for(y=h-1; y>=0; y--) { + for (y=h-1; y>=0; y--) { y_row = y*w; - for(x=0; x<w; x++, rect+=4) { + for (x=0; x<w; x++, rect+=4) { i = y_row + x; image->comps[0].data[i] = rect[0]; @@ -622,9 +631,9 @@ static opj_image_t* ibuftoimage(ImBuf *ibuf, opj_cparameters_t *parameters) break; case 12: /* Up Sampling, a bit pointless but best write the bit depth requested */ - for(y=h-1; y>=0; y--) { + for (y=h-1; y>=0; y--) { y_row = y*w; - for(x=0; x<w; x++, rect+=4) { + for (x=0; x<w; x++, rect+=4) { i = y_row + x; image->comps[0].data[i]= UPSAMPLE_8_TO_12(rect[0]); @@ -636,9 +645,9 @@ static opj_image_t* ibuftoimage(ImBuf *ibuf, opj_cparameters_t *parameters) } break; case 16: - for(y=h-1; y>=0; y--) { + for (y=h-1; y>=0; y--) { y_row = y*w; - for(x=0; x<w; x++, rect+=4) { + for (x=0; x<w; x++, rect+=4) { i = y_row + x; image->comps[0].data[i]= UPSAMPLE_8_TO_16(rect[0]); @@ -655,7 +664,7 @@ static opj_image_t* ibuftoimage(ImBuf *ibuf, opj_cparameters_t *parameters) /* Decide if MCT should be used */ parameters->tcp_mct = image->numcomps == 3 ? 1 : 0; - if(parameters->cp_cinema){ + if (parameters->cp_cinema) { cinema_setup_encoder(parameters,image,&img_fol); } diff --git a/source/blender/imbuf/intern/jpeg.c b/source/blender/imbuf/intern/jpeg.c index 75a5f274413..3f3ebc5872d 100644 --- a/source/blender/imbuf/intern/jpeg.c +++ b/source/blender/imbuf/intern/jpeg.c @@ -158,7 +158,7 @@ static void skip_input_data(j_decompress_ptr cinfo, long num_bytes) { my_src_ptr src = (my_src_ptr) cinfo->src; - if(num_bytes > 0) { + if (num_bytes > 0) { // prevent skipping over file end size_t skip_size = (size_t)num_bytes <= src->pub.bytes_in_buffer ? num_bytes : src->pub.bytes_in_buffer; @@ -372,8 +372,8 @@ static ImBuf * ibJpegImageFromCinfo(struct jpeg_decompress_struct * cinfo, int f } marker= cinfo->marker_list; - while(marker) { - if(marker->marker != JPEG_COM) + while (marker) { + if (marker->marker != JPEG_COM) goto next_stamp_marker; /* @@ -385,7 +385,7 @@ static ImBuf * ibJpegImageFromCinfo(struct jpeg_decompress_struct * cinfo, int f * That is why we need split it to the * common key/value here. */ - if(strncmp((char *) marker->data, "Blender", 7)) { + if (strncmp((char *) marker->data, "Blender", 7)) { /* * Maybe the file have text that * we don't know "what it's", in that @@ -432,7 +432,7 @@ next_stamp_marker: } jpeg_destroy((j_common_ptr) cinfo); - if(ibuf) { + if (ibuf) { ibuf->ftype = ibuf_ftype; ibuf->profile = IB_PROFILE_SRGB; } @@ -447,7 +447,7 @@ ImBuf * imb_load_jpeg (unsigned char * buffer, size_t size, int flags) struct my_error_mgr jerr; ImBuf * ibuf; - if(!imb_is_a_jpeg(buffer)) return NULL; + if (!imb_is_a_jpeg(buffer)) return NULL; cinfo->err = jpeg_std_error(&jerr.pub); jerr.pub.error_exit = jpeg_error; @@ -488,11 +488,11 @@ static void write_jpeg(struct jpeg_compress_struct * cinfo, struct ImBuf * ibuf) memcpy(neogeo + 6, &ibuf_ftype, 4); jpeg_write_marker(cinfo, 0xe1, (JOCTET*) neogeo, 10); - if(ibuf->metadata) { + if (ibuf->metadata) { /* key + max value + "Blender" */ text= MEM_mallocN(530, "stamp info read"); iptr= ibuf->metadata; - while(iptr) { + while (iptr) { if (!strcmp (iptr->key, "None")) { jpeg_write_marker(cinfo, JPEG_COM, (JOCTET *) iptr->value, strlen (iptr->value) + 1); goto next_stamp_info; @@ -520,11 +520,11 @@ next_stamp_info: cinfo->input_components * cinfo->image_width, "jpeg row_pointer"); - for(y = ibuf->y - 1; y >= 0; y--){ + for (y = ibuf->y - 1; y >= 0; y--) { rect = (uchar *) (ibuf->rect + y * ibuf->x); buffer = row_pointer[0]; - switch(cinfo->in_color_space){ + switch(cinfo->in_color_space) { case JCS_RGB: for (x = 0; x < ibuf->x; x++) { *buffer++ = rect[0]; @@ -577,7 +577,7 @@ static int init_jpeg(FILE * outfile, struct jpeg_compress_struct * cinfo, struct if (ibuf->planes == 32) cinfo->in_color_space = JCS_UNKNOWN; #endif - switch(cinfo->in_color_space){ + switch(cinfo->in_color_space) { case JCS_RGB: cinfo->input_components = 3; break; diff --git a/source/blender/imbuf/intern/metadata.c b/source/blender/imbuf/intern/metadata.c index 2b6fed59004..0da7358b55b 100644 --- a/source/blender/imbuf/intern/metadata.c +++ b/source/blender/imbuf/intern/metadata.c @@ -95,7 +95,8 @@ int IMB_metadata_add_field(struct ImBuf* img, const char* key, const char* value if (!img->metadata) { img->metadata = MEM_callocN(sizeof(ImMetaData), "ImMetaData"); info = img->metadata; - } else { + } + else { info = img->metadata; last = info; while (info) { diff --git a/source/blender/imbuf/intern/moviecache.c b/source/blender/imbuf/intern/moviecache.c index 67d9a602d12..24317278a43 100644 --- a/source/blender/imbuf/intern/moviecache.c +++ b/source/blender/imbuf/intern/moviecache.c @@ -120,7 +120,7 @@ static void check_unused_keys(MovieCache *cache) BLI_ghashIterator_step(iter); - if(!item->ibuf) + if (!item->ibuf) BLI_ghash_remove(cache->hash, key, moviecache_keyfree, moviecache_valfree); } @@ -154,22 +154,22 @@ static size_t IMB_get_size_in_memory(ImBuf *ibuf) size+= sizeof(ImBuf); - if(ibuf->rect) + if (ibuf->rect) channel_size+= sizeof(char); - if(ibuf->rect_float) + if (ibuf->rect_float) channel_size+= sizeof(float); size+= channel_size*ibuf->x*ibuf->y*ibuf->channels; - if(ibuf->miptot) { - for(a= 0; a<ibuf->miptot; a++) { - if(ibuf->mipmap[a]) + if (ibuf->miptot) { + for (a= 0; a<ibuf->miptot; a++) { + if (ibuf->mipmap[a]) size+= IMB_get_size_in_memory(ibuf->mipmap[a]); } } - if(ibuf->tiles) { + if (ibuf->tiles) { size+= sizeof(unsigned int)*ibuf->ytiles*ibuf->xtiles; } @@ -181,7 +181,7 @@ static size_t get_item_size (void *p) size_t size= sizeof(MovieCacheItem); MovieCacheItem *item= (MovieCacheItem *) p; - if(item->ibuf) + if (item->ibuf) size+= IMB_get_size_in_memory(item->ibuf); return size; @@ -194,7 +194,7 @@ void IMB_moviecache_init(void) void IMB_moviecache_destruct(void) { - if(limitor) + if (limitor) delete_MEM_CacheLimiter(limitor); } @@ -223,7 +223,7 @@ void IMB_moviecache_put(MovieCache *cache, void *userkey, ImBuf *ibuf) MovieCacheKey *key; MovieCacheItem *item; - if(!limitor) + if (!limitor) IMB_moviecache_init(); IMB_refImBuf(ibuf); @@ -251,7 +251,7 @@ void IMB_moviecache_put(MovieCache *cache, void *userkey, ImBuf *ibuf) /* cache limiter can't remove unused keys which points to destoryed values */ check_unused_keys(cache); - if(cache->points) { + if (cache->points) { MEM_freeN(cache->points); cache->points= NULL; } @@ -266,10 +266,10 @@ ImBuf* IMB_moviecache_get(MovieCache *cache, void *userkey) key.userkey= userkey; item= (MovieCacheItem*)BLI_ghash_lookup(cache->hash, &key); - if(item) { + if (item) { item->last_access= cache->curtime++; - if(item->ibuf) { + if (item->ibuf) { MEM_CacheLimiter_touch(item->c_handle); IMB_refImBuf(item->ibuf); @@ -288,7 +288,7 @@ void IMB_moviecache_free(MovieCache *cache) BLI_mempool_destroy(cache->items_pool); BLI_mempool_destroy(cache->userkeys_pool); - if(cache->points) + if (cache->points) MEM_freeN(cache->points); MEM_freeN(cache); @@ -300,20 +300,21 @@ void IMB_moviecache_get_cache_segments(MovieCache *cache, int proxy, int render_ *totseg_r= 0; *points_r= NULL; - if(!cache->getdatafp) + if (!cache->getdatafp) return; - if(cache->proxy!=proxy || cache->render_flags!=render_flags) { - if(cache->points) + if (cache->proxy!=proxy || cache->render_flags!=render_flags) { + if (cache->points) MEM_freeN(cache->points); cache->points= NULL; } - if(cache->points) { + if (cache->points) { *totseg_r= cache->totseg; *points_r= cache->points; - } else { + } + else { int totframe= BLI_ghash_size(cache->hash); int *frames= MEM_callocN(totframe*sizeof(int), "movieclip cache frames"); int a, totseg= 0; @@ -326,10 +327,10 @@ void IMB_moviecache_get_cache_segments(MovieCache *cache, int proxy, int render_ MovieCacheItem *item= BLI_ghashIterator_getValue(iter); int framenr, curproxy, curflags; - if(item->ibuf) { + if (item->ibuf) { cache->getdatafp(key->userkey, &framenr, &curproxy, &curflags); - if(curproxy==proxy && curflags==render_flags) + if (curproxy==proxy && curflags==render_flags) frames[a++]= framenr; } @@ -341,30 +342,30 @@ void IMB_moviecache_get_cache_segments(MovieCache *cache, int proxy, int render_ qsort(frames, totframe, sizeof(int), compare_int); /* count */ - for(a= 0; a<totframe; a++) { - if(a && frames[a]-frames[a-1]!=1) + for (a= 0; a<totframe; a++) { + if (a && frames[a]-frames[a-1]!=1) totseg++; - if(a==totframe-1) + if (a==totframe-1) totseg++; } - if(totseg) { + if (totseg) { int b, *points; points= MEM_callocN(2*sizeof(int)*totseg, "movieclip cache segments"); /* fill */ - for(a= 0, b= 0; a<totframe; a++) { - if(a==0) + for (a= 0, b= 0; a<totframe; a++) { + if (a==0) points[b++]= frames[a]; - if(a && frames[a]-frames[a-1]!=1) { + if (a && frames[a]-frames[a-1]!=1) { points[b++]= frames[a-1]; points[b++]= frames[a]; } - if(a==totframe-1) + if (a==totframe-1) points[b++]= frames[a]; } diff --git a/source/blender/imbuf/intern/png.c b/source/blender/imbuf/intern/png.c index 78c7c672e22..de935c7cc42 100644 --- a/source/blender/imbuf/intern/png.c +++ b/source/blender/imbuf/intern/png.c @@ -114,7 +114,7 @@ int imb_savepng(struct ImBuf *ibuf, const char *name, int flags) compression= compression < 0 ? 0 : (compression > 9 ? 9 : compression); /* for prints */ - if(flags & IB_mem) + if (flags & IB_mem) name= "<memory>"; bytesperpixel = (ibuf->planes + 7) >> 3; @@ -256,7 +256,7 @@ int imb_savepng(struct ImBuf *ibuf, const char *name, int flags) } - if(ibuf->ppm[0] > 0.0 && ibuf->ppm[1] > 0.0) { + if (ibuf->ppm[0] > 0.0 && ibuf->ppm[1] > 0.0) { png_set_pHYs(png_ptr, info_ptr, (unsigned int)(ibuf->ppm[0] + 0.5), (unsigned int)(ibuf->ppm[1] + 0.5), PNG_RESOLUTION_METER); } @@ -366,7 +366,8 @@ struct ImBuf *imb_loadpng(unsigned char *mem, size_t size, int flags) png_set_palette_to_rgb(png_ptr); if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) { bytesperpixel = 4; - } else { + } + else { bytesperpixel = 3; } break; @@ -392,8 +393,8 @@ struct ImBuf *imb_loadpng(unsigned char *mem, size_t size, int flags) int unit_type; png_uint_32 xres, yres; - if(png_get_pHYs(png_ptr, info_ptr, &xres, &yres, &unit_type)) - if(unit_type == PNG_RESOLUTION_METER) { + if (png_get_pHYs(png_ptr, info_ptr, &xres, &yres, &unit_type)) + if (unit_type == PNG_RESOLUTION_METER) { ibuf->ppm[0]= xres; ibuf->ppm[1]= yres; } @@ -470,7 +471,7 @@ struct ImBuf *imb_loadpng(unsigned char *mem, size_t size, int flags) if (flags & IB_metadata) { png_text* text_chunks; int count = png_get_text(png_ptr, info_ptr, &text_chunks, NULL); - for(i = 0; i < count; i++) { + for (i = 0; i < count; i++) { IMB_metadata_add_field(ibuf, text_chunks[i].key, text_chunks[i].text); ibuf->flags |= IB_metadata; } diff --git a/source/blender/imbuf/intern/radiance_hdr.c b/source/blender/imbuf/intern/radiance_hdr.c index 42e4db54f3f..5b093dc6cac 100644 --- a/source/blender/imbuf/intern/radiance_hdr.c +++ b/source/blender/imbuf/intern/radiance_hdr.c @@ -262,7 +262,8 @@ static int fwritecolrs(FILE* file, int width, int channels, unsigned char* ibufs fcol[RED] = fpscan[j]; fcol[GRN] = (channels >= 2)? fpscan[j+1]: fpscan[j]; fcol[BLU] = (channels >= 3)? fpscan[j+2]: fpscan[j]; - } else { + } + else { fcol[RED] = (float)ibufscan[j] / 255.f; fcol[GRN] = (float)((channels >= 2)? ibufscan[j+1]: ibufscan[j]) / 255.f; fcol[BLU] = (float)((channels >= 3)? ibufscan[j+2]: ibufscan[j]) / 255.f; @@ -343,9 +344,9 @@ int imb_savehdr(struct ImBuf *ibuf, const char *name, int flags) writeHeader(file, width, height); - if(ibuf->rect) + if (ibuf->rect) cp= (unsigned char *)ibuf->rect + ibuf->channels*(height-1)*width; - if(ibuf->rect_float) + if (ibuf->rect_float) fp= ibuf->rect_float + ibuf->channels*(height-1)*width; for (y=height-1;y>=0;y--) { @@ -354,8 +355,8 @@ int imb_savehdr(struct ImBuf *ibuf, const char *name, int flags) printf("HDR write error\n"); return 0; } - if(cp) cp-= ibuf->channels*width; - if(fp) fp-= ibuf->channels*width; + if (cp) cp-= ibuf->channels*width; + if (fp) fp-= ibuf->channels*width; } fclose(file); diff --git a/source/blender/imbuf/intern/readimage.c b/source/blender/imbuf/intern/readimage.c index 2ee389a42f6..61f90f7a97a 100644 --- a/source/blender/imbuf/intern/readimage.c +++ b/source/blender/imbuf/intern/readimage.c @@ -55,16 +55,16 @@ ImBuf *IMB_ibImageFromMemory(unsigned char *mem, size_t size, int flags, const c ImBuf *ibuf; ImFileType *type; - if(mem == NULL) { + if (mem == NULL) { fprintf(stderr, "%s: NULL pointer\n", __func__); return NULL; } - for(type=IMB_FILE_TYPES; type->is_a; type++) { - if(type->load) { + for (type=IMB_FILE_TYPES; type->is_a; type++) { + if (type->load) { ibuf= type->load(mem, size, flags); - if(ibuf) { - if(flags & IB_premul) { + if (ibuf) { + if (flags & IB_premul) { IMB_premultiply_alpha(ibuf); ibuf->flags |= IB_premul; } @@ -85,19 +85,19 @@ ImBuf *IMB_loadifffile(int file, int flags, const char *descr) unsigned char *mem; size_t size; - if(file == -1) return NULL; + if (file == -1) return NULL; size= BLI_file_descriptor_size(file); mem= mmap(NULL, size, PROT_READ, MAP_SHARED, file, 0); - if(mem==(unsigned char*)-1) { + if (mem==(unsigned char*)-1) { fprintf(stderr, "%s: couldn't get mapping %s\n", __func__, descr); return NULL; } ibuf= IMB_ibImageFromMemory(mem, size, flags, descr); - if(munmap(mem, size)) + if (munmap(mem, size)) fprintf(stderr, "%s: couldn't unmap file %s\n", __func__, descr); return ibuf; @@ -106,12 +106,12 @@ ImBuf *IMB_loadifffile(int file, int flags, const char *descr) static void imb_cache_filename(char *filename, const char *name, int flags) { /* read .tx instead if it exists and is not older */ - if(flags & IB_tilecache) { + if (flags & IB_tilecache) { BLI_strncpy(filename, name, IB_FILENAME_SIZE); - if(!BLI_replace_extension(filename, IB_FILENAME_SIZE, ".tx")) + if (!BLI_replace_extension(filename, IB_FILENAME_SIZE, ".tx")) return; - if(BLI_file_older(name, filename)) + if (BLI_file_older(name, filename)) return; } @@ -127,16 +127,16 @@ ImBuf *IMB_loadiffname(const char *filepath, int flags) imb_cache_filename(filepath_tx, filepath, flags); file = BLI_open(filepath_tx, O_BINARY|O_RDONLY, 0); - if(file < 0) return NULL; + if (file < 0) return NULL; ibuf= IMB_loadifffile(file, flags, filepath_tx); - if(ibuf) { + if (ibuf) { BLI_strncpy(ibuf->name, filepath, sizeof(ibuf->name)); BLI_strncpy(ibuf->cachename, filepath_tx, sizeof(ibuf->cachename)); - for(a=1; a<ibuf->miptot; a++) + for (a=1; a<ibuf->miptot; a++) BLI_strncpy(ibuf->mipmap[a-1]->cachename, filepath_tx, sizeof(ibuf->cachename)); - if(flags & IB_fields) IMB_de_interlace(ibuf); + if (flags & IB_fields) IMB_de_interlace(ibuf); } close(file); @@ -153,11 +153,11 @@ ImBuf *IMB_testiffname(const char *filepath, int flags) imb_cache_filename(filepath_tx, filepath, flags); file = BLI_open(filepath_tx,O_BINARY|O_RDONLY,0); - if(file < 0) return NULL; + if (file < 0) return NULL; ibuf=IMB_loadifffile(file, flags|IB_test|IB_multilayer, filepath_tx); - if(ibuf) { + if (ibuf) { BLI_strncpy(ibuf->name, filepath, sizeof(ibuf->name)); BLI_strncpy(ibuf->cachename, filepath_tx, sizeof(ibuf->cachename)); } @@ -173,21 +173,21 @@ static void imb_loadtilefile(ImBuf *ibuf, int file, int tx, int ty, unsigned int unsigned char *mem; size_t size; - if(file == -1) return; + if (file == -1) return; size= BLI_file_descriptor_size(file); mem= mmap(NULL, size, PROT_READ, MAP_SHARED, file, 0); - if(mem==(unsigned char*)-1) { + if (mem==(unsigned char*)-1) { fprintf(stderr, "Couldn't get memory mapping for %s\n", ibuf->cachename); return; } - for(type=IMB_FILE_TYPES; type->is_a; type++) - if(type->load_tile && type->ftype(type, ibuf)) + for (type=IMB_FILE_TYPES; type->is_a; type++) + if (type->load_tile && type->ftype(type, ibuf)) type->load_tile(ibuf, mem, size, tx, ty, rect); - if(munmap(mem, size)) + if (munmap(mem, size)) fprintf(stderr, "Couldn't unmap memory for %s.\n", ibuf->cachename); } @@ -196,7 +196,7 @@ void imb_loadtile(ImBuf *ibuf, int tx, int ty, unsigned int *rect) int file; file = BLI_open(ibuf->cachename, O_BINARY|O_RDONLY, 0); - if(file < 0) return; + if (file < 0) return; imb_loadtilefile(ibuf, file, tx, ty, rect); diff --git a/source/blender/imbuf/intern/rectop.c b/source/blender/imbuf/intern/rectop.c index 888fe5713d1..6ea84fd6717 100644 --- a/source/blender/imbuf/intern/rectop.c +++ b/source/blender/imbuf/intern/rectop.c @@ -61,11 +61,11 @@ static void blend_color_add(char *cp, char *cp1, char *cp2, int fac) int temp; temp= cp1[0] + ((fac*cp2[0])/255); - if(temp>254) cp[0]= 255; else cp[0]= temp; + if (temp>254) cp[0]= 255; else cp[0]= temp; temp= cp1[1] + ((fac*cp2[1])/255); - if(temp>254) cp[1]= 255; else cp[1]= temp; + if (temp>254) cp[1]= 255; else cp[1]= temp; temp= cp1[2] + ((fac*cp2[2])/255); - if(temp>254) cp[2]= 255; else cp[2]= temp; + if (temp>254) cp[2]= 255; else cp[2]= temp; } static void blend_color_sub(char *cp, char *cp1, char *cp2, int fac) @@ -73,11 +73,11 @@ static void blend_color_sub(char *cp, char *cp1, char *cp2, int fac) int temp; temp= cp1[0] - ((fac*cp2[0])/255); - if(temp<0) cp[0]= 0; else cp[0]= temp; + if (temp<0) cp[0]= 0; else cp[0]= temp; temp= cp1[1] - ((fac*cp2[1])/255); - if(temp<0) cp[1]= 0; else cp[1]= temp; + if (temp<0) cp[1]= 0; else cp[1]= temp; temp= cp1[2] - ((fac*cp2[2])/255); - if(temp<0) cp[2]= 0; else cp[2]= temp; + if (temp<0) cp[2]= 0; else cp[2]= temp; } static void blend_color_mul(char *cp, char *cp1, char *cp2, int fac) @@ -348,7 +348,8 @@ void IMB_rectblend(struct ImBuf *dbuf, struct ImBuf *sbuf, int destx, if (do_char) srect = sbuf->rect + srcy * sbuf->x + srcx; if (do_float) srectf = sbuf->rect_float + (srcy * sbuf->x + srcx)*4; srcskip = sbuf->x; - } else { + } + else { srect = drect; srectf = drectf; srcskip = destskip; @@ -452,7 +453,7 @@ void IMB_rectfill(struct ImBuf *drect, const float col[4]) { int num; - if(drect->rect) { + if (drect->rect) { unsigned int *rrect = drect->rect; char ccol[4]; @@ -466,7 +467,7 @@ void IMB_rectfill(struct ImBuf *drect, const float col[4]) *rrect++ = *((unsigned int*)ccol); } - if(drect->rect_float) { + if (drect->rect_float) { float *rrectf = drect->rect_float; num = drect->x * drect->y; @@ -514,7 +515,8 @@ void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height, chr = FTOCHAR(col[0]); chg = FTOCHAR(col[1]); chb = FTOCHAR(col[2]); - } else { + } + else { fr = col[0]*a; fg = col[1]*a; fb = col[2]*a; @@ -528,7 +530,8 @@ void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height, pixel[1] = chg; pixel[2] = chb; pixel[3] = 255; - } else { + } + else { int alphatest; pixel[0] = (char)((fr + ((float)pixel[0]*aich))*255.0f); pixel[1] = (char)((fg + ((float)pixel[1]*aich))*255.0f); @@ -550,7 +553,8 @@ void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height, pixel[1] = col[1]; pixel[2] = col[2]; pixel[3] = 1.0f; - } else { + } + else { float alphatest; pixel[0] = (col[0]*a) + (pixel[0]*ai); pixel[1] = (col[1]*a) + (pixel[1]*ai); diff --git a/source/blender/imbuf/intern/rotate.c b/source/blender/imbuf/intern/rotate.c index 7ca7445569f..8914d4ee64d 100644 --- a/source/blender/imbuf/intern/rotate.c +++ b/source/blender/imbuf/intern/rotate.c @@ -62,7 +62,7 @@ void IMB_flipy(struct ImBuf * ibuf) y >>= 1; - for(;y>0;y--) { + for (;y>0;y--) { memcpy(line, top, x*sizeof(int)); memcpy(top, bottom, x*sizeof(int)); memcpy(bottom, line, x*sizeof(int)); @@ -85,7 +85,7 @@ void IMB_flipy(struct ImBuf * ibuf) y >>= 1; - for(;y>0;y--) { + for (;y>0;y--) { memcpy(linef, topf, 4*x*sizeof(float)); memcpy(topf, bottomf, 4*x*sizeof(float)); memcpy(bottomf, linef, 4*x*sizeof(float)); @@ -108,16 +108,16 @@ void IMB_flipx(struct ImBuf * ibuf) y = ibuf->y; if (ibuf->rect) { - for(yi=y-1;yi>=0;yi--) { - for(xr=x-1, xl=0; xr>=xl; xr--, xl++) { + for (yi=y-1;yi>=0;yi--) { + for (xr=x-1, xl=0; xr>=xl; xr--, xl++) { SWAP(unsigned int, ibuf->rect[(x*yi)+xr], ibuf->rect[(x*yi)+xl]); } } } if (ibuf->rect_float) { - for(yi=y-1;yi>=0;yi--) { - for(xr=x-1, xl=0; xr>=xl; xr--, xl++) { + for (yi=y-1;yi>=0;yi--) { + for (xr=x-1, xl=0; xr>=xl; xr--, xl++) { memcpy(&px_f, &ibuf->rect_float[((x*yi)+xr)*4], 4*sizeof(float)); memcpy(&ibuf->rect_float[((x*yi)+xr)*4], &ibuf->rect_float[((x*yi)+xl)*4], 4*sizeof(float)); memcpy(&ibuf->rect_float[((x*yi)+xl)*4], &px_f, 4*sizeof(float)); diff --git a/source/blender/imbuf/intern/scaling.c b/source/blender/imbuf/intern/scaling.c index 361faa08b29..a7b994beef9 100644 --- a/source/blender/imbuf/intern/scaling.c +++ b/source/blender/imbuf/intern/scaling.c @@ -76,10 +76,10 @@ struct ImBuf *IMB_half_x(struct ImBuf *ibuf1) _p1f = ibuf1->rect_float; destf= ibuf2->rect_float; - for(y=ibuf2->y;y>0;y--) { + for (y=ibuf2->y;y>0;y--) { p1 = _p1; p1f = _p1f; - for(x = ibuf2->x; x>0; x--) { + for (x = ibuf2->x; x>0; x--) { if (do_rect) { a = *(p1++); b = *(p1++); @@ -136,7 +136,7 @@ struct ImBuf *IMB_double_fast_x(struct ImBuf *ibuf1) p1f = (float *)ibuf1->rect_float; destf = (float *)ibuf2->rect_float; - for(i = ibuf1->y * ibuf1->x; i > 0; i--) { + for (i = ibuf1->y * ibuf1->x; i > 0; i--) { if (do_rect) { col = *p1++; *dest++ = col; @@ -195,7 +195,7 @@ struct ImBuf *IMB_half_y(struct ImBuf *ibuf1) _p1f = (float *) ibuf1->rect_float; destf= (float *) ibuf2->rect_float; - for(y=ibuf2->y; y>0; y--) { + for (y=ibuf2->y; y>0; y--) { if (do_rect) { p1 = _p1; p2 = _p1 + (ibuf1->x << 2); @@ -204,7 +204,7 @@ struct ImBuf *IMB_half_y(struct ImBuf *ibuf1) p1f = _p1f; p2f = _p1f + (ibuf1->x << 2); } - for(x = ibuf2->x; x > 0; x--) { + for (x = ibuf2->x; x > 0; x--) { if (do_rect) { a = *(p1++); b = *(p1++); @@ -263,15 +263,15 @@ struct ImBuf *IMB_double_fast_y(struct ImBuf *ibuf1) p1f = (float *) ibuf1->rect_float; dest1f= (float *) ibuf2->rect_float; - for(y = ibuf1->y; y > 0; y--) { + for (y = ibuf1->y; y > 0; y--) { if (do_rect) { dest2 = dest1 + ibuf2->x; - for(x = ibuf2->x; x > 0; x--) *dest1++ = *dest2++ = *p1++; + for (x = ibuf2->x; x > 0; x--) *dest1++ = *dest2++ = *p1++; dest1 = dest2; } if (do_float) { dest2f = dest1f + (4*ibuf2->x); - for(x = ibuf2->x * 4; x > 0; x--) *dest1f++ = *dest2f++ = *p1f++; + for (x = ibuf2->x * 4; x > 0; x--) *dest1f++ = *dest2f++ = *p1f++; dest1f = dest2f; } } @@ -301,7 +301,7 @@ void imb_onehalf_no_alloc(struct ImBuf *ibuf2, struct ImBuf *ibuf1) const short do_rect= (ibuf1->rect != NULL); const short do_float= (ibuf1->rect_float != NULL) && (ibuf2->rect_float != NULL); - if(do_rect && (ibuf2->rect == NULL)) { + if (do_rect && (ibuf2->rect == NULL)) { imb_addrectImBuf(ibuf2); } @@ -310,10 +310,10 @@ void imb_onehalf_no_alloc(struct ImBuf *ibuf2, struct ImBuf *ibuf1) p1 = (uchar *) ibuf1->rect; dest=(uchar *) ibuf2->rect; - for(y=ibuf2->y;y>0;y--) { + for (y=ibuf2->y;y>0;y--) { if (do_rect) p2 = p1 + (ibuf1->x << 2); if (do_float) p2f = p1f + (ibuf1->x << 2); - for(x=ibuf2->x;x>0;x--) { + for (x=ibuf2->x;x>0;x--) { if (do_rect) { dest[0] = (p1[0] + p2[0] + p1[4] + p2[4]) >> 2; dest[1] = (p1[1] + p2[1] + p1[5] + p2[5]) >> 2; @@ -335,7 +335,7 @@ void imb_onehalf_no_alloc(struct ImBuf *ibuf2, struct ImBuf *ibuf1) } if (do_rect) p1=p2; if (do_float) p1f=p2f; - if(ibuf1->x & 1) { + if (ibuf1->x & 1) { if (do_rect) p1+=4; if (do_float) p1f+=4; } @@ -567,7 +567,8 @@ static void q_scale_byte(unsigned char* in, unsigned char* out, int in_width, if (dst_width > in_width && dst_height > in_height) { enlarge_picture_byte(in, out, in_width, in_height, dst_width, dst_height); - } else if (dst_width < in_width && dst_height < in_height) { + } + else if (dst_width < in_width && dst_height < in_height) { shrink_picture_byte(in, out, in_width, in_height, dst_width, dst_height); } @@ -767,7 +768,8 @@ static void q_scale_float(float* in, float* out, int in_width, if (dst_width > in_width && dst_height > in_height) { enlarge_picture_float(in, out, in_width, in_height, dst_width, dst_height); - } else if (dst_width < in_width && dst_height < in_height) { + } + else if (dst_width < in_width && dst_height < in_height) { shrink_picture_float(in, out, in_width, in_height, dst_width, dst_height); } @@ -1511,7 +1513,7 @@ struct ImBuf *IMB_scalefastImBuf(struct ImBuf *ibuf, unsigned int newx, unsigned if (newx == ibuf->x && newy == ibuf->y) return(ibuf); - if(do_rect) { + if (do_rect) { _newrect = MEM_mallocN(newx * newy * sizeof(int), "scalefastimbuf"); if (_newrect==NULL) return(ibuf); newrect = _newrect; @@ -1531,7 +1533,7 @@ struct ImBuf *IMB_scalefastImBuf(struct ImBuf *ibuf, unsigned int newx, unsigned ofsy = 32768; for (y = newy; y > 0; y--) { - if(do_rect) { + if (do_rect) { rect = ibuf->rect; rect += (ofsy >> 16) * ibuf->x; } diff --git a/source/blender/imbuf/intern/targa.c b/source/blender/imbuf/intern/targa.c index 1801c1a8ef9..c8c4a4fd38c 100644 --- a/source/blender/imbuf/intern/targa.c +++ b/source/blender/imbuf/intern/targa.c @@ -126,13 +126,13 @@ static short makebody_tga(ImBuf * ibuf, FILE * file, int (*out)(unsigned int, FI last = *rect++; this = *rect++; copy = last^this; - while (bytes > 0){ - if (copy){ + while (bytes > 0) { + if (copy) { do { last = this; this = *rect++; - if (last == this){ - if (this == rect[-3]){ /* three the same? */ + if (last == this) { + if (this == rect[-3]) { /* three the same? */ bytes --; /* set bytes */ break; } @@ -146,7 +146,7 @@ static short makebody_tga(ImBuf * ibuf, FILE * file, int (*out)(unsigned int, FI temp = rect; rect = rectstart; - while (copy){ + while (copy) { last = copy; if (copy>=128) last = 128; copy -= last; @@ -160,8 +160,9 @@ static short makebody_tga(ImBuf * ibuf, FILE * file, int (*out)(unsigned int, FI last = this; copy = FALSE; - } else { - while (*rect++ == this){ /* seek for first different byte */ + } + else { + while (*rect++ == this) { /* seek for first different byte */ if (--bytes == 0) break; /* oor end of line */ } rect --; @@ -170,14 +171,16 @@ static short makebody_tga(ImBuf * ibuf, FILE * file, int (*out)(unsigned int, FI bytes --; this = *rect++; - while (copy){ - if (copy>128){ + while (copy) { + if (copy>128) { if (fputc(255,file) == EOF) return(0); copy -= 128; - } else { - if (copy == 1){ + } + else { + if (copy == 1) { if (fputc(0,file) == EOF) return(0); - } else if (fputc(127 + copy,file) == EOF) return(0); + } + else if (fputc(127 + copy,file) == EOF) return(0); copy = 0; } if (out(last,file) == EOF) return(0); @@ -201,28 +204,31 @@ static int dumptarga(struct ImBuf * ibuf, FILE * file) rect = (uchar *) ibuf->rect; if (ibuf->planes <= 8) { - while(size > 0){ + while(size > 0) { if (putc(*rect, file) == EOF) return (0); size--; rect += 4; } - } else if (ibuf->planes <= 16) { - while(size > 0){ + } + else if (ibuf->planes <= 16) { + while(size > 0) { putc(rect[0], file); if (putc(rect[1], file) == EOF) return (0); size--; rect += 4; } - } else if (ibuf->planes <= 24) { - while(size > 0){ + } + else if (ibuf->planes <= 24) { + while(size > 0) { putc(rect[2], file); putc(rect[1], file); if (putc(rect[0], file) == EOF) return (0); size--; rect += 4; } - } else if (ibuf->planes <= 32) { - while(size > 0){ + } + else if (ibuf->planes <= 32) { + while(size > 0) { putc(rect[2], file); putc(rect[1], file); putc(rect[0], file); @@ -230,7 +236,8 @@ static int dumptarga(struct ImBuf * ibuf, FILE * file) size--; rect += 4; } - } else return (0); + } + else return (0); return (1); } @@ -245,9 +252,10 @@ int imb_savetarga(struct ImBuf * ibuf, const char *name, int flags) (void)flags; /* unused */ buf[16] = (ibuf->planes + 0x7 ) & ~0x7; - if (ibuf->planes > 8 ){ + if (ibuf->planes > 8 ) { buf[2] = 10; - } else{ + } + else { buf[2] = 11; } @@ -278,8 +286,9 @@ int imb_savetarga(struct ImBuf * ibuf, const char *name, int flags) if (ibuf->ftype == RAWTGA) { ok = dumptarga(ibuf, fildes); - } else { - switch((ibuf->planes + 7) >> 3){ + } + else { + switch((ibuf->planes + 7) >> 3) { case 1: ok = makebody_tga(ibuf, fildes, tga_out1); break; @@ -317,7 +326,7 @@ static int checktarga(TARGA *tga, unsigned char *mem) tga->imgdes = mem[17]; if (tga->maptyp > 1) return(0); - switch (tga->imgtyp){ + switch (tga->imgtyp) { case 1: /* raw cmap */ case 2: /* raw rgb */ case 3: /* raw b&w */ @@ -346,7 +355,7 @@ int imb_is_a_targa(unsigned char *buf) static void complete_partial_load(struct ImBuf *ibuf, unsigned int *rect) { int size = (ibuf->x * ibuf->y) - (rect - ibuf->rect); - if(size) { + if (size) { printf("decodetarga: incomplete file, %.1f%% missing\n", 100*((float)size / (ibuf->x * ibuf->y))); /* not essential but makes displaying partially rendered TGA's less ugly */ @@ -375,18 +384,18 @@ static void decodetarga(struct ImBuf *ibuf, unsigned char *mem, size_t mem_size, cp[0] = 0xff; cp[1] = cp[2] = 0; - while(size > 0){ + while(size > 0) { count = *mem++; - if(mem>mem_end) + if (mem>mem_end) goto partial_load; if (count >= 128) { /*if (count == 128) printf("TARGA: 128 in file !\n");*/ count -= 127; - if (psize & 2){ - if (psize & 1){ + if (psize & 2) { + if (psize & 1) { /* order = bgra */ cp[0] = mem[3]; cp[1] = mem[0]; @@ -394,19 +403,22 @@ static void decodetarga(struct ImBuf *ibuf, unsigned char *mem, size_t mem_size, cp[3] = mem[2]; /*col = (mem[3] << 24) + (mem[0] << 16) + (mem[1] << 8) + mem[2];*/ mem += 4; - } else{ + } + else { cp[1] = mem[0]; cp[2] = mem[1]; cp[3] = mem[2]; /*col = 0xff000000 + (mem[0] << 16) + (mem[1] << 8) + mem[2];*/ mem += 3; } - } else{ - if (psize & 1){ + } + else { + if (psize & 1) { cp[0] = mem[0]; cp[1] = mem[1]; mem += 2; - } else{ + } + else { col = *mem++; } } @@ -418,13 +430,14 @@ static void decodetarga(struct ImBuf *ibuf, unsigned char *mem, size_t mem_size, count--; } } - } else{ + } + else { count ++; size -= count; if (size >= 0) { - while (count > 0){ - if (psize & 2){ - if (psize & 1){ + while (count > 0) { + if (psize & 2) { + if (psize & 1) { /* order = bgra */ cp[0] = mem[3]; cp[1] = mem[0]; @@ -432,30 +445,33 @@ static void decodetarga(struct ImBuf *ibuf, unsigned char *mem, size_t mem_size, cp[3] = mem[2]; /*col = (mem[3] << 24) + (mem[0] << 16) + (mem[1] << 8) + mem[2];*/ mem += 4; - } else{ + } + else { cp[1] = mem[0]; cp[2] = mem[1]; cp[3] = mem[2]; /*col = 0xff000000 + (mem[0] << 16) + (mem[1] << 8) + mem[2];*/ mem += 3; } - } else{ - if (psize & 1){ + } + else { + if (psize & 1) { cp[0] = mem[0]; cp[1] = mem[1]; mem += 2; - } else{ + } + else { col = *mem++; } } *rect++ = col; count --; - if(mem>mem_end) + if (mem>mem_end) goto partial_load; } - if(mem>mem_end) + if (mem>mem_end) goto partial_load; } } @@ -486,12 +502,12 @@ static void ldtarga(struct ImBuf * ibuf,unsigned char * mem, size_t mem_size, in cp[0] = 0xff; cp[1] = cp[2] = 0; - while(size > 0){ - if(mem>mem_end) + while(size > 0) { + if (mem>mem_end) goto partial_load; - if (psize & 2){ - if (psize & 1){ + if (psize & 2) { + if (psize & 1) { /* order = bgra */ cp[0] = mem[3]; cp[1] = mem[0]; @@ -499,7 +515,8 @@ static void ldtarga(struct ImBuf * ibuf,unsigned char * mem, size_t mem_size, in cp[3] = mem[2]; /*col = (mem[3] << 24) + (mem[0] << 16) + (mem[1] << 8) + mem[2];*/ mem += 4; - } else{ + } + else { /* set alpha for 24 bits colors */ cp[1] = mem[0]; cp[2] = mem[1]; @@ -507,12 +524,14 @@ static void ldtarga(struct ImBuf * ibuf,unsigned char * mem, size_t mem_size, in /*col = 0xff000000 + (mem[0] << 16) + (mem[1] << 8) + mem[2];*/ mem += 3; } - } else{ - if (psize & 1){ + } + else { + if (psize & 1) { cp[0] = mem[0]; cp[1] = mem[1]; mem += 2; - } else{ + } + else { col = *mem++; } } @@ -547,7 +566,7 @@ struct ImBuf *imb_loadtarga(unsigned char *mem, size_t mem_size, int flags) cp[0] = 0xff; cp[1] = cp[2] = 0; - if (tga.mapsize){ + if (tga.mapsize) { /* load color map */ /*mincol = tga.maporig;*/ /*UNUSED*/ maxcol = tga.mapsize; @@ -592,13 +611,13 @@ struct ImBuf *imb_loadtarga(unsigned char *mem, size_t mem_size, int flags) if (flags & IB_test) return (ibuf); if (tga.imgtyp != 1 && tga.imgtyp != 9) { /* happens sometimes (beuh) */ - if(cmap) { + if (cmap) { MEM_freeN(cmap); cmap= NULL; } } - switch(tga.imgtyp){ + switch(tga.imgtyp) { case 1: case 2: case 3: @@ -617,10 +636,10 @@ struct ImBuf *imb_loadtarga(unsigned char *mem, size_t mem_size, int flags) break; } - if(cmap) { + if (cmap) { /* apply color map */ rect = ibuf->rect; - for(size = ibuf->x * ibuf->y; size>0; --size, ++rect) { + for (size = ibuf->x * ibuf->y; size>0; --size, ++rect) { col = *rect; if (col >= 0 && col < maxcol) *rect = cmap[col]; } @@ -630,7 +649,7 @@ struct ImBuf *imb_loadtarga(unsigned char *mem, size_t mem_size, int flags) if (tga.pixsize == 16) { rect = ibuf->rect; - for (size = ibuf->x * ibuf->y; size > 0; --size, ++rect){ + for (size = ibuf->x * ibuf->y; size > 0; --size, ++rect) { col = *rect; cp = (uchar*)rect; mem = (uchar*)&col; @@ -646,14 +665,14 @@ struct ImBuf *imb_loadtarga(unsigned char *mem, size_t mem_size, int flags) ibuf->planes = 24; } - if (tga.imgtyp == 3 || tga.imgtyp == 11){ + if (tga.imgtyp == 3 || tga.imgtyp == 11) { uchar *crect; unsigned int *lrect, col; crect = (uchar *) ibuf->rect; lrect = (unsigned int *) ibuf->rect; - for (size = ibuf->x * ibuf->y; size > 0; size --){ + for (size = ibuf->x * ibuf->y; size > 0; size --) { col = *lrect++; crect[0] = 255; diff --git a/source/blender/imbuf/intern/thumbs.c b/source/blender/imbuf/intern/thumbs.c index be716870dad..f5c22b67c1b 100644 --- a/source/blender/imbuf/intern/thumbs.c +++ b/source/blender/imbuf/intern/thumbs.c @@ -149,7 +149,8 @@ static void escape_uri_string (const char *string, char* escaped_string, int len *q++ = '%'; /* means hex coming */ *q++ = hex[c >> 4]; *q++ = hex[c & 15]; - } else { + } + else { *q++ = *p; } } @@ -280,9 +281,9 @@ ImBuf* IMB_thumb_create(const char* path, ThumbSize size, ThumbSource source, Im } /* exception, skip images over 100mb */ - if(source == THB_SOURCE_IMAGE) { + if (source == THB_SOURCE_IMAGE) { const size_t size= BLI_file_size(path); - if(size != -1 && size > THUMB_SIZE_MAX) { + if (size != -1 && size > THUMB_SIZE_MAX) { // printf("file too big: %d, skipping %s\n", (int)size, path); return NULL; } @@ -300,12 +301,13 @@ ImBuf* IMB_thumb_create(const char* path, ThumbSize size, ThumbSource source, Im if (size == THB_FAIL) { img = IMB_allocImBuf(1,1,32, IB_rect | IB_metadata); if (!img) return NULL; - } else { + } + else { if (THB_SOURCE_IMAGE == source || THB_SOURCE_BLEND == source) { /* only load if we didnt give an image */ - if(img==NULL) { - if(THB_SOURCE_BLEND == source) { + if (img==NULL) { + if (THB_SOURCE_BLEND == source) { img = IMB_loadblend_thumb(path); } else { @@ -319,14 +321,16 @@ ImBuf* IMB_thumb_create(const char* path, ThumbSize size, ThumbSource source, Im BLI_snprintf(cwidth, sizeof(cwidth), "%d", img->x); BLI_snprintf(cheight, sizeof(cheight), "%d", img->y); } - } else if (THB_SOURCE_MOVIE == source) { + } + else if (THB_SOURCE_MOVIE == source) { struct anim * anim = NULL; anim = IMB_open_anim(path, IB_rect | IB_metadata, 0); if (anim != NULL) { img = IMB_anim_absolute(anim, 0, IMB_TC_NONE, IMB_PROXY_NONE); if (img == NULL) { printf("not an anim; %s\n", path); - } else { + } + else { IMB_freeImBuf(img); img = IMB_anim_previewframe(anim); } @@ -349,8 +353,8 @@ ImBuf* IMB_thumb_create(const char* path, ThumbSize size, ThumbSource source, Im ey = (short)scaledy; /* save some time by only scaling byte buf */ - if(img->rect_float) { - if(img->rect == NULL) { + if (img->rect_float) { + if (img->rect == NULL) { IMB_rect_from_float(img); } @@ -443,7 +447,8 @@ ImBuf* IMB_thumb_manage(const char* path, ThumbSize size, ThumbSource source) if (thumbpath_from_uri(uri, thumb, sizeof(thumb), size)) { if (BLI_path_ncmp(path, thumb, sizeof(thumb)) == 0) { img = IMB_loadiffname(path, IB_rect); - } else { + } + else { img = IMB_loadiffname(thumb, IB_rect | IB_metadata); if (img) { char mtime[40]; @@ -451,7 +456,8 @@ ImBuf* IMB_thumb_manage(const char* path, ThumbSize size, ThumbSource source) /* illegal thumb, forget it! */ IMB_freeImBuf(img); img = NULL; - } else { + } + else { time_t t = atol(mtime); if (st.st_mtime != t) { /* recreate all thumbs */ @@ -461,7 +467,7 @@ ImBuf* IMB_thumb_manage(const char* path, ThumbSize size, ThumbSource source) IMB_thumb_delete(path, THB_LARGE); IMB_thumb_delete(path, THB_FAIL); img = IMB_thumb_create(path, size, source, NULL); - if(!img){ + if (!img) { /* thumb creation failed, write fail thumb */ img = IMB_thumb_create(path, THB_FAIL, source, NULL); if (img) { @@ -472,9 +478,10 @@ ImBuf* IMB_thumb_manage(const char* path, ThumbSize size, ThumbSource source) } } } - } else { + } + else { img = IMB_thumb_create(path, size, source, NULL); - if(!img){ + if (!img) { /* thumb creation failed, write fail thumb */ img = IMB_thumb_create(path, THB_FAIL, source, NULL); if (img) { diff --git a/source/blender/imbuf/intern/thumbs_blend.c b/source/blender/imbuf/intern/thumbs_blend.c index fd0be89df0d..91df1e78f44 100644 --- a/source/blender/imbuf/intern/thumbs_blend.c +++ b/source/blender/imbuf/intern/thumbs_blend.c @@ -53,23 +53,23 @@ static ImBuf *loadblend_thumb(gzFile gzfile) int sizeof_bhead; /* read the blend file header */ - if(gzread(gzfile, buf, 12) != 12) + if (gzread(gzfile, buf, 12) != 12) return NULL; - if(strncmp(buf, "BLENDER", 7)) + if (strncmp(buf, "BLENDER", 7)) return NULL; - if(buf[7]=='-') + if (buf[7]=='-') pointer_size= 8; - else if(buf[7]=='_') + else if (buf[7]=='_') pointer_size= 4; else return NULL; sizeof_bhead = 16 + pointer_size; - if(buf[8]=='V') + if (buf[8]=='V') endian= B_ENDIAN; /* big: PPC */ - else if(buf[8]=='v') + else if (buf[8]=='v') endian= L_ENDIAN; /* little: x86 */ else return NULL; @@ -77,7 +77,7 @@ static ImBuf *loadblend_thumb(gzFile gzfile) endian_switch = ((ENDIAN_ORDER != endian)) ? 1 : 0; while(gzread(gzfile, bhead, sizeof_bhead) == sizeof_bhead) { - if(endian_switch) + if (endian_switch) SWITCH_INT(bhead[1]); /* length */ if (bhead[0]==REND) { @@ -89,14 +89,14 @@ static ImBuf *loadblend_thumb(gzFile gzfile) } /* using 'TEST' since new names segfault when loading in old blenders */ - if(bhead[0] == TEST) { + if (bhead[0] == TEST) { ImBuf *img= NULL; int size[2]; - if(gzread(gzfile, size, sizeof(size)) != sizeof(size)) + if (gzread(gzfile, size, sizeof(size)) != sizeof(size)) return NULL; - if(endian_switch) { + if (endian_switch) { SWITCH_INT(size[0]); SWITCH_INT(size[1]); } @@ -104,13 +104,13 @@ static ImBuf *loadblend_thumb(gzFile gzfile) bhead[1] -= sizeof(int) * 2; /* inconsistent image size, quit early */ - if(bhead[1] != size[0] * size[1] * sizeof(int)) + if (bhead[1] != size[0] * size[1] * sizeof(int)) return NULL; /* finally malloc and read the data */ img= IMB_allocImBuf(size[0], size[1], 32, IB_rect | IB_metadata); - if(gzread(gzfile, img->rect, bhead[1]) != bhead[1]) { + if (gzread(gzfile, img->rect, bhead[1]) != bhead[1]) { IMB_freeImBuf(img); img= NULL; } @@ -151,7 +151,7 @@ void IMB_overlayblend_thumb(unsigned int *thumb, int width, int height, float as int margin_r = width - MARGIN; int margin_t = height - MARGIN; - if(aspect < 1.0f) { + if (aspect < 1.0f) { margin_l= (int)((width - ((float)width * aspect)) / 2.0f); margin_l += MARGIN; CLAMP(margin_l, MARGIN, (width/2)); @@ -168,18 +168,19 @@ void IMB_overlayblend_thumb(unsigned int *thumb, int width, int height, float as int x, y; int stride_x= (margin_r - margin_l) - 2; - for(y=0; y < height; y++) { - for(x=0; x < width; x++, px+=4) { + for (y=0; y < height; y++) { + for (x=0; x < width; x++, px+=4) { int hline= 0, vline= 0; - if((x > margin_l && x < margin_r) && (y > margin_b && y < margin_t)) { + if ((x > margin_l && x < margin_r) && (y > margin_b && y < margin_t)) { /* interior. skip */ x += stride_x; px += stride_x * 4; - } else if( (hline=(((x == margin_l || x == margin_r)) && y >= margin_b && y <= margin_t)) || - (vline=(((y == margin_b || y == margin_t)) && x >= margin_l && x <= margin_r)) - ) { + } + else if ((hline=(((x == margin_l || x == margin_r)) && y >= margin_b && y <= margin_t)) || + (vline=(((y == margin_b || y == margin_t)) && x >= margin_l && x <= margin_r))) + { /* dashed line */ - if((hline && y % 2) || (vline && x % 2)) { + if ((hline && y % 2) || (vline && x % 2)) { px[0]= px[1]= px[2]= 0; px[3] = 255; } diff --git a/source/blender/imbuf/intern/tiff.c b/source/blender/imbuf/intern/tiff.c index 1e6bc216128..5a8caa8769f 100644 --- a/source/blender/imbuf/intern/tiff.c +++ b/source/blender/imbuf/intern/tiff.c @@ -128,23 +128,23 @@ static tsize_t imb_tiff_ReadProc(thandle_t handle, tdata_t data, tsize_t n) /* get the pointer to the in-memory file */ mfile = IMB_TIFF_GET_MEMFILE(handle); - if(!mfile || !mfile->mem) { + if (!mfile || !mfile->mem) { fprintf(stderr, "imb_tiff_ReadProc: !mfile || !mfile->mem!\n"); return 0; } /* find the actual number of bytes to read (copy) */ nCopy = n; - if((tsize_t)mfile->offset >= mfile->size) + if ((tsize_t)mfile->offset >= mfile->size) nRemaining = 0; else nRemaining = mfile->size - mfile->offset; - if(nCopy > nRemaining) + if (nCopy > nRemaining) nCopy = nRemaining; /* on EOF, return immediately and read (copy) nothing */ - if(nCopy <= 0) + if (nCopy <= 0) return (0); /* all set -> do the read (copy) */ @@ -195,7 +195,7 @@ static toff_t imb_tiff_SeekProc(thandle_t handle, toff_t ofs, int whence) /* get the pointer to the in-memory file */ mfile = IMB_TIFF_GET_MEMFILE(handle); - if(!mfile || !mfile->mem) { + if (!mfile || !mfile->mem) { fprintf(stderr, "imb_tiff_SeekProc: !mfile || !mfile->mem!\n"); return (-1); } @@ -241,7 +241,7 @@ static int imb_tiff_CloseProc(thandle_t handle) /* get the pointer to the in-memory file */ mfile = IMB_TIFF_GET_MEMFILE(handle); - if(!mfile || !mfile->mem) { + if (!mfile || !mfile->mem) { fprintf(stderr,"imb_tiff_CloseProc: !mfile || !mfile->mem!\n"); return (0); } @@ -267,7 +267,7 @@ static toff_t imb_tiff_SizeProc(thandle_t handle) /* get the pointer to the in-memory file */ mfile = IMB_TIFF_GET_MEMFILE(handle); - if(!mfile || !mfile->mem) { + if (!mfile || !mfile->mem) { fprintf(stderr,"imb_tiff_SizeProc: !mfile || !mfile->mem!\n"); return (0); } @@ -361,7 +361,7 @@ static void imb_read_tiff_resolution(ImBuf *ibuf, TIFF *image) TIFFGetFieldDefaulted(image, TIFFTAG_XRESOLUTION, &xres); TIFFGetFieldDefaulted(image, TIFFTAG_YRESOLUTION, &yres); - if(unit == RESUNIT_CENTIMETER) { + if (unit == RESUNIT_CENTIMETER) { ibuf->ppm[0]= (double)xres * 100.0; ibuf->ppm[1]= (double)yres * 100.0; } @@ -397,10 +397,12 @@ static int imb_read_tiff_pixels(ImBuf *ibuf, TIFF *image, int premul) if (bitspersample == 32) { ib_flag = IB_rectfloat; fbuf = (float *)_TIFFmalloc(scanline); - } else if (bitspersample == 16) { + } + else if (bitspersample == 16) { ib_flag = IB_rectfloat; sbuf = (unsigned short *)_TIFFmalloc(scanline); - } else { + } + else { ib_flag = IB_rect; } @@ -419,13 +421,15 @@ static int imb_read_tiff_pixels(ImBuf *ibuf, TIFF *image, int premul) success |= TIFFReadScanline(image, fbuf, row, 0); scanline_contig_32bit(tmpibuf->rect_float+ib_offset, fbuf, ibuf->x, spp); - } else if (bitspersample == 16) { + } + else if (bitspersample == 16) { success |= TIFFReadScanline(image, sbuf, row, 0); scanline_contig_16bit(tmpibuf->rect_float+ib_offset, sbuf, ibuf->x, spp); } } /* separate channels: RRRGGGBBB */ - } else if (config == PLANARCONFIG_SEPARATE) { + } + else if (config == PLANARCONFIG_SEPARATE) { /* imbufs always have 4 channels of data, so we iterate over all of them * but only fill in from the TIFF scanline where necessary. */ @@ -440,7 +444,8 @@ static int imb_read_tiff_pixels(ImBuf *ibuf, TIFF *image, int premul) success |= TIFFReadScanline(image, fbuf, row, chan); scanline_separate_32bit(tmpibuf->rect_float+ib_offset, fbuf, ibuf->x, chan); - } else if (bitspersample == 16) { + } + else if (bitspersample == 16) { if (chan == 3 && spp == 3) /* fill alpha if only RGB TIFF */ memset(sbuf, 65535, sizeof(sbuf)); else @@ -457,14 +462,14 @@ static int imb_read_tiff_pixels(ImBuf *ibuf, TIFF *image, int premul) else if (bitspersample == 16) _TIFFfree(sbuf); - if(success) { + if (success) { ibuf->profile = (bitspersample==32)?IB_PROFILE_LINEAR_RGB:IB_PROFILE_SRGB; // Code seems to be not needed for 16 bits tif, on PPC G5 OSX (ton) - if(bitspersample < 16) - if(ENDIAN_ORDER == B_ENDIAN) + if (bitspersample < 16) + if (ENDIAN_ORDER == B_ENDIAN) IMB_convert_rgba_to_abgr(tmpibuf); - if(premul) { + if (premul) { IMB_premultiply_alpha(tmpibuf); ibuf->flags |= IB_premul; } @@ -514,16 +519,16 @@ ImBuf *imb_loadtiff(unsigned char *mem, size_t size, int flags) int ib_depth; /* check whether or not we have a TIFF file */ - if(size < IMB_TIFF_NCB) { + if (size < IMB_TIFF_NCB) { fprintf(stderr, "imb_loadtiff: size < IMB_TIFF_NCB\n"); return NULL; } - if(imb_is_a_tiff(mem) == 0) + if (imb_is_a_tiff(mem) == 0) return NULL; image = imb_tiff_client_open(&memFile, mem, size); - if(image == NULL) { + if (image == NULL) { printf("imb_loadtiff: could not open TIFF IO layer.\n"); return NULL; } @@ -536,7 +541,7 @@ ImBuf *imb_loadtiff(unsigned char *mem, size_t size, int flags) ib_depth = (spp==3)?24:32; ibuf = IMB_allocImBuf(width, height, ib_depth, 0); - if(ibuf) { + if (ibuf) { ibuf->ftype = TIF; } else { @@ -548,26 +553,26 @@ ImBuf *imb_loadtiff(unsigned char *mem, size_t size, int flags) } /* if testing, we're done */ - if(flags & IB_test) { + if (flags & IB_test) { TIFFClose(image); return ibuf; } /* detect if we are reading a tiled/mipmapped texture, in that case * we don't read pixels but leave it to the cache to load tiles */ - if(flags & IB_tilecache) { + if (flags & IB_tilecache) { format= NULL; TIFFGetField(image, TIFFTAG_PIXAR_TEXTUREFORMAT, &format); - if(format && strcmp(format, "Plain Texture")==0 && TIFFIsTiled(image)) { + if (format && strcmp(format, "Plain Texture")==0 && TIFFIsTiled(image)) { int numlevel = TIFFNumberOfDirectories(image); /* create empty mipmap levels in advance */ - for(level=0; level<numlevel; level++) { - if(!TIFFSetDirectory(image, level)) + for (level=0; level<numlevel; level++) { + if (!TIFFSetDirectory(image, level)) break; - if(level > 0) { + if (level > 0) { width= (width > 1)? width/2: 1; height= (height > 1)? height/2: 1; @@ -576,7 +581,7 @@ ImBuf *imb_loadtiff(unsigned char *mem, size_t size, int flags) hbuf->ftype= ibuf->ftype; ibuf->mipmap[level-1] = hbuf; - if(flags & IB_premul) + if (flags & IB_premul) hbuf->flags |= IB_premul; } else @@ -598,7 +603,7 @@ ImBuf *imb_loadtiff(unsigned char *mem, size_t size, int flags) } /* read pixels */ - if(!(ibuf->flags & IB_tilecache) && !imb_read_tiff_pixels(ibuf, image, 0)) { + if (!(ibuf->flags & IB_tilecache) && !imb_read_tiff_pixels(ibuf, image, 0)) { fprintf(stderr, "imb_loadtiff: Failed to read tiff image.\n"); TIFFClose(image); return NULL; @@ -619,23 +624,23 @@ void imb_loadtiletiff(ImBuf *ibuf, unsigned char *mem, size_t size, int tx, int image = imb_tiff_client_open(&memFile, mem, size); - if(image == NULL) { + if (image == NULL) { printf("imb_loadtiff: could not open TIFF IO layer for loading mipmap level.\n"); return; } - if(TIFFSetDirectory(image, ibuf->miplevel)) { /* allocate the image buffer */ + if (TIFFSetDirectory(image, ibuf->miplevel)) { /* allocate the image buffer */ TIFFGetField(image, TIFFTAG_IMAGEWIDTH, &width); TIFFGetField(image, TIFFTAG_IMAGELENGTH, &height); - if(width == ibuf->x && height == ibuf->y) { - if(rect) { + if (width == ibuf->x && height == ibuf->y) { + if (rect) { /* tiff pixels are bottom to top, tiles are top to bottom */ - if(TIFFReadRGBATile(image, tx*ibuf->tilex, (ibuf->ytiles - 1 - ty)*ibuf->tiley, rect) == 1) { - if(ibuf->tiley > ibuf->y) + if (TIFFReadRGBATile(image, tx*ibuf->tilex, (ibuf->ytiles - 1 - ty)*ibuf->tiley, rect) == 1) { + if (ibuf->tiley > ibuf->y) memmove(rect, rect+ibuf->tilex*(ibuf->tiley - ibuf->y), sizeof(int)*ibuf->tilex*ibuf->y); - if(ibuf->flags & IB_premul) + if (ibuf->flags & IB_premul) IMB_premultiply_rect(rect, 32, ibuf->tilex, ibuf->tiley); } else @@ -686,20 +691,20 @@ int imb_savetiff(ImBuf *ibuf, const char *name, int flags) * the TIFF writer supports 1, 3 or 4 bytes per pixel, corresponding * to gray, RGB, RGBA respectively. */ samplesperpixel = (uint16)((ibuf->planes + 7) >> 3); - if((samplesperpixel > 4) || (samplesperpixel == 2)) { + if ((samplesperpixel > 4) || (samplesperpixel == 2)) { fprintf(stderr, "imb_savetiff: unsupported number of bytes per " "pixel: %d\n", samplesperpixel); return (0); } - if((ibuf->ftype & TIF_16BIT) && ibuf->rect_float) + if ((ibuf->ftype & TIF_16BIT) && ibuf->rect_float) bitspersample = 16; else bitspersample = 8; /* open TIFF file for writing */ - if(flags & IB_mem) { + if (flags & IB_mem) { /* bork at the creation of a TIFF in memory */ fprintf(stderr, "imb_savetiff: creation of in-memory TIFF files is " @@ -710,7 +715,7 @@ int imb_savetiff(ImBuf *ibuf, const char *name, int flags) /* create image as a file */ image = TIFFOpen(name, "w"); } - if(image == NULL) { + if (image == NULL) { fprintf(stderr, "imb_savetiff: could not open TIFF for writing.\n"); return (0); @@ -718,14 +723,14 @@ int imb_savetiff(ImBuf *ibuf, const char *name, int flags) /* allocate array for pixel data */ npixels = ibuf->x * ibuf->y; - if(bitspersample == 16) + if (bitspersample == 16) pixels16 = (unsigned short*)_TIFFmalloc(npixels * samplesperpixel * sizeof(unsigned short)); else pixels = (unsigned char*)_TIFFmalloc(npixels * samplesperpixel * sizeof(unsigned char)); - if(pixels == NULL && pixels16 == NULL) { + if (pixels == NULL && pixels16 == NULL) { fprintf(stderr, "imb_savetiff: could not allocate pixels array.\n"); TIFFClose(image); @@ -733,7 +738,7 @@ int imb_savetiff(ImBuf *ibuf, const char *name, int flags) } /* setup pointers */ - if(bitspersample == 16) { + if (bitspersample == 16) { fromf = ibuf->rect_float; to16 = pixels16; } @@ -746,31 +751,31 @@ int imb_savetiff(ImBuf *ibuf, const char *name, int flags) TIFFSetField(image, TIFFTAG_BITSPERSAMPLE, bitspersample); TIFFSetField(image, TIFFTAG_SAMPLESPERPIXEL, samplesperpixel); - if(samplesperpixel == 4) { + if (samplesperpixel == 4) { /* RGBA images */ TIFFSetField(image, TIFFTAG_EXTRASAMPLES, 1, extraSampleTypes); TIFFSetField(image, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB); } - else if(samplesperpixel == 3) { + else if (samplesperpixel == 3) { /* RGB images */ TIFFSetField(image, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB); } - else if(samplesperpixel == 1) { + else if (samplesperpixel == 1) { /* greyscale images, 1 channel */ TIFFSetField(image, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK); } /* copy pixel data. While copying, we flip the image vertically. */ - for(x = 0; x < ibuf->x; x++) { - for(y = 0; y < ibuf->y; y++) { + for (x = 0; x < ibuf->x; x++) { + for (y = 0; y < ibuf->y; y++) { from_i = 4*(y*ibuf->x+x); to_i = samplesperpixel*((ibuf->y-y-1)*ibuf->x+x); - if(pixels16) { + if (pixels16) { /* convert from float source */ float rgb[3]; @@ -790,7 +795,7 @@ int imb_savetiff(ImBuf *ibuf, const char *name, int flags) } } else { - for(i = 0; i < samplesperpixel; i++, to_i++, from_i++) + for (i = 0; i < samplesperpixel; i++, to_i++, from_i++) to[to_i] = from[from_i]; } } @@ -805,7 +810,7 @@ int imb_savetiff(ImBuf *ibuf, const char *name, int flags) TIFFSetField(image, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); - if(ibuf->ppm[0] > 0.0 && ibuf->ppm[1] > 0.0) { + if (ibuf->ppm[0] > 0.0 && ibuf->ppm[1] > 0.0) { xres= (float)(ibuf->ppm[0] * 0.0254); yres= (float)(ibuf->ppm[1] * 0.0254); } @@ -816,20 +821,20 @@ int imb_savetiff(ImBuf *ibuf, const char *name, int flags) TIFFSetField(image, TIFFTAG_XRESOLUTION, xres); TIFFSetField(image, TIFFTAG_YRESOLUTION, yres); TIFFSetField(image, TIFFTAG_RESOLUTIONUNIT, RESUNIT_INCH); - if(TIFFWriteEncodedStrip(image, 0, + if (TIFFWriteEncodedStrip(image, 0, (bitspersample == 16)? (unsigned char*)pixels16: pixels, ibuf->x*ibuf->y*samplesperpixel*bitspersample/8) == -1) { fprintf(stderr, "imb_savetiff: Could not write encoded TIFF.\n"); TIFFClose(image); - if(pixels) _TIFFfree(pixels); - if(pixels16) _TIFFfree(pixels16); + if (pixels) _TIFFfree(pixels); + if (pixels16) _TIFFfree(pixels16); return (1); } /* close the TIFF file */ TIFFClose(image); - if(pixels) _TIFFfree(pixels); - if(pixels16) _TIFFfree(pixels16); + if (pixels) _TIFFfree(pixels); + if (pixels16) _TIFFfree(pixels16); return (1); } diff --git a/source/blender/imbuf/intern/util.c b/source/blender/imbuf/intern/util.c index fdcc0641628..008be2fde74 100644 --- a/source/blender/imbuf/intern/util.c +++ b/source/blender/imbuf/intern/util.c @@ -152,17 +152,17 @@ static int IMB_ispic_name(const char *name) struct stat st; int fp, buf[10]; - if(UTIL_DEBUG) printf("IMB_ispic_name: loading %s\n", name); + if (UTIL_DEBUG) printf("IMB_ispic_name: loading %s\n", name); - if(stat(name,&st) == -1) + if (stat(name,&st) == -1) return FALSE; - if(((st.st_mode) & S_IFMT) != S_IFREG) + if (((st.st_mode) & S_IFMT) != S_IFREG) return FALSE; - if((fp = BLI_open(name,O_BINARY|O_RDONLY, 0)) < 0) + if ((fp = BLI_open(name,O_BINARY|O_RDONLY, 0)) < 0) return FALSE; - if(read(fp, buf, 32) != 32) { + if (read(fp, buf, 32) != 32) { close(fp); return FALSE; } @@ -170,11 +170,11 @@ static int IMB_ispic_name(const char *name) close(fp); /* XXX move this exception */ - if((BIG_LONG(buf[0]) & 0xfffffff0) == 0xffd8ffe0) + if ((BIG_LONG(buf[0]) & 0xfffffff0) == 0xffd8ffe0) return JPG; - for(type=IMB_FILE_TYPES; type->is_a; type++) - if(type->is_a((uchar*)buf)) + for (type=IMB_FILE_TYPES; type->is_a; type++) + if (type->is_a((uchar*)buf)) return type->filetype; return FALSE; @@ -182,8 +182,8 @@ static int IMB_ispic_name(const char *name) int IMB_ispic(const char *filename) { - if(U.uiflag & USER_FILTERFILEEXTS) { - if( (BLI_testextensie_array(filename, imb_ext_image)) || + if (U.uiflag & USER_FILTERFILEEXTS) { + if ( (BLI_testextensie_array(filename, imb_ext_image)) || (G.have_quicktime && BLI_testextensie_array(filename, imb_ext_image_qt)) ) { return IMB_ispic_name(filename); @@ -234,7 +234,8 @@ void do_init_ffmpeg(void) if ((G.f & G_DEBUG) == 0) { silence_log_ffmpeg(1); - } else { + } + else { silence_log_ffmpeg(0); } } @@ -250,7 +251,7 @@ static int isffmpeg (const char *filename) do_init_ffmpeg(); - if( BLI_testextensie(filename, ".swf") || + if ( BLI_testextensie(filename, ".swf") || BLI_testextensie(filename, ".jpg") || BLI_testextensie(filename, ".png") || BLI_testextensie(filename, ".dds") || @@ -260,24 +261,24 @@ static int isffmpeg (const char *filename) BLI_testextensie(filename, ".cin") || BLI_testextensie(filename, ".wav")) return 0; - if(av_open_input_file(&pFormatCtx, filename, NULL, 0, NULL)!=0) { - if(UTIL_DEBUG) fprintf(stderr, "isffmpeg: av_open_input_file failed\n"); + if (av_open_input_file(&pFormatCtx, filename, NULL, 0, NULL)!=0) { + if (UTIL_DEBUG) fprintf(stderr, "isffmpeg: av_open_input_file failed\n"); return 0; } - if(av_find_stream_info(pFormatCtx)<0) { - if(UTIL_DEBUG) fprintf(stderr, "isffmpeg: av_find_stream_info failed\n"); + if (av_find_stream_info(pFormatCtx)<0) { + if (UTIL_DEBUG) fprintf(stderr, "isffmpeg: av_find_stream_info failed\n"); av_close_input_file(pFormatCtx); return 0; } - if(UTIL_DEBUG) av_dump_format(pFormatCtx, 0, filename, 0); + if (UTIL_DEBUG) av_dump_format(pFormatCtx, 0, filename, 0); /* Find the first video stream */ videoStream=-1; - for(i=0; i<pFormatCtx->nb_streams; i++) - if(pFormatCtx->streams[i] && + for (i=0; i<pFormatCtx->nb_streams; i++) + if (pFormatCtx->streams[i] && pFormatCtx->streams[i]->codec && (pFormatCtx->streams[i]->codec->codec_type==AVMEDIA_TYPE_VIDEO)) { @@ -285,7 +286,7 @@ static int isffmpeg (const char *filename) break; } - if(videoStream==-1) { + if (videoStream==-1) { av_close_input_file(pFormatCtx); return 0; } @@ -294,12 +295,12 @@ static int isffmpeg (const char *filename) /* Find the decoder for the video stream */ pCodec=avcodec_find_decoder(pCodecCtx->codec_id); - if(pCodec==NULL) { + if (pCodec==NULL) { av_close_input_file(pFormatCtx); return 0; } - if(avcodec_open(pCodecCtx, pCodec)<0) { + if (avcodec_open(pCodecCtx, pCodec)<0) { av_close_input_file(pFormatCtx); return 0; } @@ -329,7 +330,7 @@ int imb_get_anim_type(const char * name) int type; struct stat st; - if(UTIL_DEBUG) printf("in getanimtype: %s\n", name); + if (UTIL_DEBUG) printf("in getanimtype: %s\n", name); #ifndef _WIN32 # ifdef WITH_QUICKTIME @@ -370,9 +371,9 @@ int IMB_isanim(const char *filename) { int type; - if(U.uiflag & USER_FILTERFILEEXTS) { - if (G.have_quicktime){ - if( BLI_testextensie(filename, ".avi") + if (U.uiflag & USER_FILTERFILEEXTS) { + if (G.have_quicktime) { + if ( BLI_testextensie(filename, ".avi") || BLI_testextensie(filename, ".flc") || BLI_testextensie(filename, ".dv") || BLI_testextensie(filename, ".r3d") @@ -380,11 +381,13 @@ int IMB_isanim(const char *filename) || BLI_testextensie(filename, ".movie") || BLI_testextensie(filename, ".mv")) { type = imb_get_anim_type(filename); - } else { + } + else { return(FALSE); } - } else { // no quicktime - if( BLI_testextensie(filename, ".avi") + } + else { // no quicktime + if ( BLI_testextensie(filename, ".avi") || BLI_testextensie(filename, ".dv") || BLI_testextensie(filename, ".r3d") || BLI_testextensie(filename, ".mv")) { @@ -394,7 +397,8 @@ int IMB_isanim(const char *filename) return(FALSE); } } - } else { // no FILTERFILEEXTS + } + else { // no FILTERFILEEXTS type = imb_get_anim_type(filename); } diff --git a/source/blender/imbuf/intern/writeimage.c b/source/blender/imbuf/intern/writeimage.c index 8fbed6da32b..60fc7db6465 100644 --- a/source/blender/imbuf/intern/writeimage.c +++ b/source/blender/imbuf/intern/writeimage.c @@ -44,13 +44,13 @@ short IMB_saveiff(struct ImBuf *ibuf, const char *name, int flags) { ImFileType *type; - if(ibuf == NULL) return (FALSE); + if (ibuf == NULL) return (FALSE); ibuf->flags = flags; - for(type=IMB_FILE_TYPES; type->is_a; type++) { - if(type->save && type->ftype(type, ibuf)) { - if(!(type->flag & IM_FTYPE_FLOAT)) { - if(ibuf->rect==NULL && ibuf->rect_float) + for (type=IMB_FILE_TYPES; type->is_a; type++) { + if (type->save && type->ftype(type, ibuf)) { + if (!(type->flag & IM_FTYPE_FLOAT)) { + if (ibuf->rect==NULL && ibuf->rect_float) IMB_rect_from_float(ibuf); } return type->save(ibuf, name, flags); diff --git a/source/blender/nodes/composite/node_composite_tree.c b/source/blender/nodes/composite/node_composite_tree.c index 0ebed7105f0..b60e962f534 100644 --- a/source/blender/nodes/composite/node_composite_tree.c +++ b/source/blender/nodes/composite/node_composite_tree.c @@ -63,8 +63,8 @@ static void foreach_nodetree(Main *main, void *calldata, bNodeTreeCallback func) { Scene *sce; - for(sce= main->scene.first; sce; sce= sce->id.next) { - if(sce->nodetree) { + for (sce= main->scene.first; sce; sce= sce->id.next) { + if (sce->nodetree) { func(calldata, &sce->id, sce->nodetree); } } @@ -88,8 +88,8 @@ static void free_node_cache(bNodeTree *UNUSED(ntree), bNode *node) { bNodeSocket *sock; - for(sock= node->outputs.first; sock; sock= sock->next) { - if(sock->cache) { + for (sock= node->outputs.first; sock; sock= sock->next) { + if (sock->cache) { free_compbuf(sock->cache); sock->cache= NULL; } @@ -99,7 +99,7 @@ static void free_node_cache(bNodeTree *UNUSED(ntree), bNode *node) static void free_cache(bNodeTree *ntree) { bNode *node; - for(node= ntree->nodes.first; node; node= node->next) + for (node= ntree->nodes.first; node; node= node->next) free_node_cache(ntree, node); } @@ -107,8 +107,8 @@ static void update_node(bNodeTree *ntree, bNode *node) { bNodeSocket *sock; - for(sock= node->outputs.first; sock; sock= sock->next) { - if(sock->cache) { + for (sock= node->outputs.first; sock; sock= sock->next) { + if (sock->cache) { //free_compbuf(sock->cache); //sock->cache= NULL; } @@ -126,23 +126,23 @@ static void localize(bNodeTree *localtree, bNodeTree *ntree) bNode *node, *node_next; bNodeSocket *sock; - for(node= ntree->nodes.first; node; node= node->next) { + for (node= ntree->nodes.first; node; node= node->next) { /* ensure new user input gets handled ok */ node->need_exec= 0; /* move over the compbufs */ /* right after ntreeCopyTree() oldsock pointers are valid */ - if(ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) { - if(node->id) { - if(node->flag & NODE_DO_OUTPUT) + if (ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) { + if (node->id) { + if (node->flag & NODE_DO_OUTPUT) node->new_node->id= (ID *)copy_image((Image *)node->id); else node->new_node->id= NULL; } } - for(sock= node->outputs.first; sock; sock= sock->next) { + for (sock= node->outputs.first; sock; sock= sock->next) { sock->new_sock->cache= sock->cache; compbuf_set_node(sock->new_sock->cache, node->new_node); @@ -177,11 +177,11 @@ static void local_sync(bNodeTree *localtree, bNodeTree *ntree) bNode *lnode; /* move over the compbufs and previews */ - for(lnode= localtree->nodes.first; lnode; lnode= lnode->next) { - if( (lnode->exec & NODE_READY) && !(lnode->exec & NODE_SKIPPED) ) { - if(ntreeNodeExists(ntree, lnode->new_node)) { + for (lnode= localtree->nodes.first; lnode; lnode= lnode->next) { + if ( (lnode->exec & NODE_READY) && !(lnode->exec & NODE_SKIPPED) ) { + if (ntreeNodeExists(ntree, lnode->new_node)) { - if(lnode->preview && lnode->preview->rect) { + if (lnode->preview && lnode->preview->rect) { nodeFreePreview(lnode->new_node); lnode->new_node->preview= lnode->preview; lnode->preview= NULL; @@ -197,28 +197,28 @@ static void local_merge(bNodeTree *localtree, bNodeTree *ntree) bNodeSocket *lsock; /* move over the compbufs and previews */ - for(lnode= localtree->nodes.first; lnode; lnode= lnode->next) { - if(ntreeNodeExists(ntree, lnode->new_node)) { - if(ELEM(lnode->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) { - if(lnode->id && (lnode->flag & NODE_DO_OUTPUT)) { + for (lnode= localtree->nodes.first; lnode; lnode= lnode->next) { + if (ntreeNodeExists(ntree, lnode->new_node)) { + if (ELEM(lnode->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) { + if (lnode->id && (lnode->flag & NODE_DO_OUTPUT)) { /* image_merge does sanity check for pointers */ BKE_image_merge((Image *)lnode->new_node->id, (Image *)lnode->id); } } - else if(lnode->type==CMP_NODE_MOVIEDISTORTION) { + else if (lnode->type==CMP_NODE_MOVIEDISTORTION) { /* special case for distortion node: distortion context is allocating in exec function and to achive much better performance on further calls this context should be copied back to original node */ - if(lnode->storage) { - if(lnode->new_node->storage) + if (lnode->storage) { + if (lnode->new_node->storage) BKE_tracking_distortion_destroy(lnode->new_node->storage); lnode->new_node->storage= BKE_tracking_distortion_copy(lnode->storage); } } - for(lsock= lnode->outputs.first; lsock; lsock= lsock->next) { - if(ntreeOutputExists(lnode->new_node, lsock->new_sock)) { + for (lsock= lnode->outputs.first; lsock; lsock= lsock->next) { + if (ntreeOutputExists(lnode->new_node, lsock->new_sock)) { lsock->new_sock->cache= lsock->cache; compbuf_set_node(lsock->new_sock->cache, lnode->new_node); lsock->cache= NULL; @@ -276,21 +276,21 @@ struct bNodeTreeExec *ntreeCompositBeginExecTree(bNodeTree *ntree, int use_tree_ exec = ntree_exec_begin(ntree); - for(node= exec->nodetree->nodes.first; node; node= node->next) { + for (node= exec->nodetree->nodes.first; node; node= node->next) { /* initialize needed for groups */ node->exec= 0; - for(sock= node->outputs.first; sock; sock= sock->next) { + for (sock= node->outputs.first; sock; sock= sock->next) { bNodeStack *ns= node_get_socket_stack(exec->stack, sock); - if(ns && sock->cache) { + if (ns && sock->cache) { ns->data= sock->cache; sock->cache= NULL; } } /* cannot initialize them while using in threads */ - if(ELEM4(node->type, CMP_NODE_TIME, CMP_NODE_CURVE_VEC, CMP_NODE_CURVE_RGB, CMP_NODE_HUECORRECT)) { + if (ELEM4(node->type, CMP_NODE_TIME, CMP_NODE_CURVE_VEC, CMP_NODE_CURVE_RGB, CMP_NODE_HUECORRECT)) { curvemapping_initialize(node->storage); - if(node->type==CMP_NODE_CURVE_RGB) + if (node->type==CMP_NODE_CURVE_RGB) curvemapping_premultiply(node->storage, 0); } } @@ -310,22 +310,22 @@ struct bNodeTreeExec *ntreeCompositBeginExecTree(bNodeTree *ntree, int use_tree_ */ void ntreeCompositEndExecTree(bNodeTreeExec *exec, int use_tree_data) { - if(exec) { + if (exec) { bNodeTree *ntree= exec->nodetree; bNode *node; bNodeStack *ns; - for(node= exec->nodetree->nodes.first; node; node= node->next) { + for (node= exec->nodetree->nodes.first; node; node= node->next) { bNodeSocket *sock; - for(sock= node->outputs.first; sock; sock= sock->next) { + for (sock= node->outputs.first; sock; sock= sock->next) { ns = node_get_socket_stack(exec->stack, sock); - if(ns && ns->data) { + if (ns && ns->data) { sock->cache= ns->data; ns->data= NULL; } } - if(node->type==CMP_NODE_CURVE_RGB) + if (node->type==CMP_NODE_CURVE_RGB) curvemapping_premultiply(node->storage, 1); node->need_exec= 0; @@ -347,14 +347,14 @@ static int node_only_value(bNode *node) { bNodeSocket *sock; - if(ELEM3(node->type, CMP_NODE_TIME, CMP_NODE_VALUE, CMP_NODE_RGB)) + if (ELEM3(node->type, CMP_NODE_TIME, CMP_NODE_VALUE, CMP_NODE_RGB)) return 1; /* doing this for all node types goes wrong. memory free errors */ - if(node->inputs.first && node->type==CMP_NODE_MAP_VALUE) { + if (node->inputs.first && node->type==CMP_NODE_MAP_VALUE) { int retval= 1; - for(sock= node->inputs.first; sock; sock= sock->next) { - if(sock->link) + for (sock= node->inputs.first; sock; sock= sock->next) { + if (sock->link) retval &= node_only_value(sock->link->fromnode); } return retval; @@ -378,7 +378,7 @@ static void *exec_composite_node(void *nodeexec_v) node_get_stack(node, thd->stack, nsin, nsout); - if(node->typeinfo->execfunc) + if (node->typeinfo->execfunc) node->typeinfo->execfunc(thd->rd, node, nsin, nsout); else if (node->typeinfo->newexecfunc) node->typeinfo->newexecfunc(thd->rd, 0, node, nodeexec->data, nsin, nsout); @@ -399,13 +399,13 @@ static int setExecutableNodes(bNodeTreeExec *exec, ThreadData *thd) int n, totnode= 0, group_edit= 0; /* if we are in group edit, viewer nodes get skipped when group has viewer */ - for(node= ntree->nodes.first; node; node= node->next) - if(node->type==NODE_GROUP && (node->flag & NODE_GROUP_EDIT)) - if(ntreeHasType((bNodeTree *)node->id, CMP_NODE_VIEWER)) + for (node= ntree->nodes.first; node; node= node->next) + if (node->type==NODE_GROUP && (node->flag & NODE_GROUP_EDIT)) + if (ntreeHasType((bNodeTree *)node->id, CMP_NODE_VIEWER)) group_edit= 1; /* NB: using the exec data list here to have valid dependency sort */ - for(n=0, nodeexec=exec->nodeexec; n < exec->totnodes; ++n, ++nodeexec) { + for (n=0, nodeexec=exec->nodeexec; n < exec->totnodes; ++n, ++nodeexec) { int a; node = nodeexec->node; @@ -413,9 +413,9 @@ static int setExecutableNodes(bNodeTreeExec *exec, ThreadData *thd) /* test the outputs */ /* skip value-only nodes (should be in type!) */ - if(!node_only_value(node)) { - for(a=0, sock= node->outputs.first; sock; sock= sock->next, a++) { - if(nsout[a]->data==NULL && nsout[a]->hasoutput) { + if (!node_only_value(node)) { + for (a=0, sock= node->outputs.first; sock; sock= sock->next, a++) { + if (nsout[a]->data==NULL && nsout[a]->hasoutput) { node->need_exec= 1; break; } @@ -423,18 +423,18 @@ static int setExecutableNodes(bNodeTreeExec *exec, ThreadData *thd) } /* test the inputs */ - for(a=0, sock= node->inputs.first; sock; sock= sock->next, a++) { + for (a=0, sock= node->inputs.first; sock; sock= sock->next, a++) { /* skip viewer nodes in bg render or group edit */ - if( ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER) && (G.background || group_edit)) + if ( ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER) && (G.background || group_edit)) node->need_exec= 0; /* is sock in use? */ - else if(sock->link) { + else if (sock->link) { bNodeLink *link= sock->link; /* this is the test for a cyclic case */ - if(link->fromnode==NULL || link->tonode==NULL); - else if(link->fromnode->level >= link->tonode->level && link->tonode->level!=0xFFF) { - if(link->fromnode->need_exec) { + if (link->fromnode==NULL || link->tonode==NULL); + else if (link->fromnode->level >= link->tonode->level && link->tonode->level!=0xFFF) { + if (link->fromnode->need_exec) { node->need_exec= 1; break; } @@ -446,11 +446,11 @@ static int setExecutableNodes(bNodeTreeExec *exec, ThreadData *thd) } } - if(node->need_exec) { + if (node->need_exec) { /* free output buffers */ - for(a=0, sock= node->outputs.first; sock; sock= sock->next, a++) { - if(nsout[a]->data) { + for (a=0, sock= node->outputs.first; sock; sock= sock->next, a++) { + if (nsout[a]->data) { free_compbuf(nsout[a]->data); nsout[a]->data= NULL; } @@ -470,11 +470,11 @@ static int setExecutableNodes(bNodeTreeExec *exec, ThreadData *thd) /* last step: set the stack values for only-value nodes */ /* just does all now, compared to a full buffer exec this is nothing */ - if(totnode) { - for(n=0, nodeexec=exec->nodeexec; n < exec->totnodes; ++n, ++nodeexec) { + if (totnode) { + for (n=0, nodeexec=exec->nodeexec; n < exec->totnodes; ++n, ++nodeexec) { node = nodeexec->node; - if(node->need_exec==0 && node_only_value(node)) { - if(node->typeinfo->execfunc) { + if (node->need_exec==0 && node_only_value(node)) { + if (node->typeinfo->execfunc) { node_get_stack(node, exec->stack, nsin, nsout); node->typeinfo->execfunc(thd->rd, node, nsin, nsout); } @@ -499,28 +499,28 @@ static void freeExecutableNode(bNodeTreeExec *exec) int n; /* set exec flag for finished nodes that might need freed */ - for(node= ntree->nodes.first; node; node= node->next) { - if(node->type!=CMP_NODE_R_LAYERS) - if(node->exec & NODE_FINISHED) + for (node= ntree->nodes.first; node; node= node->next) { + if (node->type!=CMP_NODE_R_LAYERS) + if (node->exec & NODE_FINISHED) node->exec |= NODE_FREEBUFS; } /* clear this flag for input links that are not done yet. * Using the exec data for valid dependency sort. */ - for(n=0, nodeexec=exec->nodeexec; n < exec->totnodes; ++n, ++nodeexec) { + for (n=0, nodeexec=exec->nodeexec; n < exec->totnodes; ++n, ++nodeexec) { node = nodeexec->node; - if((node->exec & NODE_FINISHED)==0) { - for(sock= node->inputs.first; sock; sock= sock->next) - if(sock->link) + if ((node->exec & NODE_FINISHED)==0) { + for (sock= node->inputs.first; sock; sock= sock->next) + if (sock->link) sock->link->fromnode->exec &= ~NODE_FREEBUFS; } } /* now we can free buffers */ - for(node= ntree->nodes.first; node; node= node->next) { - if(node->exec & NODE_FREEBUFS) { - for(sock= node->outputs.first; sock; sock= sock->next) { + for (node= ntree->nodes.first; node; node= node->next) { + if (node->exec & NODE_FREEBUFS) { + for (sock= node->outputs.first; sock; sock= sock->next) { bNodeStack *ns= node_get_socket_stack(exec->stack, sock); - if(ns && ns->data) { + if (ns && ns->data) { free_compbuf(ns->data); ns->data= NULL; // printf("freed buf node %s \n", node->name); @@ -536,15 +536,15 @@ static bNodeExec *getExecutableNode(bNodeTreeExec *exec) bNodeSocket *sock; int n; - for(n=0, nodeexec=exec->nodeexec; n < exec->totnodes; ++n, ++nodeexec) { - if(nodeexec->node->exec==0) { + for (n=0, nodeexec=exec->nodeexec; n < exec->totnodes; ++n, ++nodeexec) { + if (nodeexec->node->exec==0) { /* input sockets should be ready */ - for(sock= nodeexec->node->inputs.first; sock; sock= sock->next) { - if(sock->link && sock->link->fromnode) - if((sock->link->fromnode->exec & NODE_READY)==0) + for (sock= nodeexec->node->inputs.first; sock; sock= sock->next) { + if (sock->link && sock->link->fromnode) + if ((sock->link->fromnode->exec & NODE_READY)==0) break; } - if(sock==NULL) + if (sock==NULL) return nodeexec; } } @@ -556,12 +556,12 @@ static void ntree_composite_texnode(bNodeTree *ntree, int init) { bNode *node; - for(node= ntree->nodes.first; node; node= node->next) { - if(node->type==CMP_NODE_TEXTURE && node->id) { + for (node= ntree->nodes.first; node; node= node->next) { + if (node->type==CMP_NODE_TEXTURE && node->id) { Tex *tex= (Tex *)node->id; - if(tex->nodetree && tex->use_nodes) { + if (tex->nodetree && tex->use_nodes) { /* has internal flag to detect it only does it once */ - if(init) { + if (init) { if (!tex->nodetree->execdata) tex->nodetree->execdata = ntreeTexBeginExecTree(tex->nodetree, 1); } @@ -584,11 +584,11 @@ void ntreeCompositExecTree(bNodeTree *ntree, RenderData *rd, int do_preview) int totnode, curnode, rendering= 1, n; bNodeTreeExec *exec; - if(ntree==NULL) return; + if (ntree==NULL) return; exec = ntree->execdata; - if(do_preview) + if (do_preview) ntreeInitPreview(ntree, 0, 0); if (!ntree->execdata) { @@ -598,7 +598,7 @@ void ntreeCompositExecTree(bNodeTree *ntree, RenderData *rd, int do_preview) ntree_composite_texnode(ntree, 1); /* prevent unlucky accidents */ - if(G.background) + if (G.background) rd->scemode &= ~R_COMP_CROP; /* setup callerdata for thread callback */ @@ -613,15 +613,15 @@ void ntreeCompositExecTree(bNodeTree *ntree, RenderData *rd, int do_preview) BLI_init_threads(&threads, exec_composite_node, rd->threads); - while(rendering) { + while (rendering) { - if(BLI_available_threads(&threads)) { + if (BLI_available_threads(&threads)) { nodeexec= getExecutableNode(exec); - if(nodeexec) { + if (nodeexec) { node = nodeexec->node; - if(ntree->progress && totnode) + if (ntree->progress && totnode) ntree->progress(ntree->prh, (1.0f - curnode/(float)totnode)); - if(ntree->stats_draw) { + if (ntree->stats_draw) { char str[128]; BLI_snprintf(str, sizeof(str), "Compositing %d %s", curnode, node->name); ntree->stats_draw(ntree->sdh, str); @@ -640,21 +640,21 @@ void ntreeCompositExecTree(bNodeTree *ntree, RenderData *rd, int do_preview) rendering= 0; /* test for ESC */ - if(ntree->test_break && ntree->test_break(ntree->tbh)) { - for(node= ntree->nodes.first; node; node= node->next) + if (ntree->test_break && ntree->test_break(ntree->tbh)) { + for (node= ntree->nodes.first; node; node= node->next) node->exec |= NODE_READY; } /* check for ready ones, and if we need to continue */ - for(n=0, nodeexec=exec->nodeexec; n < exec->totnodes; ++n, ++nodeexec) { + for (n=0, nodeexec=exec->nodeexec; n < exec->totnodes; ++n, ++nodeexec) { node = nodeexec->node; - if(node->exec & NODE_READY) { - if((node->exec & NODE_FINISHED)==0) { + if (node->exec & NODE_READY) { + if ((node->exec & NODE_FINISHED)==0) { BLI_remove_thread(&threads, nodeexec); /* this waits for running thread to finish btw */ node->exec |= NODE_FINISHED; /* freeing unused buffers */ - if(rd->scemode & R_COMP_FREE) + if (rd->scemode & R_COMP_FREE) freeExecutableNode(exec); } } @@ -675,10 +675,10 @@ static void force_hidden_passes(bNode *node, int passflag) { bNodeSocket *sock; - for(sock= node->outputs.first; sock; sock= sock->next) + for (sock= node->outputs.first; sock; sock= sock->next) sock->flag &= ~SOCK_UNAVAIL; - if(!(passflag & SCE_PASS_COMBINED)) { + if (!(passflag & SCE_PASS_COMBINED)) { sock= BLI_findlink(&node->outputs, RRES_OUT_IMAGE); sock->flag |= SOCK_UNAVAIL; sock= BLI_findlink(&node->outputs, RRES_OUT_ALPHA); @@ -686,60 +686,60 @@ static void force_hidden_passes(bNode *node, int passflag) } sock= BLI_findlink(&node->outputs, RRES_OUT_Z); - if(!(passflag & SCE_PASS_Z)) sock->flag |= SOCK_UNAVAIL; + if (!(passflag & SCE_PASS_Z)) sock->flag |= SOCK_UNAVAIL; sock= BLI_findlink(&node->outputs, RRES_OUT_NORMAL); - if(!(passflag & SCE_PASS_NORMAL)) sock->flag |= SOCK_UNAVAIL; + if (!(passflag & SCE_PASS_NORMAL)) sock->flag |= SOCK_UNAVAIL; sock= BLI_findlink(&node->outputs, RRES_OUT_VEC); - if(!(passflag & SCE_PASS_VECTOR)) sock->flag |= SOCK_UNAVAIL; + if (!(passflag & SCE_PASS_VECTOR)) sock->flag |= SOCK_UNAVAIL; sock= BLI_findlink(&node->outputs, RRES_OUT_UV); - if(!(passflag & SCE_PASS_UV)) sock->flag |= SOCK_UNAVAIL; + if (!(passflag & SCE_PASS_UV)) sock->flag |= SOCK_UNAVAIL; sock= BLI_findlink(&node->outputs, RRES_OUT_RGBA); - if(!(passflag & SCE_PASS_RGBA)) sock->flag |= SOCK_UNAVAIL; + if (!(passflag & SCE_PASS_RGBA)) sock->flag |= SOCK_UNAVAIL; sock= BLI_findlink(&node->outputs, RRES_OUT_DIFF); - if(!(passflag & SCE_PASS_DIFFUSE)) sock->flag |= SOCK_UNAVAIL; + if (!(passflag & SCE_PASS_DIFFUSE)) sock->flag |= SOCK_UNAVAIL; sock= BLI_findlink(&node->outputs, RRES_OUT_SPEC); - if(!(passflag & SCE_PASS_SPEC)) sock->flag |= SOCK_UNAVAIL; + if (!(passflag & SCE_PASS_SPEC)) sock->flag |= SOCK_UNAVAIL; sock= BLI_findlink(&node->outputs, RRES_OUT_SHADOW); - if(!(passflag & SCE_PASS_SHADOW)) sock->flag |= SOCK_UNAVAIL; + if (!(passflag & SCE_PASS_SHADOW)) sock->flag |= SOCK_UNAVAIL; sock= BLI_findlink(&node->outputs, RRES_OUT_AO); - if(!(passflag & SCE_PASS_AO)) sock->flag |= SOCK_UNAVAIL; + if (!(passflag & SCE_PASS_AO)) sock->flag |= SOCK_UNAVAIL; sock= BLI_findlink(&node->outputs, RRES_OUT_REFLECT); - if(!(passflag & SCE_PASS_REFLECT)) sock->flag |= SOCK_UNAVAIL; + if (!(passflag & SCE_PASS_REFLECT)) sock->flag |= SOCK_UNAVAIL; sock= BLI_findlink(&node->outputs, RRES_OUT_REFRACT); - if(!(passflag & SCE_PASS_REFRACT)) sock->flag |= SOCK_UNAVAIL; + if (!(passflag & SCE_PASS_REFRACT)) sock->flag |= SOCK_UNAVAIL; sock= BLI_findlink(&node->outputs, RRES_OUT_INDIRECT); - if(!(passflag & SCE_PASS_INDIRECT)) sock->flag |= SOCK_UNAVAIL; + if (!(passflag & SCE_PASS_INDIRECT)) sock->flag |= SOCK_UNAVAIL; sock= BLI_findlink(&node->outputs, RRES_OUT_INDEXOB); - if(!(passflag & SCE_PASS_INDEXOB)) sock->flag |= SOCK_UNAVAIL; + if (!(passflag & SCE_PASS_INDEXOB)) sock->flag |= SOCK_UNAVAIL; sock= BLI_findlink(&node->outputs, RRES_OUT_INDEXMA); - if(!(passflag & SCE_PASS_INDEXMA)) sock->flag |= SOCK_UNAVAIL; + if (!(passflag & SCE_PASS_INDEXMA)) sock->flag |= SOCK_UNAVAIL; sock= BLI_findlink(&node->outputs, RRES_OUT_MIST); - if(!(passflag & SCE_PASS_MIST)) sock->flag |= SOCK_UNAVAIL; + if (!(passflag & SCE_PASS_MIST)) sock->flag |= SOCK_UNAVAIL; sock= BLI_findlink(&node->outputs, RRES_OUT_EMIT); - if(!(passflag & SCE_PASS_EMIT)) sock->flag |= SOCK_UNAVAIL; + if (!(passflag & SCE_PASS_EMIT)) sock->flag |= SOCK_UNAVAIL; sock= BLI_findlink(&node->outputs, RRES_OUT_ENV); - if(!(passflag & SCE_PASS_ENVIRONMENT)) sock->flag |= SOCK_UNAVAIL; + if (!(passflag & SCE_PASS_ENVIRONMENT)) sock->flag |= SOCK_UNAVAIL; sock= BLI_findlink(&node->outputs, RRES_OUT_DIFF_DIRECT); - if(!(passflag & SCE_PASS_DIFFUSE_DIRECT)) sock->flag |= SOCK_UNAVAIL; + if (!(passflag & SCE_PASS_DIFFUSE_DIRECT)) sock->flag |= SOCK_UNAVAIL; sock= BLI_findlink(&node->outputs, RRES_OUT_DIFF_INDIRECT); - if(!(passflag & SCE_PASS_DIFFUSE_INDIRECT)) sock->flag |= SOCK_UNAVAIL; + if (!(passflag & SCE_PASS_DIFFUSE_INDIRECT)) sock->flag |= SOCK_UNAVAIL; sock= BLI_findlink(&node->outputs, RRES_OUT_DIFF_COLOR); - if(!(passflag & SCE_PASS_DIFFUSE_COLOR)) sock->flag |= SOCK_UNAVAIL; + if (!(passflag & SCE_PASS_DIFFUSE_COLOR)) sock->flag |= SOCK_UNAVAIL; sock= BLI_findlink(&node->outputs, RRES_OUT_GLOSSY_DIRECT); - if(!(passflag & SCE_PASS_GLOSSY_DIRECT)) sock->flag |= SOCK_UNAVAIL; + if (!(passflag & SCE_PASS_GLOSSY_DIRECT)) sock->flag |= SOCK_UNAVAIL; sock= BLI_findlink(&node->outputs, RRES_OUT_GLOSSY_INDIRECT); - if(!(passflag & SCE_PASS_GLOSSY_INDIRECT)) sock->flag |= SOCK_UNAVAIL; + if (!(passflag & SCE_PASS_GLOSSY_INDIRECT)) sock->flag |= SOCK_UNAVAIL; sock= BLI_findlink(&node->outputs, RRES_OUT_GLOSSY_COLOR); - if(!(passflag & SCE_PASS_GLOSSY_COLOR)) sock->flag |= SOCK_UNAVAIL; + if (!(passflag & SCE_PASS_GLOSSY_COLOR)) sock->flag |= SOCK_UNAVAIL; sock= BLI_findlink(&node->outputs, RRES_OUT_TRANSM_DIRECT); - if(!(passflag & SCE_PASS_TRANSM_DIRECT)) sock->flag |= SOCK_UNAVAIL; + if (!(passflag & SCE_PASS_TRANSM_DIRECT)) sock->flag |= SOCK_UNAVAIL; sock= BLI_findlink(&node->outputs, RRES_OUT_TRANSM_INDIRECT); - if(!(passflag & SCE_PASS_TRANSM_INDIRECT)) sock->flag |= SOCK_UNAVAIL; + if (!(passflag & SCE_PASS_TRANSM_INDIRECT)) sock->flag |= SOCK_UNAVAIL; sock= BLI_findlink(&node->outputs, RRES_OUT_TRANSM_COLOR); - if(!(passflag & SCE_PASS_TRANSM_COLOR)) sock->flag |= SOCK_UNAVAIL; + if (!(passflag & SCE_PASS_TRANSM_COLOR)) sock->flag |= SOCK_UNAVAIL; sock= BLI_findlink(&node->outputs, RRES_OUT_TRANSM_COLOR); } @@ -748,27 +748,27 @@ void ntreeCompositForceHidden(bNodeTree *ntree, Scene *curscene) { bNode *node; - if(ntree==NULL) return; + if (ntree==NULL) return; - for(node= ntree->nodes.first; node; node= node->next) { - if( node->type==CMP_NODE_R_LAYERS) { + for (node= ntree->nodes.first; node; node= node->next) { + if ( node->type==CMP_NODE_R_LAYERS) { Scene *sce= node->id?(Scene *)node->id:curscene; SceneRenderLayer *srl= BLI_findlink(&sce->r.layers, node->custom1); - if(srl) + if (srl) force_hidden_passes(node, srl->passflag); } - else if( node->type==CMP_NODE_IMAGE) { + else if ( node->type==CMP_NODE_IMAGE) { Image *ima= (Image *)node->id; - if(ima) { - if(ima->rr) { + if (ima) { + if (ima->rr) { ImageUser *iuser= node->storage; RenderLayer *rl= BLI_findlink(&ima->rr->layers, iuser->layer); - if(rl) + if (rl) force_hidden_passes(node, rl->passflag); else force_hidden_passes(node, RRES_OUT_IMAGE|RRES_OUT_ALPHA); } - else if(ima->type!=IMA_TYPE_MULTILAYER) { /* if ->rr not yet read we keep inputs */ + else if (ima->type!=IMA_TYPE_MULTILAYER) { /* if ->rr not yet read we keep inputs */ force_hidden_passes(node, RRES_OUT_IMAGE|RRES_OUT_ALPHA|RRES_OUT_Z); } else @@ -787,14 +787,14 @@ void ntreeCompositTagRender(Scene *curscene) { Scene *sce; - for(sce= G.main->scene.first; sce; sce= sce->id.next) { - if(sce->nodetree) { + for (sce= G.main->scene.first; sce; sce= sce->id.next) { + if (sce->nodetree) { bNode *node; - for(node= sce->nodetree->nodes.first; node; node= node->next) { - if(node->id==(ID *)curscene || node->type==CMP_NODE_COMPOSITE) + for (node= sce->nodetree->nodes.first; node; node= node->next) { + if (node->id==(ID *)curscene || node->type==CMP_NODE_COMPOSITE) nodeUpdate(sce->nodetree, node); - else if(node->type==CMP_NODE_TEXTURE) /* uses scene sizex/sizey */ + else if (node->type==CMP_NODE_TEXTURE) /* uses scene sizex/sizey */ nodeUpdate(sce->nodetree, node); } } @@ -856,31 +856,31 @@ int ntreeCompositTagAnimated(bNodeTree *ntree) bNode *node; int tagged= 0; - if(ntree==NULL) return 0; + if (ntree==NULL) return 0; - for(node= ntree->nodes.first; node; node= node->next) { + for (node= ntree->nodes.first; node; node= node->next) { tagged = node_animation_properties(ntree, node); /* otherwise always tag these node types */ - if(node->type==CMP_NODE_IMAGE) { + if (node->type==CMP_NODE_IMAGE) { Image *ima= (Image *)node->id; - if(ima && ELEM(ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) { + if (ima && ELEM(ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) { nodeUpdate(ntree, node); tagged= 1; } } - else if(node->type==CMP_NODE_TIME) { + else if (node->type==CMP_NODE_TIME) { nodeUpdate(ntree, node); tagged= 1; } /* here was tag render layer, but this is called after a render, so re-composites fail */ - else if(node->type==NODE_GROUP) { - if( ntreeCompositTagAnimated((bNodeTree *)node->id) ) { + else if (node->type==NODE_GROUP) { + if ( ntreeCompositTagAnimated((bNodeTree *)node->id) ) { nodeUpdate(ntree, node); } } - else if(ELEM(node->type, CMP_NODE_MOVIECLIP, CMP_NODE_TRANSFORM)) { + else if (ELEM(node->type, CMP_NODE_MOVIECLIP, CMP_NODE_TRANSFORM)) { nodeUpdate(ntree, node); tagged= 1; } @@ -895,10 +895,10 @@ void ntreeCompositTagGenerators(bNodeTree *ntree) { bNode *node; - if(ntree==NULL) return; + if (ntree==NULL) return; - for(node= ntree->nodes.first; node; node= node->next) { - if( ELEM(node->type, CMP_NODE_R_LAYERS, CMP_NODE_IMAGE)) + for (node= ntree->nodes.first; node; node= node->next) { + if ( ELEM(node->type, CMP_NODE_R_LAYERS, CMP_NODE_IMAGE)) nodeUpdate(ntree, node); } } @@ -908,11 +908,11 @@ void ntreeCompositClearTags(bNodeTree *ntree) { bNode *node; - if(ntree==NULL) return; + if (ntree==NULL) return; - for(node= ntree->nodes.first; node; node= node->next) { + for (node= ntree->nodes.first; node; node= node->next) { node->need_exec= 0; - if(node->type==NODE_GROUP) + if (node->type==NODE_GROUP) ntreeCompositClearTags((bNodeTree *)node->id); } } diff --git a/source/blender/nodes/composite/node_composite_util.c b/source/blender/nodes/composite/node_composite_util.c index 25c073922df..8e98c055157 100644 --- a/source/blender/nodes/composite/node_composite_util.c +++ b/source/blender/nodes/composite/node_composite_util.c @@ -42,12 +42,12 @@ CompBuf *alloc_compbuf(int sizex, int sizey, int type, int alloc) cbuf->yrad= sizey/2; cbuf->type= type; - if(alloc) { - if(cbuf->type==CB_RGBA) + if (alloc) { + if (cbuf->type==CB_RGBA) cbuf->rect= MEM_mapallocN(4*sizeof(float)*sizex*sizey, "compbuf RGBA rect"); - else if(cbuf->type==CB_VEC3) + else if (cbuf->type==CB_VEC3) cbuf->rect= MEM_mapallocN(3*sizeof(float)*sizex*sizey, "compbuf Vector3 rect"); - else if(cbuf->type==CB_VEC2) + else if (cbuf->type==CB_VEC2) cbuf->rect= MEM_mapallocN(2*sizeof(float)*sizex*sizey, "compbuf Vector2 rect"); else cbuf->rect= MEM_mapallocN(sizeof(float)*sizex*sizey, "compbuf Fac rect"); @@ -64,7 +64,7 @@ CompBuf *alloc_compbuf(int sizex, int sizey, int type, int alloc) CompBuf *dupalloc_compbuf(CompBuf *cbuf) { CompBuf *dupbuf= alloc_compbuf(cbuf->x, cbuf->y, cbuf->type, 1); - if(dupbuf) { + if (dupbuf) { memcpy(dupbuf->rect, cbuf->rect, cbuf->type*sizeof(float)*cbuf->x*cbuf->y); dupbuf->xof= cbuf->xof; @@ -79,15 +79,15 @@ CompBuf *pass_on_compbuf(CompBuf *cbuf) CompBuf *dupbuf= (cbuf)? alloc_compbuf(cbuf->x, cbuf->y, cbuf->type, 0): NULL; CompBuf *lastbuf; - if(dupbuf) { + if (dupbuf) { dupbuf->rect= cbuf->rect; dupbuf->xof= cbuf->xof; dupbuf->yof= cbuf->yof; dupbuf->malloc= 0; /* get last buffer in list, and append dupbuf */ - for(lastbuf= cbuf; lastbuf; lastbuf= lastbuf->next) - if(lastbuf->next==NULL) + for (lastbuf= cbuf; lastbuf; lastbuf= lastbuf->next) + if (lastbuf->next==NULL) break; lastbuf->next= dupbuf; dupbuf->prev= lastbuf; @@ -99,13 +99,13 @@ CompBuf *pass_on_compbuf(CompBuf *cbuf) void free_compbuf(CompBuf *cbuf) { /* check referencing, then remove from list and set malloc tag */ - if(cbuf->prev || cbuf->next) { - if(cbuf->prev) + if (cbuf->prev || cbuf->next) { + if (cbuf->prev) cbuf->prev->next= cbuf->next; - if(cbuf->next) + if (cbuf->next) cbuf->next->prev= cbuf->prev; - if(cbuf->malloc) { - if(cbuf->prev) + if (cbuf->malloc) { + if (cbuf->prev) cbuf->prev->malloc= 1; else cbuf->next->malloc= 1; @@ -113,7 +113,7 @@ void free_compbuf(CompBuf *cbuf) } } - if(cbuf->malloc && cbuf->rect) + if (cbuf->malloc && cbuf->rect) MEM_freeN(cbuf->rect); MEM_freeN(cbuf); @@ -138,16 +138,16 @@ CompBuf *get_cropped_compbuf(rcti *drect, float *rectf, int rectx, int recty, in float *outfp; int dx, y; - if(disprect.xmax>rectx) disprect.xmax = rectx; - if(disprect.ymax>recty) disprect.ymax = recty; - if(disprect.xmin>= disprect.xmax) return NULL; - if(disprect.ymin>= disprect.ymax) return NULL; + if (disprect.xmax>rectx) disprect.xmax = rectx; + if (disprect.ymax>recty) disprect.ymax = recty; + if (disprect.xmin>= disprect.xmax) return NULL; + if (disprect.ymin>= disprect.ymax) return NULL; cbuf= alloc_compbuf(disprect.xmax-disprect.xmin, disprect.ymax-disprect.ymin, type, 1); outfp= cbuf->rect; rectf += type*(disprect.ymin*rectx + disprect.xmin); dx= type*cbuf->x; - for(y=cbuf->y; y>0; y--, outfp+=dx, rectf+=type*rectx) + for (y=cbuf->y; y>0; y--, outfp+=dx, rectf+=type*rectx) memcpy(outfp, rectf, sizeof(float)*dx); return cbuf; @@ -160,7 +160,7 @@ CompBuf *scalefast_compbuf(CompBuf *inbuf, int newx, int newy) int x, y, c, pixsize= inbuf->type; int ofsx, ofsy, stepx, stepy; - if(inbuf->x==newx && inbuf->y==newy) + if (inbuf->x==newx && inbuf->y==newy) return dupalloc_compbuf(inbuf); outbuf= alloc_compbuf(newx, newy, inbuf->type, 1); @@ -170,7 +170,7 @@ CompBuf *scalefast_compbuf(CompBuf *inbuf, int newx, int newy) stepy = (65536.0 * (inbuf->y - 1.0) / (newy - 1.0)) + 0.5; ofsy = 32768; - for (y = newy; y > 0 ; y--){ + for (y = newy; y > 0 ; y--) { rectf = inbuf->rect; rectf += pixsize * (ofsy >> 16) * inbuf->x; @@ -180,7 +180,7 @@ CompBuf *scalefast_compbuf(CompBuf *inbuf, int newx, int newy) for (x = newx ; x>0 ; x--) { rf= rectf + pixsize*(ofsx >> 16); - for(c=0; c<pixsize; c++) + for (c=0; c<pixsize; c++) newrectf[c] = rf[c]; newrectf+= pixsize; @@ -194,65 +194,65 @@ CompBuf *scalefast_compbuf(CompBuf *inbuf, int newx, int newy) void typecheck_compbuf_color(float *out, float *in, int outtype, int intype) { - if(intype == outtype) { + if (intype == outtype) { memcpy(out, in, sizeof(float)*outtype); } - else if(outtype==CB_VAL) { - if(intype==CB_VEC2) { + else if (outtype==CB_VAL) { + if (intype==CB_VEC2) { *out= 0.5f*(in[0]+in[1]); } - else if(intype==CB_VEC3) { + else if (intype==CB_VEC3) { *out= 0.333333f*(in[0]+in[1]+in[2]); } - else if(intype==CB_RGBA) { + else if (intype==CB_RGBA) { *out= in[0]*0.35f + in[1]*0.45f + in[2]*0.2f; } } - else if(outtype==CB_VEC2) { - if(intype==CB_VAL) { + else if (outtype==CB_VEC2) { + if (intype==CB_VAL) { out[0]= in[0]; out[1]= in[0]; } - else if(intype==CB_VEC3) { + else if (intype==CB_VEC3) { out[0]= in[0]; out[1]= in[1]; } - else if(intype==CB_RGBA) { + else if (intype==CB_RGBA) { out[0]= in[0]; out[1]= in[1]; } } - else if(outtype==CB_VEC3) { - if(intype==CB_VAL) { + else if (outtype==CB_VEC3) { + if (intype==CB_VAL) { out[0]= in[0]; out[1]= in[0]; out[2]= in[0]; } - else if(intype==CB_VEC2) { + else if (intype==CB_VEC2) { out[0]= in[0]; out[1]= in[1]; out[2]= 0.0f; } - else if(intype==CB_RGBA) { + else if (intype==CB_RGBA) { out[0]= in[0]; out[1]= in[1]; out[2]= in[2]; } } - else if(outtype==CB_RGBA) { - if(intype==CB_VAL) { + else if (outtype==CB_RGBA) { + if (intype==CB_VAL) { out[0]= in[0]; out[1]= in[0]; out[2]= in[0]; out[3]= 1.0f; } - else if(intype==CB_VEC2) { + else if (intype==CB_VEC2) { out[0]= in[0]; out[1]= in[1]; out[2]= 0.0f; out[3]= 1.0f; } - else if(intype==CB_VEC3) { + else if (intype==CB_VEC3) { out[0]= in[0]; out[1]= in[1]; out[2]= in[2]; @@ -263,7 +263,7 @@ void typecheck_compbuf_color(float *out, float *in, int outtype, int intype) CompBuf *typecheck_compbuf(CompBuf *inbuf, int type) { - if(inbuf && inbuf->type!=type) { + if (inbuf && inbuf->type!=type) { CompBuf *outbuf; float *inrf, *outrf; int x; @@ -274,7 +274,7 @@ CompBuf *typecheck_compbuf(CompBuf *inbuf, int type) outbuf->xof= inbuf->xof; outbuf->yof= inbuf->yof; - if(inbuf->rect_procedural) { + if (inbuf->rect_procedural) { outbuf->rect_procedural= inbuf->rect_procedural; copy_v3_v3(outbuf->procedural_size, inbuf->procedural_size); copy_v3_v3(outbuf->procedural_offset, inbuf->procedural_offset); @@ -287,82 +287,82 @@ CompBuf *typecheck_compbuf(CompBuf *inbuf, int type) outrf= outbuf->rect; x= inbuf->x*inbuf->y; - if(type==CB_VAL) { - if(inbuf->type==CB_VEC2) { - for(; x>0; x--, outrf+= 1, inrf+= 2) + if (type==CB_VAL) { + if (inbuf->type==CB_VEC2) { + for (; x>0; x--, outrf+= 1, inrf+= 2) *outrf= 0.5f*(inrf[0]+inrf[1]); } - else if(inbuf->type==CB_VEC3) { - for(; x>0; x--, outrf+= 1, inrf+= 3) + else if (inbuf->type==CB_VEC3) { + for (; x>0; x--, outrf+= 1, inrf+= 3) *outrf= 0.333333f*(inrf[0]+inrf[1]+inrf[2]); } - else if(inbuf->type==CB_RGBA) { - for(; x>0; x--, outrf+= 1, inrf+= 4) + else if (inbuf->type==CB_RGBA) { + for (; x>0; x--, outrf+= 1, inrf+= 4) *outrf= inrf[0]*0.35f + inrf[1]*0.45f + inrf[2]*0.2f; } } - else if(type==CB_VEC2) { - if(inbuf->type==CB_VAL) { - for(; x>0; x--, outrf+= 2, inrf+= 1) { + else if (type==CB_VEC2) { + if (inbuf->type==CB_VAL) { + for (; x>0; x--, outrf+= 2, inrf+= 1) { outrf[0]= inrf[0]; outrf[1]= inrf[0]; } } - else if(inbuf->type==CB_VEC3) { - for(; x>0; x--, outrf+= 2, inrf+= 3) { + else if (inbuf->type==CB_VEC3) { + for (; x>0; x--, outrf+= 2, inrf+= 3) { outrf[0]= inrf[0]; outrf[1]= inrf[1]; } } - else if(inbuf->type==CB_RGBA) { - for(; x>0; x--, outrf+= 2, inrf+= 4) { + else if (inbuf->type==CB_RGBA) { + for (; x>0; x--, outrf+= 2, inrf+= 4) { outrf[0]= inrf[0]; outrf[1]= inrf[1]; } } } - else if(type==CB_VEC3) { - if(inbuf->type==CB_VAL) { - for(; x>0; x--, outrf+= 3, inrf+= 1) { + else if (type==CB_VEC3) { + if (inbuf->type==CB_VAL) { + for (; x>0; x--, outrf+= 3, inrf+= 1) { outrf[0]= inrf[0]; outrf[1]= inrf[0]; outrf[2]= inrf[0]; } } - else if(inbuf->type==CB_VEC2) { - for(; x>0; x--, outrf+= 3, inrf+= 2) { + else if (inbuf->type==CB_VEC2) { + for (; x>0; x--, outrf+= 3, inrf+= 2) { outrf[0]= inrf[0]; outrf[1]= inrf[1]; outrf[2]= 0.0f; } } - else if(inbuf->type==CB_RGBA) { - for(; x>0; x--, outrf+= 3, inrf+= 4) { + else if (inbuf->type==CB_RGBA) { + for (; x>0; x--, outrf+= 3, inrf+= 4) { outrf[0]= inrf[0]; outrf[1]= inrf[1]; outrf[2]= inrf[2]; } } } - else if(type==CB_RGBA) { - if(inbuf->type==CB_VAL) { - for(; x>0; x--, outrf+= 4, inrf+= 1) { + else if (type==CB_RGBA) { + if (inbuf->type==CB_VAL) { + for (; x>0; x--, outrf+= 4, inrf+= 1) { outrf[0]= inrf[0]; outrf[1]= inrf[0]; outrf[2]= inrf[0]; outrf[3]= 1.0f; } } - else if(inbuf->type==CB_VEC2) { - for(; x>0; x--, outrf+= 4, inrf+= 2) { + else if (inbuf->type==CB_VEC2) { + for (; x>0; x--, outrf+= 4, inrf+= 2) { outrf[0]= inrf[0]; outrf[1]= inrf[1]; outrf[2]= 0.0f; outrf[3]= 1.0f; } } - else if(inbuf->type==CB_VEC3) { - for(; x>0; x--, outrf+= 4, inrf+= 3) { + else if (inbuf->type==CB_VEC3) { + for (; x>0; x--, outrf+= 4, inrf+= 3) { outrf[0]= inrf[0]; outrf[1]= inrf[1]; outrf[2]= inrf[2]; @@ -378,8 +378,8 @@ CompBuf *typecheck_compbuf(CompBuf *inbuf, int type) float *compbuf_get_pixel(CompBuf *cbuf, float *defcol, float *use, int x, int y, int xrad, int yrad) { - if(cbuf) { - if(cbuf->rect_procedural) { + if (cbuf) { + if (cbuf->rect_procedural) { cbuf->rect_procedural(cbuf, use, (float)x/(float)xrad, (float)y/(float)yrad); return use; } @@ -390,8 +390,8 @@ float *compbuf_get_pixel(CompBuf *cbuf, float *defcol, float *use, int x, int y, x-= cbuf->xof; y-= cbuf->yof; - if(y<-cbuf->yrad || y>= -cbuf->yrad+cbuf->y) return col; - if(x<-cbuf->xrad || x>= -cbuf->xrad+cbuf->x) return col; + if (y<-cbuf->yrad || y>= -cbuf->yrad+cbuf->y) return col; + if (x<-cbuf->xrad || x>= -cbuf->xrad+cbuf->x) return col; return cbuf->rect + cbuf->type*( (cbuf->yrad+y)*cbuf->x + (cbuf->xrad+x) ); } @@ -407,7 +407,7 @@ static CompBuf *composit_check_compbuf(CompBuf *cbuf, int type, CompBuf *outbuf) CompBuf *dbuf= typecheck_compbuf(cbuf, type); /* if same as output and translated, duplicate so pixels don't interfere */ - if(dbuf == outbuf && !dbuf->rect_procedural && (dbuf->xof || dbuf->yof)) + if (dbuf == outbuf && !dbuf->rect_procedural && (dbuf->xof || dbuf->yof)) dbuf= dupalloc_compbuf(dbuf); return dbuf; @@ -428,14 +428,14 @@ void composit1_pixel_processor(bNode *node, CompBuf *out, CompBuf *src_buf, floa xrad= out->xrad; yrad= out->yrad; - for(y= -yrad; y<-yrad+out->y; y++) { - for(x= -xrad; x<-xrad+out->x; x++, outfp+=out->type) { + for (y= -yrad; y<-yrad+out->y; y++) { + for (x= -xrad; x<-xrad+out->x; x++, outfp+=out->type) { srcfp= compbuf_get_pixel(src_use, src_col, color, x, y, xrad, yrad); func(node, outfp, srcfp); } } - if(src_use!=src_buf) + if (src_use!=src_buf) free_compbuf(src_use); } @@ -455,17 +455,17 @@ void composit2_pixel_processor(bNode *node, CompBuf *out, CompBuf *src_buf, floa xrad= out->xrad; yrad= out->yrad; - for(y= -yrad; y<-yrad+out->y; y++) { - for(x= -xrad; x<-xrad+out->x; x++, outfp+=out->type) { + for (y= -yrad; y<-yrad+out->y; y++) { + for (x= -xrad; x<-xrad+out->x; x++, outfp+=out->type) { srcfp= compbuf_get_pixel(src_use, src_col, color, x, y, xrad, yrad); facfp= compbuf_get_pixel(fac_use, fac, color, x, y, xrad, yrad); func(node, outfp, srcfp, facfp); } } - if(src_use!=src_buf) + if (src_use!=src_buf) free_compbuf(src_use); - if(fac_use!=fac_buf) + if (fac_use!=fac_buf) free_compbuf(fac_use); } @@ -486,8 +486,8 @@ void composit3_pixel_processor(bNode *node, CompBuf *out, CompBuf *src1_buf, flo xrad= out->xrad; yrad= out->yrad; - for(y= -yrad; y<-yrad+out->y; y++) { - for(x= -xrad; x<-xrad+out->x; x++, outfp+=out->type) { + for (y= -yrad; y<-yrad+out->y; y++) { + for (x= -xrad; x<-xrad+out->x; x++, outfp+=out->type) { src1fp= compbuf_get_pixel(src1_use, src1_col, color, x, y, xrad, yrad); src2fp= compbuf_get_pixel(src2_use, src2_col, color, x, y, xrad, yrad); facfp= compbuf_get_pixel(fac_use, fac, color, x, y, xrad, yrad); @@ -496,11 +496,11 @@ void composit3_pixel_processor(bNode *node, CompBuf *out, CompBuf *src1_buf, flo } } - if(src1_use!=src1_buf) + if (src1_use!=src1_buf) free_compbuf(src1_use); - if(src2_use!=src2_buf) + if (src2_use!=src2_buf) free_compbuf(src2_use); - if(fac_use!=fac_buf) + if (fac_use!=fac_buf) free_compbuf(fac_use); } @@ -523,8 +523,8 @@ void composit4_pixel_processor(bNode *node, CompBuf *out, CompBuf *src1_buf, flo xrad= out->xrad; yrad= out->yrad; - for(y= -yrad; y<-yrad+out->y; y++) { - for(x= -xrad; x<-xrad+out->x; x++, outfp+=out->type) { + for (y= -yrad; y<-yrad+out->y; y++) { + for (x= -xrad; x<-xrad+out->x; x++, outfp+=out->type) { src1fp= compbuf_get_pixel(src1_use, src1_col, color, x, y, xrad, yrad); src2fp= compbuf_get_pixel(src2_use, src2_col, color, x, y, xrad, yrad); fac1fp= compbuf_get_pixel(fac1_use, fac1, color, x, y, xrad, yrad); @@ -534,13 +534,13 @@ void composit4_pixel_processor(bNode *node, CompBuf *out, CompBuf *src1_buf, flo } } - if(src1_use!=src1_buf) + if (src1_use!=src1_buf) free_compbuf(src1_use); - if(src2_use!=src2_buf) + if (src2_use!=src2_buf) free_compbuf(src2_use); - if(fac1_use!=fac1_buf) + if (fac1_use!=fac1_buf) free_compbuf(fac1_use); - if(fac2_use!=fac2_buf) + if (fac2_use!=fac2_buf) free_compbuf(fac2_use); } @@ -562,7 +562,7 @@ CompBuf *valbuf_from_rgbabuf(CompBuf *cbuf, int channel) rectf= cbuf->rect + channel; - for(tot= cbuf->x*cbuf->y; tot>0; tot--, valf++, rectf+=4) + for (tot= cbuf->x*cbuf->y; tot>0; tot--, valf++, rectf+=4) *valf= *rectf; return valbuf; @@ -580,8 +580,8 @@ static CompBuf *generate_procedural_preview(CompBuf *cbuf, int newx, int newy) xrad= outbuf->xrad; yrad= outbuf->yrad; - for(y= -yrad; y<-yrad+outbuf->y; y++) - for(x= -xrad; x<-xrad+outbuf->x; x++, outfp+=outbuf->type) + for (y= -yrad; y<-yrad+outbuf->y; y++) + for (x= -xrad; x<-xrad+outbuf->x; x++, outfp+=outbuf->type) cbuf->rect_procedural(cbuf, outfp, (float)x/(float)xrad, (float)y/(float)yrad); return outbuf; @@ -597,14 +597,14 @@ void generate_preview(void *data, bNode *node, CompBuf *stackbuf) int dither= 0; unsigned char *rect; - if(preview && stackbuf) { + if (preview && stackbuf) { CompBuf *cbuf, *stackbuf_use; - if(stackbuf->rect==NULL && stackbuf->rect_procedural==NULL) return; + if (stackbuf->rect==NULL && stackbuf->rect_procedural==NULL) return; stackbuf_use= typecheck_compbuf(stackbuf, CB_RGBA); - if(stackbuf->x > stackbuf->y) { + if (stackbuf->x > stackbuf->y) { xsize= 140; ysize= (140*stackbuf->y)/stackbuf->x; } @@ -613,7 +613,7 @@ void generate_preview(void *data, bNode *node, CompBuf *stackbuf) xsize= (140*stackbuf->x)/stackbuf->y; } - if(stackbuf_use->rect_procedural) + if (stackbuf_use->rect_procedural) cbuf= generate_procedural_preview(stackbuf_use, xsize, ysize); else cbuf= scalefast_compbuf(stackbuf_use, xsize, ysize); @@ -626,12 +626,12 @@ void generate_preview(void *data, bNode *node, CompBuf *stackbuf) xsize, ysize, xsize, xsize); free_compbuf(cbuf); - if(stackbuf_use!=stackbuf) + if (stackbuf_use!=stackbuf) free_compbuf(stackbuf_use); BLI_lock_thread(LOCK_PREVIEW); - if(preview->rect) + if (preview->rect) MEM_freeN(preview->rect); preview->xsize= xsize; preview->ysize= ysize; @@ -705,21 +705,21 @@ void gamma_correct_compbuf(CompBuf *img, int inversed) float *drect; int x; - if(img->type!=CB_RGBA) return; + if (img->type!=CB_RGBA) return; drect= img->rect; - if(inversed) { - for(x=img->x*img->y; x>0; x--, drect+=4) { - if(drect[0]>0.0f) drect[0]= sqrt(drect[0]); else drect[0]= 0.0f; - if(drect[1]>0.0f) drect[1]= sqrt(drect[1]); else drect[1]= 0.0f; - if(drect[2]>0.0f) drect[2]= sqrt(drect[2]); else drect[2]= 0.0f; + if (inversed) { + for (x=img->x*img->y; x>0; x--, drect+=4) { + if (drect[0]>0.0f) drect[0]= sqrt(drect[0]); else drect[0]= 0.0f; + if (drect[1]>0.0f) drect[1]= sqrt(drect[1]); else drect[1]= 0.0f; + if (drect[2]>0.0f) drect[2]= sqrt(drect[2]); else drect[2]= 0.0f; } } else { - for(x=img->x*img->y; x>0; x--, drect+=4) { - if(drect[0]>0.0f) drect[0]*= drect[0]; else drect[0]= 0.0f; - if(drect[1]>0.0f) drect[1]*= drect[1]; else drect[1]= 0.0f; - if(drect[2]>0.0f) drect[2]*= drect[2]; else drect[2]= 0.0f; + for (x=img->x*img->y; x>0; x--, drect+=4) { + if (drect[0]>0.0f) drect[0]*= drect[0]; else drect[0]= 0.0f; + if (drect[1]>0.0f) drect[1]*= drect[1]; else drect[1]= 0.0f; + if (drect[2]>0.0f) drect[2]*= drect[2]; else drect[2]= 0.0f; } } } @@ -729,12 +729,12 @@ void premul_compbuf(CompBuf *img, int inversed) float *drect; int x; - if(img->type!=CB_RGBA) return; + if (img->type!=CB_RGBA) return; drect= img->rect; - if(inversed) { - for(x=img->x*img->y; x>0; x--, drect+=4) { - if(fabsf(drect[3]) < 1e-5f) { + if (inversed) { + for (x=img->x*img->y; x>0; x--, drect+=4) { + if (fabsf(drect[3]) < 1e-5f) { drect[0]= 0.0f; drect[1]= 0.0f; drect[2]= 0.0f; @@ -747,7 +747,7 @@ void premul_compbuf(CompBuf *img, int inversed) } } else { - for(x=img->x*img->y; x>0; x--, drect+=4) { + for (x=img->x*img->y; x>0; x--, drect+=4) { drect[0] *= drect[3]; drect[1] *= drect[3]; drect[2] *= drect[3]; @@ -1104,11 +1104,11 @@ void convolve(CompBuf* dst, CompBuf* in1, CompBuf* in2) // sets fcol to pixelcolor at (x, y) void qd_getPixel(CompBuf* src, int x, int y, float* col) { - if(src->rect_procedural) { + if (src->rect_procedural) { float bc[4]; src->rect_procedural(src, bc, (float)x/(float)src->xrad, (float)y/(float)src->yrad); - switch(src->type){ + switch(src->type) { /* these fallthrough to get all the channels */ case CB_RGBA: col[3]=bc[3]; case CB_VEC3: col[2]=bc[2]; @@ -1118,7 +1118,7 @@ void qd_getPixel(CompBuf* src, int x, int y, float* col) } else if ((x >= 0) && (x < src->x) && (y >= 0) && (y < src->y)) { float* bc = &src->rect[(x + y*src->x)*src->type]; - switch(src->type){ + switch(src->type) { /* these fallthrough to get all the channels */ case CB_RGBA: col[3]=bc[3]; case CB_VEC3: col[2]=bc[2]; @@ -1127,7 +1127,7 @@ void qd_getPixel(CompBuf* src, int x, int y, float* col) } } else { - switch(src->type){ + switch(src->type) { /* these fallthrough to get all the channels */ case CB_RGBA: col[3]=0.0; case CB_VEC3: col[2]=0.0; @@ -1142,7 +1142,7 @@ void qd_setPixel(CompBuf* src, int x, int y, float* col) { if ((x >= 0) && (x < src->x) && (y >= 0) && (y < src->y)) { float* bc = &src->rect[(x + y*src->x)*src->type]; - switch(src->type){ + switch(src->type) { /* these fallthrough to get all the channels */ case CB_RGBA: bc[3]=col[3]; case CB_VEC3: bc[2]=col[2]; diff --git a/source/blender/nodes/composite/nodes/node_composite_alphaOver.c b/source/blender/nodes/composite/nodes/node_composite_alphaOver.c index 3a783f0f32d..5a716e18660 100644 --- a/source/blender/nodes/composite/nodes/node_composite_alphaOver.c +++ b/source/blender/nodes/composite/nodes/node_composite_alphaOver.c @@ -48,10 +48,10 @@ static void do_alphaover_premul(bNode *UNUSED(node), float *out, float *src, flo { /* Zero alpha values should still permit an add of RGB data */ - if(over[3]<0.0f) { + if (over[3]<0.0f) { copy_v4_v4(out, src); } - else if(fac[0]==1.0f && over[3]>=1.0f) { + else if (fac[0]==1.0f && over[3]>=1.0f) { copy_v4_v4(out, over); } else { @@ -68,10 +68,10 @@ static void do_alphaover_premul(bNode *UNUSED(node), float *out, float *src, flo static void do_alphaover_key(bNode *UNUSED(node), float *out, float *src, float *over, float *fac) { - if(over[3]<=0.0f) { + if (over[3]<=0.0f) { copy_v4_v4(out, src); } - else if(fac[0]==1.0f && over[3]>=1.0f) { + else if (fac[0]==1.0f && over[3]>=1.0f) { copy_v4_v4(out, over); } else { @@ -89,10 +89,10 @@ static void do_alphaover_key(bNode *UNUSED(node), float *out, float *src, float static void do_alphaover_mixed(bNode *node, float *out, float *src, float *over, float *fac) { - if(over[3]<=0.0f) { + if (over[3]<=0.0f) { copy_v4_v4(out, src); } - else if(fac[0]==1.0f && over[3]>=1.0f) { + else if (fac[0]==1.0f && over[3]>=1.0f) { copy_v4_v4(out, over); } else { @@ -115,11 +115,11 @@ static void node_composit_exec_alphaover(void *UNUSED(data), bNode *node, bNodeS { /* stack order in: col col */ /* stack order out: col */ - if(out[0]->hasoutput==0) + if (out[0]->hasoutput==0) return; /* input no image? then only color operation */ - if(in[1]->data==NULL && in[2]->data==NULL) { + if (in[1]->data==NULL && in[2]->data==NULL) { do_alphaover_premul(node, out[0]->vec, in[1]->vec, in[2]->vec, in[0]->vec); } else { @@ -128,9 +128,9 @@ static void node_composit_exec_alphaover(void *UNUSED(data), bNode *node, bNodeS CompBuf *stackbuf= alloc_compbuf(cbuf->x, cbuf->y, CB_RGBA, 1); /* allocs */ NodeTwoFloats *ntf= node->storage; - if(ntf->x != 0.0f) + if (ntf->x != 0.0f) composit3_pixel_processor(node, stackbuf, in[1]->data, in[1]->vec, in[2]->data, in[2]->vec, in[0]->data, in[0]->vec, do_alphaover_mixed, CB_RGBA, CB_RGBA, CB_VAL); - else if(node->custom1) + else if (node->custom1) composit3_pixel_processor(node, stackbuf, in[1]->data, in[1]->vec, in[2]->data, in[2]->vec, in[0]->data, in[0]->vec, do_alphaover_key, CB_RGBA, CB_RGBA, CB_VAL); else composit3_pixel_processor(node, stackbuf, in[1]->data, in[1]->vec, in[2]->data, in[2]->vec, in[0]->data, in[0]->vec, do_alphaover_premul, CB_RGBA, CB_RGBA, CB_VAL); diff --git a/source/blender/nodes/composite/nodes/node_composite_bilateralblur.c b/source/blender/nodes/composite/nodes/node_composite_bilateralblur.c index fe359372270..8faa060244a 100644 --- a/source/blender/nodes/composite/nodes/node_composite_bilateralblur.c +++ b/source/blender/nodes/composite/nodes/node_composite_bilateralblur.c @@ -102,10 +102,10 @@ static void node_composit_exec_bilateralblur(void *UNUSED(data), bNode *node, bN int deltas[8]; short found_determinator= 0; - if(img == NULL || out[0]->hasoutput == 0) + if (img == NULL || out[0]->hasoutput == 0) return; - if(img->type != CB_RGBA) { + if (img->type != CB_RGBA) { img= typecheck_compbuf(in[0]->data, CB_RGBA); } @@ -114,9 +114,9 @@ static void node_composit_exec_bilateralblur(void *UNUSED(data), bNode *node, bN pix= img->type; step= pix * imgx; - if(refimg) { - if(refimg->x == imgx && refimg->y == imgy) { - if(ELEM3(refimg->type, CB_VAL, CB_VEC2, CB_VEC3)) { + if (refimg) { + if (refimg->x == imgx && refimg->y == imgy) { + if (ELEM3(refimg->type, CB_VAL, CB_VEC2, CB_VEC3)) { refimg= typecheck_compbuf(in[1]->data, CB_RGBA); found_determinator= 1; } @@ -147,23 +147,23 @@ static void node_composit_exec_bilateralblur(void *UNUSED(data), bNode *node, bN weight_tab[1] = weight_tab[3] = weight_tab[5] = weight_tab[7] = i2sigma_space * 2; /* iterations */ - for(i= 0; i < nbbd->iter; i++) { + for (i= 0; i < nbbd->iter; i++) { src= source->rect; ref= refimg->rect; dest= new->rect; /*goes through image, there are more loops for 1st/last line and all other lines*/ /*kernel element accumulates surrounding colors, which are then written with the update_output function*/ - for(x= 0; x < imgx; x++, src+= pix, ref+= pix) { + for (x= 0; x < imgx; x++, src+= pix, ref+= pix) { INIT_C3; KERNEL_ELEMENT_C3(6); - if(x > 0) { + if (x > 0) { KERNEL_ELEMENT_C3(5); KERNEL_ELEMENT_C3(4); } - if(x < imgx - 1) { + if (x < imgx - 1) { KERNEL_ELEMENT_C3(7); KERNEL_ELEMENT_C3(0); } @@ -173,7 +173,7 @@ static void node_composit_exec_bilateralblur(void *UNUSED(data), bNode *node, bN dest+= step; - for(y= 1; y < imgy - 1; y++, dest+= step, src+= pix, ref+= pix) { + for (y= 1; y < imgy - 1; y++, dest+= step, src+= pix, ref+= pix) { x= 0; INIT_C3; @@ -189,7 +189,7 @@ static void node_composit_exec_bilateralblur(void *UNUSED(data), bNode *node, bN src+= pix; ref+= pix; - for(x= 1; x < imgx - 1; x++, src+= pix, ref+= pix) { + for (x= 1; x < imgx - 1; x++, src+= pix, ref+= pix) { INIT_C3; KERNEL_ELEMENT_C3(0); @@ -215,16 +215,16 @@ static void node_composit_exec_bilateralblur(void *UNUSED(data), bNode *node, bN UPDATE_OUTPUT_C3; } - for(x= 0; x < imgx; x++, src+= pix, ref+= pix) { + for (x= 0; x < imgx; x++, src+= pix, ref+= pix) { INIT_C3; KERNEL_ELEMENT_C3(2); - if(x > 0) { + if (x > 0) { KERNEL_ELEMENT_C3(3); KERNEL_ELEMENT_C3(4); } - if(x < imgx - 1) { + if (x < imgx - 1) { KERNEL_ELEMENT_C3(1); KERNEL_ELEMENT_C3(0); } @@ -232,16 +232,16 @@ static void node_composit_exec_bilateralblur(void *UNUSED(data), bNode *node, bN UPDATE_OUTPUT_C3; } - if(node->exec & NODE_BREAK) break; + if (node->exec & NODE_BREAK) break; SWAP(CompBuf, *source, *new); } - if(img != in[0]->data) + if (img != in[0]->data) free_compbuf(img); - if(found_determinator == 1) { - if(refimg != in[1]->data) + if (found_determinator == 1) { + if (refimg != in[1]->data) free_compbuf(refimg); } diff --git a/source/blender/nodes/composite/nodes/node_composite_blur.c b/source/blender/nodes/composite/nodes/node_composite_blur.c index fad80723ca3..0e09f2d22ee 100644 --- a/source/blender/nodes/composite/nodes/node_composite_blur.c +++ b/source/blender/nodes/composite/nodes/node_composite_blur.c @@ -61,7 +61,7 @@ static float *make_gausstab(int filtertype, int rad) } sum= 1.0f/sum; - for(i=0; i<n; i++) + for (i=0; i<n; i++) gausstab[i]*= sum; return gausstab; @@ -101,14 +101,14 @@ static void blur_single_image(bNode *node, CompBuf *new, CompBuf *img, float sca work= alloc_compbuf(imgx, imgy, img->type, 1); /* allocs */ /* horizontal */ - if(nbd->sizex == 0) { + if (nbd->sizex == 0) { memcpy(work->rect, img->rect, sizeof(float) * img->type * imgx * imgy); } else { rad = scale*(float)nbd->sizex; - if(rad>imgx/2) + if (rad>imgx/2) rad= imgx/2; - else if(rad<1) + else if (rad<1) rad= 1; gausstab= make_gausstab(nbd->filtertype, rad); @@ -130,7 +130,7 @@ static void blur_single_image(bNode *node, CompBuf *new, CompBuf *img, float sca val= gausstabcent[i]; sum+= val; rval += val * (*src++); - if(pix==4) { + if (pix==4) { gval += val * (*src++); bval += val * (*src++); aval += val * (*src++); @@ -138,13 +138,13 @@ static void blur_single_image(bNode *node, CompBuf *new, CompBuf *img, float sca } sum= 1.0f/sum; *dest++ = rval*sum; - if(pix==4) { + if (pix==4) { *dest++ = gval*sum; *dest++ = bval*sum; *dest++ = aval*sum; } } - if(node->exec & NODE_BREAK) + if (node->exec & NODE_BREAK) break; } @@ -152,14 +152,14 @@ static void blur_single_image(bNode *node, CompBuf *new, CompBuf *img, float sca MEM_freeN(gausstab); } - if(nbd->sizey == 0) { + if (nbd->sizey == 0) { memcpy(new->rect, work->rect, sizeof(float) * img->type * imgx * imgy); } else { rad = scale*(float)nbd->sizey; - if(rad>imgy/2) + if (rad>imgy/2) rad= imgy/2; - else if(rad<1) + else if (rad<1) rad= 1; gausstab= make_gausstab(nbd->filtertype, rad); @@ -182,7 +182,7 @@ static void blur_single_image(bNode *node, CompBuf *new, CompBuf *img, float sca val= gausstabcent[i]; sum+= val; rval += val * src[0]; - if(pix==4) { + if (pix==4) { gval += val * src[1]; bval += val * src[2]; aval += val * src[3]; @@ -191,14 +191,14 @@ static void blur_single_image(bNode *node, CompBuf *new, CompBuf *img, float sca } sum= 1.0f/sum; dest[0] = rval*sum; - if(pix==4) { + if (pix==4) { dest[1] = gval*sum; dest[2] = bval*sum; dest[3] = aval*sum; } dest+= bigstep; } - if(node->exec & NODE_BREAK) + if (node->exec & NODE_BREAK) break; } MEM_freeN(gausstab); @@ -225,21 +225,21 @@ static void bloom_with_reference(CompBuf *new, CompBuf *img, CompBuf *UNUSED(ref /* horizontal */ radx = (float)nbd->sizex; - if(radx>imgx/2) + if (radx>imgx/2) radx= imgx/2; - else if(radx<1) + else if (radx<1) radx= 1; /* vertical */ rady = (float)nbd->sizey; - if(rady>imgy/2) + if (rady>imgy/2) rady= imgy/2; - else if(rady<1) + else if (rady<1) rady= 1; x= MAX2(radx, rady); maintabs= MEM_mallocN(x*sizeof(void *), "gauss array"); - for(i= 0; i<x; i++) + for (i= 0; i<x; i++) maintabs[i]= make_bloomtab(i+1); /* vars to store before we go */ @@ -258,12 +258,12 @@ static void bloom_with_reference(CompBuf *new, CompBuf *img, CompBuf *UNUSED(ref int refradx= (int)(radxf*0.3f*src[3]*(src[0]+src[1]+src[2])); int refrady= (int)(radyf*0.3f*src[3]*(src[0]+src[1]+src[2])); - if(refradx>radx) refradx= radx; - else if(refradx<1) refradx= 1; - if(refrady>rady) refrady= rady; - else if(refrady<1) refrady= 1; + if (refradx>radx) refradx= radx; + else if (refradx<1) refradx= 1; + if (refrady>rady) refrady= rady; + else if (refrady<1) refrady= 1; - if(refradx==1 && refrady==1) { + if (refradx==1 && refrady==1) { wb= wbuf->rect + ( y*imgx + x); dest= new->rect + 4*( y*imgx + x); wb[0]+= 1.0f; @@ -319,7 +319,7 @@ static void bloom_with_reference(CompBuf *new, CompBuf *img, CompBuf *UNUSED(ref free_compbuf(wbuf); x= MAX2(radx, rady); - for(i= 0; i<x; i++) + for (i= 0; i<x; i++) MEM_freeN(maintabs[i]); MEM_freeN(maintabs); @@ -331,9 +331,9 @@ static float hexagon_filter(float fi, float fj) fi= fabs(fi); fj= fabs(fj); - if(fj>0.33f) { + if (fj>0.33f) { fj= (fj-0.33f)/0.66f; - if(fi+fj>1.0f) + if (fi+fj>1.0f) return 0.0f; else return 1.0f; @@ -357,16 +357,16 @@ static void bokeh_single_image(bNode *node, CompBuf *new, CompBuf *img, float fa /* horizontal */ radxf = fac*(float)nbd->sizex; - if(radxf>imgx/2.0f) + if (radxf>imgx/2.0f) radxf= imgx/2.0f; - else if(radxf<1.0f) + else if (radxf<1.0f) radxf= 1.0f; /* vertical */ radyf = fac*(float)nbd->sizey; - if(radyf>imgy/2.0f) + if (radyf>imgy/2.0f) radyf= imgy/2.0f; - else if(radyf<1.0f) + else if (radyf<1.0f) radyf= 1.0f; radx= ceil(radxf); @@ -378,8 +378,8 @@ static void bokeh_single_image(bNode *node, CompBuf *new, CompBuf *img, float fa gausstab= MEM_mallocN(sizeof(float)*n, "filter tab"); dgauss= gausstab; val= 0.0f; - for(j=-rady; j<=rady; j++) { - for(i=-radx; i<=radx; i++, dgauss++) { + for (j=-rady; j<=rady; j++) { + for (i=-radx; i<=radx; i++, dgauss++) { float fj= (float)j/radyf; float fi= (float)i/radxf; float dist= sqrt(fj*fj + fi*fi); @@ -391,17 +391,17 @@ static void bokeh_single_image(bNode *node, CompBuf *new, CompBuf *img, float fa } } - if(val!=0.0f) { + if (val!=0.0f) { val= 1.0f/val; - for(j= n -1; j>=0; j--) + for (j= n -1; j>=0; j--) gausstab[j]*= val; } else gausstab[4]= 1.0f; for (y = -rady+1; y < imgy+rady-1; y++) { - if(y<=0) srcd= img->rect; - else if(y<imgy) srcd+= pix*imgx; + if (y<=0) srcd= img->rect; + else if (y<imgy) srcd+= pix*imgx; else srcd= img->rect + pix*(imgy-1)*imgx; for (x = -radx+1; x < imgx+radx-1 ; x++) { @@ -413,8 +413,8 @@ static void bokeh_single_image(bNode *node, CompBuf *new, CompBuf *img, float fa float *destd= new->rect + pix*( (y + minyr)*imgx + x + minxr); float *dgausd= gausstab + (minyr+rady)*(2*radx+1) + minxr+radx; - if(x<=0) src= srcd; - else if(x<imgx) src+= pix; + if (x<=0) src= srcd; + else if (x<imgx) src+= pix; else src= srcd + pix*(imgx-1); for (i= minyr; i <=maxyr; i++, destd+= pix*imgx, dgausd+= 2*radx + 1) { @@ -422,9 +422,9 @@ static void bokeh_single_image(bNode *node, CompBuf *new, CompBuf *img, float fa dgauss= dgausd; for (j= minxr; j <=maxxr; j++, dest+=pix, dgauss++) { val= *dgauss; - if(val!=0.0f) { + if (val!=0.0f) { dest[0] += val * src[0]; - if(pix>1) { + if (pix>1) { dest[1] += val * src[1]; dest[2] += val * src[2]; dest[3] += val * src[3]; @@ -433,7 +433,7 @@ static void bokeh_single_image(bNode *node, CompBuf *new, CompBuf *img, float fa } } } - if(node->exec & NODE_BREAK) + if (node->exec & NODE_BREAK) break; } @@ -459,7 +459,7 @@ static void blur_with_reference(bNode *node, CompBuf *new, CompBuf *img, CompBuf float proccol[4]; /* local color if compbuf is procedural */ int refradx, refrady; - if(ref->x!=img->x || ref->y!=img->y) + if (ref->x!=img->x || ref->y!=img->y) return; ref_use= typecheck_compbuf(ref, CB_VAL); @@ -470,9 +470,9 @@ static void blur_with_reference(bNode *node, CompBuf *new, CompBuf *img, CompBuf blurbuf->yof= ref_use->yof; blurd= blurbuf->rect; refd= ref_use->rect; - for(x= imgx*imgy; x>0; x--, refd++, blurd++) { - if(refd[0]<0.0f) blurd[0]= 0.0f; - else if(refd[0]>1.0f) blurd[0]= 1.0f; + for (x= imgx*imgy; x>0; x--, refd++, blurd++) { + if (refd[0]<0.0f) blurd[0]= 0.0f; + else if (refd[0]>1.0f) blurd[0]= 1.0f; else blurd[0]= refd[0]; } @@ -480,21 +480,21 @@ static void blur_with_reference(bNode *node, CompBuf *new, CompBuf *img, CompBuf /* horizontal */ radx = (float)nbd->sizex; - if(radx>imgx/2) + if (radx>imgx/2) radx= imgx/2; - else if(radx<1) + else if (radx<1) radx= 1; /* vertical */ rady = (float)nbd->sizey; - if(rady>imgy/2) + if (rady>imgy/2) rady= imgy/2; - else if(rady<1) + else if (rady<1) rady= 1; x= MAX2(radx, rady); maintabs= MEM_mallocN(x*sizeof(void *), "gauss array"); - for(i= 0; i<x; i++) + for (i= 0; i<x; i++) maintabs[i]= make_gausstab(nbd->filtertype, i+1); dest= new->rect; @@ -507,14 +507,14 @@ static void blur_with_reference(bNode *node, CompBuf *new, CompBuf *img, CompBuf refradx= (int)(refd[0]*radxf); refrady= (int)(refd[0]*radyf); - if(refradx>radx) refradx= radx; - else if(refradx<1) refradx= 1; - if(refrady>rady) refrady= rady; - else if(refrady<1) refrady= 1; + if (refradx>radx) refradx= radx; + else if (refradx<1) refradx= 1; + if (refrady>rady) refrady= rady; + else if (refrady<1) refrady= 1; - if(refradx==1 && refrady==1) { + if (refradx==1 && refrady==1) { src= img->rect + pix*( y*imgx + x); - if(pix==1) + if (pix==1) dest[0]= src[0]; else copy_v4_v4(dest, src); @@ -541,7 +541,7 @@ static void blur_with_reference(bNode *node, CompBuf *new, CompBuf *img, CompBuf val= gausstabcenty[i]*gausstabcentx[j]; sum+= val; rval += val * src[0]; - if(pix>1) { + if (pix>1) { gval += val * src[1]; bval += val * src[2]; aval += val * src[3]; @@ -550,25 +550,25 @@ static void blur_with_reference(bNode *node, CompBuf *new, CompBuf *img, CompBuf } sum= 1.0f/sum; dest[0] = rval*sum; - if(pix>1) { + if (pix>1) { dest[1] = gval*sum; dest[2] = bval*sum; dest[3] = aval*sum; } } } - if(node->exec & NODE_BREAK) + if (node->exec & NODE_BREAK) break; } free_compbuf(blurbuf); x= MAX2(radx, rady); - for(i= 0; i<x; i++) + for (i= 0; i<x; i++) MEM_freeN(maintabs[i]); MEM_freeN(maintabs); - if(ref_use!=ref) + if (ref_use!=ref) free_compbuf(ref_use); } @@ -577,15 +577,15 @@ static void node_composit_exec_blur(void *data, bNode *node, bNodeStack **in, bN CompBuf *new, *img= in[0]->data; NodeBlurData *nbd= node->storage; - if(img==NULL) return; + if (img==NULL) return; /* store image in size that is needed for absolute/relative conversions on ui level */ nbd->image_in_width= img->x; nbd->image_in_height= img->y; - if(out[0]->hasoutput==0) return; + if (out[0]->hasoutput==0) return; - if(nbd->relative) { + if (nbd->relative) { if (nbd->aspect==CMP_NODE_BLUR_ASPECT_NONE) { nbd->sizex= (int)(nbd->percentx*0.01f*nbd->image_in_width); nbd->sizey= (int)(nbd->percenty*0.01f*nbd->image_in_height); @@ -635,14 +635,15 @@ static void node_composit_exec_blur(void *data, bNode *node, bNodeStack **in, bN } out[0]->data = new; - } else { + } + else { /* All non fast gauss blur methods */ - if(img->type==CB_VEC2 || img->type==CB_VEC3) { + if (img->type==CB_VEC2 || img->type==CB_VEC3) { img= typecheck_compbuf(in[0]->data, CB_RGBA); } /* if fac input, we do it different */ - if(in[1]->data) { + if (in[1]->data) { CompBuf *gammabuf; /* make output size of input image */ @@ -652,7 +653,7 @@ static void node_composit_exec_blur(void *data, bNode *node, bNodeStack **in, bN new->xof = img->xof; new->yof = img->yof; - if(nbd->gamma) { + if (nbd->gamma) { gammabuf= dupalloc_compbuf(img); gamma_correct_compbuf(gammabuf, 0); } @@ -660,11 +661,11 @@ static void node_composit_exec_blur(void *data, bNode *node, bNodeStack **in, bN blur_with_reference(node, new, gammabuf, in[1]->data); - if(nbd->gamma) { + if (nbd->gamma) { gamma_correct_compbuf(new, 1); free_compbuf(gammabuf); } - if(node->exec & NODE_BREAK) { + if (node->exec & NODE_BREAK) { free_compbuf(new); new= NULL; } @@ -672,7 +673,7 @@ static void node_composit_exec_blur(void *data, bNode *node, bNodeStack **in, bN } else { - if(in[1]->vec[0]<=0.001f) { /* time node inputs can be a tiny value */ + if (in[1]->vec[0]<=0.001f) { /* time node inputs can be a tiny value */ new= pass_on_compbuf(img); } else { @@ -685,31 +686,31 @@ static void node_composit_exec_blur(void *data, bNode *node, bNodeStack **in, bN new->xof = img->xof; new->yof = img->yof; - if(nbd->gamma) { + if (nbd->gamma) { gammabuf= dupalloc_compbuf(img); gamma_correct_compbuf(gammabuf, 0); } else gammabuf= img; - if(nbd->bokeh) + if (nbd->bokeh) bokeh_single_image(node, new, gammabuf, in[1]->vec[0]); - else if(1) + else if (1) blur_single_image(node, new, gammabuf, in[1]->vec[0]); else /* bloom experimental... */ bloom_with_reference(new, gammabuf, NULL, in[1]->vec[0], nbd); - if(nbd->gamma) { + if (nbd->gamma) { gamma_correct_compbuf(new, 1); free_compbuf(gammabuf); } - if(node->exec & NODE_BREAK) { + if (node->exec & NODE_BREAK) { free_compbuf(new); new= NULL; } } out[0]->data= new; } - if(img!=in[0]->data) + if (img!=in[0]->data) free_compbuf(img); } diff --git a/source/blender/nodes/composite/nodes/node_composite_brightness.c b/source/blender/nodes/composite/nodes/node_composite_brightness.c index 83607ac66b3..caae5f313cd 100644 --- a/source/blender/nodes/composite/nodes/node_composite_brightness.c +++ b/source/blender/nodes/composite/nodes/node_composite_brightness.c @@ -70,7 +70,7 @@ static void do_brightnesscontrast(bNode *UNUSED(node), float *out, float *in, fl b = a * (brightness + delta); } - for(c=0; c<3; c++){ + for (c=0; c<3; c++) { i = in[c]; v = a*i + b; out[c] = v; @@ -79,15 +79,15 @@ static void do_brightnesscontrast(bNode *UNUSED(node), float *out, float *in, fl static void node_composit_exec_brightcontrast(void *UNUSED(data), bNode *node, bNodeStack **in, bNodeStack **out) { - if(out[0]->hasoutput==0) + if (out[0]->hasoutput==0) return; - if(in[0]->data) { + if (in[0]->data) { CompBuf *stackbuf, *cbuf= typecheck_compbuf(in[0]->data, CB_RGBA); stackbuf= dupalloc_compbuf(cbuf); composit3_pixel_processor(node, stackbuf, in[0]->data, in[0]->vec, in[1]->data, in[1]->vec, in[2]->data, in[2]->vec, do_brightnesscontrast, CB_RGBA, CB_VAL, CB_VAL); out[0]->data = stackbuf; - if(cbuf != in[0]->data) + if (cbuf != in[0]->data) free_compbuf(cbuf); } } diff --git a/source/blender/nodes/composite/nodes/node_composite_channelMatte.c b/source/blender/nodes/composite/nodes/node_composite_channelMatte.c index 785786dacbe..132b1659fa5 100644 --- a/source/blender/nodes/composite/nodes/node_composite_channelMatte.c +++ b/source/blender/nodes/composite/nodes/node_composite_channelMatte.c @@ -105,10 +105,10 @@ static void do_channel_matte(bNode *node, float *out, float *in) alpha=1-alpha; /* test range*/ - if(alpha>c->t1) { + if (alpha>c->t1) { alpha=in[3]; /*whatever it was prior */ } - else if(alpha<c->t2){ + else if (alpha<c->t2) { alpha=0.0; } else {/*blend */ @@ -130,9 +130,9 @@ static void node_composit_exec_channel_matte(void *data, bNode *node, bNodeStack CompBuf *cbuf; CompBuf *outbuf; - if(in[0]->hasinput==0) return; - if(in[0]->data==NULL) return; - if(out[0]->hasoutput==0 && out[1]->hasoutput==0) return; + if (in[0]->hasinput==0) return; + if (in[0]->data==NULL) return; + if (out[0]->hasoutput==0 && out[1]->hasoutput==0) return; cbuf=typecheck_compbuf(in[0]->data, CB_RGBA); @@ -177,10 +177,10 @@ static void node_composit_exec_channel_matte(void *data, bNode *node, bNodeStack generate_preview(data, node, outbuf); out[0]->data=outbuf; - if(out[1]->hasoutput) + if (out[1]->hasoutput) out[1]->data=valbuf_from_rgbabuf(outbuf, CHAN_A); - if(cbuf!=in[0]->data) + if (cbuf!=in[0]->data) free_compbuf(cbuf); } diff --git a/source/blender/nodes/composite/nodes/node_composite_chromaMatte.c b/source/blender/nodes/composite/nodes/node_composite_chromaMatte.c index b6f490a0320..2df8e1b6139 100644 --- a/source/blender/nodes/composite/nodes/node_composite_chromaMatte.c +++ b/source/blender/nodes/composite/nodes/node_composite_chromaMatte.c @@ -111,14 +111,14 @@ static void do_chroma_key(bNode *node, float *out, float *in) out[1]=in[1]; out[2]=in[2]; - if(kfg>0.0f) { /* found a pixel that is within key color */ + if (kfg>0.0f) { /* found a pixel that is within key color */ alpha=(1.0f-kfg)*(c->fstrength); beta=atan2(z,x); angle2=c->t2; /* t2 is radians. */ /* if beta is within the cutoff angle */ - if(fabsf(beta) < (angle2/2.0f)) { + if (fabsf(beta) < (angle2/2.0f)) { alpha=0.0; } @@ -144,9 +144,9 @@ static void node_composit_exec_chroma_matte(void *data, bNode *node, bNodeStack CompBuf *chromabuf; NodeChroma *c; - if(in[0]->hasinput==0) return; - if(in[0]->data==NULL) return; - if(out[0]->hasoutput==0 && out[1]->hasoutput==0) return; + if (in[0]->hasinput==0) return; + if (in[0]->data==NULL) return; + if (out[0]->hasoutput==0 && out[1]->hasoutput==0) return; cbuf= typecheck_compbuf(in[0]->data, CB_RGBA); @@ -166,12 +166,12 @@ static void node_composit_exec_chroma_matte(void *data, bNode *node, bNodeStack composit1_pixel_processor(node, chromabuf, chromabuf, in[0]->vec, do_ycca_to_rgba_normalized, CB_RGBA); out[0]->data= chromabuf; - if(out[1]->hasoutput) + if (out[1]->hasoutput) out[1]->data= valbuf_from_rgbabuf(chromabuf, CHAN_A); generate_preview(data, node, chromabuf); - if(cbuf!=in[0]->data) + if (cbuf!=in[0]->data) free_compbuf(cbuf); } diff --git a/source/blender/nodes/composite/nodes/node_composite_colorMatte.c b/source/blender/nodes/composite/nodes/node_composite_colorMatte.c index 2d56c9e5973..12b6e802555 100644 --- a/source/blender/nodes/composite/nodes/node_composite_colorMatte.c +++ b/source/blender/nodes/composite/nodes/node_composite_colorMatte.c @@ -54,7 +54,7 @@ static void do_color_key(bNode *node, float *out, float *in) copy_v3_v3(out, in); - if( + if ( /* do hue last because it needs to wrap, and does some more checks */ /* sat */ (fabsf(in[1]-c->key[1]) < c->t2) && @@ -79,9 +79,9 @@ static void node_composit_exec_color_matte(void *data, bNode *node, bNodeStack * CompBuf *colorbuf; NodeChroma *c; - if(in[0]->hasinput==0) return; - if(in[0]->data==NULL) return; - if(out[0]->hasoutput==0 && out[1]->hasoutput==0) return; + if (in[0]->hasinput==0) return; + if (in[0]->data==NULL) return; + if (out[0]->hasoutput==0 && out[1]->hasoutput==0) return; cbuf= typecheck_compbuf(in[0]->data, CB_RGBA); @@ -103,12 +103,12 @@ static void node_composit_exec_color_matte(void *data, bNode *node, bNodeStack * composit1_pixel_processor(node, colorbuf, colorbuf, in[0]->vec, do_hsva_to_rgba, CB_RGBA); out[0]->data= colorbuf; - if(out[1]->hasoutput) + if (out[1]->hasoutput) out[1]->data= valbuf_from_rgbabuf(colorbuf, CHAN_A); generate_preview(data, node, colorbuf); - if(cbuf!=in[0]->data) + if (cbuf!=in[0]->data) free_compbuf(cbuf); } diff --git a/source/blender/nodes/composite/nodes/node_composite_colorSpill.c b/source/blender/nodes/composite/nodes/node_composite_colorSpill.c index af6a295cf7f..026d74aafc4 100644 --- a/source/blender/nodes/composite/nodes/node_composite_colorSpill.c +++ b/source/blender/nodes/composite/nodes/node_composite_colorSpill.c @@ -141,7 +141,7 @@ static void do_apply_spillmap_red(bNode *node, float* out, float *in, float *map { NodeColorspill *ncs; ncs=node->storage; - if(map[0]>0) { + if (map[0]>0) { out[0]=in[0]-(ncs->uspillr*map[0]); out[1]=in[1]+(ncs->uspillg*map[0]); out[2]=in[2]+(ncs->uspillb*map[0]); @@ -157,7 +157,7 @@ static void do_apply_spillmap_green(bNode *node, float* out, float *in, float *m { NodeColorspill *ncs; ncs=node->storage; - if(map[0]>0) { + if (map[0]>0) { out[0]=in[0]+(ncs->uspillr*map[0]); out[1]=in[1]-(ncs->uspillg*map[0]); out[2]=in[2]+(ncs->uspillb*map[0]); @@ -173,7 +173,7 @@ static void do_apply_spillmap_blue(bNode *node, float* out, float *in, float *ma { NodeColorspill *ncs; ncs=node->storage; - if(map[0]>0) { + if (map[0]>0) { out[0]=in[0]+(ncs->uspillr*map[0]); out[1]=in[1]+(ncs->uspillg*map[0]); out[2]=in[2]-(ncs->uspillb*map[0]); @@ -197,9 +197,9 @@ static void node_composit_exec_color_spill(void *UNUSED(data), bNode *node, bNod ncs=node->storage; /* early out for missing connections */ - if(out[0]->hasoutput==0 ) return; - if(in[0]->hasinput==0) return; - if(in[0]->data==NULL) return; + if (out[0]->hasoutput==0 ) return; + if (in[0]->hasinput==0) return; + if (in[0]->data==NULL) return; cbuf=typecheck_compbuf(in[0]->data, CB_RGBA); /* mask= */ /* UNUSED */ typecheck_compbuf(in[1]->data, CB_VAL); @@ -216,7 +216,8 @@ static void node_composit_exec_color_spill(void *UNUSED(data), bNode *node, bNod { if ((in[1]->data==NULL) && (in[1]->vec[0] >= 1.f)) { composit1_pixel_processor(node, spillmap, cbuf, in[0]->vec, do_simple_spillmap_red, CB_RGBA); - } else { + } + else { composit2_pixel_processor(node, spillmap, cbuf, in[0]->vec, in[1]->data, in[1]->vec, do_simple_spillmap_red_fac, CB_RGBA, CB_VAL); } break; @@ -225,13 +226,14 @@ static void node_composit_exec_color_spill(void *UNUSED(data), bNode *node, bNod { if ((in[1]->data==NULL) && (in[1]->vec[0] >= 1.f)) { composit1_pixel_processor(node, spillmap, cbuf, in[0]->vec, do_average_spillmap_red, CB_RGBA); - } else { + } + else { composit2_pixel_processor(node, spillmap, cbuf, in[0]->vec, in[1]->data, in[1]->vec, do_average_spillmap_red_fac, CB_RGBA, CB_VAL); } break; } } - if(ncs->unspill==0) { + if (ncs->unspill==0) { ncs->uspillr=1.0f; ncs->uspillg=0.0f; ncs->uspillb=0.0f; @@ -247,7 +249,8 @@ static void node_composit_exec_color_spill(void *UNUSED(data), bNode *node, bNod { if ((in[1]->data==NULL) && (in[1]->vec[0] >= 1.f)) { composit1_pixel_processor(node, spillmap, cbuf, in[0]->vec, do_simple_spillmap_green, CB_RGBA); - } else { + } + else { composit2_pixel_processor(node, spillmap, cbuf, in[0]->vec, in[1]->data, in[1]->vec, do_simple_spillmap_green_fac, CB_RGBA, CB_VAL); } break; @@ -256,13 +259,14 @@ static void node_composit_exec_color_spill(void *UNUSED(data), bNode *node, bNod { if ((in[1]->data==NULL) && (in[1]->vec[0] >= 1.f)) { composit1_pixel_processor(node, spillmap, cbuf, in[0]->vec, do_average_spillmap_green, CB_RGBA); - } else { + } + else { composit2_pixel_processor(node, spillmap, cbuf, in[0]->vec, in[1]->data, in[1]->vec, do_average_spillmap_green_fac, CB_RGBA, CB_VAL); } break; } } - if(ncs->unspill==0) { + if (ncs->unspill==0) { ncs->uspillr=0.0f; ncs->uspillg=1.0f; ncs->uspillb=0.0f; @@ -278,7 +282,8 @@ static void node_composit_exec_color_spill(void *UNUSED(data), bNode *node, bNod { if ((in[1]->data==NULL) && (in[1]->vec[0] >= 1.f)) { composit1_pixel_processor(node, spillmap, cbuf, in[0]->vec, do_simple_spillmap_blue, CB_RGBA); - } else { + } + else { composit2_pixel_processor(node, spillmap, cbuf, in[0]->vec, in[1]->data, in[1]->vec, do_simple_spillmap_blue_fac, CB_RGBA, CB_VAL); } break; @@ -287,13 +292,14 @@ static void node_composit_exec_color_spill(void *UNUSED(data), bNode *node, bNod { if ((in[1]->data==NULL) && (in[1]->vec[0] >= 1.f)) { composit1_pixel_processor(node, spillmap, cbuf, in[0]->vec, do_average_spillmap_blue, CB_RGBA); - } else { + } + else { composit2_pixel_processor(node, spillmap, cbuf, in[0]->vec, in[1]->data, in[1]->vec, do_average_spillmap_blue_fac, CB_RGBA, CB_VAL); } break; } } - if(ncs->unspill==0) { + if (ncs->unspill==0) { ncs->uspillr=0.0f; ncs->uspillg=0.0f; ncs->uspillb=1.0f; @@ -307,7 +313,7 @@ static void node_composit_exec_color_spill(void *UNUSED(data), bNode *node, bNod out[0]->data=rgbbuf; - if(cbuf!=in[0]->data) + if (cbuf!=in[0]->data) free_compbuf(cbuf); free_compbuf(spillmap); diff --git a/source/blender/nodes/composite/nodes/node_composite_colorbalance.c b/source/blender/nodes/composite/nodes/node_composite_colorbalance.c index 9995036f89c..f77e4cd9c4e 100644 --- a/source/blender/nodes/composite/nodes/node_composite_colorbalance.c +++ b/source/blender/nodes/composite/nodes/node_composite_colorbalance.c @@ -130,9 +130,9 @@ static void node_composit_exec_colorbalance(void *UNUSED(data), bNode *node, bNo /* stack order input: fac, image */ /* stack order output: image */ - if(out[0]->hasoutput==0) return; + if (out[0]->hasoutput==0) return; - if(in[0]->vec[0] == 0.f && in[0]->data == NULL) { + if (in[0]->vec[0] == 0.f && in[0]->data == NULL) { out[0]->data = pass_on_compbuf(cbuf); return; } @@ -158,7 +158,8 @@ static void node_composit_exec_colorbalance(void *UNUSED(data), bNode *node, bNo else { composit2_pixel_processor(node, stackbuf, in[1]->data, in[1]->vec, in[0]->data, in[0]->vec, do_colorbalance_lgg_fac, CB_RGBA, CB_VAL); } - } else { + } + else { /* offset/power/slope : ASC-CDL */ if ((in[0]->data==NULL) && (in[0]->vec[0] >= 1.f)) { composit1_pixel_processor(node, stackbuf, in[1]->data, in[1]->vec, do_colorbalance_cdl, CB_RGBA); diff --git a/source/blender/nodes/composite/nodes/node_composite_composite.c b/source/blender/nodes/composite/nodes/node_composite_composite.c index 73a84676caa..9b1e5e451c4 100644 --- a/source/blender/nodes/composite/nodes/node_composite_composite.c +++ b/source/blender/nodes/composite/nodes/node_composite_composite.c @@ -48,27 +48,27 @@ static void node_composit_exec_composite(void *data, bNode *node, bNodeStack **i /* image assigned to output */ /* stack order input sockets: col, alpha, z */ - if(node->flag & NODE_DO_OUTPUT) { /* only one works on out */ + if (node->flag & NODE_DO_OUTPUT) { /* only one works on out */ Scene *scene= (Scene *)node->id; RenderData *rd= data; - if(scene && (rd->scemode & R_DOCOMP)) { + if (scene && (rd->scemode & R_DOCOMP)) { Render *re= RE_GetRender(scene->id.name); RenderResult *rr= RE_AcquireResultWrite(re); - if(rr) { + if (rr) { CompBuf *outbuf, *zbuf=NULL; - if(rr->rectf) + if (rr->rectf) MEM_freeN(rr->rectf); outbuf= alloc_compbuf(rr->rectx, rr->recty, CB_RGBA, 1); - if(in[1]->data==NULL) + if (in[1]->data==NULL) composit1_pixel_processor(node, outbuf, in[0]->data, in[0]->vec, do_copy_rgba, CB_RGBA); else composit2_pixel_processor(node, outbuf, in[0]->data, in[0]->vec, in[1]->data, in[1]->vec, do_copy_a_rgba, CB_RGBA, CB_VAL); - if(in[2]->data) { - if(rr->rectz) + if (in[2]->data) { + if (rr->rectz) MEM_freeN(rr->rectz); zbuf= alloc_compbuf(rr->rectx, rr->recty, CB_VAL, 1); composit1_pixel_processor(node, zbuf, in[2]->data, in[2]->vec, do_copy_value, CB_VAL); @@ -93,7 +93,7 @@ static void node_composit_exec_composite(void *data, bNode *node, bNodeStack **i RE_ReleaseResult(re); } } - if(in[0]->data) + if (in[0]->data) generate_preview(data, node, in[0]->data); } diff --git a/source/blender/nodes/composite/nodes/node_composite_crop.c b/source/blender/nodes/composite/nodes/node_composite_crop.c index 3697f3e4c5c..242bc8396d7 100644 --- a/source/blender/nodes/composite/nodes/node_composite_crop.c +++ b/source/blender/nodes/composite/nodes/node_composite_crop.c @@ -45,7 +45,7 @@ static bNodeSocketTemplate cmp_node_crop_out[]= { static void node_composit_exec_crop(void *UNUSED(data), bNode *node, bNodeStack **in, bNodeStack **out) { - if(in[0]->data) { + if (in[0]->data) { NodeTwoXYs *ntxy= node->storage; CompBuf *cbuf= in[0]->data; CompBuf *stackbuf; @@ -53,7 +53,7 @@ static void node_composit_exec_crop(void *UNUSED(data), bNode *node, bNodeStack float *srcfp, *outfp; rcti outputrect; - if(node->custom2) { + if (node->custom2) { ntxy->x1= cbuf->x* ntxy->fac_x1; ntxy->x2= cbuf->x* ntxy->fac_x2; ntxy->y1= cbuf->y* ntxy->fac_y1; @@ -61,16 +61,16 @@ static void node_composit_exec_crop(void *UNUSED(data), bNode *node, bNodeStack } /* check input image size */ - if(cbuf->x <= ntxy->x1 + 1) + if (cbuf->x <= ntxy->x1 + 1) ntxy->x1= cbuf->x - 1; - if(cbuf->y <= ntxy->y1 + 1) + if (cbuf->y <= ntxy->y1 + 1) ntxy->y1= cbuf->y - 1; - if(cbuf->x <= ntxy->x2 + 1) + if (cbuf->x <= ntxy->x2 + 1) ntxy->x2= cbuf->x - 1; - if(cbuf->y <= ntxy->y2 + 1) + if (cbuf->y <= ntxy->y2 + 1) ntxy->y2= cbuf->y - 1; /* figure out the minimums and maximums */ @@ -79,7 +79,7 @@ static void node_composit_exec_crop(void *UNUSED(data), bNode *node, bNodeStack outputrect.ymax=MAX2(ntxy->y1, ntxy->y2) + 1; outputrect.ymin=MIN2(ntxy->y1, ntxy->y2); - if(node->custom1) { + if (node->custom1) { /* this option crops the image size too */ stackbuf= get_cropped_compbuf(&outputrect, cbuf->rect, cbuf->x, cbuf->y, cbuf->type); } @@ -89,10 +89,10 @@ static void node_composit_exec_crop(void *UNUSED(data), bNode *node, bNodeStack stackbuf = alloc_compbuf(cbuf->x, cbuf->y, cbuf->type, 1); /* select the cropped part of the image and set it to the output */ - for(y=outputrect.ymin; y<outputrect.ymax; y++){ + for (y=outputrect.ymin; y<outputrect.ymax; y++) { srcfp= cbuf->rect + (y * cbuf->x + outputrect.xmin) * cbuf->type; outfp= stackbuf->rect + (y * stackbuf->x + outputrect.xmin) * stackbuf->type; - for(x=outputrect.xmin; x<outputrect.xmax; x++, outfp+= stackbuf->type, srcfp+= cbuf->type) + for (x=outputrect.xmin; x<outputrect.xmax; x++, outfp+= stackbuf->type, srcfp+= cbuf->type) memcpy(outfp, srcfp, sizeof(float)*stackbuf->type); } } diff --git a/source/blender/nodes/composite/nodes/node_composite_curves.c b/source/blender/nodes/composite/nodes/node_composite_curves.c index 81424586a11..d17a7bf5dc8 100644 --- a/source/blender/nodes/composite/nodes/node_composite_curves.c +++ b/source/blender/nodes/composite/nodes/node_composite_curves.c @@ -47,7 +47,7 @@ static void node_composit_exec_curves_time(void *data, bNode *node, bNodeStack * /* stack order output: fac */ float fac= 0.0f; - if(node->custom1 < node->custom2) + if (node->custom1 < node->custom2) fac= (rd->cfra - node->custom1)/(float)(node->custom2-node->custom1); fac= curvemapping_evaluateF(node->storage, 0, fac); @@ -140,9 +140,9 @@ static void do_curves(bNode *node, float *out, float *in) static void do_curves_fac(bNode *node, float *out, float *in, float *fac) { - if(*fac >= 1.0f) + if (*fac >= 1.0f) curvemapping_evaluate_premulRGBF(node->storage, out, in); - else if(*fac <= 0.0f) { + else if (*fac <= 0.0f) { copy_v3_v3(out, in); } else { @@ -160,11 +160,11 @@ static void node_composit_exec_curve_rgb(void *UNUSED(data), bNode *node, bNodeS /* stack order input: fac, image, black level, white level */ /* stack order output: image */ - if(out[0]->hasoutput==0) + if (out[0]->hasoutput==0) return; /* input no image? then only color operation */ - if(in[1]->data==NULL) { + if (in[1]->data==NULL) { curvemapping_evaluateRGBF(node->storage, out[0]->vec, in[1]->vec); } else { @@ -174,7 +174,7 @@ static void node_composit_exec_curve_rgb(void *UNUSED(data), bNode *node, bNodeS curvemapping_set_black_white(node->storage, in[2]->vec, in[3]->vec); - if(in[0]->data==NULL && in[0]->vec[0] == 1.0f) + if (in[0]->data==NULL && in[0]->vec[0] == 1.0f) composit1_pixel_processor(node, stackbuf, in[1]->data, in[1]->vec, do_curves, CB_RGBA); else composit2_pixel_processor(node, stackbuf, in[1]->data, in[1]->vec, in[0]->data, in[0]->vec, do_curves_fac, CB_RGBA, CB_VAL); diff --git a/source/blender/nodes/composite/nodes/node_composite_defocus.c b/source/blender/nodes/composite/nodes/node_composite_defocus.c index 1ff2dac2900..46b134e4f65 100644 --- a/source/blender/nodes/composite/nodes/node_composite_defocus.c +++ b/source/blender/nodes/composite/nodes/node_composite_defocus.c @@ -376,7 +376,7 @@ static void defocus_blur(bNode *node, CompBuf *new, CompBuf *img, CompBuf *zbuf, wts->rect[px] = 0.f; } // esc set by main calling process - if(node->exec & NODE_BREAK) + if (node->exec & NODE_BREAK) break; } } @@ -400,7 +400,7 @@ static void defocus_blur(bNode *node, CompBuf *new, CompBuf *img, CompBuf *zbuf, #pragma omp critical { if (((ydone & 7)==0) || (ydone==(img->y-1))) { - if(G.background==0) { + if (G.background==0) { printf("\rdefocus: Processing Line %d of %d ... ", ydone+1, img->y); fflush(stdout); } @@ -411,7 +411,7 @@ static void defocus_blur(bNode *node, CompBuf *new, CompBuf *img, CompBuf *zbuf, // esc set by main calling process. don't break because openmp doesn't // allow it, just continue and do nothing - if(node->exec & NODE_BREAK) + if (node->exec & NODE_BREAK) continue; zp = y * img->x; @@ -850,7 +850,7 @@ static void node_composit_exec_defocus(void *UNUSED(data), bNode *node, bNodeSta premul_compbuf(new, 0); free_compbuf(old); } - if(node->exec & NODE_BREAK) { + if (node->exec & NODE_BREAK) { free_compbuf(new); new= NULL; } diff --git a/source/blender/nodes/composite/nodes/node_composite_diffMatte.c b/source/blender/nodes/composite/nodes/node_composite_diffMatte.c index eae59dea3f4..027786d8b22 100644 --- a/source/blender/nodes/composite/nodes/node_composite_diffMatte.c +++ b/source/blender/nodes/composite/nodes/node_composite_diffMatte.c @@ -63,15 +63,15 @@ static void do_diff_matte(bNode *node, float *outColor, float *inColor1, float * copy_v3_v3(outColor, inColor1); /*make 100% transparent*/ - if(difference < tolerence) { + if (difference < tolerence) { outColor[3]=0.0; } /*in the falloff region, make partially transparent */ - else if(difference < falloff+tolerence) { + else if (difference < falloff+tolerence) { difference=difference-tolerence; alpha=difference/falloff; /*only change if more transparent than before */ - if(alpha < inColor1[3]) { + if (alpha < inColor1[3]) { outColor[3]=alpha; } else { /* leave as before */ @@ -92,16 +92,16 @@ static void node_composit_exec_diff_matte(void *data, bNode *node, bNodeStack ** /* NodeChroma *c; */ /* UNUSED */ /*is anything connected?*/ - if(out[0]->hasoutput==0 && out[1]->hasoutput==0) return; + if (out[0]->hasoutput==0 && out[1]->hasoutput==0) return; /*must have an image imput*/ - if(in[0]->data==NULL) return; + if (in[0]->data==NULL) return; imbuf1=typecheck_compbuf(in[0]->data, CB_RGBA); /* if there's an image, use that, if not use the color */ - if(in[1]->data) { + if (in[1]->data) { imbuf2=typecheck_compbuf(in[1]->data, CB_RGBA); } @@ -112,14 +112,14 @@ static void node_composit_exec_diff_matte(void *data, bNode *node, bNodeStack ** composit2_pixel_processor(node, outbuf, imbuf1, in[0]->vec, imbuf2, in[1]->vec, do_diff_matte, CB_RGBA, CB_RGBA); out[0]->data=outbuf; - if(out[1]->hasoutput) + if (out[1]->hasoutput) out[1]->data=valbuf_from_rgbabuf(outbuf, CHAN_A); generate_preview(data, node, outbuf); - if(imbuf1!=in[0]->data) + if (imbuf1!=in[0]->data) free_compbuf(imbuf1); - if(imbuf2!=in[1]->data) + if (imbuf2!=in[1]->data) free_compbuf(imbuf2); } diff --git a/source/blender/nodes/composite/nodes/node_composite_dilate.c b/source/blender/nodes/composite/nodes/node_composite_dilate.c index f8abf96e742..ee857dd0007 100644 --- a/source/blender/nodes/composite/nodes/node_composite_dilate.c +++ b/source/blender/nodes/composite/nodes/node_composite_dilate.c @@ -117,11 +117,11 @@ static void node_composit_exec_dilateerode(void *UNUSED(data), bNode *node, bNod { /* stack order in: mask */ /* stack order out: mask */ - if(out[0]->hasoutput==0) + if (out[0]->hasoutput==0) return; /* input no image? then only color operation */ - if(in[0]->data==NULL) { + if (in[0]->data==NULL) { out[0]->vec[0] = out[0]->vec[1] = out[0]->vec[2] = 0.0f; out[0]->vec[3] = 0.0f; } @@ -134,12 +134,13 @@ static void node_composit_exec_dilateerode(void *UNUSED(data), bNode *node, bNod if (node->custom2 > 0) { // positive, dilate for (i = 0; i < node->custom2; i++) morpho_dilate(stackbuf); - } else if (node->custom2 < 0) { // negative, erode + } + else if (node->custom2 < 0) { // negative, erode for (i = 0; i > node->custom2; i--) morpho_erode(stackbuf); } - if(cbuf!=in[0]->data) + if (cbuf!=in[0]->data) free_compbuf(cbuf); out[0]->data= stackbuf; diff --git a/source/blender/nodes/composite/nodes/node_composite_directionalblur.c b/source/blender/nodes/composite/nodes/node_composite_directionalblur.c index d0f7feccf2e..f65b3312bea 100644 --- a/source/blender/nodes/composite/nodes/node_composite_directionalblur.c +++ b/source/blender/nodes/composite/nodes/node_composite_directionalblur.c @@ -68,37 +68,37 @@ static CompBuf *dblur(bNode *node, CompBuf *img, int iterations, int wrap, rot= itsc * spin; /* blur the image */ - for(i= 0; i < iterations; ++i) { + for (i= 0; i < iterations; ++i) { const float cs= cosf(rot), ss= sinf(rot); const float isc= 1.f / (1.f + sc); unsigned int x, y; float col[4]= {0,0,0,0}; - for(y= 0; y < img->y; ++y) { + for (y= 0; y < img->y; ++y) { const float v= isc * (y - center_y_pix) + ty; - for(x= 0; x < img->x; ++x) { + for (x= 0; x < img->x; ++x) { const float u= isc * (x - center_x_pix) + tx; unsigned int p= (x + y * img->x) * img->type; getpix(tmp, cs * u + ss * v + center_x_pix, cs * v - ss * u + center_y_pix, col); /* mix img and transformed tmp */ - for(j= 0; j < 4; ++j) { + for (j= 0; j < 4; ++j) { img->rect[p + j]= 0.5f * (img->rect[p + j] + col[j]); } } } /* copy img to tmp */ - if(i != (iterations - 1)) + if (i != (iterations - 1)) memcpy(tmp->rect, img->rect, sizeof(float) * img->x * img->y * img->type); /* double transformations */ tx *= 2.f, ty *= 2.f; sc *= 2.f, rot *= 2.f; - if(node->exec & NODE_BREAK) break; + if (node->exec & NODE_BREAK) break; } free_compbuf(tmp); @@ -112,7 +112,7 @@ static void node_composit_exec_dblur(void *UNUSED(data), bNode *node, bNodeStack NodeDBlurData *ndbd= node->storage; CompBuf *new, *img= in[0]->data; - if((img == NULL) || (out[0]->hasoutput == 0)) return; + if ((img == NULL) || (out[0]->hasoutput == 0)) return; if (img->type != CB_RGBA) new = typecheck_compbuf(img, CB_RGBA); diff --git a/source/blender/nodes/composite/nodes/node_composite_displace.c b/source/blender/nodes/composite/nodes/node_composite_displace.c index ad7c1fa589e..6e4bbc632ea 100644 --- a/source/blender/nodes/composite/nodes/node_composite_displace.c +++ b/source/blender/nodes/composite/nodes/node_composite_displace.c @@ -66,8 +66,8 @@ static void do_displace(bNode *node, CompBuf *stackbuf, CompBuf *cbuf, CompBuf * ibuf= IMB_allocImBuf(cbuf->x, cbuf->y, 32, 0); ibuf->rect_float= cbuf->rect; - for(y=0; y < stackbuf->y; y++) { - for(x=0; x < stackbuf->x; x++) { + for (y=0; y < stackbuf->y; y++) { + for (x=0; x < stackbuf->x; x++) { /* calc pixel coordinates */ qd_getPixel(vecbuf, x-vecbuf->xof, y-vecbuf->yof, vec); @@ -117,10 +117,10 @@ static void do_displace(bNode *node, CompBuf *stackbuf, CompBuf *cbuf, CompBuf * ibuf_sample(ibuf, u, v, dxt, dyt, col); qd_setPixel(stackbuf, x, y, col); - if(node->exec & NODE_BREAK) break; + if (node->exec & NODE_BREAK) break; } - if(node->exec & NODE_BREAK) break; + if (node->exec & NODE_BREAK) break; } IMB_freeImBuf(ibuf); @@ -133,8 +133,8 @@ static void do_displace(bNode *node, CompBuf *stackbuf, CompBuf *cbuf, CompBuf * float vec[3]; float col[3]; - for(y=0; y < stackbuf->y; y++) { - for(x=0; x < stackbuf->x; x++) { + for (y=0; y < stackbuf->y; y++) { + for (x=0; x < stackbuf->x; x++) { qd_getPixel(vecbuf, x, y, vec); dx = vec[0] * (xscale[0]); @@ -153,10 +153,10 @@ static void do_displace(bNode *node, CompBuf *stackbuf, CompBuf *cbuf, CompBuf * static void node_composit_exec_displace(void *UNUSED(data), bNode *node, bNodeStack **in, bNodeStack **out) { - if(out[0]->hasoutput==0) + if (out[0]->hasoutput==0) return; - if(in[0]->data && in[1]->data) { + if (in[0]->data && in[1]->data) { CompBuf *cbuf= in[0]->data; CompBuf *vecbuf= in[1]->data; CompBuf *xbuf= in[2]->data; @@ -175,9 +175,9 @@ static void node_composit_exec_displace(void *UNUSED(data), bNode *node, bNodeSt out[0]->data= stackbuf; - if(cbuf!=in[0]->data) + if (cbuf!=in[0]->data) free_compbuf(cbuf); - if(vecbuf!=in[1]->data) + if (vecbuf!=in[1]->data) free_compbuf(vecbuf); } } diff --git a/source/blender/nodes/composite/nodes/node_composite_distanceMatte.c b/source/blender/nodes/composite/nodes/node_composite_distanceMatte.c index 292bb66613d..7aaaa7ed9b4 100644 --- a/source/blender/nodes/composite/nodes/node_composite_distanceMatte.c +++ b/source/blender/nodes/composite/nodes/node_composite_distanceMatte.c @@ -62,15 +62,15 @@ static void do_distance_matte(bNode *node, float *out, float *in) copy_v3_v3(out, in); /*make 100% transparent */ - if(distance < tolerence) { + if (distance < tolerence) { out[3]=0.0; } /*in the falloff region, make partially transparent */ - else if(distance < falloff+tolerence){ + else if (distance < falloff+tolerence) { distance=distance-tolerence; alpha=distance/falloff; /*only change if more transparent than before */ - if(alpha < in[3]) { + if (alpha < in[3]) { out[3]=alpha; } else { /* leave as before */ @@ -93,9 +93,9 @@ static void node_composit_exec_distance_matte(void *data, bNode *node, bNodeStac NodeChroma *c; /*is anything connected?*/ - if(out[0]->hasoutput==0 && out[1]->hasoutput==0) return; + if (out[0]->hasoutput==0 && out[1]->hasoutput==0) return; /*must have an image imput*/ - if(in[0]->data==NULL) return; + if (in[0]->data==NULL) return; inbuf=typecheck_compbuf(in[0]->data, CB_RGBA); @@ -112,11 +112,11 @@ static void node_composit_exec_distance_matte(void *data, bNode *node, bNodeStac out[0]->data=workbuf; - if(out[1]->hasoutput) + if (out[1]->hasoutput) out[1]->data=valbuf_from_rgbabuf(workbuf, CHAN_A); generate_preview(data, node, workbuf); - if(inbuf!=in[0]->data) + if (inbuf!=in[0]->data) free_compbuf(inbuf); } diff --git a/source/blender/nodes/composite/nodes/node_composite_doubleEdgeMask.c b/source/blender/nodes/composite/nodes/node_composite_doubleEdgeMask.c index d012815fff9..966d8f8a21a 100644 --- a/source/blender/nodes/composite/nodes/node_composite_doubleEdgeMask.c +++ b/source/blender/nodes/composite/nodes/node_composite_doubleEdgeMask.c @@ -792,7 +792,7 @@ static void do_allEdgeDetection(unsigned int t, unsigned int rw, unsigned int *l pix_nextRow=a-rw; pix_prevCol=a+1; pix_nextCol=a-1; - while(a>dx-2) { + while (a>dx-2) { if (!limask[a]) { // if the inner mask is empty if (lomask[a]) { // if the outer mask is full /* @@ -854,7 +854,7 @@ static void do_adjacentEdgeDetection(unsigned int t, unsigned int rw, unsigned i pix_nextRow=a-rw; pix_prevCol=a+1; pix_nextCol=a-1; - while(a>dx-2) { + while (a>dx-2) { if (!limask[a]) { // if the inner mask is empty if (lomask[a]) { // if the outer mask is full /* diff --git a/source/blender/nodes/composite/nodes/node_composite_filter.c b/source/blender/nodes/composite/nodes/node_composite_filter.c index 94a109de8f2..6d470467cb0 100644 --- a/source/blender/nodes/composite/nodes/node_composite_filter.c +++ b/source/blender/nodes/composite/nodes/node_composite_filter.c @@ -51,24 +51,24 @@ static void do_filter_edge(CompBuf *out, CompBuf *in, float *filter, float fac) rowlen= in->x; - for(y=0; y<in->y; y++) { + for (y=0; y<in->y; y++) { /* setup rows */ - if(y==0) row1= in->rect; + if (y==0) row1= in->rect; else row1= in->rect + pix*(y-1)*rowlen; row2= in->rect + y*pix*rowlen; - if(y==in->y-1) row3= row2; + if (y==in->y-1) row3= row2; else row3= row2 + pix*rowlen; fp= out->rect + pix*y*rowlen; - if(pix==CB_RGBA) { + if (pix==CB_RGBA) { copy_v4_v4(fp, row2); fp+= pix; - for(x=2; x<rowlen; x++) { - for(c=0; c<3; c++) { + for (x=2; x<rowlen; x++) { + for (c=0; c<3; c++) { f1= filter[0]*row1[0] + filter[1]*row1[4] + filter[2]*row1[8] + filter[3]*row2[0] + filter[4]*row2[4] + filter[5]*row2[8] + filter[6]*row3[0] + filter[7]*row3[4] + filter[8]*row3[8]; f2= filter[0]*row1[0] + filter[3]*row1[4] + filter[6]*row1[8] + filter[1]*row2[0] + filter[4]*row2[4] + filter[7]*row2[8] + filter[2]*row3[0] + filter[5]*row3[4] + filter[8]*row3[8]; fp[0]= mfac*row2[4] + fac*sqrt(f1*f1 + f2*f2); @@ -80,9 +80,9 @@ static void do_filter_edge(CompBuf *out, CompBuf *in, float *filter, float fac) } copy_v4_v4(fp, row2+4); } - else if(pix==CB_VAL) { + else if (pix==CB_VAL) { fp+= pix; - for(x=2; x<rowlen; x++) { + for (x=2; x<rowlen; x++) { f1= filter[0]*row1[0] + filter[1]*row1[1] + filter[2]*row1[2] + filter[3]*row2[0] + filter[4]*row2[1] + filter[5]*row2[2] + filter[6]*row3[0] + filter[7]*row3[1] + filter[8]*row3[2]; f2= filter[0]*row1[0] + filter[3]*row1[1] + filter[6]*row1[2] + filter[1]*row2[0] + filter[4]*row2[1] + filter[7]*row2[2] + filter[2]*row3[0] + filter[5]*row3[1] + filter[8]*row3[2]; fp[0]= mfac*row2[1] + fac*sqrt(f1*f1 + f2*f2); @@ -101,35 +101,35 @@ static void do_filter3(CompBuf *out, CompBuf *in, float *filter, float fac) rowlen= in->x; - for(y=0; y<in->y; y++) { + for (y=0; y<in->y; y++) { /* setup rows */ - if(y==0) row1= in->rect; + if (y==0) row1= in->rect; else row1= in->rect + pixlen*(y-1)*rowlen; row2= in->rect + y*pixlen*rowlen; - if(y==in->y-1) row3= row2; + if (y==in->y-1) row3= row2; else row3= row2 + pixlen*rowlen; fp= out->rect + pixlen*(y)*rowlen; - if(pixlen==1) { + if (pixlen==1) { fp[0]= row2[0]; fp+= 1; - for(x=2; x<rowlen; x++) { + for (x=2; x<rowlen; x++) { fp[0]= mfac*row2[1] + fac*(filter[0]*row1[0] + filter[1]*row1[1] + filter[2]*row1[2] + filter[3]*row2[0] + filter[4]*row2[1] + filter[5]*row2[2] + filter[6]*row3[0] + filter[7]*row3[1] + filter[8]*row3[2]); fp++; row1++; row2++; row3++; } fp[0]= row2[1]; } - else if(pixlen==2) { + else if (pixlen==2) { fp[0]= row2[0]; fp[1]= row2[1]; fp+= 2; - for(x=2; x<rowlen; x++) { - for(c=0; c<2; c++) { + for (x=2; x<rowlen; x++) { + for (c=0; c<2; c++) { fp[0]= mfac*row2[2] + fac*(filter[0]*row1[0] + filter[1]*row1[2] + filter[2]*row1[4] + filter[3]*row2[0] + filter[4]*row2[2] + filter[5]*row2[4] + filter[6]*row3[0] + filter[7]*row3[2] + filter[8]*row3[4]); fp++; row1++; row2++; row3++; } @@ -137,12 +137,12 @@ static void do_filter3(CompBuf *out, CompBuf *in, float *filter, float fac) fp[0]= row2[2]; fp[1]= row2[3]; } - else if(pixlen==3) { + else if (pixlen==3) { copy_v3_v3(fp, row2); fp+= 3; - for(x=2; x<rowlen; x++) { - for(c=0; c<3; c++) { + for (x=2; x<rowlen; x++) { + for (c=0; c<3; c++) { fp[0]= mfac*row2[3] + fac*(filter[0]*row1[0] + filter[1]*row1[3] + filter[2]*row1[6] + filter[3]*row2[0] + filter[4]*row2[3] + filter[5]*row2[6] + filter[6]*row3[0] + filter[7]*row3[3] + filter[8]*row3[6]); fp++; row1++; row2++; row3++; } @@ -153,8 +153,8 @@ static void do_filter3(CompBuf *out, CompBuf *in, float *filter, float fac) copy_v4_v4(fp, row2); fp+= 4; - for(x=2; x<rowlen; x++) { - for(c=0; c<4; c++) { + for (x=2; x<rowlen; x++) { + for (c=0; c<4; c++) { fp[0]= mfac*row2[4] + fac*(filter[0]*row1[0] + filter[1]*row1[4] + filter[2]*row1[8] + filter[3]*row2[0] + filter[4]*row2[4] + filter[5]*row2[8] + filter[6]*row3[0] + filter[7]*row3[4] + filter[8]*row3[8]); fp++; row1++; row2++; row3++; } @@ -175,12 +175,12 @@ static void node_composit_exec_filter(void *data, bNode *node, bNodeStack **in, float kirsch[9]= {5,5,5,-3,-3,-3,-2,-2,-2}; float shadow[9]= {1,2,1,0,1,0,-1,-2,-1}; - if(out[0]->hasoutput==0) return; + if (out[0]->hasoutput==0) return; /* stack order in: Image */ /* stack order out: Image */ - if(in[1]->data) { + if (in[1]->data) { /* make output size of first available input image */ CompBuf *cbuf= in[1]->data; CompBuf *stackbuf= alloc_compbuf(cbuf->x, cbuf->y, cbuf->type, 1); /* allocs */ diff --git a/source/blender/nodes/composite/nodes/node_composite_flip.c b/source/blender/nodes/composite/nodes/node_composite_flip.c index 974a14037eb..3c297299edc 100644 --- a/source/blender/nodes/composite/nodes/node_composite_flip.c +++ b/source/blender/nodes/composite/nodes/node_composite_flip.c @@ -45,7 +45,7 @@ static bNodeSocketTemplate cmp_node_flip_out[]= { static void node_composit_exec_flip(void *UNUSED(data), bNode *node, bNodeStack **in, bNodeStack **out) { - if(in[0]->data) { + if (in[0]->data) { CompBuf *cbuf= in[0]->data; CompBuf *stackbuf= alloc_compbuf(cbuf->x, cbuf->y, cbuf->type, 1); /* note, this returns zero'd image */ int i, src_pix, src_width, src_height, srcydelt, outydelt, x, y; @@ -59,20 +59,20 @@ static void node_composit_exec_flip(void *UNUSED(data), bNode *node, bNodeStack srcydelt= src_width*src_pix; outydelt= srcydelt; - if(node->custom1) { /*set up output pointer for y flip*/ + if (node->custom1) { /*set up output pointer for y flip*/ outfp+= (src_height-1)*outydelt; outydelt= -outydelt; } - for(y=0; y<src_height; y++) { - if(node->custom1 == 1) { /* no x flip so just copy line*/ + for (y=0; y<src_height; y++) { + if (node->custom1 == 1) { /* no x flip so just copy line*/ memcpy(outfp, srcfp, sizeof(float) * src_pix * src_width); srcfp+=srcydelt; } else { outfp += (src_width-1)*src_pix; - for(x=0; x<src_width; x++) { - for(i=0; i<src_pix; i++) { + for (x=0; x<src_width; x++) { + for (i=0; i<src_pix; i++) { outfp[i]= srcfp[i]; } outfp -= src_pix; diff --git a/source/blender/nodes/composite/nodes/node_composite_gamma.c b/source/blender/nodes/composite/nodes/node_composite_gamma.c index 90135b5cf35..ae793b44f2c 100644 --- a/source/blender/nodes/composite/nodes/node_composite_gamma.c +++ b/source/blender/nodes/composite/nodes/node_composite_gamma.c @@ -48,7 +48,7 @@ static bNodeSocketTemplate cmp_node_gamma_out[]= { static void do_gamma(bNode *UNUSED(node), float *out, float *in, float *fac) { int i=0; - for(i=0; i<3; i++) { + for (i=0; i<3; i++) { /* check for negative to avoid nan's */ out[i] = (in[i] > 0.0f)? powf(in[i],fac[0]): in[i]; } @@ -58,10 +58,10 @@ static void node_composit_exec_gamma(void *UNUSED(data), bNode *node, bNodeStack { /* stack order in: Fac, Image */ /* stack order out: Image */ - if(out[0]->hasoutput==0) return; + if (out[0]->hasoutput==0) return; /* input no image? then only color operation */ - if(in[0]->data==NULL) { + if (in[0]->data==NULL) { do_gamma(node, out[0]->vec, in[0]->vec, in[1]->vec); } else { diff --git a/source/blender/nodes/composite/nodes/node_composite_glare.c b/source/blender/nodes/composite/nodes/node_composite_glare.c index d4e15f780e5..42760ddfc4e 100644 --- a/source/blender/nodes/composite/nodes/node_composite_glare.c +++ b/source/blender/nodes/composite/nodes/node_composite_glare.c @@ -436,7 +436,8 @@ static void node_composit_exec_glare(void *UNUSED(data), bNode *node, bNodeStack if (img->type != CB_RGBA) { new = typecheck_compbuf(img, CB_RGBA); src = typecheck_compbuf(img, CB_RGBA); - } else { + } + else { new = dupalloc_compbuf(img); src = dupalloc_compbuf(img); } diff --git a/source/blender/nodes/composite/nodes/node_composite_hueSatVal.c b/source/blender/nodes/composite/nodes/node_composite_hueSatVal.c index c4598717e00..7349d1dd4bf 100644 --- a/source/blender/nodes/composite/nodes/node_composite_hueSatVal.c +++ b/source/blender/nodes/composite/nodes/node_composite_hueSatVal.c @@ -48,12 +48,12 @@ static void do_hue_sat_fac(bNode *node, float *out, float *in, float *fac) { NodeHueSat *nhs= node->storage; - if(*fac!=0.0f && (nhs->hue!=0.5f || nhs->sat!=1.0f || nhs->val!=1.0f)) { + if (*fac!=0.0f && (nhs->hue!=0.5f || nhs->sat!=1.0f || nhs->val!=1.0f)) { float col[3], hsv[3], mfac= 1.0f - *fac; rgb_to_hsv(in[0], in[1], in[2], hsv, hsv+1, hsv+2); hsv[0]+= (nhs->hue - 0.5f); - if(hsv[0]>1.0f) hsv[0]-=1.0f; else if(hsv[0]<0.0f) hsv[0]+= 1.0f; + if (hsv[0]>1.0f) hsv[0]-=1.0f; else if (hsv[0]<0.0f) hsv[0]+= 1.0f; hsv[1]*= nhs->sat; hsv[2]*= nhs->val; hsv_to_rgb(hsv[0], hsv[1], hsv[2], col, col+1, col+2); @@ -72,10 +72,10 @@ static void node_composit_exec_hue_sat(void *UNUSED(data), bNode *node, bNodeSta { /* stack order in: Fac, Image */ /* stack order out: Image */ - if(out[0]->hasoutput==0) return; + if (out[0]->hasoutput==0) return; /* input no image? then only color operation */ - if(in[1]->data==NULL) { + if (in[1]->data==NULL) { do_hue_sat_fac(node, out[0]->vec, in[1]->vec, in[0]->vec); } else { @@ -88,7 +88,7 @@ static void node_composit_exec_hue_sat(void *UNUSED(data), bNode *node, bNodeSta out[0]->data= stackbuf; /* get rid of intermediary cbuf if it's extra */ - if(stackbuf!=cbuf) + if (stackbuf!=cbuf) free_compbuf(cbuf); } } diff --git a/source/blender/nodes/composite/nodes/node_composite_huecorrect.c b/source/blender/nodes/composite/nodes/node_composite_huecorrect.c index 6b0849b2391..23d04a28276 100644 --- a/source/blender/nodes/composite/nodes/node_composite_huecorrect.c +++ b/source/blender/nodes/composite/nodes/node_composite_huecorrect.c @@ -109,16 +109,16 @@ static void node_composit_exec_huecorrect(void *UNUSED(data), bNode *node, bNode /* stack order input: fac, image, black level, white level */ /* stack order output: image */ - if(out[0]->hasoutput==0) + if (out[0]->hasoutput==0) return; - if(in[0]->vec[0] == 0.f && in[0]->data == NULL) { + if (in[0]->vec[0] == 0.f && in[0]->data == NULL) { out[0]->data = pass_on_compbuf(cbuf); return; } /* input no image? then only color operation */ - if(in[1]->data==NULL) { + if (in[1]->data==NULL) { do_huecorrect_fac(node, out[0]->vec, in[1]->vec, in[0]->vec); } diff --git a/source/blender/nodes/composite/nodes/node_composite_idMask.c b/source/blender/nodes/composite/nodes/node_composite_idMask.c index 0600e44b0d0..c1dba471f20 100644 --- a/source/blender/nodes/composite/nodes/node_composite_idMask.c +++ b/source/blender/nodes/composite/nodes/node_composite_idMask.c @@ -52,15 +52,15 @@ static void do_idmask(CompBuf *stackbuf, CompBuf *cbuf, float idnr) char *abuf= MEM_mapallocN(cbuf->x*cbuf->y, "anti ali buf"); rect= cbuf->rect; - for(x= cbuf->x*cbuf->y - 1; x>=0; x--) - if(rect[x]==idnr) + for (x= cbuf->x*cbuf->y - 1; x>=0; x--) + if (rect[x]==idnr) abuf[x]= 255; antialias_tagbuf(cbuf->x, cbuf->y, abuf); rect= stackbuf->rect; - for(x= cbuf->x*cbuf->y - 1; x>=0; x--) - if(abuf[x]>1) + for (x= cbuf->x*cbuf->y - 1; x>=0; x--) + if (abuf[x]>1) rect[x]= (1.0f/255.0f)*(float)abuf[x]; MEM_freeN(abuf); @@ -74,8 +74,8 @@ static void do_idmask_fsa(CompBuf *stackbuf, CompBuf *cbuf, float idnr) rect= cbuf->rect; rs= stackbuf->rect; - for(x= cbuf->x*cbuf->y - 1; x>=0; x--) - if(rect[x]==idnr) + for (x= cbuf->x*cbuf->y - 1; x>=0; x--) + if (rect[x]==idnr) rs[x]= 1.0f; } @@ -85,19 +85,19 @@ static void node_composit_exec_idmask(void *data, bNode *node, bNodeStack **in, { RenderData *rd= data; - if(out[0]->hasoutput==0) + if (out[0]->hasoutput==0) return; - if(in[0]->data) { + if (in[0]->data) { CompBuf *cbuf= in[0]->data; CompBuf *stackbuf; - if(cbuf->type!=CB_VAL) + if (cbuf->type!=CB_VAL) return; stackbuf= alloc_compbuf(cbuf->x, cbuf->y, CB_VAL, 1); /* allocs */; - if((rd->scemode & R_FULL_SAMPLE) || node->custom2 == 0) + if ((rd->scemode & R_FULL_SAMPLE) || node->custom2 == 0) do_idmask_fsa(stackbuf, cbuf, (float)node->custom1); else do_idmask(stackbuf, cbuf, (float)node->custom1); diff --git a/source/blender/nodes/composite/nodes/node_composite_image.c b/source/blender/nodes/composite/nodes/node_composite_image.c index 997bd72d5c4..44efbc6f9db 100644 --- a/source/blender/nodes/composite/nodes/node_composite_image.c +++ b/source/blender/nodes/composite/nodes/node_composite_image.c @@ -75,8 +75,8 @@ float *node_composit_get_float_buffer(RenderData *rd, ImBuf *ibuf, int *alloc) *alloc= FALSE; - if(rd->color_mgt_flag & R_COLOR_MANAGEMENT) { - if(ibuf->profile != IB_PROFILE_NONE) { + if (rd->color_mgt_flag & R_COLOR_MANAGEMENT) { + if (ibuf->profile != IB_PROFILE_NONE) { rect= ibuf->rect_float; } else { @@ -90,7 +90,7 @@ float *node_composit_get_float_buffer(RenderData *rd, ImBuf *ibuf, int *alloc) } } else { - if(ibuf->profile == IB_PROFILE_NONE) { + if (ibuf->profile == IB_PROFILE_NONE) { rect= ibuf->rect_float; } else { @@ -119,7 +119,7 @@ static CompBuf *node_composit_get_image(RenderData *rd, Image *ima, ImageUser *i int alloc= FALSE; ibuf= BKE_image_get_ibuf(ima, iuser); - if(ibuf==NULL || (ibuf->rect==NULL && ibuf->rect_float==NULL)) { + if (ibuf==NULL || (ibuf->rect==NULL && ibuf->rect_float==NULL)) { return NULL; } @@ -129,7 +129,7 @@ static CompBuf *node_composit_get_image(RenderData *rd, Image *ima, ImageUser *i /* now we need a float buffer from the image with matching color management */ /* XXX weak code, multilayer is excluded from this */ - if(ibuf->channels == 4 && ima->rr==NULL) { + if (ibuf->channels == 4 && ima->rr==NULL) { rect= node_composit_get_float_buffer(rd, ibuf, &alloc); } else { @@ -141,9 +141,9 @@ static CompBuf *node_composit_get_image(RenderData *rd, Image *ima, ImageUser *i type= ibuf->channels; - if(rd->scemode & R_COMP_CROP) { + if (rd->scemode & R_COMP_CROP) { stackbuf= get_cropped_compbuf(&rd->disprect, rect, ibuf->x, ibuf->y, type); - if(alloc) + if (alloc) MEM_freeN(rect); } else { @@ -176,8 +176,8 @@ static CompBuf *node_composit_get_zimage(bNode *node, RenderData *rd) ImBuf *ibuf= BKE_image_get_ibuf((Image *)node->id, node->storage); CompBuf *zbuf= NULL; - if(ibuf && ibuf->zbuf_float) { - if(rd->scemode & R_COMP_CROP) { + if (ibuf && ibuf->zbuf_float) { + if (rd->scemode & R_COMP_CROP) { zbuf= get_cropped_compbuf(&rd->disprect, ibuf->zbuf_float, ibuf->x, ibuf->y, CB_VAL); } else { @@ -194,11 +194,11 @@ static CompBuf *compbuf_multilayer_get(RenderData *rd, RenderLayer *rl, Image *i RenderPass *rpass; short index; - for(index=0, rpass= rl->passes.first; rpass; rpass= rpass->next, index++) - if(rpass->passtype==passtype) + for (index=0, rpass= rl->passes.first; rpass; rpass= rpass->next, index++) + if (rpass->passtype==passtype) break; - if(rpass) { + if (rpass) { CompBuf *cbuf; iuser->pass= index; @@ -212,58 +212,58 @@ static CompBuf *compbuf_multilayer_get(RenderData *rd, RenderLayer *rl, Image *i static void outputs_multilayer_get(RenderData *rd, RenderLayer *rl, bNodeStack **out, Image *ima, ImageUser *iuser) { - if(out[RRES_OUT_Z]->hasoutput) + if (out[RRES_OUT_Z]->hasoutput) out[RRES_OUT_Z]->data= compbuf_multilayer_get(rd, rl, ima, iuser, SCE_PASS_Z); - if(out[RRES_OUT_VEC]->hasoutput) + if (out[RRES_OUT_VEC]->hasoutput) out[RRES_OUT_VEC]->data= compbuf_multilayer_get(rd, rl, ima, iuser, SCE_PASS_VECTOR); - if(out[RRES_OUT_NORMAL]->hasoutput) + if (out[RRES_OUT_NORMAL]->hasoutput) out[RRES_OUT_NORMAL]->data= compbuf_multilayer_get(rd, rl, ima, iuser, SCE_PASS_NORMAL); - if(out[RRES_OUT_UV]->hasoutput) + if (out[RRES_OUT_UV]->hasoutput) out[RRES_OUT_UV]->data= compbuf_multilayer_get(rd, rl, ima, iuser, SCE_PASS_UV); - if(out[RRES_OUT_RGBA]->hasoutput) + if (out[RRES_OUT_RGBA]->hasoutput) out[RRES_OUT_RGBA]->data= compbuf_multilayer_get(rd, rl, ima, iuser, SCE_PASS_RGBA); - if(out[RRES_OUT_DIFF]->hasoutput) + if (out[RRES_OUT_DIFF]->hasoutput) out[RRES_OUT_DIFF]->data= compbuf_multilayer_get(rd, rl, ima, iuser, SCE_PASS_DIFFUSE); - if(out[RRES_OUT_SPEC]->hasoutput) + if (out[RRES_OUT_SPEC]->hasoutput) out[RRES_OUT_SPEC]->data= compbuf_multilayer_get(rd, rl, ima, iuser, SCE_PASS_SPEC); - if(out[RRES_OUT_SHADOW]->hasoutput) + if (out[RRES_OUT_SHADOW]->hasoutput) out[RRES_OUT_SHADOW]->data= compbuf_multilayer_get(rd, rl, ima, iuser, SCE_PASS_SHADOW); - if(out[RRES_OUT_AO]->hasoutput) + if (out[RRES_OUT_AO]->hasoutput) out[RRES_OUT_AO]->data= compbuf_multilayer_get(rd, rl, ima, iuser, SCE_PASS_AO); - if(out[RRES_OUT_REFLECT]->hasoutput) + if (out[RRES_OUT_REFLECT]->hasoutput) out[RRES_OUT_REFLECT]->data= compbuf_multilayer_get(rd, rl, ima, iuser, SCE_PASS_REFLECT); - if(out[RRES_OUT_REFRACT]->hasoutput) + if (out[RRES_OUT_REFRACT]->hasoutput) out[RRES_OUT_REFRACT]->data= compbuf_multilayer_get(rd, rl, ima, iuser, SCE_PASS_REFRACT); - if(out[RRES_OUT_INDIRECT]->hasoutput) + if (out[RRES_OUT_INDIRECT]->hasoutput) out[RRES_OUT_INDIRECT]->data= compbuf_multilayer_get(rd, rl, ima, iuser, SCE_PASS_INDIRECT); - if(out[RRES_OUT_INDEXOB]->hasoutput) + if (out[RRES_OUT_INDEXOB]->hasoutput) out[RRES_OUT_INDEXOB]->data= compbuf_multilayer_get(rd, rl, ima, iuser, SCE_PASS_INDEXOB); - if(out[RRES_OUT_INDEXMA]->hasoutput) + if (out[RRES_OUT_INDEXMA]->hasoutput) out[RRES_OUT_INDEXMA]->data= compbuf_multilayer_get(rd, rl, ima, iuser, SCE_PASS_INDEXMA); - if(out[RRES_OUT_MIST]->hasoutput) + if (out[RRES_OUT_MIST]->hasoutput) out[RRES_OUT_MIST]->data= compbuf_multilayer_get(rd, rl, ima, iuser, SCE_PASS_MIST); - if(out[RRES_OUT_EMIT]->hasoutput) + if (out[RRES_OUT_EMIT]->hasoutput) out[RRES_OUT_EMIT]->data= compbuf_multilayer_get(rd, rl, ima, iuser, SCE_PASS_EMIT); - if(out[RRES_OUT_ENV]->hasoutput) + if (out[RRES_OUT_ENV]->hasoutput) out[RRES_OUT_ENV]->data= compbuf_multilayer_get(rd, rl, ima, iuser, SCE_PASS_ENVIRONMENT); - if(out[RRES_OUT_DIFF_DIRECT]->hasoutput) + if (out[RRES_OUT_DIFF_DIRECT]->hasoutput) out[RRES_OUT_DIFF_DIRECT]->data= compbuf_multilayer_get(rd, rl, ima, iuser, SCE_PASS_DIFFUSE_DIRECT); - if(out[RRES_OUT_DIFF_INDIRECT]->hasoutput) + if (out[RRES_OUT_DIFF_INDIRECT]->hasoutput) out[RRES_OUT_DIFF_INDIRECT]->data= compbuf_multilayer_get(rd, rl, ima, iuser, SCE_PASS_DIFFUSE_INDIRECT); - if(out[RRES_OUT_DIFF_COLOR]->hasoutput) + if (out[RRES_OUT_DIFF_COLOR]->hasoutput) out[RRES_OUT_DIFF_COLOR]->data= compbuf_multilayer_get(rd, rl, ima, iuser, SCE_PASS_DIFFUSE_COLOR); - if(out[RRES_OUT_GLOSSY_DIRECT]->hasoutput) + if (out[RRES_OUT_GLOSSY_DIRECT]->hasoutput) out[RRES_OUT_GLOSSY_DIRECT]->data= compbuf_multilayer_get(rd, rl, ima, iuser, SCE_PASS_GLOSSY_DIRECT); - if(out[RRES_OUT_GLOSSY_INDIRECT]->hasoutput) + if (out[RRES_OUT_GLOSSY_INDIRECT]->hasoutput) out[RRES_OUT_GLOSSY_INDIRECT]->data= compbuf_multilayer_get(rd, rl, ima, iuser, SCE_PASS_GLOSSY_INDIRECT); - if(out[RRES_OUT_GLOSSY_COLOR]->hasoutput) + if (out[RRES_OUT_GLOSSY_COLOR]->hasoutput) out[RRES_OUT_GLOSSY_COLOR]->data= compbuf_multilayer_get(rd, rl, ima, iuser, SCE_PASS_GLOSSY_COLOR); - if(out[RRES_OUT_TRANSM_DIRECT]->hasoutput) + if (out[RRES_OUT_TRANSM_DIRECT]->hasoutput) out[RRES_OUT_TRANSM_DIRECT]->data= compbuf_multilayer_get(rd, rl, ima, iuser, SCE_PASS_TRANSM_DIRECT); - if(out[RRES_OUT_TRANSM_INDIRECT]->hasoutput) + if (out[RRES_OUT_TRANSM_INDIRECT]->hasoutput) out[RRES_OUT_TRANSM_INDIRECT]->data= compbuf_multilayer_get(rd, rl, ima, iuser, SCE_PASS_TRANSM_INDIRECT); - if(out[RRES_OUT_TRANSM_COLOR]->hasoutput) + if (out[RRES_OUT_TRANSM_COLOR]->hasoutput) out[RRES_OUT_TRANSM_COLOR]->data= compbuf_multilayer_get(rd, rl, ima, iuser, SCE_PASS_TRANSM_COLOR); } @@ -273,7 +273,7 @@ static void node_composit_exec_image(void *data, bNode *node, bNodeStack **UNUSE /* image assigned to output */ /* stack order input sockets: col, alpha */ - if(node->id) { + if (node->id) { RenderData *rd= data; Image *ima= (Image *)node->id; ImageUser *iuser= (ImageUser *)node->storage; @@ -283,13 +283,13 @@ static void node_composit_exec_image(void *data, bNode *node, bNodeStack **UNUSE BKE_image_user_calc_frame(iuser, rd->cfra, 0); /* force a load, we assume iuser index will be set OK anyway */ - if(ima->type==IMA_TYPE_MULTILAYER) + if (ima->type==IMA_TYPE_MULTILAYER) BKE_image_get_ibuf(ima, iuser); - if(ima->type==IMA_TYPE_MULTILAYER && ima->rr) { + if (ima->type==IMA_TYPE_MULTILAYER && ima->rr) { RenderLayer *rl= BLI_findlink(&ima->rr->layers, iuser->layer); - if(rl) { + if (rl) { out[0]->data= stackbuf= compbuf_multilayer_get(rd, rl, ima, iuser, SCE_PASS_COMBINED); /* go over all layers */ @@ -325,14 +325,14 @@ static void node_composit_exec_image(void *data, bNode *node, bNodeStack **UNUSE /* put image on stack */ out[0]->data= stackbuf; - if(out[2]->hasoutput) + if (out[2]->hasoutput) out[2]->data= node_composit_get_zimage(node, rd); } } /* alpha and preview for both types */ - if(stackbuf) { - if(out[1]->hasoutput) + if (stackbuf) { + if (out[1]->hasoutput) out[1]->data= valbuf_from_rgbabuf(stackbuf, CHAN_A); generate_preview(data, node, stackbuf); @@ -370,18 +370,18 @@ void register_node_type_cmp_image(bNodeTreeType *ttype) static CompBuf *compbuf_from_pass(RenderData *rd, RenderLayer *rl, int rectx, int recty, int passcode) { float *fp= RE_RenderLayerGetPass(rl, passcode); - if(fp) { + if (fp) { CompBuf *buf; int buftype= CB_VEC3; - if(ELEM4(passcode, SCE_PASS_Z, SCE_PASS_INDEXOB, SCE_PASS_MIST, SCE_PASS_INDEXMA)) + if (ELEM4(passcode, SCE_PASS_Z, SCE_PASS_INDEXOB, SCE_PASS_MIST, SCE_PASS_INDEXMA)) buftype= CB_VAL; - else if(passcode==SCE_PASS_VECTOR) + else if (passcode==SCE_PASS_VECTOR) buftype= CB_VEC4; - else if(ELEM(passcode, SCE_PASS_COMBINED, SCE_PASS_RGBA)) + else if (ELEM(passcode, SCE_PASS_COMBINED, SCE_PASS_RGBA)) buftype= CB_RGBA; - if(rd->scemode & R_COMP_CROP) + if (rd->scemode & R_COMP_CROP) buf= get_cropped_compbuf(&rd->disprect, fp, rectx, recty, buftype); else { buf= alloc_compbuf(rectx, recty, buftype, 0); @@ -394,58 +394,58 @@ static CompBuf *compbuf_from_pass(RenderData *rd, RenderLayer *rl, int rectx, in static void node_composit_rlayers_out(RenderData *rd, RenderLayer *rl, bNodeStack **out, int rectx, int recty) { - if(out[RRES_OUT_Z]->hasoutput) + if (out[RRES_OUT_Z]->hasoutput) out[RRES_OUT_Z]->data= compbuf_from_pass(rd, rl, rectx, recty, SCE_PASS_Z); - if(out[RRES_OUT_VEC]->hasoutput) + if (out[RRES_OUT_VEC]->hasoutput) out[RRES_OUT_VEC]->data= compbuf_from_pass(rd, rl, rectx, recty, SCE_PASS_VECTOR); - if(out[RRES_OUT_NORMAL]->hasoutput) + if (out[RRES_OUT_NORMAL]->hasoutput) out[RRES_OUT_NORMAL]->data= compbuf_from_pass(rd, rl, rectx, recty, SCE_PASS_NORMAL); - if(out[RRES_OUT_UV]->hasoutput) + if (out[RRES_OUT_UV]->hasoutput) out[RRES_OUT_UV]->data= compbuf_from_pass(rd, rl, rectx, recty, SCE_PASS_UV); - if(out[RRES_OUT_RGBA]->hasoutput) + if (out[RRES_OUT_RGBA]->hasoutput) out[RRES_OUT_RGBA]->data= compbuf_from_pass(rd, rl, rectx, recty, SCE_PASS_RGBA); - if(out[RRES_OUT_DIFF]->hasoutput) + if (out[RRES_OUT_DIFF]->hasoutput) out[RRES_OUT_DIFF]->data= compbuf_from_pass(rd, rl, rectx, recty, SCE_PASS_DIFFUSE); - if(out[RRES_OUT_SPEC]->hasoutput) + if (out[RRES_OUT_SPEC]->hasoutput) out[RRES_OUT_SPEC]->data= compbuf_from_pass(rd, rl, rectx, recty, SCE_PASS_SPEC); - if(out[RRES_OUT_SHADOW]->hasoutput) + if (out[RRES_OUT_SHADOW]->hasoutput) out[RRES_OUT_SHADOW]->data= compbuf_from_pass(rd, rl, rectx, recty, SCE_PASS_SHADOW); - if(out[RRES_OUT_AO]->hasoutput) + if (out[RRES_OUT_AO]->hasoutput) out[RRES_OUT_AO]->data= compbuf_from_pass(rd, rl, rectx, recty, SCE_PASS_AO); - if(out[RRES_OUT_REFLECT]->hasoutput) + if (out[RRES_OUT_REFLECT]->hasoutput) out[RRES_OUT_REFLECT]->data= compbuf_from_pass(rd, rl, rectx, recty, SCE_PASS_REFLECT); - if(out[RRES_OUT_REFRACT]->hasoutput) + if (out[RRES_OUT_REFRACT]->hasoutput) out[RRES_OUT_REFRACT]->data= compbuf_from_pass(rd, rl, rectx, recty, SCE_PASS_REFRACT); - if(out[RRES_OUT_INDIRECT]->hasoutput) + if (out[RRES_OUT_INDIRECT]->hasoutput) out[RRES_OUT_INDIRECT]->data= compbuf_from_pass(rd, rl, rectx, recty, SCE_PASS_INDIRECT); - if(out[RRES_OUT_INDEXOB]->hasoutput) + if (out[RRES_OUT_INDEXOB]->hasoutput) out[RRES_OUT_INDEXOB]->data= compbuf_from_pass(rd, rl, rectx, recty, SCE_PASS_INDEXOB); - if(out[RRES_OUT_INDEXMA]->hasoutput) + if (out[RRES_OUT_INDEXMA]->hasoutput) out[RRES_OUT_INDEXMA]->data= compbuf_from_pass(rd, rl, rectx, recty, SCE_PASS_INDEXMA); - if(out[RRES_OUT_MIST]->hasoutput) + if (out[RRES_OUT_MIST]->hasoutput) out[RRES_OUT_MIST]->data= compbuf_from_pass(rd, rl, rectx, recty, SCE_PASS_MIST); - if(out[RRES_OUT_EMIT]->hasoutput) + if (out[RRES_OUT_EMIT]->hasoutput) out[RRES_OUT_EMIT]->data= compbuf_from_pass(rd, rl, rectx, recty, SCE_PASS_EMIT); - if(out[RRES_OUT_ENV]->hasoutput) + if (out[RRES_OUT_ENV]->hasoutput) out[RRES_OUT_ENV]->data= compbuf_from_pass(rd, rl, rectx, recty, SCE_PASS_ENVIRONMENT); - if(out[RRES_OUT_DIFF_DIRECT]->hasoutput) + if (out[RRES_OUT_DIFF_DIRECT]->hasoutput) out[RRES_OUT_DIFF_DIRECT]->data= compbuf_from_pass(rd, rl, rectx, recty, SCE_PASS_DIFFUSE_DIRECT); - if(out[RRES_OUT_DIFF_INDIRECT]->hasoutput) + if (out[RRES_OUT_DIFF_INDIRECT]->hasoutput) out[RRES_OUT_DIFF_INDIRECT]->data= compbuf_from_pass(rd, rl, rectx, recty, SCE_PASS_DIFFUSE_INDIRECT); - if(out[RRES_OUT_DIFF_COLOR]->hasoutput) + if (out[RRES_OUT_DIFF_COLOR]->hasoutput) out[RRES_OUT_DIFF_COLOR]->data= compbuf_from_pass(rd, rl, rectx, recty, SCE_PASS_DIFFUSE_COLOR); - if(out[RRES_OUT_GLOSSY_DIRECT]->hasoutput) + if (out[RRES_OUT_GLOSSY_DIRECT]->hasoutput) out[RRES_OUT_GLOSSY_DIRECT]->data= compbuf_from_pass(rd, rl, rectx, recty, SCE_PASS_GLOSSY_DIRECT); - if(out[RRES_OUT_GLOSSY_INDIRECT]->hasoutput) + if (out[RRES_OUT_GLOSSY_INDIRECT]->hasoutput) out[RRES_OUT_GLOSSY_INDIRECT]->data= compbuf_from_pass(rd, rl, rectx, recty, SCE_PASS_GLOSSY_INDIRECT); - if(out[RRES_OUT_GLOSSY_COLOR]->hasoutput) + if (out[RRES_OUT_GLOSSY_COLOR]->hasoutput) out[RRES_OUT_GLOSSY_COLOR]->data= compbuf_from_pass(rd, rl, rectx, recty, SCE_PASS_GLOSSY_COLOR); - if(out[RRES_OUT_TRANSM_DIRECT]->hasoutput) + if (out[RRES_OUT_TRANSM_DIRECT]->hasoutput) out[RRES_OUT_TRANSM_DIRECT]->data= compbuf_from_pass(rd, rl, rectx, recty, SCE_PASS_TRANSM_DIRECT); - if(out[RRES_OUT_TRANSM_INDIRECT]->hasoutput) + if (out[RRES_OUT_TRANSM_INDIRECT]->hasoutput) out[RRES_OUT_TRANSM_INDIRECT]->data= compbuf_from_pass(rd, rl, rectx, recty, SCE_PASS_TRANSM_INDIRECT); - if(out[RRES_OUT_TRANSM_COLOR]->hasoutput) + if (out[RRES_OUT_TRANSM_COLOR]->hasoutput) out[RRES_OUT_TRANSM_COLOR]->data= compbuf_from_pass(rd, rl, rectx, recty, SCE_PASS_TRANSM_COLOR); } @@ -456,24 +456,24 @@ static void node_composit_exec_rlayers(void *data, bNode *node, bNodeStack **UNU RenderData *rd= data; RenderResult *rr= NULL; - if(re) + if (re) rr= RE_AcquireResultRead(re); - if(rr) { + if (rr) { SceneRenderLayer *srl= BLI_findlink(&sce->r.layers, node->custom1); - if(srl) { + if (srl) { RenderLayer *rl= RE_GetRenderLayer(rr, srl->name); - if(rl && rl->rectf) { + if (rl && rl->rectf) { CompBuf *stackbuf; /* we put render rect on stack, cbuf knows rect is from other ibuf when freed! */ - if(rd->scemode & R_COMP_CROP) + if (rd->scemode & R_COMP_CROP) stackbuf= get_cropped_compbuf(&rd->disprect, rl->rectf, rr->rectx, rr->recty, CB_RGBA); else { stackbuf= alloc_compbuf(rr->rectx, rr->recty, CB_RGBA, 0); stackbuf->rect= rl->rectf; } - if(stackbuf==NULL) { + if (stackbuf==NULL) { printf("Error; Preview Panel in UV Window returns zero sized image\n"); } else { @@ -483,7 +483,7 @@ static void node_composit_exec_rlayers(void *data, bNode *node, bNodeStack **UNU /* put on stack */ out[RRES_OUT_IMAGE]->data= stackbuf; - if(out[RRES_OUT_ALPHA]->hasoutput) + if (out[RRES_OUT_ALPHA]->hasoutput) out[RRES_OUT_ALPHA]->data= valbuf_from_rgbabuf(stackbuf, CHAN_A); node_composit_rlayers_out(rd, rl, out, rr->rectx, rr->recty); @@ -494,7 +494,7 @@ static void node_composit_exec_rlayers(void *data, bNode *node, bNodeStack **UNU } } - if(re) + if (re) RE_ReleaseResult(re); } diff --git a/source/blender/nodes/composite/nodes/node_composite_invert.c b/source/blender/nodes/composite/nodes/node_composite_invert.c index 4fda90e0a1e..8f3a6fc2e25 100644 --- a/source/blender/nodes/composite/nodes/node_composite_invert.c +++ b/source/blender/nodes/composite/nodes/node_composite_invert.c @@ -45,14 +45,16 @@ static bNodeSocketTemplate cmp_node_invert_out[]= { static void do_invert(bNode *node, float *out, float *in) { - if(node->custom1 & CMP_CHAN_RGB) { + if (node->custom1 & CMP_CHAN_RGB) { out[0] = 1.0f - in[0]; out[1] = 1.0f - in[1]; out[2] = 1.0f - in[2]; - } else + } + else { copy_v3_v3(out, in); + } - if(node->custom1 & CMP_CHAN_A) + if (node->custom1 & CMP_CHAN_A) out[3] = 1.0f - in[3]; else out[3] = in[3]; @@ -67,12 +69,12 @@ static void do_invert_fac(bNode *node, float *out, float *in, float *fac) /* blend inverted result against original input with fac */ facm = 1.0f - fac[0]; - if(node->custom1 & CMP_CHAN_RGB) { + if (node->custom1 & CMP_CHAN_RGB) { col[0] = fac[0]*col[0] + (facm*in[0]); col[1] = fac[0]*col[1] + (facm*in[1]); col[2] = fac[0]*col[2] + (facm*in[2]); } - if(node->custom1 & CMP_CHAN_A) + if (node->custom1 & CMP_CHAN_A) col[3] = fac[0]*col[3] + (facm*in[3]); copy_v4_v4(out, col); @@ -84,10 +86,10 @@ static void node_composit_exec_invert(void *UNUSED(data), bNode *node, bNodeStac /* stack order out: Image */ float *fac= in[0]->vec; - if(out[0]->hasoutput==0) return; + if (out[0]->hasoutput==0) return; /* input no image? then only color operation */ - if(in[1]->data==NULL && in[0]->data==NULL) { + if (in[1]->data==NULL && in[0]->data==NULL) { do_invert_fac(node, out[0]->vec, in[1]->vec, fac); } else { @@ -105,7 +107,8 @@ static void node_composit_exec_invert(void *UNUSED(data), bNode *node, bNodeStac out[0]->data= stackbuf; return; - } else { + } + else { out[0]->data = pass_on_compbuf(cbuf); return; } diff --git a/source/blender/nodes/composite/nodes/node_composite_levels.c b/source/blender/nodes/composite/nodes/node_composite_levels.c index 9417e504a1b..ec6d2006296 100644 --- a/source/blender/nodes/composite/nodes/node_composite_levels.c +++ b/source/blender/nodes/composite/nodes/node_composite_levels.c @@ -57,13 +57,13 @@ static void fill_bins(bNode* node, CompBuf* in, int* bins) int x,y; /*fill bins */ - for(y=0; y<in->y; y++) { - for(x=0; x<in->x; x++) { + for (y=0; y<in->y; y++) { + for (x=0; x<in->x; x++) { /* get the pixel */ qd_getPixel(in, x, y, value); - if(value[3] > 0.0f) { /* don't count transparent pixels */ + if (value[3] > 0.0f) { /* don't count transparent pixels */ switch(node->custom1) { case 1: { /* all colors */ rgb_tobw(value[0],value[1],value[2], &value[0]); @@ -97,8 +97,8 @@ static void fill_bins(bNode* node, CompBuf* in, int* bins) } /*end switch */ /*clip*/ - if(ivalue<0) ivalue=0; - if(ivalue>255) ivalue=255; + if (ivalue<0) ivalue=0; + if (ivalue>255) ivalue=255; /*put in the correct bin*/ bins[ivalue]+=1; @@ -114,13 +114,13 @@ static float brightness_mean(bNode* node, CompBuf* in) int x,y; float value[4]; - for(x=0; x< in->x; x++) { - for(y=0; y < in->y; y++) { + for (x=0; x< in->x; x++) { + for (y=0; y < in->y; y++) { /* get the pixel */ qd_getPixel(in, x, y, value); - if(value[3] > 0.0f) { /* don't count transparent pixels */ + if (value[3] > 0.0f) { /* don't count transparent pixels */ numPixels++; switch(node->custom1) { @@ -166,13 +166,13 @@ static float brightness_standard_deviation(bNode* node, CompBuf* in, float mean) int x,y; float value[4]; - for(x=0; x< in->x; x++) { - for(y=0; y < in->y; y++) { + for (x=0; x< in->x; x++) { + for (y=0; y < in->y; y++) { /* get the pixel */ qd_getPixel(in, x, y, value); - if(value[3] > 0.0f) { /* don't count transparent pixels */ + if (value[3] > 0.0f) { /* don't count transparent pixels */ numPixels++; switch(node->custom1) { @@ -224,18 +224,18 @@ static void draw_histogram(bNode *node, CompBuf *out, int* bins) /* find max value */ max=0; - for(x=0; x<256; x++) { - if(bins[x]>max) max=bins[x]; + for (x=0; x<256; x++) { + if (bins[x]>max) max=bins[x]; } /*draw histogram in buffer */ - for(x=0; x<out->x; x++) { - for(y=0;y<out->y; y++) { + for (x=0; x<out->x; x++) { + for (y=0;y<out->y; y++) { /* get normalized value (0..255) */ value=((float)bins[x]/(float)max)*255.0f; - if(y < (int)value) { /*if the y value is below the height of the bar for this line then draw with the color */ + if (y < (int)value) { /*if the y value is below the height of the bar for this line then draw with the color */ switch (node->custom1) { case 1: { /* draw in black */ color[0]=0.0; color[1]=0.0; color[2]=0.0; color[3]=1.0; @@ -259,7 +259,7 @@ static void draw_histogram(bNode *node, CompBuf *out, int* bins) } } } - else{ + else { color[0]=0.8; color[1]=0.8; color[2]=0.8; color[3]=1.0; } @@ -277,14 +277,14 @@ static void node_composit_exec_view_levels(void *data, bNode *node, bNodeStack * int bins[256]; int x; - if(in[0]->hasinput==0) return; - if(in[0]->data==NULL) return; + if (in[0]->hasinput==0) return; + if (in[0]->data==NULL) return; histogram=alloc_compbuf(256, 256, CB_RGBA, 1); cbuf=typecheck_compbuf(in[0]->data, CB_RGBA); /*initalize bins*/ - for(x=0; x<256; x++) { + for (x=0; x<256; x++) { bins[x]=0; } @@ -303,14 +303,14 @@ static void node_composit_exec_view_levels(void *data, bNode *node, bNodeStack * printf("Std Dev: %f\n", std_dev); */ - if(out[0]->hasoutput) + if (out[0]->hasoutput) out[0]->vec[0]= mean; - if(out[1]->hasoutput) + if (out[1]->hasoutput) out[1]->vec[0]= std_dev; generate_preview(data, node, histogram); - if(cbuf!=in[0]->data) + if (cbuf!=in[0]->data) free_compbuf(cbuf); free_compbuf(histogram); } diff --git a/source/blender/nodes/composite/nodes/node_composite_lummaMatte.c b/source/blender/nodes/composite/nodes/node_composite_lummaMatte.c index ad5e9d423e5..85c291fd9ec 100644 --- a/source/blender/nodes/composite/nodes/node_composite_lummaMatte.c +++ b/source/blender/nodes/composite/nodes/node_composite_lummaMatte.c @@ -51,10 +51,10 @@ static void do_luma_matte(bNode *node, float *out, float *in) float alpha; /* test range*/ - if(in[0]>c->t1) { + if (in[0]>c->t1) { alpha=1.0; } - else if(in[0]<c->t2){ + else if (in[0]<c->t2) { alpha=0.0; } else {/*blend */ @@ -76,9 +76,9 @@ static void node_composit_exec_luma_matte(void *data, bNode *node, bNodeStack ** CompBuf *cbuf; CompBuf *outbuf; - if(in[0]->hasinput==0) return; - if(in[0]->data==NULL) return; - if(out[0]->hasoutput==0 && out[1]->hasoutput==0) return; + if (in[0]->hasinput==0) return; + if (in[0]->data==NULL) return; + if (out[0]->hasoutput==0 && out[1]->hasoutput==0) return; cbuf=typecheck_compbuf(in[0]->data, CB_RGBA); @@ -92,7 +92,7 @@ static void node_composit_exec_luma_matte(void *data, bNode *node, bNodeStack ** out[0]->data=outbuf; if (out[1]->hasoutput) out[1]->data=valbuf_from_rgbabuf(outbuf, CHAN_A); - if(cbuf!=in[0]->data) + if (cbuf!=in[0]->data) free_compbuf(cbuf); } diff --git a/source/blender/nodes/composite/nodes/node_composite_mapUV.c b/source/blender/nodes/composite/nodes/node_composite_mapUV.c index 1ca729c8393..7d62e6b8030 100644 --- a/source/blender/nodes/composite/nodes/node_composite_mapUV.c +++ b/source/blender/nodes/composite/nodes/node_composite_mapUV.c @@ -64,10 +64,10 @@ static void do_mapuv(CompBuf *stackbuf, CompBuf *cbuf, CompBuf *uvbuf, float thr sx= stackbuf->x; sy= stackbuf->y; - for(y=0; y<sy; y++) { - for(x=0; x<sx; x++, out+=4, uv+=3, uvnext+=3, uvprev+=3) { - if(x>0 && x<sx-1 && y>0 && y<sy-1) { - if(uv[2]!=0.0f) { + for (y=0; y<sy; y++) { + for (x=0; x<sx; x++, out+=4, uv+=3, uvnext+=3, uvprev+=3) { + if (x>0 && x<sx-1 && y>0 && y<sy-1) { + if (uv[2]!=0.0f) { float uv_l, uv_r; /* adaptive sampling, red (U) channel */ @@ -113,16 +113,16 @@ static void do_mapuv(CompBuf *stackbuf, CompBuf *cbuf, CompBuf *uvbuf, float thr /* UV to alpha threshold */ alpha= 1.0f - threshold*(dx+dy); - if(alpha<0.0f) alpha= 0.0f; + if (alpha<0.0f) alpha= 0.0f; else alpha*= uv[2]; /* should use mipmap */ - if(dx > 0.20f) dx= 0.20f; - if(dy > 0.20f) dy= 0.20f; + if (dx > 0.20f) dx= 0.20f; + if (dy > 0.20f) dy= 0.20f; ibuf_sample(ibuf, uv[0], uv[1], dx, dy, out); /* premul */ - if(alpha<1.0f) { + if (alpha<1.0f) { out[0]*= alpha; out[1]*= alpha; out[2]*= alpha; @@ -139,10 +139,10 @@ static void do_mapuv(CompBuf *stackbuf, CompBuf *cbuf, CompBuf *uvbuf, float thr static void node_composit_exec_mapuv(void *UNUSED(data), bNode *node, bNodeStack **in, bNodeStack **out) { - if(out[0]->hasoutput==0) + if (out[0]->hasoutput==0) return; - if(in[0]->data && in[1]->data) { + if (in[0]->data && in[1]->data) { CompBuf *cbuf= in[0]->data; CompBuf *uvbuf= in[1]->data; CompBuf *stackbuf; @@ -155,9 +155,9 @@ static void node_composit_exec_mapuv(void *UNUSED(data), bNode *node, bNodeStack out[0]->data= stackbuf; - if(cbuf!=in[0]->data) + if (cbuf!=in[0]->data) free_compbuf(cbuf); - if(uvbuf!=in[1]->data) + if (uvbuf!=in[1]->data) free_compbuf(uvbuf); } } diff --git a/source/blender/nodes/composite/nodes/node_composite_mapValue.c b/source/blender/nodes/composite/nodes/node_composite_mapValue.c index 380aa0b716b..2fd115261f8 100644 --- a/source/blender/nodes/composite/nodes/node_composite_mapValue.c +++ b/source/blender/nodes/composite/nodes/node_composite_mapValue.c @@ -47,11 +47,11 @@ static void do_map_value(bNode *node, float *out, float *src) TexMapping *texmap= node->storage; out[0]= (src[0] + texmap->loc[0])*texmap->size[0]; - if(texmap->flag & TEXMAP_CLIP_MIN) - if(out[0]<texmap->min[0]) + if (texmap->flag & TEXMAP_CLIP_MIN) + if (out[0]<texmap->min[0]) out[0]= texmap->min[0]; - if(texmap->flag & TEXMAP_CLIP_MAX) - if(out[0]>texmap->max[0]) + if (texmap->flag & TEXMAP_CLIP_MAX) + if (out[0]>texmap->max[0]) out[0]= texmap->max[0]; } @@ -59,10 +59,10 @@ static void node_composit_exec_map_value(void *UNUSED(data), bNode *node, bNodeS { /* stack order in: valbuf */ /* stack order out: valbuf */ - if(out[0]->hasoutput==0) return; + if (out[0]->hasoutput==0) return; /* input no image? then only value operation */ - if(in[0]->data==NULL) { + if (in[0]->data==NULL) { do_map_value(node, out[0]->vec, in[0]->vec); } else { diff --git a/source/blender/nodes/composite/nodes/node_composite_math.c b/source/blender/nodes/composite/nodes/node_composite_math.c index 6c2cbb9a92b..6f3d2f6baaf 100644 --- a/source/blender/nodes/composite/nodes/node_composite_math.c +++ b/source/blender/nodes/composite/nodes/node_composite_math.c @@ -59,7 +59,7 @@ static void do_math(bNode *node, float *out, float *in, float *in2) break; case 3: /* Divide */ { - if(in2[0]==0) /* We don't want to divide by zero. */ + if (in2[0]==0) /* We don't want to divide by zero. */ out[0]= 0.0; else out[0]= in[0] / in2[0]; @@ -77,7 +77,7 @@ static void do_math(bNode *node, float *out, float *in, float *in2) case 7: /* Arc-Sine */ { /* Can't do the impossible... */ - if(in[0] <= 1 && in[0] >= -1 ) + if (in[0] <= 1 && in[0] >= -1 ) out[0]= asin(in[0]); else out[0]= 0.0; @@ -86,7 +86,7 @@ static void do_math(bNode *node, float *out, float *in, float *in2) case 8: /* Arc-Cosine */ { /* Can't do the impossible... */ - if( in[0] <= 1 && in[0] >= -1 ) + if ( in[0] <= 1 && in[0] >= -1 ) out[0]= acos(in[0]); else out[0]= 0.0; @@ -98,14 +98,16 @@ static void do_math(bNode *node, float *out, float *in, float *in2) case 10: /* Power */ { /* Only raise negative numbers by full integers */ - if( in[0] >= 0 ) { + if ( in[0] >= 0 ) { out[0]= pow(in[0], in2[0]); - } else { + } + else { float y_mod_1 = fmod(in2[0], 1); /* if input value is not nearly an integer, fall back to zero, nicer than straight rounding */ if (y_mod_1 > 0.999f || y_mod_1 < 0.001f) { out[0]= powf(in[0], floorf(in2[0] + 0.5f)); - } else { + } + else { out[0] = 0.0f; } } @@ -114,7 +116,7 @@ static void do_math(bNode *node, float *out, float *in, float *in2) case 11: /* Logarithm */ { /* Don't want any imaginary numbers... */ - if( in[0] > 0 && in2[0] > 0 ) + if ( in[0] > 0 && in2[0] > 0 ) out[0]= log(in[0]) / log(in2[0]); else out[0]= 0.0; @@ -122,7 +124,7 @@ static void do_math(bNode *node, float *out, float *in, float *in2) break; case 12: /* Minimum */ { - if( in[0] < in2[0] ) + if ( in[0] < in2[0] ) out[0]= in[0]; else out[0]= in2[0]; @@ -130,7 +132,7 @@ static void do_math(bNode *node, float *out, float *in, float *in2) break; case 13: /* Maximum */ { - if( in[0] > in2[0] ) + if ( in[0] > in2[0] ) out[0]= in[0]; else out[0]= in2[0]; @@ -139,7 +141,7 @@ static void do_math(bNode *node, float *out, float *in, float *in2) case 14: /* Round */ { /* round by the second value */ - if( in2[0] != 0.0f ) + if ( in2[0] != 0.0f ) out[0]= floorf(in[0] / in2[0] + 0.5f) * in2[0]; else out[0]= floorf(in[0] + 0.5f); @@ -147,7 +149,7 @@ static void do_math(bNode *node, float *out, float *in, float *in2) break; case 15: /* Less Than */ { - if( in[0] < in2[0] ) + if ( in[0] < in2[0] ) out[0]= 1.0f; else out[0]= 0.0f; @@ -155,7 +157,7 @@ static void do_math(bNode *node, float *out, float *in, float *in2) break; case 16: /* Greater Than */ { - if( in[0] > in2[0] ) + if ( in[0] > in2[0] ) out[0]= 1.0f; else out[0]= 0.0f; @@ -171,16 +173,16 @@ static void node_composit_exec_math(void *UNUSED(data), bNode *node, bNodeStack CompBuf *stackbuf; /* check for inputs and outputs for early out*/ - if(out[0]->hasoutput==0) return; + if (out[0]->hasoutput==0) return; /* no image-color operation */ - if(in[0]->data==NULL && in[1]->data==NULL) { + if (in[0]->data==NULL && in[1]->data==NULL) { do_math(node, out[0]->vec, in[0]->vec, in[1]->vec); return; } /*create output based on first input */ - if(cbuf) { + if (cbuf) { stackbuf=alloc_compbuf(cbuf->x, cbuf->y, CB_VAL, 1); } /* and if it doesn't exist use the second input since we diff --git a/source/blender/nodes/composite/nodes/node_composite_mixrgb.c b/source/blender/nodes/composite/nodes/node_composite_mixrgb.c index 0296fa417d6..6539e81beec 100644 --- a/source/blender/nodes/composite/nodes/node_composite_mixrgb.c +++ b/source/blender/nodes/composite/nodes/node_composite_mixrgb.c @@ -48,7 +48,7 @@ static void do_mix_rgb(bNode *node, float *out, float *in1, float *in2, float *f float col[3]; copy_v3_v3(col, in1); - if(node->custom2) + if (node->custom2) ramp_blend(node->custom1, col, in2[3]*fac[0], in2); else ramp_blend(node->custom1, col, fac[0], in2); @@ -62,10 +62,10 @@ static void node_composit_exec_mix_rgb(void *data, bNode *node, bNodeStack **in, /* stack order out: Image */ float *fac= in[0]->vec; - if(out[0]->hasoutput==0) return; + if (out[0]->hasoutput==0) return; /* input no image? then only color operation */ - if(in[1]->data==NULL && in[2]->data==NULL) { + if (in[1]->data==NULL && in[2]->data==NULL) { do_mix_rgb(node, out[0]->vec, in[1]->vec, in[2]->vec, fac); } else { diff --git a/source/blender/nodes/composite/nodes/node_composite_movieclip.c b/source/blender/nodes/composite/nodes/node_composite_movieclip.c index 6ec64ef7c09..dd2c169fe9a 100644 --- a/source/blender/nodes/composite/nodes/node_composite_movieclip.c +++ b/source/blender/nodes/composite/nodes/node_composite_movieclip.c @@ -53,7 +53,7 @@ static CompBuf *node_composit_get_movieclip(RenderData *rd, MovieClip *clip, Mov orig_ibuf= BKE_movieclip_get_ibuf(clip, user); - if(orig_ibuf==NULL || (orig_ibuf->rect==NULL && orig_ibuf->rect_float==NULL)) { + if (orig_ibuf==NULL || (orig_ibuf->rect==NULL && orig_ibuf->rect_float==NULL)) { IMB_freeImBuf(orig_ibuf); return NULL; } @@ -67,7 +67,7 @@ static CompBuf *node_composit_get_movieclip(RenderData *rd, MovieClip *clip, Mov } /* now we need a float buffer from the image with matching color management */ - if(ibuf->channels == 4) { + if (ibuf->channels == 4) { rect= node_composit_get_float_buffer(rd, ibuf, &alloc); } else { @@ -76,16 +76,16 @@ static CompBuf *node_composit_get_movieclip(RenderData *rd, MovieClip *clip, Mov } /* done coercing into the correct color management */ - if(!alloc) { + if (!alloc) { rect= MEM_dupallocN(rect); alloc= 1; } type= ibuf->channels; - if(rd->scemode & R_COMP_CROP) { + if (rd->scemode & R_COMP_CROP) { stackbuf= get_cropped_compbuf(&rd->disprect, rect, ibuf->x, ibuf->y, type); - if(alloc) + if (alloc) MEM_freeN(rect); } else { @@ -102,7 +102,7 @@ static CompBuf *node_composit_get_movieclip(RenderData *rd, MovieClip *clip, Mov static void node_composit_exec_movieclip(void *data, bNode *node, bNodeStack **UNUSED(in), bNodeStack **out) { - if(node->id) { + if (node->id) { RenderData *rd= data; MovieClip *clip= (MovieClip *)node->id; MovieClipUser *user= (MovieClipUser *)node->storage; @@ -118,7 +118,7 @@ static void node_composit_exec_movieclip(void *data, bNode *node, bNodeStack **U /* put image on stack */ out[0]->data= stackbuf; - if(stab->flag&TRACKING_2D_STABILIZATION) { + if (stab->flag&TRACKING_2D_STABILIZATION) { float loc[2], scale, angle; BKE_tracking_stabilization_data(&clip->tracking, rd->cfra, stackbuf->x, stackbuf->y, diff --git a/source/blender/nodes/composite/nodes/node_composite_moviedistortion.c b/source/blender/nodes/composite/nodes/node_composite_moviedistortion.c index a0b7e62e644..d9f0da9b8aa 100644 --- a/source/blender/nodes/composite/nodes/node_composite_moviedistortion.c +++ b/source/blender/nodes/composite/nodes/node_composite_moviedistortion.c @@ -49,8 +49,8 @@ static bNodeSocketTemplate cmp_node_moviedistortion_out[]= { static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) { - if(in[0]->data) { - if(node->id) { + if (in[0]->data) { + if (node->id) { MovieClip *clip= (MovieClip *)node->id; CompBuf *cbuf= typecheck_compbuf(in[0]->data, CB_RGBA); CompBuf *stackbuf= alloc_compbuf(cbuf->x, cbuf->y, CB_RGBA, 0); @@ -58,7 +58,7 @@ static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) ibuf= IMB_allocImBuf(cbuf->x, cbuf->y, 32, 0); - if(ibuf) { + if (ibuf) { RenderData *rd= data; ImBuf *obuf; MovieTracking *tracking= &clip->tracking; @@ -72,10 +72,10 @@ static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) BKE_movieclip_get_size(clip, &user, &width, &height); - if(!node->storage) + if (!node->storage) node->storage= BKE_tracking_distortion_create(); - if(node->custom1==0) + if (node->custom1==0) obuf= BKE_tracking_distortion_exec(node->storage, tracking, ibuf, width, height, overscan, 1); else obuf= BKE_tracking_distortion_exec(node->storage, tracking, ibuf, width, height, overscan, 0); @@ -93,9 +93,10 @@ static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) /* pass on output and free */ out[0]->data= stackbuf; - if(cbuf!=in[0]->data) + if (cbuf!=in[0]->data) free_compbuf(cbuf); - } else { + } + else { CompBuf *cbuf= in[0]->data; CompBuf *stackbuf= pass_on_compbuf(cbuf); @@ -106,7 +107,7 @@ static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) static const char *label(bNode *node) { - if(node->custom1==0) + if (node->custom1==0) return IFACE_("Undistortion"); else return IFACE_("Distortion"); @@ -114,7 +115,7 @@ static const char *label(bNode *node) static void storage_free(bNode *node) { - if(node->storage) + if (node->storage) BKE_tracking_distortion_destroy(node->storage); node->storage= NULL; @@ -122,7 +123,7 @@ static void storage_free(bNode *node) static void storage_copy(bNode *orig_node, bNode *new_node) { - if(orig_node->storage) + if (orig_node->storage) new_node->storage= BKE_tracking_distortion_copy(orig_node->storage); } diff --git a/source/blender/nodes/composite/nodes/node_composite_normal.c b/source/blender/nodes/composite/nodes/node_composite_normal.c index 638f67c4207..e9b5f10172c 100644 --- a/source/blender/nodes/composite/nodes/node_composite_normal.c +++ b/source/blender/nodes/composite/nodes/node_composite_normal.c @@ -63,12 +63,12 @@ static void node_composit_exec_normal(void *UNUSED(data), bNode *node, bNodeStac /* stack order output: normal, value */ /* input no image? then only vector op */ - if(in[0]->data==NULL) { + if (in[0]->data==NULL) { copy_v3_v3(out[0]->vec, nor); /* render normals point inside... the widget points outside */ out[1]->vec[0]= -dot_v3v3(out[0]->vec, in[0]->vec); } - else if(out[1]->hasoutput) { + else if (out[1]->hasoutput) { /* make output size of input image */ CompBuf *cbuf= in[0]->data; CompBuf *stackbuf= alloc_compbuf(cbuf->x, cbuf->y, CB_VAL, 1); /* allocs */ diff --git a/source/blender/nodes/composite/nodes/node_composite_normalize.c b/source/blender/nodes/composite/nodes/node_composite_normalize.c index 455966e4f38..69386c3b816 100644 --- a/source/blender/nodes/composite/nodes/node_composite_normalize.c +++ b/source/blender/nodes/composite/nodes/node_composite_normalize.c @@ -65,10 +65,10 @@ static void node_composit_exec_normalize(void *UNUSED(data), bNode *node, bNodeS { /* stack order in: valbuf */ /* stack order out: valbuf */ - if(out[0]->hasoutput==0) return; + if (out[0]->hasoutput==0) return; /* Input has no image buffer? Then pass the value */ - if(in[0]->data==NULL) { + if (in[0]->data==NULL) { copy_v4_v4(out[0]->vec, in[0]->vec); } else { @@ -93,7 +93,8 @@ static void node_composit_exec_normalize(void *UNUSED(data), bNode *node, bNodeS if ((max-min) != 0.0f) { mult = 1.0f/(max-min); composit3_pixel_processor(node, stackbuf, in[0]->data, in[0]->vec, NULL, &min, NULL, &mult, do_normalize, CB_VAL, CB_VAL, CB_VAL); - } else { + } + else { memcpy(stackbuf->rect, cbuf->rect, sizeof(float) * cbuf->x * cbuf->y); } diff --git a/source/blender/nodes/composite/nodes/node_composite_outputFile.c b/source/blender/nodes/composite/nodes/node_composite_outputFile.c index fc92c3aabc8..e93c250e756 100644 --- a/source/blender/nodes/composite/nodes/node_composite_outputFile.c +++ b/source/blender/nodes/composite/nodes/node_composite_outputFile.c @@ -55,7 +55,7 @@ bNodeSocket *ntreeCompositOutputFileAddSocket(bNodeTree *ntree, bNode *node, con sock->storage = sockdata; sock->struct_type = SOCK_STRUCT_OUTPUT_FILE; - if(im_format) { + if (im_format) { sockdata->format= *im_format; if (BKE_imtype_is_movie(sockdata->format.imtype)) { sockdata->format.imtype= R_IMF_IMTYPE_OPENEXR; @@ -186,7 +186,7 @@ static void exec_output_file_singlelayer(RenderData *rd, bNode *node, bNodeStack BLI_join_dirfile(path, FILE_MAX, nimf->base_path, sock->name); BKE_makepicstring(filename, path, bmain->name, rd->cfra, format->imtype, (rd->scemode & R_EXTENSION), TRUE); - if(0 == BKE_write_ibuf(ibuf, filename, format)) + if (0 == BKE_write_ibuf(ibuf, filename, format)) printf("Cannot save Node File Output to %s\n", filename); else printf("Saved: %s\n", filename); @@ -199,7 +199,7 @@ static void exec_output_file_singlelayer(RenderData *rd, bNode *node, bNodeStack has_preview = 1; } - if(in[i]->data != cbuf) + if (in[i]->data != cbuf) free_compbuf(cbuf); } } @@ -287,7 +287,7 @@ static void exec_output_file_multilayer(RenderData *rd, bNode *node, bNodeStack } /* when the filename has no permissions, this can fail */ - if(IMB_exr_begin_write(exrhandle, filename, rectx, recty, nimf->format.exr_codec)) { + if (IMB_exr_begin_write(exrhandle, filename, rectx, recty, nimf->format.exr_codec)) { IMB_exr_write_channels(exrhandle); } else { diff --git a/source/blender/nodes/composite/nodes/node_composite_premulkey.c b/source/blender/nodes/composite/nodes/node_composite_premulkey.c index bf934fcd0f7..3d8b0108bbb 100644 --- a/source/blender/nodes/composite/nodes/node_composite_premulkey.c +++ b/source/blender/nodes/composite/nodes/node_composite_premulkey.c @@ -46,17 +46,17 @@ static bNodeSocketTemplate cmp_node_premulkey_out[]= { static void node_composit_exec_premulkey(void *UNUSED(data), bNode *node, bNodeStack **in, bNodeStack **out) { - if(out[0]->hasoutput==0) + if (out[0]->hasoutput==0) return; - if(in[0]->data) { + if (in[0]->data) { CompBuf *stackbuf, *cbuf= typecheck_compbuf(in[0]->data, CB_RGBA); stackbuf= dupalloc_compbuf(cbuf); premul_compbuf(stackbuf, node->custom1 == 1); out[0]->data = stackbuf; - if(cbuf != in[0]->data) + if (cbuf != in[0]->data) free_compbuf(cbuf); } } diff --git a/source/blender/nodes/composite/nodes/node_composite_rotate.c b/source/blender/nodes/composite/nodes/node_composite_rotate.c index 141fcef457f..6952817248d 100644 --- a/source/blender/nodes/composite/nodes/node_composite_rotate.c +++ b/source/blender/nodes/composite/nodes/node_composite_rotate.c @@ -48,10 +48,10 @@ static bNodeSocketTemplate cmp_node_rotate_out[]= { static void node_composit_exec_rotate(void *UNUSED(data), bNode *node, bNodeStack **in, bNodeStack **out) { - if(out[0]->hasoutput==0) + if (out[0]->hasoutput==0) return; - if(in[0]->data) { + if (in[0]->data) { CompBuf *cbuf= typecheck_compbuf(in[0]->data, CB_RGBA); CompBuf *stackbuf= alloc_compbuf(cbuf->x, cbuf->y, CB_RGBA, 1); /* note, this returns zero'd image */ float rad, u, v, s, c, centx, centy, miny, maxy, minx, maxx; @@ -75,14 +75,14 @@ static void node_composit_exec_rotate(void *UNUSED(data), bNode *node, bNodeStac ibuf=IMB_allocImBuf(cbuf->x, cbuf->y, 32, 0); obuf=IMB_allocImBuf(stackbuf->x, stackbuf->y, 32, 0); - if(ibuf && obuf){ + if (ibuf && obuf) { ibuf->rect_float=cbuf->rect; obuf->rect_float=stackbuf->rect; - for(y=miny; y<maxy; y++) { + for (y=miny; y<maxy; y++) { yo= y+(int)centy; - for(x=minx; x<maxx;x++) { + for (x=minx; x<maxx;x++) { u=c*x + y*s + centx; v=-s*x + c*y + centy; xo= x+(int)centx; @@ -115,7 +115,7 @@ static void node_composit_exec_rotate(void *UNUSED(data), bNode *node, bNodeStac /* pass on output and free */ out[0]->data= stackbuf; - if(cbuf!=in[0]->data) { + if (cbuf!=in[0]->data) { free_compbuf(cbuf); } } diff --git a/source/blender/nodes/composite/nodes/node_composite_scale.c b/source/blender/nodes/composite/nodes/node_composite_scale.c index 188449df5fb..b28f6a91dab 100644 --- a/source/blender/nodes/composite/nodes/node_composite_scale.c +++ b/source/blender/nodes/composite/nodes/node_composite_scale.c @@ -49,27 +49,28 @@ static bNodeSocketTemplate cmp_node_scale_out[]= { /* node->custom1 stores if input values are absolute or relative scale */ static void node_composit_exec_scale(void *data, bNode *node, bNodeStack **in, bNodeStack **out) { - if(out[0]->hasoutput==0) + if (out[0]->hasoutput==0) return; - if(in[0]->data) { + if (in[0]->data) { RenderData *rd= data; CompBuf *stackbuf, *cbuf= typecheck_compbuf(in[0]->data, CB_RGBA); ImBuf *ibuf; int newx, newy; - if(node->custom1==CMP_SCALE_RELATIVE) { + if (node->custom1==CMP_SCALE_RELATIVE) { newx= MAX2((int)(in[1]->vec[0]*cbuf->x), 1); newy= MAX2((int)(in[2]->vec[0]*cbuf->y), 1); } - else if(node->custom1==CMP_SCALE_SCENEPERCENT) { + else if (node->custom1==CMP_SCALE_SCENEPERCENT) { newx = cbuf->x * (rd->size / 100.0f); newy = cbuf->y * (rd->size / 100.0f); } else if (node->custom1==CMP_SCALE_RENDERPERCENT) { newx= (rd->xsch * rd->size)/100; newy= (rd->ysch * rd->size)/100; - } else { /* CMP_SCALE_ABSOLUTE */ + } + else { /* CMP_SCALE_ABSOLUTE */ newx= MAX2((int)in[1]->vec[0], 1); newy= MAX2((int)in[2]->vec[0], 1); } @@ -77,11 +78,11 @@ static void node_composit_exec_scale(void *data, bNode *node, bNodeStack **in, b newy= MIN2(newy, CMP_SCALE_MAX); ibuf= IMB_allocImBuf(cbuf->x, cbuf->y, 32, 0); - if(ibuf) { + if (ibuf) { ibuf->rect_float= cbuf->rect; IMB_scaleImBuf(ibuf, newx, newy); - if(ibuf->rect_float == cbuf->rect) { + if (ibuf->rect_float == cbuf->rect) { /* no scaling happened. */ stackbuf= pass_on_compbuf(in[0]->data); } @@ -105,7 +106,7 @@ static void node_composit_exec_scale(void *data, bNode *node, bNodeStack **in, b } out[0]->data= stackbuf; - if(cbuf!=in[0]->data) + if (cbuf!=in[0]->data) free_compbuf(cbuf); } else if (node->custom1==CMP_SCALE_ABSOLUTE) { diff --git a/source/blender/nodes/composite/nodes/node_composite_sepcombHSVA.c b/source/blender/nodes/composite/nodes/node_composite_sepcombHSVA.c index cde54cfd132..6dac2d16401 100644 --- a/source/blender/nodes/composite/nodes/node_composite_sepcombHSVA.c +++ b/source/blender/nodes/composite/nodes/node_composite_sepcombHSVA.c @@ -64,7 +64,7 @@ static void node_composit_exec_sephsva(void *UNUSED(data), bNode *node, bNodeSta /* stack order in: col */ /* input no image? then only color operation */ - if(in[0]->data==NULL) { + if (in[0]->data==NULL) { float h, s, v; rgb_to_hsv(in[0]->vec[0], in[0]->vec[1], in[0]->vec[2], &h, &s, &v); @@ -83,17 +83,17 @@ static void node_composit_exec_sephsva(void *UNUSED(data), bNode *node, bNodeSta composit1_pixel_processor(node, cbuf2, cbuf2, in[0]->vec, do_sephsva, CB_RGBA); /* separate each of those channels */ - if(out[0]->hasoutput) + if (out[0]->hasoutput) out[0]->data= valbuf_from_rgbabuf(cbuf2, CHAN_R); - if(out[1]->hasoutput) + if (out[1]->hasoutput) out[1]->data= valbuf_from_rgbabuf(cbuf2, CHAN_G); - if(out[2]->hasoutput) + if (out[2]->hasoutput) out[2]->data= valbuf_from_rgbabuf(cbuf2, CHAN_B); - if(out[3]->hasoutput) + if (out[3]->hasoutput) out[3]->data= valbuf_from_rgbabuf(cbuf2, CHAN_A); /*not used anymore */ - if(cbuf2!=cbuf) + if (cbuf2!=cbuf) free_compbuf(cbuf2); free_compbuf(cbuf); } @@ -142,7 +142,7 @@ static void node_composit_exec_combhsva(void *UNUSED(data), bNode *node, bNodeSt /* stack order in: 4 value channels */ /* input no image? then only color operation in HSV */ - if((in[0]->data==NULL) && (in[1]->data==NULL) && (in[2]->data==NULL) && (in[3]->data==NULL)) { + if ((in[0]->data==NULL) && (in[1]->data==NULL) && (in[2]->data==NULL) && (in[3]->data==NULL)) { hsv_to_rgb(in[0]->vec[0], in[1]->vec[0], in[2]->vec[0], &out[0]->vec[0], &out[0]->vec[1], &out[0]->vec[2]); out[0]->vec[3] = in[3]->vec[0]; diff --git a/source/blender/nodes/composite/nodes/node_composite_sepcombRGBA.c b/source/blender/nodes/composite/nodes/node_composite_sepcombRGBA.c index 1f0b504f161..be4a8ac76fe 100644 --- a/source/blender/nodes/composite/nodes/node_composite_sepcombRGBA.c +++ b/source/blender/nodes/composite/nodes/node_composite_sepcombRGBA.c @@ -51,7 +51,7 @@ static void node_composit_exec_seprgba(void *UNUSED(data), bNode *UNUSED(node), /* stack order in: col */ /* input no image? then only color operation */ - if(in[0]->data==NULL) { + if (in[0]->data==NULL) { out[0]->vec[0] = in[0]->vec[0]; out[1]->vec[0] = in[0]->vec[1]; out[2]->vec[0] = in[0]->vec[2]; @@ -62,16 +62,16 @@ static void node_composit_exec_seprgba(void *UNUSED(data), bNode *UNUSED(node), CompBuf *cbuf= typecheck_compbuf(in[0]->data, CB_RGBA); /* don't do any pixel processing, just copy the stack directly (faster, I presume) */ - if(out[0]->hasoutput) + if (out[0]->hasoutput) out[0]->data= valbuf_from_rgbabuf(cbuf, CHAN_R); - if(out[1]->hasoutput) + if (out[1]->hasoutput) out[1]->data= valbuf_from_rgbabuf(cbuf, CHAN_G); - if(out[2]->hasoutput) + if (out[2]->hasoutput) out[2]->data= valbuf_from_rgbabuf(cbuf, CHAN_B); - if(out[3]->hasoutput) + if (out[3]->hasoutput) out[3]->data= valbuf_from_rgbabuf(cbuf, CHAN_A); - if(cbuf!=in[0]->data) + if (cbuf!=in[0]->data) free_compbuf(cbuf); } @@ -118,7 +118,7 @@ static void node_composit_exec_combrgba(void *UNUSED(data), bNode *node, bNodeSt /* stack order in: 4 value channels */ /* input no image? then only color operation */ - if((in[0]->data==NULL) && (in[1]->data==NULL) && (in[2]->data==NULL) && (in[3]->data==NULL)) { + if ((in[0]->data==NULL) && (in[1]->data==NULL) && (in[2]->data==NULL) && (in[3]->data==NULL)) { out[0]->vec[0] = in[0]->vec[0]; out[0]->vec[1] = in[1]->vec[0]; out[0]->vec[2] = in[2]->vec[0]; diff --git a/source/blender/nodes/composite/nodes/node_composite_sepcombYCCA.c b/source/blender/nodes/composite/nodes/node_composite_sepcombYCCA.c index a5f827b094d..b12f08bb13d 100644 --- a/source/blender/nodes/composite/nodes/node_composite_sepcombYCCA.c +++ b/source/blender/nodes/composite/nodes/node_composite_sepcombYCCA.c @@ -88,7 +88,7 @@ static void do_sepycca_jfif(bNode *UNUSED(node), float *out, float *in) static void node_composit_exec_sepycca(void *UNUSED(data), bNode *node, bNodeStack **in, bNodeStack **out) { /* input no image? then only color operation */ - if(in[0]->data==NULL) { + if (in[0]->data==NULL) { float y, cb, cr; switch(node->custom1) @@ -132,17 +132,17 @@ static void node_composit_exec_sepycca(void *UNUSED(data), bNode *node, bNodeSta } /* separate each of those channels */ - if(out[0]->hasoutput) + if (out[0]->hasoutput) out[0]->data= valbuf_from_rgbabuf(cbuf2, CHAN_R); - if(out[1]->hasoutput) + if (out[1]->hasoutput) out[1]->data= valbuf_from_rgbabuf(cbuf2, CHAN_G); - if(out[2]->hasoutput) + if (out[2]->hasoutput) out[2]->data= valbuf_from_rgbabuf(cbuf2, CHAN_B); - if(out[3]->hasoutput) + if (out[3]->hasoutput) out[3]->data= valbuf_from_rgbabuf(cbuf2, CHAN_A); /*not used anymore */ - if(cbuf2!=cbuf) + if (cbuf2!=cbuf) free_compbuf(cbuf2); free_compbuf(cbuf); } @@ -235,7 +235,7 @@ static void node_composit_exec_combycca(void *UNUSED(data), bNode *node, bNodeSt /* stack order in: 4 value channels */ /* input no image? then only color operation */ - if((in[0]->data==NULL) && (in[1]->data==NULL) && (in[2]->data==NULL) && (in[3]->data==NULL)) { + if ((in[0]->data==NULL) && (in[1]->data==NULL) && (in[2]->data==NULL) && (in[3]->data==NULL)) { float y = in[0]->vec[0] * 255; float cb = in[1]->vec[0] * 255; float cr = in[2]->vec[0] * 255; diff --git a/source/blender/nodes/composite/nodes/node_composite_sepcombYUVA.c b/source/blender/nodes/composite/nodes/node_composite_sepcombYUVA.c index 2a2f64a5209..8dd551643f5 100644 --- a/source/blender/nodes/composite/nodes/node_composite_sepcombYUVA.c +++ b/source/blender/nodes/composite/nodes/node_composite_sepcombYUVA.c @@ -64,7 +64,7 @@ static void node_composit_exec_sepyuva(void *UNUSED(data), bNode *node, bNodeSta /* stack order in: col */ /* input no image? then only color operation */ - if(in[0]->data==NULL) { + if (in[0]->data==NULL) { float y, u, v; rgb_to_yuv(in[0]->vec[0], in[0]->vec[1], in[0]->vec[2], &y, &u, &v); @@ -83,17 +83,17 @@ static void node_composit_exec_sepyuva(void *UNUSED(data), bNode *node, bNodeSta composit1_pixel_processor(node, cbuf2, cbuf2, in[0]->vec, do_sepyuva, CB_RGBA); /* separate each of those channels */ - if(out[0]->hasoutput) + if (out[0]->hasoutput) out[0]->data= valbuf_from_rgbabuf(cbuf2, CHAN_R); - if(out[1]->hasoutput) + if (out[1]->hasoutput) out[1]->data= valbuf_from_rgbabuf(cbuf2, CHAN_G); - if(out[2]->hasoutput) + if (out[2]->hasoutput) out[2]->data= valbuf_from_rgbabuf(cbuf2, CHAN_B); - if(out[3]->hasoutput) + if (out[3]->hasoutput) out[3]->data= valbuf_from_rgbabuf(cbuf2, CHAN_A); /*not used anymore */ - if(cbuf2!=cbuf) + if (cbuf2!=cbuf) free_compbuf(cbuf2); free_compbuf(cbuf); } @@ -143,7 +143,7 @@ static void node_composit_exec_combyuva(void *UNUSED(data), bNode *node, bNodeSt /* stack order in: 4 value channels */ /* input no image? then only color operation */ - if((in[0]->data==NULL) && (in[1]->data==NULL) && (in[2]->data==NULL) && (in[3]->data==NULL)) { + if ((in[0]->data==NULL) && (in[1]->data==NULL) && (in[2]->data==NULL) && (in[3]->data==NULL)) { out[0]->vec[0] = in[0]->vec[0]; out[0]->vec[1] = in[1]->vec[0]; out[0]->vec[2] = in[2]->vec[0]; diff --git a/source/blender/nodes/composite/nodes/node_composite_setalpha.c b/source/blender/nodes/composite/nodes/node_composite_setalpha.c index 6c24185bb88..646bcc47617 100644 --- a/source/blender/nodes/composite/nodes/node_composite_setalpha.c +++ b/source/blender/nodes/composite/nodes/node_composite_setalpha.c @@ -49,7 +49,7 @@ static void node_composit_exec_setalpha(void *UNUSED(data), bNode *node, bNodeSt /* stack order in: col, alpha */ /* input no image? then only color operation */ - if(in[0]->data==NULL && in[1]->data==NULL) { + if (in[0]->data==NULL && in[1]->data==NULL) { out[0]->vec[0] = in[0]->vec[0]; out[0]->vec[1] = in[0]->vec[1]; out[0]->vec[2] = in[0]->vec[2]; @@ -60,7 +60,7 @@ static void node_composit_exec_setalpha(void *UNUSED(data), bNode *node, bNodeSt CompBuf *cbuf= in[0]->data?in[0]->data:in[1]->data; CompBuf *stackbuf= alloc_compbuf(cbuf->x, cbuf->y, CB_RGBA, 1); /* allocs */ - if(in[1]->data==NULL && in[1]->vec[0]==1.0f) { + if (in[1]->data==NULL && in[1]->vec[0]==1.0f) { /* pass on image */ composit1_pixel_processor(node, stackbuf, in[0]->data, in[0]->vec, do_copy_rgb, CB_RGBA); } diff --git a/source/blender/nodes/composite/nodes/node_composite_splitViewer.c b/source/blender/nodes/composite/nodes/node_composite_splitViewer.c index 16356098fe6..c2263053987 100644 --- a/source/blender/nodes/composite/nodes/node_composite_splitViewer.c +++ b/source/blender/nodes/composite/nodes/node_composite_splitViewer.c @@ -41,7 +41,7 @@ static bNodeSocketTemplate cmp_node_splitviewer_in[]= { static void do_copy_split_rgba(bNode *UNUSED(node), float *out, float *in1, float *in2, float *fac) { - if(*fac==0.0f) { + if (*fac==0.0f) { copy_v4_v4(out, in1); } else { @@ -54,10 +54,10 @@ static void node_composit_exec_splitviewer(void *data, bNode *node, bNodeStack * /* image assigned to output */ /* stack order input sockets: image image */ - if(in[0]->data==NULL || in[1]->data==NULL) + if (in[0]->data==NULL || in[1]->data==NULL) return; - if(node->id && (node->flag & NODE_DO_OUTPUT)) { /* only one works on out */ + if (node->id && (node->flag & NODE_DO_OUTPUT)) { /* only one works on out */ Image *ima= (Image *)node->id; RenderData *rd= data; ImBuf *ibuf; @@ -73,7 +73,7 @@ static void node_composit_exec_splitviewer(void *data, bNode *node, bNodeStack * /* always returns for viewer image, but we check nevertheless */ ibuf= BKE_image_acquire_ibuf(ima, node->storage, &lock); - if(ibuf==NULL) { + if (ibuf==NULL) { printf("node_composit_exec_viewer error\n"); BKE_image_release_ibuf(ima, lock); return; @@ -100,7 +100,7 @@ static void node_composit_exec_splitviewer(void *data, bNode *node, bNodeStack * /* Check which offset mode is selected and limit offset if needed */ - if(node->custom2 == 0) { + if (node->custom2 == 0) { offset = buf1->x / 100.0f * node->custom1; CLAMP(offset, 0, buf1->x); } @@ -109,17 +109,17 @@ static void node_composit_exec_splitviewer(void *data, bNode *node, bNodeStack * CLAMP(offset, 0, buf1->y); } - if(node->custom2 == 0) { - for(y=0; y<buf1->y; y++) { + if (node->custom2 == 0) { + for (y=0; y<buf1->y; y++) { float *fac= mask->rect + y*buf1->x; - for(x=offset; x>0; x--, fac++) + for (x=offset; x>0; x--, fac++) *fac= 1.0f; } } else { - for(y=0; y<offset; y++) { + for (y=0; y<offset; y++) { float *fac= mask->rect + y*buf1->x; - for(x=buf1->x; x>0; x--, fac++) + for (x=buf1->x; x>0; x--, fac++) *fac= 1.0f; } } @@ -132,9 +132,9 @@ static void node_composit_exec_splitviewer(void *data, bNode *node, bNodeStack * free_compbuf(cbuf); free_compbuf(mask); - if(in[0]->data != buf1) + if (in[0]->data != buf1) free_compbuf(buf1); - if(in[1]->data != buf2) + if (in[1]->data != buf2) free_compbuf(buf2); } } diff --git a/source/blender/nodes/composite/nodes/node_composite_stabilize2d.c b/source/blender/nodes/composite/nodes/node_composite_stabilize2d.c index f41751b3e15..0eac85c4030 100644 --- a/source/blender/nodes/composite/nodes/node_composite_stabilize2d.c +++ b/source/blender/nodes/composite/nodes/node_composite_stabilize2d.c @@ -47,7 +47,7 @@ static bNodeSocketTemplate cmp_node_stabilize2d_out[]= { static void node_composit_exec_stabilize2d(void *data, bNode *node, bNodeStack **in, bNodeStack **out) { - if(in[0]->data && node->id) { + if (in[0]->data && node->id) { RenderData *rd= data; MovieClip *clip= (MovieClip *)node->id; CompBuf *cbuf= typecheck_compbuf(in[0]->data, CB_RGBA); @@ -61,7 +61,7 @@ static void node_composit_exec_stabilize2d(void *data, bNode *node, bNodeStack * /* pass on output and free */ out[0]->data= stackbuf; - if(cbuf!=in[0]->data) + if (cbuf!=in[0]->data) free_compbuf(cbuf); } } diff --git a/source/blender/nodes/composite/nodes/node_composite_texture.c b/source/blender/nodes/composite/nodes/node_composite_texture.c index 7f8f14bcfc5..562e2b2737e 100644 --- a/source/blender/nodes/composite/nodes/node_composite_texture.c +++ b/source/blender/nodes/composite/nodes/node_composite_texture.c @@ -60,19 +60,19 @@ static void texture_procedural(CompBuf *cbuf, float *out, float xco, float yco) retval= multitex_ext((Tex *)node->id, vec, NULL, NULL, 0, &texres); - if(type==CB_VAL) { - if(texres.talpha) + if (type==CB_VAL) { + if (texres.talpha) col[0]= texres.ta; else col[0]= texres.tin; } - else if(type==CB_RGBA) { - if(texres.talpha) + else if (type==CB_RGBA) { + if (texres.talpha) col[3]= texres.ta; else col[3]= texres.tin; - if((retval & TEX_RGB)) { + if ((retval & TEX_RGB)) { col[0]= texres.tr; col[1]= texres.tg; col[2]= texres.tb; @@ -92,7 +92,7 @@ static void node_composit_exec_texture(void *data, bNode *node, bNodeStack **in, { /* outputs: value, color, normal */ - if(node->id) { + if (node->id) { RenderData *rd= data; short sizex, sizey; @@ -113,7 +113,7 @@ static void node_composit_exec_texture(void *data, bNode *node, bNodeStack **in, sizex = (rd->size*rd->xsch)/100; sizey = (rd->size*rd->ysch)/100; - if(out[0]->hasoutput) { + if (out[0]->hasoutput) { CompBuf *stackbuf= alloc_compbuf(sizex, sizey, CB_VAL, 1); /* alloc */ stackbuf->rect_procedural= texture_procedural; @@ -126,7 +126,7 @@ static void node_composit_exec_texture(void *data, bNode *node, bNodeStack **in, out[0]->data= stackbuf; } - if(out[1]->hasoutput) { + if (out[1]->hasoutput) { CompBuf *stackbuf= alloc_compbuf(sizex, sizey, CB_RGBA, 1); /* alloc */ stackbuf->rect_procedural= texture_procedural; diff --git a/source/blender/nodes/composite/nodes/node_composite_tonemap.c b/source/blender/nodes/composite/nodes/node_composite_tonemap.c index 9b34e117496..baa5ba046dd 100644 --- a/source/blender/nodes/composite/nodes/node_composite_tonemap.c +++ b/source/blender/nodes/composite/nodes/node_composite_tonemap.c @@ -142,7 +142,7 @@ static void node_composit_exec_tonemap(void *UNUSED(data), bNode *node, bNodeSta out[0]->data = new; - if(img!=in[0]->data) + if (img!=in[0]->data) free_compbuf(img); } diff --git a/source/blender/nodes/composite/nodes/node_composite_transform.c b/source/blender/nodes/composite/nodes/node_composite_transform.c index a016f3d1d96..a610d8a66c4 100644 --- a/source/blender/nodes/composite/nodes/node_composite_transform.c +++ b/source/blender/nodes/composite/nodes/node_composite_transform.c @@ -77,14 +77,14 @@ CompBuf* node_composit_transform(CompBuf *cbuf, float x, float y, float angle, f ibuf= IMB_allocImBuf(cbuf->x, cbuf->y, 32, 0); obuf= IMB_allocImBuf(stackbuf->x, stackbuf->y, 32, 0); - if(ibuf && obuf) { + if (ibuf && obuf) { int i, j; ibuf->rect_float= cbuf->rect; obuf->rect_float= stackbuf->rect; - for(j=0; j<cbuf->y; j++) { - for(i=0; i<cbuf->x;i++) { + for (j=0; j<cbuf->y; j++) { + for (i=0; i<cbuf->x;i++) { float vec[3]= {i, j, 0}; mul_v3_m4v3(vec, mat, vec); @@ -113,7 +113,7 @@ CompBuf* node_composit_transform(CompBuf *cbuf, float x, float y, float angle, f static void node_composit_exec_transform(void *UNUSED(data), bNode *node, bNodeStack **in, bNodeStack **out) { - if(in[0]->data) { + if (in[0]->data) { CompBuf *cbuf= typecheck_compbuf(in[0]->data, CB_RGBA); CompBuf *stackbuf; @@ -122,7 +122,7 @@ static void node_composit_exec_transform(void *UNUSED(data), bNode *node, bNodeS /* pass on output and free */ out[0]->data= stackbuf; - if(cbuf!=in[0]->data) + if (cbuf!=in[0]->data) free_compbuf(cbuf); } } diff --git a/source/blender/nodes/composite/nodes/node_composite_translate.c b/source/blender/nodes/composite/nodes/node_composite_translate.c index 073b035add0..970e2c79f14 100644 --- a/source/blender/nodes/composite/nodes/node_composite_translate.c +++ b/source/blender/nodes/composite/nodes/node_composite_translate.c @@ -48,7 +48,7 @@ static bNodeSocketTemplate cmp_node_translate_out[]= { static void node_composit_exec_translate(void *UNUSED(data), bNode *UNUSED(node), bNodeStack **in, bNodeStack **out) { - if(in[0]->data) { + if (in[0]->data) { CompBuf *cbuf= in[0]->data; CompBuf *stackbuf= pass_on_compbuf(cbuf); diff --git a/source/blender/nodes/composite/nodes/node_composite_valToRgb.c b/source/blender/nodes/composite/nodes/node_composite_valToRgb.c index 30f624641d1..86986f6038d 100644 --- a/source/blender/nodes/composite/nodes/node_composite_valToRgb.c +++ b/source/blender/nodes/composite/nodes/node_composite_valToRgb.c @@ -54,12 +54,12 @@ static void node_composit_exec_valtorgb(void *UNUSED(data), bNode *node, bNodeSt /* stack order in: fac */ /* stack order out: col, alpha */ - if(out[0]->hasoutput==0 && out[1]->hasoutput==0) + if (out[0]->hasoutput==0 && out[1]->hasoutput==0) return; - if(node->storage) { + if (node->storage) { /* input no image? then only color operation */ - if(in[0]->data==NULL) { + if (in[0]->data==NULL) { do_colorband(node->storage, in[0]->vec[0], out[0]->vec); } else { @@ -71,7 +71,7 @@ static void node_composit_exec_valtorgb(void *UNUSED(data), bNode *node, bNodeSt out[0]->data= stackbuf; - if(out[1]->hasoutput) + if (out[1]->hasoutput) out[1]->data= valbuf_from_rgbabuf(stackbuf, CHAN_A); } @@ -119,11 +119,11 @@ static void node_composit_exec_rgbtobw(void *UNUSED(data), bNode *node, bNodeSta /* stack order out: bw */ /* stack order in: col */ - if(out[0]->hasoutput==0) + if (out[0]->hasoutput==0) return; /* input no image? then only color operation */ - if(in[0]->data==NULL) { + if (in[0]->data==NULL) { do_rgbtobw(node, out[0]->vec, in[0]->vec); } else { diff --git a/source/blender/nodes/composite/nodes/node_composite_vecBlur.c b/source/blender/nodes/composite/nodes/node_composite_vecBlur.c index 69f896e9bb5..1d4662aa87b 100644 --- a/source/blender/nodes/composite/nodes/node_composite_vecBlur.c +++ b/source/blender/nodes/composite/nodes/node_composite_vecBlur.c @@ -52,21 +52,21 @@ static void node_composit_exec_vecblur(void *UNUSED(data), bNode *node, bNodeSta NodeBlurData *nbd= node->storage; CompBuf *new, *img= in[0]->data, *vecbuf= in[2]->data, *zbuf= in[1]->data; - if(img==NULL || vecbuf==NULL || zbuf==NULL || out[0]->hasoutput==0) + if (img==NULL || vecbuf==NULL || zbuf==NULL || out[0]->hasoutput==0) return; - if(vecbuf->x!=img->x || vecbuf->y!=img->y) { + if (vecbuf->x!=img->x || vecbuf->y!=img->y) { printf("ERROR: cannot do different sized vecbuf yet\n"); return; } - if(vecbuf->type!=CB_VEC4) { + if (vecbuf->type!=CB_VEC4) { printf("ERROR: input should be vecbuf\n"); return; } - if(zbuf->type!=CB_VAL) { + if (zbuf->type!=CB_VAL) { printf("ERROR: input should be zbuf\n"); return; } - if(zbuf->x!=img->x || zbuf->y!=img->y) { + if (zbuf->x!=img->x || zbuf->y!=img->y) { printf("ERROR: cannot do different sized zbuf yet\n"); return; } @@ -81,7 +81,7 @@ static void node_composit_exec_vecblur(void *UNUSED(data), bNode *node, bNodeSta out[0]->data= new; - if(img!=in[0]->data) + if (img!=in[0]->data) free_compbuf(img); } diff --git a/source/blender/nodes/composite/nodes/node_composite_viewer.c b/source/blender/nodes/composite/nodes/node_composite_viewer.c index f1a6cae62ab..f9b1e55f29f 100644 --- a/source/blender/nodes/composite/nodes/node_composite_viewer.c +++ b/source/blender/nodes/composite/nodes/node_composite_viewer.c @@ -47,7 +47,7 @@ static void node_composit_exec_viewer(void *data, bNode *node, bNodeStack **in, /* image assigned to output */ /* stack order input sockets: col, alpha, z */ - if(node->id && (node->flag & NODE_DO_OUTPUT)) { /* only one works on out */ + if (node->id && (node->flag & NODE_DO_OUTPUT)) { /* only one works on out */ RenderData *rd= data; Image *ima= (Image *)node->id; ImBuf *ibuf; @@ -59,7 +59,7 @@ static void node_composit_exec_viewer(void *data, bNode *node, bNodeStack **in, /* always returns for viewer image, but we check nevertheless */ ibuf= BKE_image_acquire_ibuf(ima, node->storage, &lock); - if(ibuf==NULL) { + if (ibuf==NULL) { printf("node_composit_exec_viewer error\n"); BKE_image_release_ibuf(ima, lock); return; @@ -72,7 +72,7 @@ static void node_composit_exec_viewer(void *data, bNode *node, bNodeStack **in, /* get size */ tbuf= in[0]->data?in[0]->data:(in[1]->data?in[1]->data:in[2]->data); - if(tbuf==NULL) { + if (tbuf==NULL) { rectx= 320; recty= 256; } else { @@ -92,14 +92,14 @@ static void node_composit_exec_viewer(void *data, bNode *node, bNodeStack **in, cbuf->rect= ibuf->rect_float; /* when no alpha, we can simply copy */ - if(in[1]->data==NULL) { + if (in[1]->data==NULL) { composit1_pixel_processor(node, cbuf, in[0]->data, in[0]->vec, do_copy_rgba, CB_RGBA); } else composit2_pixel_processor(node, cbuf, in[0]->data, in[0]->vec, in[1]->data, in[1]->vec, do_copy_a_rgba, CB_RGBA, CB_VAL); /* zbuf option */ - if(in[2]->data) { + if (in[2]->data) { CompBuf *zbuf= alloc_compbuf(rectx, recty, CB_VAL, 1); ibuf->zbuf_float= zbuf->rect; ibuf->mall |= IB_zbuffloat; @@ -117,7 +117,7 @@ static void node_composit_exec_viewer(void *data, bNode *node, bNodeStack **in, free_compbuf(cbuf); } - else if(in[0]->data) { + else if (in[0]->data) { generate_preview(data, node, in[0]->data); } } diff --git a/source/blender/nodes/composite/nodes/node_composite_zcombine.c b/source/blender/nodes/composite/nodes/node_composite_zcombine.c index 57b0b7bbf14..64342751e84 100644 --- a/source/blender/nodes/composite/nodes/node_composite_zcombine.c +++ b/source/blender/nodes/composite/nodes/node_composite_zcombine.c @@ -53,7 +53,7 @@ static void do_zcombine(bNode *node, float *out, float *src1, float *z1, float * float alpha; float malpha; - if(*z1 <= *z2) { + if (*z1 <= *z2) { if (node->custom1) { // use alpha in combine operation alpha= src1[3]; @@ -83,16 +83,16 @@ static void do_zcombine(bNode *node, float *out, float *src1, float *z1, float * copy_v4_v4(out, src1); } - if(node->custom2) + if (node->custom2) *z1= *z2; } } static void do_zcombine_mask(bNode *node, float *out, float *z1, float *z2) { - if(*z1 > *z2) { + if (*z1 > *z2) { *out= 1.0f; - if(node->custom2) + if (node->custom2) *z1= *z2; } } @@ -145,24 +145,24 @@ static void node_composit_exec_zcombine(void *data, bNode *node, bNodeStack **in /* stack order in: col z col z */ /* stack order out: col z */ - if(out[0]->hasoutput==0 && out[1]->hasoutput==0) + if (out[0]->hasoutput==0 && out[1]->hasoutput==0) return; /* no input image; do nothing now */ - if(in[0]->data==NULL) { + if (in[0]->data==NULL) { return; } - if(out[1]->hasoutput) { + if (out[1]->hasoutput) { /* copy or make a buffer for for the first z value, here we write result in */ - if(in[1]->data) + if (in[1]->data) zbuf= dupalloc_compbuf(in[1]->data); else { float *zval; int tot= cbuf->x*cbuf->y; zbuf= alloc_compbuf(cbuf->x, cbuf->y, CB_VAL, 1); - for(zval= zbuf->rect; tot; tot--, zval++) + for (zval= zbuf->rect; tot; tot--, zval++) *zval= in[1]->vec[0]; } /* lazy coder hack */ @@ -174,7 +174,7 @@ static void node_composit_exec_zcombine(void *data, bNode *node, bNodeStack **in zbuf= in[1]->data; } - if(rd->scemode & R_FULL_SAMPLE) { + if (rd->scemode & R_FULL_SAMPLE) { /* make output size of first input image */ CompBuf *stackbuf= alloc_compbuf(cbuf->x, cbuf->y, CB_RGBA, 1); // allocs @@ -199,16 +199,16 @@ static void node_composit_exec_zcombine(void *data, bNode *node, bNodeStack **in /* convert to char */ aabuf= MEM_mallocN(cbuf->x*cbuf->y, "aa buf"); fp= mbuf->rect; - for(x= cbuf->x*cbuf->y-1; x>=0; x--) - if(fp[x]==0.0f) aabuf[x]= 0; + for (x= cbuf->x*cbuf->y-1; x>=0; x--) + if (fp[x]==0.0f) aabuf[x]= 0; else aabuf[x]= 255; antialias_tagbuf(cbuf->x, cbuf->y, aabuf); /* convert to float */ fp= mbuf->rect; - for(x= cbuf->x*cbuf->y-1; x>=0; x--) - if(aabuf[x]>1) + for (x= cbuf->x*cbuf->y-1; x>=0; x--) + if (aabuf[x]>1) fp[x]= (1.0f/255.0f)*(float)aabuf[x]; composit3_pixel_processor(node, stackbuf, in[0]->data, in[0]->vec, in[2]->data, in[2]->vec, mbuf, NULL, diff --git a/source/blender/nodes/intern/node_common.c b/source/blender/nodes/intern/node_common.c index c039365ec69..d2ec5ee032b 100644 --- a/source/blender/nodes/intern/node_common.c +++ b/source/blender/nodes/intern/node_common.c @@ -105,7 +105,7 @@ bNodeSocket *node_group_add_extern_socket(bNodeTree *UNUSED(ntree), ListBase *lb sock->default_value = node_socket_make_default_value(sock->type); node_socket_copy_default_value(sock->type, sock->default_value, gsock->default_value); - if(lb) + if (lb) BLI_addtail(lb, sock); return sock; @@ -125,42 +125,42 @@ bNode *node_group_make_from_selected(bNodeTree *ntree) INIT_MINMAX2(min, max); /* is there something to group? also do some clearing */ - 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) { /* no groups in groups */ - if(node->type==NODE_GROUP) + if (node->type==NODE_GROUP) return NULL; DO_MINMAX2( (&node->locx), min, max); totnode++; } node->done= 0; } - if(totnode==0) return NULL; + if (totnode==0) return NULL; /* check if all connections are OK, no unselected node has both inputs and outputs to a selection */ - for(link= ntree->links.first; link; link= link->next) { - if(link->fromnode && link->tonode && link->fromnode->flag & NODE_SELECT) + for (link= ntree->links.first; link; link= link->next) { + if (link->fromnode && link->tonode && link->fromnode->flag & NODE_SELECT) link->tonode->done |= 1; - if(link->fromnode && link->tonode && link->tonode->flag & NODE_SELECT) + if (link->fromnode && link->tonode && link->tonode->flag & NODE_SELECT) link->fromnode->done |= 2; } - for(node= ntree->nodes.first; node; node= node->next) { - if((node->flag & NODE_SELECT)==0) - if(node->done==3) + for (node= ntree->nodes.first; node; node= node->next) { + if ((node->flag & NODE_SELECT)==0) + if (node->done==3) break; } - if(node) + if (node) return NULL; /* OK! new nodetree */ ngroup= ntreeAddTree("NodeGroup", ntree->type, NODE_GROUP); /* move nodes over */ - for(node= ntree->nodes.first; node; node= nextn) { + for (node= ntree->nodes.first; node; node= nextn) { nextn= node->next; - if(node->flag & NODE_SELECT) { + if (node->flag & NODE_SELECT) { /* keep track of this node's RNA "base" path (the part of the pat identifying the node) * if the old nodetree has animation data which potentially covers this node */ @@ -210,20 +210,20 @@ bNode *node_group_make_from_selected(bNodeTree *ntree) gnode->locy= 0.5f*(min[1]+max[1]); /* relink external sockets */ - for(link= ntree->links.first; link; link= linkn) { + for (link= ntree->links.first; link; link= linkn) { linkn= link->next; - if(link->fromnode && link->tonode && (link->fromnode->flag & link->tonode->flag & NODE_SELECT)) { + if (link->fromnode && link->tonode && (link->fromnode->flag & link->tonode->flag & NODE_SELECT)) { BLI_remlink(&ntree->links, link); BLI_addtail(&ngroup->links, link); } - else if(link->tonode && (link->tonode->flag & NODE_SELECT)) { + else if (link->tonode && (link->tonode->flag & NODE_SELECT)) { gsock = node_group_expose_socket(ngroup, link->tosock, SOCK_IN); link->tosock->link = nodeAddLink(ngroup, NULL, gsock, link->tonode, link->tosock); link->tosock = node_group_add_extern_socket(ntree, &gnode->inputs, SOCK_IN, gsock); link->tonode = gnode; } - else if(link->fromnode && (link->fromnode->flag & NODE_SELECT)) { + else if (link->fromnode && (link->fromnode->flag & NODE_SELECT)) { /* search for existing group node socket */ for (gsock=ngroup->outputs.first; gsock; gsock=gsock->next) if (gsock->link && gsock->link->fromsock==link->fromsock) @@ -258,10 +258,10 @@ int node_group_ungroup(bNodeTree *ntree, bNode *gnode) ListBase anim_basepaths = {NULL, NULL}; ngroup= (bNodeTree *)gnode->id; - if(ngroup==NULL) return 0; + if (ngroup==NULL) return 0; /* clear new pointers, set in copytree */ - for(node= ntree->nodes.first; node; node= node->next) + for (node= ntree->nodes.first; node; node= node->next) node->new_node= NULL; /* wgroup is a temporary copy of the NodeTree we're merging in @@ -271,7 +271,7 @@ int node_group_ungroup(bNodeTree *ntree, bNode *gnode) wgroup= ntreeCopyTree(ngroup); /* add the nodes into the ntree */ - for(node= wgroup->nodes.first; node; node= nextn) { + for (node= wgroup->nodes.first; node; node= nextn) { nextn= node->next; /* keep track of this node's RNA "base" path (the part of the pat identifying the node) @@ -299,7 +299,7 @@ int node_group_ungroup(bNodeTree *ntree, bNode *gnode) } /* restore external links to and from the gnode */ - for(link= ntree->links.first; link; link= link->next) { + for (link= ntree->links.first; link; link= link->next) { if (link->fromnode==gnode) { if (link->fromsock->groupsock) { bNodeSocket *gsock= link->fromsock->groupsock; @@ -326,13 +326,13 @@ int node_group_ungroup(bNodeTree *ntree, bNode *gnode) } } /* remove internal output links, these are not used anymore */ - for(link=wgroup->links.first; link; link= linkn) { + for (link=wgroup->links.first; link; link= linkn) { linkn = link->next; if (!link->tonode) nodeRemLink(wgroup, link); } /* restore links from internal nodes */ - for(link= wgroup->links.first; link; link= link->next) { + for (link= wgroup->links.first; link; link= link->next) { /* indicates link to group input */ if (!link->fromnode) { /* NB: can't use find_group_node_input here, @@ -355,7 +355,7 @@ int node_group_ungroup(bNodeTree *ntree, bNode *gnode) } /* add internal links to the ntree */ - for(link= wgroup->links.first; link; link= linkn) { + for (link= wgroup->links.first; link; link= linkn) { linkn= link->next; BLI_remlink(&wgroup->links, link); BLI_addtail(&ntree->links, link); @@ -543,11 +543,11 @@ static bNodeSocket *group_verify_socket(bNodeTree *ntree, ListBase *lb, int in_o if (gsock->flag & SOCK_INTERNAL) return NULL; - for(sock= lb->first; sock; sock= sock->next) { - if(sock->own_index==gsock->own_index) + for (sock= lb->first; sock; sock= sock->next) { + if (sock->own_index==gsock->own_index) break; } - if(sock) { + if (sock) { sock->groupsock = gsock; BLI_strncpy(sock->name, gsock->name, sizeof(sock->name)); @@ -615,7 +615,7 @@ struct bNodeTree *node_group_edit_set(bNode *node, int edit) if (edit) { bNodeTree *ngroup= (bNodeTree*)node->id; if (ngroup) { - if(ngroup->id.lib) + if (ngroup->id.lib) ntreeMakeLocal(ngroup); node->flag |= NODE_GROUP_EDIT; diff --git a/source/blender/nodes/intern/node_exec.c b/source/blender/nodes/intern/node_exec.c index eaf19ad71b6..3b757e753a4 100644 --- a/source/blender/nodes/intern/node_exec.c +++ b/source/blender/nodes/intern/node_exec.c @@ -55,13 +55,13 @@ void node_get_stack(bNode *node, bNodeStack *stack, bNodeStack **in, bNodeStack /* build pointer stack */ if (in) { - for(sock= node->inputs.first; sock; sock= sock->next) { + for (sock= node->inputs.first; sock; sock= sock->next) { *(in++) = node_get_socket_stack(stack, sock); } } if (out) { - for(sock= node->outputs.first; sock; sock= sock->next) { + for (sock= node->outputs.first; sock; sock= sock->next) { *(out++) = node_get_socket_stack(stack, sock); } } @@ -135,7 +135,7 @@ bNodeTreeExec *ntree_exec_begin(bNodeTree *ntree) bNode **nodelist; int totnodes, n; - if((ntree->init & NTREE_TYPE_INIT)==0) + if ((ntree->init & NTREE_TYPE_INIT)==0) ntreeInitTypes(ntree); /* get a dependency-sorted list of nodes */ @@ -147,10 +147,10 @@ bNodeTreeExec *ntree_exec_begin(bNodeTree *ntree) exec->nodetree = ntree; /* group inputs essentially work as outputs */ - for(gsock=ntree->inputs.first; gsock; gsock = gsock->next) + for (gsock=ntree->inputs.first; gsock; gsock = gsock->next) node_init_output_index(gsock, &index); /* set stack indexes */ - for(n=0; n < totnodes; ++n) { + for (n=0; n < totnodes; ++n) { node = nodelist[n]; node->stack_index = index; @@ -162,7 +162,7 @@ bNodeTreeExec *ntree_exec_begin(bNodeTree *ntree) node_init_output_index(sock, &index); } /* group outputs essentially work as inputs */ - for(gsock=ntree->outputs.first; gsock; gsock = gsock->next) + for (gsock=ntree->outputs.first; gsock; gsock = gsock->next) node_init_input_index(gsock, &index); /* allocated exec data pointers for nodes */ @@ -181,13 +181,13 @@ bNodeTreeExec *ntree_exec_begin(bNodeTree *ntree) /* ns = */ setup_stack(exec->stack, sock); } /* prepare all internal nodes for execution */ - for(n=0, nodeexec= exec->nodeexec; n < totnodes; ++n, ++nodeexec) { + for (n=0, nodeexec= exec->nodeexec; n < totnodes; ++n, ++nodeexec) { node = nodeexec->node = nodelist[n]; /* tag inputs */ for (sock=node->inputs.first; sock; sock=sock->next) { /* disable the node if an input link is invalid */ - if(sock->link && !(sock->link->flag & NODE_LINK_VALID)) + if (sock->link && !(sock->link->flag & NODE_LINK_VALID)) node->need_exec= 0; ns = setup_stack(exec->stack, sock); @@ -199,7 +199,7 @@ bNodeTreeExec *ntree_exec_begin(bNodeTree *ntree) /* ns = */ setup_stack(exec->stack, sock); } - if(node->typeinfo->initexecfunc) + if (node->typeinfo->initexecfunc) nodeexec->data = node->typeinfo->initexecfunc(node); } /* prepare group tree outputs */ @@ -222,7 +222,7 @@ void ntree_exec_end(bNodeTreeExec *exec) if (exec->stack) MEM_freeN(exec->stack); - for(n=0, nodeexec= exec->nodeexec; n < exec->totnodes; ++n, ++nodeexec) { + for (n=0, nodeexec= exec->nodeexec; n < exec->totnodes; ++n, ++nodeexec) { if (nodeexec->node->typeinfo->freeexecfunc) nodeexec->node->typeinfo->freeexecfunc(nodeexec->node, nodeexec->data); } @@ -240,8 +240,8 @@ bNodeThreadStack *ntreeGetThreadStack(bNodeTreeExec *exec, int thread) ListBase *lb= &exec->threadstack[thread]; bNodeThreadStack *nts; - for(nts=lb->first; nts; nts=nts->next) { - if(!nts->used) { + for (nts=lb->first; nts; nts=nts->next) { + if (!nts->used) { nts->used= 1; break; } @@ -272,15 +272,15 @@ void ntreeExecNodes(bNodeTreeExec *exec, void *callerdata, int thread) /* nodes are presorted, so exec is in order of list */ - for(n=0, nodeexec= exec->nodeexec; n < exec->totnodes; ++n, ++nodeexec) { + for (n=0, nodeexec= exec->nodeexec; n < exec->totnodes; ++n, ++nodeexec) { node = nodeexec->node; - if(node->need_exec) { + if (node->need_exec) { node_get_stack(node, exec->stack, nsin, nsout); /* Handle muted nodes... * If the mute func is not set, assume the node should never be muted, * and hence execute it! */ - if(node->typeinfo->execfunc) + if (node->typeinfo->execfunc) node->typeinfo->execfunc(callerdata, node, nsin, nsout); else if (node->typeinfo->newexecfunc) node->typeinfo->newexecfunc(callerdata, thread, node, nodeexec->data, nsin, nsout); @@ -298,15 +298,15 @@ void ntreeExecThreadNodes(bNodeTreeExec *exec, bNodeThreadStack *nts, void *call /* nodes are presorted, so exec is in order of list */ - for(n=0, nodeexec= exec->nodeexec; n < exec->totnodes; ++n, ++nodeexec) { + for (n=0, nodeexec= exec->nodeexec; n < exec->totnodes; ++n, ++nodeexec) { node = nodeexec->node; - if(node->need_exec) { + if (node->need_exec) { node_get_stack(node, nts->stack, nsin, nsout); /* Handle muted nodes... * If the mute func is not set, assume the node should never be muted, * and hence execute it! */ - if(node->typeinfo->execfunc) + if (node->typeinfo->execfunc) node->typeinfo->execfunc(callerdata, node, nsin, nsout); else if (node->typeinfo->newexecfunc) node->typeinfo->newexecfunc(callerdata, thread, node, nodeexec->data, nsin, nsout); diff --git a/source/blender/nodes/intern/node_socket.c b/source/blender/nodes/intern/node_socket.c index f03aff8fb92..4e6cf1f9bdd 100644 --- a/source/blender/nodes/intern/node_socket.c +++ b/source/blender/nodes/intern/node_socket.c @@ -485,13 +485,13 @@ static bNodeSocket *verify_socket_template(bNodeTree *ntree, bNode *node, int in { bNodeSocket *sock; - for(sock= socklist->first; sock; sock= sock->next) { - if(!(sock->flag & SOCK_DYNAMIC) && strncmp(sock->name, stemp->name, NODE_MAXSTR)==0) + for (sock= socklist->first; sock; sock= sock->next) { + if (!(sock->flag & SOCK_DYNAMIC) && strncmp(sock->name, stemp->name, NODE_MAXSTR)==0) break; } - if(sock) { + if (sock) { sock->type= stemp->type; /* in future, read this from tydefs! */ - if(stemp->limit==0) sock->limit= 0xFFF; + if (stemp->limit==0) sock->limit= 0xFFF; else sock->limit= stemp->limit; sock->flag |= stemp->flag; @@ -550,7 +550,7 @@ static void verify_socket_template_list(bNodeTree *ntree, bNode *node, int in_ou bNodeSocketTemplate *stemp; /* no inputs anymore? */ - if(stemp_first==NULL) { + if (stemp_first==NULL) { for (sock = (bNodeSocket*)socklist->first; sock; sock=nextsock) { nextsock = sock->next; if (!(sock->flag & SOCK_DYNAMIC)) @@ -560,7 +560,7 @@ static void verify_socket_template_list(bNodeTree *ntree, bNode *node, int in_ou else { /* step by step compare */ stemp= stemp_first; - while(stemp->type != -1) { + while (stemp->type != -1) { stemp->sock= verify_socket_template(ntree, node, in_out, socklist, stemp); stemp++; } @@ -578,14 +578,14 @@ static void verify_socket_template_list(bNodeTree *ntree, bNode *node, int in_ou * so we can add static sockets infront of it. */ sock = socklist->first; - while(stemp->type != -1) { + while (stemp->type != -1) { /* put static sockets infront of dynamic */ BLI_insertlinkbefore(socklist, sock, stemp->sock); stemp++; } } else { - while(stemp->type != -1) { + while (stemp->type != -1) { BLI_addtail(socklist, stemp->sock); stemp++; } @@ -600,7 +600,7 @@ void node_verify_socket_templates(bNodeTree *ntree, bNode *node) * This also prevents group node sockets from being removed, without the need to explicitly * check the node type here. */ - if(ntype && ((ntype->inputs && ntype->inputs[0].type>=0) || (ntype->outputs && ntype->outputs[0].type>=0))) { + if (ntype && ((ntype->inputs && ntype->inputs[0].type>=0) || (ntype->outputs && ntype->outputs[0].type>=0))) { verify_socket_template_list(ntree, node, SOCK_IN, &node->inputs, ntype->inputs); verify_socket_template_list(ntree, node, SOCK_OUT, &node->outputs, ntype->outputs); } diff --git a/source/blender/nodes/intern/node_util.c b/source/blender/nodes/intern/node_util.c index 5967f3c2046..1c38bdf39d7 100644 --- a/source/blender/nodes/intern/node_util.c +++ b/source/blender/nodes/intern/node_util.c @@ -110,7 +110,7 @@ ListBase node_internal_connect_default(bNodeTree *ntree, bNode *node) ret.first = ret.last = NULL; /* Security check! */ - if(!ntree) + if (!ntree) return ret; for (datatype=0; datatype < NUM_SOCKET_TYPES; ++datatype) { diff --git a/source/blender/nodes/shader/node_shader_tree.c b/source/blender/nodes/shader/node_shader_tree.c index e12ac4dee49..c028ca83664 100644 --- a/source/blender/nodes/shader/node_shader_tree.c +++ b/source/blender/nodes/shader/node_shader_tree.c @@ -65,16 +65,16 @@ static void foreach_nodetree(Main *main, void *calldata, bNodeTreeCallback func) Lamp *la; World *wo; - for(ma= main->mat.first; ma; ma= ma->id.next) - if(ma->nodetree) + for (ma= main->mat.first; ma; ma= ma->id.next) + if (ma->nodetree) func(calldata, &ma->id, ma->nodetree); - for(la= main->lamp.first; la; la= la->id.next) - if(la->nodetree) + for (la= main->lamp.first; la; la= la->id.next) + if (la->nodetree) func(calldata, &la->id, la->nodetree); - for(wo= main->world.first; wo; wo= wo->id.next) - if(wo->nodetree) + for (wo= main->world.first; wo; wo= wo->id.next) + if (wo->nodetree) func(calldata, &wo->id, wo->nodetree); } @@ -83,7 +83,7 @@ static void foreach_nodeclass(Scene *scene, void *calldata, bNodeClassCallback f func(calldata, NODE_CLASS_INPUT, IFACE_("Input")); func(calldata, NODE_CLASS_OUTPUT, IFACE_("Output")); - if(scene_use_new_shading_nodes(scene)) { + if (scene_use_new_shading_nodes(scene)) { func(calldata, NODE_CLASS_SHADER, IFACE_("Shader")); func(calldata, NODE_CLASS_TEXTURE, IFACE_("Texture")); } @@ -115,12 +115,12 @@ static void local_sync(bNodeTree *localtree, bNodeTree *ntree) bNode *lnode; /* copy over contents of previews */ - for(lnode= localtree->nodes.first; lnode; lnode= lnode->next) { - if(ntreeNodeExists(ntree, lnode->new_node)) { + for (lnode= localtree->nodes.first; lnode; lnode= lnode->next) { + if (ntreeNodeExists(ntree, lnode->new_node)) { bNode *node= lnode->new_node; - if(node->preview && node->preview->rect) { - if(lnode->preview && lnode->preview->rect) { + if (node->preview && node->preview->rect) { + if (lnode->preview && lnode->preview->rect) { int xsize= node->preview->xsize; int ysize= node->preview->ysize; memcpy(node->preview->rect, lnode->preview->rect, 4*xsize + xsize*ysize*sizeof(char)*4); @@ -202,7 +202,7 @@ bNodeTreeExec *ntreeShaderBeginExecTree(bNodeTree *ntree, int use_tree_data) /* allocate the thread stack listbase array */ exec->threadstack= MEM_callocN(BLENDER_MAX_THREADS*sizeof(ListBase), "thread stack array"); - for(node= exec->nodetree->nodes.first; node; node= node->next) + for (node= exec->nodetree->nodes.first; node; node= node->next) node->need_exec= 1; if (use_tree_data) { @@ -220,14 +220,14 @@ bNodeTreeExec *ntreeShaderBeginExecTree(bNodeTree *ntree, int use_tree_data) */ void ntreeShaderEndExecTree(bNodeTreeExec *exec, int use_tree_data) { - if(exec) { + if (exec) { bNodeTree *ntree= exec->nodetree; bNodeThreadStack *nts; int a; - if(exec->threadstack) { - for(a=0; a<BLENDER_MAX_THREADS; a++) { - for(nts=exec->threadstack[a].first; nts; nts=nts->next) + if (exec->threadstack) { + for (a=0; a<BLENDER_MAX_THREADS; a++) { + for (nts=exec->threadstack[a].first; nts; nts=nts->next) if (nts->stack) MEM_freeN(nts->stack); BLI_freelistN(&exec->threadstack[a]); } @@ -266,7 +266,7 @@ void ntreeShaderExecTree(bNodeTree *ntree, ShadeInput *shi, ShadeResult *shr) /* ensure execdata is only initialized once */ if (!exec) { BLI_lock_thread(LOCK_NODES); - if(!ntree->execdata) + if (!ntree->execdata) ntree->execdata = ntreeShaderBeginExecTree(ntree, 1); BLI_unlock_thread(LOCK_NODES); @@ -280,7 +280,7 @@ void ntreeShaderExecTree(bNodeTree *ntree, ShadeInput *shi, ShadeResult *shr) // \note: set material back to preserved material shi->mat = mat; /* better not allow negative for now */ - if(shr->combined[0]<0.0f) shr->combined[0]= 0.0f; - if(shr->combined[1]<0.0f) shr->combined[1]= 0.0f; - if(shr->combined[2]<0.0f) shr->combined[2]= 0.0f; + if (shr->combined[0]<0.0f) shr->combined[0]= 0.0f; + if (shr->combined[1]<0.0f) shr->combined[1]= 0.0f; + if (shr->combined[2]<0.0f) shr->combined[2]= 0.0f; } diff --git a/source/blender/nodes/shader/node_shader_util.c b/source/blender/nodes/shader/node_shader_util.c index 606ba98762c..df2f7879231 100644 --- a/source/blender/nodes/shader/node_shader_util.c +++ b/source/blender/nodes/shader/node_shader_util.c @@ -42,14 +42,14 @@ void nodestack_get_vec(float *in, short type_in, bNodeStack *ns) { float *from= ns->vec; - if(type_in==SOCK_FLOAT) { - if(ns->sockettype==SOCK_FLOAT) + if (type_in==SOCK_FLOAT) { + if (ns->sockettype==SOCK_FLOAT) *in= *from; else *in= 0.333333f*(from[0]+from[1]+from[2]); } - else if(type_in==SOCK_VECTOR) { - if(ns->sockettype==SOCK_FLOAT) { + else if (type_in==SOCK_VECTOR) { + if (ns->sockettype==SOCK_FLOAT) { in[0]= from[0]; in[1]= from[0]; in[2]= from[0]; @@ -59,10 +59,10 @@ void nodestack_get_vec(float *in, short type_in, bNodeStack *ns) } } else { /* type_in==SOCK_RGBA */ - if(ns->sockettype==SOCK_RGBA) { + if (ns->sockettype==SOCK_RGBA) { copy_v4_v4(in, from); } - else if(ns->sockettype==SOCK_FLOAT) { + else if (ns->sockettype==SOCK_FLOAT) { in[0]= from[0]; in[1]= from[0]; in[2]= from[0]; @@ -84,22 +84,22 @@ void ntreeShaderGetTexcoMode(bNodeTree *ntree, int r_mode, short *texco, int *mo bNodeSocket *sock; int a; - for(node= ntree->nodes.first; node; node= node->next) { - if(node->type==SH_NODE_TEXTURE) { - if((r_mode & R_OSA) && node->id) { + for (node= ntree->nodes.first; node; node= node->next) { + if (node->type==SH_NODE_TEXTURE) { + if ((r_mode & R_OSA) && node->id) { Tex *tex= (Tex *)node->id; if ELEM3(tex->type, TEX_IMAGE, TEX_PLUGIN, TEX_ENVMAP) *texco |= TEXCO_OSA|NEED_UV; } /* usability exception... without input we still give the node orcos */ sock= node->inputs.first; - if(sock==NULL || sock->link==NULL) + if (sock==NULL || sock->link==NULL) *texco |= TEXCO_ORCO|NEED_UV; } - else if(node->type==SH_NODE_GEOMETRY) { + else if (node->type==SH_NODE_GEOMETRY) { /* note; sockets always exist for the given type! */ - for(a=0, sock= node->outputs.first; sock; sock= sock->next, a++) { - if(sock->flag & SOCK_IN_USE) { + for (a=0, sock= node->outputs.first; sock; sock= sock->next, a++) { + if (sock->flag & SOCK_IN_USE) { switch(a) { case GEOM_OUT_GLOB: *texco |= TEXCO_GLOB|NEED_UV; break; @@ -125,17 +125,17 @@ void ntreeShaderGetTexcoMode(bNodeTree *ntree, int r_mode, short *texco, int *mo /* nodes that use ID data get synced with local data */ void nodeShaderSynchronizeID(bNode *node, int copyto) { - if(node->id==NULL) return; + if (node->id==NULL) return; - if(ELEM(node->type, SH_NODE_MATERIAL, SH_NODE_MATERIAL_EXT)) { + if (ELEM(node->type, SH_NODE_MATERIAL, SH_NODE_MATERIAL_EXT)) { bNodeSocket *sock; Material *ma= (Material *)node->id; int a; /* hrmf, case in loop isn't super fast, but we don't edit 100s of material at same time either! */ - for(a=0, sock= node->inputs.first; sock; sock= sock->next, a++) { - if(!nodeSocketIsHidden(sock)) { - if(copyto) { + for (a=0, sock= node->inputs.first; sock; sock= sock->next, a++) { + if (!nodeSocketIsHidden(sock)) { + if (copyto) { switch(a) { case MAT_IN_COLOR: copy_v3_v3(&ma->r, ((bNodeSocketValueRGBA*)sock->default_value)->value); break; @@ -249,19 +249,19 @@ bNode *nodeGetActiveTexture(bNodeTree *ntree) /* this is the node we texture paint and draw in textured draw */ bNode *node; - if(!ntree) + if (!ntree) return NULL; /* check for group edit */ - for(node= ntree->nodes.first; node; node= node->next) - if(node->flag & NODE_GROUP_EDIT) + for (node= ntree->nodes.first; node; node= node->next) + if (node->flag & NODE_GROUP_EDIT) break; - if(node) + if (node) ntree= (bNodeTree*)node->id; - for(node= ntree->nodes.first; node; node= node->next) - if(node->flag & NODE_ACTIVE_TEXTURE) + for (node= ntree->nodes.first; node; node= node->next) + if (node->flag & NODE_ACTIVE_TEXTURE) return node; return NULL; @@ -280,31 +280,31 @@ void ntreeExecGPUNodes(bNodeTreeExec *exec, GPUMaterial *mat, int do_outputs) stack= exec->stack; - for(n=0, nodeexec= exec->nodeexec; n < exec->totnodes; ++n, ++nodeexec) { + for (n=0, nodeexec= exec->nodeexec; n < exec->totnodes; ++n, ++nodeexec) { node = nodeexec->node; doit = 0; /* for groups, only execute outputs for edited group */ - if(node->typeinfo->nclass==NODE_CLASS_OUTPUT) { - if(do_outputs && (node->flag & NODE_DO_OUTPUT)) + if (node->typeinfo->nclass==NODE_CLASS_OUTPUT) { + if (do_outputs && (node->flag & NODE_DO_OUTPUT)) doit = 1; } else doit = 1; if (doit) { - if(node->typeinfo->gpufunc) { + if (node->typeinfo->gpufunc) { node_get_stack(node, stack, nsin, nsout); gpu_stack_from_data_list(gpuin, &node->inputs, nsin); gpu_stack_from_data_list(gpuout, &node->outputs, nsout); - if(node->typeinfo->gpufunc(mat, node, gpuin, gpuout)) + if (node->typeinfo->gpufunc(mat, node, gpuin, gpuout)) data_from_gpu_stack_list(&node->outputs, nsout, gpuout); } - else if(node->typeinfo->gpuextfunc) { + else if (node->typeinfo->gpuextfunc) { node_get_stack(node, stack, nsin, nsout); gpu_stack_from_data_list(gpuin, &node->inputs, nsin); gpu_stack_from_data_list(gpuout, &node->outputs, nsout); - if(node->typeinfo->gpuextfunc(mat, node, nodeexec->data, gpuin, gpuout)) + if (node->typeinfo->gpuextfunc(mat, node, nodeexec->data, gpuin, gpuout)) data_from_gpu_stack_list(&node->outputs, nsout, gpuout); } } @@ -318,7 +318,7 @@ void node_shader_gpu_tex_mapping(GPUMaterial *mat, bNode *node, GPUNodeStack *in float domin= (texmap->flag & TEXMAP_CLIP_MIN) != 0; float domax= (texmap->flag & TEXMAP_CLIP_MAX) != 0; - if(domin || domax || !(texmap->flag & TEXMAP_UNIT_MATRIX)) { + if (domin || domax || !(texmap->flag & TEXMAP_UNIT_MATRIX)) { GPUNodeLink *tmat = GPU_uniform((float*)texmap->mat); GPUNodeLink *tmin = GPU_uniform(texmap->min); GPUNodeLink *tmax = GPU_uniform(texmap->max); diff --git a/source/blender/nodes/shader/nodes/node_shader_camera.c b/source/blender/nodes/shader/nodes/node_shader_camera.c index 3ec75dfa4fd..69a6a5c04a9 100644 --- a/source/blender/nodes/shader/nodes/node_shader_camera.c +++ b/source/blender/nodes/shader/nodes/node_shader_camera.c @@ -43,7 +43,7 @@ static bNodeSocketTemplate sh_node_camera_out[]= { static void node_shader_exec_camera(void *data, bNode *UNUSED(node), bNodeStack **UNUSED(in), bNodeStack **out) { - if(data) { + if (data) { ShadeInput *shi= ((ShaderCallData *)data)->shi; /* Data we need for shading. */ copy_v3_v3(out[0]->vec, shi->co); /* get view vector */ diff --git a/source/blender/nodes/shader/nodes/node_shader_curves.c b/source/blender/nodes/shader/nodes/node_shader_curves.c index d30434f4e32..50bf4c58e4d 100644 --- a/source/blender/nodes/shader/nodes/node_shader_curves.c +++ b/source/blender/nodes/shader/nodes/node_shader_curves.c @@ -106,7 +106,7 @@ static void node_shader_exec_curve_rgb(void *UNUSED(data), bNode *node, bNodeSta /* stack order output: vec */ nodestack_get_vec(vec, SOCK_VECTOR, in[1]); curvemapping_evaluateRGBF(node->storage, out[0]->vec, vec); - if(in[0]->vec[0] != 1.0f) { + if (in[0]->vec[0] != 1.0f) { interp_v3_v3v3(out[0]->vec, vec, out[0]->vec, *in[0]->vec); } } diff --git a/source/blender/nodes/shader/nodes/node_shader_dynamic.c b/source/blender/nodes/shader/nodes/node_shader_dynamic.c index 0c6c53b38e4..805a7e54f04 100644 --- a/source/blender/nodes/shader/nodes/node_shader_dynamic.c +++ b/source/blender/nodes/shader/nodes/node_shader_dynamic.c @@ -459,7 +459,8 @@ static int node_dynamic_parse(struct bNode *node) if (!pyresult) { if (BTST(node->custom1, NODE_DYNAMIC_LOADED)) { node_dynamic_disable(node); - } else { + } + else { node_dynamic_disable_all_by_id(node->id); } node_dynamic_pyerror_print(node); @@ -574,7 +575,8 @@ static void node_dynamic_setup(bNode *node) } else { nodeMakeDynamicType(node); } - } else { + } + else { node_dynamic_rem_all_links(node->typeinfo); node_dynamic_free_typeinfo_sockets(node->typeinfo); node_dynamic_update_socket_links(node, NULL); diff --git a/source/blender/nodes/shader/nodes/node_shader_geom.c b/source/blender/nodes/shader/nodes/node_shader_geom.c index cf6f400ee2a..37ab8ac3f5b 100644 --- a/source/blender/nodes/shader/nodes/node_shader_geom.c +++ b/source/blender/nodes/shader/nodes/node_shader_geom.c @@ -53,17 +53,17 @@ static bNodeSocketTemplate sh_node_geom_out[]= { /* node execute callback */ static void node_shader_exec_geom(void *data, bNode *node, bNodeStack **UNUSED(in), bNodeStack **out) { - if(data) { + if (data) { ShadeInput *shi= ((ShaderCallData *)data)->shi; NodeGeometry *ngeo= (NodeGeometry*)node->storage; ShadeInputUV *suv= &shi->uv[shi->actuv]; static float defaultvcol[4] = {1.0f, 1.0f, 1.0f, 1.0f}; int i; - if(ngeo->uvname[0]) { + if (ngeo->uvname[0]) { /* find uv map by name */ - for(i = 0; i < shi->totuv; i++) { - if(strcmp(shi->uv[i].name, ngeo->uvname)==0) { + for (i = 0; i < shi->totuv; i++) { + if (strcmp(shi->uv[i].name, ngeo->uvname)==0) { suv= &shi->uv[i]; break; } @@ -82,9 +82,9 @@ static void node_shader_exec_geom(void *data, bNode *node, bNodeStack **UNUSED(i /* find vertex color layer by name */ ShadeInputCol *scol= &shi->col[0]; - if(ngeo->colname[0]) { - for(i = 0; i < shi->totcol; i++) { - if(strcmp(shi->col[i].name, ngeo->colname)==0) { + if (ngeo->colname[0]) { + for (i = 0; i < shi->totcol; i++) { + if (strcmp(shi->col[i].name, ngeo->colname)==0) { scol= &shi->col[i]; break; } @@ -100,7 +100,7 @@ static void node_shader_exec_geom(void *data, bNode *node, bNodeStack **UNUSED(i out[GEOM_OUT_VCOL_ALPHA]->vec[0]= 1.0f; } - if(shi->osatex) { + if (shi->osatex) { out[GEOM_OUT_GLOB]->data= shi->dxgl; out[GEOM_OUT_GLOB]->datatype= NS_OSA_VECTORS; out[GEOM_OUT_LOCAL]->data= shi->dxco; diff --git a/source/blender/nodes/shader/nodes/node_shader_hueSatVal.c b/source/blender/nodes/shader/nodes/node_shader_hueSatVal.c index 0f85196a45d..12b97e65be8 100644 --- a/source/blender/nodes/shader/nodes/node_shader_hueSatVal.c +++ b/source/blender/nodes/shader/nodes/node_shader_hueSatVal.c @@ -50,12 +50,12 @@ static bNodeSocketTemplate sh_node_hue_sat_out[]= { /* note: it would be possible to use CMP version for both nodes */ static void do_hue_sat_fac(bNode *UNUSED(node), float *out, float *hue, float *sat, float *val, float *in, float *fac) { - if(*fac!=0.0f && (*hue!=0.5f || *sat!=1.0f || *val!=1.0f)) { + if (*fac!=0.0f && (*hue!=0.5f || *sat!=1.0f || *val!=1.0f)) { float col[3], hsv[3], mfac= 1.0f - *fac; rgb_to_hsv(in[0], in[1], in[2], hsv, hsv+1, hsv+2); hsv[0]+= (*hue - 0.5f); - if(hsv[0]>1.0f) hsv[0]-=1.0f; else if(hsv[0]<0.0f) hsv[0]+= 1.0f; + if (hsv[0]>1.0f) hsv[0]-=1.0f; else if (hsv[0]<0.0f) hsv[0]+= 1.0f; hsv[1]*= *sat; hsv[2]*= *val; hsv_to_rgb(hsv[0], hsv[1], hsv[2], col, col+1, col+2); diff --git a/source/blender/nodes/shader/nodes/node_shader_mapping.c b/source/blender/nodes/shader/nodes/node_shader_mapping.c index c2a58d49161..b7b080fa2df 100644 --- a/source/blender/nodes/shader/nodes/node_shader_mapping.c +++ b/source/blender/nodes/shader/nodes/node_shader_mapping.c @@ -54,15 +54,15 @@ static void node_shader_exec_mapping(void *UNUSED(data), bNode *node, bNodeStack nodestack_get_vec(vec, SOCK_VECTOR, in[0]); mul_m4_v3(texmap->mat, vec); - if(texmap->flag & TEXMAP_CLIP_MIN) { - if(vec[0]<texmap->min[0]) vec[0]= texmap->min[0]; - if(vec[1]<texmap->min[1]) vec[1]= texmap->min[1]; - if(vec[2]<texmap->min[2]) vec[2]= texmap->min[2]; + if (texmap->flag & TEXMAP_CLIP_MIN) { + if (vec[0]<texmap->min[0]) vec[0]= texmap->min[0]; + if (vec[1]<texmap->min[1]) vec[1]= texmap->min[1]; + if (vec[2]<texmap->min[2]) vec[2]= texmap->min[2]; } - if(texmap->flag & TEXMAP_CLIP_MAX) { - if(vec[0]>texmap->max[0]) vec[0]= texmap->max[0]; - if(vec[1]>texmap->max[1]) vec[1]= texmap->max[1]; - if(vec[2]>texmap->max[2]) vec[2]= texmap->max[2]; + if (texmap->flag & TEXMAP_CLIP_MAX) { + if (vec[0]>texmap->max[0]) vec[0]= texmap->max[0]; + if (vec[1]>texmap->max[1]) vec[1]= texmap->max[1]; + if (vec[2]>texmap->max[2]) vec[2]= texmap->max[2]; } } diff --git a/source/blender/nodes/shader/nodes/node_shader_material.c b/source/blender/nodes/shader/nodes/node_shader_material.c index decd3bb225f..279bbfa8d1b 100644 --- a/source/blender/nodes/shader/nodes/node_shader_material.c +++ b/source/blender/nodes/shader/nodes/node_shader_material.c @@ -78,7 +78,7 @@ static bNodeSocketTemplate sh_node_material_ext_out[]= { static void node_shader_exec_material(void *data, bNode *node, bNodeStack **in, bNodeStack **out) { - if(data && node->id) { + if (data && node->id) { ShadeResult shrnode; ShadeInput *shi; ShaderCallData *shcd= data; @@ -103,17 +103,17 @@ static void node_shader_exec_material(void *data, bNode *node, bNodeStack **in, shi->har= shi->mat->har; /* write values */ - if(hasinput[MAT_IN_COLOR]) + if (hasinput[MAT_IN_COLOR]) nodestack_get_vec(&shi->r, SOCK_VECTOR, in[MAT_IN_COLOR]); - if(hasinput[MAT_IN_SPEC]) + if (hasinput[MAT_IN_SPEC]) nodestack_get_vec(&shi->specr, SOCK_VECTOR, in[MAT_IN_SPEC]); - if(hasinput[MAT_IN_REFL]) + if (hasinput[MAT_IN_REFL]) nodestack_get_vec(&shi->refl, SOCK_FLOAT, in[MAT_IN_REFL]); /* retrieve normal */ - if(hasinput[MAT_IN_NORMAL]) { + if (hasinput[MAT_IN_NORMAL]) { nodestack_get_vec(shi->vn, SOCK_VECTOR, in[MAT_IN_NORMAL]); normalize_v3(shi->vn); } @@ -121,24 +121,24 @@ static void node_shader_exec_material(void *data, bNode *node, bNodeStack **in, copy_v3_v3(shi->vn, shi->vno); /* custom option to flip normal */ - if(node->custom1 & SH_NODE_MAT_NEG) { + if (node->custom1 & SH_NODE_MAT_NEG) { negate_v3(shi->vn); } if (node->type == SH_NODE_MATERIAL_EXT) { - if(hasinput[MAT_IN_MIR]) + if (hasinput[MAT_IN_MIR]) nodestack_get_vec(&shi->mirr, SOCK_VECTOR, in[MAT_IN_MIR]); - if(hasinput[MAT_IN_AMB]) + if (hasinput[MAT_IN_AMB]) nodestack_get_vec(&shi->amb, SOCK_FLOAT, in[MAT_IN_AMB]); - if(hasinput[MAT_IN_EMIT]) + if (hasinput[MAT_IN_EMIT]) nodestack_get_vec(&shi->emit, SOCK_FLOAT, in[MAT_IN_EMIT]); - if(hasinput[MAT_IN_SPECTRA]) + if (hasinput[MAT_IN_SPECTRA]) nodestack_get_vec(&shi->spectra, SOCK_FLOAT, in[MAT_IN_SPECTRA]); - if(hasinput[MAT_IN_RAY_MIRROR]) + if (hasinput[MAT_IN_RAY_MIRROR]) nodestack_get_vec(&shi->ray_mirror, SOCK_FLOAT, in[MAT_IN_RAY_MIRROR]); - if(hasinput[MAT_IN_ALPHA]) + if (hasinput[MAT_IN_ALPHA]) nodestack_get_vec(&shi->alpha, SOCK_FLOAT, in[MAT_IN_ALPHA]); - if(hasinput[MAT_IN_TRANSLUCENCY]) + if (hasinput[MAT_IN_TRANSLUCENCY]) nodestack_get_vec(&shi->translucency, SOCK_FLOAT, in[MAT_IN_TRANSLUCENCY]); } @@ -147,13 +147,13 @@ static void node_shader_exec_material(void *data, bNode *node, bNodeStack **in, shi->nodes= 0; /* write to outputs */ - if(node->custom1 & SH_NODE_MAT_DIFF) { + if (node->custom1 & SH_NODE_MAT_DIFF) { copy_v3_v3(col, shrnode.combined); - if(!(node->custom1 & SH_NODE_MAT_SPEC)) { + if (!(node->custom1 & SH_NODE_MAT_SPEC)) { sub_v3_v3(col, shrnode.spec); } } - else if(node->custom1 & SH_NODE_MAT_SPEC) { + else if (node->custom1 & SH_NODE_MAT_SPEC) { copy_v3_v3(col, shrnode.spec); } else @@ -161,13 +161,13 @@ static void node_shader_exec_material(void *data, bNode *node, bNodeStack **in, col[3]= shrnode.alpha; - if(shi->do_preview) + if (shi->do_preview) nodeAddToPreview(node, col, shi->xs, shi->ys, shi->do_manage); copy_v3_v3(out[MAT_OUT_COLOR]->vec, col); out[MAT_OUT_ALPHA]->vec[0]= shrnode.alpha; - if(node->custom1 & SH_NODE_MAT_NEG) { + if (node->custom1 & SH_NODE_MAT_NEG) { shi->vn[0]= -shi->vn[0]; shi->vn[1]= -shi->vn[1]; shi->vn[2]= -shi->vn[2]; @@ -185,7 +185,7 @@ static void node_shader_exec_material(void *data, bNode *node, bNodeStack **in, } /* copy passes, now just active node */ - if(node->flag & NODE_ACTIVE_ID) { + if (node->flag & NODE_ACTIVE_ID) { float combined[4], alpha; copy_v4_v4(combined, shcd->shr->combined); @@ -218,7 +218,7 @@ static GPUNodeLink *gpu_get_input_link(GPUNodeStack *in) static int gpu_shader_material(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *out) { - if(node->id) { + if (node->id) { GPUShadeInput shi; GPUShadeResult shr; bNodeSocket *sock; @@ -235,47 +235,47 @@ static int gpu_shader_material(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPU_shadeinput_set(mat, (Material*)node->id, &shi); /* write values */ - if(hasinput[MAT_IN_COLOR]) + if (hasinput[MAT_IN_COLOR]) shi.rgb = gpu_get_input_link(&in[MAT_IN_COLOR]); - if(hasinput[MAT_IN_SPEC]) + if (hasinput[MAT_IN_SPEC]) shi.specrgb = gpu_get_input_link(&in[MAT_IN_SPEC]); - if(hasinput[MAT_IN_REFL]) + if (hasinput[MAT_IN_REFL]) shi.refl = gpu_get_input_link(&in[MAT_IN_REFL]); /* retrieve normal */ - if(hasinput[MAT_IN_NORMAL]) { + if (hasinput[MAT_IN_NORMAL]) { GPUNodeLink *tmp; shi.vn = gpu_get_input_link(&in[MAT_IN_NORMAL]); GPU_link(mat, "vec_math_normalize", shi.vn, &shi.vn, &tmp); } /* custom option to flip normal */ - if(node->custom1 & SH_NODE_MAT_NEG) + if (node->custom1 & SH_NODE_MAT_NEG) GPU_link(mat, "vec_math_negate", shi.vn, &shi.vn); if (node->type == SH_NODE_MATERIAL_EXT) { - if(hasinput[MAT_IN_AMB]) + if (hasinput[MAT_IN_AMB]) shi.amb= gpu_get_input_link(&in[MAT_IN_AMB]); - if(hasinput[MAT_IN_EMIT]) + if (hasinput[MAT_IN_EMIT]) shi.emit= gpu_get_input_link(&in[MAT_IN_EMIT]); - if(hasinput[MAT_IN_ALPHA]) + if (hasinput[MAT_IN_ALPHA]) shi.alpha= gpu_get_input_link(&in[MAT_IN_ALPHA]); } GPU_shaderesult_set(&shi, &shr); /* clears shr */ /* write to outputs */ - if(node->custom1 & SH_NODE_MAT_DIFF) { + if (node->custom1 & SH_NODE_MAT_DIFF) { out[MAT_OUT_COLOR].link= shr.combined; - if(!(node->custom1 & SH_NODE_MAT_SPEC)) { + if (!(node->custom1 & SH_NODE_MAT_SPEC)) { GPUNodeLink *link; GPU_link(mat, "vec_math_sub", shr.combined, shr.spec, &out[MAT_OUT_COLOR].link, &link); } } - else if(node->custom1 & SH_NODE_MAT_SPEC) { + else if (node->custom1 & SH_NODE_MAT_SPEC) { out[MAT_OUT_COLOR].link= shr.spec; } else @@ -285,7 +285,7 @@ static int gpu_shader_material(GPUMaterial *mat, bNode *node, GPUNodeStack *in, out[MAT_OUT_ALPHA].link = shr.alpha; // - if(node->custom1 & SH_NODE_MAT_NEG) + if (node->custom1 & SH_NODE_MAT_NEG) GPU_link(mat, "vec_math_negate", shi.vn, &shi.vn); out[MAT_OUT_NORMAL].link = shi.vn; diff --git a/source/blender/nodes/shader/nodes/node_shader_math.c b/source/blender/nodes/shader/nodes/node_shader_math.c index c9234c626aa..045fef1b010 100644 --- a/source/blender/nodes/shader/nodes/node_shader_math.c +++ b/source/blender/nodes/shader/nodes/node_shader_math.c @@ -48,7 +48,7 @@ static bNodeSocketTemplate sh_node_math_out[]= { static void node_shader_exec_math(void *UNUSED(data), bNode *node, bNodeStack **in, bNodeStack **out) { - switch(node->custom1){ + switch(node->custom1) { case 0: /* Add */ out[0]->vec[0]= in[0]->vec[0] + in[1]->vec[0]; @@ -61,7 +61,7 @@ bNodeStack **out) break; case 3: /* Divide */ { - if(in[1]->vec[0]==0) /* We don't want to divide by zero. */ + if (in[1]->vec[0]==0) /* We don't want to divide by zero. */ out[0]->vec[0]= 0.0; else out[0]->vec[0]= in[0]->vec[0] / in[1]->vec[0]; @@ -69,7 +69,7 @@ bNodeStack **out) break; case 4: /* Sine */ { - if(in[0]->hasinput || !in[1]->hasinput) /* This one only takes one input, so we've got to choose. */ + if (in[0]->hasinput || !in[1]->hasinput) /* This one only takes one input, so we've got to choose. */ out[0]->vec[0]= sin(in[0]->vec[0]); else out[0]->vec[0]= sin(in[1]->vec[0]); @@ -77,7 +77,7 @@ bNodeStack **out) break; case 5: /* Cosine */ { - if(in[0]->hasinput || !in[1]->hasinput) /* This one only takes one input, so we've got to choose. */ + if (in[0]->hasinput || !in[1]->hasinput) /* This one only takes one input, so we've got to choose. */ out[0]->vec[0]= cos(in[0]->vec[0]); else out[0]->vec[0]= cos(in[1]->vec[0]); @@ -85,7 +85,7 @@ bNodeStack **out) break; case 6: /* Tangent */ { - if(in[0]->hasinput || !in[1]->hasinput) /* This one only takes one input, so we've got to choose. */ + if (in[0]->hasinput || !in[1]->hasinput) /* This one only takes one input, so we've got to choose. */ out[0]->vec[0]= tan(in[0]->vec[0]); else out[0]->vec[0]= tan(in[1]->vec[0]); @@ -93,16 +93,16 @@ bNodeStack **out) break; case 7: /* Arc-Sine */ { - if(in[0]->hasinput || !in[1]->hasinput) { /* This one only takes one input, so we've got to choose. */ + if (in[0]->hasinput || !in[1]->hasinput) { /* This one only takes one input, so we've got to choose. */ /* Can't do the impossible... */ - if( in[0]->vec[0] <= 1 && in[0]->vec[0] >= -1 ) + if ( in[0]->vec[0] <= 1 && in[0]->vec[0] >= -1 ) out[0]->vec[0]= asin(in[0]->vec[0]); else out[0]->vec[0]= 0.0; } else { /* Can't do the impossible... */ - if( in[1]->vec[0] <= 1 && in[1]->vec[0] >= -1 ) + if ( in[1]->vec[0] <= 1 && in[1]->vec[0] >= -1 ) out[0]->vec[0]= asin(in[1]->vec[0]); else out[0]->vec[0]= 0.0; @@ -111,16 +111,16 @@ bNodeStack **out) break; case 8: /* Arc-Cosine */ { - if(in[0]->hasinput || !in[1]->hasinput) { /* This one only takes one input, so we've got to choose. */ + if (in[0]->hasinput || !in[1]->hasinput) { /* This one only takes one input, so we've got to choose. */ /* Can't do the impossible... */ - if( in[0]->vec[0] <= 1 && in[0]->vec[0] >= -1 ) + if ( in[0]->vec[0] <= 1 && in[0]->vec[0] >= -1 ) out[0]->vec[0]= acos(in[0]->vec[0]); else out[0]->vec[0]= 0.0; } else { /* Can't do the impossible... */ - if( in[1]->vec[0] <= 1 && in[1]->vec[0] >= -1 ) + if ( in[1]->vec[0] <= 1 && in[1]->vec[0] >= -1 ) out[0]->vec[0]= acos(in[1]->vec[0]); else out[0]->vec[0]= 0.0; @@ -129,7 +129,7 @@ bNodeStack **out) break; case 9: /* Arc-Tangent */ { - if(in[0]->hasinput || !in[1]->hasinput) /* This one only takes one input, so we've got to choose. */ + if (in[0]->hasinput || !in[1]->hasinput) /* This one only takes one input, so we've got to choose. */ out[0]->vec[0]= atan(in[0]->vec[0]); else out[0]->vec[0]= atan(in[1]->vec[0]); @@ -138,7 +138,7 @@ bNodeStack **out) case 10: /* Power */ { /* Don't want any imaginary numbers... */ - if( in[0]->vec[0] >= 0 ) + if ( in[0]->vec[0] >= 0 ) out[0]->vec[0]= pow(in[0]->vec[0], in[1]->vec[0]); else out[0]->vec[0]= 0.0; @@ -147,7 +147,7 @@ bNodeStack **out) case 11: /* Logarithm */ { /* Don't want any imaginary numbers... */ - if( in[0]->vec[0] > 0 && in[1]->vec[0] > 0 ) + if ( in[0]->vec[0] > 0 && in[1]->vec[0] > 0 ) out[0]->vec[0]= log(in[0]->vec[0]) / log(in[1]->vec[0]); else out[0]->vec[0]= 0.0; @@ -155,7 +155,7 @@ bNodeStack **out) break; case 12: /* Minimum */ { - if( in[0]->vec[0] < in[1]->vec[0] ) + if ( in[0]->vec[0] < in[1]->vec[0] ) out[0]->vec[0]= in[0]->vec[0]; else out[0]->vec[0]= in[1]->vec[0]; @@ -163,7 +163,7 @@ bNodeStack **out) break; case 13: /* Maximum */ { - if( in[0]->vec[0] > in[1]->vec[0] ) + if ( in[0]->vec[0] > in[1]->vec[0] ) out[0]->vec[0]= in[0]->vec[0]; else out[0]->vec[0]= in[1]->vec[0]; @@ -171,7 +171,7 @@ bNodeStack **out) break; case 14: /* Round */ { - if(in[0]->hasinput || !in[1]->hasinput) /* This one only takes one input, so we've got to choose. */ + if (in[0]->hasinput || !in[1]->hasinput) /* This one only takes one input, so we've got to choose. */ out[0]->vec[0]= (in[0]->vec[0]<0)?(int)(in[0]->vec[0] - 0.5f):(int)(in[0]->vec[0] + 0.5f); else out[0]->vec[0]= (in[1]->vec[0]<0)?(int)(in[1]->vec[0] - 0.5f):(int)(in[1]->vec[0] + 0.5f); @@ -179,7 +179,7 @@ bNodeStack **out) break; case 15: /* Less Than */ { - if( in[0]->vec[0] < in[1]->vec[0] ) + if ( in[0]->vec[0] < in[1]->vec[0] ) out[0]->vec[0]= 1.0f; else out[0]->vec[0]= 0.0f; @@ -187,7 +187,7 @@ bNodeStack **out) break; case 16: /* Greater Than */ { - if( in[0]->vec[0] > in[1]->vec[0] ) + if ( in[0]->vec[0] > in[1]->vec[0] ) out[0]->vec[0]= 1.0f; else out[0]->vec[0]= 0.0f; @@ -224,7 +224,7 @@ static int gpu_shader_math(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUN case 8: case 9: case 14: - if(in[0].hasinput || !in[1].hasinput) + if (in[0].hasinput || !in[1].hasinput) GPU_stack_link(mat, names[node->custom1], NULL, out, GPU_socket(&in[0])); else GPU_stack_link(mat, names[node->custom1], NULL, out, GPU_socket(&in[1])); diff --git a/source/blender/nodes/shader/nodes/node_shader_output.c b/source/blender/nodes/shader/nodes/node_shader_output.c index 8b0e9a5803b..14a115a8353 100644 --- a/source/blender/nodes/shader/nodes/node_shader_output.c +++ b/source/blender/nodes/shader/nodes/node_shader_output.c @@ -41,7 +41,7 @@ static bNodeSocketTemplate sh_node_output_in[]= { static void node_shader_exec_output(void *data, bNode *node, bNodeStack **in, bNodeStack **UNUSED(out)) { - if(data) { + if (data) { ShadeInput *shi= ((ShaderCallData *)data)->shi; float col[4]; @@ -49,12 +49,12 @@ static void node_shader_exec_output(void *data, bNode *node, bNodeStack **in, bN nodestack_get_vec(col, SOCK_VECTOR, in[0]); nodestack_get_vec(col+3, SOCK_FLOAT, in[1]); - if(shi->do_preview) { + if (shi->do_preview) { nodeAddToPreview(node, col, shi->xs, shi->ys, shi->do_manage); node->lasty= shi->ys; } - if(node->flag & NODE_DO_OUTPUT) { + if (node->flag & NODE_DO_OUTPUT) { ShadeResult *shr= ((ShaderCallData *)data)->shr; copy_v4_v4(shr->combined, col); @@ -70,7 +70,7 @@ static int gpu_shader_output(GPUMaterial *mat, bNode *UNUSED(node), GPUNodeStack GPUNodeLink *outlink; #if 0 - if(in[1].hasinput) + if (in[1].hasinput) GPU_material_enable_alpha(mat); #endif diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_checker.c b/source/blender/nodes/shader/nodes/node_shader_tex_checker.c index 551b70d9b8a..2fff2bab1d4 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_checker.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_checker.c @@ -54,7 +54,7 @@ static void node_shader_init_tex_checker(bNodeTree *UNUSED(ntree), bNode* node, static int node_shader_gpu_tex_checker(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *out) { - if(!in[0].link) + if (!in[0].link) in[0].link = GPU_attribute(CD_ORCO, ""); node_shader_gpu_tex_mapping(mat, node, in, out); diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_environment.c b/source/blender/nodes/shader/nodes/node_shader_tex_environment.c index 8ecff6e3767..852c056dc28 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_environment.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_environment.c @@ -55,13 +55,13 @@ static int node_shader_gpu_tex_environment(GPUMaterial *mat, bNode *node, GPUNod Image *ima= (Image*)node->id; ImageUser *iuser= NULL; - if(!ima) { + if (!ima) { float black[4] = {0.0f, 0.0f, 0.0f, 1.0f}; GPUNodeLink *vec = GPU_uniform(black); return GPU_stack_link(mat, "set_rgba", out, out, vec); } - if(!in[0].link) + if (!in[0].link) in[0].link = GPU_builtin(GPU_VIEW_POSITION); node_shader_gpu_tex_mapping(mat, node, in, out); diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_gradient.c b/source/blender/nodes/shader/nodes/node_shader_tex_gradient.c index a2403b6bdec..769cf845b42 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_gradient.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_gradient.c @@ -52,7 +52,7 @@ static void node_shader_init_tex_gradient(bNodeTree *UNUSED(ntree), bNode* node, static int node_shader_gpu_tex_gradient(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *out) { - if(!in[0].link) + if (!in[0].link) in[0].link = GPU_attribute(CD_ORCO, ""); node_shader_gpu_tex_mapping(mat, node, in, out); diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_image.c b/source/blender/nodes/shader/nodes/node_shader_tex_image.c index aa7ff279178..69e45469174 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_image.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_image.c @@ -54,13 +54,13 @@ static int node_shader_gpu_tex_image(GPUMaterial *mat, bNode *node, GPUNodeStack Image *ima= (Image*)node->id; ImageUser *iuser= NULL; - if(!ima) { + if (!ima) { float black[4] = {0.0f, 0.0f, 0.0f, 1.0f}; GPUNodeLink *vec = GPU_uniform(black); return GPU_stack_link(mat, "set_rgba", out, out, vec); } - if(!in[0].link) + if (!in[0].link) in[0].link = GPU_attribute(CD_MTFACE, ""); node_shader_gpu_tex_mapping(mat, node, in, out); diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_magic.c b/source/blender/nodes/shader/nodes/node_shader_tex_magic.c index 3a270220667..e2c0cfc020f 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_magic.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_magic.c @@ -57,7 +57,7 @@ static int node_shader_gpu_tex_magic(GPUMaterial *mat, bNode *node, GPUNodeStack NodeTexMagic *tex = (NodeTexMagic*)node->storage; float depth = tex->depth; - if(!in[0].link) + if (!in[0].link) in[0].link = GPU_attribute(CD_ORCO, ""); node_shader_gpu_tex_mapping(mat, node, in, out); diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_musgrave.c b/source/blender/nodes/shader/nodes/node_shader_tex_musgrave.c index 015b78687fd..9fe3e652eea 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_musgrave.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_musgrave.c @@ -58,7 +58,7 @@ static void node_shader_init_tex_musgrave(bNodeTree *UNUSED(ntree), bNode* node, static int node_shader_gpu_tex_musgrave(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *out) { - if(!in[0].link) + if (!in[0].link) in[0].link = GPU_attribute(CD_ORCO, ""); node_shader_gpu_tex_mapping(mat, node, in, out); diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_noise.c b/source/blender/nodes/shader/nodes/node_shader_tex_noise.c index bb365cf5a33..2667d2a5867 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_noise.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_noise.c @@ -54,7 +54,7 @@ static void node_shader_init_tex_noise(bNodeTree *UNUSED(ntree), bNode* node, bN static int node_shader_gpu_tex_noise(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *out) { - if(!in[0].link) + if (!in[0].link) in[0].link = GPU_attribute(CD_ORCO, ""); node_shader_gpu_tex_mapping(mat, node, in, out); diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_sky.c b/source/blender/nodes/shader/nodes/node_shader_tex_sky.c index a4131f3ca6c..b4855faaf94 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_sky.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_sky.c @@ -54,7 +54,7 @@ static void node_shader_init_tex_sky(bNodeTree *UNUSED(ntree), bNode* node, bNod static int node_shader_gpu_tex_sky(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *out) { - if(!in[0].link) + if (!in[0].link) in[0].link = GPU_attribute(CD_ORCO, ""); node_shader_gpu_tex_mapping(mat, node, in, out); diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.c b/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.c index 9adaab22b03..eebd4886c59 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.c @@ -53,7 +53,7 @@ static void node_shader_init_tex_voronoi(bNodeTree *UNUSED(ntree), bNode* node, static int node_shader_gpu_tex_voronoi(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *out) { - if(!in[0].link) + if (!in[0].link) in[0].link = GPU_attribute(CD_ORCO, ""); node_shader_gpu_tex_mapping(mat, node, in, out); diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_wave.c b/source/blender/nodes/shader/nodes/node_shader_tex_wave.c index d359a407bc0..3e079ffc4f4 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_wave.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_wave.c @@ -56,7 +56,7 @@ static void node_shader_init_tex_wave(bNodeTree *UNUSED(ntree), bNode* node, bNo static int node_shader_gpu_tex_wave(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *out) { - if(!in[0].link) + if (!in[0].link) in[0].link = GPU_attribute(CD_ORCO, ""); node_shader_gpu_tex_mapping(mat, node, in, out); diff --git a/source/blender/nodes/shader/nodes/node_shader_texture.c b/source/blender/nodes/shader/nodes/node_shader_texture.c index 02818496dab..8b6386fe2f6 100644 --- a/source/blender/nodes/shader/nodes/node_shader_texture.c +++ b/source/blender/nodes/shader/nodes/node_shader_texture.c @@ -48,7 +48,7 @@ static bNodeSocketTemplate sh_node_texture_out[]= { static void node_shader_exec_texture(void *data, bNode *node, bNodeStack **in, bNodeStack **out) { - if(data && node->id) { + if (data && node->id) { ShadeInput *shi= ((ShaderCallData *)data)->shi; TexResult texres; bNodeSocket *sock_vector= node->inputs.first; @@ -65,14 +65,14 @@ static void node_shader_exec_texture(void *data, bNode *node, bNodeStack **in, b texres.tr= texres.tg= texres.tb= 0.0f; /* don't use in[0]->hasinput, see material node for explanation */ - if(sock_vector->link) { + if (sock_vector->link) { nodestack_get_vec(vec, SOCK_VECTOR, in[0]); - if(in[0]->datatype==NS_OSA_VECTORS) { + if (in[0]->datatype==NS_OSA_VECTORS) { float *fp= in[0]->data; retval= multitex_nodes((Tex *)node->id, vec, fp, fp+3, shi->osatex, &texres, thread, which_output, NULL, NULL); } - else if(in[0]->datatype==NS_OSA_VALUES) { + else if (in[0]->datatype==NS_OSA_VALUES) { float *fp= in[0]->data; float dxt[3], dyt[3]; @@ -89,18 +89,18 @@ static void node_shader_exec_texture(void *data, bNode *node, bNodeStack **in, b } /* stupid exception */ - if( ((Tex *)node->id)->type==TEX_STUCCI) { + if ( ((Tex *)node->id)->type==TEX_STUCCI) { texres.tin= 0.5f + 0.7f*texres.nor[0]; CLAMP(texres.tin, 0.0f, 1.0f); } /* intensity and color need some handling */ - if(texres.talpha) + if (texres.talpha) out[0]->vec[0]= texres.ta; else out[0]->vec[0]= texres.tin; - if((retval & TEX_RGB)==0) { + if ((retval & TEX_RGB)==0) { out[1]->vec[0]= out[0]->vec[0]; out[1]->vec[1]= out[0]->vec[0]; out[1]->vec[2]= out[0]->vec[0]; @@ -115,7 +115,7 @@ static void node_shader_exec_texture(void *data, bNode *node, bNodeStack **in, b copy_v3_v3(out[2]->vec, nor); - if(shi->do_preview) + if (shi->do_preview) nodeAddToPreview(node, out[1]->vec, shi->xs, shi->ys, shi->do_manage); } @@ -125,7 +125,7 @@ static int gpu_shader_texture(GPUMaterial *mat, bNode *node, GPUNodeStack *in, G { Tex *tex = (Tex*)node->id; - if(tex && tex->type == TEX_IMAGE && tex->ima) { + if (tex && tex->type == TEX_IMAGE && tex->ima) { GPUNodeLink *texlink = GPU_image(tex->ima, NULL); return GPU_stack_link(mat, "texture_image", in, out, texlink); } diff --git a/source/blender/nodes/shader/nodes/node_shader_valToRgb.c b/source/blender/nodes/shader/nodes/node_shader_valToRgb.c index f0a94928985..a9513eec6ea 100644 --- a/source/blender/nodes/shader/nodes/node_shader_valToRgb.c +++ b/source/blender/nodes/shader/nodes/node_shader_valToRgb.c @@ -48,7 +48,7 @@ static void node_shader_exec_valtorgb(void *UNUSED(data), bNode *node, bNodeStac /* stack order in: fac */ /* stack order out: col, alpha */ - if(node->storage) { + if (node->storage) { float fac; nodestack_get_vec(&fac, SOCK_FLOAT, in[0]); diff --git a/source/blender/nodes/shader/nodes/node_shader_vectMath.c b/source/blender/nodes/shader/nodes/node_shader_vectMath.c index 75dbff11b6e..9b57780cd9d 100644 --- a/source/blender/nodes/shader/nodes/node_shader_vectMath.c +++ b/source/blender/nodes/shader/nodes/node_shader_vectMath.c @@ -54,39 +54,39 @@ static void node_shader_exec_vect_math(void *UNUSED(data), bNode *node, bNodeSta nodestack_get_vec(vec1, SOCK_VECTOR, in[0]); nodestack_get_vec(vec2, SOCK_VECTOR, in[1]); - if(node->custom1 == 0) { /* Add */ + if (node->custom1 == 0) { /* Add */ out[0]->vec[0]= vec1[0] + vec2[0]; out[0]->vec[1]= vec1[1] + vec2[1]; out[0]->vec[2]= vec1[2] + vec2[2]; out[1]->vec[0]= (fabs(out[0]->vec[0]) + fabs(out[0]->vec[0]) + fabs(out[0]->vec[0])) / 3; } - else if(node->custom1 == 1) { /* Subtract */ + else if (node->custom1 == 1) { /* Subtract */ out[0]->vec[0]= vec1[0] - vec2[0]; out[0]->vec[1]= vec1[1] - vec2[1]; out[0]->vec[2]= vec1[2] - vec2[2]; out[1]->vec[0]= (fabs(out[0]->vec[0]) + fabs(out[0]->vec[0]) + fabs(out[0]->vec[0])) / 3; } - else if(node->custom1 == 2) { /* Average */ + else if (node->custom1 == 2) { /* Average */ out[0]->vec[0]= vec1[0] + vec2[0]; out[0]->vec[1]= vec1[1] + vec2[1]; out[0]->vec[2]= vec1[2] + vec2[2]; out[1]->vec[0] = normalize_v3( out[0]->vec ); } - else if(node->custom1 == 3) { /* Dot product */ + else if (node->custom1 == 3) { /* Dot product */ out[1]->vec[0]= (vec1[0] * vec2[0]) + (vec1[1] * vec2[1]) + (vec1[2] * vec2[2]); } - else if(node->custom1 == 4) { /* Cross product */ + else if (node->custom1 == 4) { /* Cross product */ out[0]->vec[0]= (vec1[1] * vec2[2]) - (vec1[2] * vec2[1]); out[0]->vec[1]= (vec1[2] * vec2[0]) - (vec1[0] * vec2[2]); out[0]->vec[2]= (vec1[0] * vec2[1]) - (vec1[1] * vec2[0]); out[1]->vec[0] = normalize_v3( out[0]->vec ); } - else if(node->custom1 == 5) { /* Normalize */ - if(in[0]->hasinput || !in[1]->hasinput) { /* This one only takes one input, so we've got to choose. */ + else if (node->custom1 == 5) { /* Normalize */ + if (in[0]->hasinput || !in[1]->hasinput) { /* This one only takes one input, so we've got to choose. */ out[0]->vec[0]= vec1[0]; out[0]->vec[1]= vec1[1]; out[0]->vec[2]= vec1[2]; @@ -118,7 +118,7 @@ static int gpu_shader_vect_math(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPU_socket(&in[0]), GPU_socket(&in[1])); break; case 5: - if(in[0].hasinput || !in[1].hasinput) + if (in[0].hasinput || !in[1].hasinput) GPU_stack_link(mat, names[node->custom1], NULL, out, GPU_socket(&in[0])); else GPU_stack_link(mat, names[node->custom1], NULL, out, GPU_socket(&in[1])); diff --git a/source/blender/nodes/texture/node_texture_tree.c b/source/blender/nodes/texture/node_texture_tree.c index 2795cbd3e5a..add9fdb0b30 100644 --- a/source/blender/nodes/texture/node_texture_tree.c +++ b/source/blender/nodes/texture/node_texture_tree.c @@ -57,8 +57,8 @@ static void foreach_nodetree(Main *main, void *calldata, bNodeTreeCallback func) { Tex *tx; - for(tx= main->tex.first; tx; tx= tx->id.next) { - if(tx->nodetree) { + for (tx= main->tex.first; tx; tx= tx->id.next) { + if (tx->nodetree) { func(calldata, &tx->id, tx->nodetree); } } @@ -97,12 +97,12 @@ static void local_sync(bNodeTree *localtree, bNodeTree *ntree) bNode *lnode; /* copy over contents of previews */ - for(lnode= localtree->nodes.first; lnode; lnode= lnode->next) { - if(ntreeNodeExists(ntree, lnode->new_node)) { + for (lnode= localtree->nodes.first; lnode; lnode= lnode->next) { + if (ntreeNodeExists(ntree, lnode->new_node)) { bNode *node= lnode->new_node; - if(node->preview && node->preview->rect) { - if(lnode->preview && lnode->preview->rect) { + if (node->preview && node->preview->rect) { + if (lnode->preview && lnode->preview->rect) { int xsize= node->preview->xsize; int ysize= node->preview->ysize; memcpy(node->preview->rect, lnode->preview->rect, 4*xsize + xsize*ysize*sizeof(char)*4); @@ -135,15 +135,15 @@ int ntreeTexTagAnimated(bNodeTree *ntree) { bNode *node; - if(ntree==NULL) return 0; + if (ntree==NULL) return 0; - for(node= ntree->nodes.first; node; node= node->next) { - if(node->type==TEX_NODE_CURVE_TIME) { + for (node= ntree->nodes.first; node; node= node->next) { + if (node->type==TEX_NODE_CURVE_TIME) { nodeUpdate(ntree, node); return 1; } - else if(node->type==NODE_GROUP) { - if( ntreeTexTagAnimated((bNodeTree *)node->id) ) { + else if (node->type==NODE_GROUP) { + if ( ntreeTexTagAnimated((bNodeTree *)node->id) ) { return 1; } } @@ -174,7 +174,7 @@ bNodeTreeExec *ntreeTexBeginExecTree(bNodeTree *ntree, int use_tree_data) /* allocate the thread stack listbase array */ exec->threadstack= MEM_callocN(BLENDER_MAX_THREADS*sizeof(ListBase), "thread stack array"); - for(node= exec->nodetree->nodes.first; node; node= node->next) + for (node= exec->nodetree->nodes.first; node; node= node->next) node->need_exec= 1; if (use_tree_data) { @@ -194,10 +194,10 @@ static void tex_free_delegates(bNodeTreeExec *exec) bNodeStack *ns; int th, a; - for(th=0; th<BLENDER_MAX_THREADS; th++) - for(nts=exec->threadstack[th].first; nts; nts=nts->next) - for(ns= nts->stack, a=0; a<exec->stacksize; a++, ns++) - if(ns->data && !ns->is_copy) + for (th=0; th<BLENDER_MAX_THREADS; th++) + for (nts=exec->threadstack[th].first; nts; nts=nts->next) + for (ns= nts->stack, a=0; a<exec->stacksize; a++, ns++) + if (ns->data && !ns->is_copy) MEM_freeN(ns->data); } @@ -206,16 +206,16 @@ static void tex_free_delegates(bNodeTreeExec *exec) */ void ntreeTexEndExecTree(bNodeTreeExec *exec, int use_tree_data) { - if(exec) { + if (exec) { bNodeTree *ntree= exec->nodetree; bNodeThreadStack *nts; int a; - if(exec->threadstack) { + if (exec->threadstack) { tex_free_delegates(exec); - for(a=0; a<BLENDER_MAX_THREADS; a++) { - for(nts=exec->threadstack[a].first; nts; nts=nts->next) + for (a=0; a<BLENDER_MAX_THREADS; a++) { + for (nts=exec->threadstack[a].first; nts; nts=nts->next) if (nts->stack) MEM_freeN(nts->stack); BLI_freelistN(&exec->threadstack[a]); } @@ -246,7 +246,7 @@ int ntreeTexExecTree( int preview, ShadeInput *shi, MTex *mtex -){ +) { TexCallData data; float *nor= texres->nor; int retval = TEX_INT; @@ -268,7 +268,7 @@ int ntreeTexExecTree( /* ensure execdata is only initialized once */ if (!exec) { BLI_lock_thread(LOCK_NODES); - if(!nodes->execdata) + if (!nodes->execdata) ntreeTexBeginExecTree(nodes, 1); BLI_unlock_thread(LOCK_NODES); @@ -279,7 +279,7 @@ int ntreeTexExecTree( ntreeExecThreadNodes(exec, nts, &data, thread); ntreeReleaseThreadStack(nts); - if(texres->nor) retval |= TEX_NOR; + if (texres->nor) retval |= TEX_NOR; retval |= TEX_RGB; /* confusing stuff; the texture output node sets this to NULL to indicate no normal socket was set however, the texture code checks this for other reasons (namely, a normal is required for material) */ diff --git a/source/blender/nodes/texture/node_texture_util.c b/source/blender/nodes/texture/node_texture_util.c index a528f8cb7a7..255ed9e51fc 100644 --- a/source/blender/nodes/texture/node_texture_util.c +++ b/source/blender/nodes/texture/node_texture_util.c @@ -53,10 +53,10 @@ static void tex_call_delegate(TexDelegate *dg, float *out, TexParams *params, short thread) { - if(dg->node->need_exec) { + if (dg->node->need_exec) { dg->fn(out, params, dg->node, dg->in, thread); - if(dg->cdata->do_preview) + if (dg->cdata->do_preview) tex_do_preview(dg->node, params->previewco, out); } } @@ -64,10 +64,10 @@ static void tex_call_delegate(TexDelegate *dg, float *out, TexParams *params, sh static void tex_input(float *out, int sz, bNodeStack *in, TexParams *params, short thread) { TexDelegate *dg = in->data; - if(dg) { + if (dg) { tex_call_delegate(dg, in->vec, params, thread); - if(in->hasoutput && in->sockettype == SOCK_FLOAT) + if (in->hasoutput && in->sockettype == SOCK_FLOAT) in->vec[1] = in->vec[2] = in->vec[0]; } memcpy(out, in->vec, sz * sizeof(float)); @@ -118,7 +118,7 @@ void tex_do_preview(bNode *node, float *co, float *col) { bNodePreview *preview= node->preview; - if(preview) { + if (preview) { int xs= ((co[0] + 1.0f)*0.5f)*preview->xsize; int ys= ((co[1] + 1.0f)*0.5f)*preview->ysize; @@ -129,7 +129,7 @@ void tex_do_preview(bNode *node, float *co, float *col) void tex_output(bNode *node, bNodeStack **in, bNodeStack *out, TexFn texfn, TexCallData *cdata) { TexDelegate *dg; - if(!out->data) + if (!out->data) /* Freed in tex_end_exec (node.c) */ dg = out->data = MEM_mallocN(sizeof(TexDelegate), "tex delegate"); else @@ -145,20 +145,21 @@ void tex_output(bNode *node, bNodeStack **in, bNodeStack *out, TexFn texfn, TexC void ntreeTexCheckCyclics(struct bNodeTree *ntree) { bNode *node; - for(node= ntree->nodes.first; node; node= node->next) { + for (node= ntree->nodes.first; node; node= node->next) { - if(node->type == TEX_NODE_TEXTURE && node->id) { + if (node->type == TEX_NODE_TEXTURE && node->id) { /* custom2 stops the node from rendering */ - if(node->custom1) { + if (node->custom1) { node->custom2 = 1; node->custom1 = 0; - } else { + } + else { Tex *tex = (Tex *)node->id; node->custom2 = 0; node->custom1 = 1; - if(tex->use_nodes && tex->nodetree) { + if (tex->use_nodes && tex->nodetree) { ntreeTexCheckCyclics(tex->nodetree); } node->custom1 = 0; diff --git a/source/blender/nodes/texture/nodes/node_texture_bricks.c b/source/blender/nodes/texture/nodes/node_texture_bricks.c index 9e76309bce9..ac8799762bd 100644 --- a/source/blender/nodes/texture/nodes/node_texture_bricks.c +++ b/source/blender/nodes/texture/nodes/node_texture_bricks.c @@ -91,7 +91,7 @@ static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor rownum = (int)floor(y / row_height); - if( node->custom1 && node->custom2 ) { + if ( node->custom1 && node->custom2 ) { brick_width *= ((int)(rownum) % node->custom2 ) ? 1.0f : node->custom4; /* squash */ offset = ((int)(rownum) % node->custom1 ) ? 0 : (brick_width*node->custom3); /* offset */ } @@ -104,11 +104,12 @@ static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor tint = noise((rownum << 16) + (bricknum & 0xFFFF)) + bias; CLAMP(tint,0.0f,1.0f); - if( ins_x < mortar_thickness || ins_y < mortar_thickness || + if ( ins_x < mortar_thickness || ins_y < mortar_thickness || ins_x > (brick_width - mortar_thickness) || ins_y > (row_height - mortar_thickness) ) { copy_v4_v4( out, mortar ); - } else { + } + else { copy_v4_v4( out, bricks1 ); ramp_blend( MA_RAMP_BLEND, out, tint, bricks2 ); } diff --git a/source/blender/nodes/texture/nodes/node_texture_checker.c b/source/blender/nodes/texture/nodes/node_texture_checker.c index 6b5848270ba..c96a73d09f2 100644 --- a/source/blender/nodes/texture/nodes/node_texture_checker.c +++ b/source/blender/nodes/texture/nodes/node_texture_checker.c @@ -57,9 +57,10 @@ static void colorfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack ** int yi = (int)fabs(floor(0.00001f + y / sz)); int zi = (int)fabs(floor(0.00001f + z / sz)); - if( (xi % 2 == yi % 2) == (zi % 2) ) { + if ( (xi % 2 == yi % 2) == (zi % 2) ) { tex_input_rgba(out, in[0], p, thread); - } else { + } + else { tex_input_rgba(out, in[1], p, thread); } } diff --git a/source/blender/nodes/texture/nodes/node_texture_compose.c b/source/blender/nodes/texture/nodes/node_texture_compose.c index 5256db98d78..a3ac196ab12 100644 --- a/source/blender/nodes/texture/nodes/node_texture_compose.c +++ b/source/blender/nodes/texture/nodes/node_texture_compose.c @@ -48,7 +48,7 @@ static bNodeSocketTemplate outputs[]= { static void colorfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread) { int i; - for(i = 0; i < 4; i++) + for (i = 0; i < 4; i++) out[i] = tex_input_value(in[i], p, thread); } diff --git a/source/blender/nodes/texture/nodes/node_texture_curves.c b/source/blender/nodes/texture/nodes/node_texture_curves.c index 08e7efc1606..0f7213a5be0 100644 --- a/source/blender/nodes/texture/nodes/node_texture_curves.c +++ b/source/blender/nodes/texture/nodes/node_texture_curves.c @@ -46,7 +46,7 @@ static void time_colorfn(float *out, TexParams *p, bNode *node, bNodeStack **UNU /* stack order output: fac */ float fac= 0.0f; - if(node->custom1 < node->custom2) + if (node->custom1 < node->custom2) fac = (p->cfra - node->custom1)/(float)(node->custom2-node->custom1); fac = curvemapping_evaluateF(node->storage, 0, fac); diff --git a/source/blender/nodes/texture/nodes/node_texture_hueSatVal.c b/source/blender/nodes/texture/nodes/node_texture_hueSatVal.c index e566fb0298a..d5a957a3b28 100644 --- a/source/blender/nodes/texture/nodes/node_texture_hueSatVal.c +++ b/source/blender/nodes/texture/nodes/node_texture_hueSatVal.c @@ -49,16 +49,16 @@ static bNodeSocketTemplate outputs[]= { static void do_hue_sat_fac(bNode *UNUSED(node), float *out, float hue, float sat, float val, float *in, float fac) { - if(fac != 0 && (hue != 0.5f || sat != 1 || val != 1)) { + if (fac != 0 && (hue != 0.5f || sat != 1 || val != 1)) { float col[3], hsv[3], mfac= 1.0f - fac; rgb_to_hsv(in[0], in[1], in[2], hsv, hsv+1, hsv+2); hsv[0]+= (hue - 0.5f); - if(hsv[0]>1.0f) hsv[0]-=1.0f; else if(hsv[0]<0.0f) hsv[0]+= 1.0f; + if (hsv[0]>1.0f) hsv[0]-=1.0f; else if (hsv[0]<0.0f) hsv[0]+= 1.0f; hsv[1]*= sat; - if(hsv[1]>1.0f) hsv[1]= 1.0f; else if(hsv[1]<0.0f) hsv[1]= 0.0f; + if (hsv[1]>1.0f) hsv[1]= 1.0f; else if (hsv[1]<0.0f) hsv[1]= 0.0f; hsv[2]*= val; - if(hsv[2]>1.0f) hsv[2]= 1.0f; else if(hsv[2]<0.0f) hsv[2]= 0.0f; + if (hsv[2]>1.0f) hsv[2]= 1.0f; else if (hsv[2]<0.0f) hsv[2]= 0.0f; hsv_to_rgb(hsv[0], hsv[1], hsv[2], col, col+1, col+2); out[0]= mfac*in[0] + fac*col[0]; diff --git a/source/blender/nodes/texture/nodes/node_texture_image.c b/source/blender/nodes/texture/nodes/node_texture_image.c index 0acfe62ed82..d0bc30089e2 100644 --- a/source/blender/nodes/texture/nodes/node_texture_image.c +++ b/source/blender/nodes/texture/nodes/node_texture_image.c @@ -45,9 +45,9 @@ static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **UNUSED(i Image *ima= (Image *)node->id; ImageUser *iuser= (ImageUser *)node->storage; - if( ima ) { + if ( ima ) { ImBuf *ibuf = BKE_image_get_ibuf(ima, iuser); - if( ibuf ) { + if ( ibuf ) { float xsize, ysize; float xoff, yoff; int px, py; @@ -61,19 +61,19 @@ static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **UNUSED(i px = (int)( (x-xoff) * xsize ); py = (int)( (y-yoff) * ysize ); - if( (!xsize) || (!ysize) ) return; + if ( (!xsize) || (!ysize) ) return; - if( !ibuf->rect_float ) { + if ( !ibuf->rect_float ) { BLI_lock_thread(LOCK_IMAGE); - if( !ibuf->rect_float ) + if ( !ibuf->rect_float ) IMB_float_from_rect(ibuf); BLI_unlock_thread(LOCK_IMAGE); } - while( px < 0 ) px += ibuf->x; - while( py < 0 ) py += ibuf->y; - while( px >= ibuf->x ) px -= ibuf->x; - while( py >= ibuf->y ) py -= ibuf->y; + while ( px < 0 ) px += ibuf->x; + while ( py < 0 ) py += ibuf->y; + while ( px >= ibuf->x ) px -= ibuf->x; + while ( py >= ibuf->y ) py -= ibuf->y; result = ibuf->rect_float + py*ibuf->x*4 + px*4; copy_v4_v4( out, result ); diff --git a/source/blender/nodes/texture/nodes/node_texture_math.c b/source/blender/nodes/texture/nodes/node_texture_math.c index 4659aa2b6c0..29d154df884 100644 --- a/source/blender/nodes/texture/nodes/node_texture_math.c +++ b/source/blender/nodes/texture/nodes/node_texture_math.c @@ -51,7 +51,7 @@ static void valuefn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor float in0 = tex_input_value(in[0], p, thread); float in1 = tex_input_value(in[1], p, thread); - switch(node->custom1){ + switch(node->custom1) { case 0: /* Add */ *out= in0 + in1; @@ -64,7 +64,7 @@ static void valuefn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor break; case 3: /* Divide */ { - if(in1==0) /* We don't want to divide by zero. */ + if (in1==0) /* We don't want to divide by zero. */ *out= 0.0; else *out= in0 / in1; @@ -88,7 +88,7 @@ static void valuefn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor case 7: /* Arc-Sine */ { /* Can't do the impossible... */ - if( in0 <= 1 && in0 >= -1 ) + if ( in0 <= 1 && in0 >= -1 ) *out= asin(in0); else *out= 0.0; @@ -97,7 +97,7 @@ static void valuefn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor case 8: /* Arc-Cosine */ { /* Can't do the impossible... */ - if( in0 <= 1 && in0 >= -1 ) + if ( in0 <= 1 && in0 >= -1 ) *out= acos(in0); else *out= 0.0; @@ -111,13 +111,15 @@ static void valuefn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor case 10: /* Power */ { /* Only raise negative numbers by full integers */ - if( in0 >= 0 ) { + if ( in0 >= 0 ) { out[0]= pow(in0, in1); - } else { + } + else { float y_mod_1 = fmod(in1, 1); if (y_mod_1 > 0.999f || y_mod_1 < 0.001f) { *out = pow(in0, floor(in1 + 0.5f)); - } else { + } + else { *out = 0.0; } } @@ -126,7 +128,7 @@ static void valuefn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor case 11: /* Logarithm */ { /* Don't want any imaginary numbers... */ - if( in0 > 0 && in1 > 0 ) + if ( in0 > 0 && in1 > 0 ) *out= log(in0) / log(in1); else *out= 0.0; @@ -134,7 +136,7 @@ static void valuefn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor break; case 12: /* Minimum */ { - if( in0 < in1 ) + if ( in0 < in1 ) *out= in0; else *out= in1; @@ -142,7 +144,7 @@ static void valuefn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor break; case 13: /* Maximum */ { - if( in0 > in1 ) + if ( in0 > in1 ) *out= in0; else *out= in1; @@ -156,7 +158,7 @@ static void valuefn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor case 15: /* Less Than */ { - if( in0 < in1 ) + if ( in0 < in1 ) *out= 1.0f; else *out= 0.0f; @@ -165,7 +167,7 @@ static void valuefn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor case 16: /* Greater Than */ { - if( in0 > in1 ) + if ( in0 > in1 ) *out= 1.0f; else *out= 0.0f; diff --git a/source/blender/nodes/texture/nodes/node_texture_output.c b/source/blender/nodes/texture/nodes/node_texture_output.c index 36b31a864a5..22748fec2ea 100644 --- a/source/blender/nodes/texture/nodes/node_texture_output.c +++ b/source/blender/nodes/texture/nodes/node_texture_output.c @@ -46,11 +46,11 @@ static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **UNUSED(o TexCallData *cdata = (TexCallData *)data; TexResult *target = cdata->target; - if(cdata->do_preview) { + if (cdata->do_preview) { TexParams params; params_from_cdata(¶ms, cdata); - if(in[1] && in[1]->hasinput && !in[0]->hasinput) + if (in[1] && in[1]->hasinput && !in[0]->hasinput) tex_input_rgba(&target->tr, in[1], ¶ms, cdata->thread); else tex_input_rgba(&target->tr, in[0], ¶ms, cdata->thread); @@ -58,7 +58,7 @@ static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **UNUSED(o } else { /* 0 means don't care, so just use first */ - if(cdata->which_output == node->custom1 || (cdata->which_output == 0 && node->custom1 == 1)) { + if (cdata->which_output == node->custom1 || (cdata->which_output == 0 && node->custom1 == 1)) { TexParams params; params_from_cdata(¶ms, cdata); @@ -67,8 +67,8 @@ static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **UNUSED(o target->tin = (target->tr + target->tg + target->tb) / 3.0f; target->talpha = 1; - if(target->nor) { - if(in[1] && in[1]->hasinput) + if (target->nor) { + if (in[1] && in[1]->hasinput) tex_input_vec(target->nor, in[1], ¶ms, cdata->thread); else target->nor = NULL; @@ -88,22 +88,23 @@ static void unique_name(bNode *node) i = node; while(i->prev) i = i->prev; - for(; i; i=i->next) { - if( + for (; i; i=i->next) { + if ( i == node || i->type != TEX_NODE_OUTPUT || strcmp(name, ((TexNodeOutput*)(i->storage))->name) ) continue; - if(!new_name) { + if (!new_name) { int len = strlen(name); - if(len >= 4 && sscanf(name + len - 4, ".%03d", &suffix) == 1) { + if (len >= 4 && sscanf(name + len - 4, ".%03d", &suffix) == 1) { new_len = len; - } else { + } + else { suffix = 0; new_len = len + 4; - if(new_len > (sizeof(tno->name) - 1)) + if (new_len > (sizeof(tno->name) - 1)) new_len = (sizeof(tno->name) - 1); } @@ -114,7 +115,7 @@ static void unique_name(bNode *node) sprintf(new_name + new_len - 4, ".%03d", ++suffix); } - if(new_name) { + if (new_name) { strcpy(tno->name, new_name); MEM_freeN(new_name); } @@ -130,9 +131,9 @@ static void assign_index(struct bNode *node) tnode = tnode->prev; check_index: - for(; tnode; tnode= tnode->next) - if(tnode->type == TEX_NODE_OUTPUT && tnode != node) - if(tnode->custom1 == index) { + for (; tnode; tnode= tnode->next) + if (tnode->type == TEX_NODE_OUTPUT && tnode != node) + if (tnode->custom1 == index) { index ++; goto check_index; } diff --git a/source/blender/nodes/texture/nodes/node_texture_proc.c b/source/blender/nodes/texture/nodes/node_texture_proc.c index efc8228c01c..348827bd26c 100644 --- a/source/blender/nodes/texture/nodes/node_texture_proc.c +++ b/source/blender/nodes/texture/nodes/node_texture_proc.c @@ -62,7 +62,7 @@ static void do_proc(float *result, TexParams *p, float *col1, float *col2, char TexResult texres; int textype; - if(is_normal) { + if (is_normal) { texres.nor = result; } else @@ -71,10 +71,10 @@ static void do_proc(float *result, TexParams *p, float *col1, float *col2, char textype = multitex_nodes(tex, p->co, p->dxt, p->dyt, p->osatex, &texres, thread, 0, p->shi, p->mtex); - if(is_normal) + if (is_normal) return; - if(textype & TEX_RGB) { + if (textype & TEX_RGB) { copy_v4_v4(result, &texres.tr); } else { @@ -108,7 +108,7 @@ static int count_outputs(bNode *node) { bNodeSocket *sock; int num = 0; - for(sock= node->outputs.first; sock; sock= sock->next) { + for (sock= node->outputs.first; sock; sock= sock->next) { num++; } return num; @@ -132,8 +132,8 @@ static int count_outputs(bNode *node) static void name##_exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) \ { \ int outs = count_outputs(node); \ - if(outs >= 1) tex_output(node, in, out[0], &name##_colorfn, data); \ - if(outs >= 2) tex_output(node, in, out[1], &name##_normalfn, data); \ + if (outs >= 1) tex_output(node, in, out[0], &name##_colorfn, data); \ + if (outs >= 2) tex_output(node, in, out[1], &name##_normalfn, data); \ } @@ -289,7 +289,7 @@ static void init(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(nt default_tex(tex); tex->type = node->type - TEX_NODE_PROC; - if(tex->type == TEX_WOOD) + if (tex->type == TEX_WOOD) tex->stype = TEX_BANDNOISE; } diff --git a/source/blender/nodes/texture/nodes/node_texture_texture.c b/source/blender/nodes/texture/nodes/node_texture_texture.c index d408b874b84..bf93231c306 100644 --- a/source/blender/nodes/texture/nodes/node_texture_texture.c +++ b/source/blender/nodes/texture/nodes/node_texture_texture.c @@ -63,11 +63,11 @@ static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor zero_v3(dyt); } - if(node->custom2 || node->need_exec==0) { + if (node->custom2 || node->need_exec==0) { /* this node refers to its own texture tree! */ copy_v4_v4(out, (fabs(co[0] - co[1]) < .01) ? white : red ); } - else if(nodetex) { + else if (nodetex) { TexResult texres; int textype; float nor[] = {0,0,0}; @@ -80,7 +80,7 @@ static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor textype = multitex_nodes(nodetex, co, dxt, dyt, p->osatex, &texres, thread, 0, p->shi, p->mtex); - if(textype & TEX_RGB) { + if (textype & TEX_RGB) { copy_v4_v4(out, &texres.tr); } else { diff --git a/source/blender/nodes/texture/nodes/node_texture_valToRgb.c b/source/blender/nodes/texture/nodes/node_texture_valToRgb.c index c0efa43c14f..1d282b4d4cc 100644 --- a/source/blender/nodes/texture/nodes/node_texture_valToRgb.c +++ b/source/blender/nodes/texture/nodes/node_texture_valToRgb.c @@ -45,7 +45,7 @@ static bNodeSocketTemplate valtorgb_out[]= { static void valtorgb_colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread) { - if(node->storage) { + if (node->storage) { float fac = tex_input_value(in[0], p, thread); do_colorband(node->storage, fac, out); diff --git a/source/blender/nodes/texture/nodes/node_texture_viewer.c b/source/blender/nodes/texture/nodes/node_texture_viewer.c index 401e72761e3..0d7a04b06e2 100644 --- a/source/blender/nodes/texture/nodes/node_texture_viewer.c +++ b/source/blender/nodes/texture/nodes/node_texture_viewer.c @@ -46,7 +46,7 @@ static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **UNUSED(o { TexCallData *cdata = (TexCallData *)data; - if(cdata->do_preview) { + if (cdata->do_preview) { TexParams params; float col[4]; params_from_cdata(¶ms, cdata); diff --git a/source/blender/render/intern/raytrace/rayobject_octree.cpp b/source/blender/render/intern/raytrace/rayobject_octree.cpp index 3e2c60cfcc0..0411173f07f 100644 --- a/source/blender/render/intern/raytrace/rayobject_octree.cpp +++ b/source/blender/render/intern/raytrace/rayobject_octree.cpp @@ -158,7 +158,8 @@ static void calc_ocval_ray(OcVal *ov, float xo, float yo, float zo, float *vec1, if(vec1[0]<vec2[0]) { ocmin= OCVALRES*(vec1[0] - xo); ocmax= OCVALRES*(vec2[0] - xo); - } else { + } + else { ocmin= OCVALRES*(vec2[0] - xo); ocmax= OCVALRES*(vec1[0] - xo); } @@ -167,7 +168,8 @@ static void calc_ocval_ray(OcVal *ov, float xo, float yo, float zo, float *vec1, if(vec1[1]<vec2[1]) { ocmin= OCVALRES*(vec1[1] - yo); ocmax= OCVALRES*(vec2[1] - yo); - } else { + } + else { ocmin= OCVALRES*(vec2[1] - yo); ocmax= OCVALRES*(vec1[1] - yo); } @@ -176,7 +178,8 @@ static void calc_ocval_ray(OcVal *ov, float xo, float yo, float zo, float *vec1, if(vec1[2]<vec2[2]) { ocmin= OCVALRES*(vec1[2] - zo); ocmax= OCVALRES*(vec2[2] - zo); - } else { + } + else { ocmin= OCVALRES*(vec2[2] - zo); ocmax= OCVALRES*(vec1[2] - zo); } @@ -348,12 +351,14 @@ static void d2dda(Octree *oc, short b1, short b2, short c1, short c2, char *ocfa labdax= (ox1-ocx1-1.0f)/(ox1-ox2); ldx= -1.0f/(ox1-ox2); dx= 1; - } else { + } + else { labdax= (ox1-ocx1)/(ox1-ox2); ldx= 1.0f/(ox1-ox2); dx= -1; } - } else { + } + else { labdax=1.0f; ldx=0; } @@ -363,12 +368,14 @@ static void d2dda(Octree *oc, short b1, short b2, short c1, short c2, char *ocfa labday= (oy1-ocy1-1.0f)/(oy1-oy2); ldy= -1.0f/(oy1-oy2); dy= 1; - } else { + } + else { labday= (oy1-ocy1)/(oy1-oy2); ldy= 1.0f/(oy1-oy2); dy= -1; } - } else { + } + else { labday=1.0f; ldy=0; } @@ -387,11 +394,13 @@ static void d2dda(Octree *oc, short b1, short b2, short c1, short c2, char *ocfa x+=dx; labday+=ldy; y+=dy; - } else { + } + else { if(labdax<labday) { labdax+=ldx; x+=dx; - } else { + } + else { labday+=ldy; y+=dy; } @@ -940,11 +949,13 @@ static int RE_rayobject_octree_intersect(RayObject *tree, Isect *is) ldx= -1.0f/dox; labdax= (ocx1-ox1+1.0f)*ldx; dx= 1; - } else if(dox>FLT_EPSILON) { + } + else if(dox>FLT_EPSILON) { ldx= 1.0f/dox; labdax= (ox1-ocx1)*ldx; dx= -1; - } else { + } + else { labdax=1.0f; ldx=0; dx= 0; @@ -954,11 +965,13 @@ static int RE_rayobject_octree_intersect(RayObject *tree, Isect *is) ldy= -1.0f/doy; labday= (ocy1-oy1+1.0f)*ldy; dy= 1; - } else if(doy>FLT_EPSILON) { + } + else if(doy>FLT_EPSILON) { ldy= 1.0f/doy; labday= (oy1-ocy1)*ldy; dy= -1; - } else { + } + else { labday=1.0f; ldy=0; dy= 0; @@ -968,11 +981,13 @@ static int RE_rayobject_octree_intersect(RayObject *tree, Isect *is) ldz= -1.0f/doz; labdaz= (ocz1-oz1+1.0f)*ldz; dz= 1; - } else if(doz>FLT_EPSILON) { + } + else if(doz>FLT_EPSILON) { ldz= 1.0f/doz; labdaz= (oz1-ocz1)*ldz; dz= -1; - } else { + } + else { labdaz=1.0f; ldz=0; dz= 0; diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index a4c5adda721..7dd11dd1fe0 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -171,7 +171,7 @@ void RE_make_stars(Render *re, Scene *scenev3d, void (*initfunc)(void), int x, y, z, sx, sy, sz, ex, ey, ez, done = 0; unsigned int totstar= 0; - if(initfunc) { + if (initfunc) { scene= scenev3d; wrld= scene->world; } @@ -195,7 +195,7 @@ void RE_make_stars(Render *re, Scene *scenev3d, void (*initfunc)(void), if (re) re->flag |= R_HALO; else stargrid *= 1.0f; /* then it draws fewer */ - if(re) invert_m4_m4(mat, re->viewmat); + if (re) invert_m4_m4(mat, re->viewmat); else unit_m4(mat); /* BOUNDING BOX CALCULATION @@ -206,7 +206,7 @@ void RE_make_stars(Render *re, Scene *scenev3d, void (*initfunc)(void), camera= re ? RE_GetCamera(re) : scene->camera; - if(camera==NULL || camera->type != OB_CAMERA) + if (camera==NULL || camera->type != OB_CAMERA) return; cam = camera->data; @@ -229,7 +229,7 @@ void RE_make_stars(Render *re, Scene *scenev3d, void (*initfunc)(void), initfunc(); } - if(re) /* add render object for stars */ + if (re) /* add render object for stars */ obr= RE_addRenderObject(re, NULL, NULL, 0, 0, 0); for (x = sx, fx = sx * stargrid; x <= ex; x++, fx += stargrid) { @@ -243,7 +243,7 @@ void RE_make_stars(Render *re, Scene *scenev3d, void (*initfunc)(void), vec[3] = 1.0; if (vertexfunc) { - if(done & 1) vertexfunc(vec); + if (done & 1) vertexfunc(vec); done++; } else { @@ -267,7 +267,8 @@ void RE_make_stars(Render *re, Scene *scenev3d, void (*initfunc)(void), else if (alpha <= starmindist) alpha = 0.0; else if (alpha <= 2.0f * starmindist) { alpha = (alpha - starmindist) / starmindist; - } else { + } + else { alpha -= 2.0f * starmindist; alpha /= (clipend - 2.0f * starmindist); alpha = 1.0f - alpha; @@ -298,8 +299,8 @@ void RE_make_stars(Render *re, Scene *scenev3d, void (*initfunc)(void), } /* break out of the loop if generating stars takes too long */ - if(re && !(totstar % 1000000)) { - if(re->test_break(re->tbh)) { + if (re && !(totstar % 1000000)) { + if (re->test_break(re->tbh)) { x= ex + 1; y= ey + 1; z= ez + 1; @@ -314,7 +315,7 @@ void RE_make_stars(Render *re, Scene *scenev3d, void (*initfunc)(void), } if (termfunc) termfunc(); - if(obr) + if (obr) re->tothalo += obr->tothalo; } @@ -354,11 +355,13 @@ static void split_v_renderfaces(ObjectRen *obr, int startvlak, int UNUSED(startv if (v==vLen-1) { VlakRen *vlr = RE_findOrAddVlak(obr, startvlak + vLen*uIndex + 0); vlr->v1 = vert; - } else { + } + else { VlakRen *vlr = RE_findOrAddVlak(obr, startvlak + vLen*uIndex + v+1); vlr->v1 = vert; } - } else { + } + else { vlr->v2 = vert; if (v<vLen-1) { @@ -396,16 +399,16 @@ static void calc_edge_stress(Render *UNUSED(re), ObjectRen *obr, Mesh *me) float loc[3], size[3], *accum, *acc, *accumoffs, *stress; int a; - if(obr->totvert==0) return; + if (obr->totvert==0) return; mesh_get_texspace(me, loc, NULL, size); accum= MEM_callocN(2*sizeof(float)*obr->totvert, "temp accum for stress"); /* de-normalize orco */ - for(a=0; a<obr->totvert; a++) { + for (a=0; a<obr->totvert; a++) { VertRen *ver= RE_findOrAddVert(obr, a); - if(ver->orco) { + if (ver->orco) { ver->orco[0]= ver->orco[0]*size[0] +loc[0]; ver->orco[1]= ver->orco[1]*size[1] +loc[1]; ver->orco[2]= ver->orco[2]*size[2] +loc[2]; @@ -414,14 +417,14 @@ static void calc_edge_stress(Render *UNUSED(re), ObjectRen *obr, Mesh *me) /* add stress values */ accumoffs= accum; /* so we can use vertex index */ - for(a=0; a<obr->totvlak; a++) { + for (a=0; a<obr->totvlak; a++) { VlakRen *vlr= RE_findOrAddVlak(obr, a); - if(vlr->v1->orco && vlr->v4) { + if (vlr->v1->orco && vlr->v4) { calc_edge_stress_add(accumoffs, vlr->v1, vlr->v2); calc_edge_stress_add(accumoffs, vlr->v2, vlr->v3); calc_edge_stress_add(accumoffs, vlr->v3, vlr->v1); - if(vlr->v4) { + if (vlr->v4) { calc_edge_stress_add(accumoffs, vlr->v3, vlr->v4); calc_edge_stress_add(accumoffs, vlr->v4, vlr->v1); calc_edge_stress_add(accumoffs, vlr->v2, vlr->v4); @@ -429,12 +432,12 @@ static void calc_edge_stress(Render *UNUSED(re), ObjectRen *obr, Mesh *me) } } - for(a=0; a<obr->totvert; a++) { + for (a=0; a<obr->totvert; a++) { VertRen *ver= RE_findOrAddVert(obr, a); - if(ver->orco) { + if (ver->orco) { /* find stress value */ acc= accumoffs + 2*ver->index; - if(acc[1]!=0.0f) + if (acc[1]!=0.0f) acc[0]/= acc[1]; stress= RE_vertren_get_stress(obr, ver, 1); *stress= *acc; @@ -458,25 +461,25 @@ static void calc_tangent_vector(ObjectRen *obr, VertexTangent **vtangents, MemAr float *uv1, *uv2, *uv3, *uv4; float uv[4][2]; - if(tface) { + if (tface) { uv1= tface->uv[0]; uv2= tface->uv[1]; uv3= tface->uv[2]; uv4= tface->uv[3]; } - else if(v1->orco) { + else if (v1->orco) { uv1= uv[0]; uv2= uv[1]; uv3= uv[2]; uv4= uv[3]; map_to_sphere( &uv[0][0], &uv[0][1],v1->orco[0], v1->orco[1], v1->orco[2]); map_to_sphere( &uv[1][0], &uv[1][1],v2->orco[0], v2->orco[1], v2->orco[2]); map_to_sphere( &uv[2][0], &uv[2][1],v3->orco[0], v3->orco[1], v3->orco[2]); - if(v4) + if (v4) map_to_sphere( &uv[3][0], &uv[3][1],v4->orco[0], v4->orco[1], v4->orco[2]); } else return; tangent_from_uv(uv1, uv2, uv3, v1->co, v2->co, v3->co, vlr->n, tang); - if(do_tangent) { + if (do_tangent) { tav= RE_vertren_get_tangent(obr, v1, 1); add_v3_v3(tav, tang); tav= RE_vertren_get_tangent(obr, v2, 1); @@ -485,16 +488,16 @@ static void calc_tangent_vector(ObjectRen *obr, VertexTangent **vtangents, MemAr add_v3_v3(tav, tang); } - if(do_nmap_tangent) { + if (do_nmap_tangent) { sum_or_add_vertex_tangent(arena, &vtangents[v1->index], tang, uv1); sum_or_add_vertex_tangent(arena, &vtangents[v2->index], tang, uv2); sum_or_add_vertex_tangent(arena, &vtangents[v3->index], tang, uv3); } - if(v4) { + if (v4) { tangent_from_uv(uv1, uv3, uv4, v1->co, v3->co, v4->co, vlr->n, tang); - if(do_tangent) { + if (do_tangent) { tav= RE_vertren_get_tangent(obr, v1, 1); add_v3_v3(tav, tang); tav= RE_vertren_get_tangent(obr, v3, 1); @@ -503,7 +506,7 @@ static void calc_tangent_vector(ObjectRen *obr, VertexTangent **vtangents, MemAr add_v3_v3(tav, tang); } - if(do_nmap_tangent) { + if (do_nmap_tangent) { sum_or_add_vertex_tangent(arena, &vtangents[v1->index], tang, uv1); sum_or_add_vertex_tangent(arena, &vtangents[v3->index], tang, uv3); sum_or_add_vertex_tangent(arena, &vtangents[v4->index], tang, uv4); @@ -556,11 +559,11 @@ static void GetTextureCoordinate(const SMikkTSpaceContext * pContext, float fUV[ MTFace *tface= RE_vlakren_get_tface(pMesh->obr, vlr, pMesh->obr->actmtface, NULL, 0); const float *coord; - if(tface != NULL) { + if (tface != NULL) { coord= tface->uv[vert_index]; fUV[0]= coord[0]; fUV[1]= coord[1]; } - else if((coord= (&vlr->v1)[vert_index]->orco)) { + else if ((coord= (&vlr->v1)[vert_index]->orco)) { map_to_sphere(&fUV[0], &fUV[1], coord[0], coord[1], coord[2]); } else { /* else we get un-initialized value, 0.0 ok default? */ @@ -582,7 +585,7 @@ static void SetTSpace(const SMikkTSpaceContext * pContext, const float fvTangent SRenderMeshToTangent * pMesh = (SRenderMeshToTangent *) pContext->m_pUserData; VlakRen *vlr= RE_findOrAddVlak(pMesh->obr, face_num); float * ftang= RE_vlakren_get_nmap_tangent(pMesh->obr, vlr, 1); - if(ftang!=NULL) { + if (ftang!=NULL) { copy_v3_v3(&ftang[iVert*4+0], fvTangent); ftang[iVert*4+3]=fSign; } @@ -594,7 +597,7 @@ static void calc_vertexnormals(Render *UNUSED(re), ObjectRen *obr, int do_tangen VertexTangent **vtangents= NULL; int a; - if(do_nmap_tangent) { + if (do_nmap_tangent) { arena= BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, "nmap tangent arena"); BLI_memarena_use_calloc(arena); @@ -602,23 +605,23 @@ static void calc_vertexnormals(Render *UNUSED(re), ObjectRen *obr, int do_tangen } /* clear all vertex normals */ - for(a=0; a<obr->totvert; a++) { + for (a=0; a<obr->totvert; a++) { VertRen *ver= RE_findOrAddVert(obr, a); ver->n[0]=ver->n[1]=ver->n[2]= 0.0f; } /* calculate cos of angles and point-masses, use as weight factor to * add face normal to vertex */ - for(a=0; a<obr->totvlak; a++) { + for (a=0; a<obr->totvlak; a++) { VlakRen *vlr= RE_findOrAddVlak(obr, a); - if(vlr->flag & ME_SMOOTH) { + if (vlr->flag & ME_SMOOTH) { float *n4= (vlr->v4)? vlr->v4->n: NULL; float *c4= (vlr->v4)? vlr->v4->co: NULL; accumulate_vertex_normals(vlr->v1->n, vlr->v2->n, vlr->v3->n, n4, vlr->n, vlr->v1->co, vlr->v2->co, vlr->v3->co, c4); } - if(do_nmap_tangent || do_tangent) { + if (do_nmap_tangent || do_tangent) { /* tangents still need to be calculated for flat faces too */ /* weighting removed, they are not vertexnormals */ calc_tangent_vector(obr, vtangents, arena, vlr, do_nmap_tangent, do_tangent); @@ -626,21 +629,21 @@ static void calc_vertexnormals(Render *UNUSED(re), ObjectRen *obr, int do_tangen } /* do solid faces */ - for(a=0; a<obr->totvlak; a++) { + for (a=0; a<obr->totvlak; a++) { VlakRen *vlr= RE_findOrAddVlak(obr, a); - if((vlr->flag & ME_SMOOTH)==0) { - if(is_zero_v3(vlr->v1->n)) copy_v3_v3(vlr->v1->n, vlr->n); - if(is_zero_v3(vlr->v2->n)) copy_v3_v3(vlr->v2->n, vlr->n); - if(is_zero_v3(vlr->v3->n)) copy_v3_v3(vlr->v3->n, vlr->n); - if(vlr->v4 && is_zero_v3(vlr->v4->n)) copy_v3_v3(vlr->v4->n, vlr->n); + if ((vlr->flag & ME_SMOOTH)==0) { + if (is_zero_v3(vlr->v1->n)) copy_v3_v3(vlr->v1->n, vlr->n); + if (is_zero_v3(vlr->v2->n)) copy_v3_v3(vlr->v2->n, vlr->n); + if (is_zero_v3(vlr->v3->n)) copy_v3_v3(vlr->v3->n, vlr->n); + if (vlr->v4 && is_zero_v3(vlr->v4->n)) copy_v3_v3(vlr->v4->n, vlr->n); } - if(do_nmap_tangent) { + if (do_nmap_tangent) { VertRen *v1=vlr->v1, *v2=vlr->v2, *v3=vlr->v3, *v4=vlr->v4; MTFace *tface= RE_vlakren_get_tface(obr, vlr, obr->actmtface, NULL, 0); - if(tface) { + if (tface) { int k=0; float *vtang, *ftang= RE_vlakren_get_nmap_tangent(obr, vlr, 1); @@ -653,12 +656,12 @@ static void calc_vertexnormals(Render *UNUSED(re), ObjectRen *obr, int do_tangen vtang= find_vertex_tangent(vtangents[v3->index], tface->uv[2]); copy_v3_v3(ftang+8, vtang); normalize_v3(ftang+8); - if(v4) { + if (v4) { vtang= find_vertex_tangent(vtangents[v4->index], tface->uv[3]); copy_v3_v3(ftang+12, vtang); normalize_v3(ftang+12); } - for(k=0; k<4; k++) ftang[4*k+3]=1; + for (k=0; k<4; k++) ftang[4*k+3]=1; } } } @@ -667,7 +670,7 @@ static void calc_vertexnormals(Render *UNUSED(re), ObjectRen *obr, int do_tangen for (a=0; a<obr->totvert; a++) { VertRen *ver= RE_findOrAddVert(obr, a); normalize_v3(ver->n); - if(do_tangent) { + if (do_tangent) { float *tav= RE_vertren_get_tangent(obr, ver, 0); if (tav) { /* orthonorm. */ @@ -702,9 +705,9 @@ static void calc_vertexnormals(Render *UNUSED(re), ObjectRen *obr, int do_tangen genTangSpaceDefault(&sContext); } - if(arena) + if (arena) BLI_memarena_free(arena); - if(vtangents) + if (vtangents) MEM_freeN(vtangents); } @@ -728,16 +731,16 @@ static void as_addvert(ASvert *asv, VertRen *v1, VlakRen *vlr) ASface *asf; int a; - if(v1 == NULL) return; + if (v1 == NULL) return; - if(asv->faces.first==NULL) { + if (asv->faces.first==NULL) { asf= MEM_callocN(sizeof(ASface), "asface"); BLI_addtail(&asv->faces, asf); } asf= asv->faces.last; - for(a=0; a<4; a++) { - if(asf->vlr[a]==NULL) { + for (a=0; a<4; a++) { + if (asf->vlr[a]==NULL) { asf->vlr[a]= vlr; asv->totface++; break; @@ -745,7 +748,7 @@ static void as_addvert(ASvert *asv, VertRen *v1, VlakRen *vlr) } /* new face struct */ - if(a==4) { + if (a==4) { asf= MEM_callocN(sizeof(ASface), "asface"); BLI_addtail(&asv->faces, asf); asf->vlr[0]= vlr; @@ -760,14 +763,14 @@ static int as_testvertex(VlakRen *vlr, VertRen *UNUSED(ver), ASvert *asv, float float inp; int a; - if(vlr==0) return 0; + if (vlr==0) return 0; asf= asv->faces.first; while(asf) { - for(a=0; a<4; a++) { - if(asf->vlr[a] && asf->vlr[a]!=vlr) { + for (a=0; a<4; a++) { + if (asf->vlr[a] && asf->vlr[a]!=vlr) { inp = fabsf(dot_v3v3(vlr->n, asf->vlr[a]->n)); - if(inp < thresh) return 1; + if (inp < thresh) return 1; } } asf= asf->next; @@ -785,12 +788,12 @@ static VertRen *as_findvertex(VlakRen *vlr, VertRen *UNUSED(ver), ASvert *asv, f asf= asv->faces.first; while(asf) { - for(a=0; a<4; a++) { - if(asf->vlr[a] && asf->vlr[a]!=vlr) { + for (a=0; a<4; a++) { + if (asf->vlr[a] && asf->vlr[a]!=vlr) { /* this face already made a copy for this vertex! */ - if(asf->nver[a]) { + if (asf->nver[a]) { inp = fabsf(dot_v3v3(vlr->n, asf->vlr[a]->n)); - if(inp >= thresh) { + if (inp >= thresh) { return asf->nver[a]; } } @@ -813,7 +816,7 @@ static void autosmooth(Render *UNUSED(re), ObjectRen *obr, float mat[][4], int d float thresh; int a, b, totvert; - if(obr->totvert==0) return; + if (obr->totvert==0) return; asverts= MEM_callocN(sizeof(ASvert)*obr->totvert, "all smooth verts"); thresh= cosf(DEG2RADF((0.5f + (float)degr))); @@ -822,43 +825,43 @@ static void autosmooth(Render *UNUSED(re), ObjectRen *obr, float mat[][4], int d /* step one: construct listbase of all vertices and pointers to faces */ - for(a=0; a<obr->totvlak; a++) { + for (a=0; a<obr->totvlak; a++) { vlr= RE_findOrAddVlak(obr, a); /* skip wire faces */ - if(vlr->v2 != vlr->v3) { + if (vlr->v2 != vlr->v3) { as_addvert(asverts+vlr->v1->index, vlr->v1, vlr); as_addvert(asverts+vlr->v2->index, vlr->v2, vlr); as_addvert(asverts+vlr->v3->index, vlr->v3, vlr); - if(vlr->v4) + if (vlr->v4) as_addvert(asverts+vlr->v4->index, vlr->v4, vlr); } } totvert= obr->totvert; /* we now test all vertices, when faces have a normal too much different: they get a new vertex */ - for(a=0, asv=asverts; a<totvert; a++, asv++) { - if(asv && asv->totface>1) { + for (a=0, asv=asverts; a<totvert; a++, asv++) { + if (asv && asv->totface>1) { ver= RE_findOrAddVert(obr, a); asf= asv->faces.first; while(asf) { - for(b=0; b<4; b++) { + for (b=0; b<4; b++) { /* is there a reason to make a new vertex? */ vlr= asf->vlr[b]; - if( as_testvertex(vlr, ver, asv, thresh) ) { + if ( as_testvertex(vlr, ver, asv, thresh) ) { /* already made a new vertex within threshold? */ v1= as_findvertex(vlr, ver, asv, thresh); - if(v1==NULL) { + if (v1==NULL) { /* make a new vertex */ v1= RE_vertren_copy(obr, ver); } asf->nver[b]= v1; - if(vlr->v1==ver) vlr->v1= v1; - if(vlr->v2==ver) vlr->v2= v1; - if(vlr->v3==ver) vlr->v3= v1; - if(vlr->v4==ver) vlr->v4= v1; + if (vlr->v1==ver) vlr->v1= v1; + if (vlr->v2==ver) vlr->v2= v1; + if (vlr->v3==ver) vlr->v3= v1; + if (vlr->v4==ver) vlr->v4= v1; } } asf= asf->next; @@ -867,22 +870,22 @@ static void autosmooth(Render *UNUSED(re), ObjectRen *obr, float mat[][4], int d } /* free */ - for(a=0; a<totvert; a++) { + for (a=0; a<totvert; a++) { BLI_freelistN(&asverts[a].faces); } MEM_freeN(asverts); /* rotate vertices and calculate normal of faces */ - for(a=0; a<obr->totvert; a++) { + for (a=0; a<obr->totvert; a++) { ver= RE_findOrAddVert(obr, a); mul_m4_v3(mat, ver->co); } - for(a=0; a<obr->totvlak; a++) { + for (a=0; a<obr->totvlak; a++) { vlr= RE_findOrAddVlak(obr, a); /* skip wire faces */ - if(vlr->v2 != vlr->v3) { - if(vlr->v4) + if (vlr->v2 != vlr->v3) { + if (vlr->v4) normal_quad_v3( vlr->n,vlr->v4->co, vlr->v3->co, vlr->v2->co, vlr->v1->co); else normal_tri_v3( vlr->n,vlr->v3->co, vlr->v2->co, vlr->v1->co); @@ -906,7 +909,8 @@ static float *get_object_orco(Render *re, Object *ob) if (!orco) { if (ELEM(ob->type, OB_CURVE, OB_FONT)) { orco = make_orco_curve(re->scene, ob); - } else if (ob->type==OB_SURF) { + } + else if (ob->type==OB_SURF) { orco = make_orco_surf(ob); } @@ -942,16 +946,16 @@ static void check_material_mapto(Material *ma) * this can avoid a bit of time spent iterating through all the texture slots, map inputs and map tos * every time a property which may or may not be textured is accessed */ - for(a=0; a<MAX_MTEX; a++) { - if(ma->mtex[a] && ma->mtex[a]->tex) { + for (a=0; a<MAX_MTEX; a++) { + if (ma->mtex[a] && ma->mtex[a]->tex) { /* currently used only in volume render, so we'll check for those flags */ - if(ma->mtex[a]->mapto & MAP_DENSITY) ma->mapto_textured |= MAP_DENSITY; - if(ma->mtex[a]->mapto & MAP_EMISSION) ma->mapto_textured |= MAP_EMISSION; - if(ma->mtex[a]->mapto & MAP_EMISSION_COL) ma->mapto_textured |= MAP_EMISSION_COL; - if(ma->mtex[a]->mapto & MAP_SCATTERING) ma->mapto_textured |= MAP_SCATTERING; - if(ma->mtex[a]->mapto & MAP_TRANSMISSION_COL) ma->mapto_textured |= MAP_TRANSMISSION_COL; - if(ma->mtex[a]->mapto & MAP_REFLECTION) ma->mapto_textured |= MAP_REFLECTION; - if(ma->mtex[a]->mapto & MAP_REFLECTION_COL) ma->mapto_textured |= MAP_REFLECTION_COL; + if (ma->mtex[a]->mapto & MAP_DENSITY) ma->mapto_textured |= MAP_DENSITY; + if (ma->mtex[a]->mapto & MAP_EMISSION) ma->mapto_textured |= MAP_EMISSION; + if (ma->mtex[a]->mapto & MAP_EMISSION_COL) ma->mapto_textured |= MAP_EMISSION_COL; + if (ma->mtex[a]->mapto & MAP_SCATTERING) ma->mapto_textured |= MAP_SCATTERING; + if (ma->mtex[a]->mapto & MAP_TRANSMISSION_COL) ma->mapto_textured |= MAP_TRANSMISSION_COL; + if (ma->mtex[a]->mapto & MAP_REFLECTION) ma->mapto_textured |= MAP_REFLECTION; + if (ma->mtex[a]->mapto & MAP_REFLECTION_COL) ma->mapto_textured |= MAP_REFLECTION_COL; } } } @@ -959,17 +963,17 @@ static void flag_render_node_material(Render *re, bNodeTree *ntree) { bNode *node; - for(node=ntree->nodes.first; node; node= node->next) { - if(node->id) { - if(GS(node->id->name)==ID_MA) { + for (node=ntree->nodes.first; node; node= node->next) { + if (node->id) { + if (GS(node->id->name)==ID_MA) { Material *ma= (Material *)node->id; - if((ma->mode & MA_TRANSP) && (ma->mode & MA_ZTRANSP)) + if ((ma->mode & MA_TRANSP) && (ma->mode & MA_ZTRANSP)) re->flag |= R_ZTRA; ma->flag |= MA_IS_USED; } - else if(node->type==NODE_GROUP) + else if (node->type==NODE_GROUP) flag_render_node_material(re, (bNodeTree *)node->id); } } @@ -981,22 +985,22 @@ static Material *give_render_material(Render *re, Object *ob, short nr) Material *ma; ma= give_current_material(ob, nr); - if(ma==NULL) + if (ma==NULL) ma= &defmaterial; - if(re->r.mode & R_SPEED) ma->texco |= NEED_UV; + if (re->r.mode & R_SPEED) ma->texco |= NEED_UV; - if(ma->material_type == MA_TYPE_VOLUME) { + if (ma->material_type == MA_TYPE_VOLUME) { ma->mode |= MA_TRANSP; ma->mode &= ~MA_SHADBUF; } - if((ma->mode & MA_TRANSP) && (ma->mode & MA_ZTRANSP)) + if ((ma->mode & MA_TRANSP) && (ma->mode & MA_ZTRANSP)) re->flag |= R_ZTRA; /* for light groups and SSS */ ma->flag |= MA_IS_USED; - if(ma->nodetree && ma->use_nodes) + if (ma->nodetree && ma->use_nodes) flag_render_node_material(re, ma->nodetree); check_material_mapto(ma); @@ -1036,10 +1040,10 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, Par dy= re->winy*cross[1]*re->winmat[1][1]; w= sqrt(dx*dx + dy*dy)/w; - if(w!=0.0f) { + if (w!=0.0f) { float fac; - if(ma->strand_ease!=0.0f) { - if(ma->strand_ease<0.0f) + if (ma->strand_ease!=0.0f) { + if (ma->strand_ease<0.0f) fac= pow(sd->time, 1.0f+ma->strand_ease); else fac= pow(sd->time, 1.0f/(1.0f-ma->strand_ease)); @@ -1049,11 +1053,11 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, Par width= ((1.0f-fac)*ma->strand_sta + (fac)*ma->strand_end); /* use actual Blender units for strand width and fall back to minimum width */ - if(ma->mode & MA_STR_B_UNITS){ + if (ma->mode & MA_STR_B_UNITS) { crosslen= len_v3(cross); w= 2.0f*crosslen*ma->strand_min/w; - if(width < w) + if (width < w) width= w; /*cross is the radius of the strand so we want it to be half of full width */ @@ -1065,17 +1069,17 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, Par mul_v3_fl(cross, width); } - if(ma->mode & MA_TANGENT_STR) + if (ma->mode & MA_TANGENT_STR) flag= R_SMOOTH|R_TANGENT; else flag= R_SMOOTH; /* only 1 pixel wide strands filled in as quads now, otherwise zbuf errors */ - if(ma->strand_sta==1.0f) + if (ma->strand_sta==1.0f) flag |= R_STRAND; /* single face line */ - if(sd->line) { + if (sd->line) { vlr= RE_findOrAddVlak(obr, obr->totvlak++); vlr->flag= flag; vlr->v1= RE_findOrAddVert(obr, obr->totvert++); @@ -1112,13 +1116,13 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, Par vlr->mat= ma; vlr->ec= ME_V2V3; - if(sd->surfnor) { + if (sd->surfnor) { float *snor= RE_vlakren_get_surfnor(obr, vlr, 1); copy_v3_v3(snor, sd->surfnor); } - if(sd->uvco){ - for(i=0; i<sd->totuv; i++){ + if (sd->uvco) { + for (i=0; i<sd->totuv; i++) { MTFace *mtf; mtf=RE_vlakren_get_tface(obr,vlr,i,NULL,1); mtf->uv[0][0]=mtf->uv[1][0]= @@ -1126,7 +1130,7 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, Par mtf->uv[0][1]=mtf->uv[1][1]= mtf->uv[2][1]=mtf->uv[3][1]=(sd->uvco+2*i)[1]; } - if(sd->override_uv>=0){ + if (sd->override_uv>=0) { MTFace *mtf; mtf=RE_vlakren_get_tface(obr,vlr,sd->override_uv,NULL,0); @@ -1137,8 +1141,8 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, Par mtf->uv[2][1]=mtf->uv[3][1]=1.0f; } } - if(sd->mcol){ - for(i=0; i<sd->totcol; i++){ + if (sd->mcol) { + for (i=0; i<sd->totcol; i++) { MCol *mc; mc=RE_vlakren_get_mcol(obr,vlr,i,NULL,1); mc[0]=mc[1]=mc[2]=mc[3]=sd->mcol[i]; @@ -1147,8 +1151,8 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, Par } } /* first two vertices of a strand */ - else if(sd->first) { - if(sd->adapt){ + else if (sd->first) { + if (sd->adapt) { copy_v3_v3(anor, nor); copy_v3_v3(avec, vec); second=1; @@ -1171,7 +1175,7 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, Par } /* more vertices & faces to strand */ else { - if(sd->adapt==0 || second){ + if (sd->adapt==0 || second) { vlr= RE_findOrAddVlak(obr, obr->totvlak++); vlr->flag= flag; vlr->v1= v1; @@ -1183,14 +1187,14 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, Par v2= vlr->v3; // cycle - if(sd->adapt){ + if (sd->adapt) { second=0; copy_v3_v3(anor,nor); copy_v3_v3(avec,vec); } } - else if(sd->adapt){ + else if (sd->adapt) { float dvec[3],pvec[3]; sub_v3_v3v3(dvec,avec,vec); project_v3_v3v3(pvec,dvec,vec); @@ -1200,7 +1204,7 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, Par dx= re->winx*dvec[0]*re->winmat[0][0]/w; dy= re->winy*dvec[1]*re->winmat[1][1]/w; w= sqrt(dx*dx + dy*dy); - if(dot_v3v3(anor,nor)<sd->adapt_angle && w>sd->adapt_pix){ + if (dot_v3v3(anor,nor)<sd->adapt_angle && w>sd->adapt_pix) { vlr= RE_findOrAddVlak(obr, obr->totvlak++); vlr->flag= flag; vlr->v1= v1; @@ -1214,7 +1218,7 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, Par copy_v3_v3(anor,nor); copy_v3_v3(avec,vec); } - else{ + else { vlr= RE_findOrAddVlak(obr, obr->totvlak-1); } } @@ -1236,13 +1240,13 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, Par vlr->mat= ma; vlr->ec= ME_V2V3; - if(sd->surfnor) { + if (sd->surfnor) { float *snor= RE_vlakren_get_surfnor(obr, vlr, 1); copy_v3_v3(snor, sd->surfnor); } - if(sd->uvco){ - for(i=0; i<sd->totuv; i++){ + if (sd->uvco) { + for (i=0; i<sd->totuv; i++) { MTFace *mtf; mtf=RE_vlakren_get_tface(obr,vlr,i,NULL,1); mtf->uv[0][0]=mtf->uv[1][0]= @@ -1250,7 +1254,7 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, Par mtf->uv[0][1]=mtf->uv[1][1]= mtf->uv[2][1]=mtf->uv[3][1]=(sd->uvco+2*i)[1]; } - if(sd->override_uv>=0){ + if (sd->override_uv>=0) { MTFace *mtf; mtf=RE_vlakren_get_tface(obr,vlr,sd->override_uv,NULL,0); @@ -1261,8 +1265,8 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, Par mtf->uv[2][1]=mtf->uv[3][1]=(vlr->v3->accum+1.0f)/2.0f; } } - if(sd->mcol){ - for(i=0; i<sd->totcol; i++){ + if (sd->mcol) { + for (i=0; i<sd->totcol; i++) { MCol *mc; mc=RE_vlakren_get_mcol(obr,vlr,i,NULL,1); mc[0]=mc[1]=mc[2]=mc[3]=sd->mcol[i]; @@ -1277,7 +1281,7 @@ static void static_particle_wire(ObjectRen *obr, Material *ma, const float vec[3 VlakRen *vlr; static VertRen *v1; - if(line) { + if (line) { vlr= RE_findOrAddVlak(obr, obr->totvlak++); vlr->v1= RE_findOrAddVert(obr, obr->totvert++); vlr->v2= RE_findOrAddVert(obr, obr->totvert++); @@ -1296,7 +1300,7 @@ static void static_particle_wire(ObjectRen *obr, Material *ma, const float vec[3 vlr->ec= ME_V1V2; } - else if(first) { + else if (first) { v1= RE_findOrAddVert(obr, obr->totvert++); copy_v3_v3(v1->co, vec); } @@ -1324,11 +1328,11 @@ static void particle_curve(Render *re, ObjectRen *obr, DerivedMesh *dm, Material { HaloRen *har=0; - if(ma->material_type == MA_TYPE_WIRE) + if (ma->material_type == MA_TYPE_WIRE) static_particle_wire(obr, ma, loc, loc1, sd->first, sd->line); - else if(ma->material_type == MA_TYPE_HALO) { + else if (ma->material_type == MA_TYPE_HALO) { har= RE_inithalo_particle(re, obr, dm, ma, loc, loc1, sd->orco, sd->uvco, sd->size, 1.0, seed, pa_co); - if(har) har->lay= obr->ob->lay; + if (har) har->lay= obr->ob->lay; } else static_particle_strand(re, obr, ma, sd, loc, loc1); @@ -1377,17 +1381,17 @@ static void particle_billboard(Render *re, ObjectRen *obr, Material *ma, Particl vlr->mat= ma; vlr->ec= ME_V2V3; - if(bb->uv_split > 1){ + if (bb->uv_split > 1) { uvdx = uvdy = 1.0f / (float)bb->uv_split; - if(ELEM(bb->anim, PART_BB_ANIM_AGE, PART_BB_ANIM_FRAME)) { - if(bb->anim == PART_BB_ANIM_FRAME) + if (ELEM(bb->anim, PART_BB_ANIM_AGE, PART_BB_ANIM_FRAME)) { + if (bb->anim == PART_BB_ANIM_FRAME) time = ((int)(bb->time * bb->lifetime) % totsplit)/(float)totsplit; else time = bb->time; } - else if(bb->anim == PART_BB_ANIM_ANGLE) { - if(bb->align == PART_BB_VIEW) { + else if (bb->anim == PART_BB_ANIM_ANGLE) { + if (bb->align == PART_BB_VIEW) { time = (float)fmod((bb->tilt + 1.0f) / 2.0f, 1.0); } else { @@ -1397,23 +1401,23 @@ static void particle_billboard(Render *re, ObjectRen *obr, Material *ma, Particl axis1[(bb->align + 1) % 3] = 1.0f; axis2[(bb->align + 2) % 3] = 1.0f; - if(bb->lock == 0) { + if (bb->lock == 0) { zvec[bb->align] = 0.0f; normalize_v3(zvec); } time = saacos(dot_v3v3(zvec, axis1)) / (float)M_PI; - if(dot_v3v3(zvec, axis2) < 0.0f) + if (dot_v3v3(zvec, axis2) < 0.0f) time = 1.0f - time / 2.0f; else time /= 2.0f; } } - if(bb->split_offset == PART_BB_OFF_LINEAR) + if (bb->split_offset == PART_BB_OFF_LINEAR) time = (float)fmod(time + (float)bb->num / (float)totsplit, 1.0f); - else if(bb->split_offset==PART_BB_OFF_RANDOM) + else if (bb->split_offset==PART_BB_OFF_RANDOM) time = (float)fmod(time + bb->random, 1.0f); /* Find the coordinates in tile space (integer), then convert to UV @@ -1427,7 +1431,7 @@ static void particle_billboard(Render *re, ObjectRen *obr, Material *ma, Particl } /* normal UVs */ - if(bb->uv[0] >= 0){ + if (bb->uv[0] >= 0) { mtf = RE_vlakren_get_tface(obr, vlr, bb->uv[0], NULL, 1); mtf->uv[0][0] = 1.0f; mtf->uv[0][1] = 1.0f; @@ -1440,14 +1444,14 @@ static void particle_billboard(Render *re, ObjectRen *obr, Material *ma, Particl } /* time-index UVs */ - if(bb->uv[1] >= 0){ + if (bb->uv[1] >= 0) { mtf = RE_vlakren_get_tface(obr, vlr, bb->uv[1], NULL, 1); mtf->uv[0][0] = mtf->uv[1][0] = mtf->uv[2][0] = mtf->uv[3][0] = bb->time; mtf->uv[0][1] = mtf->uv[1][1] = mtf->uv[2][1] = mtf->uv[3][1] = (float)bb->num/(float)bb->totnum; } /* split UVs */ - if(bb->uv_split > 1 && bb->uv[2] >= 0){ + if (bb->uv_split > 1 && bb->uv[2] >= 0) { mtf = RE_vlakren_get_tface(obr, vlr, bb->uv[2], NULL, 1); mtf->uv[0][0] = uvx + uvdx; mtf->uv[0][1] = uvy + uvdy; @@ -1465,7 +1469,7 @@ static void particle_normal_ren(short ren_as, ParticleSettings *part, Render *re copy_v3_v3(loc, state->co); - if(ren_as != PART_DRAW_BB) + if (ren_as != PART_DRAW_BB) mul_m4_v3(re->viewmat, loc); switch(ren_as) { @@ -1478,7 +1482,7 @@ static void particle_normal_ren(short ren_as, ParticleSettings *part, Render *re mul_mat3_m4_v3(re->viewmat, vel); normalize_v3(vel); - if(part->draw & PART_DRAW_VEL_LENGTH) + if (part->draw & PART_DRAW_VEL_LENGTH) mul_v3_fl(vel, len_v3(state->vel)); madd_v3_v3v3fl(loc0, loc, vel, -part->draw_line[0]); @@ -1503,7 +1507,7 @@ static void particle_normal_ren(short ren_as, ParticleSettings *part, Render *re har = RE_inithalo_particle(re, obr, dm, ma, loc, NULL, sd->orco, sd->uvco, hasize, 0.0, seed, pa_co); - if(har) har->lay= obr->ob->lay; + if (har) har->lay= obr->ob->lay; break; } @@ -1514,9 +1518,9 @@ static void get_particle_uvco_mcol(short from, DerivedMesh *dm, float *fuv, int int i; /* get uvco */ - if(sd->uvco && ELEM(from,PART_FROM_FACE,PART_FROM_VOLUME)) { - for(i=0; i<sd->totuv; i++) { - if(num != DMCACHE_NOTFOUND) { + if (sd->uvco && ELEM(from,PART_FROM_FACE,PART_FROM_VOLUME)) { + for (i=0; i<sd->totuv; i++) { + if (num != DMCACHE_NOTFOUND) { MFace *mface = dm->getTessFaceData(dm, num, CD_MFACE); MTFace *mtface = (MTFace*)CustomData_get_layer_n(&dm->faceData, CD_MTFACE, i); mtface += num; @@ -1531,9 +1535,9 @@ static void get_particle_uvco_mcol(short from, DerivedMesh *dm, float *fuv, int } /* get mcol */ - if(sd->mcol && ELEM(from,PART_FROM_FACE,PART_FROM_VOLUME)) { - for(i=0; i<sd->totcol; i++) { - if(num != DMCACHE_NOTFOUND) { + if (sd->mcol && ELEM(from,PART_FROM_FACE,PART_FROM_VOLUME)) { + for (i=0; i<sd->totcol; i++) { + if (num != DMCACHE_NOTFOUND) { MFace *mface = dm->getTessFaceData(dm, num, CD_MFACE); MCol *mc = (MCol*)CustomData_get_layer_n(&dm->faceData, CD_MCOL, i); mc += num * 4; @@ -1578,23 +1582,23 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem char **uv_name=0; /* 1. check that everything is ok & updated */ - if(psys==NULL) + if (psys==NULL) return 0; part=psys->part; pars=psys->particles; - if(part==NULL || pars==NULL || !psys_check_enabled(ob, psys)) + if (part==NULL || pars==NULL || !psys_check_enabled(ob, psys)) return 0; - if(part->ren_as==PART_DRAW_OB || part->ren_as==PART_DRAW_GR || part->ren_as==PART_DRAW_NOT) + if (part->ren_as==PART_DRAW_OB || part->ren_as==PART_DRAW_GR || part->ren_as==PART_DRAW_NOT) return 1; /* 2. start initializing things */ /* last possibility to bail out! */ psmd = psys_get_modifier(ob,psys); - if(!(psmd->modifier.mode & eModifierMode_Render)) + if (!(psmd->modifier.mode & eModifierMode_Render)) return 0; sim.scene= re->scene; @@ -1602,16 +1606,16 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem sim.psys= psys; sim.psmd= psmd; - if(part->phystype==PART_PHYS_KEYED) + if (part->phystype==PART_PHYS_KEYED) psys_count_keyed_targets(&sim); totchild=psys->totchild; /* can happen for disconnected/global hair */ - if(part->type==PART_HAIR && !psys->childcache) + if (part->type==PART_HAIR && !psys->childcache) totchild= 0; - if(G.rendering == 0) { /* preview render */ + if (G.rendering == 0) { /* preview render */ totchild = (int)((float)totchild * (float)part->disp / 100.0f); } @@ -1628,7 +1632,7 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem ma= give_render_material(re, ob, part->omat); #if 0 // XXX old animation system - if(ma->ipo){ + if (ma->ipo) { calc_ipo(ma->ipo, cfra); execute_ipo((ID *)ma, ma->ipo); } @@ -1643,10 +1647,10 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem sd.totuv = CustomData_number_of_layers(&psmd->dm->faceData, CD_MTFACE); sd.totcol = CustomData_number_of_layers(&psmd->dm->faceData, CD_MCOL); - if(ma->texco & TEXCO_UV && sd.totuv) { + if (ma->texco & TEXCO_UV && sd.totuv) { sd.uvco = MEM_callocN(sd.totuv * 2 * sizeof(float), "particle_uvs"); - if(ma->strand_uvname[0]) { + if (ma->strand_uvname[0]) { sd.override_uv = CustomData_get_named_layer_index(&psmd->dm->faceData, CD_MTFACE, ma->strand_uvname); sd.override_uv -= CustomData_get_layer_index(&psmd->dm->faceData, CD_MTFACE); } @@ -1654,22 +1658,22 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem else sd.uvco = NULL; - if(sd.totcol) + if (sd.totcol) sd.mcol = MEM_callocN(sd.totcol * sizeof(MCol), "particle_mcols"); /* 2.2 setup billboards */ - if(part->ren_as == PART_DRAW_BB) { + if (part->ren_as == PART_DRAW_BB) { int first_uv = CustomData_get_layer_index(&psmd->dm->faceData, CD_MTFACE); bb.uv[0] = CustomData_get_named_layer_index(&psmd->dm->faceData, CD_MTFACE, psys->bb_uvname[0]); - if(bb.uv[0] < 0) + if (bb.uv[0] < 0) bb.uv[0] = CustomData_get_active_layer_index(&psmd->dm->faceData, CD_MTFACE); bb.uv[1] = CustomData_get_named_layer_index(&psmd->dm->faceData, CD_MTFACE, psys->bb_uvname[1]); bb.uv[2] = CustomData_get_named_layer_index(&psmd->dm->faceData, CD_MTFACE, psys->bb_uvname[2]); - if(first_uv >= 0) { + if (first_uv >= 0) { bb.uv[0] -= first_uv; bb.uv[1] -= first_uv; bb.uv[2] -= first_uv; @@ -1690,24 +1694,24 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem copy_m3_m4(nmat, ob->imat); transpose_m3(nmat); - if(psys->flag & PSYS_USE_IMAT) { + if (psys->flag & PSYS_USE_IMAT) { /* psys->imat is the original emitter's inverse matrix, ob->obmat is the duplicated object's matrix */ mult_m4_m4m4(duplimat, ob->obmat, psys->imat); use_duplimat = 1; } /* 2.6 setup strand rendering */ - if(part->ren_as == PART_DRAW_PATH && psys->pathcache){ + if (part->ren_as == PART_DRAW_PATH && psys->pathcache) { path_nbr=(int)pow(2.0,(double) part->ren_step); - if(path_nbr) { - if(!ELEM(ma->material_type, MA_TYPE_HALO, MA_TYPE_WIRE)) { + if (path_nbr) { + if (!ELEM(ma->material_type, MA_TYPE_HALO, MA_TYPE_WIRE)) { sd.orco = MEM_mallocN(3*sizeof(float)*(totpart+totchild), "particle orcos"); set_object_orco(re, psys, sd.orco); } } - if(part->draw & PART_DRAW_REN_ADAPT) { + if (part->draw & PART_DRAW_REN_ADAPT) { sd.adapt = 1; sd.adapt_pix = (float)part->adapt_pix; sd.adapt_angle = cosf(DEG2RADF((float)part->adapt_angle)); @@ -1725,29 +1729,29 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem strandbuf->overrideuv= sd.override_uv; strandbuf->minwidth= ma->strand_min; - if(ma->strand_widthfade == 0.0f) + if (ma->strand_widthfade == 0.0f) strandbuf->widthfade= 0.0f; - else if(ma->strand_widthfade >= 1.0f) + else if (ma->strand_widthfade >= 1.0f) strandbuf->widthfade= 2.0f - ma->strand_widthfade; else strandbuf->widthfade= 1.0f/MAX2(ma->strand_widthfade, 1e-5f); - if(part->flag & PART_HAIR_BSPLINE) + if (part->flag & PART_HAIR_BSPLINE) strandbuf->flag |= R_STRAND_BSPLINE; - if(ma->mode & MA_STR_B_UNITS) + if (ma->mode & MA_STR_B_UNITS) strandbuf->flag |= R_STRAND_B_UNITS; svert= strandbuf->vert; - if(re->r.mode & R_SPEED) + if (re->r.mode & R_SPEED) dosurfacecache= 1; - else if((re->wrld.mode & (WO_AMB_OCC|WO_ENV_LIGHT|WO_INDIRECT_LIGHT)) && (re->wrld.ao_gather_method == WO_AOGATHER_APPROX)) - if(ma->amb != 0.0f) + else if ((re->wrld.mode & (WO_AMB_OCC|WO_ENV_LIGHT|WO_INDIRECT_LIGHT)) && (re->wrld.ao_gather_method == WO_AOGATHER_APPROX)) + if (ma->amb != 0.0f) dosurfacecache= 1; totface= psmd->dm->getNumTessFaces(psmd->dm); origindex= psmd->dm->getTessFaceDataArray(psmd->dm, CD_ORIGINDEX); - for(a=0; a<totface; a++) + for (a=0; a<totface; a++) strandbuf->totbound= MAX2(strandbuf->totbound, (origindex)? origindex[a]: a); strandbuf->totbound++; @@ -1757,20 +1761,20 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem } } - if(sd.orco == 0) { + if (sd.orco == 0) { sd.orco = MEM_mallocN(3 * sizeof(float), "particle orco"); orco1 = 1; } - if(path_nbr == 0) + if (path_nbr == 0) psys->lattice = psys_get_lattice(&sim); /* 3. start creating renderable things */ - for(a=0,pa=pars; a<totpart+totchild; a++, pa++, seed++) { + for (a=0,pa=pars; a<totpart+totchild; a++, pa++, seed++) { random = rng_getFloat(rng); /* setup per particle individual stuff */ - if(a<totpart){ - if(pa->flag & PARS_UNEXIST) continue; + if (a<totpart) { + if (pa->flag & PARS_UNEXIST) continue; pa_time=(cfra-pa->time)/pa->lifetime; pa_birthtime = pa->time; @@ -1779,7 +1783,7 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem hasize = ma->hasize; /* get orco */ - if(tpsys && part->phystype==PART_PHYS_NO){ + if (tpsys && part->phystype==PART_PHYS_NO) { tpa=tpsys->particles+pa->num; psys_particle_on_emitter(psmd,tpart->from,tpa->num,pa->num_dmcache,tpa->fuv,tpa->foffset,co,nor,0,0,sd.orco,0); } @@ -1789,8 +1793,8 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem /* get uvco & mcol */ num= pa->num_dmcache; - if(num == DMCACHE_NOTFOUND) - if(pa->num < psmd->dm->getNumTessFaces(psmd->dm)) + if (num == DMCACHE_NOTFOUND) + if (pa->num < psmd->dm->getNumTessFaces(psmd->dm)) num= pa->num; get_particle_uvco_mcol(part->from, psmd->dm, pa->fuv, num, &sd); @@ -1800,20 +1804,20 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem r_tilt = 2.0f*(PSYS_FRAND(a) - 0.5f); r_length = PSYS_FRAND(a+1); - if(path_nbr) { + if (path_nbr) { cache = psys->pathcache[a]; max_k = (int)cache->steps; } - if(totchild && (part->draw&PART_DRAW_PARENT)==0) continue; + if (totchild && (part->draw&PART_DRAW_PARENT)==0) continue; } else { ChildParticle *cpa= psys->child+a-totpart; - if(path_nbr) { + if (path_nbr) { cache = psys->childcache[a-totpart]; - if(cache->steps < 0) + if (cache->steps < 0) continue; max_k = (int)cache->steps; @@ -1828,7 +1832,7 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem num = cpa->num; /* get orco */ - if(part->childtype == PART_CHILD_FACES) { + if (part->childtype == PART_CHILD_FACES) { psys_particle_on_emitter(psmd, PART_FROM_FACE, cpa->num,DMCACHE_ISCHILD, cpa->fuv,cpa->foffset,co,nor,0,0,sd.orco,0); @@ -1841,15 +1845,15 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem } /* get uvco & mcol */ - if(part->childtype==PART_CHILD_FACES) { + if (part->childtype==PART_CHILD_FACES) { get_particle_uvco_mcol(PART_FROM_FACE, psmd->dm, cpa->fuv, cpa->num, &sd); } else { ParticleData *parent = psys->particles + cpa->parent; num = parent->num_dmcache; - if(num == DMCACHE_NOTFOUND) - if(parent->num < psmd->dm->getNumTessFaces(psmd->dm)) + if (num == DMCACHE_NOTFOUND) + if (parent->num < psmd->dm->getNumTessFaces(psmd->dm)) num = parent->num; get_particle_uvco_mcol(part->from, psmd->dm, parent->fuv, num, &sd); @@ -1857,10 +1861,10 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem dosimplify = psys_render_simplify_params(psys, cpa, simplify); - if(strandbuf) { + if (strandbuf) { int orignum= (origindex)? origindex[cpa->num]: cpa->num; - if(orignum > sbound - strandbuf->bound) { + if (orignum > sbound - strandbuf->bound) { sbound= strandbuf->bound + orignum; sbound->start= sbound->end= obr->totstrand; } @@ -1873,7 +1877,7 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem pa_co[2] = 0.f; /* surface normal shading setup */ - if(ma->mode_l & MA_STR_SURFDIFF) { + if (ma->mode_l & MA_STR_SURFDIFF) { mul_m3_v3(nmat, nor); sd.surfnor= nor; } @@ -1881,31 +1885,31 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem sd.surfnor= NULL; /* strand render setup */ - if(strandbuf) { + if (strandbuf) { strand= RE_findOrAddStrand(obr, obr->totstrand++); strand->buffer= strandbuf; strand->vert= svert; copy_v3_v3(strand->orco, sd.orco); - if(dosimplify) { + if (dosimplify) { float *ssimplify= RE_strandren_get_simplify(obr, strand, 1); ssimplify[0]= simplify[0]; ssimplify[1]= simplify[1]; } - if(sd.surfnor) { + if (sd.surfnor) { float *snor= RE_strandren_get_surfnor(obr, strand, 1); copy_v3_v3(snor, sd.surfnor); } - if(dosurfacecache && num >= 0) { + if (dosurfacecache && num >= 0) { int *facenum= RE_strandren_get_face(obr, strand, 1); *facenum= num; } - if(sd.uvco) { - for(i=0; i<sd.totuv; i++) { - if(i != sd.override_uv) { + if (sd.uvco) { + for (i=0; i<sd.totuv; i++) { + if (i != sd.override_uv) { float *uv= RE_strandren_get_uv(obr, strand, i, NULL, 1); uv[0]= sd.uvco[2*i]; @@ -1913,8 +1917,8 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem } } } - if(sd.mcol) { - for(i=0; i<sd.totcol; i++) { + if (sd.mcol) { + for (i=0; i<sd.totcol; i++) { MCol *mc= RE_strandren_get_mcol(obr, strand, i, NULL, 1); *mc = sd.mcol[i]; } @@ -1924,43 +1928,43 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem } /* strandco computation setup */ - if(path_nbr) { + if (path_nbr) { strandlen= 0.0f; curlen= 0.0f; - for(k=1; k<=path_nbr; k++) - if(k<=max_k) + for (k=1; k<=path_nbr; k++) + if (k<=max_k) strandlen += len_v3v3((cache+k-1)->co, (cache+k)->co); } - if(path_nbr) { + if (path_nbr) { /* render strands */ - for(k=0; k<=path_nbr; k++){ + for (k=0; k<=path_nbr; k++) { float time; - if(k<=max_k){ + if (k<=max_k) { copy_v3_v3(state.co,(cache+k)->co); copy_v3_v3(state.vel,(cache+k)->vel); } else continue; - if(k > 0) + if (k > 0) curlen += len_v3v3((cache+k-1)->co, (cache+k)->co); time= curlen/strandlen; copy_v3_v3(loc,state.co); mul_m4_v3(re->viewmat,loc); - if(strandbuf) { + if (strandbuf) { copy_v3_v3(svert->co, loc); svert->strandco= -1.0f + 2.0f*time; svert++; strand->totvert++; } - else{ + else { sd.size = hasize; - if(k==1){ + if (k==1) { sd.first = 1; sd.time = 0.0f; sub_v3_v3v3(loc0,loc1,loc); @@ -1972,7 +1976,7 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem sd.first = 0; sd.time = time; - if(k) + if (k) particle_curve(re, obr, psmd->dm, ma, &sd, loc, loc1, seed, pa_co); copy_v3_v3(loc1,loc); @@ -1982,7 +1986,7 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem } else { /* render normal particles */ - if(part->trail_count > 1) { + if (part->trail_count > 1) { float length = part->path_end * (1.0f - part->randlength * r_length); int trail_count = part->trail_count * (1.0f - part->randlength * r_length); float ct = (part->draw & PART_ABS_PATH_TIME) ? cfra : pa_time; @@ -1991,24 +1995,24 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem /* make sure we have pointcache in memory before getting particle on path */ psys_make_temp_pointcache(ob, psys); - for(i=0; i < trail_count; i++, ct -= dt) { - if(part->draw & PART_ABS_PATH_TIME) { - if(ct < pa_birthtime || ct > pa_dietime) + for (i=0; i < trail_count; i++, ct -= dt) { + if (part->draw & PART_ABS_PATH_TIME) { + if (ct < pa_birthtime || ct > pa_dietime) continue; } - else if(ct < 0.0f || ct > 1.0f) + else if (ct < 0.0f || ct > 1.0f) continue; state.time = (part->draw & PART_ABS_PATH_TIME) ? -ct : ct; psys_get_particle_on_path(&sim,a,&state,1); - if(psys->parent) + if (psys->parent) mul_m4_v3(psys->parent->obmat, state.co); - if(use_duplimat) + if (use_duplimat) mul_m4_v4(duplimat, state.co); - if(part->ren_as == PART_DRAW_BB) { + if (part->ren_as == PART_DRAW_BB) { bb.random = random; bb.offset[0] = part->bb_offset[0]; bb.offset[1] = part->bb_offset[1]; @@ -2037,16 +2041,16 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem } else { state.time=cfra; - if(psys_get_particle_state(&sim,a,&state,0)==0) + if (psys_get_particle_state(&sim,a,&state,0)==0) continue; - if(psys->parent) + if (psys->parent) mul_m4_v3(psys->parent->obmat, state.co); - if(use_duplimat) + if (use_duplimat) mul_m4_v3(duplimat, state.co); - if(part->ren_as == PART_DRAW_BB) { + if (part->ren_as == PART_DRAW_BB) { bb.random = random; bb.offset[0] = part->bb_offset[0]; bb.offset[1] = part->bb_offset[1]; @@ -2072,46 +2076,46 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem } } - if(orco1==0) + if (orco1==0) sd.orco+=3; - if(re->test_break(re->tbh)) + if (re->test_break(re->tbh)) break; } - if(dosurfacecache) + if (dosurfacecache) strandbuf->surface= cache_strand_surface(re, obr, psmd->dm, mat, timeoffset); /* 4. clean up */ #if 0 // XXX old animation system - if(ma) do_mat_ipo(re->scene, ma); + if (ma) do_mat_ipo(re->scene, ma); #endif // XXX old animation system - if(orco1) + if (orco1) MEM_freeN(sd.orco); - if(sd.uvco) + if (sd.uvco) MEM_freeN(sd.uvco); - if(sd.mcol) + if (sd.mcol) MEM_freeN(sd.mcol); - if(uv_name) + if (uv_name) MEM_freeN(uv_name); - if(states) + if (states) MEM_freeN(states); rng_free(rng); psys->flag &= ~PSYS_DRAWING; - if(psys->lattice){ + if (psys->lattice) { end_latt_deform(psys->lattice); psys->lattice= NULL; } - if(path_nbr && (ma->mode_l & MA_TANGENT_STR)==0) + if (path_nbr && (ma->mode_l & MA_TANGENT_STR)==0) calc_vertexnormals(re, obr, 0, 0); return 1; @@ -2134,16 +2138,16 @@ static void make_render_halos(Render *re, ObjectRen *obr, Mesh *UNUSED(me), int re->flag |= R_HALO; - for(a=0; a<totvert; a++, mvert++) { + for (a=0; a<totvert; a++, mvert++) { ok= 1; - if(ok) { + if (ok) { hasize= ma->hasize; copy_v3_v3(vec, mvert->co); mul_m4_v3(mat, vec); - if(ma->mode & MA_HALOPUNO) { + if (ma->mode & MA_HALOPUNO) { xn= mvert->no[0]; yn= mvert->no[1]; zn= mvert->no[2]; @@ -2158,15 +2162,15 @@ static void make_render_halos(Render *re, ObjectRen *obr, Mesh *UNUSED(me), int normalize_v3(view); zn = dot_v3v3(nor, view); - if(zn>=0.0f) hasize= 0.0f; + if (zn>=0.0f) hasize= 0.0f; else hasize*= zn*zn*zn*zn; } - if(orco) har= RE_inithalo(re, obr, ma, vec, NULL, orco, hasize, 0.0, seed); + if (orco) har= RE_inithalo(re, obr, ma, vec, NULL, orco, hasize, 0.0, seed); else har= RE_inithalo(re, obr, ma, vec, NULL, mvert->co, hasize, 0.0, seed); - if(har) har->lay= ob->lay; + if (har) har->lay= ob->lay; } - if(orco) orco+= 3; + if (orco) orco+= 3; seed++; } } @@ -2176,8 +2180,8 @@ static int verghalo(const void *a1, const void *a2) const HaloRen *har1= *(const HaloRen**)a1; const HaloRen *har2= *(const HaloRen**)a2; - if(har1->zs < har2->zs) return 1; - else if(har1->zs > har2->zs) return -1; + if (har1->zs < har2->zs) return 1; + else if (har1->zs > har2->zs) return -1; return 0; } @@ -2187,14 +2191,14 @@ static void sort_halos(Render *re, int totsort) HaloRen *har= NULL, **haso; int a; - if(re->tothalo==0) return; + if (re->tothalo==0) return; re->sortedhalos= MEM_callocN(sizeof(HaloRen*)*re->tothalo, "sorthalos"); haso= re->sortedhalos; - for(obr=re->objecttable.first; obr; obr=obr->next) { - for(a=0; a<obr->tothalo; a++) { - if((a & 255)==0) har= obr->bloha[a>>8]; + for (obr=re->objecttable.first; obr; obr=obr->next) { + for (a=0; a<obr->tothalo; a++) { + if ((a & 255)==0) har= obr->bloha[a>>8]; else har++; *(haso++)= har; @@ -2217,7 +2221,7 @@ static short test_for_displace(Render *re, Object *ob) for (i=1; i<=ob->totcol; i++) { ma=give_render_material(re, ob, i); /* ma->mapto is ORed total of all mapto channels */ - if(ma && (ma->mapto & MAP_DISPLACE)) return 1; + if (ma && (ma->mapto & MAP_DISPLACE)) return 1; } return 0; } @@ -2235,10 +2239,10 @@ static void displace_render_vert(Render *re, ObjectRen *obr, ShadeInput *shi, Ve /* vertex normal is used for textures type 'col' and 'var' */ copy_v3_v3(shi->vn, vr->n); - if(mat) + if (mat) mul_m4_v3(mat, shi->co); - if(imat) { + if (imat) { shi->vn[0] = dot_v3v3(imat[0], vr->n); shi->vn[1] = dot_v3v3(imat[1], vr->n); shi->vn[2] = dot_v3v3(imat[2], vr->n); @@ -2266,7 +2270,7 @@ static void displace_render_vert(Render *re, ObjectRen *obr, ShadeInput *shi, Ve } if (texco & TEXCO_STICKY) { float *sticky= RE_vertren_get_sticky(obr, vr, 0); - if(sticky) { + if (sticky) { shi->sticky[0]= sticky[0]; shi->sticky[1]= sticky[1]; shi->sticky[2]= 0.0f; @@ -2279,15 +2283,15 @@ static void displace_render_vert(Render *re, ObjectRen *obr, ShadeInput *shi, Ve if (texco & TEXCO_NORM) { copy_v3_v3(shi->orn, shi->vn); } - if(texco & TEXCO_REFL) { + if (texco & TEXCO_REFL) { /* not (yet?) */ } - if(texco & TEXCO_STRESS) { + if (texco & TEXCO_STRESS) { float *s= RE_vertren_get_stress(obr, vr, 0); - if(s) { + if (s) { shi->stress= *s; - if(shi->stress<1.0f) shi->stress-= 1.0f; + if (shi->stress<1.0f) shi->stress-= 1.0f; else shi->stress= (shi->stress-1.0f)/shi->stress; } else @@ -2305,7 +2309,7 @@ static void displace_render_vert(Render *re, ObjectRen *obr, ShadeInput *shi, Ve displace[1]= shi->displace[1] * scale[1]; displace[2]= shi->displace[2] * scale[2]; - if(mat) + if (mat) mul_m3_v3(imat, displace); /* 0.5 could become button once? */ @@ -2377,7 +2381,7 @@ static void displace_render_face(Render *re, ObjectRen *obr, VlakRen *vlr, float } /* Recalculate the face normal - if flipped before, flip now */ - if(vlr->v4) { + if (vlr->v4) { normal_quad_v3( vlr->n,vlr->v4->co, vlr->v3->co, vlr->v2->co, vlr->v1->co); } else { @@ -2396,19 +2400,19 @@ static void do_displacement(Render *re, ObjectRen *obr, float mat[][4], float im /* Object Size with parenting */ obt=obr->ob; - while(obt){ + while(obt) { mul_v3_v3v3(temp, obt->size, obt->dscale); scale[0]*=temp[0]; scale[1]*=temp[1]; scale[2]*=temp[2]; obt=obt->parent; } /* Clear all flags */ - for(i=0; i<obr->totvert; i++){ + for (i=0; i<obr->totvert; i++) { vr= RE_findOrAddVert(obr, i); vr->flag= 0; } - for(i=0; i<obr->totvlak; i++){ + for (i=0; i<obr->totvlak; i++) { vlr=RE_findOrAddVlak(obr, i); displace_render_face(re, obr, vlr, scale, mat, imat); } @@ -2443,17 +2447,17 @@ static void init_render_mball(Render *re, ObjectRen *obr) ma= give_render_material(re, ob, 1); need_orco= 0; - if(ma->texco & TEXCO_ORCO) { + if (ma->texco & TEXCO_ORCO) { need_orco= 1; } makeDispListMBall_forRender(re->scene, ob, &dispbase); dl= dispbase.first; - if(dl==0) return; + if (dl==0) return; data= dl->verts; nors= dl->nors; - if(need_orco) { + if (need_orco) { orco= get_object_orco(re, ob); if (!orco) { @@ -2463,7 +2467,7 @@ static void init_render_mball(Render *re, ObjectRen *obr) } } - for(a=0; a<dl->nr; a++, data+=3, nors+=3) { + for (a=0; a<dl->nr; a++, data+=3, nors+=3) { ver= RE_findOrAddVert(obr, obr->totvert++); copy_v3_v3(ver->co, data); @@ -2481,14 +2485,14 @@ static void init_render_mball(Render *re, ObjectRen *obr) normalize_v3(ver->n); //if(ob->transflag & OB_NEG_SCALE) negate_v3(ver->n); - if(need_orco) { + if (need_orco) { ver->orco= orco; orco+=3; } } index= dl->index; - for(a=0; a<dl->parts; a++, index+=4) { + for (a=0; a<dl->parts; a++, index+=4) { vlr= RE_findOrAddVlak(obr, obr->totvlak++); vlr->v1= RE_findOrAddVert(obr, index[0]); @@ -2496,7 +2500,7 @@ static void init_render_mball(Render *re, ObjectRen *obr) vlr->v3= RE_findOrAddVert(obr, index[2]); vlr->v4= 0; - if(negative_scale) + if (negative_scale) normal_tri_v3( vlr->n,vlr->v1->co, vlr->v2->co, vlr->v3->co); else normal_tri_v3( vlr->n,vlr->v3->co, vlr->v2->co, vlr->v1->co); @@ -2506,14 +2510,14 @@ static void init_render_mball(Render *re, ObjectRen *obr) vlr->ec= 0; /* mball -too bad- always has triangles, because quads can be non-planar */ - if(index[3] && index[3]!=index[2]) { + if (index[3] && index[3]!=index[2]) { vlr1= RE_findOrAddVlak(obr, obr->totvlak++); vlakindex= vlr1->index; *vlr1= *vlr; vlr1->index= vlakindex; vlr1->v2= vlr1->v3; vlr1->v3= RE_findOrAddVert(obr, index[3]); - if(negative_scale) + if (negative_scale) normal_tri_v3( vlr1->n,vlr1->v1->co, vlr1->v2->co, vlr1->v3->co); else normal_tri_v3( vlr1->n,vlr1->v3->co, vlr1->v2->co, vlr1->v1->co); @@ -2546,7 +2550,7 @@ static int dl_surf_to_renderdata(ObjectRen *obr, DispList *dl, Material **matar, for (u = 0; u < sizeu; u++) { v1 = RE_findOrAddVert(obr, obr->totvert++); /* save this for possible V wrapping */ copy_v3_v3(v1->co, data); data += 3; - if(orco) { + if (orco) { v1->orco= orco; orco+= 3; orcoret++; } mul_m4_v3(mat, v1->co); @@ -2554,7 +2558,7 @@ static int dl_surf_to_renderdata(ObjectRen *obr, DispList *dl, Material **matar, for (v = 1; v < sizev; v++) { ver= RE_findOrAddVert(obr, obr->totvert++); copy_v3_v3(ver->co, data); data += 3; - if(orco) { + if (orco) { ver->orco= orco; orco+= 3; orcoret++; } mul_m4_v3(mat, ver->co); @@ -2563,7 +2567,7 @@ static int dl_surf_to_renderdata(ObjectRen *obr, DispList *dl, Material **matar, if (dl->flag & DL_CYCL_U) { ver= RE_findOrAddVert(obr, obr->totvert++); copy_v3_v3(ver->co, v1->co); - if(orco) { + if (orco) { ver->orco= orco; orco+=3; orcoret++; //orcobase + 3*(u*sizev + 0); } } @@ -2579,7 +2583,7 @@ static int dl_surf_to_renderdata(ObjectRen *obr, DispList *dl, Material **matar, v1= RE_findOrAddVert(obr, startvert + v); ver= RE_findOrAddVert(obr, obr->totvert++); copy_v3_v3(ver->co, v1->co); - if(orco) { + if (orco) { ver->orco= orco; orco+=3; orcoret++; //ver->orco= orcobase + 3*(0*sizev + v); } } @@ -2590,13 +2594,13 @@ static int dl_surf_to_renderdata(ObjectRen *obr, DispList *dl, Material **matar, startvlak= obr->totvlak; - for(u = 0; u < sizeu - 1; u++) { + for (u = 0; u < sizeu - 1; u++) { p1 = startvert + u * sizev; /* walk through face list */ p2 = p1 + 1; p3 = p2 + sizev; p4 = p3 - 1; - for(v = 0; v < sizev - 1; v++) { + for (v = 0; v < sizev - 1; v++) { v1= RE_findOrAddVert(obr, p1); v2= RE_findOrAddVert(obr, p2); v3= RE_findOrAddVert(obr, p3); @@ -2680,7 +2684,7 @@ static int dl_surf_to_renderdata(ObjectRen *obr, DispList *dl, Material **matar, copy_v3_v3(vlr2->v2->n, n1); copy_v3_v3(vlr3->v4->n, n1); } - for(a = startvert; a < obr->totvert; a++) { + for (a = startvert; a < obr->totvert; a++) { ver= RE_findOrAddVert(obr, a); normalize_v3(ver->n); } @@ -2705,18 +2709,18 @@ static void init_render_dm(DerivedMesh *dm, Render *re, ObjectRen *obr, mvert= dm->getVertArray(dm); totvert= dm->getNumVerts(dm); - for(a=0; a<totvert; a++, mvert++) { + for (a=0; a<totvert; a++, mvert++) { ver= RE_findOrAddVert(obr, obr->totvert++); copy_v3_v3(ver->co, mvert->co); mul_m4_v3(mat, ver->co); - if(orco) { + if (orco) { ver->orco= orco; orco+=3; } } - if(!timeoffset) { + if (!timeoffset) { /* store customdata names, because DerivedMesh is freed */ RE_set_customdata_names(obr, &dm->faceData); @@ -2724,16 +2728,16 @@ static void init_render_dm(DerivedMesh *dm, Render *re, ObjectRen *obr, /* faces in order of color blocks */ vertofs= obr->totvert - totvert; - for(mat_iter= 0; (mat_iter < ob->totcol || (mat_iter==0 && ob->totcol==0)); mat_iter++) { + for (mat_iter= 0; (mat_iter < ob->totcol || (mat_iter==0 && ob->totcol==0)); mat_iter++) { ma= give_render_material(re, ob, mat_iter+1); end= dm->getNumTessFaces(dm); mface= dm->getTessFaceArray(dm); - for(a=0; a<end; a++, mface++) { + for (a=0; a<end; a++, mface++) { int v1, v2, v3, v4, flag; - if(mface->mat_nr == mat_iter) { + if (mface->mat_nr == mat_iter) { float len; v1= mface->v1; @@ -2746,11 +2750,11 @@ static void init_render_dm(DerivedMesh *dm, Render *re, ObjectRen *obr, vlr->v1= RE_findOrAddVert(obr, vertofs+v1); vlr->v2= RE_findOrAddVert(obr, vertofs+v2); vlr->v3= RE_findOrAddVert(obr, vertofs+v3); - if(v4) vlr->v4= RE_findOrAddVert(obr, vertofs+v4); + if (v4) vlr->v4= RE_findOrAddVert(obr, vertofs+v4); else vlr->v4= 0; /* render normals are inverted in render */ - if(vlr->v4) + if (vlr->v4) len= normal_quad_v3( vlr->n,vlr->v4->co, vlr->v3->co, vlr->v2->co, vlr->v1->co); else len= normal_tri_v3( vlr->n,vlr->v3->co, vlr->v2->co, vlr->v1->co); @@ -2759,7 +2763,7 @@ static void init_render_dm(DerivedMesh *dm, Render *re, ObjectRen *obr, vlr->flag= flag; vlr->ec= 0; /* mesh edges rendered separately */ - if(len==0) obr->totvlak--; + if (len==0) obr->totvlak--; else { CustomDataLayer *layer; MTFace *mtface, *mtf; @@ -2767,16 +2771,16 @@ static void init_render_dm(DerivedMesh *dm, Render *re, ObjectRen *obr, int index, mtfn= 0, mcn= 0; char *name; - for(index=0; index<dm->faceData.totlayer; index++) { + for (index=0; index<dm->faceData.totlayer; index++) { layer= &dm->faceData.layers[index]; name= layer->name; - if(layer->type == CD_MTFACE && mtfn < MAX_MTFACE) { + if (layer->type == CD_MTFACE && mtfn < MAX_MTFACE) { mtf= RE_vlakren_get_tface(obr, vlr, mtfn++, &name, 1); mtface= (MTFace*)layer->data; *mtf= mtface[a]; } - else if(layer->type == CD_MCOL && mcn < MAX_MCOL) { + else if (layer->type == CD_MCOL && mcn < MAX_MCOL) { mc= RE_vlakren_get_mcol(obr, vlr, mcn++, &name, 1); mcol= (MCol*)layer->data; memcpy(mc, &mcol[a*4], sizeof(MCol)*4); @@ -2807,7 +2811,7 @@ static void init_render_surf(Render *re, ObjectRen *obr, int timeoffset) cu= ob->data; nu= cu->nurb.first; - if(nu==0) return; + if (nu==0) return; mult_m4_m4m4(mat, re->viewmat, ob->obmat); invert_m4_m4(ob->imat, mat); @@ -2816,36 +2820,37 @@ static void init_render_surf(Render *re, ObjectRen *obr, int timeoffset) totmat= ob->totcol+1; matar= MEM_callocN(sizeof(Material*)*totmat, "init_render_surf matar"); - for(a=0; a<totmat; a++) { + for (a=0; a<totmat; a++) { matar[a]= give_render_material(re, ob, a+1); - if(matar[a] && matar[a]->texco & TEXCO_ORCO) + if (matar[a] && matar[a]->texco & TEXCO_ORCO) need_orco= 1; } - if(ob->parent && (ob->parent->type==OB_LATTICE)) need_orco= 1; + if (ob->parent && (ob->parent->type==OB_LATTICE)) need_orco= 1; makeDispListSurf(re->scene, ob, &displist, &dm, 1, 0); if (dm) { - if(need_orco) { + if (need_orco) { orco= makeOrcoDispList(re->scene, ob, dm, 1); - if(orco) { + if (orco) { set_object_orco(re, ob, orco); } } init_render_dm(dm, re, obr, timeoffset, orco, mat); dm->release(dm); - } else { - if(need_orco) { + } + else { + if (need_orco) { orco= get_object_orco(re, ob); } /* walk along displaylist and create rendervertices/-faces */ - for(dl=displist.first; dl; dl=dl->next) { + for (dl=displist.first; dl; dl=dl->next) { /* watch out: u ^= y, v ^= x !! */ - if(dl->type==DL_SURF) + if (dl->type==DL_SURF) orco+= 3*dl_surf_to_renderdata(obr, dl, matar, orco, mat); } } @@ -2871,12 +2876,12 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset) int need_orco=0, totmat; cu= ob->data; - if(ob->type==OB_FONT && cu->str==NULL) return; - else if(ob->type==OB_CURVE && cu->nurb.first==NULL) return; + if (ob->type==OB_FONT && cu->str==NULL) return; + else if (ob->type==OB_CURVE && cu->nurb.first==NULL) return; makeDispListCurveTypes_forRender(re->scene, ob, &disp, &dm, 0); dl= disp.first; - if(dl==NULL) return; + if (dl==NULL) return; mult_m4_m4m4(mat, re->viewmat, ob->obmat); invert_m4_m4(ob->imat, mat); @@ -2885,39 +2890,40 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset) totmat= ob->totcol+1; matar= MEM_callocN(sizeof(Material*)*totmat, "init_render_surf matar"); - for(a=0; a<totmat; a++) { + for (a=0; a<totmat; a++) { matar[a]= give_render_material(re, ob, a+1); - if(matar[a] && matar[a]->texco & TEXCO_ORCO) + if (matar[a] && matar[a]->texco & TEXCO_ORCO) need_orco= 1; } if (dm) { - if(need_orco) { + if (need_orco) { orco= makeOrcoDispList(re->scene, ob, dm, 1); - if(orco) { + if (orco) { set_object_orco(re, ob, orco); } } init_render_dm(dm, re, obr, timeoffset, orco, mat); dm->release(dm); - } else { - if(need_orco) { + } + else { + if (need_orco) { orco= get_object_orco(re, ob); } while(dl) { - if(dl->col > ob->totcol) { + if (dl->col > ob->totcol) { /* pass */ } - else if(dl->type==DL_INDEX3) { + else if (dl->type==DL_INDEX3) { int *index; startvert= obr->totvert; data= dl->verts; - for(a=0; a<dl->nr; a++, data+=3) { + for (a=0; a<dl->nr; a++, data+=3) { ver= RE_findOrAddVert(obr, obr->totvert++); copy_v3_v3(ver->co, data); @@ -2929,20 +2935,20 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset) } } - if(timeoffset==0) { + if (timeoffset==0) { float tmp[3]; const int startvlak= obr->totvlak; zero_v3(n); index= dl->index; - for(a=0; a<dl->parts; a++, index+=3) { + for (a=0; a<dl->parts; a++, index+=3) { vlr= RE_findOrAddVlak(obr, obr->totvlak++); vlr->v1= RE_findOrAddVert(obr, startvert+index[0]); vlr->v2= RE_findOrAddVert(obr, startvert+index[1]); vlr->v3= RE_findOrAddVert(obr, startvert+index[2]); vlr->v4= NULL; - if(area_tri_v3(vlr->v3->co, vlr->v2->co, vlr->v1->co)>FLT_EPSILON) { + if (area_tri_v3(vlr->v3->co, vlr->v2->co, vlr->v1->co)>FLT_EPSILON) { normal_tri_v3(tmp, vlr->v3->co, vlr->v2->co, vlr->v1->co); add_v3_v3(n, tmp); } @@ -2955,7 +2961,7 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset) normalize_v3(n); /* vertex normals */ - for(a= startvlak; a<obr->totvlak; a++) { + for (a= startvlak; a<obr->totvlak; a++) { vlr= RE_findOrAddVlak(obr, a); copy_v3_v3(vlr->n, n); @@ -2963,7 +2969,7 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset) add_v3_v3(vlr->v3->n, vlr->n); add_v3_v3(vlr->v2->n, vlr->n); } - for(a=startvert; a<obr->totvert; a++) { + for (a=startvert; a<obr->totvert; a++) { ver= RE_findOrAddVert(obr, a); normalize_v3(ver->n); } @@ -2995,10 +3001,10 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset) } } - if(dl->bevelSplitFlag || timeoffset==0) { + if (dl->bevelSplitFlag || timeoffset==0) { const int startvlak= obr->totvlak; - for(a=0; a<dl->parts; a++) { + for (a=0; a<dl->parts; a++) { if (surfindex_displist(dl, a, &b, &p1, &p2, &p3, &p4)==0) break; @@ -3008,7 +3014,7 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset) p3+= startvert; p4+= startvert; - for(; b<dl->nr; b++) { + for (; b<dl->nr; b++) { vlr= RE_findOrAddVlak(obr, obr->totvlak++); /* important 1 offset in order is kept [#24913] */ vlr->v1= RE_findOrAddVert(obr, p2); @@ -3016,7 +3022,7 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset) vlr->v3= RE_findOrAddVert(obr, p3); vlr->v4= RE_findOrAddVert(obr, p4); vlr->ec= ME_V2V3+ME_V3V4; - if(a==0) vlr->ec+= ME_V1V2; + if (a==0) vlr->ec+= ME_V1V2; vlr->flag= dl->rt; @@ -3031,13 +3037,13 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset) } if (dl->bevelSplitFlag) { - for(a=0; a<dl->parts-1+!!(dl->flag&DL_CYCL_V); a++) - if(dl->bevelSplitFlag[a>>5]&(1<<(a&0x1F))) + for (a=0; a<dl->parts-1+!!(dl->flag&DL_CYCL_V); a++) + if (dl->bevelSplitFlag[a>>5]&(1<<(a&0x1F))) split_v_renderfaces(obr, startvlak, startvert, dl->parts, dl->nr, a, dl->flag&DL_CYCL_V, dl->flag&DL_CYCL_U); } /* vertex normals */ - for(a= startvlak; a<obr->totvlak; a++) { + for (a= startvlak; a<obr->totvlak; a++) { vlr= RE_findOrAddVlak(obr, a); add_v3_v3(vlr->v1->n, vlr->n); @@ -3045,7 +3051,7 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset) add_v3_v3(vlr->v2->n, vlr->n); add_v3_v3(vlr->v4->n, vlr->n); } - for(a=startvert; a<obr->totvert; a++) { + for (a=startvert; a<obr->totvert; a++) { ver= RE_findOrAddVert(obr, a); normalize_v3(ver->n); } @@ -3093,10 +3099,10 @@ static int vergedgesort(const void *v1, const void *v2) { const struct edgesort *x1=v1, *x2=v2; - if( x1->v1 > x2->v1) return 1; - else if( x1->v1 < x2->v1) return -1; - else if( x1->v2 > x2->v2) return 1; - else if( x1->v2 < x2->v2) return -1; + if ( x1->v1 > x2->v1) return 1; + else if ( x1->v1 < x2->v1) return -1; + else if ( x1->v2 > x2->v2) return 1; + else if ( x1->v2 < x2->v2) return -1; return 0; } @@ -3114,27 +3120,27 @@ static struct edgesort *make_mesh_edge_lookup(DerivedMesh *dm, int *totedgesort) tface= dm->getTessFaceDataArray(dm, CD_MTFACE); mcol= dm->getTessFaceDataArray(dm, CD_MCOL); - if(mcol==NULL && tface==NULL) return NULL; + if (mcol==NULL && tface==NULL) return NULL; /* make sorted table with edges and face indices in it */ - for(a= totface, mf= mface; a>0; a--, mf++) { - if(mf->v4) totedge+=4; - else if(mf->v3) totedge+=3; + for (a= totface, mf= mface; a>0; a--, mf++) { + if (mf->v4) totedge+=4; + else if (mf->v3) totedge+=3; } - if(totedge==0) + if (totedge==0) return NULL; ed= edsort= MEM_callocN(totedge*sizeof(struct edgesort), "edgesort"); - for(a=0, mf=mface; a<totface; a++, mf++) { + for (a=0, mf=mface; a<totface; a++, mf++) { to_edgesort(ed++, 0, 1, mf->v1, mf->v2, a); to_edgesort(ed++, 1, 2, mf->v2, mf->v3, a); - if(mf->v4) { + if (mf->v4) { to_edgesort(ed++, 2, 3, mf->v3, mf->v4, a); to_edgesort(ed++, 3, 0, mf->v4, mf->v1, a); } - else if(mf->v3) + else if (mf->v3) to_edgesort(ed++, 2, 3, mf->v3, mf->v1, a); } @@ -3154,7 +3160,7 @@ static void use_mesh_edge_lookup(ObjectRen *obr, DerivedMesh *dm, MEdge *medge, int index, mtfn, mcn; char *name; - if(medge->v1 < medge->v2) { + if (medge->v1 < medge->v2) { ed.v1= medge->v1; ed.v2= medge->v2; } @@ -3166,14 +3172,14 @@ static void use_mesh_edge_lookup(ObjectRen *obr, DerivedMesh *dm, MEdge *medge, edp= bsearch(&ed, edgetable, totedge, sizeof(struct edgesort), vergedgesort); /* since edges have different index ordering, we have to duplicate mcol and tface */ - if(edp) { + if (edp) { mtfn= mcn= 0; - for(index=0; index<dm->faceData.totlayer; index++) { + for (index=0; index<dm->faceData.totlayer; index++) { layer= &dm->faceData.layers[index]; name= layer->name; - if(layer->type == CD_MTFACE && mtfn < MAX_MTFACE) { + if (layer->type == CD_MTFACE && mtfn < MAX_MTFACE) { mtface= &((MTFace*)layer->data)[edp->f]; mtf= RE_vlakren_get_tface(obr, vlr, mtfn++, &name, 1); @@ -3184,7 +3190,7 @@ static void use_mesh_edge_lookup(ObjectRen *obr, DerivedMesh *dm, MEdge *medge, memcpy(mtf->uv[2], mtface->uv[1], sizeof(float)*2); memcpy(mtf->uv[3], mtface->uv[1], sizeof(float)*2); } - else if(layer->type == CD_MCOL && mcn < MAX_MCOL) { + else if (layer->type == CD_MCOL && mcn < MAX_MCOL) { mcol= &((MCol*)layer->data)[edp->f*4]; mc= RE_vlakren_get_mcol(obr, vlr, mcn++, &name, 1); @@ -3206,8 +3212,8 @@ static void init_camera_inside_volumes(Render *re) VolumeOb *vo; float co[3] = {0.f, 0.f, 0.f}; - for(vo= re->volumes.first; vo; vo= vo->next) { - for(obi= re->instancetable.first; obi; obi= obi->next) { + for (vo= re->volumes.first; vo; vo= vo->next) { + for (obi= re->instancetable.first; obi; obi= obi->next) { if (obi->obr == vo->obr) { if (point_inside_volume_objectinstance(re, obi, co)) { MatInside *mi; @@ -3270,25 +3276,25 @@ static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset) copy_m3_m4(imat, ob->imat); negative_scale= is_negative_m4(mat); - if(me->totvert==0) + if (me->totvert==0) return; need_orco= 0; - for(a=1; a<=ob->totcol; a++) { + for (a=1; a<=ob->totcol; a++) { ma= give_render_material(re, ob, a); - if(ma) { - if(ma->texco & (TEXCO_ORCO|TEXCO_STRESS)) + if (ma) { + if (ma->texco & (TEXCO_ORCO|TEXCO_STRESS)) need_orco= 1; - if(ma->texco & TEXCO_STRESS) + if (ma->texco & TEXCO_STRESS) need_stress= 1; /* normalmaps, test if tangents needed, separated from shading */ - if(ma->mode_l & MA_TANGENT_V) { + if (ma->mode_l & MA_TANGENT_V) { need_tangent= 1; - if(me->mtface==NULL) + if (me->mtface==NULL) need_orco= 1; } - if(ma->mode_l & MA_NORMAP_TANG) { - if(me->mtface==NULL) { + if (ma->mode_l & MA_NORMAP_TANG) { + if (me->mtface==NULL) { need_orco= 1; need_tangent= 1; } @@ -3297,9 +3303,9 @@ static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset) } } - if(re->flag & R_NEED_TANGENT) { + if (re->flag & R_NEED_TANGENT) { /* exception for tangent space baking */ - if(me->mtface==NULL) { + if (me->mtface==NULL) { need_orco= 1; need_tangent= 1; } @@ -3308,22 +3314,22 @@ static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset) /* check autosmooth and displacement, we then have to skip only-verts optimize */ do_autosmooth |= (me->flag & ME_AUTOSMOOTH); - if(do_autosmooth) + if (do_autosmooth) timeoffset= 0; - if(test_for_displace(re, ob ) ) + if (test_for_displace(re, ob ) ) timeoffset= 0; mask= CD_MASK_BAREMESH|CD_MASK_MTFACE|CD_MASK_MCOL; - if(!timeoffset) - if(need_orco) + if (!timeoffset) + if (need_orco) mask |= CD_MASK_ORCO; dm= mesh_create_derived_render(re->scene, ob, mask); - if(dm==NULL) return; /* in case duplicated object fails? */ + if (dm==NULL) return; /* in case duplicated object fails? */ - if(mask & CD_MASK_ORCO) { + if (mask & CD_MASK_ORCO) { orco= dm->getVertDataArray(dm, CD_ORCO); - if(orco) { + if (orco) { orco= MEM_dupallocN(orco); set_object_orco(re, ob, orco); } @@ -3333,7 +3339,7 @@ static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset) totvert= dm->getNumVerts(dm); /* attempt to autsmooth on original mesh, only without subsurf */ - if(do_autosmooth && me->totvert==totvert && me->totface==dm->getNumTessFaces(dm)) + if (do_autosmooth && me->totvert==totvert && me->totface==dm->getNumTessFaces(dm)) use_original_normals= 1; ms = (totvert==me->totvert)?me->msticky:NULL; @@ -3341,15 +3347,15 @@ static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset) ma= give_render_material(re, ob, 1); - if(ma->material_type == MA_TYPE_HALO) { + if (ma->material_type == MA_TYPE_HALO) { make_render_halos(re, obr, me, totvert, mvert, ma, orco); } else { - for(a=0; a<totvert; a++, mvert++) { + for (a=0; a<totvert; a++, mvert++) { ver= RE_findOrAddVert(obr, obr->totvert++); copy_v3_v3(ver->co, mvert->co); - if(do_autosmooth==0) { /* autosmooth on original unrotated data to prevent differences between frames */ + if (do_autosmooth==0) { /* autosmooth on original unrotated data to prevent differences between frames */ normal_short_to_float_v3(ver->n, mvert->no); mul_m4_v3(mat, ver->co); mul_transposed_m3_v3(imat, ver->n); @@ -3357,59 +3363,59 @@ static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset) negate_v3(ver->n); } - if(orco) { + if (orco) { ver->orco= orco; orco+=3; } - if(ms) { + if (ms) { float *sticky= RE_vertren_get_sticky(obr, ver, 1); copy_v2_v2(sticky, ms->co); ms++; } } - if(!timeoffset) { + if (!timeoffset) { /* store customdata names, because DerivedMesh is freed */ RE_set_customdata_names(obr, &dm->faceData); /* add tangent layer if we need one */ - if(need_nmap_tangent!=0 && CustomData_get_layer_index(&dm->faceData, CD_TANGENT) == -1) + if (need_nmap_tangent!=0 && CustomData_get_layer_index(&dm->faceData, CD_TANGENT) == -1) DM_add_tangent_layer(dm); /* still to do for keys: the correct local texture coordinate */ /* faces in order of color blocks */ vertofs= obr->totvert - totvert; - for(a1=0; (a1<ob->totcol || (a1==0 && ob->totcol==0)); a1++) { + for (a1=0; (a1<ob->totcol || (a1==0 && ob->totcol==0)); a1++) { ma= give_render_material(re, ob, a1+1); /* test for 100% transparant */ ok= 1; - if(ma->alpha==0.0f && ma->spectra==0.0f && ma->filter==0.0f && (ma->mode & MA_TRANSP) && (ma->mode & MA_RAYMIRROR)==0) { + if (ma->alpha==0.0f && ma->spectra==0.0f && ma->filter==0.0f && (ma->mode & MA_TRANSP) && (ma->mode & MA_RAYMIRROR)==0) { ok= 0; /* texture on transparency? */ - for(a=0; a<MAX_MTEX; a++) { - if(ma->mtex[a] && ma->mtex[a]->tex) { - if(ma->mtex[a]->mapto & MAP_ALPHA) ok= 1; + for (a=0; a<MAX_MTEX; a++) { + if (ma->mtex[a] && ma->mtex[a]->tex) { + if (ma->mtex[a]->mapto & MAP_ALPHA) ok= 1; } } } /* if wire material, and we got edges, don't do the faces */ - if(ma->material_type == MA_TYPE_WIRE) { + if (ma->material_type == MA_TYPE_WIRE) { end= dm->getNumEdges(dm); - if(end) ok= 0; + if (end) ok= 0; } - if(ok) { + if (ok) { end= dm->getNumTessFaces(dm); mface= dm->getTessFaceArray(dm); - for(a=0; a<end; a++, mface++) { + for (a=0; a<end; a++, mface++) { int v1, v2, v3, v4, flag; - if( mface->mat_nr==a1 ) { + if ( mface->mat_nr==a1 ) { float len; int reverse_verts = negative_scale!=0 && do_autosmooth==0; int rev_tab[] = {reverse_verts==0 ? 0 : 2, 1, reverse_verts==0 ? 2 : 0, 3}; @@ -3423,21 +3429,21 @@ static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset) vlr->v1= RE_findOrAddVert(obr, vertofs+v1); vlr->v2= RE_findOrAddVert(obr, vertofs+v2); vlr->v3= RE_findOrAddVert(obr, vertofs+v3); - if(v4) vlr->v4= RE_findOrAddVert(obr, vertofs+v4); + if (v4) vlr->v4= RE_findOrAddVert(obr, vertofs+v4); else vlr->v4= 0; /* render normals are inverted in render */ - if(use_original_normals) { + if (use_original_normals) { MFace *mf= me->mface+a; MVert *mv= me->mvert; - if(vlr->v4) + if (vlr->v4) len= normal_quad_v3( vlr->n, mv[mf->v4].co, mv[mf->v3].co, mv[mf->v2].co, mv[mf->v1].co); else len= normal_tri_v3( vlr->n,mv[mf->v3].co, mv[mf->v2].co, mv[mf->v1].co); } else { - if(vlr->v4) + if (vlr->v4) len= normal_quad_v3( vlr->n,vlr->v4->co, vlr->v3->co, vlr->v2->co, vlr->v1->co); else len= normal_tri_v3( vlr->n,vlr->v3->co, vlr->v2->co, vlr->v1->co); @@ -3447,7 +3453,7 @@ static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset) vlr->flag= flag; vlr->ec= 0; /* mesh edges rendered separately */ - if(len==0) obr->totvlak--; + if (len==0) obr->totvlak--; else { CustomDataLayer *layer; MTFace *mtface, *mtf; @@ -3456,30 +3462,30 @@ static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset) char *name; int nr_verts = v4!=0 ? 4 : 3; - for(index=0; index<dm->faceData.totlayer; index++) { + for (index=0; index<dm->faceData.totlayer; index++) { layer= &dm->faceData.layers[index]; name= layer->name; - if(layer->type == CD_MTFACE && mtfn < MAX_MTFACE) { + if (layer->type == CD_MTFACE && mtfn < MAX_MTFACE) { int t; mtf= RE_vlakren_get_tface(obr, vlr, mtfn++, &name, 1); mtface= (MTFace*)layer->data; *mtf= mtface[a]; // copy face info - for(vindex=0; vindex<nr_verts; vindex++) - for(t=0; t<2; t++) + for (vindex=0; vindex<nr_verts; vindex++) + for (t=0; t<2; t++) mtf->uv[vindex][t]=mtface[a].uv[rev_tab[vindex]][t]; } - else if(layer->type == CD_MCOL && mcn < MAX_MCOL) { + else if (layer->type == CD_MCOL && mcn < MAX_MCOL) { mc= RE_vlakren_get_mcol(obr, vlr, mcn++, &name, 1); mcol= (MCol*)layer->data; - for(vindex=0; vindex<nr_verts; vindex++) + for (vindex=0; vindex<nr_verts; vindex++) mc[vindex]=mcol[a*4+rev_tab[vindex]]; } else if (layer->type == CD_TANGENT && mtng < 1) { if (need_nmap_tangent != 0) { const float * tangent = (const float *) layer->data; float * ftang = RE_vlakren_get_nmap_tangent(obr, vlr, 1); - for(vindex=0; vindex<nr_verts; vindex++) + for (vindex=0; vindex<nr_verts; vindex++) { copy_v4_v4(ftang+vindex*4, tangent+a*16+rev_tab[vindex]*4); mul_mat3_m4_v3(mat, ftang+vindex*4); @@ -3498,7 +3504,7 @@ static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset) end= dm->getNumEdges(dm); mvert= dm->getVertArray(dm); ma= give_render_material(re, ob, 1); - if(end && (ma->material_type == MA_TYPE_WIRE)) { + if (end && (ma->material_type == MA_TYPE_WIRE)) { MEdge *medge; struct edgesort *edgetable; int totedge= 0; @@ -3509,7 +3515,7 @@ static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset) /* we want edges to have UV and vcol too... */ edgetable= make_mesh_edge_lookup(dm, &totedge); - for(a1=0; a1<end; a1++, medge++) { + for (a1=0; a1<end; a1++, medge++) { if (medge->flag&ME_EDGERENDER) { MVert *v0 = &mvert[medge->v1]; MVert *v1 = &mvert[medge->v2]; @@ -3520,7 +3526,7 @@ static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset) vlr->v3= vlr->v2; vlr->v4= NULL; - if(edgetable) + if (edgetable) use_mesh_edge_lookup(obr, dm, medge, vlr, edgetable, totedge); xn= -(v0->no[0]+v1->no[0]); @@ -3537,31 +3543,31 @@ static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset) vlr->ec= ME_V1V2; } } - if(edgetable) + if (edgetable) MEM_freeN(edgetable); } } } - if(!timeoffset) { - if(need_stress) + if (!timeoffset) { + if (need_stress) calc_edge_stress(re, obr, me); if (test_for_displace(re, ob ) ) { recalc_normals= 1; calc_vertexnormals(re, obr, 0, 0); - if(do_autosmooth) + if (do_autosmooth) do_displacement(re, obr, mat, imat); else do_displacement(re, obr, NULL, NULL); } - if(do_autosmooth) { + if (do_autosmooth) { recalc_normals= 1; autosmooth(re, obr, mat, me->smoothresh); } - if(recalc_normals!=0 || need_tangent!=0) + if (recalc_normals!=0 || need_tangent!=0) calc_vertexnormals(re, obr, need_tangent, need_nmap_tangent); } @@ -3583,15 +3589,15 @@ static void initshadowbuf(Render *re, LampRen *lar, float mat[][4]) shb= (struct ShadBuf *)MEM_callocN( sizeof(struct ShadBuf),"initshadbuf"); lar->shb= shb; - if(shb==NULL) return; + if (shb==NULL) return; VECCOPY(shb->co, lar->co); /* int copy */ /* percentage render: keep track of min and max */ shb->size= (lar->bufsize*re->r.size)/100; - if(shb->size<512) shb->size= 512; - else if(shb->size > lar->bufsize) shb->size= lar->bufsize; + if (shb->size<512) shb->size= 512; + else if (shb->size > lar->bufsize) shb->size= lar->bufsize; shb->size &= ~15; /* make sure its multiples of 16 */ @@ -3616,7 +3622,7 @@ static void initshadowbuf(Render *re, LampRen *lar, float mat[][4]) shb->bias= (0.02f*lar->bias)*0x7FFFFFFF; /* halfway method (average of first and 2nd z) reduces bias issues */ - if(ELEM(lar->buftype, LA_SHADBUF_HALFWAY, LA_SHADBUF_DEEP)) + if (ELEM(lar->buftype, LA_SHADBUF_HALFWAY, LA_SHADBUF_DEEP)) shb->bias= 0.1f*shb->bias; shb->compressthresh= lar->compressthresh; @@ -3665,11 +3671,11 @@ static GroupObject *add_render_lamp(Render *re, Object *ob) int c; /* previewrender sets this to zero... prevent accidents */ - if(la==NULL) return NULL; + if (la==NULL) return NULL; /* prevent only shadow from rendering light */ - if(la->mode & LA_ONLYSHADOW) - if((re->r.mode & R_SHADOW)==0) + if (la->mode & LA_ONLYSHADOW) + if ((re->r.mode & R_SHADOW)==0) return NULL; re->totlamp++; @@ -3692,7 +3698,7 @@ static GroupObject *add_render_lamp(Render *re, Object *ob) lar->bufsize = la->bufsize; lar->samp = la->samp; lar->buffers= la->buffers; - if(lar->buffers==0) lar->buffers= 1; + if (lar->buffers==0) lar->buffers= 1; lar->buftype= la->buftype; lar->filtertype= la->filtertype; lar->soft = la->soft; @@ -3707,7 +3713,7 @@ static GroupObject *add_render_lamp(Render *re, Object *ob) lar->mode= la->mode; lar->energy= la->energy; - if(la->mode & LA_NEG) lar->energy= -lar->energy; + if (la->mode & LA_NEG) lar->energy= -lar->energy; lar->vec[0]= -mat[2][0]; lar->vec[1]= -mat[2][1]; @@ -3740,7 +3746,7 @@ static GroupObject *add_render_lamp(Render *re, Object *ob) /* Annoying, lamp UI does this, but the UI might not have been used? - add here too. * make sure this matches buttons_shading.c's logic */ - if(ELEM4(la->type, LA_AREA, LA_SPOT, LA_SUN, LA_LOCAL) && (la->mode & LA_SHAD_RAY)) + if (ELEM4(la->type, LA_AREA, LA_SPOT, LA_SUN, LA_LOCAL) && (la->mode & LA_SHAD_RAY)) if (ELEM3(la->type, LA_SPOT, LA_SUN, LA_LOCAL)) if (la->ray_samp_method == LA_SAMP_CONSTANT) la->ray_samp_method = LA_SAMP_HALTON; @@ -3750,12 +3756,12 @@ static GroupObject *add_render_lamp(Render *re, Object *ob) lar->adapt_thresh= la->adapt_thresh; lar->sunsky = NULL; - if( ELEM(lar->type, LA_SPOT, LA_LOCAL)) { + if ( ELEM(lar->type, LA_SPOT, LA_LOCAL)) { lar->ray_totsamp= lar->ray_samp*lar->ray_samp; lar->area_shape = LA_AREA_SQUARE; lar->area_sizey= lar->area_size; } - else if(lar->type==LA_AREA) { + else if (lar->type==LA_AREA) { switch(lar->area_shape) { case LA_AREA_SQUARE: lar->ray_totsamp= lar->ray_samp*lar->ray_samp; @@ -3780,13 +3786,13 @@ static GroupObject *add_render_lamp(Render *re, Object *ob) area_lamp_vectors(lar); init_jitter_plane(lar); // subsamples } - else if(lar->type==LA_SUN){ + else if (lar->type==LA_SUN) { lar->ray_totsamp= lar->ray_samp*lar->ray_samp; lar->area_shape = LA_AREA_SQUARE; lar->area_sizey= lar->area_size; - if((la->sun_effect_type & LA_SUN_EFFECT_SKY) || - (la->sun_effect_type & LA_SUN_EFFECT_AP)){ + if ((la->sun_effect_type & LA_SUN_EFFECT_SKY) || + (la->sun_effect_type & LA_SUN_EFFECT_AP)) { lar->sunsky = (struct SunSky*)MEM_callocN(sizeof(struct SunSky), "sunskyren"); lar->sunsky->effect_type = la->sun_effect_type; @@ -3804,8 +3810,8 @@ static GroupObject *add_render_lamp(Render *re, Object *ob) else lar->ray_totsamp= 0; lar->spotsi= la->spotsize; - if(lar->mode & LA_HALO) { - if(lar->spotsi>170.0f) lar->spotsi= 170.0f; + if (lar->mode & LA_HALO) { + if (lar->spotsi>170.0f) lar->spotsi= 170.0f; } lar->spotsi= cosf( (float)M_PI*lar->spotsi/360.0f ); lar->spotbl= (1.0f-lar->spotsi)*la->spotblend; @@ -3819,7 +3825,7 @@ static GroupObject *add_render_lamp(Render *re, Object *ob) lar->ld2= la->att2; lar->curfalloff = curvemapping_copy(la->curfalloff); - if(lar->type==LA_SPOT) { + if (lar->type==LA_SPOT) { normalize_v3(lar->imat[0]); normalize_v3(lar->imat[1]); @@ -3829,15 +3835,15 @@ static GroupObject *add_render_lamp(Render *re, Object *ob) xn= sin(xn)/cos(xn); lar->spottexfac= 1.0f/(xn); - if(lar->mode & LA_ONLYSHADOW) { - if((lar->mode & (LA_SHAD_BUF|LA_SHAD_RAY))==0) lar->mode -= LA_ONLYSHADOW; + if (lar->mode & LA_ONLYSHADOW) { + if ((lar->mode & (LA_SHAD_BUF|LA_SHAD_RAY))==0) lar->mode -= LA_ONLYSHADOW; } } /* set flag for spothalo en initvars */ - if(la->type==LA_SPOT && (la->mode & LA_HALO) && (la->buftype != LA_SHADBUF_DEEP)) { - if(la->haint>0.0f) { + if (la->type==LA_SPOT && (la->mode & LA_HALO) && (la->buftype != LA_SHADBUF_DEEP)) { + if (la->haint>0.0f) { re->flag |= R_LAMPHALO; /* camera position (0,0,0) rotate around lamp */ @@ -3855,25 +3861,25 @@ static GroupObject *add_render_lamp(Render *re, Object *ob) lar->sh_invcampos[2]*= lar->sh_zfac; /* halfway shadow buffer doesn't work for volumetric effects */ - if(lar->buftype == LA_SHADBUF_HALFWAY) + if (lar->buftype == LA_SHADBUF_HALFWAY) lar->buftype = LA_SHADBUF_REGULAR; } } - else if(la->type==LA_HEMI) { + else if (la->type==LA_HEMI) { lar->mode &= ~(LA_SHAD_RAY|LA_SHAD_BUF); } - for(c=0; c<MAX_MTEX; c++) { - if(la->mtex[c] && la->mtex[c]->tex) { + for (c=0; c<MAX_MTEX; c++) { + if (la->mtex[c] && la->mtex[c]->tex) { if (la->mtex[c]->mapto & LAMAP_COL) lar->mode |= LA_TEXTURE; if (la->mtex[c]->mapto & LAMAP_SHAD) lar->mode |= LA_SHAD_TEX; - if(G.rendering) { - if(re->osa) { - if(la->mtex[c]->tex->type==TEX_IMAGE) lar->mode |= LA_OSATEX; + if (G.rendering) { + if (re->osa) { + if (la->mtex[c]->tex->type==TEX_IMAGE) lar->mode |= LA_OSATEX; } } } @@ -3882,15 +3888,15 @@ static GroupObject *add_render_lamp(Render *re, Object *ob) /* old code checked for internal render (aka not yafray) */ { /* to make sure we can check ray shadow easily in the render code */ - if(lar->mode & LA_SHAD_RAY) { - if( (re->r.mode & R_RAYTRACE)==0) + if (lar->mode & LA_SHAD_RAY) { + if ( (re->r.mode & R_RAYTRACE)==0) lar->mode &= ~LA_SHAD_RAY; } - if(re->r.mode & R_SHADOW) { + if (re->r.mode & R_SHADOW) { - if(la->type==LA_AREA && (lar->mode & LA_SHAD_RAY) && (lar->ray_samp_method == LA_SAMP_CONSTANT)) { + if (la->type==LA_AREA && (lar->mode & LA_SHAD_RAY) && (lar->ray_samp_method == LA_SAMP_CONSTANT)) { init_jitter_plane(lar); } else if (la->type==LA_SPOT && (lar->mode & LA_SHAD_BUF) ) { @@ -3902,7 +3908,7 @@ static GroupObject *add_render_lamp(Render *re, Object *ob) /* this is the way used all over to check for shadow */ - if(lar->shb || (lar->mode & LA_SHAD_RAY)) { + if (lar->shb || (lar->mode & LA_SHAD_RAY)) { LampShadowSample *ls; LampShadowSubSample *lss; int a, b; @@ -3913,9 +3919,9 @@ static GroupObject *add_render_lamp(Render *re, Object *ob) ls= lar->shadsamp; /* shadfacs actually mean light, let's put them to 1 to prevent unitialized accidents */ - for(a=0; a<re->r.threads; a++, ls++) { + for (a=0; a<re->r.threads; a++, ls++) { lss= ls->s; - for(b=0; b<re->r.osa; b++, lss++) { + for (b=0; b<re->r.osa; b++, lss++) { lss->samplenr= -1; /* used to detect whether we store or read */ lss->shadfac[0]= 1.0f; lss->shadfac[1]= 1.0f; @@ -3939,20 +3945,20 @@ static void add_lightgroup(Render *re, Group *group, int exclusive) /* it's a bit too many loops in loops... but will survive */ /* note that 'exclusive' will remove it from the global list */ - for(go= group->gobject.first; go; go= go->next) { + for (go= group->gobject.first; go; go= go->next) { go->lampren= NULL; - if(go->ob->lay & re->lay) { - if(go->ob && go->ob->type==OB_LAMP) { - for(gol= re->lights.first; gol; gol= gol->next) { - if(gol->ob==go->ob) { + if (go->ob->lay & re->lay) { + if (go->ob && go->ob->type==OB_LAMP) { + for (gol= re->lights.first; gol; gol= gol->next) { + if (gol->ob==go->ob) { go->lampren= gol->lampren; break; } } - if(go->lampren==NULL) + if (go->lampren==NULL) gol= add_render_lamp(re, go->ob); - if(gol && exclusive) { + if (gol && exclusive) { BLI_remlink(&re->lights, gol); MEM_freeN(gol); } @@ -3967,16 +3973,16 @@ static void set_material_lightgroups(Render *re) Material *ma; /* not for preview render */ - if(re->scene->r.scemode & R_PREVIEWBUTS) + if (re->scene->r.scemode & R_PREVIEWBUTS) return; - for(group= re->main->group.first; group; group=group->id.next) + for (group= re->main->group.first; group; group=group->id.next) group->id.flag |= LIB_DOIT; /* it's a bit too many loops in loops... but will survive */ /* hola! materials not in use...? */ - for(ma= re->main->mat.first; ma; ma=ma->id.next) { - if(ma->group && (ma->group->id.flag & LIB_DOIT)) + for (ma= re->main->mat.first; ma; ma=ma->id.next) { + if (ma->group && (ma->group->id.flag & LIB_DOIT)) add_lightgroup(re, ma->group, ma->mode & MA_GROUP_NOLAY); } } @@ -3985,8 +3991,8 @@ static void set_renderlayer_lightgroups(Render *re, Scene *sce) { SceneRenderLayer *srl; - for(srl= sce->r.layers.first; srl; srl= srl->next) { - if(srl->light_override) + for (srl= sce->r.layers.first; srl; srl= srl->next) { + if (srl->light_override) add_lightgroup(re, srl->light_override, 0); } } @@ -4000,7 +4006,7 @@ void init_render_world(Render *re) int a; char *cp; - if(re->scene && re->scene->world) { + if (re->scene && re->scene->world) { re->wrld= *(re->scene->world); cp= (char *)&re->wrld.fastcol; @@ -4014,14 +4020,14 @@ void init_render_world(Render *re) normalize_v3(re->grvec); copy_m3_m4(re->imat, re->viewinv); - for(a=0; a<MAX_MTEX; a++) - if(re->wrld.mtex[a] && re->wrld.mtex[a]->tex) re->wrld.skytype |= WO_SKYTEX; + for (a=0; a<MAX_MTEX; a++) + if (re->wrld.mtex[a] && re->wrld.mtex[a]->tex) re->wrld.skytype |= WO_SKYTEX; /* AO samples should be OSA minimum */ - if(re->osa) + if (re->osa) while(re->wrld.aosamp*re->wrld.aosamp < re->osa) re->wrld.aosamp++; - if(!(re->r.mode & R_RAYTRACE) && (re->wrld.ao_gather_method == WO_AOGATHER_RAYTRACE)) + if (!(re->r.mode & R_RAYTRACE) && (re->wrld.ao_gather_method == WO_AOGATHER_RAYTRACE)) re->wrld.mode &= ~(WO_AMB_OCC|WO_ENV_LIGHT|WO_INDIRECT_LIGHT); } else { @@ -4057,37 +4063,37 @@ static void set_phong_threshold(ObjectRen *obr) * are taken into account. This threshold is meant to work on smooth geometry, not / for extreme cases (ton) */ - for(i=0; i<obr->totvlak; i++) { + for (i=0; i<obr->totvlak; i++) { vlr= RE_findOrAddVlak(obr, i); - if(vlr->flag & R_SMOOTH) { + if (vlr->flag & R_SMOOTH) { dot= dot_v3v3(vlr->n, vlr->v1->n); dot= ABS(dot); - if(dot>0.9f) { + if (dot>0.9f) { thresh+= dot; tot++; } dot= dot_v3v3(vlr->n, vlr->v2->n); dot= ABS(dot); - if(dot>0.9f) { + if (dot>0.9f) { thresh+= dot; tot++; } dot= dot_v3v3(vlr->n, vlr->v3->n); dot= ABS(dot); - if(dot>0.9f) { + if (dot>0.9f) { thresh+= dot; tot++; } - if(vlr->v4) { + if (vlr->v4) { dot= dot_v3v3(vlr->n, vlr->v4->n); dot= ABS(dot); - if(dot>0.9f) { + if (dot>0.9f) { thresh+= dot; tot++; } } } } - if(tot) { + if (tot) { thresh/= (float)tot; obr->ob->smoothresh= cosf(0.5f*(float)M_PI-saacos(thresh)); } @@ -4103,21 +4109,21 @@ static void set_fullsample_trace_flag(Render *re, ObjectRen *obr) osa= re->osa; trace= re->r.mode & R_RAYTRACE; - for(a=obr->totvlak-1; a>=0; a--) { + for (a=obr->totvlak-1; a>=0; a--) { vlr= RE_findOrAddVlak(obr, a); mode= vlr->mat->mode; - if(trace && (mode & MA_TRACEBLE)) + if (trace && (mode & MA_TRACEBLE)) vlr->flag |= R_TRACEBLE; - if(osa) { - if(mode & MA_FULL_OSA) { + if (osa) { + if (mode & MA_FULL_OSA) { vlr->flag |= R_FULL_OSA; } - else if(trace) { - if(mode & MA_SHLESS); - else if(vlr->mat->material_type == MA_TYPE_VOLUME); - else if((mode & MA_RAYMIRROR) || ((mode & MA_TRANSP) && (mode & MA_RAYTRANSP))) { + else if (trace) { + if (mode & MA_SHLESS); + else if (vlr->mat->material_type == MA_TYPE_VOLUME); + else if ((mode & MA_RAYMIRROR) || ((mode & MA_TRANSP) && (mode & MA_RAYTRANSP))) { /* for blurry reflect/refract, better to take more samples * inside the raytrace than as OSA samples */ if ((vlr->mat->gloss_mir == 1.0f) && (vlr->mat->gloss_tra == 1.0f)) @@ -4136,18 +4142,18 @@ static void split_quads(ObjectRen *obr, int dir) VlakRen *vlr, *vlr1; int a; - for(a=obr->totvlak-1; a>=0; a--) { + for (a=obr->totvlak-1; a>=0; a--) { vlr= RE_findOrAddVlak(obr, a); /* test if rendering as a quad or triangle, skip wire */ - if(vlr->v4 && (vlr->flag & R_STRAND)==0 && (vlr->mat->material_type != MA_TYPE_WIRE)) { + if (vlr->v4 && (vlr->flag & R_STRAND)==0 && (vlr->mat->material_type != MA_TYPE_WIRE)) { - if(vlr->v4) { + if (vlr->v4) { vlr1= RE_vlakren_copy(obr, vlr); vlr1->flag |= R_FACE_SPLIT; - if( dir==2 ) vlr->flag |= R_DIVIDE_24; + if ( dir==2 ) vlr->flag |= R_DIVIDE_24; else vlr->flag &= ~R_DIVIDE_24; /* new vertex pointers */ @@ -4186,11 +4192,11 @@ static void check_non_flat_quads(ObjectRen *obr) float nor[3], xn, flen; int a; - for(a=obr->totvlak-1; a>=0; a--) { + for (a=obr->totvlak-1; a>=0; a--) { vlr= RE_findOrAddVlak(obr, a); /* test if rendering as a quad or triangle, skip wire */ - if(vlr->v4 && (vlr->flag & R_STRAND)==0 && (vlr->mat->material_type != MA_TYPE_WIRE)) { + if (vlr->v4 && (vlr->flag & R_STRAND)==0 && (vlr->mat->material_type != MA_TYPE_WIRE)) { /* check if quad is actually triangle */ v1= vlr->v1; @@ -4198,7 +4204,7 @@ static void check_non_flat_quads(ObjectRen *obr) v3= vlr->v3; v4= vlr->v4; sub_v3_v3v3(nor, v1->co, v2->co); - if( ABS(nor[0])<FLT_EPSILON10 && ABS(nor[1])<FLT_EPSILON10 && ABS(nor[2])<FLT_EPSILON10 ) { + if ( ABS(nor[0])<FLT_EPSILON10 && ABS(nor[1])<FLT_EPSILON10 && ABS(nor[2])<FLT_EPSILON10 ) { vlr->v1= v2; vlr->v2= v3; vlr->v3= v4; @@ -4206,26 +4212,26 @@ static void check_non_flat_quads(ObjectRen *obr) } else { sub_v3_v3v3(nor, v2->co, v3->co); - if( ABS(nor[0])<FLT_EPSILON10 && ABS(nor[1])<FLT_EPSILON10 && ABS(nor[2])<FLT_EPSILON10 ) { + if ( ABS(nor[0])<FLT_EPSILON10 && ABS(nor[1])<FLT_EPSILON10 && ABS(nor[2])<FLT_EPSILON10 ) { vlr->v2= v3; vlr->v3= v4; vlr->v4= NULL; } else { sub_v3_v3v3(nor, v3->co, v4->co); - if( ABS(nor[0])<FLT_EPSILON10 && ABS(nor[1])<FLT_EPSILON10 && ABS(nor[2])<FLT_EPSILON10 ) { + if ( ABS(nor[0])<FLT_EPSILON10 && ABS(nor[1])<FLT_EPSILON10 && ABS(nor[2])<FLT_EPSILON10 ) { vlr->v4= NULL; } else { sub_v3_v3v3(nor, v4->co, v1->co); - if( ABS(nor[0])<FLT_EPSILON10 && ABS(nor[1])<FLT_EPSILON10 && ABS(nor[2])<FLT_EPSILON10 ) { + if ( ABS(nor[0])<FLT_EPSILON10 && ABS(nor[1])<FLT_EPSILON10 && ABS(nor[2])<FLT_EPSILON10 ) { vlr->v4= NULL; } } } } - if(vlr->v4) { + if (vlr->v4) { /* Face is divided along edge with the least gradient */ /* Flagged with R_DIVIDE_24 if divide is from vert 2 to 4 */ @@ -4236,11 +4242,11 @@ static void check_non_flat_quads(ObjectRen *obr) /* render normals are inverted in render! we calculate normal of single tria here */ flen= normal_tri_v3( nor,vlr->v4->co, vlr->v3->co, vlr->v1->co); - if(flen==0.0f) normal_tri_v3( nor,vlr->v4->co, vlr->v2->co, vlr->v1->co); + if (flen==0.0f) normal_tri_v3( nor,vlr->v4->co, vlr->v2->co, vlr->v1->co); xn = dot_v3v3(nor, vlr->n); - if(ABS(xn) < 0.999995f ) { // checked on noisy fractal grid + if (ABS(xn) < 0.999995f ) { // checked on noisy fractal grid float d1, d2; @@ -4254,7 +4260,7 @@ static void check_non_flat_quads(ObjectRen *obr) normal_tri_v3( nor,vlr->v2->co, vlr->v3->co, vlr->v4->co); d2 = dot_v3v3(nor, vlr->v2->n); - if( fabs(d1) < fabs(d2) ) vlr->flag |= R_DIVIDE_24; + if ( fabs(d1) < fabs(d2) ) vlr->flag |= R_DIVIDE_24; else vlr->flag &= ~R_DIVIDE_24; /* new vertex pointers */ @@ -4296,25 +4302,26 @@ static void finalize_render_object(Render *re, ObjectRen *obr, int timeoffset) float min[3], max[3], smin[3], smax[3]; int a, b; - if(obr->totvert || obr->totvlak || obr->tothalo || obr->totstrand) { + if (obr->totvert || obr->totvlak || obr->tothalo || obr->totstrand) { /* the exception below is because displace code now is in init_render_mesh call, I will look at means to have autosmooth enabled for all object types and have it as general postprocess, like displace */ - if(ob->type!=OB_MESH && test_for_displace(re, ob)) + if (ob->type!=OB_MESH && test_for_displace(re, ob)) do_displacement(re, obr, NULL, NULL); - if(!timeoffset) { + if (!timeoffset) { /* phong normal interpolation can cause error in tracing * (terminator problem) */ ob->smoothresh= 0.0; - if((re->r.mode & R_RAYTRACE) && (re->r.mode & R_SHADOW)) + if ((re->r.mode & R_RAYTRACE) && (re->r.mode & R_SHADOW)) set_phong_threshold(obr); if (re->flag & R_BAKING && re->r.bake_quad_split != 0) { /* Baking lets us define a quad split order */ split_quads(obr, re->r.bake_quad_split); - } else { - if((re->r.mode & R_SIMPLIFY && re->r.simplify_flag & R_SIMPLE_NO_TRIANGULATE) == 0) + } + else { + if ((re->r.mode & R_SIMPLIFY && re->r.simplify_flag & R_SIMPLE_NO_TRIANGULATE) == 0) check_non_flat_quads(obr); } @@ -4322,29 +4329,29 @@ static void finalize_render_object(Render *re, ObjectRen *obr, int timeoffset) /* compute bounding boxes for clipping */ INIT_MINMAX(min, max); - for(a=0; a<obr->totvert; a++) { - if((a & 255)==0) ver= obr->vertnodes[a>>8].vert; + for (a=0; a<obr->totvert; a++) { + if ((a & 255)==0) ver= obr->vertnodes[a>>8].vert; else ver++; DO_MINMAX(ver->co, min, max); } - if(obr->strandbuf) { + if (obr->strandbuf) { float width; /* compute average bounding box of strandpoint itself (width) */ - if(obr->strandbuf->flag & R_STRAND_B_UNITS) + if (obr->strandbuf->flag & R_STRAND_B_UNITS) obr->strandbuf->maxwidth= MAX2(obr->strandbuf->ma->strand_sta, obr->strandbuf->ma->strand_end); else obr->strandbuf->maxwidth= 0.0f; width= obr->strandbuf->maxwidth; sbound= obr->strandbuf->bound; - for(b=0; b<obr->strandbuf->totbound; b++, sbound++) { + for (b=0; b<obr->strandbuf->totbound; b++, sbound++) { INIT_MINMAX(smin, smax); - for(a=sbound->start; a<sbound->end; a++) { + for (a=sbound->start; a<sbound->end; a++) { strand= RE_findOrAddStrand(obr, a); strand_minmax(strand, smin, smax, width); } @@ -4384,8 +4391,8 @@ static void find_dupli_instances(Render *re, ObjectRen *obr) /* for objects instanced by dupliverts/faces/particles, we go over the * list of instances to find ones that instance obr, and setup their * matrices and obr pointer */ - for(obi=re->instancetable.last; obi; obi=obi->prev) { - if(!obi->obr && obi->ob == obr->ob && obi->psysindex == obr->psysindex) { + for (obi=re->instancetable.last; obi; obi=obi->prev) { + if (!obi->obr && obi->ob == obr->ob && obi->psysindex == obr->psysindex) { obi->obr= obr; /* compute difference between object matrix and @@ -4397,7 +4404,7 @@ static void find_dupli_instances(Render *re, ObjectRen *obr) invert_m3_m3(obi->nmat, nmat); transpose_m3(obi->nmat); - if(!first) { + if (!first) { re->totvert += obr->totvert; re->totvlak += obr->totvlak; re->tothalo += obr->tothalo; @@ -4439,13 +4446,13 @@ static ObjectRen *find_dupligroup_dupli(Render *re, Object *ob, int psysindex) /* if the object is itself instanced, we don't want to create an instance * for it */ - if(ob->transflag & OB_RENDER_DUPLI) + if (ob->transflag & OB_RENDER_DUPLI) return NULL; /* try to find an object that was already created so we can reuse it * and save memory */ - for(obr=re->objecttable.first; obr; obr=obr->next) - if(obr->ob == ob && obr->psysindex == psysindex && (obr->flag & R_INSTANCEABLE)) + for (obr=re->objecttable.first; obr; obr=obr->next) + if (obr->ob == ob && obr->psysindex == psysindex && (obr->flag & R_INSTANCEABLE)) return obr; return NULL; @@ -4461,14 +4468,14 @@ static void set_dupli_tex_mat(Render *re, ObjectInstanceRen *obi, DupliObject *d static int needtexmat= 0; /* init */ - if(!re) { + if (!re) { lastob= NULL; needtexmat= 0; return; } /* check if we actually need it */ - if(lastob != dob->ob) { + if (lastob != dob->ob) { Material ***material; short a, *totmaterial; @@ -4478,13 +4485,13 @@ static void set_dupli_tex_mat(Render *re, ObjectInstanceRen *obi, DupliObject *d totmaterial= give_totcolp(dob->ob); material= give_matarar(dob->ob); - if(totmaterial && material) - for(a= 0; a<*totmaterial; a++) - if((*material)[a] && (*material)[a]->texco & TEXCO_OBJECT) + if (totmaterial && material) + for (a= 0; a<*totmaterial; a++) + if ((*material)[a] && (*material)[a]->texco & TEXCO_OBJECT) needtexmat= 1; } - if(needtexmat) { + if (needtexmat) { float imat[4][4]; obi->duplitexmat= BLI_memarena_alloc(re->memArena, sizeof(float)*4*4); @@ -4499,8 +4506,8 @@ static void init_render_object_data(Render *re, ObjectRen *obr, int timeoffset) ParticleSystem *psys; int i; - if(obr->psysindex) { - if((!obr->prev || obr->prev->ob != ob || (obr->prev->flag & R_INSTANCEABLE)==0) && ob->type==OB_MESH) { + if (obr->psysindex) { + if ((!obr->prev || obr->prev->ob != ob || (obr->prev->flag & R_INSTANCEABLE)==0) && ob->type==OB_MESH) { /* the emitter mesh wasn't rendered so the modifier stack wasn't * evaluated with render settings */ DerivedMesh *dm; @@ -4508,7 +4515,7 @@ static void init_render_object_data(Render *re, ObjectRen *obr, int timeoffset) dm->release(dm); } - for(psys=ob->particlesystem.first, i=0; i<obr->psysindex-1; i++) + for (psys=ob->particlesystem.first, i=0; i<obr->psysindex-1; i++) psys= psys->next; render_new_particle_system(re, obr, psys, timeoffset); @@ -4516,11 +4523,11 @@ static void init_render_object_data(Render *re, ObjectRen *obr, int timeoffset) else { if ELEM(ob->type, OB_FONT, OB_CURVE) init_render_curve(re, obr, timeoffset); - else if(ob->type==OB_SURF) + else if (ob->type==OB_SURF) init_render_surf(re, obr, timeoffset); - else if(ob->type==OB_MESH) + else if (ob->type==OB_MESH) init_render_mesh(re, obr, timeoffset); - else if(ob->type==OB_MBALL) + else if (ob->type==OB_MBALL) init_render_mball(re, obr); } @@ -4543,31 +4550,31 @@ static void add_render_object(Render *re, Object *ob, Object *par, DupliObject * /* the emitter has to be processed first (render levels of modifiers) */ /* so here we only check if the emitter should be rendered */ - if(ob->particlesystem.first) { + if (ob->particlesystem.first) { show_emitter= 0; - for(psys=ob->particlesystem.first; psys; psys=psys->next) { + for (psys=ob->particlesystem.first; psys; psys=psys->next) { show_emitter += psys->part->draw & PART_DRAW_EMITTER; psys_render_set(ob, psys, re->viewmat, re->winmat, re->winx, re->winy, timeoffset); } /* if no psys has "show emitter" selected don't render emitter */ - if(show_emitter == 0) + if (show_emitter == 0) allow_render= 0; } /* one render object for the data itself */ - if(allow_render) { + if (allow_render) { obr= RE_addRenderObject(re, ob, par, index, 0, ob->lay); - if((dob && !dob->animated) || (ob->transflag & OB_RENDER_DUPLI)) { + if ((dob && !dob->animated) || (ob->transflag & OB_RENDER_DUPLI)) { obr->flag |= R_INSTANCEABLE; copy_m4_m4(obr->obmat, ob->obmat); } init_render_object_data(re, obr, timeoffset); /* only add instance for objects that have not been used for dupli */ - if(!(ob->transflag & OB_RENDER_DUPLI)) { + if (!(ob->transflag & OB_RENDER_DUPLI)) { obi= RE_addRenderInstance(re, obr, ob, par, index, 0, NULL, ob->lay); - if(dob) set_dupli_tex_mat(re, obi, dob); + if (dob) set_dupli_tex_mat(re, obi, dob); } else find_dupli_instances(re, obr); @@ -4580,24 +4587,24 @@ static void add_render_object(Render *re, Object *ob, Object *par, DupliObject * } /* and one render object per particle system */ - if(ob->particlesystem.first) { + if (ob->particlesystem.first) { psysindex= 1; - for(psys=ob->particlesystem.first; psys; psys=psys->next, psysindex++) { + for (psys=ob->particlesystem.first; psys; psys=psys->next, psysindex++) { obr= RE_addRenderObject(re, ob, par, index, psysindex, ob->lay); - if((dob && !dob->animated) || (ob->transflag & OB_RENDER_DUPLI)) { + if ((dob && !dob->animated) || (ob->transflag & OB_RENDER_DUPLI)) { obr->flag |= R_INSTANCEABLE; copy_m4_m4(obr->obmat, ob->obmat); } - if(dob) + if (dob) psys->flag |= PSYS_USE_IMAT; init_render_object_data(re, obr, timeoffset); psys_render_restore(ob, psys); psys->flag &= ~PSYS_USE_IMAT; /* only add instance for objects that have not been used for dupli */ - if(!(ob->transflag & OB_RENDER_DUPLI)) { + if (!(ob->transflag & OB_RENDER_DUPLI)) { obi= RE_addRenderInstance(re, obr, ob, par, index, psysindex, NULL, ob->lay); - if(dob) set_dupli_tex_mat(re, obi, dob); + if (dob) set_dupli_tex_mat(re, obi, dob); } else find_dupli_instances(re, obr); @@ -4613,9 +4620,9 @@ static void init_render_object(Render *re, Object *ob, Object *par, DupliObject double time; float mat[4][4]; - if(ob->type==OB_LAMP) + if (ob->type==OB_LAMP) add_render_lamp(re, ob); - else if(render_object_type(ob->type)) + else if (render_object_type(ob->type)) add_render_object(re, ob, par, dob, timeoffset); else { mult_m4_m4m4(mat, re->viewmat, ob->obmat); @@ -4623,7 +4630,7 @@ static void init_render_object(Render *re, Object *ob, Object *par, DupliObject } time= PIL_check_seconds_timer(); - if(time - lasttime > 1.0) { + if (time - lasttime > 1.0) { lasttime= time; /* clumsy copying still */ re->i.totvert= re->totvert; @@ -4642,8 +4649,8 @@ void RE_Database_Free(Render *re) LampRen *lar; /* statistics for debugging render memory usage */ - if((G.f & G_DEBUG) && (G.rendering)) { - if((re->r.scemode & R_PREVIEWBUTS)==0) { + if ((G.f & G_DEBUG) && (G.rendering)) { + if ((re->r.scemode & R_PREVIEWBUTS)==0) { BKE_image_print_memlist(); MEM_printmemlist_stats(); } @@ -4651,11 +4658,11 @@ void RE_Database_Free(Render *re) /* FREE */ - for(lar= re->lampren.first; lar; lar= lar->next) { + for (lar= re->lampren.first; lar; lar= lar->next) { freeshadowbuf(lar); - if(lar->jitter) MEM_freeN(lar->jitter); - if(lar->shadsamp) MEM_freeN(lar->shadsamp); - if(lar->sunsky) MEM_freeN(lar->sunsky); + if (lar->jitter) MEM_freeN(lar->jitter); + if (lar->shadsamp) MEM_freeN(lar->shadsamp); + if (lar->sunsky) MEM_freeN(lar->sunsky); curvemapping_free(lar->curfalloff); } @@ -4678,20 +4685,20 @@ void RE_Database_Free(Render *re) free_camera_inside_volumes(re); - if(re->wrld.aosphere) { + if (re->wrld.aosphere) { MEM_freeN(re->wrld.aosphere); re->wrld.aosphere= NULL; re->scene->world->aosphere= NULL; } - if(re->wrld.aotables) { + if (re->wrld.aotables) { MEM_freeN(re->wrld.aotables); re->wrld.aotables= NULL; re->scene->world->aotables= NULL; } - if(re->r.mode & R_RAYTRACE) + if (re->r.mode & R_RAYTRACE) free_render_qmcsampler(re); - if(re->r.mode & R_RAYTRACE) freeraytree(re); + if (re->r.mode & R_RAYTRACE) freeraytree(re); free_sss(re); free_occ(re); @@ -4702,12 +4709,12 @@ void RE_Database_Free(Render *re) re->bakebuf= NULL; - if(re->scene) - if(re->scene->r.scemode & R_FREE_IMAGE) - if((re->r.scemode & R_PREVIEWBUTS)==0) + if (re->scene) + if (re->scene->r.scemode & R_FREE_IMAGE) + if ((re->r.scemode & R_PREVIEWBUTS)==0) BKE_image_free_all_textures(); - if(re->memArena) { + if (re->memArena) { BLI_memarena_free(re->memArena); re->memArena = NULL; } @@ -4716,19 +4723,19 @@ void RE_Database_Free(Render *re) static int allow_render_object(Render *re, Object *ob, int nolamps, int onlyselected, Object *actob) { /* override not showing object when duplis are used with particles */ - if(ob->transflag & OB_DUPLIPARTS) + if (ob->transflag & OB_DUPLIPARTS) ; /* let particle system(s) handle showing vs. not showing */ - else if((ob->transflag & OB_DUPLI) && !(ob->transflag & OB_DUPLIFRAMES)) + else if ((ob->transflag & OB_DUPLI) && !(ob->transflag & OB_DUPLIFRAMES)) return 0; /* don't add non-basic meta objects, ends up having renderobjects with no geometry */ if (ob->type == OB_MBALL && ob!=find_basis_mball(re->scene, ob)) return 0; - if(nolamps && (ob->type==OB_LAMP)) + if (nolamps && (ob->type==OB_LAMP)) return 0; - if(onlyselected && (ob!=actob && !(ob->flag & SELECT))) + if (onlyselected && (ob!=actob && !(ob->flag & SELECT))) return 0; return 1; @@ -4744,16 +4751,16 @@ static int allow_render_dupli_instance(Render *UNUSED(re), DupliObject *dob, Obj * all halo's to sort them globally in advance */ totmaterial= give_totcolp(obd); - if(totmaterial) { - for(a= 0; a<*totmaterial; a++) { + if (totmaterial) { + for (a= 0; a<*totmaterial; a++) { ma= give_current_material(obd, a); - if(ma && (ma->material_type == MA_TYPE_HALO)) + if (ma && (ma->material_type == MA_TYPE_HALO)) return 0; } } - for(psys=obd->particlesystem.first; psys; psys=psys->next) - if(!ELEM5(psys->part->ren_as, PART_DRAW_BB, PART_DRAW_LINE, PART_DRAW_PATH, PART_DRAW_OB, PART_DRAW_GR)) + for (psys=obd->particlesystem.first; psys; psys=psys->next) + if (!ELEM5(psys->part->ren_as, PART_DRAW_BB, PART_DRAW_LINE, PART_DRAW_PATH, PART_DRAW_OB, PART_DRAW_GR)) return 0; /* don't allow lamp, animated duplis, or radio render */ @@ -4770,35 +4777,35 @@ static void dupli_render_particle_set(Render *re, Object *ob, int timeoffset, in ParticleSystem *psys; DerivedMesh *dm; - if(level >= MAX_DUPLI_RECUR) + if (level >= MAX_DUPLI_RECUR) return; - if(ob->transflag & OB_DUPLIPARTS) { - for(psys=ob->particlesystem.first; psys; psys=psys->next) { - if(ELEM(psys->part->ren_as, PART_DRAW_OB, PART_DRAW_GR)) { - if(enable) + if (ob->transflag & OB_DUPLIPARTS) { + for (psys=ob->particlesystem.first; psys; psys=psys->next) { + if (ELEM(psys->part->ren_as, PART_DRAW_OB, PART_DRAW_GR)) { + if (enable) psys_render_set(ob, psys, re->viewmat, re->winmat, re->winx, re->winy, timeoffset); else psys_render_restore(ob, psys); } } - if(enable) { + if (enable) { /* this is to make sure we get render level duplis in groups: * the derivedmesh must be created before init_render_mesh, * since object_duplilist does dupliparticles before that */ dm = mesh_create_derived_render(re->scene, ob, CD_MASK_BAREMESH|CD_MASK_MTFACE|CD_MASK_MCOL); dm->release(dm); - for(psys=ob->particlesystem.first; psys; psys=psys->next) + for (psys=ob->particlesystem.first; psys; psys=psys->next) psys_get_modifier(ob, psys)->flag &= ~eParticleSystemFlag_psys_updated; } } - if(ob->dup_group==NULL) return; + if (ob->dup_group==NULL) return; group= ob->dup_group; - for(go= group->gobject.first; go; go= go->next) + for (go= group->gobject.first; go; go= go->next) dupli_render_particle_set(re, go->ob, timeoffset, level+1, enable); } @@ -4807,8 +4814,8 @@ static int get_vector_renderlayers(Scene *sce) SceneRenderLayer *srl; unsigned int lay= 0; - for(srl= sce->r.layers.first; srl; srl= srl->next) - if(srl->passflag & SCE_PASS_VECTOR) + for (srl= sce->r.layers.first; srl; srl= srl->next) + if (srl->passflag & SCE_PASS_VECTOR) lay |= srl->lay; return lay; @@ -4820,20 +4827,20 @@ static void add_group_render_dupli_obs(Render *re, Group *group, int nolamps, in Object *ob; /* simple preventing of too deep nested groups */ - if(level>MAX_DUPLI_RECUR) return; + if (level>MAX_DUPLI_RECUR) return; /* recursively go into dupligroups to find objects with OB_RENDER_DUPLI * that were not created yet */ - for(go= group->gobject.first; go; go= go->next) { + for (go= group->gobject.first; go; go= go->next) { ob= go->ob; - if(ob->flag & OB_DONE) { - if(ob->transflag & OB_RENDER_DUPLI) { - if(allow_render_object(re, ob, nolamps, onlyselected, actob)) { + if (ob->flag & OB_DONE) { + if (ob->transflag & OB_RENDER_DUPLI) { + if (allow_render_object(re, ob, nolamps, onlyselected, actob)) { init_render_object(re, ob, NULL, 0, timeoffset); ob->transflag &= ~OB_RENDER_DUPLI; - if(ob->dup_group) + if (ob->dup_group) add_group_render_dupli_obs(re, ob->dup_group, nolamps, onlyselected, actob, timeoffset, level+1); } } @@ -4862,7 +4869,7 @@ static void database_init_objects(Render *re, unsigned int renderlay, int nolamp * mtex's for mapto objects but its easier just to set the * 'imat' / 'imat_ren' on all and unlikely to be a performance hit * See bug: [#28744] - campbell */ - for(ob= re->main->object.first; ob; ob= ob->id.next) { + for (ob= re->main->object.first; ob; ob= ob->id.next) { /* imat objects has to be done here, since displace can have texture using Object map-input */ mult_m4_m4m4(mat, re->viewmat, ob->obmat); invert_m4_m4(ob->imat_ren, mat); @@ -4872,7 +4879,7 @@ static void database_init_objects(Render *re, unsigned int renderlay, int nolamp ob->transflag &= ~OB_RENDER_DUPLI; } - for(SETLOOPER(re->scene, sce_iter, base)) { + for (SETLOOPER(re->scene, sce_iter, base)) { ob= base->object; /* in the prev/next pass for making speed vectors, avoid creating @@ -4882,21 +4889,21 @@ static void database_init_objects(Render *re, unsigned int renderlay, int nolamp lay= (timeoffset)? renderlay & vectorlay: renderlay; /* if the object has been restricted from rendering in the outliner, ignore it */ - if(ob->restrictflag & OB_RESTRICT_RENDER) continue; + if (ob->restrictflag & OB_RESTRICT_RENDER) continue; /* OB_DONE means the object itself got duplicated, so was already converted */ - if(ob->flag & OB_DONE) { + if (ob->flag & OB_DONE) { /* OB_RENDER_DUPLI means instances for it were already created, now * it still needs to create the ObjectRen containing the data */ - if(ob->transflag & OB_RENDER_DUPLI) { - if(allow_render_object(re, ob, nolamps, onlyselected, actob)) { + if (ob->transflag & OB_RENDER_DUPLI) { + if (allow_render_object(re, ob, nolamps, onlyselected, actob)) { init_render_object(re, ob, NULL, 0, timeoffset); ob->transflag &= ~OB_RENDER_DUPLI; } } } - else if((base->lay & lay) || (ob->type==OB_LAMP && (base->lay & re->lay)) ) { - if((ob->transflag & OB_DUPLI) && (ob->type!=OB_MBALL)) { + else if ((base->lay & lay) || (ob->type==OB_LAMP && (base->lay & re->lay)) ) { + if ((ob->transflag & OB_DUPLI) && (ob->type!=OB_MBALL)) { DupliObject *dob; ListBase *lb; @@ -4906,25 +4913,25 @@ static void database_init_objects(Render *re, unsigned int renderlay, int nolamp lb= object_duplilist(re->scene, ob); dupli_render_particle_set(re, ob, timeoffset, 0, 0); - for(dob= lb->first; dob; dob= dob->next) { + for (dob= lb->first; dob; dob= dob->next) { Object *obd= dob->ob; copy_m4_m4(obd->obmat, dob->mat); /* group duplis need to set ob matrices correct, for deform. so no_draw is part handled */ - if(!(obd->transflag & OB_RENDER_DUPLI) && dob->no_draw) + if (!(obd->transflag & OB_RENDER_DUPLI) && dob->no_draw) continue; - if(obd->restrictflag & OB_RESTRICT_RENDER) + if (obd->restrictflag & OB_RESTRICT_RENDER) continue; - if(obd->type==OB_MBALL) + if (obd->type==OB_MBALL) continue; - if(!allow_render_object(re, obd, nolamps, onlyselected, actob)) + if (!allow_render_object(re, obd, nolamps, onlyselected, actob)) continue; - if(allow_render_dupli_instance(re, dob, obd)) { + if (allow_render_dupli_instance(re, dob, obd)) { ParticleSystem *psys; ObjectRen *obr = NULL; int psysindex; @@ -4935,13 +4942,13 @@ static void database_init_objects(Render *re, unsigned int renderlay, int nolamp /* instances instead of the actual object are added in two cases, either * this is a duplivert/face/particle, or it is a non-animated object in * a dupligroup that has already been created before */ - if(dob->type != OB_DUPLIGROUP || (obr=find_dupligroup_dupli(re, obd, 0))) { + if (dob->type != OB_DUPLIGROUP || (obr=find_dupligroup_dupli(re, obd, 0))) { mult_m4_m4m4(mat, re->viewmat, dob->mat); obi= RE_addRenderInstance(re, NULL, obd, ob, dob->index, 0, mat, obd->lay); /* fill in instance variables for texturing */ set_dupli_tex_mat(re, obi, dob); - if(dob->type != OB_DUPLIGROUP) { + if (dob->type != OB_DUPLIGROUP) { copy_v3_v3(obi->dupliorco, dob->orco); obi->dupliuv[0]= dob->uv[0]; obi->dupliuv[1]= dob->uv[1]; @@ -4952,7 +4959,7 @@ static void database_init_objects(Render *re, unsigned int renderlay, int nolamp * itself was duplicated. for the first case find_dupli_instances * will be called later. */ assign_dupligroup_dupli(re, obi, obr); - if(obd->transflag & OB_RENDER_DUPLI) + if (obd->transflag & OB_RENDER_DUPLI) find_dupli_instances(re, obr); } } @@ -4960,31 +4967,31 @@ static void database_init_objects(Render *re, unsigned int renderlay, int nolamp /* same logic for particles, each particle system has it's own object, so * need to go over them separately */ psysindex= 1; - for(psys=obd->particlesystem.first; psys; psys=psys->next) { - if(dob->type != OB_DUPLIGROUP || (obr=find_dupligroup_dupli(re, obd, psysindex))) { - if(obi == NULL) + for (psys=obd->particlesystem.first; psys; psys=psys->next) { + if (dob->type != OB_DUPLIGROUP || (obr=find_dupligroup_dupli(re, obd, psysindex))) { + if (obi == NULL) mult_m4_m4m4(mat, re->viewmat, dob->mat); obi= RE_addRenderInstance(re, NULL, obd, ob, dob->index, psysindex++, mat, obd->lay); set_dupli_tex_mat(re, obi, dob); - if(dob->type != OB_DUPLIGROUP) { + if (dob->type != OB_DUPLIGROUP) { copy_v3_v3(obi->dupliorco, dob->orco); obi->dupliuv[0]= dob->uv[0]; obi->dupliuv[1]= dob->uv[1]; } else { assign_dupligroup_dupli(re, obi, obr); - if(obd->transflag & OB_RENDER_DUPLI) + if (obd->transflag & OB_RENDER_DUPLI) find_dupli_instances(re, obr); } } } - if(obi==NULL) + if (obi==NULL) /* can't instance, just create the object */ init_render_object(re, obd, ob, dob, timeoffset); - if(dob->type != OB_DUPLIGROUP) { + if (dob->type != OB_DUPLIGROUP) { obd->flag |= OB_DONE; obd->transflag |= OB_RENDER_DUPLI; } @@ -4992,26 +4999,26 @@ static void database_init_objects(Render *re, unsigned int renderlay, int nolamp else init_render_object(re, obd, ob, dob, timeoffset); - if(re->test_break(re->tbh)) break; + if (re->test_break(re->tbh)) break; } free_object_duplilist(lb); - if(allow_render_object(re, ob, nolamps, onlyselected, actob)) + if (allow_render_object(re, ob, nolamps, onlyselected, actob)) init_render_object(re, ob, NULL, 0, timeoffset); } - else if(allow_render_object(re, ob, nolamps, onlyselected, actob)) + else if (allow_render_object(re, ob, nolamps, onlyselected, actob)) init_render_object(re, ob, NULL, 0, timeoffset); } - if(re->test_break(re->tbh)) break; + if (re->test_break(re->tbh)) break; } /* objects in groups with OB_RENDER_DUPLI set still need to be created, * since they may not be part of the scene */ - for(group= re->main->group.first; group; group=group->id.next) + for (group= re->main->group.first; group; group=group->id.next) add_group_render_dupli_obs(re, group, nolamps, onlyselected, actob, timeoffset, 0); - if(!re->test_break(re->tbh)) + if (!re->test_break(re->tbh)) RE_makeRenderInstances(re); } @@ -5043,15 +5050,15 @@ void RE_Database_FromScene(Render *re, Main *bmain, Scene *scene, unsigned int l re->i.partsdone= 0; /* signal now in use for previewrender */ /* in localview, lamps are using normal layers, objects only local bits */ - if(re->lay & 0xFF000000) + if (re->lay & 0xFF000000) lay &= 0xFF000000; /* applies changes fully */ - if((re->r.scemode & (R_NO_FRAME_UPDATE|R_PREVIEWBUTS))==0) + if ((re->r.scemode & (R_NO_FRAME_UPDATE|R_PREVIEWBUTS))==0) scene_update_for_newframe(re->main, re->scene, lay); /* if no camera, viewmat should have been set! */ - if(use_camera_view && camera) { + if (use_camera_view && camera) { /* called before but need to call again in case of lens animation from the * above call to scene_update_for_newframe, fixes bug. [#22702]. * following calls don't depend on 'RE_SetCamera' */ @@ -5064,10 +5071,10 @@ void RE_Database_FromScene(Render *re, Main *bmain, Scene *scene, unsigned int l } init_render_world(re); /* do first, because of ambient. also requires re->osa set correct */ - if(re->r.mode & R_RAYTRACE) { + if (re->r.mode & R_RAYTRACE) { init_render_qmcsampler(re); - if(re->wrld.mode & (WO_AMB_OCC|WO_ENV_LIGHT|WO_INDIRECT_LIGHT)) + if (re->wrld.mode & (WO_AMB_OCC|WO_ENV_LIGHT|WO_INDIRECT_LIGHT)) if (re->wrld.ao_samp_method == WO_AOSAMP_CONSTANT) init_ao_sphere(&re->wrld); } @@ -5081,11 +5088,11 @@ void RE_Database_FromScene(Render *re, Main *bmain, Scene *scene, unsigned int l /* MAKE RENDER DATA */ database_init_objects(re, lay, 0, 0, 0, 0); - if(!re->test_break(re->tbh)) { + if (!re->test_break(re->tbh)) { int tothalo; set_material_lightgroups(re); - for(sce= re->scene; sce; sce= sce->set) + for (sce= re->scene; sce; sce= sce->set) set_renderlayer_lightgroups(re, sce); slurph_opt= 1; @@ -5100,8 +5107,8 @@ void RE_Database_FromScene(Render *re, Main *bmain, Scene *scene, unsigned int l /* don't sort stars */ tothalo= re->tothalo; - if(!re->test_break(re->tbh)) { - if(re->wrld.mode & WO_STARS) { + if (!re->test_break(re->tbh)) { + if (re->wrld.mode & WO_STARS) { re->i.infostr= "Creating Starfield"; re->stats_draw(re->sdh, &re->i); RE_make_stars(re, NULL, NULL, NULL, NULL); @@ -5120,43 +5127,43 @@ void RE_Database_FromScene(Render *re, Main *bmain, Scene *scene, unsigned int l /* old code checked for internal render (aka not yafray) */ { /* raytree */ - if(!re->test_break(re->tbh)) { - if(re->r.mode & R_RAYTRACE) { + if (!re->test_break(re->tbh)) { + if (re->r.mode & R_RAYTRACE) { makeraytree(re); } } /* ENVIRONMENT MAPS */ - if(!re->test_break(re->tbh)) + if (!re->test_break(re->tbh)) make_envmaps(re); /* point density texture */ - if(!re->test_break(re->tbh)) + if (!re->test_break(re->tbh)) make_pointdensities(re); /* voxel data texture */ - if(!re->test_break(re->tbh)) + if (!re->test_break(re->tbh)) make_voxeldata(re); } - if(!re->test_break(re->tbh)) + if (!re->test_break(re->tbh)) project_renderdata(re, projectverto, re->r.mode & R_PANORAMA, 0, 1); /* Occlusion */ - if((re->wrld.mode & (WO_AMB_OCC|WO_ENV_LIGHT|WO_INDIRECT_LIGHT)) && !re->test_break(re->tbh)) - if(re->wrld.ao_gather_method == WO_AOGATHER_APPROX) - if(re->r.mode & R_SHADOW) + if ((re->wrld.mode & (WO_AMB_OCC|WO_ENV_LIGHT|WO_INDIRECT_LIGHT)) && !re->test_break(re->tbh)) + if (re->wrld.ao_gather_method == WO_AOGATHER_APPROX) + if (re->r.mode & R_SHADOW) make_occ_tree(re); /* SSS */ - if((re->r.mode & R_SSS) && !re->test_break(re->tbh)) + if ((re->r.mode & R_SSS) && !re->test_break(re->tbh)) make_sss_tree(re); - if(!re->test_break(re->tbh)) - if(re->r.mode & R_RAYTRACE) + if (!re->test_break(re->tbh)) + if (re->r.mode & R_RAYTRACE) volume_precache(re); } - if(re->test_break(re->tbh)) + if (re->test_break(re->tbh)) RE_Database_Free(re); else re->i.convertdone= 1; @@ -5198,7 +5205,7 @@ static void database_fromscene_vectors(Render *re, Scene *scene, unsigned int la slurph_opt= 0; /* in localview, lamps are using normal layers, objects only local bits */ - if(re->lay & 0xFF000000) + if (re->lay & 0xFF000000) lay &= 0xFF000000; /* applies changes fully */ @@ -5206,7 +5213,7 @@ static void database_fromscene_vectors(Render *re, Scene *scene, unsigned int la scene_update_for_newframe(re->main, re->scene, lay); /* if no camera, viewmat should have been set! */ - if(camera) { + if (camera) { normalize_m4(camera->obmat); invert_m4_m4(mat, camera->obmat); RE_SetView(re, mat); @@ -5215,7 +5222,7 @@ static void database_fromscene_vectors(Render *re, Scene *scene, unsigned int la /* MAKE RENDER DATA */ database_init_objects(re, lay, 0, 0, 0, timeoffset); - if(!re->test_break(re->tbh)) + if (!re->test_break(re->tbh)) project_renderdata(re, projectverto, re->r.mode & R_PANORAMA, 0, 1); /* do this in end, particles for example need cfra */ @@ -5230,11 +5237,11 @@ static void speedvector_project(Render *re, float zco[2], const float co[3], con float div; /* initialize */ - if(re) { + if (re) { pano= re->r.mode & R_PANORAMA; /* precalculate amount of radians 1 pixel rotates */ - if(pano) { + if (pano) { /* size of 1 pixel mapped to viewplane coords */ float psize= (re->viewplane.xmax-re->viewplane.xmin)/(float)re->winx; /* x angle of a pixel */ @@ -5251,17 +5258,17 @@ static void speedvector_project(Render *re, float zco[2], const float co[3], con } /* now map hocos to screenspace, uses very primitive clip still */ - if(ho[3]<0.1f) div= 10.0f; + if (ho[3]<0.1f) div= 10.0f; else div= 1.0f/ho[3]; /* use cylinder projection */ - if(pano) { + if (pano) { float vec[3], ang; /* angle between (0,0,-1) and (co) */ copy_v3_v3(vec, co); ang= saacos(-vec[2]/sqrtf(vec[0]*vec[0] + vec[2]*vec[2])); - if(vec[0]<0.0f) ang= -ang; + if (vec[0]<0.0f) ang= -ang; zco[0]= ang/pixelphix + zmulx; ang= 0.5f*(float)M_PI - saacos(vec[1] / len_v3(vec)); @@ -5284,21 +5291,21 @@ static void calculate_speedvector(const float vectors[2], int step, float winsq, zco[1]= vectors[1] - zco[1]; /* enable nice masks for hardly moving stuff or float inaccuracy */ - if(zco[0]<0.1f && zco[0]>-0.1f && zco[1]<0.1f && zco[1]>-0.1f ) { + if (zco[0]<0.1f && zco[0]>-0.1f && zco[1]<0.1f && zco[1]>-0.1f ) { zco[0]= 0.0f; zco[1]= 0.0f; } /* maximize speed for image width, otherwise it never looks good */ len= zco[0]*zco[0] + zco[1]*zco[1]; - if(len > winsq) { + if (len > winsq) { len= winroot/sqrtf(len); zco[0]*= len; zco[1]*= len; } /* note; in main vecblur loop speedvec is negated again */ - if(step) { + if (step) { speed[2]= -zco[0]; speed[3]= -zco[1]; } @@ -5310,21 +5317,21 @@ static void calculate_speedvector(const float vectors[2], int step, float winsq, static float *calculate_strandsurface_speedvectors(Render *re, ObjectInstanceRen *obi, StrandSurface *mesh) { - if(mesh->co && mesh->prevco && mesh->nextco) { + if (mesh->co && mesh->prevco && mesh->nextco) { float winsq= (float)re->winx*(float)re->winy; /* int's can wrap on large images */ float winroot= sqrt(winsq); float (*winspeed)[4]; float ho[4], prevho[4], nextho[4], winmat[4][4], vec[2]; int a; - if(obi->flag & R_TRANSFORMED) + if (obi->flag & R_TRANSFORMED) mult_m4_m4m4(winmat, re->winmat, obi->mat); else copy_m4_m4(winmat, re->winmat); winspeed= MEM_callocN(sizeof(float)*4*mesh->totvert, "StrandSurfWin"); - for(a=0; a<mesh->totvert; a++) { + for (a=0; a<mesh->totvert; a++) { projectvert(mesh->co[a], winmat, ho); projectvert(mesh->prevco[a], winmat, prevho); @@ -5354,14 +5361,14 @@ static void calculate_speedvectors(Render *re, ObjectInstanceRen *obi, float *ve float winsq= (float)re->winx*(float)re->winy, winroot= sqrt(winsq); /* int's can wrap on large images */ int a, *face, *index; - if(obi->flag & R_TRANSFORMED) + if (obi->flag & R_TRANSFORMED) mult_m4_m4m4(winmat, re->winmat, obi->mat); else copy_m4_m4(winmat, re->winmat); - if(obr->vertnodes) { - for(a=0; a<obr->totvert; a++, vectors+=2) { - if((a & 255)==0) ver= obr->vertnodes[a>>8].vert; + if (obr->vertnodes) { + for (a=0; a<obr->totvert; a++, vectors+=2) { + if ((a & 255)==0) ver= obr->vertnodes[a>>8].vert; else ver++; speed= RE_vertren_get_winspeed(obi, ver, 1); @@ -5370,21 +5377,21 @@ static void calculate_speedvectors(Render *re, ObjectInstanceRen *obi, float *ve } } - if(obr->strandnodes) { + if (obr->strandnodes) { strandbuf= obr->strandbuf; mesh= (strandbuf)? strandbuf->surface: NULL; /* compute speed vectors at surface vertices */ - if(mesh) + if (mesh) winspeed= (float(*)[4])calculate_strandsurface_speedvectors(re, obi, mesh); - if(winspeed) { - for(a=0; a<obr->totstrand; a++, vectors+=2) { - if((a & 255)==0) strand= obr->strandnodes[a>>8].strand; + if (winspeed) { + for (a=0; a<obr->totstrand; a++, vectors+=2) { + if ((a & 255)==0) strand= obr->strandnodes[a>>8].strand; else strand++; index= RE_strandren_get_face(obr, strand, 0); - if(index && *index < mesh->totface) { + if (index && *index < mesh->totface) { speed= RE_strandren_get_winspeed(obi, strand, 1); /* interpolate speed vectors from strand surface */ @@ -5401,7 +5408,7 @@ static void calculate_speedvectors(Render *re, ObjectInstanceRen *obi, float *ve madd_v4_v4fl(speed, winspeed[face[0]], w[0]); madd_v4_v4fl(speed, winspeed[face[1]], w[1]); madd_v4_v4fl(speed, winspeed[face[2]], w[2]); - if(face[3]) + if (face[3]) madd_v4_v4fl(speed, winspeed[face[3]], w[3]); } } @@ -5428,9 +5435,9 @@ static int load_fluidsimspeedvectors(Render *re, ObjectInstanceRen *obi, float * FluidVertexVelocity *velarray = NULL; /* only one step needed */ - if(step) return 1; + if (step) return 1; - if(fluidmd) + if (fluidmd) fss = fluidmd->fss; else return 0; @@ -5439,16 +5446,16 @@ static int load_fluidsimspeedvectors(Render *re, ObjectInstanceRen *obi, float * invert_m4_m4(imat, mat); /* set first vertex OK */ - if(!fss->meshVelocities) return 0; + if (!fss->meshVelocities) return 0; - if( obr->totvert != fss->totvert) { + if ( obr->totvert != fss->totvert) { //fprintf(stderr, "load_fluidsimspeedvectors - modified fluidsim mesh, not using speed vectors (%d,%d)...\n", obr->totvert, fsob->fluidsimSettings->meshSurface->totvert); // DEBUG return 0; } velarray = fss->meshVelocities; - if(obi->flag & R_TRANSFORMED) + if (obi->flag & R_TRANSFORMED) mult_m4_m4m4(winmat, re->winmat, obi->mat); else copy_m4_m4(winmat, re->winmat); @@ -5457,15 +5464,15 @@ static int load_fluidsimspeedvectors(Render *re, ObjectInstanceRen *obi, float * /* better solution would be fixing getVelocityAt() in intern/elbeem/intern/solver_util.cpp so that also small drops/little water volumes return a velocity != 0. But I had no luck in fixing that function - DG */ - for(a=0; a<obr->totvert; a++) { - for(j=0;j<3;j++) avgvel[j] += velarray[a].vel[j]; + for (a=0; a<obr->totvert; a++) { + for (j=0;j<3;j++) avgvel[j] += velarray[a].vel[j]; } - for(j=0;j<3;j++) avgvel[j] /= (float)(obr->totvert); + for (j=0;j<3;j++) avgvel[j] /= (float)(obr->totvert); - for(a=0; a<obr->totvert; a++, vectors+=2) { - if((a & 255)==0) + for (a=0; a<obr->totvert; a++, vectors+=2) { + if ((a & 255)==0) ver= obr->vertnodes[a>>8].vert; else ver++; @@ -5473,7 +5480,7 @@ static int load_fluidsimspeedvectors(Render *re, ObjectInstanceRen *obi, float * // get fluid velocity fsvec[3] = 0.; //fsvec[0] = fsvec[1] = fsvec[2] = fsvec[3] = 0.; fsvec[2] = 2.; // NT fixed test - for(j=0;j<3;j++) fsvec[j] = velarray[a].vel[j]; + for (j=0;j<3;j++) fsvec[j] = velarray[a].vel[j]; /* (bad) HACK insert average velocity if none is there (see previous comment) */ if ((fsvec[0] == 0.0f) && (fsvec[1] == 0.0f) && (fsvec[2] == 0.0f)) { @@ -5493,14 +5500,14 @@ static int load_fluidsimspeedvectors(Render *re, ObjectInstanceRen *obi, float * /* now map hocos to screenspace, uses very primitive clip still */ // use ho[3] of original vertex, xy component of vel. direction - if(ho[3]<0.1f) div= 10.0f; + if (ho[3]<0.1f) div= 10.0f; else div= 1.0f/ho[3]; zco[0]= zmulx*hoco[0]*div; zco[1]= zmuly*hoco[1]*div; // maximize speed as usual len= zco[0]*zco[0] + zco[1]*zco[1]; - if(len > winsq) { + if (len > winsq) { len= winroot/sqrtf(len); zco[0]*= len; zco[1]*= len; } @@ -5525,7 +5532,7 @@ static void copy_dbase_object_vectors(Render *re, ListBase *lb) float *vec, ho[4], winmat[4][4]; int a, totvector; - for(obi= re->instancetable.first; obi; obi= obi->next) { + for (obi= re->instancetable.first; obi; obi= obi->next) { obr= obi->obr; obilb= MEM_mallocN(sizeof(ObjectInstanceRen), "ObInstanceVector"); @@ -5534,16 +5541,16 @@ static void copy_dbase_object_vectors(Render *re, ListBase *lb) obilb->totvector= totvector= obr->totvert; - if(totvector > 0) { + if (totvector > 0) { vec= obilb->vectors= MEM_mallocN(2*sizeof(float)*totvector, "vector array"); - if(obi->flag & R_TRANSFORMED) + if (obi->flag & R_TRANSFORMED) mult_m4_m4m4(winmat, re->winmat, obi->mat); else copy_m4_m4(winmat, re->winmat); - for(a=0; a<obr->totvert; a++, vec+=2) { - if((a & 255)==0) ver= obr->vertnodes[a>>8].vert; + for (a=0; a<obr->totvert; a++, vec+=2) { + if ((a & 255)==0) ver= obr->vertnodes[a>>8].vert; else ver++; projectvert(ver->co, winmat, ho); @@ -5557,8 +5564,8 @@ static void free_dbase_object_vectors(ListBase *lb) { ObjectInstanceRen *obi; - for(obi= lb->first; obi; obi= obi->next) - if(obi->vectors) + for (obi= lb->first; obi; obi= obi->next) + if (obi->vectors) MEM_freeN(obi->vectors); BLI_freelistN(lb); } @@ -5589,7 +5596,7 @@ void RE_Database_FromScene_Vectors(Render *re, Main *bmain, Scene *sce, unsigned RE_Database_Free(re); re->strandsurface= strandsurface; - if(!re->test_break(re->tbh)) { + if (!re->test_break(re->tbh)) { /* creates entire dbase */ re->i.infostr= "Calculating next frame vectors"; @@ -5604,55 +5611,55 @@ void RE_Database_FromScene_Vectors(Render *re, Main *bmain, Scene *sce, unsigned RE_Database_Free(re); re->strandsurface= strandsurface; - if(!re->test_break(re->tbh)) + if (!re->test_break(re->tbh)) RE_Database_FromScene(re, bmain, sce, lay, 1); - if(!re->test_break(re->tbh)) { + if (!re->test_break(re->tbh)) { int vectorlay= get_vector_renderlayers(re->scene); - for(step= 0; step<2; step++) { + for (step= 0; step<2; step++) { - if(step) + if (step) table= &newtable; else table= &oldtable; oldobi= table->first; - for(obi= re->instancetable.first; obi && oldobi; obi= obi->next) { + for (obi= re->instancetable.first; obi && oldobi; obi= obi->next) { int ok= 1; FluidsimModifierData *fluidmd; - if(!(obi->lay & vectorlay)) + if (!(obi->lay & vectorlay)) continue; obi->totvector= obi->obr->totvert; /* find matching object in old table */ - if(oldobi->ob!=obi->ob || oldobi->par!=obi->par || oldobi->index!=obi->index || oldobi->psysindex!=obi->psysindex) { + if (oldobi->ob!=obi->ob || oldobi->par!=obi->par || oldobi->index!=obi->index || oldobi->psysindex!=obi->psysindex) { ok= 0; - for(oldobi= table->first; oldobi; oldobi= oldobi->next) - if(oldobi->ob==obi->ob && oldobi->par==obi->par && oldobi->index==obi->index && oldobi->psysindex==obi->psysindex) + for (oldobi= table->first; oldobi; oldobi= oldobi->next) + if (oldobi->ob==obi->ob && oldobi->par==obi->par && oldobi->index==obi->index && oldobi->psysindex==obi->psysindex) break; - if(oldobi==NULL) + if (oldobi==NULL) oldobi= table->first; else ok= 1; } - if(ok==0) { + if (ok==0) { printf("speed table: missing object %s\n", obi->ob->id.name+2); continue; } // NT check for fluidsim special treatment fluidmd = (FluidsimModifierData *)modifiers_findByType(obi->ob, eModifierType_Fluidsim); - if(fluidmd && fluidmd->fss && (fluidmd->fss->type & OB_FLUIDSIM_DOMAIN)) { + if (fluidmd && fluidmd->fss && (fluidmd->fss->type & OB_FLUIDSIM_DOMAIN)) { // use preloaded per vertex simulation data , only does calculation for step=1 // NOTE/FIXME - velocities and meshes loaded unnecessarily often during the database_fromscene_vectors calls... load_fluidsimspeedvectors(re, obi, oldobi->vectors, step); } else { /* check if both have same amounts of vertices */ - if(obi->totvector==oldobi->totvector) + if (obi->totvector==oldobi->totvector) calculate_speedvectors(re, obi, oldobi->vectors, step); else printf("Warning: object %s has different amount of vertices or strands on other frame\n", obi->ob->id.name+2); @@ -5666,12 +5673,12 @@ void RE_Database_FromScene_Vectors(Render *re, Main *bmain, Scene *sce, unsigned free_dbase_object_vectors(&oldtable); free_dbase_object_vectors(&newtable); - for(mesh=re->strandsurface.first; mesh; mesh=mesh->next) { - if(mesh->prevco) { + for (mesh=re->strandsurface.first; mesh; mesh=mesh->next) { + if (mesh->prevco) { MEM_freeN(mesh->prevco); mesh->prevco= NULL; } - if(mesh->nextco) { + if (mesh->nextco) { MEM_freeN(mesh->nextco); mesh->nextco= NULL; } @@ -5715,18 +5722,18 @@ void RE_Database_Baking(Render *re, Main *bmain, Scene *scene, unsigned int lay, re->flag |= R_BAKING; re->excludeob= actob; - if(actob) + if (actob) re->flag |= R_BAKE_TRACE; - if(type==RE_BAKE_NORMALS && re->r.bake_normal_space==R_BAKE_SPACE_TANGENT) + if (type==RE_BAKE_NORMALS && re->r.bake_normal_space==R_BAKE_SPACE_TANGENT) re->flag |= R_NEED_TANGENT; - if(!actob && ELEM4(type, RE_BAKE_LIGHT, RE_BAKE_NORMALS, RE_BAKE_TEXTURE, RE_BAKE_DISPLACEMENT)) { + if (!actob && ELEM4(type, RE_BAKE_LIGHT, RE_BAKE_NORMALS, RE_BAKE_TEXTURE, RE_BAKE_DISPLACEMENT)) { re->r.mode &= ~R_SHADOW; re->r.mode &= ~R_RAYTRACE; } - if(!actob && (type==RE_BAKE_SHADOW)) { + if (!actob && (type==RE_BAKE_SHADOW)) { re->r.mode |= R_SHADOW; } @@ -5738,13 +5745,13 @@ void RE_Database_Baking(Render *re, Main *bmain, Scene *scene, unsigned int lay, re->lampren.first= re->lampren.last= NULL; /* in localview, lamps are using normal layers, objects only local bits */ - if(re->lay & 0xFF000000) + if (re->lay & 0xFF000000) lay &= 0xFF000000; camera= RE_GetCamera(re); /* if no camera, set unit */ - if(camera) { + if (camera) { normalize_m4(camera->obmat); invert_m4_m4(mat, camera->obmat); RE_SetView(re, mat); @@ -5763,10 +5770,10 @@ void RE_Database_Baking(Render *re, Main *bmain, Scene *scene, unsigned int lay, /* done setting dummy values */ init_render_world(re); /* do first, because of ambient. also requires re->osa set correct */ - if(re->r.mode & R_RAYTRACE) { + if (re->r.mode & R_RAYTRACE) { init_render_qmcsampler(re); - if(re->wrld.mode & (WO_AMB_OCC|WO_ENV_LIGHT|WO_INDIRECT_LIGHT)) + if (re->wrld.mode & (WO_AMB_OCC|WO_ENV_LIGHT|WO_INDIRECT_LIGHT)) if (re->wrld.ao_samp_method == WO_AOSAMP_CONSTANT) init_ao_sphere(&re->wrld); } @@ -5785,27 +5792,27 @@ void RE_Database_Baking(Render *re, Main *bmain, Scene *scene, unsigned int lay, set_material_lightgroups(re); /* SHADOW BUFFER */ - if(type!=RE_BAKE_LIGHT) - if(re->r.mode & R_SHADOW) + if (type!=RE_BAKE_LIGHT) + if (re->r.mode & R_SHADOW) threaded_makeshadowbufs(re); /* raytree */ - if(!re->test_break(re->tbh)) - if(re->r.mode & R_RAYTRACE) + if (!re->test_break(re->tbh)) + if (re->r.mode & R_RAYTRACE) makeraytree(re); /* point density texture */ - if(!re->test_break(re->tbh)) + if (!re->test_break(re->tbh)) make_pointdensities(re); /* voxel data texture */ - if(!re->test_break(re->tbh)) + if (!re->test_break(re->tbh)) make_voxeldata(re); /* occlusion */ - if((re->wrld.mode & (WO_AMB_OCC|WO_ENV_LIGHT|WO_INDIRECT_LIGHT)) && !re->test_break(re->tbh)) - if(re->wrld.ao_gather_method == WO_AOGATHER_APPROX) - if(re->r.mode & R_SHADOW) + if ((re->wrld.mode & (WO_AMB_OCC|WO_ENV_LIGHT|WO_INDIRECT_LIGHT)) && !re->test_break(re->tbh)) + if (re->wrld.ao_gather_method == WO_AOGATHER_APPROX) + if (re->r.mode & R_SHADOW) make_occ_tree(re); } @@ -5825,19 +5832,19 @@ void RE_make_sticky(Scene *scene, View3D *v3d) int a; Object *camera= NULL; - if(v3d==NULL) { + if (v3d==NULL) { printf("Need a 3d view to make sticky\n"); return; } - if(v3d) camera= V3D_CAMERA_LOCAL(v3d); - if(camera == NULL) camera= scene->camera; + if (v3d) camera= V3D_CAMERA_LOCAL(v3d); + if (camera == NULL) camera= scene->camera; - if(camera==NULL) { + if (camera==NULL) { printf("Need camera to make sticky\n"); return; } - if(scene->obedit) { + if (scene->obedit) { printf("Unable to make sticky in Edit Mode\n"); return; } @@ -5853,14 +5860,14 @@ void RE_make_sticky(Scene *scene, View3D *v3d) invert_m4_m4(mat, camera->obmat); RE_SetView(re, mat); - for(base= FIRSTBASE; base; base= base->next) { + for (base= FIRSTBASE; base; base= base->next) { if TESTBASELIB(v3d, base) { - if(base->object->type==OB_MESH) { + if (base->object->type==OB_MESH) { ob= base->object; me= ob->data; mvert= me->mvert; - if(me->msticky) + if (me->msticky) CustomData_free_layer_active(&me->vdata, CD_MSTICKY, me->totvert); me->msticky= CustomData_add_layer(&me->vdata, CD_MSTICKY, CD_CALLOC, NULL, me->totvert); @@ -5869,7 +5876,7 @@ void RE_make_sticky(Scene *scene, View3D *v3d) mult_m4_m4m4(mat, re->viewmat, ob->obmat); ms= me->msticky; - for(a=0; a<me->totvert; a++, ms++, mvert++) { + for (a=0; a<me->totvert; a++, ms++, mvert++) { copy_v3_v3(ho, mvert->co); mul_m4_v3(mat, ho); projectverto(ho, re->winmat, ho); diff --git a/source/blender/render/intern/source/envmap.c b/source/blender/render/intern/source/envmap.c index 2f6934ba10f..59f8782e816 100644 --- a/source/blender/render/intern/source/envmap.c +++ b/source/blender/render/intern/source/envmap.c @@ -76,7 +76,7 @@ static void envmap_split_ima(EnvMap *env, ImBuf *ibuf) /* after lock we test cube[1], if set the other thread has done it fine */ BLI_lock_thread(LOCK_IMAGE); - if(env->cube[1]==NULL) { + if (env->cube[1]==NULL) { BKE_free_envmapdata(env); @@ -85,18 +85,20 @@ static void envmap_split_ima(EnvMap *env, ImBuf *ibuf) if (3*dx == ibuf->x) { env->type = ENV_CUBE; env->ok= ENV_OSA; - } else if (ibuf->x == ibuf->y) { + } + else if (ibuf->x == ibuf->y) { env->type = ENV_PLANE; env->ok= ENV_OSA; - } else { + } + else { printf("Incorrect envmap size\n"); env->ok= 0; env->ima->ok= 0; } - if(env->ok) { + if (env->ok) { if (env->type == ENV_CUBE) { - for(part=0; part<6; part++) { + for (part=0; part<6; part++) { env->cube[part]= IMB_allocImBuf(dx, dx, 24, IB_rect|IB_rectfloat); } IMB_float_from_rect(ibuf); @@ -214,19 +216,24 @@ static void envmap_transmatrix(float mat[][4], int part) eul[0]= eul[1]= eul[2]= 0.0; - if(part==0) { /* neg z */ + if (part==0) { /* neg z */ ; - } else if(part==1) { /* pos z */ + } + else if (part==1) { /* pos z */ eul[0]= M_PI; - } else if(part==2) { /* pos y */ + } + else if (part==2) { /* pos y */ eul[0]= M_PI/2.0; - } else if(part==3) { /* neg x */ + } + else if (part==3) { /* neg x */ eul[0]= M_PI/2.0; eul[2]= M_PI/2.0; - } else if(part==4) { /* neg y */ + } + else if (part==4) { /* neg y */ eul[0]= M_PI/2.0; eul[2]= M_PI; - } else { /* pos x */ + } + else { /* pos x */ eul[0]= M_PI/2.0; eul[2]= -M_PI/2.0; } @@ -250,7 +257,7 @@ static void env_rotate_scene(Render *re, float mat[][4], int mode) float imat[3][3], pmat[4][4], smat[4][4], tmat[4][4], cmat[3][3], tmpmat[4][4]; int a; - if(mode==0) { + if (mode==0) { invert_m4_m4(tmat, mat); copy_m3_m4(imat, tmat); } @@ -259,13 +266,13 @@ static void env_rotate_scene(Render *re, float mat[][4], int mode) copy_m3_m4(imat, mat); } - for(obi=re->instancetable.first; obi; obi=obi->next) { + for (obi=re->instancetable.first; obi; obi=obi->next) { /* append or set matrix depending on dupli */ - if(obi->flag & R_DUPLI_TRANSFORMED) { + if (obi->flag & R_DUPLI_TRANSFORMED) { copy_m4_m4(tmpmat, obi->mat); mult_m4_m4m4(obi->mat, tmat, tmpmat); } - else if(mode==1) + else if (mode==1) copy_m4_m4(obi->mat, tmat); else unit_m4(obi->mat); @@ -275,23 +282,23 @@ static void env_rotate_scene(Render *re, float mat[][4], int mode) transpose_m3(obi->nmat); /* indicate the renderer has to use transform matrices */ - if(mode==0) + if (mode==0) obi->flag &= ~R_ENV_TRANSFORMED; else obi->flag |= R_ENV_TRANSFORMED; } - for(obr=re->objecttable.first; obr; obr=obr->next) { - for(a=0; a<obr->tothalo; a++) { - if((a & 255)==0) har= obr->bloha[a>>8]; + for (obr=re->objecttable.first; obr; obr=obr->next) { + for (a=0; a<obr->tothalo; a++) { + if ((a & 255)==0) har= obr->bloha[a>>8]; else har++; mul_m4_v3(tmat, har->co); } } - for(go=re->lights.first; go; go= go->next) { + for (go=re->lights.first; go; go= go->next) { lar= go->lampren; /* removed here some horrible code of someone in NaN who tried to fix @@ -309,8 +316,8 @@ static void env_rotate_scene(Render *re, float mat[][4], int mode) mul_m3_v3(lar->imat, lar->sh_invcampos); lar->sh_invcampos[2]*= lar->sh_zfac; - if(lar->shb) { - if(mode==1) { + if (lar->shb) { + if (mode==1) { invert_m4_m4(pmat, mat); mult_m4_m4m4(smat, lar->shb->viewmat, pmat); mult_m4_m4m4(lar->shb->persmat, lar->shb->winmat, smat); @@ -339,10 +346,10 @@ static void env_layerflags(Render *re, unsigned int notlay) notlay= ~notlay; - for(obr=re->objecttable.first; obr; obr=obr->next) { - if((obr->lay & notlay)==0) { - for(a=0; a<obr->totvlak; a++) { - if((a & 255)==0) vlr= obr->vlaknodes[a>>8].vlak; + for (obr=re->objecttable.first; obr; obr=obr->next) { + if ((obr->lay & notlay)==0) { + for (a=0; a<obr->totvlak; a++) { + if ((a & 255)==0) vlr= obr->vlaknodes[a>>8].vlak; else vlr++; vlr->flag |= R_HIDDEN; @@ -357,12 +364,12 @@ static void env_hideobject(Render *re, Object *ob) VlakRen *vlr = NULL; int a; - for(obr=re->objecttable.first; obr; obr=obr->next) { - for(a=0; a<obr->totvlak; a++) { - if((a & 255)==0) vlr= obr->vlaknodes[a>>8].vlak; + for (obr=re->objecttable.first; obr; obr=obr->next) { + for (a=0; a<obr->totvlak; a++) { + if ((a & 255)==0) vlr= obr->vlaknodes[a>>8].vlak; else vlr++; - if(obr->ob == ob) + if (obr->ob == ob) vlr->flag |= R_HIDDEN; } } @@ -374,9 +381,9 @@ static void env_showobjects(Render *re) VlakRen *vlr = NULL; int a; - for(obr=re->objecttable.first; obr; obr=obr->next) { - for(a=0; a<obr->totvlak; a++) { - if((a & 255)==0) vlr= obr->vlaknodes[a>>8].vlak; + for (obr=re->objecttable.first; obr; obr=obr->next) { + for (a=0; a<obr->totvlak; a++) { + if ((a & 255)==0) vlr= obr->vlaknodes[a>>8].vlak; else vlr++; vlr->flag &= ~R_HIDDEN; @@ -426,8 +433,8 @@ static void render_envmap(Render *re, EnvMap *env) invert_m4_m4(tmat, mat); copy_m3_m4(env->obimat, tmat); - for(part=0; part<6; part++) { - if(env->type==ENV_PLANE && part!=1) + for (part=0; part<6; part++) { + if (env->type==ENV_PLANE && part!=1) continue; re->display_clear(re->dch, envre->result); @@ -451,7 +458,7 @@ static void render_envmap(Render *re, EnvMap *env) env_hideobject(envre, env->object); env_set_imats(envre); - if(re->test_break(re->tbh)==0) { + if (re->test_break(re->tbh)==0) { RE_TileProcessor(envre); } @@ -459,7 +466,7 @@ static void render_envmap(Render *re, EnvMap *env) env_showobjects(envre); env_rotate_scene(envre, tmat, 0); - if(re->test_break(re->tbh)==0) { + if (re->test_break(re->tbh)==0) { RenderLayer *rl= envre->result->layers.first; int y; float *alpha; @@ -472,19 +479,19 @@ static void render_envmap(Render *re, EnvMap *env) /* envmap renders without alpha */ alpha= ((float *)ibuf->rect_float)+3; - for(y= ibuf->x*ibuf->y - 1; y>=0; y--, alpha+=4) + for (y= ibuf->x*ibuf->y - 1; y>=0; y--, alpha+=4) *alpha= 1.0; env->cube[part]= ibuf; } - if(re->test_break(re->tbh)) break; + if (re->test_break(re->tbh)) break; } - if(re->test_break(re->tbh)) BKE_free_envmapdata(env); + if (re->test_break(re->tbh)) BKE_free_envmapdata(env); else { - if(envre->r.mode & R_OSA) env->ok= ENV_OSA; + if (envre->r.mode & R_OSA) env->ok= ENV_OSA; else env->ok= ENV_NORMAL; env->lastframe= re->scene->r.cfra; } @@ -515,12 +522,12 @@ void make_envmaps(Render *re) while(depth<5) { tex= re->main->tex.first; while(tex) { - if(tex->id.us && tex->type==TEX_ENVMAP) { - if(tex->env && tex->env->object) { + if (tex->id.us && tex->type==TEX_ENVMAP) { + if (tex->env && tex->env->object) { EnvMap *env= tex->env; - if(env->object->lay & re->lay) { - if(env->stype==ENV_LOAD) { + if (env->object->lay & re->lay) { + if (env->stype==ENV_LOAD) { float orthmat[4][4], mat[4][4], tmat[4][4]; /* precalc orthmat for object */ @@ -535,29 +542,29 @@ void make_envmaps(Render *re) else { /* decide if to render an envmap (again) */ - if(env->depth >= depth) { + if (env->depth >= depth) { /* set 'recalc' to make sure it does an entire loop of recalcs */ - if(env->ok) { + if (env->ok) { /* free when OSA, and old one isn't OSA */ - if((re->r.mode & R_OSA) && env->ok==ENV_NORMAL) + if ((re->r.mode & R_OSA) && env->ok==ENV_NORMAL) BKE_free_envmapdata(env); /* free when size larger */ - else if(env->lastsize < re->r.size) + else if (env->lastsize < re->r.size) BKE_free_envmapdata(env); /* free when env is in recalcmode */ - else if(env->recalc) + else if (env->recalc) BKE_free_envmapdata(env); } - if(env->ok==0 && depth==0) env->recalc= 1; + if (env->ok==0 && depth==0) env->recalc= 1; - if(env->ok==0) { + if (env->ok==0) { do_init= 1; render_envmap(re, env); - if(depth==env->depth) env->recalc= 0; + if (depth==env->depth) env->recalc= 0; } } } @@ -569,7 +576,7 @@ void make_envmaps(Render *re) depth++; } - if(do_init) { + if (do_init) { re->display_init(re->dih, re->result); re->display_clear(re->dch, re->result); // re->flag |= R_REDRAW_PRV; @@ -586,7 +593,7 @@ static int envcube_isect(EnvMap *env, float *vec, float *answ) float labda; int face; - if(env->type==ENV_PLANE) { + if (env->type==ENV_PLANE) { face= 1; labda= 1.0f/vec[2]; @@ -595,7 +602,7 @@ static int envcube_isect(EnvMap *env, float *vec, float *answ) } else { /* which face */ - if( vec[2] <= -fabsf(vec[0]) && vec[2] <= -fabsf(vec[1]) ) { + if ( vec[2] <= -fabsf(vec[0]) && vec[2] <= -fabsf(vec[1]) ) { face= 0; labda= -1.0f/vec[2]; answ[0]= labda*vec[0]; @@ -642,13 +649,13 @@ static int envcube_isect(EnvMap *env, float *vec, float *answ) static void set_dxtdyt(float *dxts, float *dyts, float *dxt, float *dyt, int face) { - if(face==2 || face==4) { + if (face==2 || face==4) { dxts[0]= dxt[0]; dyts[0]= dyt[0]; dxts[1]= dxt[2]; dyts[1]= dyt[2]; } - else if(face==3 || face==5) { + else if (face==3 || face==5) { dxts[0]= dxt[1]; dxts[1]= dxt[2]; dyts[0]= dyt[1]; @@ -674,17 +681,17 @@ int envmaptex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, TexRe int face, face1; env= tex->env; - if(env==NULL || (env->stype!=ENV_LOAD && env->object==NULL)) { + if (env==NULL || (env->stype!=ENV_LOAD && env->object==NULL)) { texres->tin= 0.0; return 0; } - if(env->stype==ENV_LOAD) { + if (env->stype==ENV_LOAD) { env->ima= tex->ima; - if(env->ima && env->ima->ok) { - if(env->cube[1]==NULL) { + if (env->ima && env->ima->ok) { + if (env->cube[1]==NULL) { ImBuf *ibuf_ima= BKE_image_get_ibuf(env->ima, NULL); - if(ibuf_ima) + if (ibuf_ima) envmap_split_ima(env, ibuf_ima); else env->ok= 0; @@ -692,21 +699,21 @@ int envmaptex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, TexRe } } - if(env->ok==0) { + if (env->ok==0) { texres->tin= 0.0; return 0; } /* rotate to envmap space, if object is set */ copy_v3_v3(vec, texvec); - if(env->object) mul_m3_v3(env->obimat, vec); + if (env->object) mul_m3_v3(env->obimat, vec); else mul_mat3_m4_v3(R.viewinv, vec); face= envcube_isect(env, vec, sco); ibuf= env->cube[face]; - if(osatex) { - if(env->object) { + if (osatex) { + if (env->object) { mul_m3_v3(env->obimat, dxt); mul_m3_v3(env->obimat, dyt); } @@ -719,7 +726,7 @@ int envmaptex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, TexRe /* edges? */ - if(texres->ta<1.0f) { + if (texres->ta<1.0f) { TexResult texr1, texr2; texr1.nor= texr2.nor= NULL; @@ -729,7 +736,7 @@ int envmaptex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, TexRe face1= envcube_isect(env, vec, sco); sub_v3_v3(vec, dxt); - if(face!=face1) { + if (face!=face1) { ibuf= env->cube[face1]; set_dxtdyt(dxts, dyts, dxt, dyt, face1); imagewraposa(tex, NULL, ibuf, sco, dxts, dyts, &texr1); @@ -742,7 +749,7 @@ int envmaptex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, TexRe face1= envcube_isect(env, vec, sco); sub_v3_v3(vec, dyt); - if(face!=face1) { + if (face!=face1) { ibuf= env->cube[face1]; set_dxtdyt(dxts, dyts, dxt, dyt, face1); imagewraposa(tex, NULL, ibuf, sco, dxts, dyts, &texr2); @@ -750,7 +757,7 @@ int envmaptex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, TexRe else texr2.tr= texr2.tg= texr2.tb= texr2.ta= 0.0; fac= (texres->ta+texr1.ta+texr2.ta); - if(fac!=0.0f) { + if (fac!=0.0f) { fac= 1.0f/fac; texres->tr= fac*(texres->ta*texres->tr + texr1.ta*texr1.tr + texr2.ta*texr2.tr ); diff --git a/source/blender/render/intern/source/external_engine.c b/source/blender/render/intern/source/external_engine.c index 6e2d33cdf10..ea352a16934 100644 --- a/source/blender/render/intern/source/external_engine.c +++ b/source/blender/render/intern/source/external_engine.c @@ -91,13 +91,13 @@ void RE_engines_exit(void) { RenderEngineType *type, *next; - for(type=R_engines.first; type; type=next) { + for (type=R_engines.first; type; type=next) { next= type->next; BLI_remlink(&R_engines, type); - if(!(type->flag & RE_INTERNAL)) { - if(type->ext.free) + if (!(type->flag & RE_INTERNAL)) { + if (type->ext.free) type->ext.free(type->ext.data); MEM_freeN(type); @@ -110,7 +110,7 @@ RenderEngineType *RE_engines_find(const char *idname) RenderEngineType *type; type= BLI_findstring(&R_engines, idname, offsetof(RenderEngineType, idname)); - if(!type) + if (!type) type= &internal_render_type; return type; @@ -135,12 +135,12 @@ RenderEngine *RE_engine_create(RenderEngineType *type) void RE_engine_free(RenderEngine *engine) { #ifdef WITH_PYTHON - if(engine->py_instance) { + if (engine->py_instance) { BPY_DECREF(engine->py_instance); } #endif - if(engine->text) + if (engine->text) MEM_freeN(engine->text); MEM_freeN(engine); @@ -160,9 +160,9 @@ RenderResult *RE_engine_begin_result(RenderEngine *engine, int x, int y, int w, CLAMP(w, 0, re->result->rectx); CLAMP(h, 0, re->result->recty); - if(x + w > re->result->rectx) + if (x + w > re->result->rectx) w= re->result->rectx - x; - if(y + h > re->result->recty) + if (y + h > re->result->recty) h= re->result->recty - y; /* allocate a render result */ @@ -186,7 +186,7 @@ void RE_engine_update_result(RenderEngine *engine, RenderResult *result) { Render *re= engine->re; - if(result) { + if (result) { result->renlay= result->layers.first; // weak, draws first layer always re->display_draw(re->ddh, result, NULL); } @@ -196,15 +196,15 @@ void RE_engine_end_result(RenderEngine *engine, RenderResult *result) { Render *re= engine->re; - if(!result) + if (!result) return; /* merge. on break, don't merge in result for preview renders, looks nicer */ - if(!(re->test_break(re->tbh) && (re->r.scemode & R_PREVIEWBUTS))) + if (!(re->test_break(re->tbh) && (re->r.scemode & R_PREVIEWBUTS))) render_result_merge(re->result, result); /* draw */ - if(!re->test_break(re->tbh)) { + if (!re->test_break(re->tbh)) { result->renlay= result->layers.first; // weak, draws first layer always re->display_draw(re->ddh, result, NULL); } @@ -219,7 +219,7 @@ int RE_engine_test_break(RenderEngine *engine) { Render *re= engine->re; - if(re) + if (re) return re->test_break(re->tbh); return 0; @@ -232,7 +232,7 @@ void RE_engine_update_stats(RenderEngine *engine, const char *stats, const char Render *re= engine->re; /* stats draw callback */ - if(re) { + if (re) { re->i.statstr= stats; re->i.infostr= info; re->stats_draw(re->sdh, &re->i); @@ -241,16 +241,16 @@ void RE_engine_update_stats(RenderEngine *engine, const char *stats, const char } /* set engine text */ - if(engine->text) { + if (engine->text) { MEM_freeN(engine->text); engine->text= NULL; } - if(stats && stats[0] && info && info[0]) + if (stats && stats[0] && info && info[0]) engine->text= BLI_sprintfN("%s | %s", stats, info); - else if(info && info[0]) + else if (info && info[0]) engine->text= BLI_strdup(info); - else if(stats && stats[0]) + else if (stats && stats[0]) engine->text= BLI_strdup(stats); } @@ -258,7 +258,7 @@ void RE_engine_update_progress(RenderEngine *engine, float progress) { Render *re= engine->re; - if(re) { + if (re) { CLAMP(progress, 0.0f, 1.0f); re->progress(re->prh, progress); } @@ -277,25 +277,25 @@ int RE_engine_render(Render *re, int do_all) RenderEngine *engine; /* verify if we can render */ - if(!type->render) + if (!type->render) return 0; - if((re->r.scemode & R_PREVIEWBUTS) && !(type->flag & RE_USE_PREVIEW)) + if ((re->r.scemode & R_PREVIEWBUTS) && !(type->flag & RE_USE_PREVIEW)) return 0; - if(do_all && !(type->flag & RE_USE_POSTPROCESS)) + if (do_all && !(type->flag & RE_USE_POSTPROCESS)) return 0; - if(!do_all && (type->flag & RE_USE_POSTPROCESS)) + if (!do_all && (type->flag & RE_USE_POSTPROCESS)) return 0; /* create render result */ BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE); - if(re->result==NULL || !(re->r.scemode & R_PREVIEWBUTS)) { - if(re->result) + if (re->result==NULL || !(re->r.scemode & R_PREVIEWBUTS)) { + if (re->result) render_result_free(re->result); re->result= render_result_new(re, &re->disprect, 0, 0); } BLI_rw_mutex_unlock(&re->resultmutex); - if(re->result==NULL) + if (re->result==NULL) return 1; /* set render info */ @@ -307,24 +307,24 @@ int RE_engine_render(Render *re, int do_all) engine = RE_engine_create(type); engine->re= re; - if(re->flag & R_ANIMATION) + if (re->flag & R_ANIMATION) engine->flag |= RE_ENGINE_ANIMATION; - if(re->r.scemode & R_PREVIEWBUTS) + if (re->r.scemode & R_PREVIEWBUTS) engine->flag |= RE_ENGINE_PREVIEW; - if((re->r.scemode & (R_NO_FRAME_UPDATE|R_PREVIEWBUTS))==0) + if ((re->r.scemode & (R_NO_FRAME_UPDATE|R_PREVIEWBUTS))==0) scene_update_for_newframe(re->main, re->scene, re->lay); - if(type->update) + if (type->update) type->update(engine, re->main, re->scene); - if(type->render) + if (type->render) type->render(engine, re->scene); render_result_free_list(&engine->fullresult, engine->fullresult.first); RE_engine_free(engine); - if(BKE_reports_contain(re->reports, RPT_ERROR)) + if (BKE_reports_contain(re->reports, RPT_ERROR)) G.afbreek = 1; return 1; diff --git a/source/blender/render/intern/source/imagetexture.c b/source/blender/render/intern/source/imagetexture.c index bbca11e09fd..6d8ae20985c 100644 --- a/source/blender/render/intern/source/imagetexture.c +++ b/source/blender/render/intern/source/imagetexture.c @@ -85,12 +85,12 @@ static void ibuf_get_color(float *col, struct ImBuf *ibuf, int x, int y) { int ofs = y * ibuf->x + x; - if(ibuf->rect_float) { - if(ibuf->channels==4) { + if (ibuf->rect_float) { + if (ibuf->channels==4) { float *fp= ibuf->rect_float + 4*ofs; copy_v4_v4(col, fp); } - else if(ibuf->channels==3) { + else if (ibuf->channels==3) { float *fp= ibuf->rect_float + 3*ofs; copy_v3_v3(col, fp); col[3]= 1.0f; @@ -122,23 +122,23 @@ int imagewrap(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], TexResul retval= texres->nor?3:1; /* quick tests */ - if(ibuf==NULL && ima==NULL) + if (ibuf==NULL && ima==NULL) return retval; - if(ima) { + if (ima) { /* hack for icon render */ - if(ima->ibufs.first==NULL && (R.r.scemode & R_NO_IMAGE_LOAD)) + if (ima->ibufs.first==NULL && (R.r.scemode & R_NO_IMAGE_LOAD)) return retval; ibuf= BKE_image_get_ibuf(ima, &tex->iuser); ima->flag|= IMA_USED_FOR_RENDER; } - if(ibuf==NULL || (ibuf->rect==NULL && ibuf->rect_float==NULL)) + if (ibuf==NULL || (ibuf->rect==NULL && ibuf->rect_float==NULL)) return retval; /* setup mapping */ - if(tex->imaflag & TEX_IMAROT) { + if (tex->imaflag & TEX_IMAROT) { fy= texvec[0]; fx= texvec[1]; } @@ -147,7 +147,7 @@ int imagewrap(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], TexResul fy= texvec[1]; } - if(tex->extend == TEX_CHECKER) { + if (tex->extend == TEX_CHECKER) { int xs, ys; xs= (int)floor(fx); @@ -155,14 +155,14 @@ int imagewrap(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], TexResul fx-= xs; fy-= ys; - if( (tex->flag & TEX_CHECKER_ODD)==0) { - if((xs+ys) & 1);else return retval; + if ( (tex->flag & TEX_CHECKER_ODD)==0) { + if ((xs+ys) & 1);else return retval; } - if( (tex->flag & TEX_CHECKER_EVEN)==0) { - if((xs+ys) & 1) return retval; + if ( (tex->flag & TEX_CHECKER_EVEN)==0) { + if ((xs+ys) & 1) return retval; } /* scale around center, (0.5, 0.5) */ - if(tex->checkerdist<1.0f) { + if (tex->checkerdist<1.0f) { fx= (fx-0.5f)/(1.0f-tex->checkerdist) +0.5f; fy= (fy-0.5f)/(1.0f-tex->checkerdist) +0.5f; } @@ -171,37 +171,37 @@ int imagewrap(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], TexResul x= xi= (int)floorf(fx*ibuf->x); y= yi= (int)floorf(fy*ibuf->y); - if(tex->extend == TEX_CLIPCUBE) { - if(x<0 || y<0 || x>=ibuf->x || y>=ibuf->y || texvec[2]<-1.0f || texvec[2]>1.0f) { + if (tex->extend == TEX_CLIPCUBE) { + if (x<0 || y<0 || x>=ibuf->x || y>=ibuf->y || texvec[2]<-1.0f || texvec[2]>1.0f) { return retval; } } - else if( tex->extend==TEX_CLIP || tex->extend==TEX_CHECKER) { - if(x<0 || y<0 || x>=ibuf->x || y>=ibuf->y) { + else if ( tex->extend==TEX_CLIP || tex->extend==TEX_CHECKER) { + if (x<0 || y<0 || x>=ibuf->x || y>=ibuf->y) { return retval; } } else { - if(tex->extend==TEX_EXTEND) { - if(x>=ibuf->x) x = ibuf->x-1; - else if(x<0) x= 0; + if (tex->extend==TEX_EXTEND) { + if (x>=ibuf->x) x = ibuf->x-1; + else if (x<0) x= 0; } else { x= x % ibuf->x; - if(x<0) x+= ibuf->x; + if (x<0) x+= ibuf->x; } - if(tex->extend==TEX_EXTEND) { - if(y>=ibuf->y) y = ibuf->y-1; - else if(y<0) y= 0; + if (tex->extend==TEX_EXTEND) { + if (y>=ibuf->y) y = ibuf->y-1; + else if (y<0) y= 0; } else { y= y % ibuf->y; - if(y<0) y+= ibuf->y; + if (y<0) y+= ibuf->y; } } /* warning, no return before setting back! */ - if( (R.flag & R_SEC_FIELD) && (ibuf->flags & IB_fields) ) { + if ( (R.flag & R_SEC_FIELD) && (ibuf->flags & IB_fields) ) { ibuf->rect+= (ibuf->x*ibuf->y); } @@ -230,12 +230,12 @@ int imagewrap(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], TexResul ibuf_get_color(&texres->tr, ibuf, x, y); } - if( (R.flag & R_SEC_FIELD) && (ibuf->flags & IB_fields) ) { + if ( (R.flag & R_SEC_FIELD) && (ibuf->flags & IB_fields) ) { ibuf->rect-= (ibuf->x*ibuf->y); } - if(texres->nor) { - if(tex->imaflag & TEX_NORMALMAP) { + if (texres->nor) { + if (tex->imaflag & TEX_NORMALMAP) { // qdn: normal from color // The invert of the red channel is to make // the normal map compliant with the outside world. @@ -251,14 +251,14 @@ int imagewrap(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], TexResul /* bump: take three samples */ val1= texres->tr+texres->tg+texres->tb; - if(x<ibuf->x-1) { + if (x<ibuf->x-1) { float col[4]; ibuf_get_color(col, ibuf, x+1, y); val2= (col[0]+col[1]+col[2]); } else val2= val1; - if(y<ibuf->y-1) { + if (y<ibuf->y-1) { float col[4]; ibuf_get_color(col, ibuf, x, y+1); val3= (col[0]+col[1]+col[2]); @@ -271,16 +271,16 @@ int imagewrap(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], TexResul } } - if(texres->talpha) texres->tin= texres->ta; - else if(tex->imaflag & TEX_CALCALPHA) { + if (texres->talpha) texres->tin= texres->ta; + else if (tex->imaflag & TEX_CALCALPHA) { texres->ta= texres->tin= MAX3(texres->tr, texres->tg, texres->tb); } else texres->ta= texres->tin= 1.0; - if(tex->flag & TEX_NEGALPHA) texres->ta= 1.0f-texres->ta; + if (tex->flag & TEX_NEGALPHA) texres->ta= 1.0f-texres->ta; /* de-premul, this is being premulled in shade_input_do_shade() */ - if(texres->ta!=1.0f && texres->ta>1e-4f) { + if (texres->ta!=1.0f && texres->ta>1e-4f) { fx= 1.0f/texres->ta; texres->tr*= fx; texres->tg*= fx; @@ -299,14 +299,14 @@ static void clipx_rctf_swap(rctf *stack, short *count, float x1, float x2) a= *count; rf= stack; - for(;a>0;a--) { - if(rf->xmin<x1) { - if(rf->xmax<x1) { + for (;a>0;a--) { + if (rf->xmin<x1) { + if (rf->xmax<x1) { rf->xmin+= (x2-x1); rf->xmax+= (x2-x1); } else { - if(rf->xmax>x2) rf->xmax = x2; + if (rf->xmax>x2) rf->xmax = x2; newrct= stack+ *count; (*count)++; @@ -315,18 +315,18 @@ static void clipx_rctf_swap(rctf *stack, short *count, float x1, float x2) newrct->ymin = rf->ymin; newrct->ymax = rf->ymax; - if(newrct->xmin ==newrct->xmax) (*count)--; + if (newrct->xmin ==newrct->xmax) (*count)--; rf->xmin = x1; } } - else if(rf->xmax>x2) { - if(rf->xmin>x2) { + else if (rf->xmax>x2) { + if (rf->xmin>x2) { rf->xmin-= (x2-x1); rf->xmax-= (x2-x1); } else { - if(rf->xmin<x1) rf->xmin = x1; + if (rf->xmin<x1) rf->xmin = x1; newrct= stack+ *count; (*count)++; @@ -335,7 +335,7 @@ static void clipx_rctf_swap(rctf *stack, short *count, float x1, float x2) newrct->ymin = rf->ymin; newrct->ymax = rf->ymax; - if(newrct->xmin ==newrct->xmax) (*count)--; + if (newrct->xmin ==newrct->xmax) (*count)--; rf->xmax = x2; } @@ -352,14 +352,14 @@ static void clipy_rctf_swap(rctf *stack, short *count, float y1, float y2) a= *count; rf= stack; - for(;a>0;a--) { - if(rf->ymin<y1) { - if(rf->ymax<y1) { + for (;a>0;a--) { + if (rf->ymin<y1) { + if (rf->ymax<y1) { rf->ymin+= (y2-y1); rf->ymax+= (y2-y1); } else { - if(rf->ymax>y2) rf->ymax = y2; + if (rf->ymax>y2) rf->ymax = y2; newrct= stack+ *count; (*count)++; @@ -368,18 +368,18 @@ static void clipy_rctf_swap(rctf *stack, short *count, float y1, float y2) newrct->xmin = rf->xmin; newrct->xmax = rf->xmax; - if(newrct->ymin==newrct->ymax) (*count)--; + if (newrct->ymin==newrct->ymax) (*count)--; rf->ymin = y1; } } - else if(rf->ymax>y2) { - if(rf->ymin>y2) { + else if (rf->ymax>y2) { + if (rf->ymin>y2) { rf->ymin-= (y2-y1); rf->ymax-= (y2-y1); } else { - if(rf->ymin<y1) rf->ymin = y1; + if (rf->ymin<y1) rf->ymin = y1; newrct= stack+ *count; (*count)++; @@ -388,7 +388,7 @@ static void clipy_rctf_swap(rctf *stack, short *count, float y1, float y2) newrct->xmin = rf->xmin; newrct->xmax = rf->xmax; - if(newrct->ymin==newrct->ymax) (*count)--; + if (newrct->ymin==newrct->ymax) (*count)--; rf->ymax = y2; } @@ -412,17 +412,17 @@ static float clipx_rctf(rctf *rf, float x1, float x2) size= rf->xmax - rf->xmin; - if(rf->xmin<x1) { + if (rf->xmin<x1) { rf->xmin = x1; } - if(rf->xmax>x2) { + if (rf->xmax>x2) { rf->xmax = x2; } - if(rf->xmin > rf->xmax) { + if (rf->xmin > rf->xmax) { rf->xmin = rf->xmax; return 0.0; } - else if(size!=0.0f) { + else if (size!=0.0f) { return (rf->xmax - rf->xmin)/size; } return 1.0; @@ -434,18 +434,18 @@ static float clipy_rctf(rctf *rf, float y1, float y2) size= rf->ymax - rf->ymin; - if(rf->ymin<y1) { + if (rf->ymin<y1) { rf->ymin = y1; } - if(rf->ymax>y2) { + if (rf->ymax>y2) { rf->ymax = y2; } - if(rf->ymin > rf->ymax) { + if (rf->ymin > rf->ymax) { rf->ymin = rf->ymax; return 0.0; } - else if(size!=0.0f) { + else if (size!=0.0f) { return (rf->ymax - rf->ymin)/size; } return 1.0; @@ -465,27 +465,27 @@ static void boxsampleclip(struct ImBuf *ibuf, rctf *rf, TexResult *texres) starty= (int)floor(rf->ymin); endy= (int)floor(rf->ymax); - if(startx < 0) startx= 0; - if(starty < 0) starty= 0; - if(endx>=ibuf->x) endx= ibuf->x-1; - if(endy>=ibuf->y) endy= ibuf->y-1; + if (startx < 0) startx= 0; + if (starty < 0) starty= 0; + if (endx>=ibuf->x) endx= ibuf->x-1; + if (endy>=ibuf->y) endy= ibuf->y-1; - if(starty==endy && startx==endx) { + if (starty==endy && startx==endx) { ibuf_get_color(&texres->tr, ibuf, startx, starty); } else { div= texres->tr= texres->tg= texres->tb= texres->ta= 0.0; - for(y=starty; y<=endy; y++) { + for (y=starty; y<=endy; y++) { muly= 1.0; - if(starty==endy); + if (starty==endy); else { - if(y==starty) muly= 1.0f-(rf->ymin - y); - if(y==endy) muly= (rf->ymax - y); + if (y==starty) muly= 1.0f-(rf->ymin - y); + if (y==endy) muly= (rf->ymax - y); } - if(startx==endx) { + if (startx==endx) { mulx= muly; ibuf_get_color(col, ibuf, startx, y); @@ -497,14 +497,14 @@ static void boxsampleclip(struct ImBuf *ibuf, rctf *rf, TexResult *texres) div+= mulx; } else { - for(x=startx; x<=endx; x++) { + for (x=startx; x<=endx; x++) { mulx= muly; - if(x==startx) mulx*= 1.0f-(rf->xmin - x); - if(x==endx) mulx*= (rf->xmax - x); + if (x==startx) mulx*= 1.0f-(rf->xmin - x); + if (x==endx) mulx*= (rf->xmax - x); ibuf_get_color(col, ibuf, x, y); - if(mulx==1.0f) { + if (mulx==1.0f) { texres->ta+= col[3]; texres->tr+= col[0]; texres->tg+= col[1]; @@ -522,7 +522,7 @@ static void boxsampleclip(struct ImBuf *ibuf, rctf *rf, TexResult *texres) } } - if(div!=0.0f) { + if (div!=0.0f) { div= 1.0f/div; texres->tb*= div; texres->tg*= div; @@ -559,37 +559,37 @@ static void boxsample(ImBuf *ibuf, float minx, float miny, float maxx, float max texr.talpha= texres->talpha; /* is read by boxsample_clip */ - if(imapextend) { + if (imapextend) { CLAMP(rf->xmin, 0.0f, ibuf->x-1); CLAMP(rf->xmax, 0.0f, ibuf->x-1); } - else if(imaprepeat) + else if (imaprepeat) clipx_rctf_swap(stack, &count, 0.0, (float)(ibuf->x)); else { alphaclip= clipx_rctf(rf, 0.0, (float)(ibuf->x)); - if(alphaclip<=0.0f) { + if (alphaclip<=0.0f) { texres->tr= texres->tb= texres->tg= texres->ta= 0.0; return; } } - if(imapextend) { + if (imapextend) { CLAMP(rf->ymin, 0.0f, ibuf->y-1); CLAMP(rf->ymax, 0.0f, ibuf->y-1); } - else if(imaprepeat) + else if (imaprepeat) clipy_rctf_swap(stack, &count, 0.0, (float)(ibuf->y)); else { alphaclip*= clipy_rctf(rf, 0.0, (float)(ibuf->y)); - if(alphaclip<=0.0f) { + if (alphaclip<=0.0f) { texres->tr= texres->tb= texres->tg= texres->ta= 0.0; return; } } - if(count>1) { + if (count>1) { tot= texres->tr= texres->tb= texres->tg= texres->ta= 0.0; while(count--) { boxsampleclip(ibuf, rf, &texr); @@ -600,22 +600,22 @@ static void boxsample(ImBuf *ibuf, float minx, float miny, float maxx, float max texres->tr+= opp*texr.tr; texres->tg+= opp*texr.tg; texres->tb+= opp*texr.tb; - if(texres->talpha) texres->ta+= opp*texr.ta; + if (texres->talpha) texres->ta+= opp*texr.ta; rf++; } - if(tot!= 0.0f) { + if (tot!= 0.0f) { texres->tr/= tot; texres->tg/= tot; texres->tb/= tot; - if(texres->talpha) texres->ta/= tot; + if (texres->talpha) texres->ta/= tot; } } else boxsampleclip(ibuf, rf, texres); - if(texres->talpha==0) texres->ta= 1.0; + if (texres->talpha==0) texres->ta= 1.0; - if(alphaclip!=1.0f) { + if (alphaclip!=1.0f) { /* premul it all */ texres->tr*= alphaclip; texres->tg*= alphaclip; @@ -978,7 +978,7 @@ static void alpha_clip_aniso(ImBuf *ibuf, float minx, float miny, float maxx, fl // TXF apha: we're doing the same alphaclip here as boxsample, but i'm doubting // if this is actually correct for the all the filtering algorithms .. - if(!(extflag == TXC_REPT || extflag == TXC_EXTD)) { + if (!(extflag == TXC_REPT || extflag == TXC_EXTD)) { rf.xmin = minx*(ibuf->x); rf.xmax = maxx*(ibuf->x); rf.ymin = miny*(ibuf->y); @@ -988,7 +988,7 @@ static void alpha_clip_aniso(ImBuf *ibuf, float minx, float miny, float maxx, fl alphaclip*= clipy_rctf(&rf, 0.0, (float)(ibuf->y)); alphaclip= MAX2(alphaclip, 0.0f); - if(alphaclip!=1.0f) { + if (alphaclip!=1.0f) { /* premul it all */ texres->tr*= alphaclip; texres->tg*= alphaclip; @@ -1213,9 +1213,9 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex // brecht: added stupid clamping here, large dx/dy can give very large // filter sizes which take ages to render, it may be better to do this // more intelligently later in the code .. probably it's not noticeable - if(AFD.dxt[0]*AFD.dxt[0] + AFD.dxt[1]*AFD.dxt[1] > 2.0f*2.0f) + if (AFD.dxt[0]*AFD.dxt[0] + AFD.dxt[1]*AFD.dxt[1] > 2.0f*2.0f) mul_v2_fl(AFD.dxt, 2.0f/len_v2(AFD.dxt)); - if(AFD.dyt[0]*AFD.dyt[0] + AFD.dyt[1]*AFD.dyt[1] > 2.0f*2.0f) + if (AFD.dyt[0]*AFD.dyt[0] + AFD.dyt[1]*AFD.dyt[1] > 2.0f*2.0f) mul_v2_fl(AFD.dyt, 2.0f/len_v2(AFD.dyt)); // choice: @@ -1434,32 +1434,32 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const retval= texres->nor?3:1; /* quick tests */ - if(ibuf==NULL && ima==NULL) + if (ibuf==NULL && ima==NULL) return retval; - if(ima) { + if (ima) { /* hack for icon render */ - if(ima->ibufs.first==NULL && (R.r.scemode & R_NO_IMAGE_LOAD)) + if (ima->ibufs.first==NULL && (R.r.scemode & R_NO_IMAGE_LOAD)) return retval; ibuf= BKE_image_get_ibuf(ima, &tex->iuser); ima->flag|= IMA_USED_FOR_RENDER; } - if(ibuf==NULL || (ibuf->rect==NULL && ibuf->rect_float==NULL)) + if (ibuf==NULL || (ibuf->rect==NULL && ibuf->rect_float==NULL)) return retval; /* mipmap test */ image_mipmap_test(tex, ibuf); - if(tex->imaflag & TEX_USEALPHA) { - if(tex->imaflag & TEX_CALCALPHA); + if (tex->imaflag & TEX_USEALPHA) { + if (tex->imaflag & TEX_CALCALPHA); else texres->talpha= 1; } texr.talpha= texres->talpha; - if(tex->imaflag & TEX_IMAROT) { + if (tex->imaflag & TEX_IMAROT) { fy= texvec[0]; fx= texvec[1]; } @@ -1468,9 +1468,9 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const fy= texvec[1]; } - if(ibuf->flags & IB_fields) { - if(R.r.mode & R_FIELDS) { /* field render */ - if(R.flag & R_SEC_FIELD) { /* correction for 2nd field */ + if (ibuf->flags & IB_fields) { + if (R.r.mode & R_FIELDS) { /* field render */ + if (R.flag & R_SEC_FIELD) { /* correction for 2nd field */ /* fac1= 0.5/( (float)ibuf->y ); */ /* fy-= fac1; */ } @@ -1491,16 +1491,16 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const minx= (maxx-minx)/2.0f; miny= (maxy-miny)/2.0f; - if(tex->imaflag & TEX_FILTER_MIN) { + if (tex->imaflag & TEX_FILTER_MIN) { /* make sure the filtersize is minimal in pixels (normal, ref map can have miniature pixel dx/dy) */ float addval= (0.5f * tex->filtersize) / (float) MIN2(ibuf->x, ibuf->y); - if(addval > minx) + if (addval > minx) minx= addval; - if(addval > miny) + if (addval > miny) miny= addval; } - else if(tex->filtersize!=1.0f) { + else if (tex->filtersize!=1.0f) { minx*= tex->filtersize; miny*= tex->filtersize; @@ -1510,33 +1510,33 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const dyt[1]*= tex->filtersize; } - if(tex->imaflag & TEX_IMAROT) SWAP(float, minx, miny); + if (tex->imaflag & TEX_IMAROT) SWAP(float, minx, miny); - if(minx>0.25f) minx= 0.25f; - else if(minx<0.00001f) minx= 0.00001f; /* side faces of unit-cube */ - if(miny>0.25f) miny= 0.25f; - else if(miny<0.00001f) miny= 0.00001f; + if (minx>0.25f) minx= 0.25f; + else if (minx<0.00001f) minx= 0.00001f; /* side faces of unit-cube */ + if (miny>0.25f) miny= 0.25f; + else if (miny<0.00001f) miny= 0.00001f; /* repeat and clip */ imaprepeat= (tex->extend==TEX_REPEAT); imapextend= (tex->extend==TEX_EXTEND); - if(tex->extend == TEX_REPEAT) { - if(tex->flag & (TEX_REPEAT_XMIR|TEX_REPEAT_YMIR)) { + if (tex->extend == TEX_REPEAT) { + if (tex->flag & (TEX_REPEAT_XMIR|TEX_REPEAT_YMIR)) { imaprepeat= 0; imapextend= 1; } } - if(tex->extend == TEX_CHECKER) { + if (tex->extend == TEX_CHECKER) { int xs, ys, xs1, ys1, xs2, ys2, boundary; xs= (int)floor(fx); ys= (int)floor(fy); // both checkers available, no boundary exceptions, checkerdist will eat aliasing - if( (tex->flag & TEX_CHECKER_ODD) && (tex->flag & TEX_CHECKER_EVEN) ) { + if ( (tex->flag & TEX_CHECKER_ODD) && (tex->flag & TEX_CHECKER_EVEN) ) { fx-= xs; fy-= ys; } @@ -1548,37 +1548,37 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const ys2= (int)floor(fy+miny); boundary= (xs1!=xs2) || (ys1!=ys2); - if(boundary==0) { - if( (tex->flag & TEX_CHECKER_ODD)==0) { - if((xs+ys) & 1); + if (boundary==0) { + if ( (tex->flag & TEX_CHECKER_ODD)==0) { + if ((xs+ys) & 1); else return retval; } - if( (tex->flag & TEX_CHECKER_EVEN)==0) { - if((xs+ys) & 1) return retval; + if ( (tex->flag & TEX_CHECKER_EVEN)==0) { + if ((xs+ys) & 1) return retval; } fx-= xs; fy-= ys; } else { - if(tex->flag & TEX_CHECKER_ODD) { - if((xs1+ys) & 1) fx-= xs2; + if (tex->flag & TEX_CHECKER_ODD) { + if ((xs1+ys) & 1) fx-= xs2; else fx-= xs1; - if((ys1+xs) & 1) fy-= ys2; + if ((ys1+xs) & 1) fy-= ys2; else fy-= ys1; } - if(tex->flag & TEX_CHECKER_EVEN) { - if((xs1+ys) & 1) fx-= xs1; + if (tex->flag & TEX_CHECKER_EVEN) { + if ((xs1+ys) & 1) fx-= xs1; else fx-= xs2; - if((ys1+xs) & 1) fy-= ys1; + if ((ys1+xs) & 1) fy-= ys1; else fy-= ys2; } } } /* scale around center, (0.5, 0.5) */ - if(tex->checkerdist<1.0f) { + if (tex->checkerdist<1.0f) { fx= (fx-0.5f)/(1.0f-tex->checkerdist) +0.5f; fy= (fy-0.5f)/(1.0f-tex->checkerdist) +0.5f; minx/= (1.0f-tex->checkerdist); @@ -1586,74 +1586,74 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const } } - if(tex->extend == TEX_CLIPCUBE) { - if(fx+minx<0.0f || fy+miny<0.0f || fx-minx>1.0f || fy-miny>1.0f || texvec[2]<-1.0f || texvec[2]>1.0f) { + if (tex->extend == TEX_CLIPCUBE) { + if (fx+minx<0.0f || fy+miny<0.0f || fx-minx>1.0f || fy-miny>1.0f || texvec[2]<-1.0f || texvec[2]>1.0f) { return retval; } } - else if(tex->extend==TEX_CLIP || tex->extend==TEX_CHECKER) { - if(fx+minx<0.0f || fy+miny<0.0f || fx-minx>1.0f || fy-miny>1.0f) { + else if (tex->extend==TEX_CLIP || tex->extend==TEX_CHECKER) { + if (fx+minx<0.0f || fy+miny<0.0f || fx-minx>1.0f || fy-miny>1.0f) { return retval; } } else { - if(imapextend) { - if(fx>1.0f) fx = 1.0f; - else if(fx<0.0f) fx= 0.0f; + if (imapextend) { + if (fx>1.0f) fx = 1.0f; + else if (fx<0.0f) fx= 0.0f; } else { - if(fx>1.0f) fx -= (int)(fx); - else if(fx<0.0f) fx+= 1-(int)(fx); + if (fx>1.0f) fx -= (int)(fx); + else if (fx<0.0f) fx+= 1-(int)(fx); } - if(imapextend) { - if(fy>1.0f) fy = 1.0f; - else if(fy<0.0f) fy= 0.0f; + if (imapextend) { + if (fy>1.0f) fy = 1.0f; + else if (fy<0.0f) fy= 0.0f; } else { - if(fy>1.0f) fy -= (int)(fy); - else if(fy<0.0f) fy+= 1-(int)(fy); + if (fy>1.0f) fy -= (int)(fy); + else if (fy<0.0f) fy+= 1-(int)(fy); } } /* warning no return! */ - if( (R.flag & R_SEC_FIELD) && (ibuf->flags & IB_fields) ) { + if ( (R.flag & R_SEC_FIELD) && (ibuf->flags & IB_fields) ) { ibuf->rect+= (ibuf->x*ibuf->y); } /* choice: */ - if(tex->imaflag & TEX_MIPMAP) { + if (tex->imaflag & TEX_MIPMAP) { ImBuf *previbuf, *curibuf; float bumpscale; dx= minx; dy= miny; maxd= MAX2(dx, dy); - if(maxd>0.5f) maxd= 0.5f; + if (maxd>0.5f) maxd= 0.5f; pixsize = 1.0f/ (float) MIN2(ibuf->x, ibuf->y); bumpscale= pixsize/maxd; - if(bumpscale>1.0f) bumpscale= 1.0f; + if (bumpscale>1.0f) bumpscale= 1.0f; else bumpscale*=bumpscale; curmap= 0; previbuf= curibuf= ibuf; while(curmap<IB_MIPMAP_LEVELS && ibuf->mipmap[curmap]) { - if(maxd < pixsize) break; + if (maxd < pixsize) break; previbuf= curibuf; curibuf= ibuf->mipmap[curmap]; pixsize= 1.0f / (float)MIN2(curibuf->x, curibuf->y); curmap++; } - if(previbuf!=curibuf || (tex->imaflag & TEX_INTERPOL)) { + if (previbuf!=curibuf || (tex->imaflag & TEX_INTERPOL)) { /* sample at least 1 pixel */ if (minx < 0.5f / ibuf->x) minx = 0.5f / ibuf->x; if (miny < 0.5f / ibuf->y) miny = 0.5f / ibuf->y; } - if(texres->nor && (tex->imaflag & TEX_NORMALMAP)==0) { + if (texres->nor && (tex->imaflag & TEX_NORMALMAP)==0) { /* a bit extra filter */ //minx*= 1.35f; //miny*= 1.35f; @@ -1669,13 +1669,13 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const texres->nor[0]= (val1-val2); texres->nor[1]= (val1-val3); - if(previbuf!=curibuf) { /* interpolate */ + if (previbuf!=curibuf) { /* interpolate */ boxsample(previbuf, fx-minx, fy-miny, fx+minx, fy+miny, &texr, imaprepeat, imapextend); /* calc rgb */ dx= 2.0f*(pixsize-maxd)/pixsize; - if(dx>=1.0f) { + if (dx>=1.0f) { texres->ta= texr.ta; texres->tb= texr.tb; texres->tg= texr.tg; texres->tr= texr.tr; } @@ -1696,7 +1696,7 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const texres->nor[0]= (val1-val2); /* vals have been interpolated above! */ texres->nor[1]= (val1-val3); - if(dx<1.0f) { + if (dx<1.0f) { dy= 1.0f-dx; texres->tb= dy*texres->tb+ dx*texr.tb; texres->tg= dy*texres->tg+ dx*texr.tg; @@ -1715,15 +1715,16 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const boxsample(curibuf, minx, miny, maxx, maxy, texres, imaprepeat, imapextend); - if(previbuf!=curibuf) { /* interpolate */ + if (previbuf!=curibuf) { /* interpolate */ boxsample(previbuf, minx, miny, maxx, maxy, &texr, imaprepeat, imapextend); fx= 2.0f*(pixsize-maxd)/pixsize; - if(fx>=1.0f) { + if (fx>=1.0f) { texres->ta= texr.ta; texres->tb= texr.tb; texres->tg= texr.tg; texres->tr= texr.tr; - } else { + } + else { fy= 1.0f-fx; texres->tb= fy*texres->tb+ fx*texr.tb; texres->tg= fy*texres->tg+ fx*texr.tg; @@ -1741,7 +1742,7 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const if (miny < 0.5f / ibuf->y) miny = 0.5f / ibuf->y; } - if(texres->nor && (tex->imaflag & TEX_NORMALMAP)==0) { + if (texres->nor && (tex->imaflag & TEX_NORMALMAP)==0) { boxsample(ibuf, fx-minx, fy-miny, fx+minx, fy+miny, texres, imaprepeat, imapextend); val1= texres->tr+texres->tg+texres->tb; boxsample(ibuf, fx-minx+dxt[0], fy-miny+dxt[1], fx+minx+dxt[0], fy+miny+dxt[1], &texr, imaprepeat, imapextend); @@ -1757,18 +1758,18 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const boxsample(ibuf, fx-minx, fy-miny, fx+minx, fy+miny, texres, imaprepeat, imapextend); } - if(tex->imaflag & TEX_CALCALPHA) { + if (tex->imaflag & TEX_CALCALPHA) { texres->ta= texres->tin= texres->ta*MAX3(texres->tr, texres->tg, texres->tb); } else texres->tin= texres->ta; - if(tex->flag & TEX_NEGALPHA) texres->ta= 1.0f-texres->ta; + if (tex->flag & TEX_NEGALPHA) texres->ta= 1.0f-texres->ta; - if( (R.flag & R_SEC_FIELD) && (ibuf->flags & IB_fields) ) { + if ( (R.flag & R_SEC_FIELD) && (ibuf->flags & IB_fields) ) { ibuf->rect-= (ibuf->x*ibuf->y); } - if(texres->nor && (tex->imaflag & TEX_NORMALMAP)) { + if (texres->nor && (tex->imaflag & TEX_NORMALMAP)) { // qdn: normal from color // The invert of the red channel is to make // the normal map compliant with the outside world. @@ -1782,7 +1783,7 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const } /* de-premul, this is being premulled in shade_input_do_shade() */ - if(texres->ta!=1.0f && texres->ta>1e-4f) { + if (texres->ta!=1.0f && texres->ta>1e-4f) { fx= 1.0f/texres->ta; texres->tr*= fx; texres->tg*= fx; @@ -1799,12 +1800,12 @@ void image_sample(Image *ima, float fx, float fy, float dx, float dy, float *res TexResult texres; ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL); - if(ibuf==NULL) { + if (ibuf==NULL) { result[0]= result[1]= result[2]= result[3]= 0.0f; return; } - if( (R.flag & R_SEC_FIELD) && (ibuf->flags & IB_fields) ) + if ( (R.flag & R_SEC_FIELD) && (ibuf->flags & IB_fields) ) ibuf->rect+= (ibuf->x*ibuf->y); texres.talpha= 1; /* boxsample expects to be initialized */ @@ -1814,7 +1815,7 @@ void image_sample(Image *ima, float fx, float fy, float dx, float dy, float *res result[2]= texres.tb; result[3]= texres.ta; - if( (R.flag & R_SEC_FIELD) && (ibuf->flags & IB_fields) ) + if ( (R.flag & R_SEC_FIELD) && (ibuf->flags & IB_fields) ) ibuf->rect-= (ibuf->x*ibuf->y); ima->flag|= IMA_USED_FOR_RENDER; @@ -1825,7 +1826,7 @@ void ibuf_sample(ImBuf *ibuf, float fx, float fy, float dx, float dy, float *res TexResult texres; afdata_t AFD; - if(ibuf==NULL) { + if (ibuf==NULL) { return; } diff --git a/source/blender/render/intern/source/initrender.c b/source/blender/render/intern/source/initrender.c index 9b68d28e0cf..f7f592c9407 100644 --- a/source/blender/render/intern/source/initrender.c +++ b/source/blender/render/intern/source/initrender.c @@ -92,7 +92,7 @@ static void init_render_jit(Render *re) static int lastjit= 0; static int last_mblur_jit= 0; - if(lastjit!=re->r.osa || last_mblur_jit != re->r.mblur_samples) { + if (lastjit!=re->r.osa || last_mblur_jit != re->r.mblur_samples) { memset(jit, 0, sizeof(jit)); BLI_initjit(jit[0], re->r.osa); @@ -169,11 +169,11 @@ float RE_filter_value(int type, float x) switch(type) { case R_FILTER_BOX: - if(x>1.0f) return 0.0f; + if (x>1.0f) return 0.0f; return 1.0f; case R_FILTER_TENT: - if(x>1.0f) return 0.0f; + if (x>1.0f) return 0.0f; return 1.0f-x; case R_FILTER_GAUSS: @@ -200,7 +200,7 @@ static float calc_weight(Render *re, float *weight, int i, int j) float x, y, dist, totw= 0.0; int a; - for(a=0; a<re->osa; a++) { + for (a=0; a<re->osa; a++) { x= re->jit[a][0] + i; y= re->jit[a][1] + j; dist= sqrt(x*x+y*y); @@ -210,11 +210,11 @@ static float calc_weight(Render *re, float *weight, int i, int j) /* Weighting choices */ switch(re->r.filtertype) { case R_FILTER_BOX: - if(i==0 && j==0) weight[a]= 1.0; + if (i==0 && j==0) weight[a]= 1.0; break; case R_FILTER_TENT: - if(dist < re->r.gauss) + if (dist < re->r.gauss) weight[a]= re->r.gauss - dist; break; @@ -251,8 +251,8 @@ void free_sample_tables(Render *re) { int a; - if(re->samples) { - for(a=0; a<9; a++) { + if (re->samples) { + for (a=0; a<9; a++) { MEM_freeN(re->samples->fmask1[a]); MEM_freeN(re->samples->fmask2[a]); } @@ -273,7 +273,7 @@ void make_sample_tables(Render *re) int i, j, a; /* optimization tables, only once */ - if(firsttime) { + if (firsttime) { firsttime= 0; } @@ -281,7 +281,7 @@ void make_sample_tables(Render *re) init_render_jit(re); /* needed for mblur too */ - if(re->osa==0) { + if (re->osa==0) { /* just prevents cpu cycles for larger render and copying */ re->r.filtertype= 0; return; @@ -289,78 +289,78 @@ void make_sample_tables(Render *re) st= re->samples= MEM_callocN(sizeof(SampleTables), "sample tables"); - for(a=0; a<9;a++) { + for (a=0; a<9;a++) { st->fmask1[a]= MEM_callocN(256*sizeof(float), "initfilt"); st->fmask2[a]= MEM_callocN(256*sizeof(float), "initfilt"); } - for(a=0; a<256; a++) { + for (a=0; a<256; a++) { st->cmask[a]= 0; - if(a & 1) st->cmask[a]++; - if(a & 2) st->cmask[a]++; - if(a & 4) st->cmask[a]++; - if(a & 8) st->cmask[a]++; - if(a & 16) st->cmask[a]++; - if(a & 32) st->cmask[a]++; - if(a & 64) st->cmask[a]++; - if(a & 128) st->cmask[a]++; + if (a & 1) st->cmask[a]++; + if (a & 2) st->cmask[a]++; + if (a & 4) st->cmask[a]++; + if (a & 8) st->cmask[a]++; + if (a & 16) st->cmask[a]++; + if (a & 32) st->cmask[a]++; + if (a & 64) st->cmask[a]++; + if (a & 128) st->cmask[a]++; } st->centmask= MEM_mallocN((1<<re->osa), "Initfilt3"); - for(a=0; a<16; a++) { + for (a=0; a<16; a++) { st->centLut[a]= -0.45f+((float)a)/16.0f; } /* calculate totw */ totw= 0.0; - for(j= -1; j<2; j++) { - for(i= -1; i<2; i++) { + for (j= -1; j<2; j++) { + for (i= -1; i<2; i++) { totw+= calc_weight(re, weight, i, j); } } - for(j= -1; j<2; j++) { - for(i= -1; i<2; i++) { + for (j= -1; j<2; j++) { + for (i= -1; i<2; i++) { /* calculate using jit, with offset the weights */ memset(weight, 0, sizeof(weight)); calc_weight(re, weight, i, j); - for(a=0; a<16; a++) flweight[a]= weight[a]*(1.0f/totw); + for (a=0; a<16; a++) flweight[a]= weight[a]*(1.0f/totw); m3= st->fmask1[ 3*(j+1)+i+1 ]; m4= st->fmask2[ 3*(j+1)+i+1 ]; - for(a=0; a<256; a++) { - if(a & 1) { + for (a=0; a<256; a++) { + if (a & 1) { m3[a]+= flweight[0]; m4[a]+= flweight[8]; } - if(a & 2) { + if (a & 2) { m3[a]+= flweight[1]; m4[a]+= flweight[9]; } - if(a & 4) { + if (a & 4) { m3[a]+= flweight[2]; m4[a]+= flweight[10]; } - if(a & 8) { + if (a & 8) { m3[a]+= flweight[3]; m4[a]+= flweight[11]; } - if(a & 16) { + if (a & 16) { m3[a]+= flweight[4]; m4[a]+= flweight[12]; } - if(a & 32) { + if (a & 32) { m3[a]+= flweight[5]; m4[a]+= flweight[13]; } - if(a & 64) { + if (a & 64) { m3[a]+= flweight[6]; m4[a]+= flweight[14]; } - if(a & 128) { + if (a & 128) { m3[a]+= flweight[7]; m4[a]+= flweight[15]; } @@ -374,52 +374,52 @@ void make_sample_tables(Render *re) fpx2= MEM_mallocN(256*sizeof(float), "initgauss4"); fpy1= MEM_mallocN(256*sizeof(float), "initgauss4"); fpy2= MEM_mallocN(256*sizeof(float), "initgauss4"); - for(a=0; a<256; a++) { + for (a=0; a<256; a++) { fpx1[a]= fpx2[a]= 0.0; fpy1[a]= fpy2[a]= 0.0; - if(a & 1) { + if (a & 1) { fpx1[a]+= re->jit[0][0]; fpy1[a]+= re->jit[0][1]; fpx2[a]+= re->jit[8][0]; fpy2[a]+= re->jit[8][1]; } - if(a & 2) { + if (a & 2) { fpx1[a]+= re->jit[1][0]; fpy1[a]+= re->jit[1][1]; fpx2[a]+= re->jit[9][0]; fpy2[a]+= re->jit[9][1]; } - if(a & 4) { + if (a & 4) { fpx1[a]+= re->jit[2][0]; fpy1[a]+= re->jit[2][1]; fpx2[a]+= re->jit[10][0]; fpy2[a]+= re->jit[10][1]; } - if(a & 8) { + if (a & 8) { fpx1[a]+= re->jit[3][0]; fpy1[a]+= re->jit[3][1]; fpx2[a]+= re->jit[11][0]; fpy2[a]+= re->jit[11][1]; } - if(a & 16) { + if (a & 16) { fpx1[a]+= re->jit[4][0]; fpy1[a]+= re->jit[4][1]; fpx2[a]+= re->jit[12][0]; fpy2[a]+= re->jit[12][1]; } - if(a & 32) { + if (a & 32) { fpx1[a]+= re->jit[5][0]; fpy1[a]+= re->jit[5][1]; fpx2[a]+= re->jit[13][0]; fpy2[a]+= re->jit[13][1]; } - if(a & 64) { + if (a & 64) { fpx1[a]+= re->jit[6][0]; fpy1[a]+= re->jit[6][1]; fpx2[a]+= re->jit[14][0]; fpy2[a]+= re->jit[14][1]; } - if(a & 128) { + if (a & 128) { fpx1[a]+= re->jit[7][0]; fpy1[a]+= re->jit[7][1]; fpx2[a]+= re->jit[15][0]; @@ -427,7 +427,7 @@ void make_sample_tables(Render *re) } } - for(a= (1<<re->osa)-1; a>0; a--) { + for (a= (1<<re->osa)-1; a>0; a--) { val= st->cmask[a & 255] + st->cmask[a>>8]; i= 8+(15.9f*(fpy1[a & 255]+fpy2[a>>8])/val); CLAMP(i, 0, 15); @@ -531,9 +531,9 @@ void freeparts(Render *re) { RenderPart *part= re->parts.first; - while(part) { - if(part->rectp) MEM_freeN(part->rectp); - if(part->rectz) MEM_freeN(part->rectz); + while (part) { + if (part->rectp) MEM_freeN(part->rectp); + if (part->rectz) MEM_freeN(part->rectz); part= part->next; } BLI_freelistN(&re->parts); @@ -561,16 +561,16 @@ void initparts(Render *re) yparts= re->r.yparts; /* mininum part size, but for exr tile saving it was checked already */ - if(!(re->r.scemode & (R_EXR_TILE_FILE|R_FULL_SAMPLE))) { - if(re->r.mode & R_PANORAMA) { - if(ceil(re->rectx/(float)xparts) < 8) + if (!(re->r.scemode & (R_EXR_TILE_FILE|R_FULL_SAMPLE))) { + if (re->r.mode & R_PANORAMA) { + if (ceil(re->rectx/(float)xparts) < 8) xparts= 1 + re->rectx/8; } else - if(ceil(re->rectx/(float)xparts) < 64) + if (ceil(re->rectx/(float)xparts) < 64) xparts= 1 + re->rectx/64; - if(ceil(re->recty/(float)yparts) < 64) + if (ceil(re->recty/(float)yparts) < 64) yparts= 1 + re->recty/64; } @@ -584,10 +584,10 @@ void initparts(Render *re) re->party= party; /* calculate rotation factor of 1 pixel */ - if(re->r.mode & R_PANORAMA) + if (re->r.mode & R_PANORAMA) re->panophi= panorama_pixel_rot(re); - for(nr=0; nr<xparts*yparts; nr++) { + for (nr=0; nr<xparts*yparts; nr++) { rcti disprect; int rectx, recty; @@ -598,16 +598,16 @@ void initparts(Render *re) disprect.ymin = yminb+ yd*party; /* ensure we cover the entire picture, so last parts go to end */ - if(xd<xparts-1) { + if (xd<xparts-1) { disprect.xmax = disprect.xmin + partx; - if(disprect.xmax > xmaxb) + if (disprect.xmax > xmaxb) disprect.xmax = xmaxb; } else disprect.xmax = xmaxb; - if(yd<yparts-1) { + if (yd<yparts-1) { disprect.ymax = disprect.ymin + party; - if(disprect.ymax > ymaxb) + if (disprect.ymax > ymaxb) disprect.ymax = ymaxb; } else disprect.ymax = ymaxb; @@ -616,11 +616,11 @@ void initparts(Render *re) recty= disprect.ymax - disprect.ymin; /* so, now can we add this part? */ - if(rectx>0 && recty>0) { + if (rectx>0 && recty>0) { RenderPart *pa= MEM_callocN(sizeof(RenderPart), "new part"); /* Non-box filters need 2 pixels extra to work */ - if((re->r.filtertype || (re->r.mode & R_EDGE))) { + if ((re->r.filtertype || (re->r.mode & R_EDGE))) { pa->crop= 2; disprect.xmin -= pa->crop; disprect.ymin -= pa->crop; diff --git a/source/blender/render/intern/source/occlusion.c b/source/blender/render/intern/source/occlusion.c index 6ebd84d6635..532d384ec26 100644 --- a/source/blender/render/intern/source/occlusion.c +++ b/source/blender/render/intern/source/occlusion.c @@ -148,7 +148,7 @@ static void occ_shade(ShadeSample *ssamp, ObjectInstanceRen *obi, VlakRen *vlr, float l, u, v, *v1, *v2, *v3; /* init */ - if(vlr->v4) { + if (vlr->v4) { shi->u= u= 0.5f; shi->v= v= 0.5f; } @@ -184,13 +184,13 @@ static void occ_shade(ShadeSample *ssamp, ObjectInstanceRen *obi, VlakRen *vlr, shade_input_set_normals(shi); /* no normal flip */ - if(shi->flippednor) + if (shi->flippednor) shade_input_flip_normals(shi); madd_v3_v3fl(shi->co, shi->vn, 0.0001f); /* ugly.. */ /* not a pretty solution, but fixes common cases */ - if(shi->obr->ob && shi->obr->ob->transflag & OB_NEG_SCALE) { + if (shi->obr->ob && shi->obr->ob->transflag & OB_NEG_SCALE) { negate_v3(shi->vn); negate_v3(shi->vno); negate_v3(shi->nmapnorm); @@ -224,7 +224,7 @@ static void occ_build_shade(Render *re, OcclusionTree *tree) ssamp.shi[0].combinedflag= ~(SCE_PASS_SPEC); ssamp.tot= 1; - for(a=0; a<tree->totface; a++) { + for (a=0; a<tree->totface; a++) { obi= &R.objectinstance[tree->face[a].obi]; vlr= RE_findOrAddVlak(obi->obr, tree->face[a].facenr); @@ -248,7 +248,7 @@ static void sh_mul(float *sh, float f) { int i; - for(i=0; i<9; i++) + for (i=0; i<9; i++) sh[i] *= f; } @@ -256,7 +256,7 @@ static void sh_add(float *shresult, float *sh1, float *sh2) { int i; - for(i=0; i<9; i++) + for (i=0; i<9; i++) shresult[i]= sh1[i] + sh2[i]; } @@ -319,40 +319,40 @@ static void occ_face(const OccFace *face, float co[3], float normal[3], float *a obi= &R.objectinstance[face->obi]; vlr= RE_findOrAddVlak(obi->obr, face->facenr); - if(co) { - if(vlr->v4) + if (co) { + if (vlr->v4) mid_v3_v3v3(co, vlr->v1->co, vlr->v3->co); else cent_tri_v3(co, vlr->v1->co, vlr->v2->co, vlr->v3->co); - if(obi->flag & R_TRANSFORMED) + if (obi->flag & R_TRANSFORMED) mul_m4_v3(obi->mat, co); } - if(normal) { + if (normal) { normal[0]= -vlr->n[0]; normal[1]= -vlr->n[1]; normal[2]= -vlr->n[2]; - if(obi->flag & R_TRANSFORMED) + if (obi->flag & R_TRANSFORMED) mul_m3_v3(obi->nmat, normal); } - if(area) { + if (area) { copy_v3_v3(v1, vlr->v1->co); copy_v3_v3(v2, vlr->v2->co); copy_v3_v3(v3, vlr->v3->co); - if(vlr->v4) copy_v3_v3(v4, vlr->v4->co); + if (vlr->v4) copy_v3_v3(v4, vlr->v4->co); - if(obi->flag & R_TRANSFORMED) { + if (obi->flag & R_TRANSFORMED) { mul_m4_v3(obi->mat, v1); mul_m4_v3(obi->mat, v2); mul_m4_v3(obi->mat, v3); - if(vlr->v4) mul_m4_v3(obi->mat, v4); + if (vlr->v4) mul_m4_v3(obi->mat, v4); } /* todo: correct area for instances */ - if(vlr->v4) + if (vlr->v4) *area= area_quad_v3(v1, v2, v3, v4); else *area= area_tri_v3(v1, v2, v3); @@ -367,33 +367,33 @@ static void occ_sum_occlusion(OcclusionTree *tree, OccNode *node) occ= 0.0f; totarea= 0.0f; - if(indirect) zero_v3(rad); + if (indirect) zero_v3(rad); - for(b=0; b<TOTCHILD; b++) { - if(node->childflag & (1<<b)) { + for (b=0; b<TOTCHILD; b++) { + if (node->childflag & (1<<b)) { a= node->child[b].face; occ_face(&tree->face[a], 0, 0, &area); occ += area*tree->occlusion[a]; - if(indirect) madd_v3_v3fl(rad, tree->rad[a], area); + if (indirect) madd_v3_v3fl(rad, tree->rad[a], area); totarea += area; } - else if(node->child[b].node) { + else if (node->child[b].node) { child= node->child[b].node; occ_sum_occlusion(tree, child); occ += child->area*child->occlusion; - if(indirect) madd_v3_v3fl(rad, child->rad, child->area); + if (indirect) madd_v3_v3fl(rad, child->rad, child->area); totarea += child->area; } } - if(totarea != 0.0f) { + if (totarea != 0.0f) { occ /= totarea; - if(indirect) mul_v3_fl(rad, 1.0f/totarea); + if (indirect) mul_v3_fl(rad, 1.0f/totarea); } node->occlusion= occ; - if(indirect) copy_v3_v3(node->rad, rad); + if (indirect) copy_v3_v3(node->rad, rad); } static int occ_find_bbox_axis(OcclusionTree *tree, int begin, int end, float *min, float *max) @@ -407,10 +407,10 @@ static int occ_find_bbox_axis(OcclusionTree *tree, int begin, int end, float *mi DO_MINMAX(tree->co[a], min, max); } - for(a=0; a<3; a++) { + for (a=0; a<3; a++) { len= max[a] - min[a]; - if(len > maxlen) { + if (len > maxlen) { maxlen= len; axis= a; } @@ -431,13 +431,13 @@ static void occ_node_from_face(OccFace *face, OccNode *node) static void occ_build_dco(OcclusionTree *tree, OccNode *node, const float co[3], float *dco) { int b; - for(b=0; b<TOTCHILD; b++) { + for (b=0; b<TOTCHILD; b++) { float dist, d[3], nco[3]; - if(node->childflag & (1<<b)) { + if (node->childflag & (1<<b)) { occ_face(tree->face+node->child[b].face, nco, NULL, NULL); } - else if(node->child[b].node) { + else if (node->child[b].node) { OccNode *child= node->child[b].node; occ_build_dco(tree, child, co, dco); copy_v3_v3(nco, child->co); @@ -448,7 +448,7 @@ static void occ_build_dco(OcclusionTree *tree, OccNode *node, const float co[3], sub_v3_v3v3(d, nco, co); dist= dot_v3v3(d, d); - if(dist > *dco) + if (dist > *dco) *dco= dist; } } @@ -467,7 +467,7 @@ static void occ_build_split(OcclusionTree *tree, int begin, int end, int *split) a= begin; enda= end; while(a<enda) { - if(tree->co[a][axis] > mid) { + if (tree->co[a][axis] > mid) { enda--; SWAP(OccFace, tree->face[a], tree->face[enda]); SWAP(float, tree->co[a][0], tree->co[enda][0]); @@ -489,7 +489,7 @@ static void occ_build_8_split(OcclusionTree *tree, int begin, int end, int *offs occ_build_split(tree, begin, end, &splitx); /* force split if none found, to deal with degenerate geometry */ - if(splitx == begin || splitx == end) + if (splitx == begin || splitx == end) splitx= (begin+end)/2; occ_build_split(tree, begin, splitx, &splity[0]); @@ -509,7 +509,7 @@ static void occ_build_8_split(OcclusionTree *tree, int begin, int end, int *offs offset[6]= splity[1]; offset[7]= splitz[3]; - for(b=0; b<7; b++) + for (b=0; b<7; b++) count[b]= offset[b+1] - offset[b]; count[7]= end - offset[7]; } @@ -537,8 +537,8 @@ static void occ_build_recursive(OcclusionTree *tree, OccNode *node, int begin, i node->occlusion= 1.0f; /* leaf node with only children */ - if(end - begin <= TOTCHILD) { - for(a=begin, b=0; a<end; a++, b++) { + if (end - begin <= TOTCHILD) { + for (a=begin, b=0; a<end; a++, b++) { /* face= &tree->face[a]; */ node->child[b].face= a; node->childflag |= (1<<b); @@ -548,33 +548,33 @@ static void occ_build_recursive(OcclusionTree *tree, OccNode *node, int begin, i /* order faces */ occ_build_8_split(tree, begin, end, offset, count); - if(depth == 1 && tree->dothreadedbuild) + if (depth == 1 && tree->dothreadedbuild) BLI_init_threads(&threads, exec_occ_build, tree->totbuildthread); - for(b=0; b<TOTCHILD; b++) { - if(count[b] == 0) { + for (b=0; b<TOTCHILD; b++) { + if (count[b] == 0) { node->child[b].node= NULL; } - else if(count[b] == 1) { + else if (count[b] == 1) { /* face= &tree->face[offset[b]]; */ node->child[b].face= offset[b]; node->childflag |= (1<<b); } else { - if(tree->dothreadedbuild) + if (tree->dothreadedbuild) BLI_lock_thread(LOCK_CUSTOM1); child= BLI_memarena_alloc(tree->arena, sizeof(OccNode)); node->child[b].node= child; /* keep track of maximum depth for stack */ - if(depth+1 > tree->maxdepth) + if (depth+1 > tree->maxdepth) tree->maxdepth= depth+1; - if(tree->dothreadedbuild) + if (tree->dothreadedbuild) BLI_unlock_thread(LOCK_CUSTOM1); - if(depth == 1 && tree->dothreadedbuild) { + if (depth == 1 && tree->dothreadedbuild) { othreads[totthread].tree= tree; othreads[totthread].node= child; othreads[totthread].begin= offset[b]; @@ -588,13 +588,13 @@ static void occ_build_recursive(OcclusionTree *tree, OccNode *node, int begin, i } } - if(depth == 1 && tree->dothreadedbuild) + if (depth == 1 && tree->dothreadedbuild) BLI_end_threads(&threads); } /* combine area, position and sh */ - for(b=0; b<TOTCHILD; b++) { - if(node->childflag & (1<<b)) { + for (b=0; b<TOTCHILD; b++) { + if (node->childflag & (1<<b)) { child= &tmpnode; occ_node_from_face(tree->face+node->child[b].face, &tmpnode); } @@ -602,19 +602,19 @@ static void occ_build_recursive(OcclusionTree *tree, OccNode *node, int begin, i child= node->child[b].node; } - if(child) { + if (child) { node->area += child->area; sh_add(node->sh, node->sh, child->sh); madd_v3_v3fl(node->co, child->co, child->area); } } - if(node->area != 0.0f) + if (node->area != 0.0f) mul_v3_fl(node->co, 1.0f/node->area); /* compute maximum distance from center */ node->dco= 0.0f; - if(node->area > 0.0f) + if (node->area > 0.0f) occ_build_dco(tree, node, node->co, &node->dco); } @@ -624,12 +624,12 @@ static void occ_build_sh_normalize(OccNode *node) * we can clamp the dot product and then mutliply by area */ int b; - if(node->area != 0.0f) + if (node->area != 0.0f) sh_mul(node->sh, 1.0f/node->area); - for(b=0; b<TOTCHILD; b++) { - if(node->childflag & (1<<b)); - else if(node->child[b].node) + for (b=0; b<TOTCHILD; b++) { + if (node->childflag & (1<<b)); + else if (node->child[b].node) occ_build_sh_normalize(node->child[b].node); } } @@ -645,20 +645,20 @@ static OcclusionTree *occ_tree_build(Render *re) /* count */ totface= 0; - for(obi=re->instancetable.first; obi; obi=obi->next) { + for (obi=re->instancetable.first; obi; obi=obi->next) { obr= obi->obr; - for(a=0; a<obr->totvlak; a++) { - if((a & 255)==0) vlr= obr->vlaknodes[a>>8].vlak; + for (a=0; a<obr->totvlak; a++) { + if ((a & 255)==0) vlr= obr->vlaknodes[a>>8].vlak; else vlr++; ma= vlr->mat; - if((ma->shade_flag & MA_APPROX_OCCLUSION) && (ma->material_type == MA_TYPE_SURFACE)) + if ((ma->shade_flag & MA_APPROX_OCCLUSION) && (ma->material_type == MA_TYPE_SURFACE)) totface++; } } - if(totface == 0) + if (totface == 0) return NULL; tree= MEM_callocN(sizeof(OcclusionTree), "OcclusionTree"); @@ -673,26 +673,26 @@ static OcclusionTree *occ_tree_build(Render *re) tree->arena= BLI_memarena_new(0x8000 * sizeof(OccNode), "occ tree arena"); BLI_memarena_use_calloc(tree->arena); - if(re->wrld.aomode & WO_AOCACHE) + if (re->wrld.aomode & WO_AOCACHE) tree->cache= MEM_callocN(sizeof(OcclusionCache)*BLENDER_MAX_THREADS, "OcclusionCache"); tree->face= MEM_callocN(sizeof(OccFace)*totface, "OcclusionFace"); tree->co= MEM_callocN(sizeof(float)*3*totface, "OcclusionCo"); tree->occlusion= MEM_callocN(sizeof(float)*totface, "OcclusionOcclusion"); - if(tree->doindirect) + if (tree->doindirect) tree->rad= MEM_callocN(sizeof(float)*3*totface, "OcclusionRad"); /* make array of face pointers */ - for(b=0, c=0, obi=re->instancetable.first; obi; obi=obi->next, c++) { + for (b=0, c=0, obi=re->instancetable.first; obi; obi=obi->next, c++) { obr= obi->obr; - for(a=0; a<obr->totvlak; a++) { - if((a & 255)==0) vlr= obr->vlaknodes[a>>8].vlak; + for (a=0; a<obr->totvlak; a++) { + if ((a & 255)==0) vlr= obr->vlaknodes[a>>8].vlak; else vlr++; ma= vlr->mat; - if((ma->shade_flag & MA_APPROX_OCCLUSION) && (ma->material_type == MA_TYPE_SURFACE)) { + if ((ma->shade_flag & MA_APPROX_OCCLUSION) && (ma->material_type == MA_TYPE_SURFACE)) { tree->face[b].obi= c; tree->face[b].facenr= a; tree->occlusion[b]= 1.0f; @@ -711,7 +711,7 @@ static OcclusionTree *occ_tree_build(Render *re) tree->maxdepth= 1; occ_build_recursive(tree, tree->root, 0, totface, 1); - if(tree->doindirect) { + if (tree->doindirect) { occ_build_shade(re, tree); occ_sum_occlusion(tree, tree->root); } @@ -721,7 +721,7 @@ static OcclusionTree *occ_tree_build(Render *re) occ_build_sh_normalize(tree->root); - for(a=0; a<BLENDER_MAX_THREADS; a++) + for (a=0; a<BLENDER_MAX_THREADS; a++) tree->stack[a]= MEM_callocN(sizeof(OccNode)*TOTCHILD*(tree->maxdepth+1), "OccStack"); return tree; @@ -731,15 +731,15 @@ static void occ_free_tree(OcclusionTree *tree) { int a; - if(tree) { - if(tree->arena) BLI_memarena_free(tree->arena); - for(a=0; a<BLENDER_MAX_THREADS; a++) - if(tree->stack[a]) + if (tree) { + if (tree->arena) BLI_memarena_free(tree->arena); + for (a=0; a<BLENDER_MAX_THREADS; a++) + if (tree->stack[a]) MEM_freeN(tree->stack[a]); - if(tree->occlusion) MEM_freeN(tree->occlusion); - if(tree->cache) MEM_freeN(tree->cache); - if(tree->face) MEM_freeN(tree->face); - if(tree->rad) MEM_freeN(tree->rad); + if (tree->occlusion) MEM_freeN(tree->occlusion); + if (tree->cache) MEM_freeN(tree->cache); + if (tree->face) MEM_freeN(tree->face); + if (tree->rad) MEM_freeN(tree->rad); MEM_freeN(tree); } } @@ -782,20 +782,20 @@ static int occ_visible_quad(float *p, const float n[3], const float v0[3], const sd[1]= dot_v3v3(n, v1) - c; sd[2]= dot_v3v3(n, v2) - c; - if(fabsf(sd[0]) < epsilon) sd[0] = 0.0f; - if(fabsf(sd[1]) < epsilon) sd[1] = 0.0f; - if(fabsf(sd[2]) < epsilon) sd[2] = 0.0f; + if (fabsf(sd[0]) < epsilon) sd[0] = 0.0f; + if (fabsf(sd[1]) < epsilon) sd[1] = 0.0f; + if (fabsf(sd[2]) < epsilon) sd[2] = 0.0f; - if(sd[0] > 0) { - if(sd[1] > 0) { - if(sd[2] > 0) { + if (sd[0] > 0) { + if (sd[1] > 0) { + if (sd[2] > 0) { // +++ copy_v3_v3(q0, v0); copy_v3_v3(q1, v1); copy_v3_v3(q2, v2); copy_v3_v3(q3, q2); } - else if(sd[2] < 0) { + else if (sd[2] < 0) { // ++- copy_v3_v3(q0, v0); copy_v3_v3(q1, v1); @@ -810,15 +810,15 @@ static int occ_visible_quad(float *p, const float n[3], const float v0[3], const copy_v3_v3(q3, q2); } } - else if(sd[1] < 0) { - if(sd[2] > 0) { + else if (sd[1] < 0) { + if (sd[2] > 0) { // +-+ copy_v3_v3(q0, v0); VecAddDir(q1, v0, v1, (sd[0]/(sd[0]-sd[1]))); VecAddDir(q2, v1, v2, (sd[1]/(sd[1]-sd[2]))); copy_v3_v3(q3, v2); } - else if(sd[2] < 0) { + else if (sd[2] < 0) { // +-- copy_v3_v3(q0, v0); VecAddDir(q1, v0, v1, (sd[0]/(sd[0]-sd[1]))); @@ -834,14 +834,14 @@ static int occ_visible_quad(float *p, const float n[3], const float v0[3], const } } else { - if(sd[2] > 0) { + if (sd[2] > 0) { // +0+ copy_v3_v3(q0, v0); copy_v3_v3(q1, v1); copy_v3_v3(q2, v2); copy_v3_v3(q3, q2); } - else if(sd[2] < 0) { + else if (sd[2] < 0) { // +0- copy_v3_v3(q0, v0); copy_v3_v3(q1, v1); @@ -857,16 +857,16 @@ static int occ_visible_quad(float *p, const float n[3], const float v0[3], const } } } - else if(sd[0] < 0) { - if(sd[1] > 0) { - if(sd[2] > 0) { + else if (sd[0] < 0) { + if (sd[1] > 0) { + if (sd[2] > 0) { // -++ VecAddDir(q0, v0, v1, (sd[0]/(sd[0]-sd[1]))); copy_v3_v3(q1, v1); copy_v3_v3(q2, v2); VecAddDir(q3, v0, v2, (sd[0]/(sd[0]-sd[2]))); } - else if(sd[2] < 0) { + else if (sd[2] < 0) { // -+- VecAddDir(q0, v0, v1, (sd[0]/(sd[0]-sd[1]))); copy_v3_v3(q1, v1); @@ -881,15 +881,15 @@ static int occ_visible_quad(float *p, const float n[3], const float v0[3], const copy_v3_v3(q3, q2); } } - else if(sd[1] < 0) { - if(sd[2] > 0) { + else if (sd[1] < 0) { + if (sd[2] > 0) { // --+ VecAddDir(q0, v0, v2, (sd[0]/(sd[0]-sd[2]))); VecAddDir(q1, v1, v2, (sd[1]/(sd[1]-sd[2]))); copy_v3_v3(q2, v2); copy_v3_v3(q3, q2); } - else if(sd[2] < 0) { + else if (sd[2] < 0) { // --- return 0; } @@ -899,14 +899,14 @@ static int occ_visible_quad(float *p, const float n[3], const float v0[3], const } } else { - if(sd[2] > 0) { + if (sd[2] > 0) { // -0+ VecAddDir(q0, v0, v2, (sd[0]/(sd[0]-sd[2]))); copy_v3_v3(q1, v1); copy_v3_v3(q2, v2); copy_v3_v3(q3, q2); } - else if(sd[2] < 0) { + else if (sd[2] < 0) { // -0- return 0; } @@ -917,15 +917,15 @@ static int occ_visible_quad(float *p, const float n[3], const float v0[3], const } } else { - if(sd[1] > 0) { - if(sd[2] > 0) { + if (sd[1] > 0) { + if (sd[2] > 0) { // 0++ copy_v3_v3(q0, v0); copy_v3_v3(q1, v1); copy_v3_v3(q2, v2); copy_v3_v3(q3, q2); } - else if(sd[2] < 0) { + else if (sd[2] < 0) { // 0+- copy_v3_v3(q0, v0); copy_v3_v3(q1, v1); @@ -940,15 +940,15 @@ static int occ_visible_quad(float *p, const float n[3], const float v0[3], const copy_v3_v3(q3, q2); } } - else if(sd[1] < 0) { - if(sd[2] > 0) { + else if (sd[1] < 0) { + if (sd[2] > 0) { // 0-+ copy_v3_v3(q0, v0); VecAddDir(q1, v1, v2, (sd[1]/(sd[1]-sd[2]))); copy_v3_v3(q2, v2); copy_v3_v3(q3, q2); } - else if(sd[2] < 0) { + else if (sd[2] < 0) { // 0-- return 0; } @@ -958,14 +958,14 @@ static int occ_visible_quad(float *p, const float n[3], const float v0[3], const } } else { - if(sd[2] > 0) { + if (sd[2] > 0) { // 00+ copy_v3_v3(q0, v0); copy_v3_v3(q1, v1); copy_v3_v3(q2, v2); copy_v3_v3(q3, q2); } - else if(sd[2] < 0) { + else if (sd[2] < 0) { // 00- return 0; } @@ -991,20 +991,20 @@ typedef union { static vFloat vec_splat_float(float val) { - return (vFloat){val, val, val, val}; + return (vFloat) {val, val, val, val}; } static float occ_quad_form_factor(float *p, float *n, float *q0, float *q1, float *q2, float *q3) { vFloat vcos, rlen, vrx, vry, vrz, vsrx, vsry, vsrz, gx, gy, gz, vangle; - vUInt8 rotate = (vUInt8){4,5,6,7,8,9,10,11,12,13,14,15,0,1,2,3}; + vUInt8 rotate = (vUInt8) {4,5,6,7,8,9,10,11,12,13,14,15,0,1,2,3}; vFloatResult vresult; float result; /* compute r* */ - vrx = (vFloat){q0[0], q1[0], q2[0], q3[0]} - vec_splat_float(p[0]); - vry = (vFloat){q0[1], q1[1], q2[1], q3[1]} - vec_splat_float(p[1]); - vrz = (vFloat){q0[2], q1[2], q2[2], q3[2]} - vec_splat_float(p[2]); + vrx = (vFloat) {q0[0], q1[0], q2[0], q3[0]} - vec_splat_float(p[0]); + vry = (vFloat) {q0[1], q1[1], q2[1], q3[1]} - vec_splat_float(p[1]); + vrz = (vFloat) {q0[2], q1[2], q2[2], q3[2]} - vec_splat_float(p[2]); /* normalize r* */ rlen = vec_rsqrte(vrx*vrx + vry*vry + vrz*vrz + vec_splat_float(1e-16f)); @@ -1120,7 +1120,7 @@ static void normalizef(float *n) d= dot_v3v3(n, n); - if(d > 1.0e-35F) { + if (d > 1.0e-35F) { d= 1.0f/sqrtf(d); n[0] *= d; @@ -1178,21 +1178,21 @@ static float occ_form_factor(OccFace *face, float *p, float *n) copy_v3_v3(v2, vlr->v2->co); copy_v3_v3(v3, vlr->v3->co); - if(obi->flag & R_TRANSFORMED) { + if (obi->flag & R_TRANSFORMED) { mul_m4_v3(obi->mat, v1); mul_m4_v3(obi->mat, v2); mul_m4_v3(obi->mat, v3); } - if(occ_visible_quad(p, n, v1, v2, v3, q0, q1, q2, q3)) + if (occ_visible_quad(p, n, v1, v2, v3, q0, q1, q2, q3)) contrib += occ_quad_form_factor(p, n, q0, q1, q2, q3); - if(vlr->v4) { + if (vlr->v4) { copy_v3_v3(v4, vlr->v4->co); - if(obi->flag & R_TRANSFORMED) + if (obi->flag & R_TRANSFORMED) mul_m4_v3(obi->mat, v4); - if(occ_visible_quad(p, n, v1, v3, v4, q0, q1, q2, q3)) + if (occ_visible_quad(p, n, v1, v3, v4, q0, q1, q2, q3)) contrib += occ_quad_form_factor(p, n, q0, q1, q2, q3); } @@ -1212,7 +1212,7 @@ static void occ_lookup(OcclusionTree *tree, int thread, OccFace *exclude, float copy_v3_v3(n, pn); madd_v3_v3fl(p, n, 1e-4f); - if(bentn) + if (bentn) copy_v3_v3(bentn, n); error= tree->error; @@ -1234,10 +1234,10 @@ static void occ_lookup(OcclusionTree *tree, int thread, OccFace *exclude, float d2= dot_v3v3(v, v) + 1e-16f; emitarea= MAX2(node->area, node->dco); - if(d2*error > emitarea) { - if(distfac != 0.0f) { + if (d2*error > emitarea) { + if (distfac != 0.0f) { fac= 1.0f/(1.0f + distfac*d2); - if(fac < 0.01f) + if (fac < 0.01f) continue; } else @@ -1247,12 +1247,12 @@ static void occ_lookup(OcclusionTree *tree, int thread, OccFace *exclude, float invd2 = 1.0f/sqrtf(d2); weight= occ_solid_angle(node, v, d2, invd2, n); - if(rad) + if (rad) madd_v3_v3fl(resultrad, node->rad, weight*fac); weight *= node->occlusion; - if(bentn) { + if (bentn) { bentn[0] -= weight*invd2*v[0]; bentn[1] -= weight*invd2*v[1]; bentn[2] -= weight*invd2*v[2]; @@ -1262,20 +1262,20 @@ static void occ_lookup(OcclusionTree *tree, int thread, OccFace *exclude, float } else { /* traverse into children */ - for(b=0; b<TOTCHILD; b++) { - if(node->childflag & (1<<b)) { + for (b=0; b<TOTCHILD; b++) { + if (node->childflag & (1<<b)) { f= node->child[b].face; face= &tree->face[f]; /* accumulate occlusion with face form factor */ - if(!exclude || !(face->obi == exclude->obi && face->facenr == exclude->facenr)) { - if(bentn || distfac != 0.0f) { + if (!exclude || !(face->obi == exclude->obi && face->facenr == exclude->facenr)) { + if (bentn || distfac != 0.0f) { occ_face(face, co, NULL, NULL); sub_v3_v3v3(v, co, p); d2= dot_v3v3(v, v) + 1e-16f; fac= (distfac == 0.0f)? 1.0f: 1.0f/(1.0f + distfac*d2); - if(fac < 0.01f) + if (fac < 0.01f) continue; } else @@ -1283,12 +1283,12 @@ static void occ_lookup(OcclusionTree *tree, int thread, OccFace *exclude, float weight= occ_form_factor(face, p, n); - if(rad) + if (rad) madd_v3_v3fl(resultrad, tree->rad[f], weight*fac); weight *= tree->occlusion[f]; - if(bentn) { + if (bentn) { invd2= 1.0f/sqrtf(d2); bentn[0] -= weight*invd2*v[0]; bentn[1] -= weight*invd2*v[1]; @@ -1298,7 +1298,7 @@ static void occ_lookup(OcclusionTree *tree, int thread, OccFace *exclude, float resultocc += weight*fac; } } - else if(node->child[b].node) { + else if (node->child[b].node) { /* push child on the stack */ stack[totstack++]= node->child[b].node; } @@ -1306,17 +1306,17 @@ static void occ_lookup(OcclusionTree *tree, int thread, OccFace *exclude, float } } - if(occ) *occ= resultocc; - if(rad) copy_v3_v3(rad, resultrad); + if (occ) *occ= resultocc; + if (rad) copy_v3_v3(rad, resultrad); #if 0 - if(rad && exclude) { + if (rad && exclude) { int a; - for(a=0; a<tree->totface; a++) - if((tree->face[a].obi == exclude->obi && tree->face[a].facenr == exclude->facenr)) + for (a=0; a<tree->totface; a++) + if ((tree->face[a].obi == exclude->obi && tree->face[a].facenr == exclude->facenr)) copy_v3_v3(rad, tree->rad[a]); } #endif - if(bentn) normalize_v3(bentn); + if (bentn) normalize_v3(bentn); } static void occ_compute_bounces(Render *re, OcclusionTree *tree, int totbounce) @@ -1327,8 +1327,8 @@ static void occ_compute_bounces(Render *re, OcclusionTree *tree, int totbounce) rad= MEM_callocN(sizeof(float)*3*tree->totface, "OcclusionBounceRad"); sum= MEM_dupallocN(tree->rad); - for(bounce=1; bounce<totbounce; bounce++) { - for(i=0; i<tree->totface; i++) { + for (bounce=1; bounce<totbounce; bounce++) { + for (i=0; i<tree->totface; i++) { occ_face(&tree->face[i], co, n, NULL); madd_v3_v3fl(co, n, 1e-8f); @@ -1338,11 +1338,11 @@ static void occ_compute_bounces(Render *re, OcclusionTree *tree, int totbounce) rad[i][2]= MAX2(rad[i][2], 0.0f); add_v3_v3(sum[i], rad[i]); - if(re->test_break(re->tbh)) + if (re->test_break(re->tbh)) break; } - if(re->test_break(re->tbh)) + if (re->test_break(re->tbh)) break; tmp= tree->rad; @@ -1356,7 +1356,7 @@ static void occ_compute_bounces(Render *re, OcclusionTree *tree, int totbounce) MEM_freeN(tree->rad); tree->rad= sum; - if(!re->test_break(re->tbh)) + if (!re->test_break(re->tbh)) occ_sum_occlusion(tree, tree->root); } @@ -1367,23 +1367,23 @@ static void occ_compute_passes(Render *re, OcclusionTree *tree, int totpass) occ= MEM_callocN(sizeof(float)*tree->totface, "OcclusionPassOcc"); - for(pass=0; pass<totpass; pass++) { - for(i=0; i<tree->totface; i++) { + for (pass=0; pass<totpass; pass++) { + for (i=0; i<tree->totface; i++) { occ_face(&tree->face[i], co, n, NULL); negate_v3(n); madd_v3_v3fl(co, n, 1e-8f); occ_lookup(tree, 0, &tree->face[i], co, n, &occ[i], NULL, NULL); - if(re->test_break(re->tbh)) + if (re->test_break(re->tbh)) break; } - if(re->test_break(re->tbh)) + if (re->test_break(re->tbh)) break; - for(i=0; i<tree->totface; i++) { + for (i=0; i<tree->totface; i++) { tree->occlusion[i] -= occ[i]; //MAX2(1.0f-occ[i], 0.0f); - if(tree->occlusion[i] < 0.0f) + if (tree->occlusion[i] < 0.0f) tree->occlusion[i]= 0.0f; } @@ -1399,7 +1399,7 @@ static void sample_occ_tree(Render *re, OcclusionTree *tree, OccFace *exclude, f int envcolor; envcolor= re->wrld.aocolor; - if(onlyshadow) + if (onlyshadow) envcolor= WO_AOPLAIN; negate_v3_v3(nn, n); @@ -1410,12 +1410,12 @@ static void sample_occ_tree(Render *re, OcclusionTree *tree, OccFace *exclude, f occlusion= (1.0f-correction)*(1.0f-occ); CLAMP(occlusion, 0.0f, 1.0f); - if(correction != 0.0f) + if (correction != 0.0f) occlusion += correction*expf(-occ); - if(env) { + if (env) { /* sky shading using bent normal */ - if(ELEM(envcolor, WO_AOSKYCOL, WO_AOSKYTEX)) { + if (ELEM(envcolor, WO_AOSKYCOL, WO_AOSKYTEX)) { fac= 0.5f * (1.0f + dot_v3v3(bn, re->grvec)); env[0]= (1.0f-fac)*re->wrld.horr + fac*re->wrld.zenr; env[1]= (1.0f-fac)*re->wrld.horg + fac*re->wrld.zeng; @@ -1442,13 +1442,13 @@ static void sample_occ_tree(Render *re, OcclusionTree *tree, OccFace *exclude, f #endif } - if(ao) { + if (ao) { ao[0]= occlusion; ao[1]= occlusion; ao[2]= occlusion; } - if(tree->doindirect) copy_v3_v3(indirect, rad); + if (tree->doindirect) copy_v3_v3(indirect, rad); else zero_v3(indirect); } @@ -1464,7 +1464,7 @@ static OcclusionCacheSample *find_occ_sample(OcclusionCache *cache, int x, int y x *= cache->step; y *= cache->step; - if(x < 0 || x >= cache->w || y < 0 || y >= cache->h) + if (x < 0 || x >= cache->w || y < 0 || y >= cache->h) return NULL; else return &cache->sample[y*cache->w + x]; @@ -1478,18 +1478,18 @@ static int sample_occ_cache(OcclusionTree *tree, float *co, float *n, int x, int float d[3], dist2; int i, x1, y1, x2, y2; - if(!tree->cache) + if (!tree->cache) return 0; /* first try to find a sample in the same pixel */ cache= &tree->cache[thread]; - if(cache->sample && cache->step) { + if (cache->sample && cache->step) { sample= &cache->sample[(y-cache->y)*cache->w + (x-cache->x)]; - if(sample->filled) { + if (sample->filled) { sub_v3_v3v3(d, sample->co, co); dist2= dot_v3v3(d, d); - if(dist2 < 0.5f*sample->dist2 && dot_v3v3(sample->n, n) > 0.98f) { + if (dist2 < 0.5f*sample->dist2 && dot_v3v3(sample->n, n) > 0.98f) { copy_v3_v3(ao, sample->ao); copy_v3_v3(env, sample->env); copy_v3_v3(indirect, sample->indirect); @@ -1506,15 +1506,15 @@ static int sample_occ_cache(OcclusionTree *tree, float *co, float *n, int x, int samples[2]= find_occ_sample(cache, x, y+cache->step); samples[3]= find_occ_sample(cache, x+cache->step, y+cache->step); - for(i=0; i<4; i++) - if(!samples[i] || !samples[i]->filled) + for (i=0; i<4; i++) + if (!samples[i] || !samples[i]->filled) return 0; /* require intensities not being too different */ mino= MIN4(samples[0]->intensity, samples[1]->intensity, samples[2]->intensity, samples[3]->intensity); maxo= MAX4(samples[0]->intensity, samples[1]->intensity, samples[2]->intensity, samples[3]->intensity); - if(maxo - mino > 0.05f) + if (maxo - mino > 0.05f) return 0; /* compute weighted interpolation between samples */ @@ -1536,7 +1536,7 @@ static int sample_occ_cache(OcclusionTree *tree, float *co, float *n, int x, int wb[1]= (1.0f-tx)*(ty); wb[0]= tx*ty; - for(i=0; i<4; i++) { + for (i=0; i<4; i++) { sub_v3_v3v3(d, samples[i]->co, co); //dist2= dot_v3v3(d, d); @@ -1551,7 +1551,7 @@ static int sample_occ_cache(OcclusionTree *tree, float *co, float *n, int x, int madd_v3_v3fl(indirect, samples[i]->indirect, w); } - if(totw >= 0.9f) { + if (totw >= 0.9f) { totw= 1.0f/totw; mul_v3_fl(ao, totw); mul_v3_fl(env, totw); @@ -1569,7 +1569,7 @@ static void sample_occ_surface(ShadeInput *shi) int *face, *index = RE_strandren_get_face(shi->obr, strand, 0); float w[4], *co1, *co2, *co3, *co4; - if(mesh && mesh->face && mesh->co && mesh->ao && index) { + if (mesh && mesh->face && mesh->co && mesh->ao && index) { face= mesh->face[*index]; co1= mesh->co[face[0]]; @@ -1592,7 +1592,7 @@ static void sample_occ_surface(ShadeInput *shi) madd_v3_v3fl(shi->ao, mesh->ao[face[2]], w[2]); madd_v3_v3fl(shi->env, mesh->env[face[2]], w[2]); madd_v3_v3fl(shi->indirect, mesh->indirect[face[2]], w[2]); - if(face[3]) { + if (face[3]) { madd_v3_v3fl(shi->ao, mesh->ao[face[3]], w[3]); madd_v3_v3fl(shi->env, mesh->env[face[3]], w[3]); madd_v3_v3fl(shi->indirect, mesh->indirect[face[3]], w[3]); @@ -1617,13 +1617,13 @@ static void *exec_strandsurface_sample(void *data) float ao[3], env[3], indirect[3], co[3], n[3], *co1, *co2, *co3, *co4; int a, *face; - for(a=othread->begin; a<othread->end; a++) { + for (a=othread->begin; a<othread->end; a++) { face= mesh->face[a]; co1= mesh->co[face[0]]; co2= mesh->co[face[1]]; co3= mesh->co[face[2]]; - if(face[3]) { + if (face[3]) { co4= mesh->co[face[3]]; mid_v3_v3v3(co, co1, co3); @@ -1661,14 +1661,14 @@ void make_occ_tree(Render *re) re->occlusiontree= tree= occ_tree_build(re); - if(tree) { - if(re->wrld.ao_approx_passes > 0) + if (tree) { + if (re->wrld.ao_approx_passes > 0) occ_compute_passes(re, tree, re->wrld.ao_approx_passes); - if(tree->doindirect && (re->wrld.mode & WO_INDIRECT_LIGHT)) + if (tree->doindirect && (re->wrld.mode & WO_INDIRECT_LIGHT)) occ_compute_bounces(re, tree, re->wrld.ao_indirect_bounces); - for(mesh=re->strandsurface.first; mesh; mesh=mesh->next) { - if(!mesh->face || !mesh->co || !mesh->ao) + for (mesh=re->strandsurface.first; mesh; mesh=mesh->next) { + if (!mesh->face || !mesh->co || !mesh->ao) continue; count= MEM_callocN(sizeof(int)*mesh->totvert, "OcclusionCount"); @@ -1678,7 +1678,7 @@ void make_occ_tree(Render *re) totthread= (mesh->totface > 10000)? re->r.threads: 1; totface= mesh->totface/totthread; - for(a=0; a<totthread; a++) { + for (a=0; a<totthread; a++) { othreads[a].re= re; othreads[a].faceao= faceao; othreads[a].faceenv= faceenv; @@ -1689,19 +1689,19 @@ void make_occ_tree(Render *re) othreads[a].end= (a == totthread-1)? mesh->totface: (a+1)*totface; } - if(totthread == 1) { + if (totthread == 1) { exec_strandsurface_sample(&othreads[0]); } else { BLI_init_threads(&threads, exec_strandsurface_sample, totthread); - for(a=0; a<totthread; a++) + for (a=0; a<totthread; a++) BLI_insert_thread(&threads, &othreads[a]); BLI_end_threads(&threads); } - for(a=0; a<mesh->totface; a++) { + for (a=0; a<mesh->totface; a++) { face= mesh->face[a]; copy_v3_v3(ao, faceao[a]); @@ -1721,7 +1721,7 @@ void make_occ_tree(Render *re) add_v3_v3(mesh->indirect[face[2]], indirect); count[face[2]]++; - if(face[3]) { + if (face[3]) { add_v3_v3(mesh->ao[face[3]], ao); add_v3_v3(mesh->env[face[3]], env); add_v3_v3(mesh->indirect[face[3]], indirect); @@ -1729,8 +1729,8 @@ void make_occ_tree(Render *re) } } - for(a=0; a<mesh->totvert; a++) { - if(count[a]) { + for (a=0; a<mesh->totvert; a++) { + if (count[a]) { mul_v3_fl(mesh->ao[a], 1.0f/count[a]); mul_v3_fl(mesh->env[a], 1.0f/count[a]); mul_v3_fl(mesh->indirect[a], 1.0f/count[a]); @@ -1747,7 +1747,7 @@ void make_occ_tree(Render *re) void free_occ(Render *re) { - if(re->occlusiontree) { + if (re->occlusiontree) { occ_free_tree(re->occlusiontree); re->occlusiontree = NULL; } @@ -1761,12 +1761,12 @@ void sample_occ(Render *re, ShadeInput *shi) OccFace exclude; int onlyshadow; - if(tree) { - if(shi->strand) { + if (tree) { + if (shi->strand) { sample_occ_surface(shi); } /* try to get result from the cache if possible */ - else if(shi->depth!=0 || !sample_occ_cache(tree, shi->co, shi->vno, shi->xs, shi->ys, shi->thread, shi->ao, shi->env, shi->indirect)) { + else if (shi->depth!=0 || !sample_occ_cache(tree, shi->co, shi->vno, shi->xs, shi->ys, shi->thread, shi->ao, shi->env, shi->indirect)) { /* no luck, let's sample the occlusion */ exclude.obi= shi->obi - re->objectinstance; exclude.facenr= shi->vlr->index; @@ -1774,10 +1774,10 @@ void sample_occ(Render *re, ShadeInput *shi) sample_occ_tree(re, tree, &exclude, shi->co, shi->vno, shi->thread, onlyshadow, shi->ao, shi->env, shi->indirect); /* fill result into sample, each time */ - if(tree->cache) { + if (tree->cache) { cache= &tree->cache[shi->thread]; - if(cache->sample && cache->step) { + if (cache->sample && cache->step) { sample= &cache->sample[(shi->ys-cache->y)*cache->w + (shi->xs-cache->x)]; copy_v3_v3(sample->co, shi->co); copy_v3_v3(sample->n, shi->vno); @@ -1820,7 +1820,7 @@ void cache_occ_samples(Render *re, RenderPart *pa, ShadeSample *ssamp) int *ro=NULL, *rp=NULL, *rz=NULL, onlyshadow; int x, y, step = CACHE_STEP; - if(!tree->cache) + if (!tree->cache) return; cache= &tree->cache[pa->thread]; @@ -1832,7 +1832,7 @@ void cache_occ_samples(Render *re, RenderPart *pa, ShadeSample *ssamp) cache->sample= MEM_callocN(sizeof(OcclusionCacheSample)*cache->w*cache->h, "OcclusionCacheSample"); sample= cache->sample; - if(re->osa) { + if (re->osa) { rd= pa->rectdaps; } else { @@ -1846,20 +1846,20 @@ void cache_occ_samples(Render *re, RenderPart *pa, ShadeSample *ssamp) } /* compute a sample at every step pixels */ - for(y=pa->disprect.ymin; y<pa->disprect.ymax; y++) { - for(x=pa->disprect.xmin; x<pa->disprect.xmax; x++, sample++, rd++, ro++, rp++, rz++) { - if(!(((x - pa->disprect.xmin + step) % step) == 0 || x == pa->disprect.xmax-1)) + for (y=pa->disprect.ymin; y<pa->disprect.ymax; y++) { + for (x=pa->disprect.xmin; x<pa->disprect.xmax; x++, sample++, rd++, ro++, rp++, rz++) { + if (!(((x - pa->disprect.xmin + step) % step) == 0 || x == pa->disprect.xmax-1)) continue; - if(!(((y - pa->disprect.ymin + step) % step) == 0 || y == pa->disprect.ymax-1)) + if (!(((y - pa->disprect.ymin + step) % step) == 0 || y == pa->disprect.ymax-1)) continue; - if(re->osa) { - if(!*rd) continue; + if (re->osa) { + if (!*rd) continue; shade_samples_fill_with_ps(ssamp, (PixStr *)(*rd), x, y); } else { - if(!*rp) continue; + if (!*rp) continue; ps.obi= *ro; ps.facenr= *rp; @@ -1868,7 +1868,7 @@ void cache_occ_samples(Render *re, RenderPart *pa, ShadeSample *ssamp) } shi= ssamp->shi; - if(shi->vlr) { + if (shi->vlr) { onlyshadow= (shi->mat->mode & MA_ONLYSHADOW); exclude.obi= shi->obi - re->objectinstance; exclude.facenr= shi->vlr->index; @@ -1888,7 +1888,7 @@ void cache_occ_samples(Render *re, RenderPart *pa, ShadeSample *ssamp) sample->filled= 1; } - if(re->test_break(re->tbh)) + if (re->test_break(re->tbh)) break; } } @@ -1899,10 +1899,10 @@ void free_occ_samples(Render *re, RenderPart *pa) OcclusionTree *tree= re->occlusiontree; OcclusionCache *cache; - if(tree->cache) { + if (tree->cache) { cache= &tree->cache[pa->thread]; - if(cache->sample) + if (cache->sample) MEM_freeN(cache->sample); cache->w= 0; diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index b2092f94af8..aa475e8aef0 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -158,16 +158,16 @@ static void stats_background(void *UNUSED(arg), RenderStats *rs) fprintf(stdout, "Fra:%d Mem:%.2fM (%.2fM, peak %.2fM) ", rs->cfra, megs_used_memory, mmap_used_memory, megs_peak_memory); - if(rs->curfield) + if (rs->curfield) fprintf(stdout, "Field %d ", rs->curfield); - if(rs->curblur) + if (rs->curblur) fprintf(stdout, "Blur %d ", rs->curblur); - if(rs->infostr) { + if (rs->infostr) { fprintf(stdout, "| %s", rs->infostr); } else { - if(rs->tothalo) + if (rs->tothalo) fprintf(stdout, "Sce: %s Ve:%d Fa:%d Ha:%d La:%d", rs->scenename, rs->totvert, rs->totface, rs->tothalo, rs->totlamp); else fprintf(stdout, "Sce: %s Ve:%d Fa:%d La:%d", rs->scenename, rs->totvert, rs->totface, rs->totlamp); @@ -188,8 +188,8 @@ float *RE_RenderLayerGetPass(RenderLayer *rl, int passtype) { RenderPass *rpass; - for(rpass=rl->passes.first; rpass; rpass= rpass->next) - if(rpass->passtype== passtype) + for (rpass=rl->passes.first; rpass; rpass= rpass->next) + if (rpass->passtype== passtype) return rpass->rect; return NULL; } @@ -198,10 +198,10 @@ RenderLayer *RE_GetRenderLayer(RenderResult *rr, const char *name) { RenderLayer *rl; - if(rr==NULL) return NULL; + if (rr==NULL) return NULL; - for(rl= rr->layers.first; rl; rl= rl->next) - if(strncmp(rl->name, name, RE_MAXNAME)==0) + for (rl= rr->layers.first; rl; rl= rl->next) + if (strncmp(rl->name, name, RE_MAXNAME)==0) return rl; return NULL; } @@ -215,7 +215,7 @@ RenderLayer *render_get_active_layer(Render *re, RenderResult *rr) { RenderLayer *rl= BLI_findlink(&rr->layers, re->r.actlay); - if(rl) + if (rl) return rl; else return rr->layers.first; @@ -225,9 +225,9 @@ static int render_scene_needs_vector(Render *re) { SceneRenderLayer *srl; - for(srl= re->scene->r.layers.first; srl; srl= srl->next) - if(!(srl->layflag & SCE_LAY_DISABLE)) - if(srl->passflag & SCE_PASS_VECTOR) + for (srl= re->scene->r.layers.first; srl; srl= srl->next) + if (!(srl->layflag & SCE_LAY_DISABLE)) + if (srl->passflag & SCE_PASS_VECTOR) return 1; return 0; @@ -240,8 +240,8 @@ Render *RE_GetRender(const char *name) Render *re; /* search for existing renders */ - for(re= RenderGlobal.renderlist.first; re; re= re->next) - if(strncmp(re->name, name, RE_MAXNAME)==0) + for (re= RenderGlobal.renderlist.first; re; re= re->next) + if (strncmp(re->name, name, RE_MAXNAME)==0) break; return re; @@ -250,7 +250,7 @@ Render *RE_GetRender(const char *name) /* if you want to know exactly what has been done */ RenderResult *RE_AcquireResultRead(Render *re) { - if(re) { + if (re) { BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_READ); return re->result; } @@ -260,7 +260,7 @@ RenderResult *RE_AcquireResultRead(Render *re) RenderResult *RE_AcquireResultWrite(Render *re) { - if(re) { + if (re) { BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE); return re->result; } @@ -271,7 +271,7 @@ RenderResult *RE_AcquireResultWrite(Render *re) void RE_SwapResult(Render *re, RenderResult **rr) { /* for keeping render buffers */ - if(re) { + if (re) { SWAP(RenderResult*, re->result, *rr); } } @@ -279,14 +279,14 @@ void RE_SwapResult(Render *re, RenderResult **rr) void RE_ReleaseResult(Render *re) { - if(re) + if (re) BLI_rw_mutex_unlock(&re->resultmutex); } /* displist.c util.... */ Scene *RE_GetScene(Render *re) { - if(re) + if (re) return re->scene; return NULL; } @@ -296,10 +296,10 @@ void RE_AcquireResultImage(Render *re, RenderResult *rr) { memset(rr, 0, sizeof(RenderResult)); - if(re) { + if (re) { BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_READ); - if(re->result) { + if (re->result) { RenderLayer *rl; rr->rectx= re->result->rectx; @@ -312,10 +312,10 @@ void RE_AcquireResultImage(Render *re, RenderResult *rr) /* active layer */ rl= render_get_active_layer(re, re->result); - if(rl) { - if(rr->rectf==NULL) + if (rl) { + if (rr->rectf==NULL) rr->rectf= rl->rectf; - if(rr->rectz==NULL) + if (rr->rectz==NULL) rr->rectz= RE_RenderLayerGetPass(rl, SCE_PASS_Z); } @@ -327,7 +327,7 @@ void RE_AcquireResultImage(Render *re, RenderResult *rr) void RE_ReleaseResultImage(Render *re) { - if(re) + if (re) BLI_rw_mutex_unlock(&re->resultmutex); } @@ -352,7 +352,7 @@ Render *RE_NewRender(const char *name) /* only one render per name exists */ re= RE_GetRender(name); - if(re==NULL) { + if (re==NULL) { /* new render data struct */ re= MEM_callocN(sizeof(Render), "new render"); @@ -379,7 +379,7 @@ void RE_InitRenderCB(Render *re) re->display_draw= result_rcti_nothing; re->progress= float_nothing; re->test_break= default_break; - if(G.background) + if (G.background) re->stats_draw= stats_background; else re->stats_draw= stats_nothing; @@ -424,7 +424,7 @@ void RE_InitState(Render *re, Render *source, RenderData *rd, SceneRenderLayer * re->winx= winx; re->winy= winy; - if(disprect) { + if (disprect) { re->disprect= *disprect; re->rectx= disprect->xmax-disprect->xmin; re->recty= disprect->ymax-disprect->ymin; @@ -437,18 +437,18 @@ void RE_InitState(Render *re, Render *source, RenderData *rd, SceneRenderLayer * re->recty= winy; } - if(re->rectx < 2 || re->recty < 2 || (BKE_imtype_is_movie(rd->im_format.imtype) && + if (re->rectx < 2 || re->recty < 2 || (BKE_imtype_is_movie(rd->im_format.imtype) && (re->rectx < 16 || re->recty < 16) )) { BKE_report(re->reports, RPT_ERROR, "Image too small"); re->ok= 0; return; } - if((re->r.mode & (R_OSA))==0) + if ((re->r.mode & (R_OSA))==0) re->r.scemode &= ~R_FULL_SAMPLE; #ifdef WITH_OPENEXR - if(re->r.scemode & R_FULL_SAMPLE) + if (re->r.scemode & R_FULL_SAMPLE) re->r.scemode |= R_EXR_TILE_FILE; /* enable automatic */ /* Until use_border is made compatible with save_buffers/full_sample, render without the later instead of not rendering at all.*/ @@ -462,18 +462,18 @@ void RE_InitState(Render *re, Render *source, RenderData *rd, SceneRenderLayer * #endif /* fullsample wants uniform osa levels */ - if(source && (re->r.scemode & R_FULL_SAMPLE)) { + if (source && (re->r.scemode & R_FULL_SAMPLE)) { /* but, if source has no full sample we disable it */ - if((source->r.scemode & R_FULL_SAMPLE)==0) + if ((source->r.scemode & R_FULL_SAMPLE)==0) re->r.scemode &= ~R_FULL_SAMPLE; else re->r.osa= re->osa= source->osa; } else { /* check state variables, osa? */ - if(re->r.mode & (R_OSA)) { + if (re->r.mode & (R_OSA)) { re->osa= re->r.osa; - if(re->osa>16) re->osa= 16; + if (re->osa>16) re->osa= 16; } else re->osa= 0; } @@ -492,8 +492,8 @@ void RE_InitState(Render *re, Render *source, RenderData *rd, SceneRenderLayer * /* if preview render, we try to keep old result */ BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE); - if(re->r.scemode & R_PREVIEWBUTS) { - if(re->result && re->result->rectx==re->rectx && re->result->recty==re->recty); + if (re->r.scemode & R_PREVIEWBUTS) { + if (re->result && re->result->rectx==re->rectx && re->result->recty==re->recty); else { render_result_free(re->result); re->result= NULL; @@ -606,7 +606,7 @@ void RE_AddObject(Render *UNUSED(re), Object *UNUSED(ob)) static int render_display_draw_enabled(Render *re) { /* don't show preprocess for previewrender sss */ - if(re->sss_points) + if (re->sss_points) return !(re->r.scemode & R_PREVIEWBUTS); else return 1; @@ -618,27 +618,27 @@ static void *do_part_thread(void *pa_v) RenderPart *pa= pa_v; /* need to return nicely all parts on esc */ - if(R.test_break(R.tbh)==0) { + if (R.test_break(R.tbh)==0) { - if(!R.sss_points && (R.r.scemode & R_FULL_SAMPLE)) + if (!R.sss_points && (R.r.scemode & R_FULL_SAMPLE)) pa->result= render_result_new_full_sample(&R, &pa->fullresult, &pa->disprect, pa->crop, RR_USE_MEM); else pa->result= render_result_new(&R, &pa->disprect, pa->crop, RR_USE_MEM); - if(R.sss_points) + if (R.sss_points) zbufshade_sss_tile(pa); - else if(R.osa) + else if (R.osa) zbufshadeDA_tile(pa); else zbufshade_tile(pa); /* merge too on break! */ - if(R.result->exrhandle) { + if (R.result->exrhandle) { render_result_exr_file_merge(R.result, pa->result); } - else if(render_display_draw_enabled(&R)) { + else if (render_display_draw_enabled(&R)) { /* on break, don't merge in result for preview renders, looks nicer */ - if(R.test_break(R.tbh) && (R.r.scemode & R_PREVIEWBUTS)); + if (R.test_break(R.tbh) && (R.r.scemode & R_PREVIEWBUTS)); else render_result_merge(R.result, pa->result); } } @@ -682,16 +682,16 @@ static RenderPart *find_next_pano_slice(Render *re, int *minx, rctf *viewplane) *minx= re->winx; /* most left part of the non-rendering parts */ - for(pa= re->parts.first; pa; pa= pa->next) { - if(pa->ready==0 && pa->nr==0) { - if(pa->disprect.xmin < *minx) { + for (pa= re->parts.first; pa; pa= pa->next) { + if (pa->ready==0 && pa->nr==0) { + if (pa->disprect.xmin < *minx) { best= pa; *minx= pa->disprect.xmin; } } } - if(best) { + if (best) { float phi= panorama_pixel_rot(re); R.panodxp= (re->winx - (best->disprect.xmin + best->disprect.xmax) )/2; @@ -720,8 +720,8 @@ static RenderPart *find_next_part(Render *re, int minx) long long int mindist= (long long int)re->winx * (long long int)re->winy; /* find center of rendered parts, image center counts for 1 too */ - for(pa= re->parts.first; pa; pa= pa->next) { - if(pa->ready) { + for (pa= re->parts.first; pa; pa= pa->next) { + if (pa->ready) { centx+= (pa->disprect.xmin+pa->disprect.xmax)/2; centy+= (pa->disprect.ymin+pa->disprect.ymax)/2; tot++; @@ -731,14 +731,14 @@ static RenderPart *find_next_part(Render *re, int minx) centy/=tot; /* closest of the non-rendering parts */ - for(pa= re->parts.first; pa; pa= pa->next) { - if(pa->ready==0 && pa->nr==0) { + for (pa= re->parts.first; pa; pa= pa->next) { + if (pa->ready==0 && pa->nr==0) { long long int distx= centx - (pa->disprect.xmin+pa->disprect.xmax)/2; long long int disty= centy - (pa->disprect.ymin+pa->disprect.ymax)/2; distx= (long long int)sqrt(distx*distx + disty*disty); - if(distx<mindist) { - if(re->r.mode & R_PANORAMA) { - if(pa->disprect.xmin==minx) { + if (distx<mindist) { + if (re->r.mode & R_PANORAMA) { + if (pa->disprect.xmin==minx) { best= pa; mindist= distx; } @@ -773,12 +773,12 @@ static void threaded_tile_processor(Render *re) BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE); /* first step; free the entire render result, make new, and/or prepare exr buffer saving */ - if(re->result==NULL || !(re->r.scemode & R_PREVIEWBUTS)) { + if (re->result==NULL || !(re->r.scemode & R_PREVIEWBUTS)) { render_result_free(re->result); - if(re->sss_points && render_display_draw_enabled(re)) + if (re->sss_points && render_display_draw_enabled(re)) re->result= render_result_new(re, &re->disprect, 0, RR_USE_MEM); - else if(re->r.scemode & R_FULL_SAMPLE) + else if (re->r.scemode & R_FULL_SAMPLE) re->result= render_result_new_full_sample(re, &re->fullresult, &re->disprect, 0, RR_USE_EXR); else re->result= render_result_new(re, &re->disprect, 0, @@ -787,14 +787,14 @@ static void threaded_tile_processor(Render *re) BLI_rw_mutex_unlock(&re->resultmutex); - if(re->result==NULL) + if (re->result==NULL) return; /* warning; no return here without closing exr file */ initparts(re); - if(re->result->exrhandle) + if (re->result->exrhandle) render_result_exr_file_begin(re); BLI_init_threads(&threads, do_part_thread, re->r.threads); @@ -806,16 +806,16 @@ static void threaded_tile_processor(Render *re) R.test_break= thread_break; /* timer loop demands to sleep when no parts are left, so we enter loop with a part */ - if(re->r.mode & R_PANORAMA) + if (re->r.mode & R_PANORAMA) nextpa= find_next_pano_slice(re, &minx, &viewplane); else nextpa= find_next_part(re, 0); while(rendering) { - if(re->test_break(re->tbh)) + if (re->test_break(re->tbh)) PIL_sleep_ms(50); - else if(nextpa && BLI_available_threads(&threads)) { + else if (nextpa && BLI_available_threads(&threads)) { drawtimer= 0; nextpa->nr= counter++; /* for nicest part, and for stats */ nextpa->thread= BLI_available_thread_index(&threads); /* sample index */ @@ -823,8 +823,8 @@ static void threaded_tile_processor(Render *re) nextpa= find_next_part(re, minx); } - else if(re->r.mode & R_PANORAMA) { - if(nextpa==NULL && BLI_available_threads(&threads)==re->r.threads) + else if (re->r.mode & R_PANORAMA) { + if (nextpa==NULL && BLI_available_threads(&threads)==re->r.threads) nextpa= find_next_pano_slice(re, &minx, &viewplane); else { PIL_sleep_ms(50); @@ -839,13 +839,13 @@ static void threaded_tile_processor(Render *re) /* check for ready ones to display, and if we need to continue */ rendering= 0; hasdrawn= 0; - for(pa= re->parts.first; pa; pa= pa->next) { - if(pa->ready) { + for (pa= re->parts.first; pa; pa= pa->next) { + if (pa->ready) { BLI_remove_thread(&threads, pa); - if(pa->result) { - if(render_display_draw_enabled(re)) + if (pa->result) { + if (render_display_draw_enabled(re)) re->display_draw(re->ddh, pa->result, NULL); print_part_stats(re, pa); @@ -858,23 +858,23 @@ static void threaded_tile_processor(Render *re) } else { rendering= 1; - if(pa->nr && pa->result && drawtimer>20) { - if(render_display_draw_enabled(re)) + if (pa->nr && pa->result && drawtimer>20) { + if (render_display_draw_enabled(re)) re->display_draw(re->ddh, pa->result, &pa->result->renrect); hasdrawn= 1; } } } - if(hasdrawn) + if (hasdrawn) drawtimer= 0; /* on break, wait for all slots to get freed */ - if( (g_break=re->test_break(re->tbh)) && BLI_available_threads(&threads)==re->r.threads) + if ( (g_break=re->test_break(re->tbh)) && BLI_available_threads(&threads)==re->r.threads) rendering= 0; } - if(re->result->exrhandle) { + if (re->result->exrhandle) { BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE); render_result_exr_file_end(re); BLI_rw_mutex_unlock(&re->resultmutex); @@ -899,7 +899,7 @@ void RE_TileProcessor(Render *re) static void do_render_3d(Render *re) { /* try external */ - if(RE_engine_render(re, 0)) + if (RE_engine_render(re, 0)) return; /* internal */ @@ -908,24 +908,24 @@ static void do_render_3d(Render *re) re->scene->r.subframe = re->mblur_offs + re->field_offs; /* lock drawing in UI during data phase */ - if(re->draw_lock) + if (re->draw_lock) re->draw_lock(re->dlh, 1); /* make render verts/faces/halos/lamps */ - if(render_scene_needs_vector(re)) + if (render_scene_needs_vector(re)) RE_Database_FromScene_Vectors(re, re->main, re->scene, re->lay); else RE_Database_FromScene(re, re->main, re->scene, re->lay, 1); /* clear UI drawing locks */ - if(re->draw_lock) + if (re->draw_lock) re->draw_lock(re->dlh, 0); threaded_tile_processor(re); /* do left-over 3d post effects (flares) */ - if(re->flag & R_HALO) - if(!re->test_break(re->tbh)) + if (re->flag & R_HALO) + if (!re->test_break(re->tbh)) add_halo_flare(re); /* free all render verts etc */ @@ -941,17 +941,17 @@ static void addblur_rect_key(RenderResult *rr, float *rectf, float *rectf1, floa int a, b, stride= 4*rr->rectx; int len= stride*sizeof(float); - for(a=0; a<rr->recty; a++) { - if(blurfac==1.0f) { + for (a=0; a<rr->recty; a++) { + if (blurfac==1.0f) { memcpy(rectf, rectf1, len); } else { float *rf= rectf, *rf1= rectf1; - for( b= rr->rectx; b>0; b--, rf+=4, rf1+=4) { - if(rf1[3]<0.01f) + for ( b= rr->rectx; b>0; b--, rf+=4, rf1+=4) { + if (rf1[3]<0.01f) rf[3]= mfac*rf[3]; - else if(rf[3]<0.01f) { + else if (rf[3]<0.01f) { rf[0]= rf1[0]; rf[1]= rf1[1]; rf[2]= rf1[2]; @@ -977,14 +977,14 @@ static void addblur_rect(RenderResult *rr, float *rectf, float *rectf1, float bl int a, b, stride= channels*rr->rectx; int len= stride*sizeof(float); - for(a=0; a<rr->recty; a++) { - if(blurfac==1.0f) { + for (a=0; a<rr->recty; a++) { + if (blurfac==1.0f) { memcpy(rectf, rectf1, len); } else { float *rf= rectf, *rf1= rectf1; - for( b= rr->rectx*channels; b>0; b--, rf++, rf1++) { + for ( b= rr->rectx*channels; b>0; b--, rf++, rf1++) { rf[0]= mfac*rf[0] + blurfac*rf1[0]; } } @@ -1001,11 +1001,11 @@ static void merge_renderresult_blur(RenderResult *rr, RenderResult *brr, float b RenderPass *rpass, *rpass1; rl1= brr->layers.first; - for(rl= rr->layers.first; rl && rl1; rl= rl->next, rl1= rl1->next) { + for (rl= rr->layers.first; rl && rl1; rl= rl->next, rl1= rl1->next) { /* combined */ - if(rl->rectf && rl1->rectf) { - if(key_alpha) + if (rl->rectf && rl1->rectf) { + if (key_alpha) addblur_rect_key(rr, rl->rectf, rl1->rectf, blurfac); else addblur_rect(rr, rl->rectf, rl1->rectf, blurfac, 4); @@ -1013,7 +1013,7 @@ static void merge_renderresult_blur(RenderResult *rr, RenderResult *brr, float b /* passes are allocated in sync */ rpass1= rl1->passes.first; - for(rpass= rl->passes.first; rpass && rpass1; rpass= rpass->next, rpass1= rpass1->next) { + for (rpass= rl->passes.first; rpass && rpass1; rpass= rpass->next, rpass1= rpass1->next) { addblur_rect(rr, rpass->rect, rpass1->rect, blurfac, rpass->channels); } } @@ -1040,7 +1040,7 @@ static void do_render_blur_3d(Render *re) blurfac= 1.0f/(float)(re->r.mblur_samples-blur); merge_renderresult_blur(rres, re->result, blurfac, re->r.alphamode & R_ALPHAKEY); - if(re->test_break(re->tbh)) break; + if (re->test_break(re->tbh)) break; } /* swap results */ @@ -1064,7 +1064,7 @@ static void interleave_rect(RenderResult *rr, float *rectf, float *rectf1, float int a, stride= channels*rr->rectx; int len= stride*sizeof(float); - for(a=0; a<rr->recty; a+=2) { + for (a=0; a<rr->recty; a+=2) { memcpy(rectf, rectf1, len); rectf+= stride; rectf1+= stride; @@ -1082,16 +1082,16 @@ static void merge_renderresult_fields(RenderResult *rr, RenderResult *rr1, Rende rl1= rr1->layers.first; rl2= rr2->layers.first; - for(rl= rr->layers.first; rl && rl1 && rl2; rl= rl->next, rl1= rl1->next, rl2= rl2->next) { + for (rl= rr->layers.first; rl && rl1 && rl2; rl= rl->next, rl1= rl1->next, rl2= rl2->next) { /* combined */ - if(rl->rectf && rl1->rectf && rl2->rectf) + if (rl->rectf && rl1->rectf && rl2->rectf) interleave_rect(rr, rl->rectf, rl1->rectf, rl2->rectf, 4); /* passes are allocated in sync */ rpass1= rl1->passes.first; rpass2= rl2->passes.first; - for(rpass= rl->passes.first; rpass && rpass1 && rpass2; rpass= rpass->next, rpass1= rpass1->next, rpass2= rpass2->next) { + for (rpass= rl->passes.first; rpass && rpass1 && rpass2; rpass= rpass->next, rpass1= rpass1->next, rpass2= rpass2->next) { interleave_rect(rr, rpass->rect, rpass1->rect, rpass2->rect, rpass->channels); } } @@ -1114,7 +1114,7 @@ static void do_render_fields_3d(Render *re) /* first field, we have to call camera routine for correct aspect and subpixel offset */ RE_SetCamera(re, camera); - if(re->r.mode & R_MBLUR && (re->r.scemode & R_FULL_SAMPLE)==0) + if (re->r.mode & R_MBLUR && (re->r.scemode & R_FULL_SAMPLE)==0) do_render_blur_3d(re); else do_render_3d(re); @@ -1125,16 +1125,16 @@ static void do_render_fields_3d(Render *re) BLI_rw_mutex_unlock(&re->resultmutex); /* second field */ - if(!re->test_break(re->tbh)) { + if (!re->test_break(re->tbh)) { re->i.curfield= 2; /* stats */ re->flag |= R_SEC_FIELD; - if((re->r.mode & R_FIELDSTILL)==0) { + if ((re->r.mode & R_FIELDSTILL)==0) { re->field_offs = 0.5f; } RE_SetCamera(re, camera); - if(re->r.mode & R_MBLUR && (re->r.scemode & R_FULL_SAMPLE)==0) + if (re->r.mode & R_MBLUR && (re->r.scemode & R_FULL_SAMPLE)==0) do_render_blur_3d(re); else do_render_3d(re); @@ -1154,8 +1154,8 @@ static void do_render_fields_3d(Render *re) BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE); re->result= render_result_new(re, &re->disprect, 0, RR_USE_MEM); - if(rr2) { - if(re->r.mode & R_ODDFIELD) + if (rr2) { + if (re->r.mode & R_ODDFIELD) merge_renderresult_fields(re->result, rr2, rr1); else merge_renderresult_fields(re->result, rr1, rr2); @@ -1180,7 +1180,7 @@ static void do_render_fields_blur_3d(Render *re) { Object *camera= RE_GetCamera(re); /* also check for camera here */ - if(camera == NULL) { + if (camera == NULL) { printf("ERROR: Cannot render, no camera\n"); G.afbreek= 1; return; @@ -1189,17 +1189,17 @@ static void do_render_fields_blur_3d(Render *re) /* now use renderdata and camera to set viewplane */ RE_SetCamera(re, camera); - if(re->r.mode & R_FIELDS) + if (re->r.mode & R_FIELDS) do_render_fields_3d(re); - else if(re->r.mode & R_MBLUR && (re->r.scemode & R_FULL_SAMPLE)==0) + else if (re->r.mode & R_MBLUR && (re->r.scemode & R_FULL_SAMPLE)==0) do_render_blur_3d(re); else do_render_3d(re); /* when border render, check if we have to insert it in black */ - if(re->result) { - if(re->r.mode & R_BORDER) { - if((re->r.mode & R_CROP)==0) { + if (re->result) { + if (re->r.mode & R_BORDER) { + if ((re->r.mode & R_CROP)==0) { RenderResult *rres; BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE); @@ -1252,7 +1252,7 @@ static void render_scene(Render *re, Scene *sce, int cfra) scene_camera_switch_update(sce); /* exception: scene uses own size (unfinished code) */ - if(0) { + if (0) { winx= (sce->r.size*sce->r.xsch)/100; winy= (sce->r.size*sce->r.ysch)/100; } @@ -1285,13 +1285,13 @@ static int composite_needs_render(Scene *sce, int this_scene) bNodeTree *ntree= sce->nodetree; bNode *node; - if(ntree==NULL) return 1; - if(sce->use_nodes==0) return 1; - if((sce->r.scemode & R_DOCOMP)==0) return 1; + if (ntree==NULL) return 1; + if (sce->use_nodes==0) return 1; + if ((sce->r.scemode & R_DOCOMP)==0) return 1; - for(node= ntree->nodes.first; node; node= node->next) { - if(node->type==CMP_NODE_R_LAYERS) - if(this_scene==0 || node->id==NULL || node->id==&sce->id) + for (node= ntree->nodes.first; node; node= node->next) { + if (node->type==CMP_NODE_R_LAYERS) + if (this_scene==0 || node->id==NULL || node->id==&sce->id) return 1; } return 0; @@ -1302,19 +1302,19 @@ static void tag_scenes_for_render(Render *re) bNode *node; Scene *sce; - for(sce= re->main->scene.first; sce; sce= sce->id.next) + for (sce= re->main->scene.first; sce; sce= sce->id.next) sce->id.flag &= ~LIB_DOIT; - if(RE_GetCamera(re) && composite_needs_render(re->scene, 1)) + if (RE_GetCamera(re) && composite_needs_render(re->scene, 1)) re->scene->id.flag |= LIB_DOIT; - if(re->scene->nodetree==NULL) return; + if (re->scene->nodetree==NULL) return; /* check for render-layers nodes using other scenes, we tag them LIB_DOIT */ - for(node= re->scene->nodetree->nodes.first; node; node= node->next) { - if(node->type==CMP_NODE_R_LAYERS) { - if(node->id) { - if(node->id != (ID *)re->scene) + for (node= re->scene->nodetree->nodes.first; node; node= node->next) { + if (node->type==CMP_NODE_R_LAYERS) { + if (node->id) { + if (node->id != (ID *)re->scene) node->id->flag |= LIB_DOIT; } } @@ -1328,16 +1328,16 @@ static void ntree_render_scenes(Render *re) int cfra= re->scene->r.cfra; int restore_scene= 0; - if(re->scene->nodetree==NULL) return; + if (re->scene->nodetree==NULL) return; tag_scenes_for_render(re); /* now foreach render-result node tagged we do a full render */ /* results are stored in a way compisitor will find it */ - for(node= re->scene->nodetree->nodes.first; node; node= node->next) { - if(node->type==CMP_NODE_R_LAYERS) { - if(node->id && node->id != (ID *)re->scene) { - if(node->id->flag & LIB_DOIT) { + for (node= re->scene->nodetree->nodes.first; node; node= node->next) { + if (node->type==CMP_NODE_R_LAYERS) { + if (node->id && node->id != (ID *)re->scene) { + if (node->id->flag & LIB_DOIT) { Scene *scene = (Scene*)node->id; render_scene(re, scene, cfra); @@ -1351,7 +1351,7 @@ static void ntree_render_scenes(Render *re) } /* restore scene if we rendered another last */ - if(restore_scene) + if (restore_scene) set_scene_bg(re->main, re->scene); } @@ -1371,7 +1371,7 @@ static void do_merge_fullsample(Render *re, bNodeTree *ntree) int sample; /* interaction callbacks */ - if(ntree) { + if (ntree) { ntree->stats_draw= render_composit_stats; ntree->test_break= re->test_break; ntree->progress= re->progress; @@ -1386,7 +1386,7 @@ static void do_merge_fullsample(Render *re, bNodeTree *ntree) /* we accumulate in here */ rectf= MEM_mapallocN(re->rectx*re->recty*sizeof(float)*4, "fullsample rgba"); - for(sample=0; sample<re->r.osa; sample++) { + for (sample=0; sample<re->r.osa; sample++) { Render *re1; RenderResult rres; int x, y, mask; @@ -1398,10 +1398,10 @@ static void do_merge_fullsample(Render *re, bNodeTree *ntree) /* also function below assumes this */ tag_scenes_for_render(re); - for(re1= RenderGlobal.renderlist.first; re1; re1= re1->next) { - if(re1->scene->id.flag & LIB_DOIT) { - if(re1->r.scemode & R_FULL_SAMPLE) { - if(sample) { + for (re1= RenderGlobal.renderlist.first; re1; re1= re1->next) { + if (re1->scene->id.flag & LIB_DOIT) { + if (re1->r.scemode & R_FULL_SAMPLE) { + if (sample) { BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE); render_result_exr_file_read(re1, sample); BLI_rw_mutex_unlock(&re->resultmutex); @@ -1412,7 +1412,7 @@ static void do_merge_fullsample(Render *re, bNodeTree *ntree) } /* composite */ - if(ntree) { + if (ntree) { ntreeCompositTagRender(re->scene); ntreeCompositTagAnimated(ntree); @@ -1426,15 +1426,15 @@ static void do_merge_fullsample(Render *re, bNodeTree *ntree) mask= (1<<sample); mask_array(mask, filt); - for(y=0; y<re->recty; y++) { + for (y=0; y<re->recty; y++) { float *rf= rectf + 4*y*re->rectx; float *col= rres.rectf + 4*y*re->rectx; - for(x=0; x<re->rectx; x++, rf+=4, col+=4) { + for (x=0; x<re->rectx; x++, rf+=4, col+=4) { /* clamping to 1.0 is needed for correct AA */ - if(col[0]<0.0f) col[0]=0.0f; else if(col[0] > 1.0f) col[0]= 1.0f; - if(col[1]<0.0f) col[1]=0.0f; else if(col[1] > 1.0f) col[1]= 1.0f; - if(col[2]<0.0f) col[2]=0.0f; else if(col[2] > 1.0f) col[2]= 1.0f; + if (col[0]<0.0f) col[0]=0.0f; else if (col[0] > 1.0f) col[0]= 1.0f; + if (col[1]<0.0f) col[1]=0.0f; else if (col[1] > 1.0f) col[1]= 1.0f; + if (col[2]<0.0f) col[2]=0.0f; else if (col[2] > 1.0f) col[2]= 1.0f; add_filt_fmask_coord(filt, col, rf, re->rectx, re->recty, x, y); } @@ -1443,18 +1443,18 @@ static void do_merge_fullsample(Render *re, bNodeTree *ntree) RE_ReleaseResultImage(re); /* show stuff */ - if(sample!=re->osa-1) { + if (sample!=re->osa-1) { /* weak... the display callback wants an active renderlayer pointer... */ re->result->renlay= render_get_active_layer(re, re->result); re->display_draw(re->ddh, re->result, NULL); } - if(re->test_break(re->tbh)) + if (re->test_break(re->tbh)) break; } /* clear interaction callbacks */ - if(ntree) { + if (ntree) { ntree->stats_draw= NULL; ntree->test_break= NULL; ntree->progress= NULL; @@ -1465,7 +1465,7 @@ static void do_merge_fullsample(Render *re, bNodeTree *ntree) R.i.curfsa= 0; BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE); - if(re->result->rectf) + if (re->result->rectf) MEM_freeN(re->result->rectf); re->result->rectf= rectf; BLI_rw_mutex_unlock(&re->resultmutex); @@ -1486,15 +1486,15 @@ void RE_MergeFullSample(Render *re, Main *bmain, Scene *sce, bNodeTree *ntree) /* first call RE_ReadRenderResult on every renderlayer scene. this creates Render structs */ /* tag scenes unread */ - for(scene= re->main->scene.first; scene; scene= scene->id.next) + for (scene= re->main->scene.first; scene; scene= scene->id.next) scene->id.flag |= LIB_DOIT; - for(node= ntree->nodes.first; node; node= node->next) { - if(node->type==CMP_NODE_R_LAYERS) { + for (node= ntree->nodes.first; node; node= node->next) { + if (node->type==CMP_NODE_R_LAYERS) { Scene *nodescene= (Scene *)node->id; - if(nodescene==NULL) nodescene= sce; - if(nodescene->id.flag & LIB_DOIT) { + if (nodescene==NULL) nodescene= sce; + if (nodescene->id.flag & LIB_DOIT) { nodescene->r.mode |= R_OSA; /* render struct needs tables */ RE_ReadRenderResult(sce, nodescene); nodescene->id.flag &= ~LIB_DOIT; @@ -1503,7 +1503,7 @@ void RE_MergeFullSample(Render *re, Main *bmain, Scene *sce, bNodeTree *ntree) } /* own render result should be read/allocated */ - if(re->scene->id.flag & LIB_DOIT) { + if (re->scene->id.flag & LIB_DOIT) { RE_ReadRenderResult(re->scene, re->scene); re->scene->id.flag &= ~LIB_DOIT; } @@ -1524,7 +1524,7 @@ static void do_render_composite_fields_blur_3d(Render *re) /* INIT seeding, compositor can use random texture */ BLI_srandom(re->r.cfra); - if(composite_needs_render(re->scene, 1)) { + if (composite_needs_render(re->scene, 1)) { /* save memory... free all cached images */ ntreeFreeCache(ntree); @@ -1544,25 +1544,25 @@ static void do_render_composite_fields_blur_3d(Render *re) } /* swap render result */ - if(re->r.scemode & R_SINGLE_LAYER) { + if (re->r.scemode & R_SINGLE_LAYER) { BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE); render_result_single_layer_end(re); BLI_rw_mutex_unlock(&re->resultmutex); } - if(!re->test_break(re->tbh)) { + if (!re->test_break(re->tbh)) { - if(ntree) { + if (ntree) { ntreeCompositTagRender(re->scene); ntreeCompositTagAnimated(ntree); } - if(ntree && re->scene->use_nodes && re->r.scemode & R_DOCOMP) { + if (ntree && re->scene->use_nodes && re->r.scemode & R_DOCOMP) { /* checks if there are render-result nodes that need scene */ - if((re->r.scemode & R_SINGLE_LAYER)==0) + if ((re->r.scemode & R_SINGLE_LAYER)==0) ntree_render_scenes(re); - if(!re->test_break(re->tbh)) { + if (!re->test_break(re->tbh)) { ntree->stats_draw= render_composit_stats; ntree->test_break= re->test_break; ntree->progress= re->progress; @@ -1577,7 +1577,7 @@ static void do_render_composite_fields_blur_3d(Render *re) if (update_newframe) scene_update_for_newframe(re->main, re->scene, re->lay); - if(re->r.scemode & R_FULL_SAMPLE) + if (re->r.scemode & R_FULL_SAMPLE) do_merge_fullsample(re, ntree); else { ntreeCompositExecTree(ntree, &re->r, G.background==0); @@ -1589,7 +1589,7 @@ static void do_render_composite_fields_blur_3d(Render *re) ntree->tbh= ntree->sdh= ntree->prh= NULL; } } - else if(re->r.scemode & R_FULL_SAMPLE) + else if (re->r.scemode & R_FULL_SAMPLE) do_merge_fullsample(re, NULL); } @@ -1636,20 +1636,21 @@ static void do_render_seq(Render * re) re->i.cfra= cfra; - if(recurs_depth==0) { + if (recurs_depth==0) { /* otherwise sequencer animation isn't updated */ BKE_animsys_evaluate_all_animation(re->main, re->scene, (float)cfra); // XXX, was BKE_curframe(re->scene) } recurs_depth++; - if((re->r.mode & R_BORDER) && (re->r.mode & R_CROP)==0) { + if ((re->r.mode & R_BORDER) && (re->r.mode & R_CROP)==0) { /* if border rendering is used and cropping is disabled, final buffer should * be as large as the whole frame */ context = seq_new_render_data(re->main, re->scene, re->winx, re->winy, 100); - } else { + } + else { context = seq_new_render_data(re->main, re->scene, re->result->rectx, re->result->recty, 100); @@ -1663,7 +1664,7 @@ static void do_render_seq(Render * re) BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE); - if(ibuf) { + if (ibuf) { /* copy ibuf into combined pixel rect */ render_result_rect_from_ibuf(rr, &re->r, ibuf); @@ -1685,7 +1686,7 @@ static void do_render_seq(Render * re) re->r.scemode |= R_DOSEQ; /* set overall progress of sequence rendering */ - if(re->r.efra!=re->r.sfra) + if (re->r.efra!=re->r.sfra) re->progress(re->prh, (float)(cfra-re->r.sfra) / (re->r.efra-re->r.sfra)); else re->progress(re->prh, 1.0f); @@ -1703,12 +1704,12 @@ static void do_render_all_options(Render *re) /* ensure no images are in memory from previous animated sequences */ BKE_image_all_free_anim_ibufs(re->r.cfra); - if(RE_engine_render(re, 1)) { + if (RE_engine_render(re, 1)) { /* in this case external render overrides all */ } - else if(RE_seq_render_active(re->scene, &re->r)) { + else if (RE_seq_render_active(re->scene, &re->r)) { /* note: do_render_seq() frees rect32 when sequencer returns float images */ - if(!re->test_break(re->tbh)) + if (!re->test_break(re->tbh)) do_render_seq(re); re->stats_draw(re->sdh, &re->i); @@ -1723,7 +1724,7 @@ static void do_render_all_options(Render *re) re->stats_draw(re->sdh, &re->i); /* stamp image info here */ - if((re->r.stamp & R_STAMP_ALL) && (re->r.stamp & R_STAMP_DRAW)) { + if ((re->r.stamp & R_STAMP_ALL) && (re->r.stamp & R_STAMP_DRAW)) { renderresult_stampinfo(re); re->display_draw(re->ddh, re->result, NULL); } @@ -1736,20 +1737,21 @@ static int check_valid_camera(Scene *scene, Object *camera_override) if (camera_override == NULL && scene->camera == NULL) scene->camera= scene_find_camera(scene); - if(scene->r.scemode&R_DOSEQ) { - if(scene->ed) { + if (scene->r.scemode&R_DOSEQ) { + if (scene->ed) { Sequence *seq= scene->ed->seqbase.first; check_comp= 0; while(seq) { - if(seq->type == SEQ_SCENE && seq->scene) { - if(!seq->scene_camera) { - if(!seq->scene->camera && !scene_find_camera(seq->scene)) { - if(seq->scene == scene) { + if (seq->type == SEQ_SCENE && seq->scene) { + if (!seq->scene_camera) { + if (!seq->scene->camera && !scene_find_camera(seq->scene)) { + if (seq->scene == scene) { /* for current scene camera could be unneeded due to compisite nodes */ check_comp= 1; - } else { + } + else { /* for other scenes camera is necessary */ return 0; } @@ -1762,15 +1764,15 @@ static int check_valid_camera(Scene *scene, Object *camera_override) } } - if(check_comp) { /* no sequencer or sequencer depends on compositor */ - if(scene->r.scemode&R_DOCOMP && scene->use_nodes) { + if (check_comp) { /* no sequencer or sequencer depends on compositor */ + if (scene->r.scemode&R_DOCOMP && scene->use_nodes) { bNode *node= scene->nodetree->nodes.first; while(node) { - if(node->type == CMP_NODE_R_LAYERS) { + if (node->type == CMP_NODE_R_LAYERS) { Scene *sce= node->id ? (Scene*)node->id : scene; - if(!sce->camera && !scene_find_camera(sce)) { + if (!sce->camera && !scene_find_camera(sce)) { /* all render layers nodes need camera */ return 0; } @@ -1778,7 +1780,8 @@ static int check_valid_camera(Scene *scene, Object *camera_override) node= node->next; } - } else { + } + else { return (camera_override != NULL || scene->camera != NULL); } } @@ -1790,15 +1793,15 @@ int RE_is_rendering_allowed(Scene *scene, Object *camera_override, ReportList *r { SceneRenderLayer *srl; - if(scene->r.mode & R_BORDER) { - if(scene->r.border.xmax <= scene->r.border.xmin || + if (scene->r.mode & R_BORDER) { + if (scene->r.border.xmax <= scene->r.border.xmin || scene->r.border.ymax <= scene->r.border.ymin) { BKE_report(reports, RPT_ERROR, "No border area selected."); return 0; } } - if(scene->r.scemode & (R_EXR_TILE_FILE|R_FULL_SAMPLE)) { + if (scene->r.scemode & (R_EXR_TILE_FILE|R_FULL_SAMPLE)) { char str[FILE_MAX]; render_result_exr_file_path(scene, 0, str); @@ -1809,7 +1812,7 @@ int RE_is_rendering_allowed(Scene *scene, Object *camera_override, ReportList *r } /* no fullsample and edge */ - if((scene->r.scemode & R_FULL_SAMPLE) && (scene->r.mode & R_EDGE)) { + if ((scene->r.scemode & R_FULL_SAMPLE) && (scene->r.mode & R_EDGE)) { BKE_report(reports, RPT_ERROR, "Full Sample doesn't support Edge Enhance"); return 0; } @@ -1818,27 +1821,27 @@ int RE_is_rendering_allowed(Scene *scene, Object *camera_override, ReportList *r else scene->r.scemode &= ~R_FULL_SAMPLE; /* clear to be sure */ - if(scene->r.scemode & R_DOCOMP) { - if(scene->use_nodes) { + if (scene->r.scemode & R_DOCOMP) { + if (scene->use_nodes) { bNodeTree *ntree= scene->nodetree; bNode *node; - if(ntree==NULL) { + if (ntree==NULL) { BKE_report(reports, RPT_ERROR, "No Nodetree in Scene"); return 0; } - for(node= ntree->nodes.first; node; node= node->next) - if(node->type==CMP_NODE_COMPOSITE) + for (node= ntree->nodes.first; node; node= node->next) + if (node->type==CMP_NODE_COMPOSITE) break; - if(node==NULL) { + if (node==NULL) { BKE_report(reports, RPT_ERROR, "No Render Output Node in Scene"); return 0; } - if(scene->r.scemode & R_FULL_SAMPLE) { - if(composite_needs_render(scene, 0)==0) { + if (scene->r.scemode & R_FULL_SAMPLE) { + if (composite_needs_render(scene, 0)==0) { BKE_report(reports, RPT_ERROR, "Full Sample AA not supported without 3d rendering"); return 0; } @@ -1847,7 +1850,7 @@ int RE_is_rendering_allowed(Scene *scene, Object *camera_override, ReportList *r } /* check valid camera, without camera render is OK (compo, seq) */ - if(!check_valid_camera(scene, camera_override)) { + if (!check_valid_camera(scene, camera_override)) { BKE_report(reports, RPT_ERROR, "No camera"); return 0; } @@ -1856,24 +1859,24 @@ int RE_is_rendering_allowed(Scene *scene, Object *camera_override, ReportList *r object_camera_mode(&scene->r, camera_override ? camera_override : scene->camera); /* forbidden combinations */ - if(scene->r.mode & R_PANORAMA) { - if(scene->r.mode & R_ORTHO) { + if (scene->r.mode & R_PANORAMA) { + if (scene->r.mode & R_ORTHO) { BKE_report(reports, RPT_ERROR, "No Ortho render possible for Panorama"); return 0; } } /* layer flag tests */ - if(scene->r.scemode & R_SINGLE_LAYER) { + if (scene->r.scemode & R_SINGLE_LAYER) { srl= BLI_findlink(&scene->r.layers, scene->r.actlay); /* force layer to be enabled */ srl->layflag &= ~SCE_LAY_DISABLE; } - for(srl= scene->r.layers.first; srl; srl= srl->next) - if(!(srl->layflag & SCE_LAY_DISABLE)) + for (srl= scene->r.layers.first; srl; srl= srl->next) + if (!(srl->layflag & SCE_LAY_DISABLE)) break; - if(srl==NULL) { + if (srl==NULL) { BKE_report(reports, RPT_ERROR, "All RenderLayers are disabled"); return 0; } @@ -1883,13 +1886,14 @@ int RE_is_rendering_allowed(Scene *scene, Object *camera_override, ReportList *r static void validate_render_settings(Render *re) { - if(re->r.scemode & (R_EXR_TILE_FILE|R_FULL_SAMPLE)) { + if (re->r.scemode & (R_EXR_TILE_FILE|R_FULL_SAMPLE)) { /* no osa + fullsample won't work... */ - if(re->r.osa==0) + if (re->r.osa==0) re->r.scemode &= ~R_FULL_SAMPLE; - } else re->r.scemode &= ~R_FULL_SAMPLE; /* clear to be sure */ + } + else re->r.scemode &= ~R_FULL_SAMPLE; /* clear to be sure */ - if(RE_engine_is_external(re)) { + if (RE_engine_is_external(re)) { /* not supported yet */ re->r.scemode &= ~(R_EXR_TILE_FILE|R_FULL_SAMPLE); re->r.mode &= ~(R_FIELDS|R_MBLUR); @@ -1927,7 +1931,7 @@ static int render_initialize_from_main(Render *re, Main *bmain, Scene *scene, Sc winy= (scene->r.size*scene->r.ysch)/100; /* we always render smaller part, inserting it in larger image is compositor bizz, it uses disprect for it */ - if(scene->r.mode & R_BORDER) { + if (scene->r.mode & R_BORDER) { disprect.xmin = scene->r.border.xmin*winx; disprect.xmax = scene->r.border.xmax*winx; @@ -1946,7 +1950,7 @@ static int render_initialize_from_main(Render *re, Main *bmain, Scene *scene, Sc re->lay= lay; /* not too nice, but it survives anim-border render */ - if(anim) { + if (anim) { re->disprect= disprect; return 1; } @@ -1959,19 +1963,19 @@ static int render_initialize_from_main(Render *re, Main *bmain, Scene *scene, Sc * can be later set as render profile option * and default for background render. */ - if(0) { + if (0) { /* make sure dynamics are up to date */ update_physics_cache(re, scene, anim_init); } - if(srl || scene->r.scemode & R_SINGLE_LAYER) { + if (srl || scene->r.scemode & R_SINGLE_LAYER) { BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE); render_result_single_layer_begin(re); BLI_rw_mutex_unlock(&re->resultmutex); } RE_InitState(re, NULL, &scene->r, srl, winx, winy, &disprect); - if(!re->ok) /* if an error was printed, abort */ + if (!re->ok) /* if an error was printed, abort */ return 0; /* initstate makes new result, have to send changed tags around */ @@ -1998,15 +2002,15 @@ void RE_BlenderFrame(Render *re, Main *bmain, Scene *scene, SceneRenderLayer *sr scene->r.cfra= frame; - if(render_initialize_from_main(re, bmain, scene, srl, camera_override, lay, 0, 0)) { + if (render_initialize_from_main(re, bmain, scene, srl, camera_override, lay, 0, 0)) { MEM_reset_peak_memory(); BLI_exec_cb(re->main, (ID *)scene, BLI_CB_EVT_RENDER_PRE); do_render_all_options(re); - if(write_still && !G.afbreek) { - if(BKE_imtype_is_movie(scene->r.im_format.imtype)) { + if (write_still && !G.afbreek) { + if (BKE_imtype_is_movie(scene->r.im_format.imtype)) { /* operator checks this but in case its called from elsewhere */ printf("Error: cant write single images with a movie format!\n"); } @@ -2038,11 +2042,11 @@ static int do_write_image_or_movie(Render *re, Main *bmain, Scene *scene, bMovie RE_AcquireResultImage(re, &rres); /* write movie or image */ - if(BKE_imtype_is_movie(scene->r.im_format.imtype)) { + if (BKE_imtype_is_movie(scene->r.im_format.imtype)) { int dofree = 0; unsigned int *rect32 = (unsigned int *)rres.rect32; /* note; the way it gets 32 bits rects is weak... */ - if(rres.rect32 == NULL) { + if (rres.rect32 == NULL) { rect32 = MEM_mapallocN(sizeof(int)*rres.rectx*rres.recty, "temp 32 bits rect"); RE_ResultGet32(re, rect32); dofree = 1; @@ -2050,19 +2054,19 @@ static int do_write_image_or_movie(Render *re, Main *bmain, Scene *scene, bMovie ok= mh->append_movie(&re->r, scene->r.sfra, scene->r.cfra, (int *)rect32, rres.rectx, rres.recty, re->reports); - if(dofree) { + if (dofree) { MEM_freeN(rect32); } printf("Append frame %d", scene->r.cfra); } else { - if(name_override) + if (name_override) BLI_strncpy(name, name_override, sizeof(name)); else BKE_makepicstring(name, scene->r.pic, bmain->name, scene->r.cfra, scene->r.im_format.imtype, scene->r.scemode & R_EXTENSION, TRUE); - if(re->r.im_format.imtype==R_IMF_IMTYPE_MULTILAYER) { - if(re->result) { + if (re->r.im_format.imtype==R_IMF_IMTYPE_MULTILAYER) { + if (re->result) { RE_WriteRenderResult(re->reports, re->result, name, scene->r.im_format.exr_codec); printf("Saved: %s", name); } @@ -2072,17 +2076,17 @@ static int do_write_image_or_movie(Render *re, Main *bmain, Scene *scene, bMovie ok= BKE_write_ibuf_stamp(scene, camera, ibuf, name, &scene->r.im_format); - if(ok==0) { + if (ok==0) { printf("Render error: cannot save %s\n", name); } else printf("Saved: %s", name); /* optional preview images for exr */ - if(ok && scene->r.im_format.imtype==R_IMF_IMTYPE_OPENEXR && (scene->r.im_format.flag & R_IMF_FLAG_PREVIEW_JPG)) { + if (ok && scene->r.im_format.imtype==R_IMF_IMTYPE_OPENEXR && (scene->r.im_format.flag & R_IMF_FLAG_PREVIEW_JPG)) { ImageFormatData imf= scene->r.im_format; imf.imtype= R_IMF_IMTYPE_JPEG90; - if(BLI_testextensie(name, ".exr")) + if (BLI_testextensie(name, ".exr")) name[strlen(name)-4]= 0; BKE_add_image_extension(name, R_IMF_IMTYPE_JPEG90); ibuf->planes= 24; @@ -2116,7 +2120,7 @@ void RE_BlenderAnim(Render *re, Main *bmain, Scene *scene, Object *camera_overri int nfra, totrendered= 0, totskipped= 0; /* do not fully call for each frame, it initializes & pops output window */ - if(!render_initialize_from_main(re, bmain, scene, NULL, camera_override, lay, 0, 1)) + if (!render_initialize_from_main(re, bmain, scene, NULL, camera_override, lay, 0, 1)) return; /* ugly global still... is to prevent renderwin events and signal subsurfs etc to make full resol */ @@ -2125,8 +2129,8 @@ void RE_BlenderAnim(Render *re, Main *bmain, Scene *scene, Object *camera_overri re->flag |= R_ANIMATION; - if(BKE_imtype_is_movie(scene->r.im_format.imtype)) - if(!mh->start_movie(scene, &re->r, re->rectx, re->recty, re->reports)) + if (BKE_imtype_is_movie(scene->r.im_format.imtype)) + if (!mh->start_movie(scene, &re->r, re->rectx, re->recty, re->reports)) G.afbreek= 1; if (mh->get_next_frame) { @@ -2140,28 +2144,29 @@ void RE_BlenderAnim(Render *re, Main *bmain, Scene *scene, Object *camera_overri do_render_all_options(re); totrendered++; - if(re->test_break(re->tbh) == 0) { - if(!do_write_image_or_movie(re, bmain, scene, mh, NULL)) + if (re->test_break(re->tbh) == 0) { + if (!do_write_image_or_movie(re, bmain, scene, mh, NULL)) G.afbreek= 1; } - if(G.afbreek == 0) { + if (G.afbreek == 0) { BLI_exec_cb(re->main, (ID *)scene, BLI_CB_EVT_RENDER_POST); /* keep after file save */ } } else { - if(re->test_break(re->tbh)) + if (re->test_break(re->tbh)) G.afbreek= 1; } } - } else { - for(nfra= sfra, scene->r.cfra= sfra; scene->r.cfra<=efra; scene->r.cfra++) { + } + else { + for (nfra= sfra, scene->r.cfra= sfra; scene->r.cfra<=efra; scene->r.cfra++) { char name[FILE_MAX]; /* only border now, todo: camera lens. (ton) */ render_initialize_from_main(re, bmain, scene, NULL, camera_override, lay, 1, 0); - if(nfra!=scene->r.cfra) { + if (nfra!=scene->r.cfra) { /* * Skip this frame, but update for physics and particles system. * From convertblender.c: @@ -2169,7 +2174,7 @@ void RE_BlenderAnim(Render *re, Main *bmain, Scene *scene, Object *camera_overri */ unsigned int updatelay; - if(re->lay & 0xFF000000) + if (re->lay & 0xFF000000) updatelay= re->lay & 0xFF000000; else updatelay= re->lay; @@ -2181,16 +2186,16 @@ void RE_BlenderAnim(Render *re, Main *bmain, Scene *scene, Object *camera_overri nfra+= tfra; /* Touch/NoOverwrite options are only valid for image's */ - if(BKE_imtype_is_movie(scene->r.im_format.imtype) == 0) { - if(scene->r.mode & (R_NO_OVERWRITE | R_TOUCH)) + if (BKE_imtype_is_movie(scene->r.im_format.imtype) == 0) { + if (scene->r.mode & (R_NO_OVERWRITE | R_TOUCH)) BKE_makepicstring(name, scene->r.pic, bmain->name, scene->r.cfra, scene->r.im_format.imtype, scene->r.scemode & R_EXTENSION, TRUE); - if(scene->r.mode & R_NO_OVERWRITE && BLI_exists(name)) { + if (scene->r.mode & R_NO_OVERWRITE && BLI_exists(name)) { printf("skipping existing frame \"%s\"\n", name); totskipped++; continue; } - if(scene->r.mode & R_TOUCH && !BLI_exists(name)) { + if (scene->r.mode & R_TOUCH && !BLI_exists(name)) { BLI_make_existing_file(name); /* makes the dir if its not there */ BLI_file_touch(name); } @@ -2205,17 +2210,17 @@ void RE_BlenderAnim(Render *re, Main *bmain, Scene *scene, Object *camera_overri do_render_all_options(re); totrendered++; - if(re->test_break(re->tbh) == 0) { - if(!G.afbreek) - if(!do_write_image_or_movie(re, bmain, scene, mh, NULL)) + if (re->test_break(re->tbh) == 0) { + if (!G.afbreek) + if (!do_write_image_or_movie(re, bmain, scene, mh, NULL)) G.afbreek= 1; } else G.afbreek= 1; - if(G.afbreek==1) { + if (G.afbreek==1) { /* remove touched file */ - if(BKE_imtype_is_movie(scene->r.im_format.imtype) == 0) { + if (BKE_imtype_is_movie(scene->r.im_format.imtype) == 0) { if (scene->r.mode & R_TOUCH && BLI_exists(name) && BLI_file_size(name) == 0) { BLI_delete(name, 0, 0); } @@ -2224,17 +2229,17 @@ void RE_BlenderAnim(Render *re, Main *bmain, Scene *scene, Object *camera_overri break; } - if(G.afbreek==0) { + if (G.afbreek==0) { BLI_exec_cb(re->main, (ID *)scene, BLI_CB_EVT_RENDER_POST); /* keep after file save */ } } } /* end movie */ - if(BKE_imtype_is_movie(scene->r.im_format.imtype)) + if (BKE_imtype_is_movie(scene->r.im_format.imtype)) mh->end_movie(); - if(totskipped && totrendered == 0) + if (totskipped && totrendered == 0) BKE_report(re->reports, RPT_INFO, "No frames rendered, skipped to not overwrite"); scene->r.cfra= cfrao; @@ -2281,7 +2286,7 @@ int RE_ReadRenderResult(Scene *scene, Scene *scenode) winy= (scene->r.size*scene->r.ysch)/100; /* only in movie case we render smaller part */ - if(scene->r.mode & R_BORDER) { + if (scene->r.mode & R_BORDER) { disprect.xmin = scene->r.border.xmin*winx; disprect.xmax = scene->r.border.xmax*winx; @@ -2294,12 +2299,12 @@ int RE_ReadRenderResult(Scene *scene, Scene *scenode) disprect.ymax = winy; } - if(scenode) + if (scenode) scene= scenode; /* get render: it can be called from UI with draw callbacks */ re= RE_GetRender(scene->id.name); - if(re==NULL) + if (re==NULL) re= RE_NewRender(scene->id.name); RE_InitState(re, NULL, &scene->r, NULL, winx, winy, &disprect); re->scene= scene; @@ -2315,18 +2320,21 @@ void RE_set_max_threads(int threads) { if (threads==0) { RenderGlobal.threads = BLI_system_thread_count(); - } else if(threads>=1 && threads<=BLENDER_MAX_THREADS) { + } + else if (threads>=1 && threads<=BLENDER_MAX_THREADS) { RenderGlobal.threads= threads; - } else { + } + else { printf("Error, threads has to be in range 0-%d\n", BLENDER_MAX_THREADS); } } void RE_init_threadcount(Render *re) { - if(RenderGlobal.threads >= 1) { /* only set as an arg in background mode */ + if (RenderGlobal.threads >= 1) { /* only set as an arg in background mode */ re->r.threads= MIN2(RenderGlobal.threads, BLENDER_MAX_THREADS); - } else if ((re->r.mode & R_FIXED_THREADS)==0 || RenderGlobal.threads == 0) { /* Automatic threads */ + } + else if ((re->r.mode & R_FIXED_THREADS)==0 || RenderGlobal.threads == 0) { /* Automatic threads */ re->r.threads = BLI_system_thread_count(); } } @@ -2337,21 +2345,22 @@ void RE_layer_load_from_file(RenderLayer *layer, ReportList *reports, const char { ImBuf *ibuf = IMB_loadiffname(filename, IB_rect); - if(ibuf && (ibuf->rect || ibuf->rect_float)) { + if (ibuf && (ibuf->rect || ibuf->rect_float)) { if (ibuf->x == layer->rectx && ibuf->y == layer->recty) { - if(ibuf->rect_float==NULL) + if (ibuf->rect_float==NULL) IMB_float_from_rect(ibuf); memcpy(layer->rectf, ibuf->rect_float, sizeof(float)*4*layer->rectx*layer->recty); - } else { + } + else { if ((ibuf->x - x >= layer->rectx) && (ibuf->y - y >= layer->recty)) { ImBuf *ibuf_clip; - if(ibuf->rect_float==NULL) + if (ibuf->rect_float==NULL) IMB_float_from_rect(ibuf); ibuf_clip = IMB_allocImBuf(layer->rectx, layer->recty, 32, IB_rectfloat); - if(ibuf_clip) { + if (ibuf_clip) { IMB_rectcpy(ibuf_clip, ibuf, 0,0, x,y, layer->rectx, layer->recty); memcpy(layer->rectf, ibuf_clip->rect_float, sizeof(float)*4*layer->rectx*layer->recty); @@ -2375,7 +2384,7 @@ void RE_layer_load_from_file(RenderLayer *layer, ReportList *reports, const char void RE_result_load_from_file(RenderResult *result, ReportList *reports, const char *filename) { - if(!render_result_exr_file_read_path(result, filename)) { + if (!render_result_exr_file_read_path(result, filename)) { BKE_reportf(reports, RPT_ERROR, "RE_result_rect_from_file: failed to load '%s'\n", filename); return; } @@ -2392,7 +2401,7 @@ int RE_WriteEnvmapResult(struct ReportList *reports, Scene *scene, EnvMap *env, int maxX=0,maxY=0,i=0; char filepath[FILE_MAX]; - if(env->cube[1]==NULL) { + if (env->cube[1]==NULL) { BKE_report(reports, RPT_ERROR, "There is no generated environment map available to save"); return 0; } @@ -2434,7 +2443,7 @@ int RE_WriteEnvmapResult(struct ReportList *reports, Scene *scene, EnvMap *env, IMB_freeImBuf(ibuf); - if(ok) { + if (ok) { return TRUE; } else { diff --git a/source/blender/render/intern/source/pixelblending.c b/source/blender/render/intern/source/pixelblending.c index 0a8a59a860c..41b12171b2c 100644 --- a/source/blender/render/intern/source/pixelblending.c +++ b/source/blender/render/intern/source/pixelblending.c @@ -119,28 +119,28 @@ void addalphaAddfacFloat(float *dest, float *source, char addfac) /* blend colors*/ c= (m * dest[0]) + source[0]; #ifdef RE_FLOAT_COLOR_CLIPPING - if(c >= RE_FULL_COLOR_FLOAT) dest[0] = RE_FULL_COLOR_FLOAT; + if (c >= RE_FULL_COLOR_FLOAT) dest[0] = RE_FULL_COLOR_FLOAT; else #endif dest[0]= c; c= (m * dest[1]) + source[1]; #ifdef RE_FLOAT_COLOR_CLIPPING - if(c >= RE_FULL_COLOR_FLOAT) dest[1] = RE_FULL_COLOR_FLOAT; + if (c >= RE_FULL_COLOR_FLOAT) dest[1] = RE_FULL_COLOR_FLOAT; else #endif dest[1]= c; c= (m * dest[2]) + source[2]; #ifdef RE_FLOAT_COLOR_CLIPPING - if(c >= RE_FULL_COLOR_FLOAT) dest[2] = RE_FULL_COLOR_FLOAT; + if (c >= RE_FULL_COLOR_FLOAT) dest[2] = RE_FULL_COLOR_FLOAT; else #endif dest[2]= c; c= (m * dest[3]) + source[3]; #ifdef RE_ALPHA_CLIPPING - if(c >= RE_FULL_COLOR_FLOAT) dest[3] = RE_FULL_COLOR_FLOAT; + if (c >= RE_FULL_COLOR_FLOAT) dest[3] = RE_FULL_COLOR_FLOAT; else #endif dest[3]= c; @@ -172,12 +172,12 @@ void add_filt_fmask(unsigned int mask, float *col, float *rowbuf, int row_w) maskand= (mask & 255); maskshift= (mask >>8); - for(j=2; j>=0; j--) { + for (j=2; j>=0; j--) { a= j; val= *(fmask1[a] +maskand) + *(fmask2[a] +maskshift); - if(val!=0.0f) { + if (val!=0.0f) { rb1[0]+= val*r; rb1[1]+= val*g; rb1[2]+= val*b; @@ -186,7 +186,7 @@ void add_filt_fmask(unsigned int mask, float *col, float *rowbuf, int row_w) a+=3; val= *(fmask1[a] +maskand) + *(fmask2[a] +maskshift); - if(val!=0.0f) { + if (val!=0.0f) { rb2[0]+= val*r; rb2[1]+= val*g; rb2[2]+= val*b; @@ -195,7 +195,7 @@ void add_filt_fmask(unsigned int mask, float *col, float *rowbuf, int row_w) a+=3; val= *(fmask1[a] +maskand) + *(fmask2[a] +maskshift); - if(val!=0.0f) { + if (val!=0.0f) { rb3[0]+= val*r; rb3[1]+= val*g; rb3[2]+= val*b; @@ -216,7 +216,7 @@ void mask_array(unsigned int mask, float filt[][3]) unsigned int maskshift= (mask >>8); int a, j; - for(j=2; j>=0; j--) { + for (j=2; j>=0; j--) { a= j; @@ -269,7 +269,7 @@ void add_filt_fmask_coord(float filt[][3], float *col, float *rowbuf, int row_w, fpoin[1][2]= fpoin[1][1] + 4; fpoin[2][2]= fpoin[2][1] + 4; - if(y==0) { + if (y==0) { fpoin[0][0]= fpoin[1][0]; fpoin[0][1]= fpoin[1][1]; fpoin[0][2]= fpoin[1][2]; @@ -278,7 +278,7 @@ void add_filt_fmask_coord(float filt[][3], float *col, float *rowbuf, int row_w, lfilt[0][1]= filt[2][1]; lfilt[0][2]= filt[2][2]; } - else if(y==col_h-1) { + else if (y==col_h-1) { fpoin[2][0]= fpoin[1][0]; fpoin[2][1]= fpoin[1][1]; fpoin[2][2]= fpoin[1][2]; @@ -288,7 +288,7 @@ void add_filt_fmask_coord(float filt[][3], float *col, float *rowbuf, int row_w, lfilt[2][2]= filt[0][2]; } - if(x==0) { + if (x==0) { fpoin[2][0]= fpoin[2][1]; fpoin[1][0]= fpoin[1][1]; fpoin[0][0]= fpoin[0][1]; @@ -297,7 +297,7 @@ void add_filt_fmask_coord(float filt[][3], float *col, float *rowbuf, int row_w, lfilt[1][0]= filt[1][2]; lfilt[0][0]= filt[0][2]; } - else if(x==row_w-1) { + else if (x==row_w-1) { fpoin[2][2]= fpoin[2][1]; fpoin[1][2]= fpoin[1][1]; fpoin[0][2]= fpoin[0][1]; @@ -338,27 +338,27 @@ void add_filt_fmask_pixsize(unsigned int mask, float *in, float *rowbuf, int row maskand= (mask & 255); maskshift= (mask >>8); - for(j=2; j>=0; j--) { + for (j=2; j>=0; j--) { a= j; val= *(fmask1[a] +maskand) + *(fmask2[a] +maskshift); - if(val!=0.0f) { - for(i= 0; i<pixsize; i++) + if (val!=0.0f) { + for (i= 0; i<pixsize; i++) rb1[i]+= val*in[i]; } a+=3; val= *(fmask1[a] +maskand) + *(fmask2[a] +maskshift); - if(val!=0.0f) { - for(i= 0; i<pixsize; i++) + if (val!=0.0f) { + for (i= 0; i<pixsize; i++) rb2[i]+= val*in[i]; } a+=3; val= *(fmask1[a] +maskand) + *(fmask2[a] +maskshift); - if(val!=0.0f) { - for(i= 0; i<pixsize; i++) + if (val!=0.0f) { + for (i= 0; i<pixsize; i++) rb3[i]+= val*in[i]; } @@ -373,7 +373,7 @@ void addalphaAddFloat(float *dest, float *source) { /* Makes me wonder whether this is required... */ - if( dest[3] < RE_EMPTY_COLOR_FLOAT) { + if ( dest[3] < RE_EMPTY_COLOR_FLOAT) { dest[0] = source[0]; dest[1] = source[1]; dest[2] = source[2]; diff --git a/source/blender/render/intern/source/pixelshading.c b/source/blender/render/intern/source/pixelshading.c index 965abb361fd..98578c8dc70 100644 --- a/source/blender/render/intern/source/pixelshading.c +++ b/source/blender/render/intern/source/pixelshading.c @@ -89,14 +89,14 @@ static void render_lighting_halo(HaloRen *har, float col_r[3]) vn= har->no; - for(go=R.lights.first; go; go= go->next) { + for (go=R.lights.first; go; go= go->next) { lar= go->lampren; /* test for lamplayer */ - if(lar->mode & LA_LAYER) if((lar->lay & har->lay)==0) continue; + if (lar->mode & LA_LAYER) if((lar->lay & har->lay)==0) continue; /* lampdist cacluation */ - if(lar->type==LA_SUN || lar->type==LA_HEMI) { + if (lar->type==LA_SUN || lar->type==LA_HEMI) { copy_v3_v3(lv, lar->vec); lampdist= 1.0; } @@ -111,11 +111,11 @@ static void render_lighting_halo(HaloRen *har, float col_r[3]) /* ld is re-used further on (texco's) */ - if(lar->mode & LA_QUAD) { + if (lar->mode & LA_QUAD) { t= 1.0; - if(lar->ld1>0.0f) + if (lar->ld1>0.0f) t= lar->dist/(lar->dist+lar->ld1*ld); - if(lar->ld2>0.0f) + if (lar->ld2>0.0f) t*= lar->distkw/(lar->distkw+lar->ld2*ld*ld); lampdist= t; @@ -124,9 +124,9 @@ static void render_lighting_halo(HaloRen *har, float col_r[3]) lampdist= (lar->dist/(lar->dist+ld)); } - if(lar->mode & LA_SPHERE) { + if (lar->mode & LA_SPHERE) { t= lar->dist - ld; - if(t<0.0f) continue; + if (t<0.0f) continue; t/= lar->dist; lampdist*= (t); @@ -138,7 +138,7 @@ static void render_lighting_halo(HaloRen *har, float col_r[3]) lacol[1]= lar->g; lacol[2]= lar->b; - if(lar->mode & LA_TEXTURE) { + if (lar->mode & LA_TEXTURE) { ShadeInput shi; /* Warning, This is not that nice, and possibly a bit slow, @@ -152,10 +152,10 @@ static void render_lighting_halo(HaloRen *har, float col_r[3]) do_lamp_tex(lar, lv, &shi, lacol, LA_TEXTURE); } - if(lar->type==LA_SPOT) { + if (lar->type==LA_SPOT) { - if(lar->mode & LA_SQUARE) { - if(lv[0]*lar->vec[0]+lv[1]*lar->vec[1]+lv[2]*lar->vec[2]>0.0f) { + if (lar->mode & LA_SQUARE) { + if (lv[0]*lar->vec[0]+lv[1]*lar->vec[1]+lv[2]*lar->vec[2]>0.0f) { float x, lvrot[3]; /* rotate view to lampspace */ @@ -174,25 +174,25 @@ static void render_lighting_halo(HaloRen *har, float col_r[3]) } t= lar->spotsi; - if(inpr<t) continue; + if (inpr<t) continue; else { t= inpr-t; soft= 1.0; - if(t<lar->spotbl && lar->spotbl!=0.0f) { + if (t<lar->spotbl && lar->spotbl!=0.0f) { /* soft area */ i= t/lar->spotbl; t= i*i; soft= (3.0f*t-2.0f*t*i); inpr*= soft; } - if(lar->mode & LA_ONLYSHADOW) { + if (lar->mode & LA_ONLYSHADOW) { /* if(ma->mode & MA_SHADOW) { */ /* dot product positive: front side face! */ inp= vn[0]*lv[0] + vn[1]*lv[1] + vn[2]*lv[2]; - if(inp>0.0f) { + if (inp>0.0f) { /* testshadowbuf==0.0 : 100% shadow */ shadfac = testshadowbuf(&R, lar->shb, rco, dco, dco, inp, 0.0f); - if( shadfac>0.0f ) { + if ( shadfac>0.0f ) { shadfac*= inp*soft*lar->energy; ir -= shadfac; ig -= shadfac; @@ -205,7 +205,7 @@ static void render_lighting_halo(HaloRen *har, float col_r[3]) } lampdist*=inpr; } - if(lar->mode & LA_ONLYSHADOW) continue; + if (lar->mode & LA_ONLYSHADOW) continue; } @@ -217,32 +217,32 @@ static void render_lighting_halo(HaloRen *har, float col_r[3]) i= inp; - if(lar->type==LA_HEMI) { + if (lar->type==LA_HEMI) { i= 0.5f*i+0.5f; } - if(i>0.0f) { + if (i>0.0f) { i*= lampdist; } /* shadow */ - if(i> -0.41f) { /* heuristic valua! */ - if(lar->shb) { + if (i> -0.41f) { /* heuristic valua! */ + if (lar->shb) { shadfac = testshadowbuf(&R, lar->shb, rco, dco, dco, inp, 0.0f); - if(shadfac==0.0f) continue; + if (shadfac==0.0f) continue; i*= shadfac; } } - if(i>0.0f) { + if (i>0.0f) { ir+= i*lacol[0]; ig+= i*lacol[1]; ib+= i*lacol[2]; } } - if(ir<0.0f) ir= 0.0f; - if(ig<0.0f) ig= 0.0f; - if(ib<0.0f) ib= 0.0f; + if (ir<0.0f) ir= 0.0f; + if (ig<0.0f) ig= 0.0f; + if (ib<0.0f) ib= 0.0f; col_r[0]*= ir; col_r[1]*= ig; @@ -260,11 +260,11 @@ static float haloZtoDist(int z) { float zco = 0; - if(z >= 0x7FFFFF) + if (z >= 0x7FFFFF) return 10e10; else { zco = (float)z/(float)0x7FFFFF; - if(R.r.mode & R_ORTHO) + if (R.r.mode & R_ORTHO) return (R.winmat[3][2] - zco*R.winmat[3][3])/(R.winmat[2][2]); else return (R.winmat[3][2])/(R.winmat[2][2] - R.winmat[2][3]*zco); @@ -287,8 +287,8 @@ int shadeHaloFloat(HaloRen *har, float *col, int zz, float t, zn, radist, ringf=0.0f, linef=0.0f, alpha, si, co; int a; - if(R.wrld.mode & WO_MIST) { - if(har->type & HA_ONLYSKY) { + if (R.wrld.mode & WO_MIST) { + if (har->type & HA_ONLYSKY) { /* stars but no mist */ alpha= har->alfa; } @@ -299,37 +299,37 @@ int shadeHaloFloat(HaloRen *har, float *col, int zz, } else alpha= har->alfa; - if(alpha==0.0f) + if (alpha==0.0f) return 0; /* soften the halo if it intersects geometry */ - if(har->mat && har->mat->mode & MA_HALO_SOFT) { + if (har->mat && har->mat->mode & MA_HALO_SOFT) { float segment_length, halo_depth, distance_from_z /* , visible_depth */ /* UNUSED */, soften; /* calculate halo depth */ segment_length= har->hasize*sasqrt(1.0f - dist/(har->rad*har->rad)); halo_depth= 2.0f*segment_length; - if(halo_depth < FLT_EPSILON) + if (halo_depth < FLT_EPSILON) return 0; /* calculate how much of this depth is visible */ distance_from_z = haloZtoDist(zz) - haloZtoDist(har->zs); /* visible_depth = halo_depth; */ /* UNUSED */ - if(distance_from_z < segment_length) { + if (distance_from_z < segment_length) { soften= (segment_length + distance_from_z)/halo_depth; /* apply softening to alpha */ - if(soften < 1.0f) + if (soften < 1.0f) alpha *= soften; - if(alpha <= 0.0f) + if (alpha <= 0.0f) return 0; } } else { /* not a soft halo. use the old softening code */ /* halo being intersected? */ - if(har->zs> zz-har->zd) { + if (har->zs> zz-har->zd) { t= ((float)(zz-har->zs))/(float)har->zd; alpha*= sqrtf(sqrtf(t)); } @@ -338,31 +338,31 @@ int shadeHaloFloat(HaloRen *har, float *col, int zz, radist= sqrt(dist); /* watch it: not used nicely: flarec is set at zero in pixstruct */ - if(flarec) har->pixels+= (int)(har->rad-radist); + if (flarec) har->pixels+= (int)(har->rad-radist); - if(har->ringc) { + if (har->ringc) { float *rc, fac; int ofs; /* per ring an antialised circle */ ofs= har->seed; - for(a= har->ringc; a>0; a--, ofs+=2) { + for (a= har->ringc; a>0; a--, ofs+=2) { rc= hashvectf + (ofs % 768); fac= fabsf( rc[1]*(har->rad*fabsf(rc[0]) - radist) ); - if(fac< 1.0f) { + if (fac< 1.0f) { ringf+= (1.0f-fac); } } } - if(har->type & HA_VECT) { + if (har->type & HA_VECT) { dist= fabsf( har->cos*(yn) - har->sin*(xn) )/har->rad; - if(dist>1.0f) dist= 1.0f; - if(har->tex) { + if (dist>1.0f) dist= 1.0f; + if (har->tex) { zn= har->sin*xn - har->cos*yn; yn= har->cos*xn + har->sin*yn; xn= zn; @@ -370,49 +370,49 @@ int shadeHaloFloat(HaloRen *har, float *col, int zz, } else dist= dist/har->radsq; - if(har->type & HA_FLARECIRC) { + if (har->type & HA_FLARECIRC) { dist= 0.5+fabs(dist-0.5f); } - if(har->hard>=30) { + if (har->hard>=30) { dist= sqrt(dist); - if(har->hard>=40) { + if (har->hard>=40) { dist= sinf(dist*(float)M_PI_2); - if(har->hard>=50) { + if (har->hard>=50) { dist= sqrt(dist); } } } - else if(har->hard<20) dist*=dist; + else if (har->hard<20) dist*=dist; - if(dist < 1.0f) + if (dist < 1.0f) dist= (1.0f-dist); else dist= 0.0f; - if(har->linec) { + if (har->linec) { float *rc, fac; int ofs; /* per starpoint an antialiased line */ ofs= har->seed; - for(a= har->linec; a>0; a--, ofs+=3) { + for (a= har->linec; a>0; a--, ofs+=3) { rc= hashvectf + (ofs % 768); fac= fabs( (xn)*rc[0]+(yn)*rc[1]); - if(fac< 1.0f ) + if (fac< 1.0f ) linef+= (1.0f-fac); } linef*= dist; } - if(har->starpoints) { + if (har->starpoints) { float ster, angle; /* rotation */ angle= atan2(yn, xn); @@ -424,15 +424,15 @@ int shadeHaloFloat(HaloRen *har, float *col, int zz, angle= (co*xn+si*yn)*(co*yn-si*xn); ster= fabs(angle); - if(ster>1.0f) { + if (ster>1.0f) { ster= (har->rad)/(ster); - if(ster<1.0f) dist*= sqrtf(ster); + if (ster<1.0f) dist*= sqrtf(ster); } } /* disputable optimize... (ton) */ - if(dist<=0.00001f) + if (dist<=0.00001f) return 0; dist*= alpha; @@ -441,7 +441,7 @@ int shadeHaloFloat(HaloRen *har, float *col, int zz, /* The color is either the rgb spec-ed by the user, or extracted from */ /* the texture */ - if(har->tex) { + if (har->tex) { col[0]= har->r; col[1]= har->g; col[2]= har->b; @@ -458,41 +458,41 @@ int shadeHaloFloat(HaloRen *har, float *col, int zz, col[0]= dist*har->r; col[1]= dist*har->g; col[2]= dist*har->b; - if(har->type & HA_XALPHA) col[3]= dist*dist; + if (har->type & HA_XALPHA) col[3]= dist*dist; else col[3]= dist; } - if(har->mat) { - if(har->mat->mode & MA_HALO_SHADE) { + if (har->mat) { + if (har->mat->mode & MA_HALO_SHADE) { /* we test for lights because of preview... */ - if(R.lights.first) render_lighting_halo(har, col); + if (R.lights.first) render_lighting_halo(har, col); } /* Next, we do the line and ring factor modifications. */ - if(linef!=0.0f) { + if (linef!=0.0f) { Material *ma= har->mat; col[0]+= linef * ma->specr; col[1]+= linef * ma->specg; col[2]+= linef * ma->specb; - if(har->type & HA_XALPHA) col[3]+= linef*linef; + if (har->type & HA_XALPHA) col[3]+= linef*linef; else col[3]+= linef; } - if(ringf!=0.0f) { + if (ringf!=0.0f) { Material *ma= har->mat; col[0]+= ringf * ma->mirr; col[1]+= ringf * ma->mirg; col[2]+= ringf * ma->mirb; - if(har->type & HA_XALPHA) col[3]+= ringf*ringf; + if (har->type & HA_XALPHA) col[3]+= ringf*ringf; else col[3]+= ringf; } } /* alpha requires clip, gives black dots */ - if(col[3] > 1.0f) + if (col[3] > 1.0f) col[3]= 1.0f; return 1; @@ -510,15 +510,15 @@ void shadeSkyView(float col_r[3], const float rco[3], const float view[3], const skyflag = WO_ZENUP; /* Some view vector stuff. */ - if(R.wrld.skytype & WO_SKYREAL) { + if (R.wrld.skytype & WO_SKYREAL) { blend = dot_v3v3(view, R.grvec); - if(blend<0.0f) skyflag= 0; + if (blend<0.0f) skyflag= 0; blend= fabs(blend); } - else if(R.wrld.skytype & WO_SKYPAPER) { + else if (R.wrld.skytype & WO_SKYPAPER) { blend= 0.5f + 0.5f * view[1]; } else { @@ -531,9 +531,9 @@ void shadeSkyView(float col_r[3], const float rco[3], const float view[3], const /* Careful: SKYTEX and SKYBLEND are NOT mutually exclusive! If */ /* SKYBLEND is active, the texture and color blend are added. */ - if(R.wrld.skytype & WO_SKYTEX) { + if (R.wrld.skytype & WO_SKYTEX) { copy_v3_v3(lo, view); - if(R.wrld.skytype & WO_SKYREAL) { + if (R.wrld.skytype & WO_SKYREAL) { mul_m3_v3(R.imat, lo); @@ -543,15 +543,16 @@ void shadeSkyView(float col_r[3], const float rco[3], const float view[3], const do_sky_tex(rco, lo, dxyview, hor, zen, &blend, skyflag, thread); } - if(blend>1.0f) blend= 1.0f; + if (blend>1.0f) blend= 1.0f; blendm= 1.0f-blend; /* No clipping, no conversion! */ - if(R.wrld.skytype & WO_SKYBLEND) { + if (R.wrld.skytype & WO_SKYBLEND) { col_r[0] = (blendm*hor[0] + blend*zen[0]); col_r[1] = (blendm*hor[1] + blend*zen[1]); col_r[2] = (blendm*hor[2] + blend*zen[2]); - } else { + } + else { /* Done when a texture was grabbed. */ col_r[0]= hor[0]; col_r[1]= hor[1]; @@ -567,13 +568,13 @@ void shadeSunView(float col_r[3], const float view[3]) float sview[3]; int do_init= 1; - for(go=R.lights.first; go; go= go->next) { + for (go=R.lights.first; go; go= go->next) { lar= go->lampren; - if(lar->type==LA_SUN && lar->sunsky && (lar->sunsky->effect_type & LA_SUN_EFFECT_SKY)){ + if (lar->type==LA_SUN && lar->sunsky && (lar->sunsky->effect_type & LA_SUN_EFFECT_SKY)) { float sun_collector[3]; float colorxyz[3]; - if(do_init) { + if (do_init) { normalize_v3_v3(sview, view); mul_m3_v3(R.imat, sview); @@ -608,7 +609,7 @@ void shadeSkyPixel(float collector[4], float fx, float fy, short thread) float fac; - if((R.wrld.skytype & (WO_SKYBLEND+WO_SKYTEX))==0) { + if ((R.wrld.skytype & (WO_SKYBLEND+WO_SKYTEX))==0) { /* 1. solid color */ copy_v3_v3(collector, &R.wrld.horr); @@ -618,7 +619,7 @@ void shadeSkyPixel(float collector[4], float fx, float fy, short thread) /* 2. */ /* This one true because of the context of this routine */ - if(R.wrld.skytype & WO_SKYPAPER) { + if (R.wrld.skytype & WO_SKYPAPER) { view[0]= -1.0f + 2.0f*(fx/(float)R.winx); view[1]= -1.0f + 2.0f*(fy/(float)R.winy); view[2]= 0.0; @@ -630,7 +631,7 @@ void shadeSkyPixel(float collector[4], float fx, float fy, short thread) calc_view_vector(view, fx, fy); fac= normalize_v3(view); - if(R.wrld.skytype & WO_SKYTEX) { + if (R.wrld.skytype & WO_SKYTEX) { dxyview[0]= -R.viewdx/fac; dxyview[1]= -R.viewdy/fac; } diff --git a/source/blender/render/intern/source/pointdensity.c b/source/blender/render/intern/source/pointdensity.c index 1904d5dce63..5d4f9db9a02 100644 --- a/source/blender/render/intern/source/pointdensity.c +++ b/source/blender/render/intern/source/pointdensity.c @@ -151,7 +151,7 @@ static void pointdensity_cache_psys(Render *re, PointDensity *pd, Object *ob, Pa for (i=0, pa=psys->particles; i < total_particles; i++, pa++) { state.time = cfra; - if(psys_get_particle_state(&sim, i, &state, 0)) { + if (psys_get_particle_state(&sim, i, &state, 0)) { copy_v3_v3(partco, state.co); @@ -159,7 +159,8 @@ static void pointdensity_cache_psys(Render *re, PointDensity *pd, Object *ob, Pa mul_m4_v3(ob->imat, partco); else if (pd->psys_cache_space == TEX_PD_OBJECTLOC) { sub_v3_v3(partco, ob->loc); - } else { + } + else { /* TEX_PD_WORLDSPACE */ } @@ -175,7 +176,8 @@ static void pointdensity_cache_psys(Render *re, PointDensity *pd, Object *ob, Pa if (i < psys->totpart) { pa_time = (cfra - pa->time)/pa->lifetime; - } else { + } + else { ChildParticle *cpa= (psys->child + i) - psys->totpart; float pa_birthtime, pa_dietime; @@ -191,7 +193,7 @@ static void pointdensity_cache_psys(Render *re, PointDensity *pd, Object *ob, Pa BLI_bvhtree_balance(pd->point_tree); dm->release(dm); - if(psys->lattice){ + if (psys->lattice) { end_latt_deform(psys->lattice); psys->lattice=0; } @@ -214,7 +216,7 @@ static void pointdensity_cache_object(Render *re, PointDensity *pd, Object *ob) pd->point_tree = BLI_bvhtree_new(pd->totpoints, 0.0, 4, 6); - for(i=0; i < pd->totpoints; i++, mvert++) { + for (i=0; i < pd->totpoints; i++, mvert++) { float co[3]; copy_v3_v3(co, mvert->co); @@ -243,7 +245,7 @@ void cache_pointdensity(Render *re, Tex *tex) { PointDensity *pd = tex->pd; - if(!pd) + if (!pd) return; if (pd->point_tree) { @@ -293,14 +295,14 @@ void make_pointdensities(Render *re) { Tex *tex; - if(re->scene->r.scemode & R_PREVIEWBUTS) + if (re->scene->r.scemode & R_PREVIEWBUTS) return; re->i.infostr= "Caching Point Densities"; re->stats_draw(re->sdh, &re->i); for (tex= re->main->tex.first; tex; tex= tex->id.next) { - if(tex->id.us && tex->type==TEX_POINTDENSITY) { + if (tex->id.us && tex->type==TEX_POINTDENSITY) { cache_pointdensity(re, tex); } } @@ -313,11 +315,11 @@ void free_pointdensities(Render *re) { Tex *tex; - if(re->scene->r.scemode & R_PREVIEWBUTS) + if (re->scene->r.scemode & R_PREVIEWBUTS) return; for (tex= re->main->tex.first; tex; tex= tex->id.next) { - if(tex->id.us && tex->type==TEX_POINTDENSITY) { + if (tex->id.us && tex->type==TEX_POINTDENSITY) { free_pointdensity(re, tex); } } diff --git a/source/blender/render/intern/source/rayshade.c b/source/blender/render/intern/source/rayshade.c index 355bae0d2d8..1222dd121a7 100644 --- a/source/blender/render/intern/source/rayshade.c +++ b/source/blender/render/intern/source/rayshade.c @@ -87,7 +87,7 @@ static int test_break(void *data) static void RE_rayobject_config_control(RayObject *r, Render *re) { - if(RE_rayobject_isRayAPI(r)) + if (RE_rayobject_isRayAPI(r)) { r = RE_rayobject_align( r ); r->control.data = re; @@ -99,7 +99,7 @@ static RayObject* RE_rayobject_create(Render *re, int type, int size) { RayObject * res = NULL; - if(type == R_RAYSTRUCTURE_AUTO) + if (type == R_RAYSTRUCTURE_AUTO) { //TODO //if(detect_simd()) @@ -111,7 +111,7 @@ static RayObject* RE_rayobject_create(Render *re, int type, int size) } #ifndef __SSE__ - if(type == R_RAYSTRUCTURE_SIMD_SVBVH || type == R_RAYSTRUCTURE_SIMD_QBVH) + if (type == R_RAYSTRUCTURE_SIMD_SVBVH || type == R_RAYSTRUCTURE_SIMD_QBVH) { puts("Warning: Using VBVH (SSE was disabled at compile time)"); type = R_RAYSTRUCTURE_VBVH; @@ -119,21 +119,21 @@ static RayObject* RE_rayobject_create(Render *re, int type, int size) #endif - if(type == R_RAYSTRUCTURE_OCTREE) //TODO dynamic ocres + if (type == R_RAYSTRUCTURE_OCTREE) //TODO dynamic ocres res = RE_rayobject_octree_create(re->r.ocres, size); - else if(type == R_RAYSTRUCTURE_BLIBVH) + else if (type == R_RAYSTRUCTURE_BLIBVH) res = RE_rayobject_blibvh_create(size); - else if(type == R_RAYSTRUCTURE_VBVH) + else if (type == R_RAYSTRUCTURE_VBVH) res = RE_rayobject_vbvh_create(size); - else if(type == R_RAYSTRUCTURE_SIMD_SVBVH) + else if (type == R_RAYSTRUCTURE_SIMD_SVBVH) res = RE_rayobject_svbvh_create(size); - else if(type == R_RAYSTRUCTURE_SIMD_QBVH) + else if (type == R_RAYSTRUCTURE_SIMD_QBVH) res = RE_rayobject_qbvh_create(size); else res = RE_rayobject_vbvh_create(size); //Fallback - if(res) + if (res) RE_rayobject_config_control(res, re); return res; @@ -148,36 +148,36 @@ void freeraytree(Render *re) { ObjectInstanceRen *obi; - if(re->raytree) + if (re->raytree) { RE_rayobject_free(re->raytree); re->raytree = NULL; } - if(re->rayfaces) + if (re->rayfaces) { MEM_freeN(re->rayfaces); re->rayfaces = NULL; } - if(re->rayprimitives) + if (re->rayprimitives) { MEM_freeN(re->rayprimitives); re->rayprimitives = NULL; } - for(obi=re->instancetable.first; obi; obi=obi->next) + for (obi=re->instancetable.first; obi; obi=obi->next) { ObjectRen *obr = obi->obr; - if(obr->raytree) + if (obr->raytree) { RE_rayobject_free(obr->raytree); obr->raytree = NULL; } - if(obr->rayfaces) + if (obr->rayfaces) { MEM_freeN(obr->rayfaces); obr->rayfaces = NULL; } - if(obi->raytree) + if (obi->raytree) { RE_rayobject_free(obi->raytree); obi->raytree = NULL; @@ -189,7 +189,7 @@ void freeraytree(Render *re) RayCounter sum; memset( &sum, 0, sizeof(sum) ); int i; - for(i=0; i<BLENDER_MAX_THREADS; i++) + for (i=0; i<BLENDER_MAX_THREADS; i++) RE_RC_MERGE(&sum, re_rc_counter+i); RE_RC_INFO(&sum); } @@ -199,8 +199,8 @@ void freeraytree(Render *re) static int is_raytraceable_vlr(Render *re, VlakRen *vlr) { /* note: volumetric must be tracable, wire must not */ - if((re->flag & R_BAKE_TRACE) || (vlr->flag & R_TRACEBLE) || (vlr->mat->material_type == MA_TYPE_VOLUME)) - if(vlr->mat->material_type != MA_TYPE_WIRE) + if ((re->flag & R_BAKE_TRACE) || (vlr->flag & R_TRACEBLE) || (vlr->mat->material_type == MA_TYPE_VOLUME)) + if (vlr->mat->material_type != MA_TYPE_WIRE) return 1; return 0; } @@ -210,13 +210,13 @@ static int is_raytraceable(Render *re, ObjectInstanceRen *obi) int v; ObjectRen *obr = obi->obr; - if(re->excludeob && obr->ob == re->excludeob) + if (re->excludeob && obr->ob == re->excludeob) return 0; - for(v=0;v<obr->totvlak;v++) { + for (v=0;v<obr->totvlak;v++) { VlakRen *vlr = obr->vlaknodes[v>>8].vlak + (v&255); - if(is_raytraceable_vlr(re, vlr)) + if (is_raytraceable_vlr(re, vlr)) return 1; } @@ -232,7 +232,7 @@ RayObject* makeraytree_object(Render *re, ObjectInstanceRen *obi) // update render stats ObjectRen *obr = obi->obr; - if(obr->raytree == NULL) + if (obr->raytree == NULL) { RayObject *raytree; RayFace *face = NULL; @@ -241,10 +241,10 @@ RayObject* makeraytree_object(Render *re, ObjectInstanceRen *obi) //Count faces int faces = 0; - for(v=0;v<obr->totvlak;v++) + for (v=0;v<obr->totvlak;v++) { VlakRen *vlr = obr->vlaknodes[v>>8].vlak + (v&255); - if(is_raytraceable_vlr(re, vlr)) + if (is_raytraceable_vlr(re, vlr)) faces++; } @@ -253,17 +253,17 @@ RayObject* makeraytree_object(Render *re, ObjectInstanceRen *obi) //Create Ray cast accelaration structure raytree = RE_rayobject_create( re, re->r.raytrace_structure, faces ); - if( (re->r.raytrace_options & R_RAYTRACE_USE_LOCAL_COORDS) ) + if ( (re->r.raytrace_options & R_RAYTRACE_USE_LOCAL_COORDS) ) vlakprimitive = obr->rayprimitives = (VlakPrimitive*)MEM_callocN(faces*sizeof(VlakPrimitive), "ObjectRen primitives"); else face = obr->rayfaces = (RayFace*)MEM_callocN(faces*sizeof(RayFace), "ObjectRen faces"); obr->rayobi = obi; - for(v=0;v<obr->totvlak;v++) + for (v=0;v<obr->totvlak;v++) { VlakRen *vlr = obr->vlaknodes[v>>8].vlak + (v&255); - if(is_raytraceable_vlr(re, vlr)) + if (is_raytraceable_vlr(re, vlr)) { if ((re->r.raytrace_options & R_RAYTRACE_USE_LOCAL_COORDS)) { RE_rayobject_add( raytree, RE_vlakprimitive_from_vlak( vlakprimitive, obi, vlr ) ); @@ -279,38 +279,38 @@ RayObject* makeraytree_object(Render *re, ObjectInstanceRen *obi) RE_rayobject_done( raytree ); /* in case of cancel during build, raytree is not usable */ - if(test_break(re)) + if (test_break(re)) RE_rayobject_free(raytree); else obr->raytree= raytree; } - if(obr->raytree) { - if((obi->flag & R_TRANSFORMED) && obi->raytree == NULL) + if (obr->raytree) { + if ((obi->flag & R_TRANSFORMED) && obi->raytree == NULL) { obi->transform_primitives = 0; obi->raytree = RE_rayobject_instance_create( obr->raytree, obi->mat, obi, obi->obr->rayobi ); } } - if(obi->raytree) return obi->raytree; + if (obi->raytree) return obi->raytree; return obi->obr->raytree; } static int has_special_rayobject(Render *re, ObjectInstanceRen *obi) { - if( (obi->flag & R_TRANSFORMED) && (re->r.raytrace_options & R_RAYTRACE_USE_INSTANCES) ) + if ( (obi->flag & R_TRANSFORMED) && (re->r.raytrace_options & R_RAYTRACE_USE_INSTANCES) ) { ObjectRen *obr = obi->obr; int v, faces = 0; - for(v=0;v<obr->totvlak;v++) + for (v=0;v<obr->totvlak;v++) { VlakRen *vlr = obr->vlaknodes[v>>8].vlak + (v&255); - if(is_raytraceable_vlr(re, vlr)) + if (is_raytraceable_vlr(re, vlr)) { faces++; - if(faces > 4) + if (faces > 4) return 1; } } @@ -328,8 +328,8 @@ static void makeraytree_single(Render *re) VlakPrimitive *vlakprimitive = NULL; int faces = 0, obs = 0, special = 0; - for(obi=re->instancetable.first; obi; obi=obi->next) - if(is_raytraceable(re, obi)) + for (obi=re->instancetable.first; obi; obi=obi->next) + if (is_raytraceable(re, obi)) { ObjectRen *obr = obi->obr; obs++; @@ -339,16 +339,16 @@ static void makeraytree_single(Render *re) } else { int v; - for(v=0;v<obr->totvlak;v++) + for (v=0;v<obr->totvlak;v++) { VlakRen *vlr = obr->vlaknodes[v>>8].vlak + (v&255); - if(is_raytraceable_vlr(re, vlr)) + if (is_raytraceable_vlr(re, vlr)) faces++; } } } - if(faces + special == 0) + if (faces + special == 0) { re->raytree = RE_rayobject_empty_create(); return; @@ -357,7 +357,7 @@ static void makeraytree_single(Render *re) //Create raytree raytree = re->raytree = RE_rayobject_create( re, re->r.raytrace_structure, faces+special ); - if( (re->r.raytrace_options & R_RAYTRACE_USE_LOCAL_COORDS) ) + if ( (re->r.raytrace_options & R_RAYTRACE_USE_LOCAL_COORDS) ) { vlakprimitive = re->rayprimitives = (VlakPrimitive*)MEM_callocN(faces*sizeof(VlakPrimitive), "Raytrace vlak-primitives"); } @@ -365,16 +365,16 @@ static void makeraytree_single(Render *re) face = re->rayfaces = (RayFace*)MEM_callocN(faces*sizeof(RayFace), "Render ray faces"); } - for(obi=re->instancetable.first; obi; obi=obi->next) - if(is_raytraceable(re, obi)) + for (obi=re->instancetable.first; obi; obi=obi->next) + if (is_raytraceable(re, obi)) { - if(test_break(re)) + if (test_break(re)) break; if (has_special_rayobject(re, obi)) { RayObject *obj = makeraytree_object(re, obi); - if(test_break(re)) + if (test_break(re)) break; if (obj) @@ -384,12 +384,12 @@ static void makeraytree_single(Render *re) int v; ObjectRen *obr = obi->obr; - if(obi->flag & R_TRANSFORMED) + if (obi->flag & R_TRANSFORMED) { obi->transform_primitives = 1; } - for(v=0;v<obr->totvlak;v++) + for (v=0;v<obr->totvlak;v++) { VlakRen *vlr = obr->vlaknodes[v>>8].vlak + (v&255); if (is_raytraceable_vlr(re, vlr)) { @@ -400,12 +400,12 @@ static void makeraytree_single(Render *re) } else { RE_rayface_from_vlak(face, obi, vlr); - if((obi->flag & R_TRANSFORMED)) + if ((obi->flag & R_TRANSFORMED)) { mul_m4_v3(obi->mat, face->v1); mul_m4_v3(obi->mat, face->v2); mul_m4_v3(obi->mat, face->v3); - if(RE_rayface_isQuad(face)) + if (RE_rayface_isQuad(face)) mul_m4_v3(obi->mat, face->v4); } @@ -417,7 +417,7 @@ static void makeraytree_single(Render *re) } } - if(!test_break(re)) + if (!test_break(re)) { re->i.infostr= "Raytree.. building"; re->stats_draw(re->sdh, &re->i); @@ -436,7 +436,7 @@ void makeraytree(Render *re) /* disable options not yet supported by octree, * they might actually never be supported (unless people really need it) */ - if(re->r.raytrace_structure == R_RAYSTRUCTURE_OCTREE) + if (re->r.raytrace_structure == R_RAYSTRUCTURE_OCTREE) re->r.raytrace_options &= ~( R_RAYTRACE_USE_INSTANCES | R_RAYTRACE_USE_LOCAL_COORDS); makeraytree_single(re); @@ -452,7 +452,7 @@ void makeraytree(Render *re) //This is ONLY needed to kept a bogus behavior of SUN and HEMI lights INIT_MINMAX(min, max); RE_rayobject_merge_bb( re->raytree, min, max ); - for(i=0; i<3; i++) + for (i=0; i<3; i++) { min[i] += 0.01f; max[i] += 0.01f; @@ -460,7 +460,7 @@ void makeraytree(Render *re) } re->maxdist = dot_v3v3(sub, sub); - if(re->maxdist > 0.0f) re->maxdist= sqrt(re->maxdist); + if (re->maxdist > 0.0f) re->maxdist= sqrt(re->maxdist); re->i.infostr= "Raytree finished"; re->stats_draw(re->sdh, &re->i); @@ -471,7 +471,7 @@ void makeraytree(Render *re) #endif } -/* if(shi->osatex) */ +/* if (shi->osatex) */ static void shade_ray_set_derivative(ShadeInput *shi) { float detsh, t00, t10, t01, t11; @@ -481,7 +481,7 @@ static void shade_ray_set_derivative(ShadeInput *shi) axis_dominant_v3(&axis1, &axis2, shi->facenor); /* compute u,v and derivatives */ - if(shi->obi->flag & R_TRANSFORMED) { + if (shi->obi->flag & R_TRANSFORMED) { float v1[3], v2[3], v3[3]; mul_v3_m3v3(v1, shi->obi->nmat, shi->v1->co); @@ -535,7 +535,7 @@ void shade_ray(Isect *is, ShadeInput *shi, ShadeResult *shr) shi->mat= vlr->mat; shade_input_init_material(shi); - if(is->isect==2) + if (is->isect==2) shade_input_set_triangle_i(shi, obi, vlr, 0, 2, 3); else shade_input_set_triangle_i(shi, obi, vlr, 0, 1, 2); @@ -544,21 +544,22 @@ void shade_ray(Isect *is, ShadeInput *shi, ShadeResult *shr) shi->v= is->v; shi->dx_u= shi->dx_v= shi->dy_u= shi->dy_v= 0.0f; - if(shi->osatex) + if (shi->osatex) shade_ray_set_derivative(shi); shade_input_set_normals(shi); shade_input_set_shade_texco(shi); if (shi->mat->material_type == MA_TYPE_VOLUME) { - if(ELEM(is->mode, RE_RAY_SHADOW, RE_RAY_SHADOW_TRA)) { + if (ELEM(is->mode, RE_RAY_SHADOW, RE_RAY_SHADOW_TRA)) { shade_volume_shadow(shi, shr, is); - } else { + } + else { shade_volume_outside(shi, shr); } } - else if(is->mode==RE_RAY_SHADOW_TRA) { + else if (is->mode==RE_RAY_SHADOW_TRA) { /* temp hack to prevent recursion */ - if(shi->nodes==0 && shi->mat->nodetree && shi->mat->use_nodes) { + if (shi->nodes==0 && shi->mat->nodetree && shi->mat->use_nodes) { ntreeShaderExecTree(shi->mat->nodetree, shi, shr); shi->mat= vlr->mat; /* shi->mat is being set in nodetree */ } @@ -566,7 +567,7 @@ void shade_ray(Isect *is, ShadeInput *shi, ShadeResult *shr) shade_color(shi, shr); } else { - if(shi->mat->nodetree && shi->mat->use_nodes) { + if (shi->mat->nodetree && shi->mat->use_nodes) { ntreeShaderExecTree(shi->mat->nodetree, shi, shr); shi->mat= vlr->mat; /* shi->mat is being set in nodetree */ } @@ -588,15 +589,15 @@ static int refraction(float refract[3], const float n[3], const float view[3], f dot = dot_v3v3(view, n); - if(dot>0.0f) { + if (dot>0.0f) { index = 1.0f/index; fac= 1.0f - (1.0f - dot*dot)*index*index; - if(fac<= 0.0f) return 0; + if (fac<= 0.0f) return 0; fac= -dot*index + sqrtf(fac); } else { fac= 1.0f - (1.0f - dot*dot)*index*index; - if(fac<= 0.0f) return 0; + if (fac<= 0.0f) return 0; fac= -dot*index - sqrtf(fac); } @@ -622,7 +623,7 @@ static void reflection(float ref[3], float n[3], const float view[3], const floa /* test phong normals, then we should prevent vector going to the back */ f1= dot_v3v3(ref, orn); - if(f1>0.0f) { + if (f1>0.0f) { f1+= 0.01f; ref[0]-= f1*orn[0]; ref[1]-= f1*orn[1]; @@ -672,7 +673,7 @@ static float shade_by_transmission(Isect *is, ShadeInput *shi, ShadeResult *shr) d= shi->mat->tx_limit; p = shi->mat->tx_falloff; - if(p < 0.0f) p= 0.0f; + if (p < 0.0f) p= 0.0f; else if (p > 10.0f) p= 10.0f; shr->alpha *= powf(d, p); @@ -688,7 +689,8 @@ static void ray_fadeout_endcolor(float col[3], ShadeInput *origshi, ShadeInput * /* un-intersected rays get either rendered material color or sky color */ if (origshi->mat->fadeto_mir == MA_RAYMIR_FADETOMAT) { copy_v3_v3(col, shr->combined); - } else if (origshi->mat->fadeto_mir == MA_RAYMIR_FADETOSKY) { + } + else if (origshi->mat->fadeto_mir == MA_RAYMIR_FADETOSKY) { copy_v3_v3(shi->view, vec); normalize_v3(shi->view); @@ -729,7 +731,7 @@ static void traceray(ShadeInput *origshi, ShadeResult *origshr, short depth, con isec.orig.face = vlr; RE_RC_INIT(isec, shi); - if(RE_rayobject_raycast(R.raytree, &isec)) { + if (RE_rayobject_raycast(R.raytree, &isec)) { ShadeResult shr= {{0}}; float d= 1.0f; @@ -756,10 +758,10 @@ static void traceray(ShadeInput *origshi, ShadeResult *origshr, short depth, con if (traflag & RAY_INSIDE) d= shade_by_transmission(&isec, &shi, &shr); - if(depth>0) { + if (depth>0) { float fr, fg, fb, f, f1; - if((shi.mat->mode_l & MA_TRANSP) && shr.alpha < 1.0f && (shi.mat->mode_l & (MA_ZTRANSP | MA_RAYTRANSP))) { + if ((shi.mat->mode_l & MA_TRANSP) && shr.alpha < 1.0f && (shi.mat->mode_l & (MA_ZTRANSP | MA_RAYTRANSP))) { float nf, f, refract[3], tracol[4]; tracol[0]= shi.r; @@ -767,11 +769,11 @@ static void traceray(ShadeInput *origshi, ShadeResult *origshr, short depth, con tracol[2]= shi.b; tracol[3]= col[3]; // we pass on and accumulate alpha - if((shi.mat->mode & MA_TRANSP) && (shi.mat->mode & MA_RAYTRANSP)) { + if ((shi.mat->mode & MA_TRANSP) && (shi.mat->mode & MA_RAYTRANSP)) { /* don't overwrite traflag, it's value is used in mirror reflection */ int new_traflag = traflag; - if(new_traflag & RAY_INSIDE) { + if (new_traflag & RAY_INSIDE) { /* inside the material, so use inverse normal */ float norm[3]; norm[0]= - shi.vn[0]; @@ -820,13 +822,13 @@ static void traceray(ShadeInput *origshi, ShadeResult *origshr, short depth, con else col[3]= 1.0f; - if(shi.mat->mode_l & MA_RAYMIRROR) { + if (shi.mat->mode_l & MA_RAYMIRROR) { f= shi.ray_mirror; - if(f!=0.0f) f*= fresnel_fac(shi.view, shi.vn, shi.mat->fresnel_mir_i, shi.mat->fresnel_mir); + if (f!=0.0f) f*= fresnel_fac(shi.view, shi.vn, shi.mat->fresnel_mir_i, shi.mat->fresnel_mir); } else f= 0.0f; - if(f!=0.0f) { + if (f!=0.0f) { float mircol[4]; float ref[3]; @@ -891,16 +893,16 @@ static void DP_energy(float *table, float vec[2], int tot, float xsize, float ys min*= min; result[0]= result[1]= 0.0f; - for(y= -1; y<2; y++) { + for (y= -1; y<2; y++) { dy= ysize*y; - for(x= -1; x<2; x++) { + for (x= -1; x<2; x++) { dx= xsize*x; fp= table; - for(a=0; a<tot; a++, fp+= 2) { + for (a=0; a<tot; a++, fp+= 2) { force[0]= vec[0] - fp[0]-dx; force[1]= vec[1] - fp[1]-dy; dist= force[0]*force[0] + force[1]*force[1]; - if(dist < min && dist>0.0f) { + if (dist < min && dist>0.0f) { result[0]+= force[0]/dist; result[1]+= force[1]/dist; } @@ -922,11 +924,11 @@ static void jitter_plane_offset(float *jitter1, float *jitter2, int tot, float s float hsizex= 0.5f*sizex, hsizey= 0.5f*sizey; int x; - for(x=tot; x>0; x--, jitter1+=2, jitter2+=2) { + for (x=tot; x>0; x--, jitter1+=2, jitter2+=2) { jitter2[0]= jitter1[0] + dsizex; jitter2[1]= jitter1[1] + dsizey; - if(jitter2[0] > hsizex) jitter2[0]-= sizex; - if(jitter2[1] > hsizey) jitter2[1]-= sizey; + if (jitter2[0] > hsizex) jitter2[0]-= sizex; + if (jitter2[1] > hsizey) jitter2[1]-= sizey; } } @@ -938,29 +940,29 @@ void init_jitter_plane(LampRen *lar) int x, tot= lar->ray_totsamp; /* test if already initialized */ - if(lar->jitter) return; + if (lar->jitter) return; /* at least 4, or max threads+1 tables */ - if(BLENDER_MAX_THREADS < 4) x= 4; + if (BLENDER_MAX_THREADS < 4) x= 4; else x= BLENDER_MAX_THREADS+1; fp= lar->jitter= MEM_callocN(x*tot*2*sizeof(float), "lamp jitter tab"); /* if 1 sample, we leave table to be zero's */ - if(tot>1) { + if (tot>1) { int iter=12; /* set per-lamp fixed seed */ BLI_srandom(tot); /* fill table with random locations, area_size large */ - for(x=0; x<tot; x++, fp+=2) { + for (x=0; x<tot; x++, fp+=2) { fp[0]= (BLI_frand()-0.5f)*lar->area_size; fp[1]= (BLI_frand()-0.5f)*lar->area_sizey; } - while(iter--) { + while (iter--) { fp= lar->jitter; - for(x=tot; x>0; x--, fp+=2) { + for (x=tot; x>0; x--, fp+=2) { DP_energy(lar->jitter, fp, tot, lar->area_size, lar->area_sizey); } } @@ -978,17 +980,17 @@ static float *give_jitter_plane(LampRen *lar, int thread, int xs, int ys) tot= lar->ray_totsamp; - if(lar->ray_samp_type & LA_SAMP_JITTER) { + if (lar->ray_samp_type & LA_SAMP_JITTER) { /* made it threadsafe */ - if(lar->xold[thread]!=xs || lar->yold[thread]!=ys) { + if (lar->xold[thread]!=xs || lar->yold[thread]!=ys) { jitter_plane_offset(lar->jitter, lar->jitter+2*(thread+1)*tot, tot, lar->area_size, lar->area_sizey, BLI_thread_frand(thread), BLI_thread_frand(thread)); lar->xold[thread]= xs; lar->yold[thread]= ys; } return lar->jitter+2*(thread+1)*tot; } - if(lar->ray_samp_type & LA_SAMP_DITHER) { + if (lar->ray_samp_type & LA_SAMP_DITHER) { return lar->jitter + 2*tot*((xs & 1)+2*(ys & 1)); } @@ -1203,8 +1205,8 @@ static QMCSampler *get_thread_qmcsampler(Render *re, int thread, int type, int t /* create qmc samplers as needed, since recursion makes it hard to * predict how many are needed */ - for(qsa=re->qmcsamplers[thread].first; qsa; qsa=qsa->next) { - if(qsa->type == type && qsa->tot == tot && !qsa->used) { + for (qsa=re->qmcsamplers[thread].first; qsa; qsa=qsa->next) { + if (qsa->type == type && qsa->tot == tot && !qsa->used) { qsa->used= 1; return qsa; } @@ -1224,11 +1226,11 @@ static void release_thread_qmcsampler(Render *UNUSED(re), int UNUSED(thread), QM void free_render_qmcsampler(Render *re) { - if(re->qmcsamplers) { + if (re->qmcsamplers) { QMCSampler *qsa, *next; int a; - for(a=0; a<BLENDER_MAX_THREADS; a++) { - for(qsa=re->qmcsamplers[a].first; qsa; qsa=next) { + for (a=0; a<BLENDER_MAX_THREADS; a++) { + for (qsa=re->qmcsamplers[a].first; qsa; qsa=next) { next= qsa->next; QMC_freeSampler(qsa); } @@ -1270,7 +1272,8 @@ static int adaptive_sample_contrast_val(int samples, float prev, float val, floa * going to be the same is wasting effort */ if (fabsf( prev/(float)(samples-1) - val/(float)samples ) < thresh) { return 1; - } else + } + else return 0; } @@ -1318,16 +1321,18 @@ static void trace_refract(float col[4], ShadeInput *shi, ShadeResult *shr) /* all samples are generated per pixel */ qsa = get_thread_qmcsampler(&R, shi->thread, samp_type, max_samples); QMC_initPixel(qsa, shi->thread); - } else + } + else max_samples = 1; while (samples < max_samples) { - if(refraction(v_refract, shi->vn, shi->view, shi->ang)) { + if (refraction(v_refract, shi->vn, shi->view, shi->ang)) { traflag |= RAY_INSIDE; - } else { + } + else { /* total external reflection can happen for materials with IOR < 1.0 */ - if((shi->vlr->flag & R_SMOOTH)) + if ((shi->vlr->flag & R_SMOOTH)) reflection(v_refract, shi->vn, shi->view, shi->facenor); else reflection_simple(v_refract, shi->vn, shi->view); @@ -1349,7 +1354,8 @@ static void trace_refract(float col[4], ShadeInput *shi, ShadeResult *shr) add_v3_v3(v_refract_new, orthy); normalize_v3(v_refract_new); - } else { + } + else { /* no blurriness, use the original normal */ copy_v3_v3(v_refract_new, v_refract); } @@ -1417,7 +1423,8 @@ static void trace_reflect(float col[3], ShadeInput *shi, ShadeResult *shr, float /* all samples are generated per pixel */ qsa = get_thread_qmcsampler(&R, shi->thread, samp_type, max_samples); QMC_initPixel(qsa, shi->thread); - } else + } + else max_samples = 1; while (samples < max_samples) { @@ -1433,7 +1440,8 @@ static void trace_reflect(float col[3], ShadeInput *shi, ShadeResult *shr, float copy_v3_v3(orthy, shi->tang); mul_v3_fl(orthx, samp3d[0]); mul_v3_fl(orthy, samp3d[1]*aniso); - } else { + } + else { ortho_basis_v3v3_v3( orthx, orthy,shi->vn); mul_v3_fl(orthx, samp3d[0]); mul_v3_fl(orthy, samp3d[1]); @@ -1443,12 +1451,13 @@ static void trace_reflect(float col[3], ShadeInput *shi, ShadeResult *shr, float add_v3_v3v3(v_nor_new, shi->vn, orthx); add_v3_v3(v_nor_new, orthy); normalize_v3(v_nor_new); - } else { + } + else { /* no blurriness, use the original normal */ copy_v3_v3(v_nor_new, shi->vn); } - if((shi->vlr->flag & R_SMOOTH)) + if ((shi->vlr->flag & R_SMOOTH)) reflection(v_reflect, v_nor_new, shi->view, shi->facenor); else reflection_simple(v_reflect, v_nor_new, shi->view); @@ -1511,12 +1520,12 @@ void ray_trace(ShadeInput *shi, ShadeResult *shr) do_mir= ((shi->mat->mode & MA_RAYMIRROR) && shi->ray_mirror!=0.0f && (shi->depth <= shi->mat->ray_depth)); /* raytrace mirror and refract like to separate the spec color */ - if(shi->combinedflag & SCE_PASS_SPEC) + if (shi->combinedflag & SCE_PASS_SPEC) sub_v3_v3v3(diff, shr->combined, shr->spec); else copy_v3_v3(diff, shr->combined); - if(do_tra) { + if (do_tra) { float olddiff[3], f; trace_refract(tracol, shi, shr); @@ -1533,18 +1542,18 @@ void ray_trace(ShadeInput *shi, ShadeResult *shr) diff[1]= f*diff[1] + f1*fg*tracol[1]; diff[2]= f*diff[2] + f1*fb*tracol[2]; - if(shi->passflag & SCE_PASS_REFRACT) + if (shi->passflag & SCE_PASS_REFRACT) sub_v3_v3v3(shr->refr, diff, olddiff); - if(!(shi->combinedflag & SCE_PASS_REFRACT)) + if (!(shi->combinedflag & SCE_PASS_REFRACT)) sub_v3_v3v3(diff, diff, shr->refr); shr->alpha= MIN2(1.0f, tracol[3]); } - if(do_mir) { + if (do_mir) { const float i= shi->ray_mirror*fresnel_fac(shi->view, shi->vn, shi->mat->fresnel_mir_i, shi->mat->fresnel_mir); - if(i!=0.0f) { + if (i!=0.0f) { trace_reflect(mircol, shi, shr, i); @@ -1552,14 +1561,14 @@ void ray_trace(ShadeInput *shi, ShadeResult *shr) fg= i*shi->mirg; fb= i*shi->mirb; - if(shi->passflag & SCE_PASS_REFLECT) { + if (shi->passflag & SCE_PASS_REFLECT) { /* mirror pass is not blocked out with spec */ shr->refl[0]= fr*mircol[0] - fr*diff[0]; shr->refl[1]= fg*mircol[1] - fg*diff[1]; shr->refl[2]= fb*mircol[2] - fb*diff[2]; } - if(shi->combinedflag & SCE_PASS_REFLECT) { + if (shi->combinedflag & SCE_PASS_REFLECT) { /* values in shr->spec can be greater then 1.0. * In this case the mircol uses a zero blending factor, so ignoring it is ok. * Fixes bug #18837 - when the spec is higher then 1.0, @@ -1571,14 +1580,14 @@ void ray_trace(ShadeInput *shi, ShadeResult *shr) diff[1] *= f1; diff[2] *= f1; - if(shr->spec[0]<1.0f) diff[0] += mircol[0] * (fr*(1.0f-shr->spec[0])); - if(shr->spec[1]<1.0f) diff[1] += mircol[1] * (fg*(1.0f-shr->spec[1])); - if(shr->spec[2]<1.0f) diff[2] += mircol[2] * (fb*(1.0f-shr->spec[2])); + if (shr->spec[0]<1.0f) diff[0] += mircol[0] * (fr*(1.0f-shr->spec[0])); + if (shr->spec[1]<1.0f) diff[1] += mircol[1] * (fg*(1.0f-shr->spec[1])); + if (shr->spec[2]<1.0f) diff[2] += mircol[2] * (fb*(1.0f-shr->spec[2])); } } } /* put back together */ - if(shi->combinedflag & SCE_PASS_SPEC) + if (shi->combinedflag & SCE_PASS_SPEC) add_v3_v3v3(shr->combined, diff, shr->spec); else copy_v3_v3(shr->combined, diff); @@ -1607,7 +1616,7 @@ static void ray_trace_shadow_tra(Isect *is, ShadeInput *origshi, int depth, int * if it has col[3]>0.0f continue. so exit when alpha is full */ const float initial_dist = is->dist; - if(RE_rayobject_raycast(R.raytree, is)) { + if (RE_rayobject_raycast(R.raytree, is)) { /* Warning regarding initializing to zero's, This is not that nice, * and possibly a bit slow for every ray, however some variables were * not initialized properly in, unless using @@ -1637,7 +1646,8 @@ static void ray_trace_shadow_tra(Isect *is, ShadeInput *origshi, int depth, int 1.0f; /* mix colors based on shadfac (rgb + amount of light factor) */ addAlphaLight(col, shr.diff, shr.alpha, d*shi.mat->filter); - } else if (shi.mat->material_type == MA_TYPE_VOLUME) { + } + else if (shi.mat->material_type == MA_TYPE_VOLUME) { const float a = col[3]; col[0] = a*col[0] + shr.alpha*shr.combined[0]; @@ -1647,7 +1657,7 @@ static void ray_trace_shadow_tra(Isect *is, ShadeInput *origshi, int depth, int col[3] = (1.0f - shr.alpha)*a; } - if(depth>0 && col[3]>0.0f) { + if (depth>0 && col[3]>0.0f) { /* adapt isect struct */ copy_v3_v3(is->start, shi.co); @@ -1676,7 +1686,7 @@ static int UNUSED_FUNCTION(ray_trace_shadow_rad)(ShadeInput *ship, ShadeResult * assert(0); - if(only_one) { + if (only_one) { return 0; } only_one= 1; @@ -1691,7 +1701,7 @@ static int UNUSED_FUNCTION(ray_trace_shadow_rad)(ShadeInput *ship, ShadeResult * RE_RC_INIT(isec, shi); - for(a=0; a<8*8; a++) { + for (a=0; a<8*8; a++) { counter+=3; counter %= 768; @@ -1705,7 +1715,7 @@ static int UNUSED_FUNCTION(ray_trace_shadow_rad)(ShadeInput *ship, ShadeResult * copy_v3_v3(isec.dir, vec ); isec.dist = RE_RAYTRACE_MAXDIST; - if(RE_rayobject_raycast(R.raytree, &isec)) { + if (RE_rayobject_raycast(R.raytree, &isec)) { float fac; /* Warning, This is not that nice, and possibly a bit slow for every ray, @@ -1724,7 +1734,7 @@ static int UNUSED_FUNCTION(ray_trace_shadow_rad)(ShadeInput *ship, ShadeResult * else div+= 1.0f; } - if(div!=0.0f) { + if (div!=0.0f) { shr->diff[0]+= accum[0]/div; shr->diff[1]+= accum[1]/div; shr->diff[2]+= accum[2]/div; @@ -1757,10 +1767,10 @@ static void DS_energy(float *sphere, int tot, float vec[3]) res[0]= res[1]= res[2]= 0.0f; - for(a=0, fp=sphere; a<tot; a++, fp+=3) { + for (a=0, fp=sphere; a<tot; a++, fp+=3) { sub_v3_v3v3(force, vec, fp); fac = dot_v3v3(force, force); - if(fac!=0.0f) { + if (fac!=0.0f) { fac= 1.0f/fac; res[0]+= fac*force[0]; res[1]+= fac*force[1]; @@ -1792,12 +1802,12 @@ void init_ao_sphere(World *wrld) /* init */ fp= wrld->aosphere; - for(a=0; a<tot; a++, fp+= 3) { + for (a=0; a<tot; a++, fp+= 3) { RandomSpherical(fp); } - while(iter--) { - for(a=0, fp= wrld->aosphere; a<tot; a++, fp+= 3) { + while (iter--) { + for (a=0, fp= wrld->aosphere; a<tot; a++, fp+= 3) { DS_energy(wrld->aosphere, tot, fp); } } @@ -1812,14 +1822,14 @@ static float *threadsafe_table_sphere(int test, int thread, int xs, int ys, int static int xso[BLENDER_MAX_THREADS], yso[BLENDER_MAX_THREADS]; static int firsttime= 1; - if(firsttime) { + if (firsttime) { memset(xso, 255, sizeof(xso)); memset(yso, 255, sizeof(yso)); firsttime= 0; } - if(xs==xso[thread] && ys==yso[thread]) return R.wrld.aotables+ thread*tot*3; - if(test) return NULL; + if (xs==xso[thread] && ys==yso[thread]) return R.wrld.aotables+ thread*tot*3; + if (test) return NULL; xso[thread]= xs; yso[thread]= ys; return R.wrld.aotables+ thread*tot*3; } @@ -1852,7 +1862,7 @@ static float *sphere_sampler(int type, int resol, int thread, int xs, int ys, in // returns table if xs and ys were equal to last call, and not resetting sphere= (reset)? NULL: threadsafe_table_sphere(1, thread, xs, ys, tot); - if(sphere==NULL) { + if (sphere==NULL) { float cosfi, sinfi, cost, sint; float ang; int a; @@ -1920,16 +1930,16 @@ static void ray_ao_qmc(ShadeInput *shi, float ao[3], float env[3]) /* prevent sky colors to be added for only shadow (shadow becomes alpha) */ envcolor= R.wrld.aocolor; - if(shi->mat->mode & MA_ONLYSHADOW) + if (shi->mat->mode & MA_ONLYSHADOW) envcolor= WO_AOPLAIN; - if(envcolor == WO_AOSKYTEX) { + if (envcolor == WO_AOSKYTEX) { dxyview[0]= 1.0f/(float)R.wrld.aosamp; dxyview[1]= 1.0f/(float)R.wrld.aosamp; dxyview[2]= 0.0f; } - if(shi->vlr->flag & R_SMOOTH) { + if (shi->vlr->flag & R_SMOOTH) { copy_v3_v3(nrm, shi->vn); } else { @@ -1948,7 +1958,8 @@ static void ray_ao_qmc(ShadeInput *shi, float ao[3], float env[3]) if (max_samples < 5) max_samples = 5; qsa = get_thread_qmcsampler(&R, shi->thread, SAMP_TYPE_HALTON, max_samples); - } else if (R.wrld.ao_samp_method==WO_AOSAMP_HAMMERSLEY) + } + else if (R.wrld.ao_samp_method==WO_AOSAMP_HAMMERSLEY) qsa = get_thread_qmcsampler(&R, shi->thread, SAMP_TYPE_HAMMERSLEY, max_samples); QMC_initPixel(qsa, shi->thread); @@ -1971,11 +1982,11 @@ static void ray_ao_qmc(ShadeInput *shi, float ao[3], float env[3]) prev = fac; - if(RE_rayobject_raycast(R.raytree, &isec)) { + if (RE_rayobject_raycast(R.raytree, &isec)) { if (R.wrld.aomode & WO_AODIST) fac+= expf(-isec.dist*R.wrld.aodistfac); else fac+= 1.0f; } - else if(envcolor!=WO_AOPLAIN) { + else if (envcolor!=WO_AOPLAIN) { float skycol[4]; float view[3]; @@ -1984,7 +1995,7 @@ static void ray_ao_qmc(ShadeInput *shi, float ao[3], float env[3]) view[2]= -dir[2]; normalize_v3(view); - if(envcolor==WO_AOSKYCOL) { + if (envcolor==WO_AOSKYCOL) { const float skyfac= 0.5f * (1.0f + dot_v3v3(view, R.grvec)); env[0]+= (1.0f-skyfac)*R.wrld.horr + skyfac*R.wrld.zenr; env[1]+= (1.0f-skyfac)*R.wrld.horg + skyfac*R.wrld.zeng; @@ -2016,7 +2027,7 @@ static void ray_ao_qmc(ShadeInput *shi, float ao[3], float env[3]) /* average color times distances/hits formula */ ao[0]= ao[1]= ao[2]= 1.0f - fac/(float)samples; - if(envcolor!=WO_AOPLAIN && skyadded) + if (envcolor!=WO_AOPLAIN && skyadded) mul_v3_fl(env, (1.0f - fac/(float)samples)/((float)skyadded)); else copy_v3_v3(env, ao); @@ -2058,7 +2069,7 @@ static void ray_ao_spheresamp(ShadeInput *shi, float ao[3], float env[3]) zero_v3(env); /* bias prevents smoothed faces to appear flat */ - if(shi->vlr->flag & R_SMOOTH) { + if (shi->vlr->flag & R_SMOOTH) { bias= R.wrld.aobias; nrm= shi->vn; } @@ -2069,10 +2080,10 @@ static void ray_ao_spheresamp(ShadeInput *shi, float ao[3], float env[3]) /* prevent sky colors to be added for only shadow (shadow becomes alpha) */ envcolor= R.wrld.aocolor; - if(shi->mat->mode & MA_ONLYSHADOW) + if (shi->mat->mode & MA_ONLYSHADOW) envcolor= WO_AOPLAIN; - if(resol>32) resol= 32; + if (resol>32) resol= 32; /* get sphere samples. for faces we get the same samples for sample x/y values, * for strand render we always require a new sampler because x/y are not set */ @@ -2081,20 +2092,20 @@ static void ray_ao_spheresamp(ShadeInput *shi, float ao[3], float env[3]) // warning: since we use full sphere now, and dotproduct is below, we do twice as much tot= 2*resol*resol; - if(envcolor == WO_AOSKYTEX) { + if (envcolor == WO_AOSKYTEX) { dxyview[0]= 1.0f/(float)resol; dxyview[1]= 1.0f/(float)resol; dxyview[2]= 0.0f; } - while(tot--) { + while (tot--) { if (dot_v3v3(vec, nrm) > bias) { /* only ao samples for mask */ - if(R.r.mode & R_OSA) { + if (R.r.mode & R_OSA) { j++; - if(j==R.osa) j= 0; - if(!(shi->mask & (1<<j))) { + if (j==R.osa) j= 0; + if (!(shi->mask & (1<<j))) { vec+=3; continue; } @@ -2109,11 +2120,11 @@ static void ray_ao_spheresamp(ShadeInput *shi, float ao[3], float env[3]) isec.dist = maxdist; /* do the trace */ - if(RE_rayobject_raycast(R.raytree, &isec)) { + if (RE_rayobject_raycast(R.raytree, &isec)) { if (R.wrld.aomode & WO_AODIST) sh+= expf(-isec.dist*R.wrld.aodistfac); else sh+= 1.0f; } - else if(envcolor!=WO_AOPLAIN) { + else if (envcolor!=WO_AOPLAIN) { float skycol[4]; float view[3]; @@ -2122,7 +2133,7 @@ static void ray_ao_spheresamp(ShadeInput *shi, float ao[3], float env[3]) view[2]= -vec[2]; normalize_v3(view); - if(envcolor==WO_AOSKYCOL) { + if (envcolor==WO_AOSKYCOL) { const float fac = 0.5f * (1.0f + dot_v3v3(view, R.grvec)); env[0]+= (1.0f-fac)*R.wrld.horr + fac*R.wrld.zenr; env[1]+= (1.0f-fac)*R.wrld.horg + fac*R.wrld.zeng; @@ -2142,13 +2153,13 @@ static void ray_ao_spheresamp(ShadeInput *shi, float ao[3], float env[3]) vec+= 3; } - if(actual==0) sh= 1.0f; + if (actual==0) sh= 1.0f; else sh = 1.0f - sh/((float)actual); /* average color times distances/hits formula */ ao[0]= ao[1]= ao[2]= sh; - if(envcolor!=WO_AOPLAIN && skyadded) + if (envcolor!=WO_AOPLAIN && skyadded) mul_v3_fl(env, sh/((float)skyadded)); else copy_v3_v3(env, ao); @@ -2177,17 +2188,17 @@ static void ray_shadow_jittered_coords(ShadeInput *shi, int max, float jitco[RE_ /* for better antialising shadow samples are distributed over the subpixel * sample coordinates, this only works for raytracing depth 0 though */ - if(!shi->strand && shi->depth == 0 && count > 1 && count <= max) { + if (!shi->strand && shi->depth == 0 && count > 1 && count <= max) { float xs, ys, zs, view[3]; int samp, ordsamp, tot= 0; - for(samp=0; samp<R.osa; samp++) { - if(R.osa == 8) ordsamp = order8[samp]; - else if(R.osa == 11) ordsamp = order11[samp]; - else if(R.osa == 16) ordsamp = order16[samp]; + for (samp=0; samp<R.osa; samp++) { + if (R.osa == 8) ordsamp = order8[samp]; + else if (R.osa == 11) ordsamp = order11[samp]; + else if (R.osa == 16) ordsamp = order16[samp]; else ordsamp = samp; - if(shi->mask & (1<<ordsamp)) { + if (shi->mask & (1<<ordsamp)) { /* zbuffer has this inverse corrected, ensures xs,ys are inside pixel */ xs= (float)shi->scanco[0] + R.jit[ordsamp][0] + 0.5f; ys= (float)shi->scanco[1] + R.jit[ordsamp][1] + 0.5f; @@ -2226,9 +2237,10 @@ static void ray_shadow_qmc(ShadeInput *shi, LampRen *lar, const float lampco[3], int totjitco; colsq[0] = colsq[1] = colsq[2] = 0.0; - if(isec->mode==RE_RAY_SHADOW_TRA) { + if (isec->mode==RE_RAY_SHADOW_TRA) { shadfac[0]= shadfac[1]= shadfac[2]= shadfac[3]= 0.0f; - } else + } + else shadfac[3]= 1.0f; if (lar->ray_totsamp < 2) do_soft = 0; @@ -2237,7 +2249,8 @@ static void ray_shadow_qmc(ShadeInput *shi, LampRen *lar, const float lampco[3], if (full_osa) { if (do_soft) max_samples = max_samples/R.osa + 1; else max_samples = 1; - } else { + } + else { if (do_soft) max_samples = lar->ray_totsamp; else if (shi->depth == 0) max_samples = (R.osa > 4)?R.osa:5; else max_samples = 1; @@ -2254,7 +2267,7 @@ static void ray_shadow_qmc(ShadeInput *shi, LampRen *lar, const float lampco[3], QMC_initPixel(qsa, shi->thread); INIT_MINMAX(min, max); - for(i=0; i<totjitco; i++) + for (i=0; i<totjitco; i++) { DO_MINMAX(jitco[i], min, max); } @@ -2305,11 +2318,12 @@ static void ray_shadow_qmc(ShadeInput *shi, LampRen *lar, const float lampco[3], end[0] = vec[0]+samp3d[0]; end[1] = vec[1]+samp3d[1]; end[2] = vec[2]+samp3d[2]; - } else { + } + else { copy_v3_v3(end, vec); } - if(shi->strand) { + if (shi->strand) { /* bias away somewhat to avoid self intersection */ float jitbias= 0.5f*(len_v3(shi->dxco) + len_v3(shi->dyco)); float v[3]; @@ -2329,7 +2343,7 @@ static void ray_shadow_qmc(ShadeInput *shi, LampRen *lar, const float lampco[3], isec->dist = normalize_v3(isec->dir); /* trace the ray */ - if(isec->mode==RE_RAY_SHADOW_TRA) { + if (isec->mode==RE_RAY_SHADOW_TRA) { float col[4] = {1.0f, 1.0f, 1.0f, 1.0f}; ray_trace_shadow_tra(isec, shi, DEPTH_SHADOW_TRA, 0, col); @@ -2344,7 +2358,7 @@ static void ray_shadow_qmc(ShadeInput *shi, LampRen *lar, const float lampco[3], colsq[2] += col[2]*col[2]; } else { - if( RE_rayobject_raycast(R.raytree, isec) ) fac+= 1.0f; + if ( RE_rayobject_raycast(R.raytree, isec) ) fac+= 1.0f; } samples++; @@ -2358,7 +2372,8 @@ static void ray_shadow_qmc(ShadeInput *shi, LampRen *lar, const float lampco[3], break; else if (adaptive_sample_variance(samples, shadfac, colsq, adapt_thresh)) break; - } else { + } + else { if ((fac / samples > (1.0f-adapt_thresh)) || (fac / samples < adapt_thresh)) break; } @@ -2366,12 +2381,13 @@ static void ray_shadow_qmc(ShadeInput *shi, LampRen *lar, const float lampco[3], } } - if(isec->mode==RE_RAY_SHADOW_TRA) { + if (isec->mode==RE_RAY_SHADOW_TRA) { shadfac[0] /= samples; shadfac[1] /= samples; shadfac[2] /= samples; shadfac[3] /= samples; - } else + } + else shadfac[3]= 1.0f-fac/samples; if (qsa) @@ -2386,7 +2402,7 @@ static void ray_shadow_jitter(ShadeInput *shi, LampRen *lar, const float lampco[ int a, j= -1, mask; RayHint point_hint; - if(isec->mode==RE_RAY_SHADOW_TRA) { + if (isec->mode==RE_RAY_SHADOW_TRA) { shadfac[0]= shadfac[1]= shadfac[2]= shadfac[3]= 0.0f; } else shadfac[3]= 1.0f; @@ -2398,8 +2414,8 @@ static void ray_shadow_jitter(ShadeInput *shi, LampRen *lar, const float lampco[ /* this correction to make sure we always take at least 1 sample */ mask= shi->mask; - if(a==4) mask |= (mask>>4)|(mask>>8); - else if(a==9) mask |= (mask>>9); + if (a==4) mask |= (mask>>4)|(mask>>8); + else if (a==9) mask |= (mask>>9); copy_v3_v3(isec->start, shi->co); isec->orig.ob = shi->obi; @@ -2407,12 +2423,12 @@ static void ray_shadow_jitter(ShadeInput *shi, LampRen *lar, const float lampco[ RE_rayobject_hint_bb( R.raytree, &point_hint, isec->start, isec->start ); isec->hint = &point_hint; - while(a--) { + while (a--) { - if(R.r.mode & R_OSA) { + if (R.r.mode & R_OSA) { j++; - if(j>=R.osa) j= 0; - if(!(mask & (1<<j))) { + if (j>=R.osa) j= 0; + if (!(mask & (1<<j))) { jitlamp+= 2; continue; } @@ -2431,7 +2447,7 @@ static void ray_shadow_jitter(ShadeInput *shi, LampRen *lar, const float lampco[ isec->check = RE_CHECK_VLR_RENDER; isec->skip = RE_SKIP_VLR_NEIGHBOUR; - if(isec->mode==RE_RAY_SHADOW_TRA) { + if (isec->mode==RE_RAY_SHADOW_TRA) { /* isec.col is like shadfac, so defines amount of light (0.0 is full shadow) */ float col[4] = {1.0f, 1.0f, 1.0f, 1.0f}; @@ -2441,13 +2457,13 @@ static void ray_shadow_jitter(ShadeInput *shi, LampRen *lar, const float lampco[ shadfac[2] += col[2]; shadfac[3] += col[3]; } - else if( RE_rayobject_raycast(R.raytree, isec) ) fac+= 1.0f; + else if ( RE_rayobject_raycast(R.raytree, isec) ) fac+= 1.0f; div+= 1.0f; jitlamp+= 2; } - if(isec->mode==RE_RAY_SHADOW_TRA) { + if (isec->mode==RE_RAY_SHADOW_TRA) { shadfac[0] /= div; shadfac[1] /= div; shadfac[2] /= div; @@ -2455,7 +2471,7 @@ static void ray_shadow_jitter(ShadeInput *shi, LampRen *lar, const float lampco[ } else { // sqrt makes nice umbra effect - if(lar->ray_samp_type & LA_SAMP_UMBRA) + if (lar->ray_samp_type & LA_SAMP_UMBRA) shadfac[3]= sqrt(1.0f-fac/div); else shadfac[3]= 1.0f-fac/div; @@ -2469,24 +2485,24 @@ void ray_shadow(ShadeInput *shi, LampRen *lar, float shadfac[4]) /* setup isec */ RE_RC_INIT(isec, *shi); - if(shi->mat->mode & MA_SHADOW_TRA) isec.mode= RE_RAY_SHADOW_TRA; + if (shi->mat->mode & MA_SHADOW_TRA) isec.mode= RE_RAY_SHADOW_TRA; else isec.mode= RE_RAY_SHADOW; isec.hint = 0; - if(lar->mode & (LA_LAYER|LA_LAYER_SHADOW)) + if (lar->mode & (LA_LAYER|LA_LAYER_SHADOW)) isec.lay= lar->lay; else isec.lay= -1; /* only when not mir tracing, first hit optimm */ - if(shi->depth==0) { + if (shi->depth==0) { isec.last_hit = lar->last_hit[shi->thread]; } else { isec.last_hit = NULL; } - if(lar->type==LA_SUN || lar->type==LA_HEMI) { + if (lar->type==LA_SUN || lar->type==LA_HEMI) { /* jitter and QMC sampling add a displace vector to the lamp position * that's incorrect because a SUN lamp does not has an exact position * and the displace should be done at the ray vector instead of the @@ -2512,8 +2528,9 @@ void ray_shadow(ShadeInput *shi, LampRen *lar, float shadfac[4]) ray_shadow_qmc(shi, lar, lampco, shadfac, &isec); - } else { - if(lar->ray_totsamp<2) { + } + else { + if (lar->ray_totsamp<2) { isec.orig.ob = shi->obi; isec.orig.face = shi->vlr; @@ -2525,14 +2542,14 @@ void ray_shadow(ShadeInput *shi, LampRen *lar, float shadfac[4]) sub_v3_v3v3(isec.dir, lampco, isec.start); isec.dist = normalize_v3(isec.dir); - if(isec.mode==RE_RAY_SHADOW_TRA) { + if (isec.mode==RE_RAY_SHADOW_TRA) { /* isec.col is like shadfac, so defines amount of light (0.0 is full shadow) */ float col[4] = {1.0f, 1.0f, 1.0f, 1.0f}; ray_trace_shadow_tra(&isec, shi, DEPTH_SHADOW_TRA, 0, col); copy_v4_v4(shadfac, col); } - else if(RE_rayobject_raycast(R.raytree, &isec)) + else if (RE_rayobject_raycast(R.raytree, &isec)) shadfac[3]= 0.0f; } else { @@ -2541,7 +2558,7 @@ void ray_shadow(ShadeInput *shi, LampRen *lar, float shadfac[4]) } /* for first hit optim, set last interesected shadow face */ - if(shi->depth==0) { + if (shi->depth==0) { lar->last_hit[shi->thread] = isec.last_hit; } @@ -2561,9 +2578,9 @@ static void ray_translucent(ShadeInput *shi, LampRen *lar, float *distfac, float isec.mode= RE_RAY_SHADOW_TRA; isec.hint = 0; - if(lar->mode & LA_LAYER) isec.lay= lar->lay; else isec.lay= -1; + if (lar->mode & LA_LAYER) isec.lay= lar->lay; else isec.lay= -1; - if(lar->type==LA_SUN || lar->type==LA_HEMI) { + if (lar->type==LA_SUN || lar->type==LA_HEMI) { lampco[0]= shi->co[0] - RE_RAYTRACE_MAXDIST*lar->vec[0]; lampco[1]= shi->co[1] - RE_RAYTRACE_MAXDIST*lar->vec[1]; lampco[2]= shi->co[2] - RE_RAYTRACE_MAXDIST*lar->vec[2]; @@ -2579,7 +2596,7 @@ static void ray_translucent(ShadeInput *shi, LampRen *lar, float *distfac, float copy_v3_v3(isec.start, shi->co); copy_v3_v3(isec.end, lampco); - if(RE_rayobject_raycast(R.raytree, &isec)) { + if (RE_rayobject_raycast(R.raytree, &isec)) { /* we got a face */ /* render co */ diff --git a/source/blender/render/intern/source/render_result.c b/source/blender/render/intern/source/render_result.c index 2cf5346fdd7..37d6479e7bc 100644 --- a/source/blender/render/intern/source/render_result.c +++ b/source/blender/render/intern/source/render_result.c @@ -60,19 +60,19 @@ void render_result_free(RenderResult *res) { - if(res==NULL) return; + if (res==NULL) return; - while(res->layers.first) { + while (res->layers.first) { RenderLayer *rl= res->layers.first; - if(rl->rectf) MEM_freeN(rl->rectf); + if (rl->rectf) MEM_freeN(rl->rectf); /* acolrect and scolrect are optionally allocated in shade_tile, only free here since it can be used for drawing */ - if(rl->acolrect) MEM_freeN(rl->acolrect); - if(rl->scolrect) MEM_freeN(rl->scolrect); + if (rl->acolrect) MEM_freeN(rl->acolrect); + if (rl->scolrect) MEM_freeN(rl->scolrect); - while(rl->passes.first) { + while (rl->passes.first) { RenderPass *rpass= rl->passes.first; - if(rpass->rect) MEM_freeN(rpass->rect); + if (rpass->rect) MEM_freeN(rpass->rect); BLI_remlink(&rl->passes, rpass); MEM_freeN(rpass); } @@ -80,13 +80,13 @@ void render_result_free(RenderResult *res) MEM_freeN(rl); } - if(res->rect32) + if (res->rect32) MEM_freeN(res->rect32); - if(res->rectz) + if (res->rectz) MEM_freeN(res->rectz); - if(res->rectf) + if (res->rectf) MEM_freeN(res->rectf); - if(res->text) + if (res->text) MEM_freeN(res->text); MEM_freeN(res); @@ -97,10 +97,10 @@ void render_result_free_list(ListBase *lb, RenderResult *rr) { RenderResult *rrnext; - for(; rr; rr= rrnext) { + for (; rr; rr= rrnext) { rrnext= rr->next; - if(lb && lb->first) + if (lb && lb->first) BLI_remlink(lb, rr); render_result_free(rr); @@ -114,167 +114,167 @@ void render_result_free_list(ListBase *lb, RenderResult *rr) static const char *get_pass_name(int passtype, int channel) { - if(passtype == SCE_PASS_COMBINED) { - if(channel==-1) return "Combined"; - if(channel==0) return "Combined.R"; - if(channel==1) return "Combined.G"; - if(channel==2) return "Combined.B"; + if (passtype == SCE_PASS_COMBINED) { + if (channel==-1) return "Combined"; + if (channel==0) return "Combined.R"; + if (channel==1) return "Combined.G"; + if (channel==2) return "Combined.B"; return "Combined.A"; } - if(passtype == SCE_PASS_Z) { - if(channel==-1) return "Depth"; + if (passtype == SCE_PASS_Z) { + if (channel==-1) return "Depth"; return "Depth.Z"; } - if(passtype == SCE_PASS_VECTOR) { - if(channel==-1) return "Vector"; - if(channel==0) return "Vector.X"; - if(channel==1) return "Vector.Y"; - if(channel==2) return "Vector.Z"; + if (passtype == SCE_PASS_VECTOR) { + if (channel==-1) return "Vector"; + if (channel==0) return "Vector.X"; + if (channel==1) return "Vector.Y"; + if (channel==2) return "Vector.Z"; return "Vector.W"; } - if(passtype == SCE_PASS_NORMAL) { - if(channel==-1) return "Normal"; - if(channel==0) return "Normal.X"; - if(channel==1) return "Normal.Y"; + if (passtype == SCE_PASS_NORMAL) { + if (channel==-1) return "Normal"; + if (channel==0) return "Normal.X"; + if (channel==1) return "Normal.Y"; return "Normal.Z"; } - if(passtype == SCE_PASS_UV) { - if(channel==-1) return "UV"; - if(channel==0) return "UV.U"; - if(channel==1) return "UV.V"; + if (passtype == SCE_PASS_UV) { + if (channel==-1) return "UV"; + if (channel==0) return "UV.U"; + if (channel==1) return "UV.V"; return "UV.A"; } - if(passtype == SCE_PASS_RGBA) { - if(channel==-1) return "Color"; - if(channel==0) return "Color.R"; - if(channel==1) return "Color.G"; - if(channel==2) return "Color.B"; + if (passtype == SCE_PASS_RGBA) { + if (channel==-1) return "Color"; + if (channel==0) return "Color.R"; + if (channel==1) return "Color.G"; + if (channel==2) return "Color.B"; return "Color.A"; } - if(passtype == SCE_PASS_EMIT) { - if(channel==-1) return "Emit"; - if(channel==0) return "Emit.R"; - if(channel==1) return "Emit.G"; + if (passtype == SCE_PASS_EMIT) { + if (channel==-1) return "Emit"; + if (channel==0) return "Emit.R"; + if (channel==1) return "Emit.G"; return "Emit.B"; } - if(passtype == SCE_PASS_DIFFUSE) { - if(channel==-1) return "Diffuse"; - if(channel==0) return "Diffuse.R"; - if(channel==1) return "Diffuse.G"; + if (passtype == SCE_PASS_DIFFUSE) { + if (channel==-1) return "Diffuse"; + if (channel==0) return "Diffuse.R"; + if (channel==1) return "Diffuse.G"; return "Diffuse.B"; } - if(passtype == SCE_PASS_SPEC) { - if(channel==-1) return "Spec"; - if(channel==0) return "Spec.R"; - if(channel==1) return "Spec.G"; + if (passtype == SCE_PASS_SPEC) { + if (channel==-1) return "Spec"; + if (channel==0) return "Spec.R"; + if (channel==1) return "Spec.G"; return "Spec.B"; } - if(passtype == SCE_PASS_SHADOW) { - if(channel==-1) return "Shadow"; - if(channel==0) return "Shadow.R"; - if(channel==1) return "Shadow.G"; + if (passtype == SCE_PASS_SHADOW) { + if (channel==-1) return "Shadow"; + if (channel==0) return "Shadow.R"; + if (channel==1) return "Shadow.G"; return "Shadow.B"; } - if(passtype == SCE_PASS_AO) { - if(channel==-1) return "AO"; - if(channel==0) return "AO.R"; - if(channel==1) return "AO.G"; + if (passtype == SCE_PASS_AO) { + if (channel==-1) return "AO"; + if (channel==0) return "AO.R"; + if (channel==1) return "AO.G"; return "AO.B"; } - if(passtype == SCE_PASS_ENVIRONMENT) { - if(channel==-1) return "Env"; - if(channel==0) return "Env.R"; - if(channel==1) return "Env.G"; + if (passtype == SCE_PASS_ENVIRONMENT) { + if (channel==-1) return "Env"; + if (channel==0) return "Env.R"; + if (channel==1) return "Env.G"; return "Env.B"; } - if(passtype == SCE_PASS_INDIRECT) { - if(channel==-1) return "Indirect"; - if(channel==0) return "Indirect.R"; - if(channel==1) return "Indirect.G"; + if (passtype == SCE_PASS_INDIRECT) { + if (channel==-1) return "Indirect"; + if (channel==0) return "Indirect.R"; + if (channel==1) return "Indirect.G"; return "Indirect.B"; } - if(passtype == SCE_PASS_REFLECT) { - if(channel==-1) return "Reflect"; - if(channel==0) return "Reflect.R"; - if(channel==1) return "Reflect.G"; + if (passtype == SCE_PASS_REFLECT) { + if (channel==-1) return "Reflect"; + if (channel==0) return "Reflect.R"; + if (channel==1) return "Reflect.G"; return "Reflect.B"; } - if(passtype == SCE_PASS_REFRACT) { - if(channel==-1) return "Refract"; - if(channel==0) return "Refract.R"; - if(channel==1) return "Refract.G"; + if (passtype == SCE_PASS_REFRACT) { + if (channel==-1) return "Refract"; + if (channel==0) return "Refract.R"; + if (channel==1) return "Refract.G"; return "Refract.B"; } - if(passtype == SCE_PASS_INDEXOB) { - if(channel==-1) return "IndexOB"; + if (passtype == SCE_PASS_INDEXOB) { + if (channel==-1) return "IndexOB"; return "IndexOB.X"; } - if(passtype == SCE_PASS_INDEXMA) { - if(channel==-1) return "IndexMA"; + if (passtype == SCE_PASS_INDEXMA) { + if (channel==-1) return "IndexMA"; return "IndexMA.X"; } - if(passtype == SCE_PASS_MIST) { - if(channel==-1) return "Mist"; + if (passtype == SCE_PASS_MIST) { + if (channel==-1) return "Mist"; return "Mist.Z"; } - if(passtype == SCE_PASS_RAYHITS) { - if(channel==-1) return "Rayhits"; - if(channel==0) return "Rayhits.R"; - if(channel==1) return "Rayhits.G"; + if (passtype == SCE_PASS_RAYHITS) { + if (channel==-1) return "Rayhits"; + if (channel==0) return "Rayhits.R"; + if (channel==1) return "Rayhits.G"; return "Rayhits.B"; } - if(passtype == SCE_PASS_DIFFUSE_DIRECT) { - if(channel==-1) return "DiffDir"; - if(channel==0) return "DiffDir.R"; - if(channel==1) return "DiffDir.G"; + if (passtype == SCE_PASS_DIFFUSE_DIRECT) { + if (channel==-1) return "DiffDir"; + if (channel==0) return "DiffDir.R"; + if (channel==1) return "DiffDir.G"; return "DiffDir.B"; } - if(passtype == SCE_PASS_DIFFUSE_INDIRECT) { - if(channel==-1) return "DiffInd"; - if(channel==0) return "DiffInd.R"; - if(channel==1) return "DiffInd.G"; + if (passtype == SCE_PASS_DIFFUSE_INDIRECT) { + if (channel==-1) return "DiffInd"; + if (channel==0) return "DiffInd.R"; + if (channel==1) return "DiffInd.G"; return "DiffInd.B"; } - if(passtype == SCE_PASS_DIFFUSE_COLOR) { - if(channel==-1) return "DiffCol"; - if(channel==0) return "DiffCol.R"; - if(channel==1) return "DiffCol.G"; + if (passtype == SCE_PASS_DIFFUSE_COLOR) { + if (channel==-1) return "DiffCol"; + if (channel==0) return "DiffCol.R"; + if (channel==1) return "DiffCol.G"; return "DiffCol.B"; } - if(passtype == SCE_PASS_GLOSSY_DIRECT) { - if(channel==-1) return "GlossDir"; - if(channel==0) return "GlossDir.R"; - if(channel==1) return "GlossDir.G"; + if (passtype == SCE_PASS_GLOSSY_DIRECT) { + if (channel==-1) return "GlossDir"; + if (channel==0) return "GlossDir.R"; + if (channel==1) return "GlossDir.G"; return "GlossDir.B"; } - if(passtype == SCE_PASS_GLOSSY_INDIRECT) { - if(channel==-1) return "GlossInd"; - if(channel==0) return "GlossInd.R"; - if(channel==1) return "GlossInd.G"; + if (passtype == SCE_PASS_GLOSSY_INDIRECT) { + if (channel==-1) return "GlossInd"; + if (channel==0) return "GlossInd.R"; + if (channel==1) return "GlossInd.G"; return "GlossInd.B"; } - if(passtype == SCE_PASS_GLOSSY_COLOR) { - if(channel==-1) return "GlossCol"; - if(channel==0) return "GlossCol.R"; - if(channel==1) return "GlossCol.G"; + if (passtype == SCE_PASS_GLOSSY_COLOR) { + if (channel==-1) return "GlossCol"; + if (channel==0) return "GlossCol.R"; + if (channel==1) return "GlossCol.G"; return "GlossCol.B"; } - if(passtype == SCE_PASS_TRANSM_DIRECT) { - if(channel==-1) return "TransDir"; - if(channel==0) return "TransDir.R"; - if(channel==1) return "TransDir.G"; + if (passtype == SCE_PASS_TRANSM_DIRECT) { + if (channel==-1) return "TransDir"; + if (channel==0) return "TransDir.R"; + if (channel==1) return "TransDir.G"; return "TransDir.B"; } - if(passtype == SCE_PASS_TRANSM_INDIRECT) { - if(channel==-1) return "TransInd"; - if(channel==0) return "TransInd.R"; - if(channel==1) return "TransInd.G"; + if (passtype == SCE_PASS_TRANSM_INDIRECT) { + if (channel==-1) return "TransInd"; + if (channel==0) return "TransInd.R"; + if (channel==1) return "TransInd.G"; return "TransInd.B"; } - if(passtype == SCE_PASS_TRANSM_COLOR) { - if(channel==-1) return "TransCol"; - if(channel==0) return "TransCol.R"; - if(channel==1) return "TransCol.G"; + if (passtype == SCE_PASS_TRANSM_COLOR) { + if (channel==-1) return "TransCol"; + if (channel==0) return "TransCol.R"; + if (channel==1) return "TransCol.G"; return "TransCol.B"; } return "Unknown"; @@ -283,88 +283,88 @@ static const char *get_pass_name(int passtype, int channel) static int passtype_from_name(const char *str) { - if(strcmp(str, "Combined")==0) + if (strcmp(str, "Combined")==0) return SCE_PASS_COMBINED; - if(strcmp(str, "Depth")==0) + if (strcmp(str, "Depth")==0) return SCE_PASS_Z; - if(strcmp(str, "Vector")==0) + if (strcmp(str, "Vector")==0) return SCE_PASS_VECTOR; - if(strcmp(str, "Normal")==0) + if (strcmp(str, "Normal")==0) return SCE_PASS_NORMAL; - if(strcmp(str, "UV")==0) + if (strcmp(str, "UV")==0) return SCE_PASS_UV; - if(strcmp(str, "Color")==0) + if (strcmp(str, "Color")==0) return SCE_PASS_RGBA; - if(strcmp(str, "Emit")==0) + if (strcmp(str, "Emit")==0) return SCE_PASS_EMIT; - if(strcmp(str, "Diffuse")==0) + if (strcmp(str, "Diffuse")==0) return SCE_PASS_DIFFUSE; - if(strcmp(str, "Spec")==0) + if (strcmp(str, "Spec")==0) return SCE_PASS_SPEC; - if(strcmp(str, "Shadow")==0) + if (strcmp(str, "Shadow")==0) return SCE_PASS_SHADOW; - if(strcmp(str, "AO")==0) + if (strcmp(str, "AO")==0) return SCE_PASS_AO; - if(strcmp(str, "Env")==0) + if (strcmp(str, "Env")==0) return SCE_PASS_ENVIRONMENT; - if(strcmp(str, "Indirect")==0) + if (strcmp(str, "Indirect")==0) return SCE_PASS_INDIRECT; - if(strcmp(str, "Reflect")==0) + if (strcmp(str, "Reflect")==0) return SCE_PASS_REFLECT; - if(strcmp(str, "Refract")==0) + if (strcmp(str, "Refract")==0) return SCE_PASS_REFRACT; - if(strcmp(str, "IndexOB")==0) + if (strcmp(str, "IndexOB")==0) return SCE_PASS_INDEXOB; - if(strcmp(str, "IndexMA")==0) + if (strcmp(str, "IndexMA")==0) return SCE_PASS_INDEXMA; - if(strcmp(str, "Mist")==0) + if (strcmp(str, "Mist")==0) return SCE_PASS_MIST; - if(strcmp(str, "RayHits")==0) + if (strcmp(str, "RayHits")==0) return SCE_PASS_RAYHITS; - if(strcmp(str, "DiffDir")==0) + if (strcmp(str, "DiffDir")==0) return SCE_PASS_DIFFUSE_DIRECT; - if(strcmp(str, "DiffInd")==0) + if (strcmp(str, "DiffInd")==0) return SCE_PASS_DIFFUSE_INDIRECT; - if(strcmp(str, "DiffCol")==0) + if (strcmp(str, "DiffCol")==0) return SCE_PASS_DIFFUSE_COLOR; - if(strcmp(str, "GlossDir")==0) + if (strcmp(str, "GlossDir")==0) return SCE_PASS_GLOSSY_DIRECT; - if(strcmp(str, "GlossInd")==0) + if (strcmp(str, "GlossInd")==0) return SCE_PASS_GLOSSY_INDIRECT; - if(strcmp(str, "GlossCol")==0) + if (strcmp(str, "GlossCol")==0) return SCE_PASS_GLOSSY_COLOR; - if(strcmp(str, "TransDir")==0) + if (strcmp(str, "TransDir")==0) return SCE_PASS_TRANSM_DIRECT; - if(strcmp(str, "TransInd")==0) + if (strcmp(str, "TransInd")==0) return SCE_PASS_TRANSM_INDIRECT; - if(strcmp(str, "TransCol")==0) + if (strcmp(str, "TransCol")==0) return SCE_PASS_TRANSM_COLOR; return 0; @@ -385,9 +385,9 @@ static void render_layer_add_pass(RenderResult *rr, RenderLayer *rl, int channel rpass->recty= rl->recty; BLI_strncpy(rpass->name, get_pass_name(rpass->passtype, -1), sizeof(rpass->name)); - if(rr->exrhandle) { + if (rr->exrhandle) { int a; - for(a=0; a<channels; a++) + for (a=0; a<channels; a++) IMB_exr_add_channel(rr->exrhandle, rl->name, get_pass_name(passtype, a), 0, 0, NULL); } else { @@ -396,15 +396,15 @@ static void render_layer_add_pass(RenderResult *rr, RenderLayer *rl, int channel rpass->rect= MEM_mapallocN(sizeof(float)*rectsize, typestr); - if(passtype==SCE_PASS_VECTOR) { + if (passtype==SCE_PASS_VECTOR) { /* initialize to max speed */ rect= rpass->rect; - for(x= rectsize-1; x>=0; x--) + for (x= rectsize-1; x>=0; x--) rect[x]= PASS_VECTOR_MAX; } - else if(passtype==SCE_PASS_Z) { + else if (passtype==SCE_PASS_Z) { rect= rpass->rect; - for(x= rectsize-1; x>=0; x--) + for (x= rectsize-1; x>=0; x--) rect[x]= 10e10; } } @@ -424,7 +424,7 @@ RenderResult *render_result_new(Render *re, rcti *partrct, int crop, int savebuf rectx= partrct->xmax - partrct->xmin; recty= partrct->ymax - partrct->ymin; - if(rectx<=0 || recty<=0) + if (rectx<=0 || recty<=0) return NULL; rr= MEM_callocN(sizeof(RenderResult), "new render result"); @@ -440,16 +440,16 @@ RenderResult *render_result_new(Render *re, rcti *partrct, int crop, int savebuf rr->tilerect.ymin = partrct->ymin - re->disprect.ymin; rr->tilerect.ymax = partrct->ymax - re->disprect.ymax; - if(savebuffers) { + if (savebuffers) { rr->exrhandle= IMB_exr_get_handle(); } /* check renderdata for amount of layers */ - for(nr=0, srl= re->r.layers.first; srl; srl= srl->next, nr++) { + for (nr=0, srl= re->r.layers.first; srl; srl= srl->next, nr++) { - if((re->r.scemode & R_SINGLE_LAYER) && nr!=re->r.actlay) + if ((re->r.scemode & R_SINGLE_LAYER) && nr!=re->r.actlay) continue; - if(srl->layflag & SCE_LAY_DISABLE) + if (srl->layflag & SCE_LAY_DISABLE) continue; rl= MEM_callocN(sizeof(RenderLayer), "new render layer"); @@ -466,7 +466,7 @@ RenderResult *render_result_new(Render *re, rcti *partrct, int crop, int savebuf rl->rectx= rectx; rl->recty= recty; - if(rr->exrhandle) { + if (rr->exrhandle) { IMB_exr_add_channel(rr->exrhandle, rl->name, "Combined.R", 0, 0, NULL); IMB_exr_add_channel(rr->exrhandle, rl->name, "Combined.G", 0, 0, NULL); IMB_exr_add_channel(rr->exrhandle, rl->name, "Combined.B", 0, 0, NULL); @@ -475,64 +475,64 @@ RenderResult *render_result_new(Render *re, rcti *partrct, int crop, int savebuf else rl->rectf= MEM_mapallocN(rectx*recty*sizeof(float)*4, "Combined rgba"); - if(srl->passflag & SCE_PASS_Z) + if (srl->passflag & SCE_PASS_Z) render_layer_add_pass(rr, rl, 1, SCE_PASS_Z); - if(srl->passflag & SCE_PASS_VECTOR) + if (srl->passflag & SCE_PASS_VECTOR) render_layer_add_pass(rr, rl, 4, SCE_PASS_VECTOR); - if(srl->passflag & SCE_PASS_NORMAL) + if (srl->passflag & SCE_PASS_NORMAL) render_layer_add_pass(rr, rl, 3, SCE_PASS_NORMAL); - if(srl->passflag & SCE_PASS_UV) + if (srl->passflag & SCE_PASS_UV) render_layer_add_pass(rr, rl, 3, SCE_PASS_UV); - if(srl->passflag & SCE_PASS_RGBA) + if (srl->passflag & SCE_PASS_RGBA) render_layer_add_pass(rr, rl, 4, SCE_PASS_RGBA); - if(srl->passflag & SCE_PASS_EMIT) + if (srl->passflag & SCE_PASS_EMIT) render_layer_add_pass(rr, rl, 3, SCE_PASS_EMIT); - if(srl->passflag & SCE_PASS_DIFFUSE) + if (srl->passflag & SCE_PASS_DIFFUSE) render_layer_add_pass(rr, rl, 3, SCE_PASS_DIFFUSE); - if(srl->passflag & SCE_PASS_SPEC) + if (srl->passflag & SCE_PASS_SPEC) render_layer_add_pass(rr, rl, 3, SCE_PASS_SPEC); - if(srl->passflag & SCE_PASS_AO) + if (srl->passflag & SCE_PASS_AO) render_layer_add_pass(rr, rl, 3, SCE_PASS_AO); - if(srl->passflag & SCE_PASS_ENVIRONMENT) + if (srl->passflag & SCE_PASS_ENVIRONMENT) render_layer_add_pass(rr, rl, 3, SCE_PASS_ENVIRONMENT); - if(srl->passflag & SCE_PASS_INDIRECT) + if (srl->passflag & SCE_PASS_INDIRECT) render_layer_add_pass(rr, rl, 3, SCE_PASS_INDIRECT); - if(srl->passflag & SCE_PASS_SHADOW) + if (srl->passflag & SCE_PASS_SHADOW) render_layer_add_pass(rr, rl, 3, SCE_PASS_SHADOW); - if(srl->passflag & SCE_PASS_REFLECT) + if (srl->passflag & SCE_PASS_REFLECT) render_layer_add_pass(rr, rl, 3, SCE_PASS_REFLECT); - if(srl->passflag & SCE_PASS_REFRACT) + if (srl->passflag & SCE_PASS_REFRACT) render_layer_add_pass(rr, rl, 3, SCE_PASS_REFRACT); - if(srl->passflag & SCE_PASS_INDEXOB) + if (srl->passflag & SCE_PASS_INDEXOB) render_layer_add_pass(rr, rl, 1, SCE_PASS_INDEXOB); - if(srl->passflag & SCE_PASS_INDEXMA) + if (srl->passflag & SCE_PASS_INDEXMA) render_layer_add_pass(rr, rl, 1, SCE_PASS_INDEXMA); - if(srl->passflag & SCE_PASS_MIST) + if (srl->passflag & SCE_PASS_MIST) render_layer_add_pass(rr, rl, 1, SCE_PASS_MIST); - if(rl->passflag & SCE_PASS_RAYHITS) + if (rl->passflag & SCE_PASS_RAYHITS) render_layer_add_pass(rr, rl, 4, SCE_PASS_RAYHITS); - if(srl->passflag & SCE_PASS_DIFFUSE_DIRECT) + if (srl->passflag & SCE_PASS_DIFFUSE_DIRECT) render_layer_add_pass(rr, rl, 3, SCE_PASS_DIFFUSE_DIRECT); - if(srl->passflag & SCE_PASS_DIFFUSE_INDIRECT) + if (srl->passflag & SCE_PASS_DIFFUSE_INDIRECT) render_layer_add_pass(rr, rl, 3, SCE_PASS_DIFFUSE_INDIRECT); - if(srl->passflag & SCE_PASS_DIFFUSE_COLOR) + if (srl->passflag & SCE_PASS_DIFFUSE_COLOR) render_layer_add_pass(rr, rl, 3, SCE_PASS_DIFFUSE_COLOR); - if(srl->passflag & SCE_PASS_GLOSSY_DIRECT) + if (srl->passflag & SCE_PASS_GLOSSY_DIRECT) render_layer_add_pass(rr, rl, 3, SCE_PASS_GLOSSY_DIRECT); - if(srl->passflag & SCE_PASS_GLOSSY_INDIRECT) + if (srl->passflag & SCE_PASS_GLOSSY_INDIRECT) render_layer_add_pass(rr, rl, 3, SCE_PASS_GLOSSY_INDIRECT); - if(srl->passflag & SCE_PASS_GLOSSY_COLOR) + if (srl->passflag & SCE_PASS_GLOSSY_COLOR) render_layer_add_pass(rr, rl, 3, SCE_PASS_GLOSSY_COLOR); - if(srl->passflag & SCE_PASS_TRANSM_DIRECT) + if (srl->passflag & SCE_PASS_TRANSM_DIRECT) render_layer_add_pass(rr, rl, 3, SCE_PASS_TRANSM_DIRECT); - if(srl->passflag & SCE_PASS_TRANSM_INDIRECT) + if (srl->passflag & SCE_PASS_TRANSM_INDIRECT) render_layer_add_pass(rr, rl, 3, SCE_PASS_TRANSM_INDIRECT); - if(srl->passflag & SCE_PASS_TRANSM_COLOR) + if (srl->passflag & SCE_PASS_TRANSM_COLOR) render_layer_add_pass(rr, rl, 3, SCE_PASS_TRANSM_COLOR); } /* sss, previewrender and envmap don't do layers, so we make a default one */ - if(rr->layers.first==NULL) { + if (rr->layers.first==NULL) { rl= MEM_callocN(sizeof(RenderLayer), "new render layer"); BLI_addtail(&rr->layers, rl); @@ -540,7 +540,7 @@ RenderResult *render_result_new(Render *re, rcti *partrct, int crop, int savebuf rl->recty= recty; /* duplicate code... */ - if(rr->exrhandle) { + if (rr->exrhandle) { IMB_exr_add_channel(rr->exrhandle, rl->name, "Combined.R", 0, 0, NULL); IMB_exr_add_channel(rr->exrhandle, rl->name, "Combined.G", 0, 0, NULL); IMB_exr_add_channel(rr->exrhandle, rl->name, "Combined.B", 0, 0, NULL); @@ -569,10 +569,10 @@ RenderResult *render_result_new_full_sample(Render *re, ListBase *lb, rcti *part { int a; - if(re->osa==0) + if (re->osa==0) return render_result_new(re, partrct, crop, savebuffers); - for(a=0; a<re->osa; a++) { + for (a=0; a<re->osa; a++) { RenderResult *rr= render_result_new(re, partrct, crop, savebuffers); BLI_addtail(lb, rr); rr->sample_nr= a; @@ -604,12 +604,12 @@ static void ml_addpass_cb(void *UNUSED(base), void *lay, char *str, float *rect, rpass->channels= totchan; rpass->passtype= passtype_from_name(str); - if(rpass->passtype==0) printf("unknown pass %s\n", str); + if (rpass->passtype==0) printf("unknown pass %s\n", str); rl->passflag |= rpass->passtype; BLI_strncpy(rpass->name, str, EXR_PASS_MAXNAME); /* channel id chars */ - for(a=0; a<totchan; a++) + for (a=0; a<totchan; a++) rpass->chan_id[a]= chan_id[a]; rpass->rect= rect; @@ -627,11 +627,11 @@ RenderResult *render_result_new_from_exr(void *exrhandle, int rectx, int recty) IMB_exr_multilayer_convert(exrhandle, rr, ml_addlayer_cb, ml_addpass_cb); - for(rl=rr->layers.first; rl; rl=rl->next) { + for (rl=rr->layers.first; rl; rl=rl->next) { rl->rectx= rectx; rl->recty= recty; - for(rpass=rl->passes.first; rpass; rpass=rpass->next) { + for (rpass=rl->passes.first; rpass; rpass=rpass->next) { rpass->rectx= rectx; rpass->recty= recty; } @@ -649,7 +649,7 @@ static void do_merge_tile(RenderResult *rr, RenderResult *rrpart, float *target, copylen= tilex= rrpart->rectx; tiley= rrpart->recty; - if(rrpart->crop) { /* filters add pixel extra */ + if (rrpart->crop) { /* filters add pixel extra */ tile+= pixsize*(rrpart->crop + rrpart->crop*tilex); copylen= tilex - 2*rrpart->crop; @@ -667,7 +667,7 @@ static void do_merge_tile(RenderResult *rr, RenderResult *rrpart, float *target, tilex *= pixsize; ofs= pixsize*rr->rectx; - for(y=0; y<tiley; y++) { + for (y=0; y<tiley; y++) { memcpy(target, tile, copylen); target+= ofs; tile+= tilex; @@ -682,14 +682,14 @@ void render_result_merge(RenderResult *rr, RenderResult *rrpart) RenderLayer *rl, *rlp; RenderPass *rpass, *rpassp; - for(rl= rr->layers.first, rlp= rrpart->layers.first; rl && rlp; rl= rl->next, rlp= rlp->next) { + for (rl= rr->layers.first, rlp= rrpart->layers.first; rl && rlp; rl= rl->next, rlp= rlp->next) { /* combined */ - if(rl->rectf && rlp->rectf) + if (rl->rectf && rlp->rectf) do_merge_tile(rr, rrpart, rl->rectf, rlp->rectf, 4); /* passes are allocated in sync */ - for(rpass= rl->passes.first, rpassp= rlp->passes.first; rpass && rpassp; rpass= rpass->next, rpassp= rpassp->next) { + for (rpass= rl->passes.first, rpassp= rlp->passes.first; rpass && rpassp; rpass= rpass->next, rpassp= rpassp->next) { do_merge_tile(rr, rrpart, rpass->rect, rpassp->rect, rpass->channels); } } @@ -722,7 +722,7 @@ int RE_WriteRenderResult(ReportList *reports, RenderResult *rr, const char *file BLI_make_existing_file(filename); /* composite result */ - if(rr->rectf) { + if (rr->rectf) { IMB_exr_add_channel(exrhandle, "Composite", "Combined.R", 4, 4*rr->rectx, rr->rectf); IMB_exr_add_channel(exrhandle, "Composite", "Combined.G", 4, 4*rr->rectx, rr->rectf+1); IMB_exr_add_channel(exrhandle, "Composite", "Combined.B", 4, 4*rr->rectx, rr->rectf+2); @@ -730,21 +730,21 @@ int RE_WriteRenderResult(ReportList *reports, RenderResult *rr, const char *file } /* add layers/passes and assign channels */ - for(rl= rr->layers.first; rl; rl= rl->next) { + for (rl= rr->layers.first; rl; rl= rl->next) { /* combined */ - if(rl->rectf) { + if (rl->rectf) { int a, xstride= 4; - for(a=0; a<xstride; a++) + for (a=0; a<xstride; a++) IMB_exr_add_channel(exrhandle, rl->name, get_pass_name(SCE_PASS_COMBINED, a), xstride, xstride*rr->rectx, rl->rectf+a); } /* passes are allocated in sync */ - for(rpass= rl->passes.first; rpass; rpass= rpass->next) { + for (rpass= rl->passes.first; rpass; rpass= rpass->next) { int a, xstride= rpass->channels; - for(a=0; a<xstride; a++) { - if(rpass->passtype) + for (a=0; a<xstride; a++) { + if (rpass->passtype) IMB_exr_add_channel(exrhandle, rl->name, get_pass_name(rpass->passtype, a), xstride, xstride*rr->rectx, rpass->rect+a); else @@ -755,7 +755,7 @@ int RE_WriteRenderResult(ReportList *reports, RenderResult *rr, const char *file } /* when the filename has no permissions, this can fail */ - if(IMB_exr_begin_write(exrhandle, filename, rr->rectx, rr->recty, compress)) { + if (IMB_exr_begin_write(exrhandle, filename, rr->rectx, rr->recty, compress)) { IMB_exr_write_channels(exrhandle); success= TRUE; } @@ -790,15 +790,15 @@ void render_result_single_layer_end(Render *re) RenderLayer *rl; int nr; - if(re->result==NULL) { + if (re->result==NULL) { printf("pop render result error; no current result!\n"); return; } - if(!re->pushedresult) + if (!re->pushedresult) return; - if(re->pushedresult->rectx==re->result->rectx && re->pushedresult->recty==re->result->recty) { + if (re->pushedresult->rectx==re->result->rectx && re->pushedresult->recty==re->result->recty) { /* find which layer in re->pushedresult should be replaced */ rl= re->result->layers.first; @@ -806,12 +806,12 @@ void render_result_single_layer_end(Render *re) BLI_remlink(&re->result->layers, rl); /* reconstruct render result layers */ - for(nr=0, srl= re->scene->r.layers.first; srl; srl= srl->next, nr++) { - if(nr==re->r.actlay) + for (nr=0, srl= re->scene->r.layers.first; srl; srl= srl->next, nr++) { + if (nr==re->r.actlay) BLI_addtail(&re->result->layers, rl); else { rlpush= RE_GetRenderLayer(re->pushedresult, srl->name); - if(rlpush) { + if (rlpush) { BLI_remlink(&re->pushedresult->layers, rlpush); BLI_addtail(&re->result->layers, rlpush); } @@ -833,9 +833,9 @@ static void save_render_result_tile(RenderResult *rr, RenderResult *rrpart) BLI_lock_thread(LOCK_IMAGE); - for(rlp= rrpart->layers.first; rlp; rlp= rlp->next) { + for (rlp= rrpart->layers.first; rlp; rlp= rlp->next) { - if(rrpart->crop) { /* filters add pixel extra */ + if (rrpart->crop) { /* filters add pixel extra */ offs= (rrpart->crop + rrpart->crop*rrpart->rectx); } else { @@ -843,17 +843,17 @@ static void save_render_result_tile(RenderResult *rr, RenderResult *rrpart) } /* combined */ - if(rlp->rectf) { + if (rlp->rectf) { int a, xstride= 4; - for(a=0; a<xstride; a++) + for (a=0; a<xstride; a++) IMB_exr_set_channel(rr->exrhandle, rlp->name, get_pass_name(SCE_PASS_COMBINED, a), xstride, xstride*rrpart->rectx, rlp->rectf+a + xstride*offs); } /* passes are allocated in sync */ - for(rpassp= rlp->passes.first; rpassp; rpassp= rpassp->next) { + for (rpassp= rlp->passes.first; rpassp; rpassp= rpassp->next) { int a, xstride= rpassp->channels; - for(a=0; a<xstride; a++) + for (a=0; a<xstride; a++) IMB_exr_set_channel(rr->exrhandle, rlp->name, get_pass_name(rpassp->passtype, a), xstride, xstride*rrpart->rectx, rpassp->rect+a + xstride*offs); } @@ -872,11 +872,11 @@ static void save_empty_result_tiles(Render *re) RenderPart *pa; RenderResult *rr; - for(rr= re->result; rr; rr= rr->next) { + for (rr= re->result; rr; rr= rr->next) { IMB_exrtile_clear_channels(rr->exrhandle); - for(pa= re->parts.first; pa; pa= pa->next) { - if(pa->ready==0) { + for (pa= re->parts.first; pa; pa= pa->next) { + if (pa->ready==0) { int party= pa->disprect.ymin - re->disprect.ymin + pa->crop; int partx= pa->disprect.xmin - re->disprect.xmin + pa->crop; IMB_exrtile_write_channels(rr->exrhandle, partx, party, 0); @@ -891,7 +891,7 @@ void render_result_exr_file_begin(Render *re) RenderResult *rr; char str[FILE_MAX]; - for(rr= re->result; rr; rr= rr->next) { + for (rr= re->result; rr; rr= rr->next) { render_result_exr_file_path(re->scene, rr->sample_nr, str); printf("write exr tmp file, %dx%d, %s\n", rr->rectx, rr->recty, str); @@ -906,7 +906,7 @@ void render_result_exr_file_end(Render *re) save_empty_result_tiles(re); - for(rr= re->result; rr; rr= rr->next) { + for (rr= re->result; rr; rr= rr->next) { IMB_exr_close(rr->exrhandle); rr->exrhandle= NULL; } @@ -920,7 +920,7 @@ void render_result_exr_file_end(Render *re) /* save part into exr file */ void render_result_exr_file_merge(RenderResult *rr, RenderResult *rrpart) { - for(; rr && rrpart; rr= rr->next, rrpart= rrpart->next) + for (; rr && rrpart; rr= rr->next, rrpart= rrpart->next) save_render_result_tile(rr, rrpart); } @@ -932,7 +932,7 @@ void render_result_exr_file_path(Scene *scene, int sample, char *filepath) BLI_strncpy(di, G.main->name, FILE_MAX); BLI_splitdirstring(di, fi); - if(sample==0) + if (sample==0) BLI_snprintf(name, sizeof(name), "%s_%s.exr", fi, scene->id.name+2); else BLI_snprintf(name, sizeof(name), "%s_%s%d.exr", fi, scene->id.name+2, sample); @@ -952,7 +952,7 @@ int render_result_exr_file_read(Render *re, int sample) render_result_exr_file_path(re->scene, sample, str); printf("read exr tmp file: %s\n", str); - if(render_result_exr_file_read_path(re->result, str)) { + if (render_result_exr_file_read_path(re->result, str)) { success= TRUE; } else { @@ -972,14 +972,14 @@ int render_result_exr_file_read_path(RenderResult *rr, const char *filepath) void *exrhandle= IMB_exr_get_handle(); int rectx, recty; - if(IMB_exr_begin_read(exrhandle, filepath, &rectx, &recty)==0) { + if (IMB_exr_begin_read(exrhandle, filepath, &rectx, &recty)==0) { printf("failed being read %s\n", filepath); IMB_exr_close(exrhandle); return 0; } - if(rr == NULL || rectx!=rr->rectx || recty!=rr->recty) { - if(rr) + if (rr == NULL || rectx!=rr->rectx || recty!=rr->recty) { + if (rr) printf("error in reading render result: dimensions don't match\n"); else printf("error in reading render result: NULL result pointer\n"); @@ -987,19 +987,19 @@ int render_result_exr_file_read_path(RenderResult *rr, const char *filepath) return 0; } - for(rl= rr->layers.first; rl; rl= rl->next) { + for (rl= rr->layers.first; rl; rl= rl->next) { /* combined */ - if(rl->rectf) { + if (rl->rectf) { int a, xstride= 4; - for(a=0; a<xstride; a++) + for (a=0; a<xstride; a++) IMB_exr_set_channel(exrhandle, rl->name, get_pass_name(SCE_PASS_COMBINED, a), xstride, xstride*rectx, rl->rectf+a); } /* passes are allocated in sync */ - for(rpass= rl->passes.first; rpass; rpass= rpass->next) { + for (rpass= rl->passes.first; rpass; rpass= rpass->next) { int a, xstride= rpass->channels; - for(a=0; a<xstride; a++) + for (a=0; a<xstride; a++) IMB_exr_set_channel(exrhandle, rl->name, get_pass_name(rpass->passtype, a), xstride, xstride*rectx, rpass->rect+a); @@ -1035,14 +1035,15 @@ ImBuf *render_result_rect_to_ibuf(RenderResult *rr, RenderData *rd) ibuf->profile = IB_PROFILE_SRGB; if (BKE_imtype_valid_depths(rd->im_format.imtype) & (R_IMF_CHAN_DEPTH_12|R_IMF_CHAN_DEPTH_16|R_IMF_CHAN_DEPTH_24|R_IMF_CHAN_DEPTH_32)) IMB_float_from_rect(ibuf); - } else { + } + else { ibuf->profile = IB_PROFILE_LINEAR_RGB; } } /* color -> greyscale */ /* editing directly would alter the render view */ - if(rd->im_format.planes == R_IMF_PLANES_BW) { + if (rd->im_format.planes == R_IMF_PLANES_BW) { ImBuf *ibuf_bw= IMB_dupImBuf(ibuf); IMB_color_to_bw(ibuf_bw); IMB_freeImBuf(ibuf); @@ -1054,7 +1055,7 @@ ImBuf *render_result_rect_to_ibuf(RenderResult *rr, RenderData *rd) void render_result_rect_from_ibuf(RenderResult *rr, RenderData *rd, ImBuf *ibuf) { - if(ibuf->rect_float) { + if (ibuf->rect_float) { /* color management: when off ensure rectf is non-lin, since thats what the internal * render engine delivers */ int profile_to= (rd->color_mgt_flag & R_COLOR_MANAGEMENT)? IB_PROFILE_LINEAR_RGB: IB_PROFILE_SRGB; @@ -1070,19 +1071,19 @@ void render_result_rect_from_ibuf(RenderResult *rr, RenderData *rd, ImBuf *ibuf) /* TSK! Since sequence render doesn't free the *rr render result, the old rect32 * can hang around when sequence render has rendered a 32 bits one before */ - if(rr->rect32) { + if (rr->rect32) { MEM_freeN(rr->rect32); rr->rect32= NULL; } } - else if(ibuf->rect) { + else if (ibuf->rect) { if (!rr->rect32) rr->rect32= MEM_mallocN(sizeof(int)*rr->rectx*rr->recty, "render_seq rect"); memcpy(rr->rect32, ibuf->rect, 4*rr->rectx*rr->recty); /* Same things as above, old rectf can hang around from previous render. */ - if(rr->rectf) { + if (rr->rectf) { MEM_freeN(rr->rectf); rr->rectf= NULL; } @@ -1101,10 +1102,10 @@ void render_result_rect_fill_zero(RenderResult *rr) void render_result_rect_get_pixels(RenderResult *rr, RenderData *rd, unsigned int *rect, int rectx, int recty) { - if(rr->rect32) { + if (rr->rect32) { memcpy(rect, rr->rect32, sizeof(int)*rr->rectx*rr->recty); } - else if(rr->rectf) { + else if (rr->rectf) { int profile_from= (rd->color_mgt_flag & R_COLOR_MANAGEMENT)? IB_PROFILE_LINEAR_RGB: IB_PROFILE_SRGB; int predivide= (rd->color_mgt_flag & R_COLOR_MANAGEMENT_PREDIVIDE); int dither= 0; diff --git a/source/blender/render/intern/source/render_texture.c b/source/blender/render/intern/source/render_texture.c index ede314a42e1..7e1ff53d4e7 100644 --- a/source/blender/render/intern/source/render_texture.c +++ b/source/blender/render/intern/source/render_texture.c @@ -96,39 +96,39 @@ static void init_render_texture(Render *re, Tex *tex) { int cfra= re->scene->r.cfra; - if(re) cfra= re->r.cfra; + if (re) cfra= re->r.cfra; /* imap test */ - if(tex->ima && ELEM(tex->ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) { + if (tex->ima && ELEM(tex->ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) { BKE_image_user_calc_frame(&tex->iuser, cfra, re?re->flag & R_SEC_FIELD:0); } - if(tex->type==TEX_PLUGIN) { - if(tex->plugin && tex->plugin->doit) { - if(tex->plugin->cfra) { + if (tex->type==TEX_PLUGIN) { + if (tex->plugin && tex->plugin->doit) { + if (tex->plugin->cfra) { *(tex->plugin->cfra)= (float)cfra; //BKE_curframe(re->scene); // XXX old animsys - timing stuff to be fixed } } } - else if(tex->type==TEX_ENVMAP) { + else if (tex->type==TEX_ENVMAP) { /* just in case */ tex->imaflag |= TEX_INTERPOL | TEX_MIPMAP; tex->extend= TEX_CLIP; - if(tex->env) { - if(tex->env->type==ENV_PLANE) + if (tex->env) { + if (tex->env->type==ENV_PLANE) tex->extend= TEX_EXTEND; /* only free envmap when rendermode was set to render envmaps, for previewrender */ - if(G.rendering && re) { + if (G.rendering && re) { if (re->r.mode & R_ENVMAP) - if(tex->env->stype==ENV_ANIM) + if (tex->env->stype==ENV_ANIM) BKE_free_envmapdata(tex->env); } } } - if(tex->nodetree && tex->use_nodes) { + if (tex->nodetree && tex->use_nodes) { ntreeTexBeginExecTree(tex->nodetree, 1); /* has internal flag to detect it only does it once */ } } @@ -141,22 +141,22 @@ void init_render_textures(Render *re) tex= re->main->tex.first; while(tex) { - if(tex->id.us) init_render_texture(re, tex); + if (tex->id.us) init_render_texture(re, tex); tex= tex->id.next; } } static void end_render_texture(Tex *tex) { - if(tex && tex->use_nodes && tex->nodetree && tex->nodetree->execdata) + if (tex && tex->use_nodes && tex->nodetree && tex->nodetree->execdata) ntreeTexEndExecTree(tex->nodetree->execdata, 1); } void end_render_textures(Render *re) { Tex *tex; - for(tex= re->main->tex.first; tex; tex= tex->id.next) - if(tex->id.us) + for (tex= re->main->tex.first; tex; tex= tex->id.next) + if (tex->id.us) end_render_texture(tex); } @@ -197,7 +197,7 @@ static int blend(Tex *tex, float *texvec, TexResult *texres) { float x, y, t; - if(tex->flag & TEX_FLIPBLEND) { + if (tex->flag & TEX_FLIPBLEND) { x= texvec[1]; y= texvec[0]; } @@ -206,33 +206,33 @@ static int blend(Tex *tex, float *texvec, TexResult *texres) y= texvec[1]; } - if(tex->stype==TEX_LIN) { /* lin */ + if (tex->stype==TEX_LIN) { /* lin */ texres->tin= (1.0f+x)/2.0f; } - else if(tex->stype==TEX_QUAD) { /* quad */ + else if (tex->stype==TEX_QUAD) { /* quad */ texres->tin= (1.0f+x)/2.0f; - if(texres->tin<0.0f) texres->tin= 0.0f; + if (texres->tin<0.0f) texres->tin= 0.0f; else texres->tin*= texres->tin; } - else if(tex->stype==TEX_EASE) { /* ease */ + else if (tex->stype==TEX_EASE) { /* ease */ texres->tin= (1.0f+x)/2.0f; - if(texres->tin<=0.0f) texres->tin= 0.0f; - else if(texres->tin>=1.0f) texres->tin= 1.0f; + if (texres->tin<=0.0f) texres->tin= 0.0f; + else if (texres->tin>=1.0f) texres->tin= 1.0f; else { t= texres->tin*texres->tin; texres->tin= (3.0f*t-2.0f*t*texres->tin); } } - else if(tex->stype==TEX_DIAG) { /* diag */ + else if (tex->stype==TEX_DIAG) { /* diag */ texres->tin= (2.0f+x+y)/4.0f; } - else if(tex->stype==TEX_RAD) { /* radial */ + else if (tex->stype==TEX_RAD) { /* radial */ texres->tin= (atan2(y,x) / (2*M_PI) + 0.5); } else { /* sphere TEX_SPHERE */ texres->tin= 1.0-sqrt(x*x+ y*y+texvec[2]*texvec[2]); - if(texres->tin<0.0f) texres->tin= 0.0f; - if(tex->stype==TEX_HALO) texres->tin*= texres->tin; /* halo */ + if (texres->tin<0.0f) texres->tin= 0.0f; + if (tex->stype==TEX_HALO) texres->tin*= texres->tin; /* halo */ } BRICONT; @@ -426,37 +426,37 @@ static int magic(Tex *tex, float *texvec, TexResult *texres) x= sin( ( texvec[0]+texvec[1]+texvec[2])*5.0f ); y= cos( (-texvec[0]+texvec[1]-texvec[2])*5.0f ); z= -cos( (-texvec[0]-texvec[1]+texvec[2])*5.0f ); - if(n>0) { + if (n>0) { x*= turb; y*= turb; z*= turb; y= -cos(x-y+z); y*= turb; - if(n>1) { + if (n>1) { x= cos(x-y-z); x*= turb; - if(n>2) { + if (n>2) { z= sin(-x-y-z); z*= turb; - if(n>3) { + if (n>3) { x= -cos(-x+y-z); x*= turb; - if(n>4) { + if (n>4) { y= -sin(-x+y+z); y*= turb; - if(n>5) { + if (n>5) { y= -cos(-x+y+z); y*= turb; - if(n>6) { + if (n>6) { x= cos(x+y+z); x*= turb; - if(n>7) { + if (n>7) { z= sin(x+y-z); z*= turb; - if(n>8) { + if (n>8) { x= -cos(-x-y+z); x*= turb; - if(n>9) { + if (n>9) { y= -sin(x-y+z); y*= turb; } @@ -470,7 +470,7 @@ static int magic(Tex *tex, float *texvec, TexResult *texres) } } - if(turb!=0.0f) { + if (turb!=0.0f) { turb*= 2.0f; x/= turb; y/= turb; @@ -500,19 +500,19 @@ static int stucci(Tex *tex, float *texvec, TexResult *texres) ofs= tex->turbul/200.0f; - if(tex->stype) ofs*=(b2*b2); + if (tex->stype) ofs*=(b2*b2); nor[0] = BLI_gNoise(tex->noisesize, texvec[0]+ofs, texvec[1], texvec[2], (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis); nor[1] = BLI_gNoise(tex->noisesize, texvec[0], texvec[1]+ofs, texvec[2], (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis); nor[2] = BLI_gNoise(tex->noisesize, texvec[0], texvec[1], texvec[2]+ofs, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis); texres->tin= nor[2]; - if(texres->nor) { + if (texres->nor) { copy_v3_v3(texres->nor, nor); tex_normal_derivate(tex, texres); - if(tex->stype==TEX_WALLOUT) { + if (tex->stype==TEX_WALLOUT) { texres->nor[0]= -texres->nor[0]; texres->nor[1]= -texres->nor[1]; texres->nor[2]= -texres->nor[2]; @@ -521,10 +521,10 @@ static int stucci(Tex *tex, float *texvec, TexResult *texres) retval |= TEX_NOR; } - if(tex->stype==TEX_WALLOUT) + if (tex->stype==TEX_WALLOUT) texres->tin= 1.0f-texres->tin; - if(texres->tin<0.0f) + if (texres->tin<0.0f) texres->tin= 0.0f; return retval; @@ -756,21 +756,23 @@ static int plugintex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex texres->tin= 0.0; pit= tex->plugin; - if(pit && pit->doit) { - if(texres->nor) { + if (pit && pit->doit) { + if (texres->nor) { if (pit->version < 6) { copy_v3_v3(pit->result+5, texres->nor); - } else { + } + else { copy_v3_v3(result+5, texres->nor); } } if (pit->version < 6) { - if(osatex) rgbnor= ((TexDoitold)pit->doit)(tex->stype, + if (osatex) rgbnor= ((TexDoitold)pit->doit)(tex->stype, pit->data, texvec, dxt, dyt); else rgbnor= ((TexDoitold)pit->doit)(tex->stype, pit->data, texvec, NULL, NULL); - } else { - if(osatex) rgbnor= ((TexDoit)pit->doit)(tex->stype, + } + else { + if (osatex) rgbnor= ((TexDoit)pit->doit)(tex->stype, pit->data, texvec, dxt, dyt, result); else rgbnor= ((TexDoit)pit->doit)(tex->stype, pit->data, texvec, NULL, NULL, result); @@ -778,27 +780,30 @@ static int plugintex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex if (pit->version < 6) { texres->tin = pit->result[0]; - } else { + } + else { texres->tin = result[0]; /* XXX, assigning garbage value, fixme! */ } - if(rgbnor & TEX_NOR) { - if(texres->nor) { + if (rgbnor & TEX_NOR) { + if (texres->nor) { if (pit->version < 6) { copy_v3_v3(texres->nor, pit->result+5); - } else { + } + else { copy_v3_v3(texres->nor, result+5); } } } - if(rgbnor & TEX_RGB) { + if (rgbnor & TEX_RGB) { if (pit->version < 6) { texres->tr = pit->result[1]; texres->tg = pit->result[2]; texres->tb = pit->result[3]; texres->ta = pit->result[4]; - } else { + } + else { texres->tr = result[1]; texres->tg = result[2]; texres->tb = result[3]; @@ -820,7 +825,7 @@ static int cubemap_glob(float *n, float x, float y, float z, float *adr1, float float x1, y1, z1, nor[3]; int ret; - if(n==NULL) { + if (n==NULL) { nor[0]= x; nor[1]= y; nor[2]= z; // use local render coord } else { @@ -832,12 +837,12 @@ static int cubemap_glob(float *n, float x, float y, float z, float *adr1, float y1= fabs(nor[1]); z1= fabs(nor[2]); - if(z1>=x1 && z1>=y1) { + if (z1>=x1 && z1>=y1) { *adr1 = (x + 1.0f) / 2.0f; *adr2 = (y + 1.0f) / 2.0f; ret= 0; } - else if(y1>=x1 && y1>=z1) { + else if (y1>=x1 && y1>=z1) { *adr1 = (x + 1.0f) / 2.0f; *adr2 = (z + 1.0f) / 2.0f; ret= 1; @@ -857,24 +862,24 @@ static int cubemap(MTex *mtex, VlakRen *vlr, float *n, float x, float y, float z { int proj[4]={0, ME_PROJXY, ME_PROJXZ, ME_PROJYZ}, ret= 0; - if(vlr) { + if (vlr) { int index; /* Mesh vertices have such flags, for others we calculate it once based on orco */ - if((vlr->puno & (ME_PROJXY|ME_PROJXZ|ME_PROJYZ))==0) { + if ((vlr->puno & (ME_PROJXY|ME_PROJXZ|ME_PROJYZ))==0) { /* test for v1, vlr can be faked for baking */ - if(vlr->v1 && vlr->v1->orco) { + if (vlr->v1 && vlr->v1->orco) { float nor[3]; normal_tri_v3( nor,vlr->v1->orco, vlr->v2->orco, vlr->v3->orco); - if( fabs(nor[0])<fabs(nor[2]) && fabs(nor[1])<fabs(nor[2]) ) vlr->puno |= ME_PROJXY; - else if( fabs(nor[0])<fabs(nor[1]) && fabs(nor[2])<fabs(nor[1]) ) vlr->puno |= ME_PROJXZ; + if ( fabs(nor[0])<fabs(nor[2]) && fabs(nor[1])<fabs(nor[2]) ) vlr->puno |= ME_PROJXY; + else if ( fabs(nor[0])<fabs(nor[1]) && fabs(nor[2])<fabs(nor[1]) ) vlr->puno |= ME_PROJXZ; else vlr->puno |= ME_PROJYZ; } else return cubemap_glob(n, x, y, z, adr1, adr2); } - if(mtex) { + if (mtex) { /* the mtex->proj{xyz} have type char. maybe this should be wider? */ /* casting to int ensures that the index type is right. */ index = (int) mtex->projx; @@ -887,11 +892,11 @@ static int cubemap(MTex *mtex, VlakRen *vlr, float *n, float x, float y, float z proj[index]= ME_PROJYZ; } - if(vlr->puno & proj[1]) { + if (vlr->puno & proj[1]) { *adr1 = (x + 1.0f) / 2.0f; *adr2 = (y + 1.0f) / 2.0f; } - else if(vlr->puno & proj[2]) { + else if (vlr->puno & proj[2]) { *adr1 = (x + 1.0f) / 2.0f; *adr2 = (z + 1.0f) / 2.0f; ret= 1; @@ -916,21 +921,21 @@ static int cubemap_ob(Object *ob, float *n, float x, float y, float z, float *ad float x1, y1, z1, nor[3]; int ret; - if(n==NULL) return 0; + if (n==NULL) return 0; copy_v3_v3(nor, n); - if(ob) mul_mat3_m4_v3(ob->imat, nor); + if (ob) mul_mat3_m4_v3(ob->imat, nor); x1= fabs(nor[0]); y1= fabs(nor[1]); z1= fabs(nor[2]); - if(z1>=x1 && z1>=y1) { + if (z1>=x1 && z1>=y1) { *adr1 = (x + 1.0f) / 2.0f; *adr2 = (y + 1.0f) / 2.0f; ret= 0; } - else if(y1>=x1 && y1>=z1) { + else if (y1>=x1 && y1>=z1) { *adr1 = (x + 1.0f) / 2.0f; *adr2 = (z + 1.0f) / 2.0f; ret= 1; @@ -958,53 +963,53 @@ static void do_2d_mapping(MTex *mtex, float *t, VlakRen *vlr, float *n, float *d ob= mtex->object; texco= mtex->texco; - if(R.osa==0) { + if (R.osa==0) { - if(wrap==MTEX_FLAT) { + if (wrap==MTEX_FLAT) { fx = (t[0] + 1.0f) / 2.0f; fy = (t[1] + 1.0f) / 2.0f; } - else if(wrap==MTEX_TUBE) map_to_tube( &fx, &fy,t[0], t[1], t[2]); - else if(wrap==MTEX_SPHERE) map_to_sphere( &fx, &fy,t[0], t[1], t[2]); + else if (wrap==MTEX_TUBE) map_to_tube( &fx, &fy,t[0], t[1], t[2]); + else if (wrap==MTEX_SPHERE) map_to_sphere( &fx, &fy,t[0], t[1], t[2]); else { - if(texco==TEXCO_OBJECT) cubemap_ob(ob, n, t[0], t[1], t[2], &fx, &fy); - else if(texco==TEXCO_GLOB) cubemap_glob(n, t[0], t[1], t[2], &fx, &fy); + if (texco==TEXCO_OBJECT) cubemap_ob(ob, n, t[0], t[1], t[2], &fx, &fy); + else if (texco==TEXCO_GLOB) cubemap_glob(n, t[0], t[1], t[2], &fx, &fy); else cubemap(mtex, vlr, n, t[0], t[1], t[2], &fx, &fy); } /* repeat */ - if(tex->extend==TEX_REPEAT) { - if(tex->xrepeat>1) { + if (tex->extend==TEX_REPEAT) { + if (tex->xrepeat>1) { float origf= fx *= tex->xrepeat; - if(fx>1.0f) fx -= (int)(fx); - else if(fx<0.0f) fx+= 1-(int)(fx); + if (fx>1.0f) fx -= (int)(fx); + else if (fx<0.0f) fx+= 1-(int)(fx); - if(tex->flag & TEX_REPEAT_XMIR) { + if (tex->flag & TEX_REPEAT_XMIR) { int orig= (int)floor(origf); - if(orig & 1) + if (orig & 1) fx= 1.0f-fx; } } - if(tex->yrepeat>1) { + if (tex->yrepeat>1) { float origf= fy *= tex->yrepeat; - if(fy>1.0f) fy -= (int)(fy); - else if(fy<0.0f) fy+= 1-(int)(fy); + if (fy>1.0f) fy -= (int)(fy); + else if (fy<0.0f) fy+= 1-(int)(fy); - if(tex->flag & TEX_REPEAT_YMIR) { + if (tex->flag & TEX_REPEAT_YMIR) { int orig= (int)floor(origf); - if(orig & 1) + if (orig & 1) fy= 1.0f-fy; } } } /* crop */ - if(tex->cropxmin!=0.0f || tex->cropxmax!=1.0f) { + if (tex->cropxmin!=0.0f || tex->cropxmax!=1.0f) { fac1= tex->cropxmax - tex->cropxmin; fx= tex->cropxmin+ fx*fac1; } - if(tex->cropymin!=0.0f || tex->cropymax!=1.0f) { + if (tex->cropymin!=0.0f || tex->cropymax!=1.0f) { fac1= tex->cropymax - tex->cropymin; fy= tex->cropymin+ fy*fac1; } @@ -1014,7 +1019,7 @@ static void do_2d_mapping(MTex *mtex, float *t, VlakRen *vlr, float *n, float *d } else { - if(wrap==MTEX_FLAT) { + if (wrap==MTEX_FLAT) { fx= (t[0] + 1.0f) / 2.0f; fy= (t[1] + 1.0f) / 2.0f; dxt[0]/= 2.0f; @@ -1027,15 +1032,15 @@ static void do_2d_mapping(MTex *mtex, float *t, VlakRen *vlr, float *n, float *d else if ELEM(wrap, MTEX_TUBE, MTEX_SPHERE) { /* exception: the seam behind (y<0.0) */ ok= 1; - if(t[1]<=0.0f) { + if (t[1]<=0.0f) { fx= t[0]+dxt[0]; fy= t[0]+dyt[0]; - if(fx>=0.0f && fy>=0.0f && t[0]>=0.0f); - else if(fx<=0.0f && fy<=0.0f && t[0]<=0.0f); + if (fx>=0.0f && fy>=0.0f && t[0]>=0.0f); + else if (fx<=0.0f && fy<=0.0f && t[0]<=0.0f); else ok= 0; } - if(ok) { - if(wrap==MTEX_TUBE) { + if (ok) { + if (wrap==MTEX_TUBE) { map_to_tube( area, area+1,t[0], t[1], t[2]); map_to_tube( area+2, area+3,t[0]+dxt[0], t[1]+dxt[1], t[2]+dxt[2]); map_to_tube( area+4, area+5,t[0]+dyt[0], t[1]+dyt[1], t[2]+dyt[2]); @@ -1048,7 +1053,7 @@ static void do_2d_mapping(MTex *mtex, float *t, VlakRen *vlr, float *n, float *d areaflag= 1; } else { - if(wrap==MTEX_TUBE) map_to_tube( &fx, &fy,t[0], t[1], t[2]); + if (wrap==MTEX_TUBE) map_to_tube( &fx, &fy,t[0], t[1], t[2]); else map_to_sphere( &fx, &fy,t[0], t[1], t[2]); dxt[0]/= 2.0f; dxt[1]/= 2.0f; @@ -1058,15 +1063,15 @@ static void do_2d_mapping(MTex *mtex, float *t, VlakRen *vlr, float *n, float *d } else { - if(texco==TEXCO_OBJECT) proj = cubemap_ob(ob, n, t[0], t[1], t[2], &fx, &fy); + if (texco==TEXCO_OBJECT) proj = cubemap_ob(ob, n, t[0], t[1], t[2], &fx, &fy); else if (texco==TEXCO_GLOB) proj = cubemap_glob(n, t[0], t[1], t[2], &fx, &fy); else proj = cubemap(mtex, vlr, n, t[0], t[1], t[2], &fx, &fy); - if(proj==1) { + if (proj==1) { SWAP(float, dxt[1], dxt[2]); SWAP(float, dyt[1], dyt[2]); } - else if(proj==2) { + else if (proj==2) { float f1= dxt[0], f2= dyt[0]; dxt[0]= dxt[1]; dyt[0]= dyt[1]; @@ -1087,7 +1092,7 @@ static void do_2d_mapping(MTex *mtex, float *t, VlakRen *vlr, float *n, float *d } /* if area, then reacalculate dxt[] and dyt[] */ - if(areaflag) { + if (areaflag) { fx= area[0]; fy= area[1]; dxt[0]= area[2]-fx; @@ -1097,19 +1102,19 @@ static void do_2d_mapping(MTex *mtex, float *t, VlakRen *vlr, float *n, float *d } /* repeat */ - if(tex->extend==TEX_REPEAT) { + if (tex->extend==TEX_REPEAT) { float max= 1.0f; - if(tex->xrepeat>1) { + if (tex->xrepeat>1) { float origf= fx *= tex->xrepeat; // TXF: omit mirror here, see comments in do_material_tex() after do_2d_mapping() call if (tex->texfilter == TXF_BOX) { - if(fx>1.0f) fx -= (int)(fx); - else if(fx<0.0f) fx+= 1-(int)(fx); + if (fx>1.0f) fx -= (int)(fx); + else if (fx<0.0f) fx+= 1-(int)(fx); - if(tex->flag & TEX_REPEAT_XMIR) { + if (tex->flag & TEX_REPEAT_XMIR) { int orig= (int)floor(origf); - if(orig & 1) + if (orig & 1) fx= 1.0f-fx; } } @@ -1119,41 +1124,41 @@ static void do_2d_mapping(MTex *mtex, float *t, VlakRen *vlr, float *n, float *d dxt[0]*= tex->xrepeat; dyt[0]*= tex->xrepeat; } - if(tex->yrepeat>1) { + if (tex->yrepeat>1) { float origf= fy *= tex->yrepeat; // TXF: omit mirror here, see comments in do_material_tex() after do_2d_mapping() call if (tex->texfilter == TXF_BOX) { - if(fy>1.0f) fy -= (int)(fy); - else if(fy<0.0f) fy+= 1-(int)(fy); + if (fy>1.0f) fy -= (int)(fy); + else if (fy<0.0f) fy+= 1-(int)(fy); - if(tex->flag & TEX_REPEAT_YMIR) { + if (tex->flag & TEX_REPEAT_YMIR) { int orig= (int)floor(origf); - if(orig & 1) + if (orig & 1) fy= 1.0f-fy; } } - if(max<tex->yrepeat) + if (max<tex->yrepeat) max= tex->yrepeat; dxt[1]*= tex->yrepeat; dyt[1]*= tex->yrepeat; } - if(max!=1.0f) { + if (max!=1.0f) { dxt[2]*= max; dyt[2]*= max; } } /* crop */ - if(tex->cropxmin!=0.0f || tex->cropxmax!=1.0f) { + if (tex->cropxmin!=0.0f || tex->cropxmax!=1.0f) { fac1= tex->cropxmax - tex->cropxmin; fx= tex->cropxmin+ fx*fac1; dxt[0]*= fac1; dyt[0]*= fac1; } - if(tex->cropymin!=0.0f || tex->cropymax!=1.0f) { + if (tex->cropymin!=0.0f || tex->cropymax!=1.0f) { fac1= tex->cropymax - tex->cropymin; fy= tex->cropymin+ fy*fac1; dxt[1]*= fac1; @@ -1175,7 +1180,7 @@ static int multitex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, texres->talpha= 0; /* is set when image texture returns alpha (considered premul) */ - if(tex->use_nodes && tex->nodetree) { + if (tex->use_nodes && tex->nodetree) { retval = ntreeTexExecTree(tex->nodetree, texres, texvec, dxt, dyt, osatex, thread, tex, which_output, R.r.cfra, (R.r.scemode & R_TEXNODE_PREVIEW) != 0, NULL, NULL); } @@ -1207,7 +1212,7 @@ static int multitex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, retval= texnoise(tex, texres); break; case TEX_IMAGE: - if(osatex) retval= imagewraposa(tex, tex->ima, NULL, texvec, dxt, dyt, texres); + if (osatex) retval= imagewraposa(tex, tex->ima, NULL, texvec, dxt, dyt, texres); else retval= imagewrap(tex, tex->ima, NULL, texvec, texres); tag_image_time(tex->ima); /* tag image as having being used */ break; @@ -1287,27 +1292,27 @@ static int multitex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, /* this is called from the shader and texture nodes */ int multitex_nodes(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, TexResult *texres, short thread, short which_output, ShadeInput *shi, MTex *mtex) { - if(tex==NULL) { + if (tex==NULL) { memset(texres, 0, sizeof(TexResult)); return 0; } - if(mtex) + if (mtex) which_output= mtex->which_output; - if(tex->type==TEX_IMAGE) { + if (tex->type==TEX_IMAGE) { int rgbnor; - if(mtex) { + if (mtex) { /* we have mtex, use it for 2d mapping images only */ do_2d_mapping(mtex, texvec, shi->vlr, shi->facenor, dxt, dyt); rgbnor= multitex(tex, texvec, dxt, dyt, osatex, texres, thread, which_output); - if(mtex->mapto & (MAP_COL+MAP_COLSPEC+MAP_COLMIR)) { + if (mtex->mapto & (MAP_COL+MAP_COLSPEC+MAP_COLMIR)) { ImBuf *ibuf = BKE_image_get_ibuf(tex->ima, &tex->iuser); /* don't linearize float buffers, assumed to be linear */ - if(ibuf && !(ibuf->rect_float) && R.r.color_mgt_flag & R_COLOR_MANAGEMENT) + if (ibuf && !(ibuf->rect_float) && R.r.color_mgt_flag & R_COLOR_MANAGEMENT) srgb_to_linearrgb_v3_v3(&texres->tr, &texres->tr); } } @@ -1322,7 +1327,7 @@ int multitex_nodes(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, localmtex.texco= TEXCO_ORCO; copy_v3_v3(texvec_l, texvec); - if(dxt && dyt) { + if (dxt && dyt) { copy_v3_v3(dxt_l, dxt); copy_v3_v3(dyt_l, dyt); } @@ -1346,7 +1351,7 @@ int multitex_mtex(ShadeInput *shi, MTex *mtex, float *texvec, float *dxt, float { Tex *tex= mtex->tex; - if(tex->use_nodes && tex->nodetree) { + if (tex->use_nodes && tex->nodetree) { /* stupid exception here .. but we have to pass shi and mtex to * textures nodes for 2d mapping and color management for images */ return ntreeTexExecTree(tex->nodetree, texres, texvec, dxt, dyt, shi->osatex, shi->thread, @@ -1414,15 +1419,15 @@ void texture_rgb_blend(float in[3], const float tex[3], const float out[3], floa fact*= facg; facm= 1.0f-facg; - if(out[0] < 0.5f) + if (out[0] < 0.5f) in[0] = out[0] * (facm + 2.0f*fact*tex[0]); else in[0] = 1.0f - (facm + 2.0f*fact*(1.0f - tex[0])) * (1.0f - out[0]); - if(out[1] < 0.5f) + if (out[1] < 0.5f) in[1] = out[1] * (facm + 2.0f*fact*tex[1]); else in[1] = 1.0f - (facm + 2.0f*fact*(1.0f - tex[1])) * (1.0f - out[1]); - if(out[2] < 0.5f) + if (out[2] < 0.5f) in[2] = out[2] * (facm + 2.0f*fact*tex[2]); else in[2] = 1.0f - (facm + 2.0f*fact*(1.0f - tex[2])) * (1.0f - out[2]); @@ -1441,11 +1446,11 @@ void texture_rgb_blend(float in[3], const float tex[3], const float out[3], floa fact*= facg; facm= 1.0f-fact; - if(tex[0]!=0.0f) + if (tex[0]!=0.0f) in[0]= facm*out[0] + fact*out[0]/tex[0]; - if(tex[1]!=0.0f) + if (tex[1]!=0.0f) in[1]= facm*out[1] + fact*out[1]/tex[1]; - if(tex[2]!=0.0f) + if (tex[2]!=0.0f) in[2]= facm*out[2] + fact*out[2]/tex[2]; break; @@ -1463,22 +1468,22 @@ void texture_rgb_blend(float in[3], const float tex[3], const float out[3], floa facm= 1.0f-fact; col= tex[0]+((1-tex[0])*facm); - if(col < out[0]) in[0]= col; else in[0]= out[0]; + if (col < out[0]) in[0]= col; else in[0]= out[0]; col= tex[1]+((1-tex[1])*facm); - if(col < out[1]) in[1]= col; else in[1]= out[1]; + if (col < out[1]) in[1]= col; else in[1]= out[1]; col= tex[2]+((1-tex[2])*facm); - if(col < out[2]) in[2]= col; else in[2]= out[2]; + if (col < out[2]) in[2]= col; else in[2]= out[2]; break; case MTEX_LIGHT: fact*= facg; col= fact*tex[0]; - if(col > out[0]) in[0]= col; else in[0]= out[0]; + if (col > out[0]) in[0]= col; else in[0]= out[0]; col= fact*tex[1]; - if(col > out[1]) in[1]= col; else in[1]= out[1]; + if (col > out[1]) in[1]= col; else in[1]= out[1]; col= fact*tex[2]; - if(col > out[2]) in[2]= col; else in[2]= out[2]; + if (col > out[2]) in[2]= col; else in[2]= out[2]; break; case MTEX_BLEND_HUE: @@ -1523,7 +1528,7 @@ float texture_value_blend(float tex, float out, float fact, float facg, int blen fact*= facg; facm= 1.0f-fact; - if(flip) SWAP(float, fact, facm); + if (flip) SWAP(float, fact, facm); switch(blendtype) { case MTEX_BLEND: @@ -1542,7 +1547,7 @@ float texture_value_blend(float tex, float out, float fact, float facg, int blen case MTEX_OVERLAY: facm= 1.0f-facg; - if(out < 0.5f) + if (out < 0.5f) in = out * (facm + 2.0f*fact*tex); else in = 1.0f - (facm + 2.0f*fact*(1.0f - tex)) * (1.0f - out); @@ -1555,7 +1560,7 @@ float texture_value_blend(float tex, float out, float fact, float facg, int blen break; case MTEX_DIV: - if(tex!=0.0f) + if (tex!=0.0f) in= facm*out + fact*out/tex; break; @@ -1565,12 +1570,12 @@ float texture_value_blend(float tex, float out, float fact, float facg, int blen case MTEX_DARK: col= fact*tex; - if(col < out) in= col; else in= out; + if (col < out) in= col; else in= out; break; case MTEX_LIGHT: col= fact*tex; - if(col > out) in= col; else in= out; + if (col > out) in= col; else in= out; break; case MTEX_SOFT_LIGHT: @@ -1702,14 +1707,14 @@ static void compatible_bump_uv_derivs(CompatibleBump *compat_bump, ShadeInput *s // NOTE: test for shi->obr->ob here, since vlr/obr/obi can be 'fake' when called from fastshade(), another reason to move it.. // NOTE: shi->v1 is NULL when called from displace_render_vert, assigning verts in this case is not trivial because the shi quad face side is not know. if ((mtex->texflag & MTEX_COMPAT_BUMP) && shi->obr && shi->obr->ob && shi->v1) { - if(mtex->mapto & (MAP_NORM|MAP_WARP) && !((mtex->tex->type==TEX_IMAGE) && (mtex->tex->imaflag & TEX_NORMALMAP))) { + if (mtex->mapto & (MAP_NORM|MAP_WARP) && !((mtex->tex->type==TEX_IMAGE) && (mtex->tex->imaflag & TEX_NORMALMAP))) { MTFace* tf = RE_vlakren_get_tface(shi->obr, shi->vlr, i, NULL, 0); int j1 = shi->i1, j2 = shi->i2, j3 = shi->i3; vlr_set_uv_indices(shi->vlr, &j1, &j2, &j3); // compute ortho basis around normal - if(!compat_bump->nunvdone) { + if (!compat_bump->nunvdone) { // render normal is negated compat_bump->nn[0] = -shi->vn[0]; compat_bump->nn[1] = -shi->vn[1]; @@ -1763,7 +1768,7 @@ static int compatible_bump_compute(CompatibleBump *compat_bump, ShadeInput *shi, du = dv = 0.01f; // compute ortho basis around normal - if(!compat_bump->nunvdone) { + if (!compat_bump->nunvdone) { // render normal is negated negate_v3_v3(compat_bump->nn, shi->vn); ortho_basis_v3v3_v3(compat_bump->nu, compat_bump->nv, compat_bump->nn); @@ -1932,15 +1937,16 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T float *nvec = texres->nor; texres->nor = NULL; - if(found_deriv_map==0) { - if( mtex->texflag & MTEX_BUMP_TEXTURESPACE ) { - if(tex->ima) + if (found_deriv_map==0) { + if ( mtex->texflag & MTEX_BUMP_TEXTURESPACE ) { + if (tex->ima) Hscale *= 13.0f; // appears to be a sensible default value - } else + } + else Hscale *= 0.1f; // factor 0.1 proved to look like the previous bump code } - if( !ntap_bump->init_done ) { + if ( !ntap_bump->init_done ) { copy_v3_v3(ntap_bump->vNacc, shi->vn); copy_v3_v3(ntap_bump->vNorg, shi->vn); ntap_bump->fPrevMagnitude = 1.0f; @@ -1950,7 +1956,7 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T } // resolve image dimensions - if(found_deriv_map || (mtex->texflag&MTEX_BUMP_TEXTURESPACE)!=0) { + if (found_deriv_map || (mtex->texflag&MTEX_BUMP_TEXTURESPACE)!=0) { ImBuf* ibuf = BKE_image_get_ibuf(tex->ima, &tex->iuser); if (ibuf) { dimx = ibuf->x; @@ -1959,13 +1965,13 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T } } - if(found_deriv_map) { + if (found_deriv_map) { float dBdu, dBdv, auto_bump = 1.0f; float s = 1; // negate this if flipped texture coordinate texco_mapping(shi, tex, mtex, co, dx, dy, texvec, dxt, dyt); rgbnor = multitex_mtex(shi, mtex, texvec, dxt, dyt, texres); - if(shi->obr->ob->derivedFinal) { + if (shi->obr->ob->derivedFinal) { auto_bump = shi->obr->ob->derivedFinal->auto_bump_scale; } @@ -1982,14 +1988,14 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T dHdx = dBdu*dxt[0] + s * dBdv*dxt[1]; dHdy = dBdu*dyt[0] + s * dBdv*dyt[1]; } - else if(!(mtex->texflag & MTEX_5TAP_BUMP)) { + else if (!(mtex->texflag & MTEX_5TAP_BUMP)) { // compute height derivatives with respect to output image pixel coordinates x and y float STll[3], STlr[3], STul[3]; float Hll, Hlr, Hul; texco_mapping(shi, tex, mtex, co, dx, dy, texvec, dxt, dyt); - for(c=0; c<nr_channels; c++) { + for (c=0; c<nr_channels; c++) { // dx contains the derivatives (du/dx, dv/dx) // dy contains the derivatives (du/dy, dv/dy) STll[c] = texvec[c]; @@ -1998,7 +2004,7 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T } // clear unused derivatives - for(c=nr_channels; c<3; c++) { + for (c=nr_channels; c<3; c++) { STll[c] = 0.0f; STlr[c] = 0.0f; STul[c] = 0.0f; @@ -2025,7 +2031,7 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T texco_mapping(shi, tex, mtex, co, dx, dy, texvec, dxt, dyt); - for(c=0; c<nr_channels; c++) { + for (c=0; c<nr_channels; c++) { STc[c] = texvec[c]; STl[c] = texvec[c] - 0.5f*dxt[c]; STr[c] = texvec[c] + 0.5f*dxt[c]; @@ -2034,7 +2040,7 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T } // clear unused derivatives - for(c=nr_channels; c<3; c++) { + for (c=nr_channels; c<3; c++) { STc[c] = 0.0f; STl[c] = 0.0f; STr[c] = 0.0f; @@ -2067,14 +2073,14 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T * [Mik10] Mikkelsen M. S.: Bump Mapping Unparametrized Surfaces on the GPU. * -> http://jbit.net/~sparky/sfgrad_bump/mm_sfgrad_bump.pdf */ - if( mtex->texflag & MTEX_BUMP_OBJECTSPACE ) + if ( mtex->texflag & MTEX_BUMP_OBJECTSPACE ) iBumpSpace = 1; - else if( mtex->texflag & MTEX_BUMP_TEXTURESPACE ) + else if ( mtex->texflag & MTEX_BUMP_TEXTURESPACE ) iBumpSpace = 2; else iBumpSpace = 4; // ViewSpace - if( ntap_bump->iPrevBumpSpace != iBumpSpace ) { + if ( ntap_bump->iPrevBumpSpace != iBumpSpace ) { // initialize normal perturbation vectors int xyz; @@ -2087,7 +2093,7 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T copy_v3_v3(dPdy, shi->dyco); copy_v3_v3(vN, ntap_bump->vNorg); - if( mtex->texflag & MTEX_BUMP_OBJECTSPACE ) { + if ( mtex->texflag & MTEX_BUMP_OBJECTSPACE ) { // TODO: these calculations happen for every pixel! // -> move to shi->obi mult_m4_m4m4(tmp, R.viewmat, shi->obr->ob->obmat); @@ -2108,8 +2114,8 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T ntap_bump->sgn_det = (fDet < 0)? -1.0f: 1.0f; abs_fDet = ntap_bump->sgn_det * fDet; - if( mtex->texflag & MTEX_BUMP_TEXTURESPACE ) { - if(tex->ima) { + if ( mtex->texflag & MTEX_BUMP_TEXTURESPACE ) { + if (tex->ima) { // crazy hack solution that gives results similar to normal mapping - part 1 normalize_v3(ntap_bump->vR1); normalize_v3(ntap_bump->vR2); @@ -2118,7 +2124,7 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T } fMagnitude = abs_fDet; - if( mtex->texflag & MTEX_BUMP_OBJECTSPACE ) { + if ( mtex->texflag & MTEX_BUMP_OBJECTSPACE ) { // pre do transform of texres->nor by the inverse transposed of obj2view mul_transposed_m3_v3( view2obj, vN ); mul_transposed_m3_v3( view2obj, ntap_bump->vR1 ); @@ -2127,16 +2133,16 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T fMagnitude *= len_v3(vN); } - if(ntap_bump->fPrevMagnitude > 0.0f) - for(xyz=0; xyz<3; xyz++) + if (ntap_bump->fPrevMagnitude > 0.0f) + for (xyz=0; xyz<3; xyz++) ntap_bump->vNacc[xyz] *= fMagnitude / ntap_bump->fPrevMagnitude; ntap_bump->fPrevMagnitude = fMagnitude; ntap_bump->iPrevBumpSpace = iBumpSpace; } - if( mtex->texflag & MTEX_BUMP_TEXTURESPACE ) { - if(tex->ima) { + if ( mtex->texflag & MTEX_BUMP_TEXTURESPACE ) { + if (tex->ima) { // crazy hack solution that gives results similar to normal mapping - part 2 float vec[2]; const float imag_tspace_dimension_y = aspect*imag_tspace_dimension_x; @@ -2151,7 +2157,7 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T } // subtract the surface gradient from vNacc - for(c=0; c<3; c++) { + for (c=0; c<3; c++) { float vSurfGrad_compi = ntap_bump->sgn_det * (dHdx * ntap_bump->vR1[c] + dHdy * ntap_bump->vR2[c]); ntap_bump->vNacc[c] -= vSurfGrad_compi; texres->nor[c] = ntap_bump->vNacc[c]; // copy @@ -2182,42 +2188,42 @@ void do_material_tex(ShadeInput *shi, Render *re) if (re->r.scemode & R_NO_TEX) return; /* here: test flag if there's a tex (todo) */ - for(tex_nr=0; tex_nr<MAX_MTEX; tex_nr++) { + for (tex_nr=0; tex_nr<MAX_MTEX; tex_nr++) { /* separate tex switching */ - if(shi->mat->septex & (1<<tex_nr)) continue; + if (shi->mat->septex & (1<<tex_nr)) continue; - if(shi->mat->mtex[tex_nr]) { + if (shi->mat->mtex[tex_nr]) { mtex= shi->mat->mtex[tex_nr]; tex= mtex->tex; - if(tex==0) continue; + if (tex==0) continue; found_deriv_map = (tex->type==TEX_IMAGE) && (tex->imaflag & TEX_DERIVATIVEMAP); use_compat_bump= (mtex->texflag & MTEX_COMPAT_BUMP); use_ntap_bump= ((mtex->texflag & (MTEX_3TAP_BUMP|MTEX_5TAP_BUMP|MTEX_BICUBIC_BUMP))!=0 || found_deriv_map!=0) ? 1 : 0; /* XXX texture node trees don't work for this yet */ - if(tex->nodetree && tex->use_nodes) { + if (tex->nodetree && tex->use_nodes) { use_compat_bump = 0; use_ntap_bump = 0; } /* case displacement mapping */ - if(shi->osatex==0 && use_ntap_bump) { + if (shi->osatex==0 && use_ntap_bump) { use_ntap_bump = 0; use_compat_bump = 1; } /* case ocean */ - if(tex->type == TEX_OCEAN) { + if (tex->type == TEX_OCEAN) { use_ntap_bump = 0; use_compat_bump = 0; } /* which coords */ - if(mtex->texco==TEXCO_ORCO) { - if(mtex->texflag & MTEX_DUPLI_MAPTO) { + if (mtex->texco==TEXCO_ORCO) { + if (mtex->texflag & MTEX_DUPLI_MAPTO) { co= shi->duplilo; dx= dxt; dy= dyt; dxt[0]= dxt[1]= dxt[2]= 0.0f; dyt[0]= dyt[1]= dyt[2]= 0.0f; @@ -2226,21 +2232,21 @@ void do_material_tex(ShadeInput *shi, Render *re) co= shi->lo; dx= shi->dxlo; dy= shi->dylo; } } - else if(mtex->texco==TEXCO_STICKY) { + else if (mtex->texco==TEXCO_STICKY) { co= shi->sticky; dx= shi->dxsticky; dy= shi->dysticky; } - else if(mtex->texco==TEXCO_OBJECT) { + else if (mtex->texco==TEXCO_OBJECT) { Object *ob= mtex->object; - if(ob) { + if (ob) { co= tempvec; dx= dxt; dy= dyt; copy_v3_v3(tempvec, shi->co); - if(mtex->texflag & MTEX_OB_DUPLI_ORIG) - if(shi->obi && shi->obi->duplitexmat) + if (mtex->texflag & MTEX_OB_DUPLI_ORIG) + if (shi->obi && shi->obi->duplitexmat) mul_m4_v3(shi->obi->duplitexmat, tempvec); mul_m4_v3(ob->imat_ren, tempvec); - if(shi->osatex) { + if (shi->osatex) { copy_v3_v3(dxt, shi->dxco); copy_v3_v3(dyt, shi->dyco); mul_mat3_m4_v3(ob->imat_ren, dxt); @@ -2253,21 +2259,21 @@ void do_material_tex(ShadeInput *shi, Render *re) dx= shi->dxco; dy= shi->dyco; } } - else if(mtex->texco==TEXCO_REFL) { + else if (mtex->texco==TEXCO_REFL) { calc_R_ref(shi); co= shi->ref; dx= shi->dxref; dy= shi->dyref; } - else if(mtex->texco==TEXCO_NORM) { + else if (mtex->texco==TEXCO_NORM) { co= shi->orn; dx= shi->dxno; dy= shi->dyno; } - else if(mtex->texco==TEXCO_TANGENT) { + else if (mtex->texco==TEXCO_TANGENT) { co= shi->tang; dx= shi->dxno; dy= shi->dyno; } - else if(mtex->texco==TEXCO_GLOB) { + else if (mtex->texco==TEXCO_GLOB) { co= shi->gl; dx= shi->dxgl; dy= shi->dygl; } - else if(mtex->texco==TEXCO_UV) { - if(mtex->texflag & MTEX_DUPLI_MAPTO) { + else if (mtex->texco==TEXCO_UV) { + if (mtex->texflag & MTEX_DUPLI_MAPTO) { co= shi->dupliuv; dx= dxt; dy= dyt; dxt[0]= dxt[1]= dxt[2]= 0.0f; dyt[0]= dyt[1]= dyt[2]= 0.0f; @@ -2276,9 +2282,9 @@ void do_material_tex(ShadeInput *shi, Render *re) ShadeInputUV *suv= &shi->uv[shi->actuv]; int i = shi->actuv; - if(mtex->uvname[0] != 0) { - for(i = 0; i < shi->totuv; i++) { - if(strcmp(shi->uv[i].name, mtex->uvname)==0) { + if (mtex->uvname[0] != 0) { + for (i = 0; i < shi->totuv; i++) { + if (strcmp(shi->uv[i].name, mtex->uvname)==0) { suv= &shi->uv[i]; break; } @@ -2292,10 +2298,10 @@ void do_material_tex(ShadeInput *shi, Render *re) compatible_bump_uv_derivs(&compat_bump, shi, mtex, i); } } - else if(mtex->texco==TEXCO_WINDOW) { + else if (mtex->texco==TEXCO_WINDOW) { co= shi->winco; dx= shi->dxwin; dy= shi->dywin; } - else if(mtex->texco==TEXCO_STRAND) { + else if (mtex->texco==TEXCO_STRAND) { co= tempvec; dx= dxt; dy= dyt; co[0]= shi->strandco; co[1]= co[2]= 0.0f; @@ -2304,7 +2310,7 @@ void do_material_tex(ShadeInput *shi, Render *re) dy[0]= shi->dystrand; dy[1]= dy[2]= 0.0f; } - else if(mtex->texco==TEXCO_STRESS) { + else if (mtex->texco==TEXCO_STRESS) { co= tempvec; dx= dxt; dy= dyt; co[0]= shi->stress; co[1]= co[2]= 0.0f; @@ -2316,24 +2322,24 @@ void do_material_tex(ShadeInput *shi, Render *re) else continue; // can happen when texco defines disappear and it renders old files /* the pointer defines if bumping happens */ - if(mtex->mapto & (MAP_NORM|MAP_WARP)) { + if (mtex->mapto & (MAP_NORM|MAP_WARP)) { texres.nor= norvec; norvec[0]= norvec[1]= norvec[2]= 0.0; } else texres.nor= NULL; - if(warpdone) { + if (warpdone) { add_v3_v3v3(tempvec, co, warpvec); co= tempvec; } /* XXX texture node trees don't work for this yet */ - if(texres.nor && !((tex->type==TEX_IMAGE) && (tex->imaflag & TEX_NORMALMAP))) { - if(use_compat_bump) { + if (texres.nor && !((tex->type==TEX_IMAGE) && (tex->imaflag & TEX_NORMALMAP))) { + if (use_compat_bump) { rgbnor = compatible_bump_compute(&compat_bump, shi, mtex, tex, &texres, Tnor*stencilTin, co, dx, dy, texvec, dxt, dyt); } - else if(use_ntap_bump) { + else if (use_ntap_bump) { rgbnor = ntap_bump_compute(&ntap_bump, shi, mtex, tex, &texres, Tnor*stencilTin, co, dx, dy, texvec, dxt, dyt); } @@ -2349,20 +2355,20 @@ void do_material_tex(ShadeInput *shi, Render *re) /* texture output */ - if( (rgbnor & TEX_RGB) && (mtex->texflag & MTEX_RGBTOINT)) { + if ( (rgbnor & TEX_RGB) && (mtex->texflag & MTEX_RGBTOINT)) { texres.tin= (0.35f*texres.tr+0.45f*texres.tg+0.2f*texres.tb); rgbnor-= TEX_RGB; } - if(mtex->texflag & MTEX_NEGATIVE) { - if(rgbnor & TEX_RGB) { + if (mtex->texflag & MTEX_NEGATIVE) { + if (rgbnor & TEX_RGB) { texres.tr= 1.0f-texres.tr; texres.tg= 1.0f-texres.tg; texres.tb= 1.0f-texres.tb; } texres.tin= 1.0f-texres.tin; } - if(mtex->texflag & MTEX_STENCIL) { - if(rgbnor & TEX_RGB) { + if (mtex->texflag & MTEX_STENCIL) { + if (rgbnor & TEX_RGB) { fact= texres.ta; texres.ta*= stencilTin; stencilTin*= fact; @@ -2377,10 +2383,10 @@ void do_material_tex(ShadeInput *shi, Render *re) Tnor*= stencilTin; } - if(texres.nor) { - if((rgbnor & TEX_NOR)==0) { + if (texres.nor) { + if ((rgbnor & TEX_NOR)==0) { /* make our own normal */ - if(rgbnor & TEX_RGB) { + if (rgbnor & TEX_RGB) { texres.nor[0]= texres.tr; texres.nor[1]= texres.tg; texres.nor[2]= texres.tb; @@ -2400,10 +2406,10 @@ void do_material_tex(ShadeInput *shi, Render *re) } } // warping, local space - if(mtex->mapto & MAP_WARP) { + if (mtex->mapto & MAP_WARP) { float *warpnor= texres.nor, warpnor_[3]; - if(use_ntap_bump) { + if (use_ntap_bump) { copy_v3_v3(warpnor_, texres.nor); warpnor= warpnor_; normalize_v3(warpnor_); @@ -2414,10 +2420,10 @@ void do_material_tex(ShadeInput *shi, Render *re) warpdone= 1; } #if 0 - if(mtex->texflag & MTEX_VIEWSPACE) { + if (mtex->texflag & MTEX_VIEWSPACE) { // rotate to global coords - if(mtex->texco==TEXCO_ORCO || mtex->texco==TEXCO_UV) { - if(shi->vlr && shi->obr && shi->obr->ob) { + if (mtex->texco==TEXCO_ORCO || mtex->texco==TEXCO_UV) { + if (shi->vlr && shi->obr && shi->obr->ob) { float len= normalize_v3(texres.nor); // can be optimized... (ton) mul_mat3_m4_v3(shi->obr->ob->obmat, texres.nor); @@ -2431,19 +2437,19 @@ void do_material_tex(ShadeInput *shi, Render *re) } /* mapping */ - if(mtex->mapto & (MAP_COL+MAP_COLSPEC+MAP_COLMIR)) { + if (mtex->mapto & (MAP_COL+MAP_COLSPEC+MAP_COLMIR)) { float tcol[3]; /* stencil maps on the texture control slider, not texture intensity value */ tcol[0]=texres.tr; tcol[1]=texres.tg; tcol[2]=texres.tb; - if((rgbnor & TEX_RGB)==0) { + if ((rgbnor & TEX_RGB)==0) { tcol[0]= mtex->r; tcol[1]= mtex->g; tcol[2]= mtex->b; } - else if(mtex->mapto & MAP_ALPHA) { + else if (mtex->mapto & MAP_ALPHA) { texres.tin= stencilTin; } else texres.tin= texres.ta; @@ -2458,19 +2464,19 @@ void do_material_tex(ShadeInput *shi, Render *re) srgb_to_linearrgb_v3_v3(tcol, tcol); } - if(mtex->mapto & MAP_COL) { + if (mtex->mapto & MAP_COL) { float colfac= mtex->colfac*stencilTin; texture_rgb_blend(&shi->r, tcol, &shi->r, texres.tin, colfac, mtex->blendtype); } - if(mtex->mapto & MAP_COLSPEC) { + if (mtex->mapto & MAP_COLSPEC) { float colspecfac= mtex->colspecfac*stencilTin; texture_rgb_blend(&shi->specr, tcol, &shi->specr, texres.tin, colspecfac, mtex->blendtype); } - if(mtex->mapto & MAP_COLMIR) { + if (mtex->mapto & MAP_COLMIR) { float mirrfac= mtex->mirrfac*stencilTin; // exception for envmap only - if(tex->type==TEX_ENVMAP && mtex->blendtype==MTEX_BLEND) { + if (tex->type==TEX_ENVMAP && mtex->blendtype==MTEX_BLEND) { fact= texres.tin*mirrfac; facm= 1.0f- fact; shi->refcol[0]= fact + facm*shi->refcol[0]; @@ -2483,8 +2489,8 @@ void do_material_tex(ShadeInput *shi, Render *re) } } } - if( (mtex->mapto & MAP_NORM) ) { - if(texres.nor) { + if ( (mtex->mapto & MAP_NORM) ) { + if (texres.nor) { float norfac= mtex->norfac; /* we need to code blending modes for normals too once.. now 1 exception hardcoded */ @@ -2502,7 +2508,7 @@ void do_material_tex(ShadeInput *shi, Render *re) fact = Tnor*fabsf(norfac); if (fact>1.f) fact = 1.f; facm = 1.f-fact; - if(mtex->normapspace == MTEX_NSPACE_TANGENT) { + if (mtex->normapspace == MTEX_NSPACE_TANGENT) { /* qdn: tangent space */ float B[3], tv[3]; const float * no = iFirstTimeNMap!=0 ? shi->nmapnorm : shi->vn; @@ -2522,12 +2528,12 @@ void do_material_tex(ShadeInput *shi, Render *re) copy_v3_v3(nor, texres.nor); - if(mtex->normapspace == MTEX_NSPACE_CAMERA); - else if(mtex->normapspace == MTEX_NSPACE_WORLD) { + if (mtex->normapspace == MTEX_NSPACE_CAMERA); + else if (mtex->normapspace == MTEX_NSPACE_WORLD) { mul_mat3_m4_v3(re->viewmat, nor); } - else if(mtex->normapspace == MTEX_NSPACE_OBJECT) { - if(shi->obr && shi->obr->ob) + else if (mtex->normapspace == MTEX_NSPACE_OBJECT) { + if (shi->obr && shi->obr->ob) mul_mat3_m4_v3(shi->obr->ob->obmat, nor); mul_mat3_m4_v3(re->viewmat, nor); } @@ -2550,7 +2556,7 @@ void do_material_tex(ShadeInput *shi, Render *re) else { float nor[3], dot; - if(shi->mat->mode & MA_TANGENT_V) { + if (shi->mat->mode & MA_TANGENT_V) { shi->tang[0]+= Tnor*norfac*texres.nor[0]; shi->tang[1]+= Tnor*norfac*texres.nor[1]; shi->tang[2]+= Tnor*norfac*texres.nor[2]; @@ -2577,10 +2583,10 @@ void do_material_tex(ShadeInput *shi, Render *re) } } - if( mtex->mapto & MAP_DISPLACE ) { + if ( mtex->mapto & MAP_DISPLACE ) { /* Now that most textures offer both Nor and Intensity, allow */ /* both to work, and let user select with slider. */ - if(texres.nor) { + if (texres.nor) { float norfac= mtex->norfac; shi->displace[0]+= 0.2f*Tnor*norfac*texres.nor[0]; @@ -2588,94 +2594,94 @@ void do_material_tex(ShadeInput *shi, Render *re) shi->displace[2]+= 0.2f*Tnor*norfac*texres.nor[2]; } - if(rgbnor & TEX_RGB) { + if (rgbnor & TEX_RGB) { texres.tin= (0.35f*texres.tr+0.45f*texres.tg+0.2f*texres.tb); } factt= (0.5f-texres.tin)*mtex->dispfac*stencilTin; facmm= 1.0f-factt; - if(mtex->blendtype==MTEX_BLEND) { + if (mtex->blendtype==MTEX_BLEND) { shi->displace[0]= factt*shi->vn[0] + facmm*shi->displace[0]; shi->displace[1]= factt*shi->vn[1] + facmm*shi->displace[1]; shi->displace[2]= factt*shi->vn[2] + facmm*shi->displace[2]; } - else if(mtex->blendtype==MTEX_MUL) { + else if (mtex->blendtype==MTEX_MUL) { shi->displace[0]*= factt*shi->vn[0]; shi->displace[1]*= factt*shi->vn[1]; shi->displace[2]*= factt*shi->vn[2]; } else { /* add or sub */ - if(mtex->blendtype==MTEX_SUB) factt= -factt; + if (mtex->blendtype==MTEX_SUB) factt= -factt; shi->displace[0]+= factt*shi->vn[0]; shi->displace[1]+= factt*shi->vn[1]; shi->displace[2]+= factt*shi->vn[2]; } } - if(mtex->mapto & MAP_VARS) { + if (mtex->mapto & MAP_VARS) { /* stencil maps on the texture control slider, not texture intensity value */ - if(rgbnor & TEX_RGB) { - if(texres.talpha) texres.tin= texres.ta; + if (rgbnor & TEX_RGB) { + if (texres.talpha) texres.tin= texres.ta; else texres.tin= (0.35f*texres.tr+0.45f*texres.tg+0.2f*texres.tb); } - if(mtex->mapto & MAP_REF) { + if (mtex->mapto & MAP_REF) { float difffac= mtex->difffac*stencilTin; shi->refl= texture_value_blend(mtex->def_var, shi->refl, texres.tin, difffac, mtex->blendtype); - if(shi->refl<0.0f) shi->refl= 0.0f; + if (shi->refl<0.0f) shi->refl= 0.0f; } - if(mtex->mapto & MAP_SPEC) { + if (mtex->mapto & MAP_SPEC) { float specfac= mtex->specfac*stencilTin; shi->spec= texture_value_blend(mtex->def_var, shi->spec, texres.tin, specfac, mtex->blendtype); - if(shi->spec<0.0f) shi->spec= 0.0f; + if (shi->spec<0.0f) shi->spec= 0.0f; } - if(mtex->mapto & MAP_EMIT) { + if (mtex->mapto & MAP_EMIT) { float emitfac= mtex->emitfac*stencilTin; shi->emit= texture_value_blend(mtex->def_var, shi->emit, texres.tin, emitfac, mtex->blendtype); - if(shi->emit<0.0f) shi->emit= 0.0f; + if (shi->emit<0.0f) shi->emit= 0.0f; } - if(mtex->mapto & MAP_ALPHA) { + if (mtex->mapto & MAP_ALPHA) { float alphafac= mtex->alphafac*stencilTin; shi->alpha= texture_value_blend(mtex->def_var, shi->alpha, texres.tin, alphafac, mtex->blendtype); - if(shi->alpha<0.0f) shi->alpha= 0.0f; - else if(shi->alpha>1.0f) shi->alpha= 1.0f; + if (shi->alpha<0.0f) shi->alpha= 0.0f; + else if (shi->alpha>1.0f) shi->alpha= 1.0f; } - if(mtex->mapto & MAP_HAR) { + if (mtex->mapto & MAP_HAR) { float har; // have to map to 0-1 float hardfac= mtex->hardfac*stencilTin; har= ((float)shi->har)/128.0f; har= 128.0f*texture_value_blend(mtex->def_var, har, texres.tin, hardfac, mtex->blendtype); - if(har<1.0f) shi->har= 1; - else if(har>511) shi->har= 511; + if (har<1.0f) shi->har= 1; + else if (har>511) shi->har= 511; else shi->har= (int)har; } - if(mtex->mapto & MAP_RAYMIRR) { + if (mtex->mapto & MAP_RAYMIRR) { float raymirrfac= mtex->raymirrfac*stencilTin; shi->ray_mirror= texture_value_blend(mtex->def_var, shi->ray_mirror, texres.tin, raymirrfac, mtex->blendtype); - if(shi->ray_mirror<0.0f) shi->ray_mirror= 0.0f; - else if(shi->ray_mirror>1.0f) shi->ray_mirror= 1.0f; + if (shi->ray_mirror<0.0f) shi->ray_mirror= 0.0f; + else if (shi->ray_mirror>1.0f) shi->ray_mirror= 1.0f; } - if(mtex->mapto & MAP_TRANSLU) { + if (mtex->mapto & MAP_TRANSLU) { float translfac= mtex->translfac*stencilTin; shi->translucency= texture_value_blend(mtex->def_var, shi->translucency, texres.tin, translfac, mtex->blendtype); - if(shi->translucency<0.0f) shi->translucency= 0.0f; - else if(shi->translucency>1.0f) shi->translucency= 1.0f; + if (shi->translucency<0.0f) shi->translucency= 0.0f; + else if (shi->translucency>1.0f) shi->translucency= 1.0f; } - if(mtex->mapto & MAP_AMB) { + if (mtex->mapto & MAP_AMB) { float ambfac= mtex->ambfac*stencilTin; shi->amb= texture_value_blend(mtex->def_var, shi->amb, texres.tin, ambfac, mtex->blendtype); - if(shi->amb<0.0f) shi->amb= 0.0f; - else if(shi->amb>1.0f) shi->amb= 1.0f; + if (shi->amb<0.0f) shi->amb= 0.0f; + else if (shi->amb>1.0f) shi->amb= 1.0f; shi->ambr= shi->amb*re->wrld.ambr; shi->ambg= shi->amb*re->wrld.ambg; @@ -2705,35 +2711,35 @@ void do_volume_tex(ShadeInput *shi, const float *xyz, int mapto_flag, float *col if (re->r.scemode & R_NO_TEX) return; /* here: test flag if there's a tex (todo) */ - for(tex_nr=0; tex_nr<MAX_MTEX; tex_nr++) { + for (tex_nr=0; tex_nr<MAX_MTEX; tex_nr++) { /* separate tex switching */ - if(shi->mat->septex & (1<<tex_nr)) continue; + if (shi->mat->septex & (1<<tex_nr)) continue; - if(shi->mat->mtex[tex_nr]) { + if (shi->mat->mtex[tex_nr]) { mtex= shi->mat->mtex[tex_nr]; tex= mtex->tex; - if(tex==0) continue; + if (tex==0) continue; /* only process if this texture is mapped * to one that we're interested in */ if (!(mtex->mapto & mapto_flag)) continue; /* which coords */ - if(mtex->texco==TEXCO_OBJECT) { + if (mtex->texco==TEXCO_OBJECT) { Object *ob= mtex->object; - if(ob) { + if (ob) { copy_v3_v3(co, xyz); - if(mtex->texflag & MTEX_OB_DUPLI_ORIG) { - if(shi->obi && shi->obi->duplitexmat) + if (mtex->texflag & MTEX_OB_DUPLI_ORIG) { + if (shi->obi && shi->obi->duplitexmat) mul_m4_v3(shi->obi->duplitexmat, co); } mul_m4_v3(ob->imat_ren, co); } } /* not really orco, but 'local' */ - else if(mtex->texco==TEXCO_ORCO) { + else if (mtex->texco==TEXCO_ORCO) { - if(mtex->texflag & MTEX_DUPLI_MAPTO) { + if (mtex->texflag & MTEX_DUPLI_MAPTO) { copy_v3_v3(co, shi->duplilo); } else { @@ -2742,7 +2748,7 @@ void do_volume_tex(ShadeInput *shi, const float *xyz, int mapto_flag, float *col mul_m4_v3(ob->imat_ren, co); } } - else if(mtex->texco==TEXCO_GLOB) { + else if (mtex->texco==TEXCO_GLOB) { copy_v3_v3(co, xyz); mul_m4_v3(re->viewinv, co); } @@ -2750,19 +2756,19 @@ void do_volume_tex(ShadeInput *shi, const float *xyz, int mapto_flag, float *col texres.nor= NULL; - if(tex->type==TEX_IMAGE) { + if (tex->type==TEX_IMAGE) { continue; /* not supported yet */ //do_2d_mapping(mtex, texvec, NULL, NULL, dxt, dyt); } else { /* placement */ - if(mtex->projx) texvec[0]= mtex->size[0]*(co[mtex->projx-1]+mtex->ofs[0]); + if (mtex->projx) texvec[0]= mtex->size[0]*(co[mtex->projx-1]+mtex->ofs[0]); else texvec[0]= mtex->size[0]*(mtex->ofs[0]); - if(mtex->projy) texvec[1]= mtex->size[1]*(co[mtex->projy-1]+mtex->ofs[1]); + if (mtex->projy) texvec[1]= mtex->size[1]*(co[mtex->projy-1]+mtex->ofs[1]); else texvec[1]= mtex->size[1]*(mtex->ofs[1]); - if(mtex->projz) texvec[2]= mtex->size[2]*(co[mtex->projz-1]+mtex->ofs[2]); + if (mtex->projz) texvec[2]= mtex->size[2]*(co[mtex->projz-1]+mtex->ofs[2]); else texvec[2]= mtex->size[2]*(mtex->ofs[2]); } @@ -2770,20 +2776,20 @@ void do_volume_tex(ShadeInput *shi, const float *xyz, int mapto_flag, float *col /* texture output */ - if( (rgbnor & TEX_RGB) && (mtex->texflag & MTEX_RGBTOINT)) { + if ( (rgbnor & TEX_RGB) && (mtex->texflag & MTEX_RGBTOINT)) { texres.tin= (0.35f*texres.tr+0.45f*texres.tg+0.2f*texres.tb); rgbnor-= TEX_RGB; } - if(mtex->texflag & MTEX_NEGATIVE) { - if(rgbnor & TEX_RGB) { + if (mtex->texflag & MTEX_NEGATIVE) { + if (rgbnor & TEX_RGB) { texres.tr= 1.0f-texres.tr; texres.tg= 1.0f-texres.tg; texres.tb= 1.0f-texres.tb; } texres.tin= 1.0f-texres.tin; } - if(mtex->texflag & MTEX_STENCIL) { - if(rgbnor & TEX_RGB) { + if (mtex->texflag & MTEX_STENCIL) { + if (rgbnor & TEX_RGB) { fact= texres.ta; texres.ta*= stencilTin; stencilTin*= fact; @@ -2796,70 +2802,71 @@ void do_volume_tex(ShadeInput *shi, const float *xyz, int mapto_flag, float *col } - if((mapto_flag & (MAP_EMISSION_COL+MAP_TRANSMISSION_COL+MAP_REFLECTION_COL)) && (mtex->mapto & (MAP_EMISSION_COL+MAP_TRANSMISSION_COL+MAP_REFLECTION_COL))) { + if ((mapto_flag & (MAP_EMISSION_COL+MAP_TRANSMISSION_COL+MAP_REFLECTION_COL)) && (mtex->mapto & (MAP_EMISSION_COL+MAP_TRANSMISSION_COL+MAP_REFLECTION_COL))) { float tcol[3]; /* stencil maps on the texture control slider, not texture intensity value */ - if((rgbnor & TEX_RGB)==0) { + if ((rgbnor & TEX_RGB)==0) { tcol[0]= mtex->r; tcol[1]= mtex->g; tcol[2]= mtex->b; - } else { + } + else { tcol[0]=texres.tr; tcol[1]=texres.tg; tcol[2]=texres.tb; - if(texres.talpha) + if (texres.talpha) texres.tin= texres.ta; } /* used for emit */ - if((mapto_flag & MAP_EMISSION_COL) && (mtex->mapto & MAP_EMISSION_COL)) { + if ((mapto_flag & MAP_EMISSION_COL) && (mtex->mapto & MAP_EMISSION_COL)) { float colemitfac= mtex->colemitfac*stencilTin; texture_rgb_blend(col, tcol, col, texres.tin, colemitfac, mtex->blendtype); } - if((mapto_flag & MAP_REFLECTION_COL) && (mtex->mapto & MAP_REFLECTION_COL)) { + if ((mapto_flag & MAP_REFLECTION_COL) && (mtex->mapto & MAP_REFLECTION_COL)) { float colreflfac= mtex->colreflfac*stencilTin; texture_rgb_blend(col, tcol, col, texres.tin, colreflfac, mtex->blendtype); } - if((mapto_flag & MAP_TRANSMISSION_COL) && (mtex->mapto & MAP_TRANSMISSION_COL)) { + if ((mapto_flag & MAP_TRANSMISSION_COL) && (mtex->mapto & MAP_TRANSMISSION_COL)) { float coltransfac= mtex->coltransfac*stencilTin; texture_rgb_blend(col, tcol, col, texres.tin, coltransfac, mtex->blendtype); } } - if((mapto_flag & MAP_VARS) && (mtex->mapto & MAP_VARS)) { + if ((mapto_flag & MAP_VARS) && (mtex->mapto & MAP_VARS)) { /* stencil maps on the texture control slider, not texture intensity value */ /* convert RGB to intensity if intensity info isn't provided */ if (!(rgbnor & TEX_INT)) { if (rgbnor & TEX_RGB) { - if(texres.talpha) texres.tin= texres.ta; + if (texres.talpha) texres.tin= texres.ta; else texres.tin= (0.35f*texres.tr+0.45f*texres.tg+0.2f*texres.tb); } } - if((mapto_flag & MAP_EMISSION) && (mtex->mapto & MAP_EMISSION)) { + if ((mapto_flag & MAP_EMISSION) && (mtex->mapto & MAP_EMISSION)) { float emitfac= mtex->emitfac*stencilTin; *val = texture_value_blend(mtex->def_var, *val, texres.tin, emitfac, mtex->blendtype); - if(*val<0.0f) *val= 0.0f; + if (*val<0.0f) *val= 0.0f; } - if((mapto_flag & MAP_DENSITY) && (mtex->mapto & MAP_DENSITY)) { + if ((mapto_flag & MAP_DENSITY) && (mtex->mapto & MAP_DENSITY)) { float densfac= mtex->densfac*stencilTin; *val = texture_value_blend(mtex->def_var, *val, texres.tin, densfac, mtex->blendtype); CLAMP(*val, 0.0f, 1.0f); } - if((mapto_flag & MAP_SCATTERING) && (mtex->mapto & MAP_SCATTERING)) { + if ((mapto_flag & MAP_SCATTERING) && (mtex->mapto & MAP_SCATTERING)) { float scatterfac= mtex->scatterfac*stencilTin; *val = texture_value_blend(mtex->def_var, *val, texres.tin, scatterfac, mtex->blendtype); CLAMP(*val, 0.0f, 1.0f); } - if((mapto_flag & MAP_REFLECTION) && (mtex->mapto & MAP_REFLECTION)) { + if ((mapto_flag & MAP_REFLECTION) && (mtex->mapto & MAP_REFLECTION)) { float reflfac= mtex->reflfac*stencilTin; *val = texture_value_blend(mtex->def_var, *val, texres.tin, reflfac, mtex->blendtype); @@ -2883,8 +2890,8 @@ void do_halo_tex(HaloRen *har, float xn, float yn, float col_r[4]) if (R.r.scemode & R_NO_TEX) return; mtex= har->mat->mtex[0]; - if(har->mat->septex & (1<<0)) return; - if(mtex->tex==NULL) return; + if (har->mat->septex & (1<<0)) return; + if (mtex->tex==NULL) return; /* no normal mapping */ texres.nor= NULL; @@ -2896,32 +2903,32 @@ void do_halo_tex(HaloRen *har, float xn, float yn, float col_r[4]) osatex= (har->mat->texco & TEXCO_OSA); /* placement */ - if(mtex->projx) texvec[0]= mtex->size[0]*(texvec[mtex->projx-1]+mtex->ofs[0]); + if (mtex->projx) texvec[0]= mtex->size[0]*(texvec[mtex->projx-1]+mtex->ofs[0]); else texvec[0]= mtex->size[0]*(mtex->ofs[0]); - if(mtex->projy) texvec[1]= mtex->size[1]*(texvec[mtex->projy-1]+mtex->ofs[1]); + if (mtex->projy) texvec[1]= mtex->size[1]*(texvec[mtex->projy-1]+mtex->ofs[1]); else texvec[1]= mtex->size[1]*(mtex->ofs[1]); - if(mtex->projz) texvec[2]= mtex->size[2]*(texvec[mtex->projz-1]+mtex->ofs[2]); + if (mtex->projz) texvec[2]= mtex->size[2]*(texvec[mtex->projz-1]+mtex->ofs[2]); else texvec[2]= mtex->size[2]*(mtex->ofs[2]); - if(osatex) { + if (osatex) { dx= 1.0f/har->rad; - if(mtex->projx) { + if (mtex->projx) { dxt[0]= mtex->size[0]*dx; dyt[0]= mtex->size[0]*dx; } else dxt[0]= dyt[0]= 0.0; - if(mtex->projy) { + if (mtex->projy) { dxt[1]= mtex->size[1]*dx; dyt[1]= mtex->size[1]*dx; } else dxt[1]= dyt[1]= 0.0; - if(mtex->projz) { + if (mtex->projz) { dxt[2]= 0.0; dyt[2]= 0.0; } @@ -2929,17 +2936,17 @@ void do_halo_tex(HaloRen *har, float xn, float yn, float col_r[4]) } - if(mtex->tex->type==TEX_IMAGE) do_2d_mapping(mtex, texvec, NULL, NULL, dxt, dyt); + if (mtex->tex->type==TEX_IMAGE) do_2d_mapping(mtex, texvec, NULL, NULL, dxt, dyt); rgb= multitex(mtex->tex, texvec, dxt, dyt, osatex, &texres, 0, mtex->which_output); /* texture output */ - if(rgb && (mtex->texflag & MTEX_RGBTOINT)) { + if (rgb && (mtex->texflag & MTEX_RGBTOINT)) { texres.tin= (0.35f*texres.tr+0.45f*texres.tg+0.2f*texres.tb); rgb= 0; } - if(mtex->texflag & MTEX_NEGATIVE) { - if(rgb) { + if (mtex->texflag & MTEX_NEGATIVE) { + if (rgb) { texres.tr= 1.0f-texres.tr; texres.tg= 1.0f-texres.tg; texres.tb= 1.0f-texres.tb; @@ -2948,14 +2955,14 @@ void do_halo_tex(HaloRen *har, float xn, float yn, float col_r[4]) } /* mapping */ - if(mtex->mapto & MAP_COL) { + if (mtex->mapto & MAP_COL) { - if(rgb==0) { + if (rgb==0) { texres.tr= mtex->r; texres.tg= mtex->g; texres.tb= mtex->b; } - else if(mtex->mapto & MAP_ALPHA) { + else if (mtex->mapto & MAP_ALPHA) { texres.tin= 1.0; } else texres.tin= texres.ta; @@ -2973,18 +2980,18 @@ void do_halo_tex(HaloRen *har, float xn, float yn, float col_r[4]) fact= texres.tin*mtex->colfac; facm= 1.0f-fact; - if(mtex->blendtype==MTEX_MUL) { + if (mtex->blendtype==MTEX_MUL) { facm= 1.0f-mtex->colfac; } - if(mtex->blendtype==MTEX_SUB) fact= -fact; + if (mtex->blendtype==MTEX_SUB) fact= -fact; - if(mtex->blendtype==MTEX_BLEND) { + if (mtex->blendtype==MTEX_BLEND) { col_r[0]= (fact*texres.tr + facm*har->r); col_r[1]= (fact*texres.tg + facm*har->g); col_r[2]= (fact*texres.tb + facm*har->b); } - else if(mtex->blendtype==MTEX_MUL) { + else if (mtex->blendtype==MTEX_MUL) { col_r[0]= (facm+fact*texres.tr)*har->r; col_r[1]= (facm+fact*texres.tg)*har->g; col_r[2]= (facm+fact*texres.tb)*har->b; @@ -2999,9 +3006,9 @@ void do_halo_tex(HaloRen *har, float xn, float yn, float col_r[4]) CLAMP(col_r[2], 0.0f, 1.0f); } } - if(mtex->mapto & MAP_ALPHA) { - if(rgb) { - if(texres.talpha) texres.tin= texres.ta; + if (mtex->mapto & MAP_ALPHA) { + if (rgb) { + if (texres.talpha) texres.tin= texres.ta; else texres.tin= (0.35f*texres.tr+0.45f*texres.tg+0.2f*texres.tb); } @@ -3025,19 +3032,19 @@ void do_sky_tex(const float rco[3], float lo[3], const float dxyview[2], float h /* todo: add flag to test if there's a tex */ texres.nor= NULL; - for(tex_nr=0; tex_nr<MAX_MTEX; tex_nr++) { - if(R.wrld.mtex[tex_nr]) { + for (tex_nr=0; tex_nr<MAX_MTEX; tex_nr++) { + if (R.wrld.mtex[tex_nr]) { mtex= R.wrld.mtex[tex_nr]; tex= mtex->tex; - if(tex==0) continue; + if (tex==0) continue; /* if(mtex->mapto==0) continue; */ /* which coords */ co= lo; /* dxt dyt just from 1 value */ - if(dxyview) { + if (dxyview) { dxt[0]= dxt[1]= dxt[2]= dxyview[0]; dyt[0]= dyt[1]= dyt[2]= dxyview[1]; } @@ -3051,7 +3058,7 @@ void do_sky_tex(const float rco[3], float lo[3], const float dxyview[2], float h case TEXCO_ANGMAP: /* only works with texture being "real" */ /* use saacos(), fixes bug [#22398], float precision caused lo[2] to be slightly less then -1.0 */ - if(lo[0] || lo[1]) { /* check for zero case [#24807] */ + if (lo[0] || lo[1]) { /* check for zero case [#24807] */ fact= (1.0f/(float)M_PI)*saacos(lo[2])/(sqrtf(lo[0]*lo[0] + lo[1]*lo[1])); tempvec[0]= lo[0]*fact; tempvec[1]= lo[1]*fact; @@ -3069,8 +3076,8 @@ void do_sky_tex(const float rco[3], float lo[3], const float dxyview[2], float h case TEXCO_H_SPHEREMAP: case TEXCO_H_TUBEMAP: - if(skyflag & WO_ZENUP) { - if(mtex->texco==TEXCO_H_TUBEMAP) map_to_tube( tempvec, tempvec+1,lo[0], lo[2], lo[1]); + if (skyflag & WO_ZENUP) { + if (mtex->texco==TEXCO_H_TUBEMAP) map_to_tube( tempvec, tempvec+1,lo[0], lo[2], lo[1]); else map_to_sphere( tempvec, tempvec+1,lo[0], lo[2], lo[1]); /* tube/spheremap maps for outside view, not inside */ tempvec[0]= 1.0f-tempvec[0]; @@ -3094,7 +3101,7 @@ void do_sky_tex(const float rco[3], float lo[3], const float dxyview[2], float h co= tempvec; break; case TEXCO_OBJECT: - if(mtex->object) { + if (mtex->object) { copy_v3_v3(tempvec, lo); mul_m4_v3(mtex->object->imat_ren, tempvec); co= tempvec; @@ -3102,7 +3109,7 @@ void do_sky_tex(const float rco[3], float lo[3], const float dxyview[2], float h break; case TEXCO_GLOB: - if(rco) { + if (rco) { copy_v3_v3(tempvec, rco); mul_m4_v3(R.viewinv, tempvec); co= tempvec; @@ -3118,35 +3125,35 @@ void do_sky_tex(const float rco[3], float lo[3], const float dxyview[2], float h } /* placement */ - if(mtex->projx) texvec[0]= mtex->size[0]*(co[mtex->projx-1]+mtex->ofs[0]); + if (mtex->projx) texvec[0]= mtex->size[0]*(co[mtex->projx-1]+mtex->ofs[0]); else texvec[0]= mtex->size[0]*(mtex->ofs[0]); - if(mtex->projy) texvec[1]= mtex->size[1]*(co[mtex->projy-1]+mtex->ofs[1]); + if (mtex->projy) texvec[1]= mtex->size[1]*(co[mtex->projy-1]+mtex->ofs[1]); else texvec[1]= mtex->size[1]*(mtex->ofs[1]); - if(mtex->projz) texvec[2]= mtex->size[2]*(co[mtex->projz-1]+mtex->ofs[2]); + if (mtex->projz) texvec[2]= mtex->size[2]*(co[mtex->projz-1]+mtex->ofs[2]); else texvec[2]= mtex->size[2]*(mtex->ofs[2]); /* texture */ - if(tex->type==TEX_IMAGE) do_2d_mapping(mtex, texvec, NULL, NULL, dxt, dyt); + if (tex->type==TEX_IMAGE) do_2d_mapping(mtex, texvec, NULL, NULL, dxt, dyt); rgb= multitex(mtex->tex, texvec, dxt, dyt, R.osa, &texres, thread, mtex->which_output); /* texture output */ - if(rgb && (mtex->texflag & MTEX_RGBTOINT)) { + if (rgb && (mtex->texflag & MTEX_RGBTOINT)) { texres.tin= (0.35f*texres.tr+0.45f*texres.tg+0.2f*texres.tb); rgb= 0; } - if(mtex->texflag & MTEX_NEGATIVE) { - if(rgb) { + if (mtex->texflag & MTEX_NEGATIVE) { + if (rgb) { texres.tr= 1.0f-texres.tr; texres.tg= 1.0f-texres.tg; texres.tb= 1.0f-texres.tb; } else texres.tin= 1.0f-texres.tin; } - if(mtex->texflag & MTEX_STENCIL) { - if(rgb) { + if (mtex->texflag & MTEX_STENCIL) { + if (rgb) { fact= texres.ta; texres.ta*= stencilTin; stencilTin*= fact; @@ -3158,15 +3165,15 @@ void do_sky_tex(const float rco[3], float lo[3], const float dxyview[2], float h } } else { - if(rgb) texres.ta *= stencilTin; + if (rgb) texres.ta *= stencilTin; else texres.tin*= stencilTin; } /* color mapping */ - if(mtex->mapto & (WOMAP_HORIZ+WOMAP_ZENUP+WOMAP_ZENDOWN)) { + if (mtex->mapto & (WOMAP_HORIZ+WOMAP_ZENUP+WOMAP_ZENDOWN)) { float tcol[3]; - if(rgb==0) { + if (rgb==0) { texres.tr= mtex->r; texres.tg= mtex->g; texres.tb= mtex->b; @@ -3185,29 +3192,29 @@ void do_sky_tex(const float rco[3], float lo[3], const float dxyview[2], float h srgb_to_linearrgb_v3_v3(tcol, tcol); } - if(mtex->mapto & WOMAP_HORIZ) { + if (mtex->mapto & WOMAP_HORIZ) { texture_rgb_blend(hor, tcol, hor, texres.tin, mtex->colfac, mtex->blendtype); } - if(mtex->mapto & (WOMAP_ZENUP+WOMAP_ZENDOWN)) { + if (mtex->mapto & (WOMAP_ZENUP+WOMAP_ZENDOWN)) { float zenfac = 0.0f; - if(R.wrld.skytype & WO_SKYREAL) { - if((skyflag & WO_ZENUP)) { - if(mtex->mapto & WOMAP_ZENUP) zenfac= mtex->zenupfac; + if (R.wrld.skytype & WO_SKYREAL) { + if ((skyflag & WO_ZENUP)) { + if (mtex->mapto & WOMAP_ZENUP) zenfac= mtex->zenupfac; } - else if(mtex->mapto & WOMAP_ZENDOWN) zenfac= mtex->zendownfac; + else if (mtex->mapto & WOMAP_ZENDOWN) zenfac= mtex->zendownfac; } else { - if(mtex->mapto & WOMAP_ZENUP) zenfac= mtex->zenupfac; - else if(mtex->mapto & WOMAP_ZENDOWN) zenfac= mtex->zendownfac; + if (mtex->mapto & WOMAP_ZENUP) zenfac= mtex->zenupfac; + else if (mtex->mapto & WOMAP_ZENDOWN) zenfac= mtex->zendownfac; } - if(zenfac != 0.0f) + if (zenfac != 0.0f) texture_rgb_blend(zen, tcol, zen, texres.tin, zenfac, mtex->blendtype); } } - if(mtex->mapto & WOMAP_BLEND) { - if(rgb) texres.tin= (0.35f*texres.tr+0.45f*texres.tg+0.2f*texres.tb); + if (mtex->mapto & WOMAP_BLEND) { + if (rgb) texres.tin= (0.35f*texres.tr+0.45f*texres.tg+0.2f*texres.tb); *blend= texture_value_blend(mtex->def_var, *blend, texres.tin, mtex->blendfac, mtex->blendtype); } @@ -3231,25 +3238,25 @@ void do_lamp_tex(LampRen *la, const float lavec[3], ShadeInput *shi, float col_r if (R.r.scemode & R_NO_TEX) return; tex_nr= 0; - for(; tex_nr<MAX_MTEX; tex_nr++) { + for (; tex_nr<MAX_MTEX; tex_nr++) { - if(la->mtex[tex_nr]) { + if (la->mtex[tex_nr]) { mtex= la->mtex[tex_nr]; tex= mtex->tex; - if(tex==NULL) continue; + if (tex==NULL) continue; texres.nor= NULL; /* which coords */ - if(mtex->texco==TEXCO_OBJECT) { + if (mtex->texco==TEXCO_OBJECT) { ob= mtex->object; - if(ob) { + if (ob) { co= tempvec; dx= dxt; dy= dyt; copy_v3_v3(tempvec, shi->co); mul_m4_v3(ob->imat_ren, tempvec); - if(shi->osatex) { + if (shi->osatex) { copy_v3_v3(dxt, shi->dxco); copy_v3_v3(dyt, shi->dyco); mul_mat3_m4_v3(ob->imat_ren, dxt); @@ -3261,17 +3268,17 @@ void do_lamp_tex(LampRen *la, const float lavec[3], ShadeInput *shi, float col_r dx= shi->dxco; dy= shi->dyco; } } - else if(mtex->texco==TEXCO_GLOB) { + else if (mtex->texco==TEXCO_GLOB) { co= shi->gl; dx= shi->dxco; dy= shi->dyco; copy_v3_v3(shi->gl, shi->co); mul_m4_v3(R.viewinv, shi->gl); } - else if(mtex->texco==TEXCO_VIEW) { + else if (mtex->texco==TEXCO_VIEW) { copy_v3_v3(tempvec, lavec); mul_m3_v3(la->imat, tempvec); - if(la->type==LA_SPOT) { + if (la->type==LA_SPOT) { tempvec[0]*= la->spottexfac; tempvec[1]*= la->spottexfac; /* project from 3d to 2d */ @@ -3281,7 +3288,7 @@ void do_lamp_tex(LampRen *la, const float lavec[3], ShadeInput *shi, float col_r co= tempvec; dx= dxt; dy= dyt; - if(shi->osatex) { + if (shi->osatex) { copy_v3_v3(dxt, shi->dxlv); copy_v3_v3(dyt, shi->dylv); /* need some matrix conversion here? la->imat is a [3][3] matrix!!! **/ @@ -3295,39 +3302,43 @@ void do_lamp_tex(LampRen *la, const float lavec[3], ShadeInput *shi, float col_r /* placement */ - if(mtex->projx && co) texvec[0]= mtex->size[0]*(co[mtex->projx-1]+mtex->ofs[0]); + if (mtex->projx && co) texvec[0]= mtex->size[0]*(co[mtex->projx-1]+mtex->ofs[0]); else texvec[0]= mtex->size[0]*(mtex->ofs[0]); - if(mtex->projy && co) texvec[1]= mtex->size[1]*(co[mtex->projy-1]+mtex->ofs[1]); + if (mtex->projy && co) texvec[1]= mtex->size[1]*(co[mtex->projy-1]+mtex->ofs[1]); else texvec[1]= mtex->size[1]*(mtex->ofs[1]); - if(mtex->projz && co) texvec[2]= mtex->size[2]*(co[mtex->projz-1]+mtex->ofs[2]); + if (mtex->projz && co) texvec[2]= mtex->size[2]*(co[mtex->projz-1]+mtex->ofs[2]); else texvec[2]= mtex->size[2]*(mtex->ofs[2]); - if(shi->osatex) { + if (shi->osatex) { if (!dx) { - for(i=0;i<2;i++) { + for (i=0;i<2;i++) { dxt[i] = dyt[i] = 0.0; } - } else { - if(mtex->projx) { + } + else { + if (mtex->projx) { dxt[0]= mtex->size[0]*dx[mtex->projx-1]; dyt[0]= mtex->size[0]*dy[mtex->projx-1]; - } else { + } + else { dxt[0]= 0.0; dyt[0]= 0.0; } - if(mtex->projy) { + if (mtex->projy) { dxt[1]= mtex->size[1]*dx[mtex->projy-1]; dyt[1]= mtex->size[1]*dy[mtex->projy-1]; - } else { + } + else { dxt[1]= 0.0; dyt[1]= 0.0; } - if(mtex->projz) { + if (mtex->projz) { dxt[2]= mtex->size[2]*dx[mtex->projz-1]; dyt[2]= mtex->size[2]*dy[mtex->projz-1]; - } else { + } + else { dxt[2]= 0.0; dyt[2]= 0.0; } @@ -3335,27 +3346,27 @@ void do_lamp_tex(LampRen *la, const float lavec[3], ShadeInput *shi, float col_r } /* texture */ - if(tex->type==TEX_IMAGE) { + if (tex->type==TEX_IMAGE) { do_2d_mapping(mtex, texvec, NULL, NULL, dxt, dyt); } rgb= multitex(tex, texvec, dxt, dyt, shi->osatex, &texres, shi->thread, mtex->which_output); /* texture output */ - if(rgb && (mtex->texflag & MTEX_RGBTOINT)) { + if (rgb && (mtex->texflag & MTEX_RGBTOINT)) { texres.tin= (0.35f*texres.tr+0.45f*texres.tg+0.2f*texres.tb); rgb= 0; } - if(mtex->texflag & MTEX_NEGATIVE) { - if(rgb) { + if (mtex->texflag & MTEX_NEGATIVE) { + if (rgb) { texres.tr= 1.0f-texres.tr; texres.tg= 1.0f-texres.tg; texres.tb= 1.0f-texres.tb; } else texres.tin= 1.0f-texres.tin; } - if(mtex->texflag & MTEX_STENCIL) { - if(rgb) { + if (mtex->texflag & MTEX_STENCIL) { + if (rgb) { fact= texres.ta; texres.ta*= stencilTin; stencilTin*= fact; @@ -3367,20 +3378,20 @@ void do_lamp_tex(LampRen *la, const float lavec[3], ShadeInput *shi, float col_r } } else { - if(rgb) texres.ta*= stencilTin; + if (rgb) texres.ta*= stencilTin; else texres.tin*= stencilTin; } /* mapping */ - if(((mtex->mapto & LAMAP_COL) && (effect & LA_TEXTURE))||((mtex->mapto & LAMAP_SHAD) && (effect & LA_SHAD_TEX))) { + if (((mtex->mapto & LAMAP_COL) && (effect & LA_TEXTURE))||((mtex->mapto & LAMAP_SHAD) && (effect & LA_SHAD_TEX))) { float col[3]; - if(rgb==0) { + if (rgb==0) { texres.tr= mtex->r; texres.tg= mtex->g; texres.tb= mtex->b; } - else if(mtex->mapto & MAP_ALPHA) { + else if (mtex->mapto & MAP_ALPHA) { texres.tin= stencilTin; } else texres.tin= texres.ta; @@ -3416,27 +3427,27 @@ int externtex(MTex *mtex, const float vec[3], float *tin, float *tr, float *tg, int rgb; tex= mtex->tex; - if(tex==NULL) return 0; + if (tex==NULL) return 0; texr.nor= NULL; /* placement */ - if(mtex->projx) texvec[0]= mtex->size[0]*(vec[mtex->projx-1]+mtex->ofs[0]); + if (mtex->projx) texvec[0]= mtex->size[0]*(vec[mtex->projx-1]+mtex->ofs[0]); else texvec[0]= mtex->size[0]*(mtex->ofs[0]); - if(mtex->projy) texvec[1]= mtex->size[1]*(vec[mtex->projy-1]+mtex->ofs[1]); + if (mtex->projy) texvec[1]= mtex->size[1]*(vec[mtex->projy-1]+mtex->ofs[1]); else texvec[1]= mtex->size[1]*(mtex->ofs[1]); - if(mtex->projz) texvec[2]= mtex->size[2]*(vec[mtex->projz-1]+mtex->ofs[2]); + if (mtex->projz) texvec[2]= mtex->size[2]*(vec[mtex->projz-1]+mtex->ofs[2]); else texvec[2]= mtex->size[2]*(mtex->ofs[2]); /* texture */ - if(tex->type==TEX_IMAGE) { + if (tex->type==TEX_IMAGE) { do_2d_mapping(mtex, texvec, NULL, NULL, dxt, dyt); } rgb= multitex(tex, texvec, dxt, dyt, 0, &texr, thread, mtex->which_output); - if(rgb) { + if (rgb) { texr.tin= (0.35f*texr.tr+0.45f*texr.tg+0.2f*texr.tb); } else { @@ -3467,12 +3478,12 @@ void render_realtime_texture(ShadeInput *shi, Image *ima) ShadeInputUV *suv= &shi->uv[shi->actuv]; int a; - if(R.r.scemode & R_NO_TEX) return; + if (R.r.scemode & R_NO_TEX) return; - if(firsttime) { + if (firsttime) { BLI_lock_thread(LOCK_IMAGE); - if(firsttime) { - for(a=0; a<BLENDER_MAX_THREADS; a++) { + if (firsttime) { + for (a=0; a<BLENDER_MAX_THREADS; a++) { memset(&imatex[a], 0, sizeof(Tex)); default_tex(&imatex[a]); imatex[a].type= TEX_IMAGE; @@ -3489,7 +3500,7 @@ void render_realtime_texture(ShadeInput *shi, Image *ima) texvec[0]= 0.5f+0.5f*suv->uv[0]; texvec[1]= 0.5f+0.5f*suv->uv[1]; texvec[2] = 0.0f; // initalize it because imagewrap looks at it. - if(shi->osatex) { + if (shi->osatex) { dx[0]= 0.5f*suv->dxuv[0]; dx[1]= 0.5f*suv->dxuv[1]; dy[0]= 0.5f*suv->dyuv[0]; @@ -3498,7 +3509,7 @@ void render_realtime_texture(ShadeInput *shi, Image *ima) texr.nor= NULL; - if(shi->osatex) imagewraposa(tex, ima, NULL, texvec, dx, dy, &texr); + if (shi->osatex) imagewraposa(tex, ima, NULL, texvec, dx, dy, &texr); else imagewrap(tex, ima, NULL, texvec, &texr); shi->vcol[0]*= texr.tr; @@ -3550,13 +3561,13 @@ Material *RE_init_sample_material(Material *orig_mat, Scene *scene) BKE_animsys_evaluate_animdata(scene, &mat->id, mat->adt, BKE_curframe(scene), ADT_RECALC_ANIM); /* strip material copy from unsupported flags */ - for(tex_nr=0; tex_nr<MAX_MTEX; tex_nr++) { - if(mat->septex & (1<<tex_nr)) continue; + for (tex_nr=0; tex_nr<MAX_MTEX; tex_nr++) { + if (mat->septex & (1<<tex_nr)) continue; - if(mat->mtex[tex_nr]) { + if (mat->mtex[tex_nr]) { MTex *mtex = mat->mtex[tex_nr]; - if(!mtex->tex) continue; + if (!mtex->tex) continue; /* only keep compatible texflags */ mtex->texflag = mtex->texflag & (MTEX_RGBTOINT | MTEX_STENCIL | MTEX_NEGATIVE | MTEX_ALPHAMIX); @@ -3582,9 +3593,9 @@ Material *RE_init_sample_material(Material *orig_mat, Scene *scene) } /* if mapped to an object, calculate inverse matrices */ - if(mtex->texco==TEXCO_OBJECT) { + if (mtex->texco==TEXCO_OBJECT) { Object *ob= mtex->object; - if(ob) { + if (ob) { invert_m4_m4(ob->imat, ob->obmat); copy_m4_m4(ob->imat_ren, ob->imat); } @@ -3597,10 +3608,10 @@ Material *RE_init_sample_material(Material *orig_mat, Scene *scene) BKE_animsys_evaluate_animdata(scene, &tex->id, tex->adt, BKE_curframe(scene), ADT_RECALC_ANIM); /* update texture cache if required */ - if(tex->type==TEX_VOXELDATA) { + if (tex->type==TEX_VOXELDATA) { cache_voxeldata(tex, (int)scene->r.cfra); } - if(tex->type==TEX_POINTDENSITY) { + if (tex->type==TEX_POINTDENSITY) { /* set dummy values for render and do cache */ Render dummy_re = {0}; dummy_re.scene = scene; @@ -3612,8 +3623,8 @@ Material *RE_init_sample_material(Material *orig_mat, Scene *scene) } /* update image sequences and movies */ - if(tex->ima && ELEM(tex->ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) { - if(tex->iuser.flag & IMA_ANIM_ALWAYS) + if (tex->ima && ELEM(tex->ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) { + if (tex->iuser.flag & IMA_ANIM_ALWAYS) BKE_image_user_calc_frame(&tex->iuser, (int)scene->r.cfra, 0); } } @@ -3627,12 +3638,12 @@ void RE_free_sample_material(Material *mat) int tex_nr; /* free textures */ - for(tex_nr=0; tex_nr<MAX_MTEX; tex_nr++) { - if(mat->septex & (1<<tex_nr)) continue; - if(mat->mtex[tex_nr]) { + for (tex_nr=0; tex_nr<MAX_MTEX; tex_nr++) { + if (mat->septex & (1<<tex_nr)) continue; + if (mat->mtex[tex_nr]) { MTex *mtex= mat->mtex[tex_nr]; - if(mtex->tex) { + if (mtex->tex) { free_texture(mtex->tex); MEM_freeN(mtex->tex); mtex->tex = NULL; @@ -3703,7 +3714,7 @@ void RE_sample_material_color(Material *mat, float color[3], float *alpha, const /* for every uv map set coords and name */ for (i=0; i<layers; i++) { - if(layer_index >= 0) { + if (layer_index >= 0) { float *uv1, *uv2, *uv3; float l; CustomData *data = &orcoDm->faceData; diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c index da598cb4733..6f0ffcb8470 100644 --- a/source/blender/render/intern/source/rendercore.c +++ b/source/blender/render/intern/source/rendercore.c @@ -97,12 +97,12 @@ void calc_view_vector(float *view, float x, float y) view[2]= -ABS(R.clipsta); - if(R.r.mode & R_ORTHO) { + if (R.r.mode & R_ORTHO) { view[0]= view[1]= 0.0f; } else { - if(R.r.mode & R_PANORAMA) { + if (R.r.mode & R_PANORAMA) { x-= R.panodxp; } @@ -113,13 +113,13 @@ void calc_view_vector(float *view, float x, float y) y= (y/(float)R.winy); view[1]= R.viewplane.ymin + y*(R.viewplane.ymax - R.viewplane.ymin); -// if(R.flag & R_SEC_FIELD) { -// if(R.r.mode & R_ODDFIELD) view[1]= (y+R.ystart)*R.ycor; +// if (R.flag & R_SEC_FIELD) { +// if (R.r.mode & R_ODDFIELD) view[1]= (y+R.ystart)*R.ycor; // else view[1]= (y+R.ystart+1.0)*R.ycor; // } // else view[1]= (y+R.ystart+R.bluroffsy+0.5)*R.ycor; - if(R.r.mode & R_PANORAMA) { + if (R.r.mode & R_PANORAMA) { float u= view[0] + R.panodxv; float v= view[2]; view[0]= R.panoco*u + R.panosi*v; view[2]= -R.panosi*u + R.panoco*v; @@ -157,7 +157,7 @@ void calc_renderco_zbuf(float co[3], const float view[3], int z) /* also used in zbuf.c and shadbuf.c */ int count_mask(unsigned short mask) { - if(R.samples) + if (R.samples) return (R.samples->cmask[mask & 255]+R.samples->cmask[mask>>8]); return 0; } @@ -165,8 +165,8 @@ int count_mask(unsigned short mask) static int calchalo_z(HaloRen *har, int zz) { - if(har->type & HA_ONLYSKY) { - if(zz < 0x7FFFFFF0) zz= - 0x7FFFFF; /* edge render messes zvalues */ + if (har->type & HA_ONLYSKY) { + if (zz < 0x7FFFFFF0) zz= - 0x7FFFFF; /* edge render messes zvalues */ } else { zz= (zz>>8); @@ -186,18 +186,18 @@ static void halo_pixelstruct(HaloRen *har, RenderLayer **rlpp, int totsample, in accol[0]=accol[1]=accol[2]=accol[3]= 0.0f; flarec= har->flarec; - while(ps) { + while (ps) { amountm= count_mask(ps->mask); amount+= amountm; zz= calchalo_z(har, ps->z); - if((zz> har->zs) || (har->mat && (har->mat->mode & MA_HALO_SOFT))) { - if(shadeHaloFloat(har, col, zz, dist, xn, yn, flarec)) { + if ((zz> har->zs) || (har->mat && (har->mat->mode & MA_HALO_SOFT))) { + if (shadeHaloFloat(har, col, zz, dist, xn, yn, flarec)) { flarec= 0; - if(fullsample) { - for(sample=0; sample<totsample; sample++) - if(ps->mask & (1 << sample)) + if (fullsample) { + for (sample=0; sample<totsample; sample++) + if (ps->mask & (1 << sample)) addalphaAddfacFloat(rlpp[sample]->rectf + od*4, col, har->add); } else { @@ -216,9 +216,9 @@ static void halo_pixelstruct(HaloRen *har, RenderLayer **rlpp, int totsample, in /* now do the sky sub-pixels */ amount= R.osa-amount; - if(amount) { - if(shadeHaloFloat(har, col, 0x7FFFFF, dist, xn, yn, flarec)) { - if(!fullsample) { + if (amount) { + if (shadeHaloFloat(har, col, 0x7FFFFF, dist, xn, yn, flarec)) { + if (!fullsample) { fac= ((float)amount)/(float)R.osa; accol[0]+= fac*col[0]; accol[1]+= fac*col[1]; @@ -228,9 +228,9 @@ static void halo_pixelstruct(HaloRen *har, RenderLayer **rlpp, int totsample, in } } - if(fullsample) { - for(sample=0; sample<totsample; sample++) - if(!(mask & (1 << sample))) + if (fullsample) { + for (sample=0; sample<totsample; sample++) + if (!(mask & (1 << sample))) addalphaAddfacFloat(rlpp[sample]->rectf + od*4, col, har->add); } else { @@ -239,7 +239,7 @@ static void halo_pixelstruct(HaloRen *har, RenderLayer **rlpp, int totsample, in col[2]= accol[2]; col[3]= accol[3]; - for(sample=0; sample<totsample; sample++) + for (sample=0; sample<totsample; sample++) addalphaAddfacFloat(rlpp[sample]->rectf + od*4, col, har->add); } } @@ -257,7 +257,7 @@ static void halo_tile(RenderPart *pa, RenderLayer *rl) unsigned int lay= rl->lay; /* we don't render halos in the cropped area, gives errors in flare counter */ - if(pa->crop) { + if (pa->crop) { testrect.xmin+= pa->crop; testrect.xmax-= pa->crop; testrect.ymin+= pa->crop; @@ -266,20 +266,20 @@ static void halo_tile(RenderPart *pa, RenderLayer *rl) totsample= get_sample_layers(pa, rl, rlpp); - for(a=0; a<R.tothalo; a++) { + for (a=0; a<R.tothalo; a++) { har= R.sortedhalos[a]; /* layer test, clip halo with y */ - if((har->lay & lay)==0); - else if(testrect.ymin > har->maxy); - else if(testrect.ymax < har->miny); + if ((har->lay & lay)==0); + else if (testrect.ymin > har->maxy); + else if (testrect.ymax < har->miny); else { minx= floor(har->xs-har->rad); maxx= ceil(har->xs+har->rad); - if(testrect.xmin > maxx); - else if(testrect.xmax < minx); + if (testrect.xmin > maxx); + else if (testrect.xmax < minx); else { minx= MAX2(minx, testrect.xmin); @@ -288,41 +288,41 @@ static void halo_tile(RenderPart *pa, RenderLayer *rl) miny= MAX2(har->miny, testrect.ymin); maxy= MIN2(har->maxy, testrect.ymax); - for(y=miny; y<maxy; y++) { + for (y=miny; y<maxy; y++) { int rectofs= (y-disprect.ymin)*pa->rectx + (minx - disprect.xmin); rz= pa->rectz + rectofs; od= rectofs; - if(pa->rectdaps) + if (pa->rectdaps) rd= pa->rectdaps + rectofs; yn= (y-har->ys)*R.ycor; ysq= yn*yn; - for(x=minx; x<maxx; x++, rz++, od++) { + for (x=minx; x<maxx; x++, rz++, od++) { xn= x- har->xs; xsq= xn*xn; dist= xsq+ysq; - if(dist<har->radsq) { - if(rd && *rd) { + if (dist<har->radsq) { + if (rd && *rd) { halo_pixelstruct(har, rlpp, totsample, od, dist, xn, yn, (PixStr *)*rd); } else { zz= calchalo_z(har, *rz); - if((zz> har->zs) || (har->mat && (har->mat->mode & MA_HALO_SOFT))) { - if(shadeHaloFloat(har, col, zz, dist, xn, yn, har->flarec)) { - for(sample=0; sample<totsample; sample++) + if ((zz> har->zs) || (har->mat && (har->mat->mode & MA_HALO_SOFT))) { + if (shadeHaloFloat(har, col, zz, dist, xn, yn, har->flarec)) { + for (sample=0; sample<totsample; sample++) addalphaAddfacFloat(rlpp[sample]->rectf + od*4, col, har->add); } } } } - if(rd) rd++; + if (rd) rd++; } } } } - if(R.test_break(R.tbh) ) break; + if (R.test_break(R.tbh) ) break; } } @@ -341,17 +341,17 @@ static void lamphalo_tile(RenderPart *pa, RenderLayer *rl) shade_input_initialize(&shi, pa, rl, 0); /* this zero's ShadeInput for us */ - for(od=0, y=pa->disprect.ymin; y<pa->disprect.ymax; y++) { - for(x=pa->disprect.xmin; x<pa->disprect.xmax; x++, rz++, od++) { + for (od=0, y=pa->disprect.ymin; y<pa->disprect.ymax; y++) { + for (x=pa->disprect.xmin; x<pa->disprect.xmax; x++, rz++, od++) { calc_view_vector(shi.view, x, y); - if(rd && *rd) { + if (rd && *rd) { PixStr *ps= (PixStr *)*rd; int count, totsamp= 0, mask= 0; - while(ps) { - if(R.r.mode & R_ORTHO) + while (ps) { + if (R.r.mode & R_ORTHO) calc_renderco_ortho(shi.co, (float)x, (float)y, ps->z); else calc_renderco_zbuf(shi.co, shi.view, ps->z); @@ -362,15 +362,15 @@ static void lamphalo_tile(RenderPart *pa, RenderLayer *rl) col[0]= col[1]= col[2]= col[3]= 0.0f; renderspothalo(&shi, col, 1.0f); - if(fullsample) { - for(sample=0; sample<totsample; sample++) { - if(ps->mask & (1 << sample)) { + if (fullsample) { + for (sample=0; sample<totsample; sample++) { + if (ps->mask & (1 << sample)) { pass= rlpp[sample]->rectf + od*4; pass[0]+= col[0]; pass[1]+= col[1]; pass[2]+= col[2]; pass[3]+= col[3]; - if(pass[3]>1.0f) pass[3]= 1.0f; + if (pass[3]>1.0f) pass[3]= 1.0f; } } } @@ -381,27 +381,27 @@ static void lamphalo_tile(RenderPart *pa, RenderLayer *rl) pass[1]+= fac*col[1]; pass[2]+= fac*col[2]; pass[3]+= fac*col[3]; - if(pass[3]>1.0f) pass[3]= 1.0f; + if (pass[3]>1.0f) pass[3]= 1.0f; } ps= ps->next; } - if(totsamp<R.osa) { + if (totsamp<R.osa) { shi.co[2]= 0.0f; col[0]= col[1]= col[2]= col[3]= 0.0f; renderspothalo(&shi, col, 1.0f); - if(fullsample) { - for(sample=0; sample<totsample; sample++) { - if(!(mask & (1 << sample))) { + if (fullsample) { + for (sample=0; sample<totsample; sample++) { + if (!(mask & (1 << sample))) { pass= rlpp[sample]->rectf + od*4; pass[0]+= col[0]; pass[1]+= col[1]; pass[2]+= col[2]; pass[3]+= col[3]; - if(pass[3]>1.0f) pass[3]= 1.0f; + if (pass[3]>1.0f) pass[3]= 1.0f; } } } @@ -412,12 +412,12 @@ static void lamphalo_tile(RenderPart *pa, RenderLayer *rl) pass[1]+= fac*col[1]; pass[2]+= fac*col[2]; pass[3]+= fac*col[3]; - if(pass[3]>1.0f) pass[3]= 1.0f; + if (pass[3]>1.0f) pass[3]= 1.0f; } } } else { - if(R.r.mode & R_ORTHO) + if (R.r.mode & R_ORTHO) calc_renderco_ortho(shi.co, (float)x, (float)y, *rz); else calc_renderco_zbuf(shi.co, shi.view, *rz); @@ -425,20 +425,20 @@ static void lamphalo_tile(RenderPart *pa, RenderLayer *rl) col[0]= col[1]= col[2]= col[3]= 0.0f; renderspothalo(&shi, col, 1.0f); - for(sample=0; sample<totsample; sample++) { + for (sample=0; sample<totsample; sample++) { pass= rlpp[sample]->rectf + od*4; pass[0]+= col[0]; pass[1]+= col[1]; pass[2]+= col[2]; pass[3]+= col[3]; - if(pass[3]>1.0f) pass[3]= 1.0f; + if (pass[3]>1.0f) pass[3]= 1.0f; } } - if(rd) rd++; + if (rd) rd++; } - if(y&1) - if(R.test_break(R.tbh)) break; + if (y&1) + if (R.test_break(R.tbh)) break; } } @@ -453,7 +453,7 @@ static void add_filt_passes(RenderLayer *rl, int curmask, int rectx, int offset, /* combined rgb */ add_filt_fmask(curmask, shr->combined, rl->rectf + 4*offset, rectx); - for(rpass= rl->passes.first; rpass; rpass= rpass->next) { + for (rpass= rl->passes.first; rpass; rpass= rpass->next) { float *fp, *col= NULL; int pixsize= 3; @@ -498,7 +498,7 @@ static void add_filt_passes(RenderLayer *rl, int curmask, int rectx, int offset, break; case SCE_PASS_UV: /* box filter only, gauss will screwup UV too much */ - if(shi->totuv) { + if (shi->totuv) { float mult= (float)count_mask(curmask)/(float)R.osa; fp= rpass->rect + 3*offset; fp[0]+= mult*(0.5f + 0.5f*shi->uv[shi->actuv].uv[0]); @@ -508,17 +508,17 @@ static void add_filt_passes(RenderLayer *rl, int curmask, int rectx, int offset, break; case SCE_PASS_INDEXOB: /* no filter */ - if(shi->vlr) { + if (shi->vlr) { fp= rpass->rect + offset; - if(*fp==0.0f) + if (*fp==0.0f) *fp= (float)shi->obr->ob->index; } break; case SCE_PASS_INDEXMA: /* no filter */ - if(shi->vlr) { + if (shi->vlr) { fp= rpass->rect + offset; - if(*fp==0.0f) + if (*fp==0.0f) *fp= (float)shi->mat->index; } break; @@ -532,11 +532,11 @@ static void add_filt_passes(RenderLayer *rl, int curmask, int rectx, int offset, { /* add minimum speed in pixel, no filter */ fp= rpass->rect + 4*offset; - if( (ABS(shr->winspeed[0]) + ABS(shr->winspeed[1]))< (ABS(fp[0]) + ABS(fp[1])) ) { + if ( (ABS(shr->winspeed[0]) + ABS(shr->winspeed[1]))< (ABS(fp[0]) + ABS(fp[1])) ) { fp[0]= shr->winspeed[0]; fp[1]= shr->winspeed[1]; } - if( (ABS(shr->winspeed[2]) + ABS(shr->winspeed[3]))< (ABS(fp[2]) + ABS(fp[3])) ) { + if ( (ABS(shr->winspeed[2]) + ABS(shr->winspeed[3]))< (ABS(fp[2]) + ABS(fp[3])) ) { fp[2]= shr->winspeed[2]; fp[3]= shr->winspeed[3]; } @@ -549,7 +549,7 @@ static void add_filt_passes(RenderLayer *rl, int curmask, int rectx, int offset, pixsize= 4; break; } - if(col) { + if (col) { fp= rpass->rect + pixsize*offset; add_filt_fmask_pixsize(curmask, col, fp, rectx, pixsize); } @@ -565,7 +565,7 @@ static void add_passes(RenderLayer *rl, int offset, ShadeInput *shi, ShadeResult fp= rl->rectf + 4*offset; copy_v4_v4(fp, shr->combined); - for(rpass= rl->passes.first; rpass; rpass= rpass->next) { + for (rpass= rl->passes.first; rpass; rpass= rpass->next) { float *col= NULL, uvcol[3]; int a, pixsize= 3; @@ -609,7 +609,7 @@ static void add_passes(RenderLayer *rl, int offset, ShadeInput *shi, ShadeResult col= shr->nor; break; case SCE_PASS_UV: - if(shi->totuv) { + if (shi->totuv) { uvcol[0]= 0.5f + 0.5f*shi->uv[shi->actuv].uv[0]; uvcol[1]= 0.5f + 0.5f*shi->uv[shi->actuv].uv[1]; uvcol[2]= 1.0f; @@ -621,13 +621,13 @@ static void add_passes(RenderLayer *rl, int offset, ShadeInput *shi, ShadeResult pixsize= 4; break; case SCE_PASS_INDEXOB: - if(shi->vlr) { + if (shi->vlr) { fp= rpass->rect + offset; *fp= (float)shi->obr->ob->index; } break; case SCE_PASS_INDEXMA: - if(shi->vlr) { + if (shi->vlr) { fp= rpass->rect + offset; *fp= (float)shi->mat->index; } @@ -641,9 +641,9 @@ static void add_passes(RenderLayer *rl, int offset, ShadeInput *shi, ShadeResult pixsize= 4; break; } - if(col) { + if (col) { fp= rpass->rect + pixsize*offset; - for(a=0; a<pixsize; a++) + for (a=0; a<pixsize; a++) fp[a]= col[a]; } } @@ -652,10 +652,10 @@ static void add_passes(RenderLayer *rl, int offset, ShadeInput *shi, ShadeResult int get_sample_layers(RenderPart *pa, RenderLayer *rl, RenderLayer **rlpp) { - if(pa->fullresult.first) { + if (pa->fullresult.first) { int sample, nr= BLI_findindex(&pa->result->layers, rl); - for(sample=0; sample<R.osa; sample++) { + for (sample=0; sample<R.osa; sample++) { RenderResult *rr= BLI_findlink(&pa->fullresult, sample); rlpp[sample]= BLI_findlink(&rr->layers, nr); @@ -675,27 +675,27 @@ static void sky_tile(RenderPart *pa, RenderLayer *rl) RenderLayer *rlpp[RE_MAX_OSA]; int x, y, od=0, totsample; - if(R.r.alphamode!=R_ADDSKY) + if (R.r.alphamode!=R_ADDSKY) return; totsample= get_sample_layers(pa, rl, rlpp); - for(y=pa->disprect.ymin; y<pa->disprect.ymax; y++) { - for(x=pa->disprect.xmin; x<pa->disprect.xmax; x++, od+=4) { + for (y=pa->disprect.ymin; y<pa->disprect.ymax; y++) { + for (x=pa->disprect.xmin; x<pa->disprect.xmax; x++, od+=4) { float col[4]; int sample, done= 0; - for(sample= 0; sample<totsample; sample++) { + for (sample= 0; sample<totsample; sample++) { float *pass= rlpp[sample]->rectf + od; - if(pass[3]<1.0f) { + if (pass[3]<1.0f) { - if(done==0) { + if (done==0) { shadeSkyPixel(col, x, y, pa->thread); done= 1; } - if(pass[3]==0.0f) { + if (pass[3]==0.0f) { copy_v4_v4(pass, col); } else { @@ -705,8 +705,8 @@ static void sky_tile(RenderPart *pa, RenderLayer *rl) } } - if(y&1) - if(R.test_break(R.tbh)) break; + if (y&1) + if (R.test_break(R.tbh)) break; } } @@ -722,67 +722,67 @@ static void atm_tile(RenderPart *pa, RenderLayer *rl) totsample= get_sample_layers(pa, rl, rlpp); /* check that z pass is enabled */ - if(pa->rectz==NULL) return; - for(zpass= rl->passes.first; zpass; zpass= zpass->next) - if(zpass->passtype==SCE_PASS_Z) + if (pa->rectz==NULL) return; + for (zpass= rl->passes.first; zpass; zpass= zpass->next) + if (zpass->passtype==SCE_PASS_Z) break; - if(zpass==NULL) return; + if (zpass==NULL) return; /* check for at least one sun lamp that its atmosphere flag is enabled */ - for(go=R.lights.first; go; go= go->next) { + for (go=R.lights.first; go; go= go->next) { lar= go->lampren; - if(lar->type==LA_SUN && lar->sunsky && (lar->sunsky->effect_type & LA_SUN_EFFECT_AP)) + if (lar->type==LA_SUN && lar->sunsky && (lar->sunsky->effect_type & LA_SUN_EFFECT_AP)) break; } /* do nothign and return if there is no sun lamp */ - if(go==NULL) + if (go==NULL) return; /* for each x,y and each sample, and each sun lamp*/ - for(y=pa->disprect.ymin; y<pa->disprect.ymax; y++) { - for(x=pa->disprect.xmin; x<pa->disprect.xmax; x++, od++) { + for (y=pa->disprect.ymin; y<pa->disprect.ymax; y++) { + for (x=pa->disprect.xmin; x<pa->disprect.xmax; x++, od++) { int sample; - for(sample=0; sample<totsample; sample++) { + for (sample=0; sample<totsample; sample++) { float *zrect= RE_RenderLayerGetPass(rlpp[sample], SCE_PASS_Z) + od; float *rgbrect = rlpp[sample]->rectf + 4*od; float rgb[3] = {0}; int done= 0; - for(go=R.lights.first; go; go= go->next) { + for (go=R.lights.first; go; go= go->next) { lar= go->lampren; - if(lar->type==LA_SUN && lar->sunsky) { + if (lar->type==LA_SUN && lar->sunsky) { /* if it's sky continue and don't apply atmosphere effect on it */ - if(*zrect >= 9.9e10f || rgbrect[3]==0.0f) { + if (*zrect >= 9.9e10f || rgbrect[3]==0.0f) { continue; } - if((lar->sunsky->effect_type & LA_SUN_EFFECT_AP)) { + if ((lar->sunsky->effect_type & LA_SUN_EFFECT_AP)) { float tmp_rgb[3]; /* skip if worldspace lamp vector is below horizon */ - if(go->ob->obmat[2][2] < 0.f) { + if (go->ob->obmat[2][2] < 0.f) { continue; } copy_v3_v3(tmp_rgb, rgbrect); - if(rgbrect[3]!=1.0f) { /* de-premul */ + if (rgbrect[3]!=1.0f) { /* de-premul */ mul_v3_fl(tmp_rgb, 1.0f/rgbrect[3]); } shadeAtmPixel(lar->sunsky, tmp_rgb, x, y, *zrect); - if(rgbrect[3]!=1.0f) { /* premul */ + if (rgbrect[3]!=1.0f) { /* premul */ mul_v3_fl(tmp_rgb, rgbrect[3]); } - if(done==0) { + if (done==0) { copy_v3_v3(rgb, tmp_rgb); done = 1; } - else{ + else { rgb[0] = 0.5f*rgb[0] + 0.5f*tmp_rgb[0]; rgb[1] = 0.5f*rgb[1] + 0.5f*tmp_rgb[1]; rgb[2] = 0.5f*rgb[2] + 0.5f*tmp_rgb[2]; @@ -792,7 +792,7 @@ static void atm_tile(RenderPart *pa, RenderLayer *rl) } /* if at least for one sun lamp aerial perspective was applied*/ - if(done) { + if (done) { copy_v3_v3(rgbrect, rgb); } } @@ -808,10 +808,10 @@ static void shadeDA_tile(RenderPart *pa, RenderLayer *rl) int samp; int x, y, seed, crop=0, offs=0, od; - if(R.test_break(R.tbh)) return; + if (R.test_break(R.tbh)) return; /* irregular shadowb buffer creation */ - if(R.r.mode & R_SHADOW) + if (R.r.mode & R_SHADOW) ISB_create(pa, NULL); /* we set per pixel a fixed seed, for random AO and shadow samples */ @@ -821,11 +821,11 @@ static void shadeDA_tile(RenderPart *pa, RenderLayer *rl) shade_sample_initialize(&ssamp, pa, rl); /* occlusion caching */ - if(R.occlusiontree) + if (R.occlusiontree) cache_occ_samples(&R, pa, &ssamp); /* filtered render, for now we assume only 1 filter size */ - if(pa->crop) { + if (pa->crop) { crop= 1; rectdaps+= pa->rectx + 1; offs= pa->rectx + 1; @@ -836,30 +836,30 @@ static void shadeDA_tile(RenderPart *pa, RenderLayer *rl) rr->renrect.ymax = -2*crop; rr->renlay= rl; - for(y=pa->disprect.ymin+crop; y<pa->disprect.ymax-crop; y++, rr->renrect.ymax++) { + for (y=pa->disprect.ymin+crop; y<pa->disprect.ymax-crop; y++, rr->renrect.ymax++) { rd= rectdaps; od= offs; - for(x=pa->disprect.xmin+crop; x<pa->disprect.xmax-crop; x++, rd++, od++) { + for (x=pa->disprect.xmin+crop; x<pa->disprect.xmax-crop; x++, rd++, od++) { BLI_thread_srandom(pa->thread, seed++); - if(*rd) { - if(shade_samples(&ssamp, (PixStr *)(*rd), x, y)) { + if (*rd) { + if (shade_samples(&ssamp, (PixStr *)(*rd), x, y)) { /* multisample buffers or filtered mask filling? */ - if(pa->fullresult.first) { + if (pa->fullresult.first) { int a; - for(samp=0; samp<ssamp.tot; samp++) { + for (samp=0; samp<ssamp.tot; samp++) { int smask= ssamp.shi[samp].mask; - for(a=0; a<R.osa; a++) { + for (a=0; a<R.osa; a++) { int mask= 1<<a; - if(smask & mask) + if (smask & mask) add_passes(ssamp.rlpp[a], od, &ssamp.shi[samp], &ssamp.shr[samp]); } } } else { - for(samp=0; samp<ssamp.tot; samp++) + for (samp=0; samp<ssamp.tot; samp++) add_filt_passes(rl, ssamp.shi[samp].mask, pa->rectx, od, &ssamp.shi[samp], &ssamp.shr[samp]); } } @@ -869,16 +869,16 @@ static void shadeDA_tile(RenderPart *pa, RenderLayer *rl) rectdaps+= pa->rectx; offs+= pa->rectx; - if(y&1) if(R.test_break(R.tbh)) break; + if (y&1) if(R.test_break(R.tbh)) break; } /* disable scanline updating */ rr->renlay= NULL; - if(R.r.mode & R_SHADOW) + if (R.r.mode & R_SHADOW) ISB_free(pa); - if(R.occlusiontree) + if (R.occlusiontree) free_occ_samples(&R, pa); } @@ -902,9 +902,9 @@ static void freeps(ListBase *lb) { PixStrMain *psm, *psmnext; - for(psm= lb->first; psm; psm= psmnext) { + for (psm= lb->first; psm; psm= psmnext) { psmnext= psm->next; - if(psm->ps) + if (psm->ps) MEM_freeN(psm->ps); MEM_freeN(psm); } @@ -916,11 +916,11 @@ static void addps(ListBase *lb, intptr_t *rd, int obi, int facenr, int z, int ma PixStrMain *psm; PixStr *ps, *last= NULL; - if(*rd) { + if (*rd) { ps= (PixStr *)(*rd); - while(ps) { - if( ps->obi == obi && ps->facenr == facenr ) { + while (ps) { + if ( ps->obi == obi && ps->facenr == facenr ) { ps->mask |= mask; return; } @@ -932,12 +932,12 @@ static void addps(ListBase *lb, intptr_t *rd, int obi, int facenr, int z, int ma /* make new PS (pixel struct) */ psm= lb->last; - if(psm->counter==4095) + if (psm->counter==4095) psm= addpsmain(lb); ps= psm->ps + psm->counter++; - if(last) last->next= ps; + if (last) last->next= ps; else *rd= (intptr_t)ps; ps->next= NULL; @@ -954,11 +954,11 @@ static void edge_enhance_add(RenderPart *pa, float *rectf, float *arect) float addcol[4]; int pix; - if(arect==NULL) + if (arect==NULL) return; - for(pix= pa->rectx*pa->recty; pix>0; pix--, arect++, rectf+=4) { - if(*arect != 0.0f) { + for (pix= pa->rectx*pa->recty; pix>0; pix--, arect++, rectf+=4) { + if (*arect != 0.0f) { addcol[0]= *arect * R.r.edgeR; addcol[1]= *arect * R.r.edgeG; addcol[2]= *arect * R.r.edgeB; @@ -975,12 +975,12 @@ static void convert_to_key_alpha(RenderPart *pa, RenderLayer *rl) totsample= get_sample_layers(pa, rl, rlpp); - for(sample= 0; sample<totsample; sample++) { + for (sample= 0; sample<totsample; sample++) { float *rectf= rlpp[sample]->rectf; - for(y= pa->rectx*pa->recty; y>0; y--, rectf+=4) { - if(rectf[3] >= 1.0f); - else if(rectf[3] > 0.0f) { + for (y= pa->rectx*pa->recty; y>0; y--, rectf+=4) { + if (rectf[3] >= 1.0f); + else if (rectf[3] > 0.0f) { rectf[0] /= rectf[3]; rectf[1] /= rectf[3]; rectf[2] /= rectf[3]; @@ -999,10 +999,10 @@ static void edge_enhance_tile(RenderPart *pa, float *rectf, int *rectz) /* shift values in zbuffer 4 to the right (anti overflows), for filter we need multiplying with 12 max */ rz= rectz; - if(rz==NULL) return; + if (rz==NULL) return; - for(y=0; y<pa->recty; y++) - for(x=0; x<pa->rectx; x++, rz++) (*rz)>>= 4; + for (y=0; y<pa->recty; y++) + for (x=0; x<pa->rectx; x++, rz++) (*rz)>>= 4; rz1= rectz; rz2= rz1+pa->rectx; @@ -1010,8 +1010,8 @@ static void edge_enhance_tile(RenderPart *pa, float *rectf, int *rectz) rf= rectf+pa->rectx+1; - for(y=0; y<pa->recty-2; y++) { - for(x=0; x<pa->rectx-2; x++, rz1++, rz2++, rz3++, rf++) { + for (y=0; y<pa->recty-2; y++) { + for (x=0; x<pa->rectx-2; x++, rz1++, rz2++, rz3++, rf++) { /* prevent overflow with sky z values */ zval1= rz1[0] + 2*rz1[1] + rz1[2]; @@ -1019,19 +1019,19 @@ static void edge_enhance_tile(RenderPart *pa, float *rectf, int *rectz) zval3= rz3[0] + 2*rz3[1] + rz3[2]; col= ( 4*rz2[1] - (zval1 + zval2 + zval3)/3 ); - if(col<0) col= -col; + if (col<0) col= -col; col >>= 5; - if(col > (1<<16)) col= (1<<16); + if (col > (1<<16)) col= (1<<16); else col= (R.r.edgeint*col)>>8; - if(col>0) { + if (col>0) { float fcol; - if(col>255) fcol= 1.0f; + if (col>255) fcol= 1.0f; else fcol= (float)col/255.0f; - if(R.osa) + if (R.osa) *rf+= fcol/(float)R.osa; else *rf= fcol; @@ -1045,8 +1045,8 @@ static void edge_enhance_tile(RenderPart *pa, float *rectf, int *rectz) /* shift back zbuf values, we might need it still */ rz= rectz; - for(y=0; y<pa->recty; y++) - for(x=0; x<pa->rectx; x++, rz++) (*rz)<<= 4; + for (y=0; y<pa->recty; y++) + for (x=0; x<pa->rectx; x++, rz++) (*rz)<<= 4; } @@ -1059,12 +1059,12 @@ static void reset_sky_speed(RenderPart *pa, RenderLayer *rl) totsample= get_sample_layers(pa, rl, rlpp); - for(sample= 0; sample<totsample; sample++) { + for (sample= 0; sample<totsample; sample++) { fp= RE_RenderLayerGetPass(rlpp[sample], SCE_PASS_VECTOR); - if(fp==NULL) break; + if (fp==NULL) break; - for(a= 4*pa->rectx*pa->recty - 1; a>=0; a--) - if(fp[a] == PASS_VECTOR_MAX) fp[a]= 0.0f; + for (a= 4*pa->rectx*pa->recty - 1; a>=0; a--) + if (fp[a] == PASS_VECTOR_MAX) fp[a]= 0.0f; } } @@ -1074,16 +1074,16 @@ static unsigned short *make_solid_mask(RenderPart *pa) unsigned short *solidmask, *sp; int x; - if(rd==NULL) return NULL; + if (rd==NULL) return NULL; sp=solidmask= MEM_mallocN(sizeof(short)*pa->rectx*pa->recty, "solidmask"); - for(x=pa->rectx*pa->recty; x>0; x--, rd++, sp++) { - if(*rd) { + for (x=pa->rectx*pa->recty; x>0; x--, rd++, sp++) { + if (*rd) { PixStr *ps= (PixStr *)*rd; *sp= ps->mask; - for(ps= ps->next; ps; ps= ps->next) + for (ps= ps->next; ps; ps= ps->next) *sp |= ps->mask; } else @@ -1098,10 +1098,10 @@ static void addAlphaOverFloatMask(float *dest, float *source, unsigned short dma unsigned short shared= dmask & smask; float mul= 1.0f - source[3]; - if(shared) { /* overlapping masks */ + if (shared) { /* overlapping masks */ /* masks differ, we make a mixture of 'add' and 'over' */ - if(shared!=dmask) { + if (shared!=dmask) { float shared_bits= (float)count_mask(shared); /* alpha over */ float tot_bits= (float)count_mask(smask|dmask); /* alpha add */ @@ -1109,7 +1109,7 @@ static void addAlphaOverFloatMask(float *dest, float *source, unsigned short dma mul= add + (1.0f-add)*mul; } } - else if(dmask && smask) { + else if (dmask && smask) { /* works for premul only, of course */ dest[0]+= source[0]; dest[1]+= source[1]; @@ -1143,16 +1143,16 @@ static void make_pixelstructs(RenderPart *pa, ZSpan *zspan, int sample, void *da int x, y; int mask= 1<<sample; - for(y=0; y<pa->recty; y++) { - for(x=0; x<pa->rectx; x++, rd++, rp++, ro++, rz++, rm++) { - if(*rp) { + for (y=0; y<pa->recty; y++) { + for (x=0; x<pa->rectx; x++, rd++, rp++, ro++, rz++, rm++) { + if (*rp) { addps(lb, rd, *ro, *rp, *rz, (zspan->rectmask)? *rm: 0, mask); } } } - if(sdata->rl->layflag & SCE_LAY_EDGE) - if(R.r.mode & R_EDGE) + if (sdata->rl->layflag & SCE_LAY_EDGE) + if (R.r.mode & R_EDGE) edge_enhance_tile(pa, sdata->edgerect, zspan->rectz); } @@ -1170,47 +1170,47 @@ void zbufshadeDA_tile(RenderPart *pa) pa->recto= MEM_mallocN(sizeof(int)*pa->rectx*pa->recty, "recto"); pa->rectp= MEM_mallocN(sizeof(int)*pa->rectx*pa->recty, "rectp"); pa->rectz= MEM_mallocN(sizeof(int)*pa->rectx*pa->recty, "rectz"); - for(rl= rr->layers.first; rl; rl= rl->next) { - if((rl->layflag & SCE_LAY_ZMASK) && (rl->layflag & SCE_LAY_NEG_ZMASK)) + for (rl= rr->layers.first; rl; rl= rl->next) { + if ((rl->layflag & SCE_LAY_ZMASK) && (rl->layflag & SCE_LAY_NEG_ZMASK)) pa->rectmask= MEM_mallocN(sizeof(int)*pa->rectx*pa->recty, "rectmask"); /* initialize pixelstructs and edge buffer */ addpsmain(&psmlist); pa->rectdaps= MEM_callocN(sizeof(intptr_t)*pa->rectx*pa->recty+4, "zbufDArectd"); - if(rl->layflag & SCE_LAY_EDGE) - if(R.r.mode & R_EDGE) + if (rl->layflag & SCE_LAY_EDGE) + if (R.r.mode & R_EDGE) edgerect= MEM_callocN(sizeof(float)*pa->rectx*pa->recty, "rectedge"); /* always fill visibility */ - for(pa->sample=0; pa->sample<R.osa; pa->sample+=4) { + for (pa->sample=0; pa->sample<R.osa; pa->sample+=4) { ZbufSolidData sdata; sdata.rl= rl; sdata.psmlist= &psmlist; sdata.edgerect= edgerect; zbuffer_solid(pa, rl, make_pixelstructs, &sdata); - if(R.test_break(R.tbh)) break; + if (R.test_break(R.tbh)) break; } /* shades solid */ - if(rl->layflag & SCE_LAY_SOLID) + if (rl->layflag & SCE_LAY_SOLID) shadeDA_tile(pa, rl); /* lamphalo after solid, before ztra, looks nicest because ztra does own halo */ - if(R.flag & R_LAMPHALO) - if(rl->layflag & SCE_LAY_HALO) + if (R.flag & R_LAMPHALO) + if (rl->layflag & SCE_LAY_HALO) lamphalo_tile(pa, rl); /* halo before ztra, because ztra fills in zbuffer now */ - if(R.flag & R_HALO) - if(rl->layflag & SCE_LAY_HALO) + if (R.flag & R_HALO) + if (rl->layflag & SCE_LAY_HALO) halo_tile(pa, rl); /* transp layer */ - if(R.flag & R_ZTRA || R.totstrand) { - if(rl->layflag & (SCE_LAY_ZTRA|SCE_LAY_STRAND)) { - if(pa->fullresult.first) { + if (R.flag & R_ZTRA || R.totstrand) { + if (rl->layflag & (SCE_LAY_ZTRA|SCE_LAY_STRAND)) { + if (pa->fullresult.first) { zbuffer_transp_shade(pa, rl, rl->rectf, &psmlist); } else { @@ -1225,17 +1225,17 @@ void zbufshadeDA_tile(RenderPart *pa) SWAP(float *, rl->acolrect, rl->rectf); /* zbuffer transp only returns ztramask if there's solid rendered */ - if(ztramask) + if (ztramask) solidmask= make_solid_mask(pa); - if(ztramask && solidmask) { + if (ztramask && solidmask) { unsigned short *sps= solidmask, *spz= ztramask; unsigned short fullmask= (1<<R.osa)-1; float *fcol= rl->rectf; float *acol= rl->acolrect; int x; - for(x=pa->rectx*pa->recty; x>0; x--, acol+=4, fcol+=4, sps++, spz++) { - if(*sps == fullmask) + for (x=pa->rectx*pa->recty; x>0; x--, acol+=4, fcol+=4, sps++, spz++) { + if (*sps == fullmask) addAlphaOverFloat(fcol, acol); else addAlphaOverFloatMask(fcol, acol, *sps, *spz); @@ -1244,44 +1244,44 @@ void zbufshadeDA_tile(RenderPart *pa) else { float *fcol= rl->rectf; float *acol= rl->acolrect; int x; - for(x=pa->rectx*pa->recty; x>0; x--, acol+=4, fcol+=4) { + for (x=pa->rectx*pa->recty; x>0; x--, acol+=4, fcol+=4) { addAlphaOverFloat(fcol, acol); } } - if(solidmask) MEM_freeN(solidmask); - if(ztramask) MEM_freeN(ztramask); + if (solidmask) MEM_freeN(solidmask); + if (ztramask) MEM_freeN(ztramask); } } } /* sun/sky */ - if(rl->layflag & SCE_LAY_SKY) + if (rl->layflag & SCE_LAY_SKY) atm_tile(pa, rl); /* sky before edge */ - if(rl->layflag & SCE_LAY_SKY) + if (rl->layflag & SCE_LAY_SKY) sky_tile(pa, rl); /* extra layers */ - if(rl->layflag & SCE_LAY_EDGE) - if(R.r.mode & R_EDGE) + if (rl->layflag & SCE_LAY_EDGE) + if (R.r.mode & R_EDGE) edge_enhance_add(pa, rl->rectf, edgerect); - if(rl->passflag & SCE_PASS_VECTOR) + if (rl->passflag & SCE_PASS_VECTOR) reset_sky_speed(pa, rl); /* de-premul alpha */ - if(R.r.alphamode & R_ALPHAKEY) + if (R.r.alphamode & R_ALPHAKEY) convert_to_key_alpha(pa, rl); /* free stuff within loop! */ MEM_freeN(pa->rectdaps); pa->rectdaps= NULL; freeps(&psmlist); - if(edgerect) MEM_freeN(edgerect); + if (edgerect) MEM_freeN(edgerect); edgerect= NULL; - if(pa->rectmask) { + if (pa->rectmask) { MEM_freeN(pa->rectmask); pa->rectmask= NULL; } @@ -1319,8 +1319,8 @@ void zbufshade_tile(RenderPart *pa) pa->rectp= MEM_mallocN(sizeof(int)*pa->rectx*pa->recty, "rectp"); pa->rectz= MEM_mallocN(sizeof(int)*pa->rectx*pa->recty, "rectz"); - for(rl= rr->layers.first; rl; rl= rl->next) { - if((rl->layflag & SCE_LAY_ZMASK) && (rl->layflag & SCE_LAY_NEG_ZMASK)) + for (rl= rr->layers.first; rl; rl= rl->next) { + if ((rl->layflag & SCE_LAY_ZMASK) && (rl->layflag & SCE_LAY_NEG_ZMASK)) pa->rectmask= MEM_mallocN(sizeof(int)*pa->rectx*pa->recty, "rectmask"); /* general shader info, passes */ @@ -1328,11 +1328,11 @@ void zbufshade_tile(RenderPart *pa) zbuffer_solid(pa, rl, NULL, NULL); - if(!R.test_break(R.tbh)) { /* NOTE: this if() is not consistent */ + if (!R.test_break(R.tbh)) { /* NOTE: this if() is not consistent */ /* edges only for solid part, ztransp doesn't support it yet anti-aliased */ - if(rl->layflag & SCE_LAY_EDGE) { - if(R.r.mode & R_EDGE) { + if (rl->layflag & SCE_LAY_EDGE) { + if (R.r.mode & R_EDGE) { edgerect= MEM_callocN(sizeof(float)*pa->rectx*pa->recty, "rectedge"); edge_enhance_tile(pa, edgerect, pa->rectz); } @@ -1342,7 +1342,7 @@ void zbufshade_tile(RenderPart *pa) rr->renrect.ymin = 0; rr->renlay= rl; - if(rl->layflag & SCE_LAY_SOLID) { + if (rl->layflag & SCE_LAY_SOLID) { float *fcol= rl->rectf; int *ro= pa->recto, *rp= pa->rectp, *rz= pa->rectz; int x, y, offs=0, seed; @@ -1351,35 +1351,35 @@ void zbufshade_tile(RenderPart *pa) seed= pa->rectx*pa->disprect.ymin; /* irregular shadowb buffer creation */ - if(R.r.mode & R_SHADOW) + if (R.r.mode & R_SHADOW) ISB_create(pa, NULL); - if(R.occlusiontree) + if (R.occlusiontree) cache_occ_samples(&R, pa, &ssamp); - for(y=pa->disprect.ymin; y<pa->disprect.ymax; y++, rr->renrect.ymax++) { - for(x=pa->disprect.xmin; x<pa->disprect.xmax; x++, ro++, rz++, rp++, fcol+=4, offs++) { + for (y=pa->disprect.ymin; y<pa->disprect.ymax; y++, rr->renrect.ymax++) { + for (x=pa->disprect.xmin; x<pa->disprect.xmax; x++, ro++, rz++, rp++, fcol+=4, offs++) { /* per pixel fixed seed */ BLI_thread_srandom(pa->thread, seed++); - if(*rp) { + if (*rp) { ps.obi= *ro; ps.facenr= *rp; ps.z= *rz; - if(shade_samples(&ssamp, &ps, x, y)) { + if (shade_samples(&ssamp, &ps, x, y)) { /* combined and passes */ add_passes(rl, offs, ssamp.shi, ssamp.shr); } } } - if(y&1) - if(R.test_break(R.tbh)) break; + if (y&1) + if (R.test_break(R.tbh)) break; } - if(R.occlusiontree) + if (R.occlusiontree) free_occ_samples(&R, pa); - if(R.r.mode & R_SHADOW) + if (R.r.mode & R_SHADOW) ISB_free(pa); } @@ -1388,17 +1388,17 @@ void zbufshade_tile(RenderPart *pa) } /* lamphalo after solid, before ztra, looks nicest because ztra does own halo */ - if(R.flag & R_LAMPHALO) - if(rl->layflag & SCE_LAY_HALO) + if (R.flag & R_LAMPHALO) + if (rl->layflag & SCE_LAY_HALO) lamphalo_tile(pa, rl); /* halo before ztra, because ztra fills in zbuffer now */ - if(R.flag & R_HALO) - if(rl->layflag & SCE_LAY_HALO) + if (R.flag & R_HALO) + if (rl->layflag & SCE_LAY_HALO) halo_tile(pa, rl); - if(R.flag & R_ZTRA || R.totstrand) { - if(rl->layflag & (SCE_LAY_ZTRA|SCE_LAY_STRAND)) { + if (R.flag & R_ZTRA || R.totstrand) { + if (rl->layflag & (SCE_LAY_ZTRA|SCE_LAY_STRAND)) { float *fcol, *acol; int x; @@ -1411,37 +1411,37 @@ void zbufshade_tile(RenderPart *pa) SWAP(float *, rl->acolrect, rl->rectf); fcol= rl->rectf; acol= rl->acolrect; - for(x=pa->rectx*pa->recty; x>0; x--, acol+=4, fcol+=4) { + for (x=pa->rectx*pa->recty; x>0; x--, acol+=4, fcol+=4) { addAlphaOverFloat(fcol, acol); } } } /* sun/sky */ - if(rl->layflag & SCE_LAY_SKY) + if (rl->layflag & SCE_LAY_SKY) atm_tile(pa, rl); /* sky before edge */ - if(rl->layflag & SCE_LAY_SKY) + if (rl->layflag & SCE_LAY_SKY) sky_tile(pa, rl); - if(!R.test_break(R.tbh)) { - if(rl->layflag & SCE_LAY_EDGE) - if(R.r.mode & R_EDGE) + if (!R.test_break(R.tbh)) { + if (rl->layflag & SCE_LAY_EDGE) + if (R.r.mode & R_EDGE) edge_enhance_add(pa, rl->rectf, edgerect); } - if(rl->passflag & SCE_PASS_VECTOR) + if (rl->passflag & SCE_PASS_VECTOR) reset_sky_speed(pa, rl); /* de-premul alpha */ - if(R.r.alphamode & R_ALPHAKEY) + if (R.r.alphamode & R_ALPHAKEY) convert_to_key_alpha(pa, rl); - if(edgerect) MEM_freeN(edgerect); + if (edgerect) MEM_freeN(edgerect); edgerect= NULL; - if(pa->rectmask) { + if (pa->rectmask) { MEM_freeN(pa->rectmask); pa->rectmask= NULL; } @@ -1470,37 +1470,37 @@ static void addps_sss(void *cb_handle, int obi, int facenr, int x, int y, int z) /* extra border for filter gives double samples on part edges, * don't use those */ - if(x<pa->crop || x>=pa->rectx-pa->crop) + if (x<pa->crop || x>=pa->rectx-pa->crop) return; - if(y<pa->crop || y>=pa->recty-pa->crop) + if (y<pa->crop || y>=pa->recty-pa->crop) return; - if(pa->rectall) { + if (pa->rectall) { intptr_t *rs= pa->rectall + pa->rectx*y + x; addps(&handle->psmlist, rs, obi, facenr, z, 0, 0); handle->totps++; } - if(pa->rectz) { + if (pa->rectz) { int *rz= pa->rectz + pa->rectx*y + x; int *rp= pa->rectp + pa->rectx*y + x; int *ro= pa->recto + pa->rectx*y + x; - if(z < *rz) { - if(*rp == 0) + if (z < *rz) { + if (*rp == 0) handle->totps++; *rz= z; *rp= facenr; *ro= obi; } } - if(pa->rectbackz) { + if (pa->rectbackz) { int *rz= pa->rectbackz + pa->rectx*y + x; int *rp= pa->rectbackp + pa->rectx*y + x; int *ro= pa->rectbacko + pa->rectx*y + x; - if(z >= *rz) { - if(*rp == 0) + if (z >= *rz) { + if (*rp == 0) handle->totps++; *rz= z; *rp= facenr; @@ -1518,7 +1518,7 @@ static void shade_sample_sss(ShadeSample *ssamp, Material *mat, ObjectInstanceRe /* cache for shadow */ shi->samplenr= R.shadowsamplenr[shi->thread]++; - if(quad) + if (quad) shade_input_set_triangle_i(shi, obi, vlr, 0, 2, 3); else shade_input_set_triangle_i(shi, obi, vlr, 0, 1, 2); @@ -1548,11 +1548,11 @@ static void shade_sample_sss(ShadeSample *ssamp, Material *mat, ObjectInstanceRe shade_input_set_normals(shi); /* we don't want flipped normals, they screw up back scattering */ - if(shi->flippednor) + if (shi->flippednor) shade_input_flip_normals(shi); /* not a pretty solution, but fixes common cases */ - if(shi->obr->ob && shi->obr->ob->transflag & OB_NEG_SCALE) { + if (shi->obr->ob && shi->obr->ob->transflag & OB_NEG_SCALE) { negate_v3(shi->vn); negate_v3(shi->vno); negate_v3(shi->nmapnorm); @@ -1560,7 +1560,7 @@ static void shade_sample_sss(ShadeSample *ssamp, Material *mat, ObjectInstanceRe /* if nodetree, use the material that we are currently preprocessing * instead of the node material */ - if(shi->mat->nodetree && shi->mat->use_nodes) + if (shi->mat->nodetree && shi->mat->use_nodes) shi->mat= mat; /* init material vars */ @@ -1638,7 +1638,7 @@ void zbufshade_sss_tile(RenderPart *pa) shade_sample_initialize(&ssamp, pa, rr->layers.first); ssamp.tot= 1; - for(rl=rr->layers.first; rl; rl=rl->next) { + for (rl=rr->layers.first; rl; rl=rl->next) { ssamp.shi[0].lay |= rl->lay; ssamp.shi[0].layflag |= rl->layflag; ssamp.shi[0].passflag |= rl->passflag; @@ -1655,7 +1655,7 @@ void zbufshade_sss_tile(RenderPart *pa) /* create the pixelstrs to be used later */ zbuffer_sss(pa, lay, &handle, addps_sss); - if(handle.totps==0) { + if (handle.totps==0) { zbufshade_sss_free(pa); return; } @@ -1668,11 +1668,11 @@ void zbufshade_sss_tile(RenderPart *pa) #if 0 /* create ISB (does not work currently!) */ - if(re->r.mode & R_SHADOW) + if (re->r.mode & R_SHADOW) ISB_create(pa, NULL); #endif - if(display) { + if (display) { /* initialize scanline updates for main thread */ rr->renrect.ymin = 0; rr->renlay= rl; @@ -1691,15 +1691,15 @@ void zbufshade_sss_tile(RenderPart *pa) #endif totpoint= 0; - for(y=pa->disprect.ymin; y<pa->disprect.ymax; y++, rr->renrect.ymax++) { - for(x=pa->disprect.xmin; x<pa->disprect.xmax; x++, fcol+=4) { + for (y=pa->disprect.ymin; y<pa->disprect.ymax; y++, rr->renrect.ymax++) { + for (x=pa->disprect.xmin; x<pa->disprect.xmax; x++, fcol+=4) { /* per pixel fixed seed */ BLI_thread_srandom(pa->thread, seed++); #if 0 - if(rs) { + if (rs) { /* for each sample in this pixel, shade it */ - for(ps=(PixStr*)*rs; ps; ps=ps->next) { + for (ps=(PixStr*)*rs; ps; ps=ps->next) { ObjectInstanceRen *obi= &re->objectinstance[ps->obi]; ObjectRen *obr= obi->obr; vlr= RE_findOrAddVlak(obr, (ps->facenr-1) & RE_QUAD_MASK); @@ -1718,8 +1718,8 @@ void zbufshade_sss_tile(RenderPart *pa) rs++; } #else - if(rp) { - if(*rp != 0) { + if (rp) { + if (*rp != 0) { ObjectInstanceRen *obi= &re->objectinstance[*ro]; ObjectRen *obr= obi->obr; @@ -1738,8 +1738,8 @@ void zbufshade_sss_tile(RenderPart *pa) rp++; rz++; ro++; } - if(rbp) { - if(*rbp != 0 && !(*rbp == *(rp-1) && *rbo == *(ro-1))) { + if (rbp) { + if (*rbp != 0 && !(*rbp == *(rp-1) && *rbo == *(ro-1))) { ObjectInstanceRen *obi= &re->objectinstance[*rbo]; ObjectRen *obr= obi->obr; @@ -1763,12 +1763,12 @@ void zbufshade_sss_tile(RenderPart *pa) #endif } - if(y&1) - if(re->test_break(re->tbh)) break; + if (y&1) + if (re->test_break(re->tbh)) break; } /* note: after adding we do not free these arrays, sss keeps them */ - if(totpoint > 0) { + if (totpoint > 0) { sss_add_points(re, co, color, area, totpoint); } else { @@ -1778,11 +1778,11 @@ void zbufshade_sss_tile(RenderPart *pa) } #if 0 - if(re->r.mode & R_SHADOW) + if (re->r.mode & R_SHADOW) ISB_free(pa); #endif - if(display) { + if (display) { /* display active layer */ rr->renrect.ymin=rr->renrect.ymax = 0; rr->renlay= render_get_active_layer(&R, rr); @@ -1806,37 +1806,37 @@ static void renderhalo_post(RenderResult *rr, float *rectf, HaloRen *har) /* pos har->miny= miny= haloys - har->rad/R.ycor; har->maxy= maxy= haloys + har->rad/R.ycor; - if(maxy<0); - else if(rr->recty<miny); + if (maxy<0); + else if (rr->recty<miny); else { minx= floor(haloxs-har->rad); maxx= ceil(haloxs+har->rad); - if(maxx<0); - else if(rr->rectx<minx); + if (maxx<0); + else if (rr->rectx<minx); else { - if(minx<0) minx= 0; - if(maxx>=rr->rectx) maxx= rr->rectx-1; - if(miny<0) miny= 0; - if(maxy>rr->recty) maxy= rr->recty; + if (minx<0) minx= 0; + if (maxx>=rr->rectx) maxx= rr->rectx-1; + if (miny<0) miny= 0; + if (maxy>rr->recty) maxy= rr->recty; rectft= rectf+ 4*rr->rectx*miny; - for(y=miny; y<maxy; y++) { + for (y=miny; y<maxy; y++) { rtf= rectft+4*minx; yn= (y - haloys)*R.ycor; ysq= yn*yn; - for(x=minx; x<=maxx; x++) { + for (x=minx; x<=maxx; x++) { xn= x - haloxs; xsq= xn*xn; dist= xsq+ysq; - if(dist<har->radsq) { + if (dist<har->radsq) { - if(shadeHaloFloat(har, colf, 0x7FFFFF, dist, xn, yn, har->flarec)) + if (shadeHaloFloat(har, colf, 0x7FFFFF, dist, xn, yn, har->flarec)) addalphaAddfacFloat(rtf, colf, har->add); } rtf+=4; @@ -1844,7 +1844,7 @@ static void renderhalo_post(RenderResult *rr, float *rectf, HaloRen *har) /* pos rectft+= 4*rr->rectx; - if(R.test_break(R.tbh)) break; + if (R.test_break(R.tbh)) break; } } } @@ -1885,7 +1885,7 @@ static void renderflare(RenderResult *rr, float *rectf, HaloRen *har) /* next halo's: the flares */ rc= hashvectf + ma->seed2; - for(b=1; b<har->flarec; b++) { + for (b=1; b<har->flarec; b++) { fla.r= fabs(rc[0]); fla.g= fabs(rc[1]); @@ -1898,7 +1898,7 @@ static void renderflare(RenderResult *rr, float *rectf, HaloRen *har) fla.rad= ma->subsize*sqrtf(fabs(2.0f*har->rad*rc[4])); - if(type==3) { + if (type==3) { fla.rad*= 3.0f; fla.rad+= R.rectx/10; } @@ -1912,16 +1912,16 @@ static void renderflare(RenderResult *rr, float *rectf, HaloRen *har) fla.xs= R.winx/2 + vec[0] + (1.2f+rc[8])*R.rectx*vec[0]/vec[2]; fla.ys= R.winy/2 + vec[1] + (1.2f+rc[8])*R.rectx*vec[1]/vec[2]; - if(R.flag & R_SEC_FIELD) { - if(R.r.mode & R_ODDFIELD) fla.ys += 0.5f; + if (R.flag & R_SEC_FIELD) { + if (R.r.mode & R_ODDFIELD) fla.ys += 0.5f; else fla.ys -= 0.5f; } - if(type & 1) fla.type= HA_FLARECIRC; + if (type & 1) fla.type= HA_FLARECIRC; else fla.type= 0; renderhalo_post(rr, rectf, &fla); fla.alfa*= 0.5f; - if(type & 2) fla.type= HA_FLARECIRC; + if (type & 2) fla.type= HA_FLARECIRC; else fla.type= 0; renderhalo_post(rr, rectf, &fla); @@ -1938,11 +1938,11 @@ void add_halo_flare(Render *re) int a, mode, do_draw=0; /* for now, we get the first renderlayer in list with halos set */ - for(rl= rr->layers.first; rl; rl= rl->next) - if(rl->layflag & SCE_LAY_HALO) + for (rl= rr->layers.first; rl; rl= rl->next) + if (rl->layflag & SCE_LAY_HALO) break; - if(rl==NULL || rl->rectf==NULL) + if (rl==NULL || rl->rectf==NULL) return; mode= R.r.mode; @@ -1950,16 +1950,16 @@ void add_halo_flare(Render *re) project_renderdata(&R, projectverto, 0, 0, 0); - for(a=0; a<R.tothalo; a++) { + for (a=0; a<R.tothalo; a++) { har= R.sortedhalos[a]; - if(har->flarec) { + if (har->flarec) { do_draw= 1; renderflare(rr, rl->rectf, har); } } - if(do_draw) { + if (do_draw) { /* weak... the display callback wants an active renderlayer pointer... */ rr->renlay= rl; re->display_draw(re->ddh, rr, NULL); @@ -1998,7 +1998,7 @@ typedef struct BakeShade { static void bake_set_shade_input(ObjectInstanceRen *obi, VlakRen *vlr, ShadeInput *shi, int quad, int UNUSED(isect), int x, int y, float u, float v) { - if(quad) + if (quad) shade_input_set_triangle_i(shi, obi, vlr, 0, 2, 3); else shade_input_set_triangle_i(shi, obi, vlr, 0, 1, 2); @@ -2017,7 +2017,7 @@ static void bake_set_shade_input(ObjectInstanceRen *obi, VlakRen *vlr, ShadeInpu shade_input_set_normals(shi); /* no normal flip */ - if(shi->flippednor) + if (shi->flippednor) shade_input_flip_normals(shi); /* set up view vector to look right at the surface (note that the normal @@ -2036,10 +2036,10 @@ static void bake_shade(void *handle, Object *ob, ShadeInput *shi, int UNUSED(qua shade_input_init_material(shi); - if(bs->type==RE_BAKE_AO) { + if (bs->type==RE_BAKE_AO) { ambient_occlusion(shi); - if(R.r.bake_flag & R_BAKE_NORMALIZE) { + if (R.r.bake_flag & R_BAKE_NORMALIZE) { copy_v3_v3(shr.combined, shi->ao); } else { @@ -2055,27 +2055,27 @@ static void bake_shade(void *handle, Object *ob, ShadeInput *shi, int UNUSED(qua /* only do AO for a full bake (and obviously AO bakes) * AO for light bakes is a leftover and might not be needed */ - if( ELEM3(bs->type, RE_BAKE_ALL, RE_BAKE_AO, RE_BAKE_LIGHT)) + if ( ELEM3(bs->type, RE_BAKE_ALL, RE_BAKE_AO, RE_BAKE_LIGHT)) shade_samples_do_AO(ssamp); - if(shi->mat->nodetree && shi->mat->use_nodes) { + if (shi->mat->nodetree && shi->mat->use_nodes) { ntreeShaderExecTree(shi->mat->nodetree, shi, &shr); shi->mat= vlr->mat; /* shi->mat is being set in nodetree */ } else shade_material_loop(shi, &shr); - if(bs->type==RE_BAKE_NORMALS) { + if (bs->type==RE_BAKE_NORMALS) { float nor[3]; copy_v3_v3(nor, shi->vn); - if(R.r.bake_normal_space == R_BAKE_SPACE_CAMERA); - else if(R.r.bake_normal_space == R_BAKE_SPACE_TANGENT) { + if (R.r.bake_normal_space == R_BAKE_SPACE_CAMERA); + else if (R.r.bake_normal_space == R_BAKE_SPACE_TANGENT) { float mat[3][3], imat[3][3]; /* bitangent */ - if(tvn && ttang) { + if (tvn && ttang) { copy_v3_v3(mat[0], ttang); cross_v3_v3v3(mat[1], tvn, ttang); mul_v3_fl(mat[1], ttang[3]); @@ -2091,9 +2091,9 @@ static void bake_shade(void *handle, Object *ob, ShadeInput *shi, int UNUSED(qua invert_m3_m3(imat, mat); mul_m3_v3(imat, nor); } - else if(R.r.bake_normal_space == R_BAKE_SPACE_OBJECT) + else if (R.r.bake_normal_space == R_BAKE_SPACE_OBJECT) mul_mat3_m4_v3(ob->imat_ren, nor); /* ob->imat_ren includes viewinv! */ - else if(R.r.bake_normal_space == R_BAKE_SPACE_WORLD) + else if (R.r.bake_normal_space == R_BAKE_SPACE_WORLD) mul_mat3_m4_v3(R.viewinv, nor); normalize_v3(nor); /* in case object has scaling */ @@ -2108,47 +2108,47 @@ static void bake_shade(void *handle, Object *ob, ShadeInput *shi, int UNUSED(qua shr.combined[1]= nor[1]/2.0f + 0.5f; shr.combined[2]= nor[2]/2.0f + 0.5f; } - else if(bs->type==RE_BAKE_TEXTURE) { + else if (bs->type==RE_BAKE_TEXTURE) { shr.combined[0]= shi->r; shr.combined[1]= shi->g; shr.combined[2]= shi->b; shr.alpha = shi->alpha; } - else if(bs->type==RE_BAKE_SHADOW) { + else if (bs->type==RE_BAKE_SHADOW) { copy_v3_v3(shr.combined, shr.shad); shr.alpha = shi->alpha; } - else if(bs->type==RE_BAKE_SPEC_COLOR) { + else if (bs->type==RE_BAKE_SPEC_COLOR) { shr.combined[0]= shi->specr; shr.combined[1]= shi->specg; shr.combined[2]= shi->specb; shr.alpha = 1.0f; } - else if(bs->type==RE_BAKE_SPEC_INTENSITY) { + else if (bs->type==RE_BAKE_SPEC_INTENSITY) { shr.combined[0]= shr.combined[1]= shr.combined[2]= shi->spec; shr.alpha = 1.0f; } - else if(bs->type==RE_BAKE_MIRROR_COLOR) { + else if (bs->type==RE_BAKE_MIRROR_COLOR) { shr.combined[0]= shi->mirr; shr.combined[1]= shi->mirg; shr.combined[2]= shi->mirb; shr.alpha = 1.0f; } - else if(bs->type==RE_BAKE_MIRROR_INTENSITY) { + else if (bs->type==RE_BAKE_MIRROR_INTENSITY) { shr.combined[0]= shr.combined[1]= shr.combined[2]= shi->ray_mirror; shr.alpha = 1.0f; } - else if(bs->type==RE_BAKE_ALPHA) { + else if (bs->type==RE_BAKE_ALPHA) { shr.combined[0]= shr.combined[1]= shr.combined[2]= shi->alpha; shr.alpha = 1.0f; } - else if(bs->type==RE_BAKE_EMIT) { + else if (bs->type==RE_BAKE_EMIT) { shr.combined[0]= shr.combined[1]= shr.combined[2]= shi->emit; @@ -2156,12 +2156,13 @@ static void bake_shade(void *handle, Object *ob, ShadeInput *shi, int UNUSED(qua } } - if(bs->rect_float) { + if (bs->rect_float) { float *col= bs->rect_float + 4*(bs->rectx*y + x); copy_v3_v3(col, shr.combined); if (bs->type==RE_BAKE_ALL || bs->type==RE_BAKE_TEXTURE) { col[3]= shr.alpha; - } else { + } + else { col[3]= 1.0; } } @@ -2177,7 +2178,8 @@ static void bake_shade(void *handle, Object *ob, ShadeInput *shi, int UNUSED(qua if (ELEM(bs->type, RE_BAKE_ALL, RE_BAKE_TEXTURE)) { col[3]= FTOCHAR(shr.alpha); - } else { + } + else { col[3]= 255; } } @@ -2192,17 +2194,19 @@ static void bake_displacement(void *handle, ShadeInput *UNUSED(shi), float dist, BakeShade *bs= handle; float disp; - if(R.r.bake_flag & R_BAKE_NORMALIZE && R.r.bake_maxdist) { + if (R.r.bake_flag & R_BAKE_NORMALIZE && R.r.bake_maxdist) { disp = (dist+R.r.bake_maxdist) / (R.r.bake_maxdist*2); /* alter the range from [-bake_maxdist, bake_maxdist] to [0, 1]*/ - } else { + } + else { disp = 0.5f + dist; /* alter the range from [-0.5,0.5] to [0,1]*/ } - if(bs->rect_float) { + if (bs->rect_float) { float *col= bs->rect_float + 4*(bs->rectx*y + x); col[0] = col[1] = col[2] = disp; col[3]= 1.0f; - } else { + } + else { char *col= (char *)(bs->rect + bs->rectx*y + x); col[0] = col[1] = col[2] = FTOCHAR(disp); col[3]= 255; @@ -2218,7 +2222,7 @@ static int bake_intersect_tree(RayObject* raytree, Isect* isect, float *start, f int hit; /* might be useful to make a user setting for maxsize*/ - if(R.r.bake_maxdist > 0.0f) + if (R.r.bake_maxdist > 0.0f) maxdist= R.r.bake_maxdist; else maxdist= RE_RAYTRACE_MAXDIST + R.r.bake_biasdist; @@ -2231,7 +2235,7 @@ static int bake_intersect_tree(RayObject* raytree, Isect* isect, float *start, f isect->dist = maxdist; hit = RE_rayobject_raycast(raytree, isect); - if(hit) { + if (hit) { madd_v3_v3v3fl(hitco, isect->start, isect->dir, isect->dist); *dist= isect->dist; @@ -2245,7 +2249,7 @@ static void bake_set_vlr_dxyco(BakeShade *bs, float *uv1, float *uv2, float *uv3 VlakRen *vlr= bs->vlr; float A, d1, d2, d3, *v1, *v2, *v3; - if(bs->quad) { + if (bs->quad) { v1= vlr->v1->co; v2= vlr->v3->co; v3= vlr->v4->co; @@ -2261,7 +2265,7 @@ static void bake_set_vlr_dxyco(BakeShade *bs, float *uv1, float *uv2, float *uv3 * then taking u and v partial derivatives to get dxco and dyco */ A= (uv2[0] - uv1[0])*(uv3[1] - uv1[1]) - (uv3[0] - uv1[0])*(uv2[1] - uv1[1]); - if(fabsf(A) > FLT_EPSILON) { + if (fabsf(A) > FLT_EPSILON) { A= 0.5f/A; d1= uv2[1] - uv3[1]; @@ -2283,7 +2287,7 @@ static void bake_set_vlr_dxyco(BakeShade *bs, float *uv1, float *uv2, float *uv3 bs->dyco[0]= bs->dyco[1]= bs->dyco[2]= 0.0f; } - if(bs->obi->flag & R_TRANSFORMED) { + if (bs->obi->flag & R_TRANSFORMED) { mul_m3_v3(bs->obi->nmat, bs->dxco); mul_m3_v3(bs->obi->nmat, bs->dyco); } @@ -2301,11 +2305,11 @@ static void do_bake_shade(void *handle, int x, int y, float u, float v) ShadeInput *shi= ssamp->shi; /* fast threadsafe break test */ - if(R.test_break(R.tbh)) + if (R.test_break(R.tbh)) return; /* setup render coordinates */ - if(bs->quad) { + if (bs->quad) { v1= vlr->v1->co; v2= vlr->v3->co; v3= vlr->v4->co; @@ -2323,7 +2327,7 @@ static void do_bake_shade(void *handle, int x, int y, float u, float v) shi->co[1]= l*v3[1]+u*v1[1]+v*v2[1]; shi->co[2]= l*v3[2]+u*v1[2]+v*v2[2]; - if(obi->flag & R_TRANSFORMED) + if (obi->flag & R_TRANSFORMED) mul_m4_v3(obi->mat, shi->co); copy_v3_v3(shi->dxco, bs->dxco); @@ -2332,14 +2336,14 @@ static void do_bake_shade(void *handle, int x, int y, float u, float v) quad= bs->quad; bake_set_shade_input(obi, vlr, shi, quad, 0, x, y, u, v); - if(bs->type==RE_BAKE_NORMALS && R.r.bake_normal_space==R_BAKE_SPACE_TANGENT) { + if (bs->type==RE_BAKE_NORMALS && R.r.bake_normal_space==R_BAKE_SPACE_TANGENT) { shade_input_set_shade_texco(shi); copy_v3_v3(tvn, shi->nmapnorm); copy_v4_v4(ttang, shi->nmaptang); } /* if we are doing selected to active baking, find point on other face */ - if(bs->actob) { + if (bs->actob) { Isect isec, minisec; float co[3], minco[3], dist, mindist=0.0f; int hit, sign, dir=1; @@ -2351,7 +2355,7 @@ static void do_bake_shade(void *handle, int x, int y, float u, float v) copy_v3_v3(bs->dir, shi->vn); - for(sign=-1; sign<=1; sign+=2) { + for (sign=-1; sign<=1; sign+=2) { memset(&isec, 0, sizeof(isec)); isec.mode= RE_RAY_MIRROR; @@ -2361,8 +2365,8 @@ static void do_bake_shade(void *handle, int x, int y, float u, float v) isec.check = RE_CHECK_VLR_BAKE; isec.skip = RE_SKIP_VLR_NEIGHBOUR; - if(bake_intersect_tree(R.raytree, &isec, shi->co, shi->vn, sign, co, &dist)) { - if(!hit || len_squared_v3v3(shi->co, co) < len_squared_v3v3(shi->co, minco)) { + if (bake_intersect_tree(R.raytree, &isec, shi->co, shi->vn, sign, co, &dist)) { + if (!hit || len_squared_v3v3(shi->co, co) < len_squared_v3v3(shi->co, minco)) { minisec= isec; mindist= dist; copy_v3_v3(minco, co); @@ -2373,7 +2377,7 @@ static void do_bake_shade(void *handle, int x, int y, float u, float v) } if (bs->type==RE_BAKE_DISPLACEMENT) { - if(hit) + if (hit) bake_displacement(handle, shi, (dir==-1)? mindist:-mindist, x, y); else bake_displacement(handle, shi, 0.0f, x, y); @@ -2381,7 +2385,7 @@ static void do_bake_shade(void *handle, int x, int y, float u, float v) } /* if hit, we shade from the new point, otherwise from point one starting face */ - if(hit) { + if (hit) { obi= (ObjectInstanceRen*)minisec.hit.ob; vlr= (VlakRen*)minisec.hit.face; quad= (minisec.isect == 2); @@ -2393,7 +2397,7 @@ static void do_bake_shade(void *handle, int x, int y, float u, float v) } } - if(bs->type==RE_BAKE_NORMALS && R.r.bake_normal_space==R_BAKE_SPACE_TANGENT) + if (bs->type==RE_BAKE_NORMALS && R.r.bake_normal_space==R_BAKE_SPACE_TANGENT) bake_shade(handle, ob, shi, quad, x, y, u, v, tvn, ttang); else bake_shade(handle, ob, shi, quad, x, y, u, v, 0, 0); @@ -2407,7 +2411,7 @@ static int get_next_bake_face(BakeShade *bs) static int v= 0, vdone= 0; static ObjectInstanceRen *obi= NULL; - if(bs==NULL) { + if (bs==NULL) { vlr= NULL; v= vdone= 0; obi= R.instancetable.first; @@ -2416,44 +2420,44 @@ static int get_next_bake_face(BakeShade *bs) BLI_lock_thread(LOCK_CUSTOM1); - for(; obi; obi=obi->next, v=0) { + for (; obi; obi=obi->next, v=0) { obr= obi->obr; - for(; v<obr->totvlak; v++) { + for (; v<obr->totvlak; v++) { vlr= RE_findOrAddVlak(obr, v); - if((bs->actob && bs->actob == obr->ob) || (!bs->actob && (obr->ob->flag & SELECT))) { + if ((bs->actob && bs->actob == obr->ob) || (!bs->actob && (obr->ob->flag & SELECT))) { tface= RE_vlakren_get_tface(obr, vlr, obr->bakemtface, NULL, 0); - if(tface && tface->tpage) { + if (tface && tface->tpage) { Image *ima= tface->tpage; ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL); 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}; - if(ibuf==NULL) + if (ibuf==NULL) continue; - if(ibuf->rect==NULL && ibuf->rect_float==NULL) + if (ibuf->rect==NULL && ibuf->rect_float==NULL) continue; - if(ibuf->rect_float && !(ibuf->channels==0 || ibuf->channels==4)) + if (ibuf->rect_float && !(ibuf->channels==0 || ibuf->channels==4)) continue; - if(ima->flag & IMA_USED_FOR_RENDER) { + if (ima->flag & IMA_USED_FOR_RENDER) { ima->id.flag &= ~LIB_DOIT; continue; } /* find the image for the first time? */ - if(ima->id.flag & LIB_DOIT) { + if (ima->id.flag & LIB_DOIT) { ima->id.flag &= ~LIB_DOIT; /* we either fill in float or char, this ensures things go fine */ - if(ibuf->rect_float) + if (ibuf->rect_float) imb_freerectImBuf(ibuf); /* clear image */ - if(R.r.bake_flag & R_BAKE_CLEAR) + if (R.r.bake_flag & R_BAKE_CLEAR) IMB_rectfill(ibuf, (ibuf->planes == R_IMF_PLANES_RGBA) ? vec_alpha : vec_solid); /* might be read by UI to set active image for display */ @@ -2489,7 +2493,7 @@ static void shade_tface(BakeShade *bs) int a, i1, i2, i3; /* check valid zspan */ - if(ima!=bs->ima) { + if (ima!=bs->ima) { bs->ima= ima; bs->ibuf= BKE_image_get_ibuf(ima, NULL); /* note, these calls only free/fill contents of zspan struct, not zspan itself */ @@ -2510,13 +2514,14 @@ static void shade_tface(BakeShade *bs) bs->ibuf->userdata = (void *)MEM_callocN(sizeof(char)*bs->rectx*bs->recty, "BakeMask"); bs->rect_mask= (char *)bs->ibuf->userdata; BLI_unlock_thread(LOCK_CUSTOM1); - } else { + } + else { bs->rect_mask= (char *)bs->ibuf->userdata; } } /* get pixel level vertex coordinates */ - for(a=0; a<4; a++) { + for (a=0; a<4; a++) { /* Note, workaround for pixel aligned UVs which are common and can screw up our intersection tests * where a pixel gets in between 2 faces or the middle of a quad, * camera aligned quads also have this problem but they are less common. @@ -2531,7 +2536,7 @@ static void shade_tface(BakeShade *bs) bake_set_vlr_dxyco(bs, vec[i1], vec[i2], vec[i3]); zspan_scanconvert(bs->zspan, bs, vec[i1], vec[i2], vec[i3], do_bake_shade); - if(vlr->v4) { + if (vlr->v4) { bs->quad= 1; bake_set_vlr_dxyco(bs, vec[0], vec[2], vec[3]); zspan_scanconvert(bs->zspan, bs, vec[0], vec[2], vec[3], do_bake_shade); @@ -2542,16 +2547,16 @@ static void *do_bake_thread(void *bs_v) { BakeShade *bs= bs_v; - while(get_next_bake_face(bs)) { + while (get_next_bake_face(bs)) { shade_tface(bs); /* fast threadsafe break test */ - if(R.test_break(R.tbh)) + if (R.test_break(R.tbh)) break; /* access is not threadsafe but since its just true/false probably ok * only used for interactive baking */ - if(bs->do_update) + if (bs->do_update) *bs->do_update= TRUE; } bs->ready= 1; @@ -2565,16 +2570,16 @@ void RE_bake_ibuf_filter(ImBuf *ibuf, char *mask, const int filter) const short is_new_alpha= (ibuf->planes != R_IMF_PLANES_RGBA) && BKE_alphatest_ibuf(ibuf); /* Margin */ - if(filter) { + if (filter) { IMB_filter_extend(ibuf, mask, filter); } /* if the bake results in new alpha then change the image setting */ - if(is_new_alpha) { + if (is_new_alpha) { ibuf->planes= R_IMF_PLANES_RGBA; } else { - if(filter && ibuf->planes != R_IMF_PLANES_RGBA) { + if (filter && ibuf->planes != R_IMF_PLANES_RGBA) { /* clear alpha added by filtering */ IMB_rectfill_alpha(ibuf, 1.0f); } @@ -2603,13 +2608,13 @@ int RE_bake_shade_all_selected(Render *re, int type, Object *actob, short *do_up usemask = 1; /* baker uses this flag to detect if image was initialized */ - for(ima= G.main->image.first; ima; ima= ima->id.next) { + for (ima= G.main->image.first; ima; ima= ima->id.next) { ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL); ima->id.flag |= LIB_DOIT; ima->flag&= ~IMA_USED_FOR_RENDER; - if(ibuf) { + if (ibuf) { ibuf->userdata = NULL; /* use for masking if needed */ - if(ibuf->rect_float) + if (ibuf->rect_float) ibuf->profile = IB_PROFILE_LINEAR_RGB; } } @@ -2619,13 +2624,14 @@ int RE_bake_shade_all_selected(Render *re, int type, Object *actob, short *do_up handles= MEM_callocN(sizeof(BakeShade)*re->r.threads, "BakeShade"); /* get the threads running */ - for(a=0; a<re->r.threads; a++) { + for (a=0; a<re->r.threads; a++) { /* set defaults in handles */ handles[a].ssamp.shi[0].lay= re->lay; if (type==RE_BAKE_SHADOW) { handles[a].ssamp.shi[0].passflag= SCE_PASS_SHADOW; - } else { + } + else { handles[a].ssamp.shi[0].passflag= SCE_PASS_COMBINED; } handles[a].ssamp.shi[0].combinedflag= ~(SCE_PASS_SPEC); @@ -2645,30 +2651,30 @@ int RE_bake_shade_all_selected(Render *re, int type, Object *actob, short *do_up /* wait for everything to be done */ a= 0; - while(a!=re->r.threads) { + while (a!=re->r.threads) { PIL_sleep_ms(50); /* calculate progress */ - for(vdone=0, a=0; a<re->r.threads; a++) + for (vdone=0, a=0; a<re->r.threads; a++) vdone+= handles[a].vdone; if (progress) *progress = (float)(vdone / (float)re->totvlak); - for(a=0; a<re->r.threads; a++) { - if(handles[a].ready==0) + for (a=0; a<re->r.threads; a++) { + if (handles[a].ready==0) break; } } /* filter and refresh images */ - for(ima= G.main->image.first; ima; ima= ima->id.next) { - if((ima->id.flag & LIB_DOIT)==0) { + for (ima= G.main->image.first; ima; ima= ima->id.next) { + if ((ima->id.flag & LIB_DOIT)==0) { ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL); - if(ima->flag & IMA_USED_FOR_RENDER) + if (ima->flag & IMA_USED_FOR_RENDER) result= BAKE_RESULT_FEEDBACK_LOOP; - if(!ibuf) + if (!ibuf) continue; RE_bake_ibuf_filter(ibuf, (char *)ibuf->userdata, re->r.bake_filter); @@ -2679,7 +2685,7 @@ int RE_bake_shade_all_selected(Render *re, int type, Object *actob, short *do_up } /* calculate return value */ - for(a=0; a<re->r.threads; a++) { + for (a=0; a<re->r.threads; a++) { zbuf_free_span(handles[a].zspan); MEM_freeN(handles[a].zspan); } @@ -2688,7 +2694,7 @@ int RE_bake_shade_all_selected(Render *re, int type, Object *actob, short *do_up BLI_end_threads(&threads); - if(vdone==0) + if (vdone==0) result= BAKE_RESULT_NO_OBJECTS; return result; diff --git a/source/blender/render/intern/source/renderdatabase.c b/source/blender/render/intern/source/renderdatabase.c index 81e8b5d73fe..f28931f7b16 100644 --- a/source/blender/render/intern/source/renderdatabase.c +++ b/source/blender/render/intern/source/renderdatabase.c @@ -120,8 +120,8 @@ float *RE_vertren_get_sticky(ObjectRen *obr, VertRen *ver, int verify) int nr= ver->index>>8; sticky= obr->vertnodes[nr].sticky; - if(sticky==NULL) { - if(verify) + if (sticky==NULL) { + if (verify) sticky= obr->vertnodes[nr].sticky= MEM_mallocN(256*RE_STICKY_ELEMS*sizeof(float), "sticky table"); else return NULL; @@ -135,8 +135,8 @@ float *RE_vertren_get_stress(ObjectRen *obr, VertRen *ver, int verify) int nr= ver->index>>8; stress= obr->vertnodes[nr].stress; - if(stress==NULL) { - if(verify) + if (stress==NULL) { + if (verify) stress= obr->vertnodes[nr].stress= MEM_mallocN(256*RE_STRESS_ELEMS*sizeof(float), "stress table"); else return NULL; @@ -151,8 +151,8 @@ float *RE_vertren_get_rad(ObjectRen *obr, VertRen *ver, int verify) int nr= ver->index>>8; rad= obr->vertnodes[nr].rad; - if(rad==NULL) { - if(verify) + if (rad==NULL) { + if (verify) rad= obr->vertnodes[nr].rad= MEM_callocN(256*RE_RAD_ELEMS*sizeof(float), "rad table"); else return NULL; @@ -166,8 +166,8 @@ float *RE_vertren_get_strand(ObjectRen *obr, VertRen *ver, int verify) int nr= ver->index>>8; strand= obr->vertnodes[nr].strand; - if(strand==NULL) { - if(verify) + if (strand==NULL) { + if (verify) strand= obr->vertnodes[nr].strand= MEM_mallocN(256*RE_STRAND_ELEMS*sizeof(float), "strand table"); else return NULL; @@ -182,8 +182,8 @@ float *RE_vertren_get_tangent(ObjectRen *obr, VertRen *ver, int verify) int nr= ver->index>>8; tangent= obr->vertnodes[nr].tangent; - if(tangent==NULL) { - if(verify) + if (tangent==NULL) { + if (verify) tangent= obr->vertnodes[nr].tangent= MEM_callocN(256*RE_TANGENT_ELEMS*sizeof(float), "tangent table"); else return NULL; @@ -199,8 +199,8 @@ float *RE_vertren_get_winspeed(ObjectInstanceRen *obi, VertRen *ver, int verify) int totvector; winspeed= obi->vectors; - if(winspeed==NULL) { - if(verify) { + if (winspeed==NULL) { + if (verify) { totvector= obi->obr->totvert + obi->obr->totstrand; winspeed= obi->vectors= MEM_callocN(totvector*RE_WINSPEED_ELEMS*sizeof(float), "winspeed table"); } @@ -220,27 +220,27 @@ VertRen *RE_vertren_copy(ObjectRen *obr, VertRen *ver) v1->index= index; fp1= RE_vertren_get_sticky(obr, ver, 0); - if(fp1) { + if (fp1) { fp2= RE_vertren_get_sticky(obr, v1, 1); memcpy(fp2, fp1, RE_STICKY_ELEMS*sizeof(float)); } fp1= RE_vertren_get_stress(obr, ver, 0); - if(fp1) { + if (fp1) { fp2= RE_vertren_get_stress(obr, v1, 1); memcpy(fp2, fp1, RE_STRESS_ELEMS*sizeof(float)); } fp1= RE_vertren_get_rad(obr, ver, 0); - if(fp1) { + if (fp1) { fp2= RE_vertren_get_rad(obr, v1, 1); memcpy(fp2, fp1, RE_RAD_ELEMS*sizeof(float)); } fp1= RE_vertren_get_strand(obr, ver, 0); - if(fp1) { + if (fp1) { fp2= RE_vertren_get_strand(obr, v1, 1); memcpy(fp2, fp1, RE_STRAND_ELEMS*sizeof(float)); } fp1= RE_vertren_get_tangent(obr, ver, 0); - if(fp1) { + if (fp1) { fp2= RE_vertren_get_tangent(obr, v1, 1); memcpy(fp2, fp1, RE_TANGENT_ELEMS*sizeof(float)); } @@ -253,7 +253,7 @@ VertRen *RE_findOrAddVert(ObjectRen *obr, int nr) VertRen *v; int a; - if(nr<0) { + if (nr<0) { printf("error in findOrAddVert: %d\n",nr); return NULL; } @@ -263,21 +263,21 @@ VertRen *RE_findOrAddVert(ObjectRen *obr, int nr) temp= obr->vertnodes; obr->vertnodes= MEM_mallocN(sizeof(VertTableNode)*(obr->vertnodeslen+TABLEINITSIZE) , "vertnodes"); - if(temp) memcpy(obr->vertnodes, temp, obr->vertnodeslen*sizeof(VertTableNode)); + if (temp) memcpy(obr->vertnodes, temp, obr->vertnodeslen*sizeof(VertTableNode)); memset(obr->vertnodes+obr->vertnodeslen, 0, TABLEINITSIZE*sizeof(VertTableNode)); obr->vertnodeslen+=TABLEINITSIZE; - if(temp) MEM_freeN(temp); + if (temp) MEM_freeN(temp); } v= obr->vertnodes[a].vert; - if(v==NULL) { + if (v==NULL) { int i; v= (VertRen *)MEM_callocN(256*sizeof(VertRen),"findOrAddVert"); obr->vertnodes[a].vert= v; - for(i= (nr & 0xFFFFFF00), a=0; a<256; a++, i++) { + for (i= (nr & 0xFFFFFF00), a=0; a<256; a++, i++) { v[a].index= i; } } @@ -295,14 +295,14 @@ MTFace *RE_vlakren_get_tface(ObjectRen *obr, VlakRen *vlr, int n, char **name, i node= &obr->vlaknodes[nr]; - if(verify) { - if(n>=node->totmtface) { + if (verify) { + if (n>=node->totmtface) { MTFace *mtface= node->mtface; int size= (n+1)*256; node->mtface= MEM_callocN(size*sizeof(MTFace), "Vlak mtface"); - if(mtface) { + if (mtface) { size= node->totmtface*256; memcpy(node->mtface, mtface, size*sizeof(MTFace)); MEM_freeN(mtface); @@ -312,10 +312,10 @@ MTFace *RE_vlakren_get_tface(ObjectRen *obr, VlakRen *vlr, int n, char **name, i } } else { - if(n>=node->totmtface) + if (n>=node->totmtface) return NULL; - if(name) *name= obr->mtface[n]; + if (name) *name= obr->mtface[n]; } return node->mtface + index; @@ -329,14 +329,14 @@ MCol *RE_vlakren_get_mcol(ObjectRen *obr, VlakRen *vlr, int n, char **name, int node= &obr->vlaknodes[nr]; - if(verify) { - if(n>=node->totmcol) { + if (verify) { + if (n>=node->totmcol) { MCol *mcol= node->mcol; int size= (n+1)*256; node->mcol= MEM_callocN(size*sizeof(MCol)*RE_MCOL_ELEMS, "Vlak mcol"); - if(mcol) { + if (mcol) { size= node->totmcol*256; memcpy(node->mcol, mcol, size*sizeof(MCol)*RE_MCOL_ELEMS); MEM_freeN(mcol); @@ -346,10 +346,10 @@ MCol *RE_vlakren_get_mcol(ObjectRen *obr, VlakRen *vlr, int n, char **name, int } } else { - if(n>=node->totmcol) + if (n>=node->totmcol) return NULL; - if(name) *name= obr->mcol[n]; + if (name) *name= obr->mcol[n]; } return node->mcol + index*RE_MCOL_ELEMS; @@ -361,8 +361,8 @@ float *RE_vlakren_get_surfnor(ObjectRen *obr, VlakRen *vlak, int verify) int nr= vlak->index>>8; surfnor= obr->vlaknodes[nr].surfnor; - if(surfnor==NULL) { - if(verify) + if (surfnor==NULL) { + if (verify) surfnor= obr->vlaknodes[nr].surfnor= MEM_callocN(256*RE_SURFNOR_ELEMS*sizeof(float), "surfnor table"); else return NULL; @@ -376,8 +376,8 @@ float *RE_vlakren_get_nmap_tangent(ObjectRen *obr, VlakRen *vlak, int verify) int nr= vlak->index>>8; tangent= obr->vlaknodes[nr].tangent; - if(tangent==NULL) { - if(verify) + if (tangent==NULL) { + if (verify) tangent= obr->vlaknodes[nr].tangent= MEM_callocN(256*RE_NMAP_TANGENT_ELEMS*sizeof(float), "tangent table"); else return NULL; @@ -391,8 +391,8 @@ RadFace **RE_vlakren_get_radface(ObjectRen *obr, VlakRen *vlak, int verify) int nr= vlak->index>>8; radface= obr->vlaknodes[nr].radface; - if(radface==NULL) { - if(verify) + if (radface==NULL) { + if (verify) radface= obr->vlaknodes[nr].radface= MEM_callocN(256*RE_RADFACE_ELEMS*sizeof(void*), "radface table"); else return NULL; @@ -424,19 +424,19 @@ VlakRen *RE_vlakren_copy(ObjectRen *obr, VlakRen *vlr) } surfnor= RE_vlakren_get_surfnor(obr, vlr, 0); - if(surfnor) { + if (surfnor) { surfnor1= RE_vlakren_get_surfnor(obr, vlr1, 1); copy_v3_v3(surfnor1, surfnor); } tangent= RE_vlakren_get_nmap_tangent(obr, vlr, 0); - if(tangent) { + if (tangent) { tangent1= RE_vlakren_get_nmap_tangent(obr, vlr1, 1); memcpy(tangent1, tangent, sizeof(float)*RE_NMAP_TANGENT_ELEMS); } radface= RE_vlakren_get_radface(obr, vlr, 0); - if(radface) { + if (radface) { radface1= RE_vlakren_get_radface(obr, vlr1, 1); *radface1= *radface; } @@ -448,7 +448,7 @@ void RE_vlakren_get_normal(Render *UNUSED(re), ObjectInstanceRen *obi, VlakRen * { float (*nmat)[3]= obi->nmat; - if(obi->flag & R_TRANSFORMED) { + if (obi->flag & R_TRANSFORMED) { mul_v3_m3v3(nor, nmat, vlr->n); normalize_v3(nor); } @@ -496,32 +496,32 @@ VlakRen *RE_findOrAddVlak(ObjectRen *obr, int nr) VlakRen *v; int a; - if(nr<0) { + if (nr<0) { printf("error in findOrAddVlak: %d\n",nr); return obr->vlaknodes[0].vlak; } a= nr>>8; - if (a>=obr->vlaknodeslen-1){ /* Need to allocate more columns..., and keep last element NULL for free loop */ + if (a>=obr->vlaknodeslen-1) { /* Need to allocate more columns..., and keep last element NULL for free loop */ temp= obr->vlaknodes; obr->vlaknodes= MEM_mallocN(sizeof(VlakTableNode)*(obr->vlaknodeslen+TABLEINITSIZE) , "vlaknodes"); - if(temp) memcpy(obr->vlaknodes, temp, obr->vlaknodeslen*sizeof(VlakTableNode)); + if (temp) memcpy(obr->vlaknodes, temp, obr->vlaknodeslen*sizeof(VlakTableNode)); memset(obr->vlaknodes+obr->vlaknodeslen, 0, TABLEINITSIZE*sizeof(VlakTableNode)); obr->vlaknodeslen+=TABLEINITSIZE; /*Does this really need to be power of 2?*/ - if(temp) MEM_freeN(temp); + if (temp) MEM_freeN(temp); } v= obr->vlaknodes[a].vlak; - if(v==NULL) { + if (v==NULL) { int i; v= (VlakRen *)MEM_callocN(256*sizeof(VlakRen),"findOrAddVlak"); obr->vlaknodes[a].vlak= v; - for(i= (nr & 0xFFFFFF00), a=0; a<256; a++, i++) + for (i= (nr & 0xFFFFFF00), a=0; a<256; a++, i++) v[a].index= i; } v+= (nr & 255); @@ -536,8 +536,8 @@ float *RE_strandren_get_surfnor(ObjectRen *obr, StrandRen *strand, int verify) int nr= strand->index>>8; surfnor= obr->strandnodes[nr].surfnor; - if(surfnor==NULL) { - if(verify) + if (surfnor==NULL) { + if (verify) surfnor= obr->strandnodes[nr].surfnor= MEM_callocN(256*RE_SURFNOR_ELEMS*sizeof(float), "surfnor strand table"); else return NULL; @@ -553,14 +553,14 @@ float *RE_strandren_get_uv(ObjectRen *obr, StrandRen *strand, int n, char **name node= &obr->strandnodes[nr]; - if(verify) { - if(n>=node->totuv) { + if (verify) { + if (n>=node->totuv) { float *uv= node->uv; int size= (n+1)*256; node->uv= MEM_callocN(size*sizeof(float)*RE_UV_ELEMS, "strand uv table"); - if(uv) { + if (uv) { size= node->totuv*256; memcpy(node->uv, uv, size*sizeof(float)*RE_UV_ELEMS); MEM_freeN(uv); @@ -570,10 +570,10 @@ float *RE_strandren_get_uv(ObjectRen *obr, StrandRen *strand, int n, char **name } } else { - if(n>=node->totuv) + if (n>=node->totuv) return NULL; - if(name) *name= obr->mtface[n]; + if (name) *name= obr->mtface[n]; } return node->uv + index*RE_UV_ELEMS; @@ -587,14 +587,14 @@ MCol *RE_strandren_get_mcol(ObjectRen *obr, StrandRen *strand, int n, char **nam node= &obr->strandnodes[nr]; - if(verify) { - if(n>=node->totmcol) { + if (verify) { + if (n>=node->totmcol) { MCol *mcol= node->mcol; int size= (n+1)*256; node->mcol= MEM_callocN(size*sizeof(MCol)*RE_MCOL_ELEMS, "strand mcol table"); - if(mcol) { + if (mcol) { size= node->totmcol*256; memcpy(node->mcol, mcol, size*sizeof(MCol)*RE_MCOL_ELEMS); MEM_freeN(mcol); @@ -604,10 +604,10 @@ MCol *RE_strandren_get_mcol(ObjectRen *obr, StrandRen *strand, int n, char **nam } } else { - if(n>=node->totmcol) + if (n>=node->totmcol) return NULL; - if(name) *name= obr->mcol[n]; + if (name) *name= obr->mcol[n]; } return node->mcol + index*RE_MCOL_ELEMS; @@ -619,8 +619,8 @@ float *RE_strandren_get_simplify(struct ObjectRen *obr, struct StrandRen *strand int nr= strand->index>>8; simplify= obr->strandnodes[nr].simplify; - if(simplify==NULL) { - if(verify) + if (simplify==NULL) { + if (verify) simplify= obr->strandnodes[nr].simplify= MEM_callocN(256*RE_SIMPLIFY_ELEMS*sizeof(float), "simplify strand table"); else return NULL; @@ -634,8 +634,8 @@ int *RE_strandren_get_face(ObjectRen *obr, StrandRen *strand, int verify) int nr= strand->index>>8; face= obr->strandnodes[nr].face; - if(face==NULL) { - if(verify) + if (face==NULL) { + if (verify) face= obr->strandnodes[nr].face= MEM_callocN(256*RE_FACE_ELEMS*sizeof(int), "face strand table"); else return NULL; @@ -650,8 +650,8 @@ float *RE_strandren_get_winspeed(ObjectInstanceRen *obi, StrandRen *strand, int int totvector; winspeed= obi->vectors; - if(winspeed==NULL) { - if(verify) { + if (winspeed==NULL) { + if (verify) { totvector= obi->obr->totvert + obi->obr->totstrand; winspeed= obi->vectors= MEM_callocN(totvector*RE_WINSPEED_ELEMS*sizeof(float), "winspeed strand table"); } @@ -667,32 +667,32 @@ StrandRen *RE_findOrAddStrand(ObjectRen *obr, int nr) StrandRen *v; int a; - if(nr<0) { + if (nr<0) { printf("error in findOrAddStrand: %d\n",nr); return obr->strandnodes[0].strand; } a= nr>>8; - if (a>=obr->strandnodeslen-1){ /* Need to allocate more columns..., and keep last element NULL for free loop */ + if (a>=obr->strandnodeslen-1) { /* Need to allocate more columns..., and keep last element NULL for free loop */ temp= obr->strandnodes; obr->strandnodes= MEM_mallocN(sizeof(StrandTableNode)*(obr->strandnodeslen+TABLEINITSIZE) , "strandnodes"); - if(temp) memcpy(obr->strandnodes, temp, obr->strandnodeslen*sizeof(StrandTableNode)); + if (temp) memcpy(obr->strandnodes, temp, obr->strandnodeslen*sizeof(StrandTableNode)); memset(obr->strandnodes+obr->strandnodeslen, 0, TABLEINITSIZE*sizeof(StrandTableNode)); obr->strandnodeslen+=TABLEINITSIZE; /*Does this really need to be power of 2?*/ - if(temp) MEM_freeN(temp); + if (temp) MEM_freeN(temp); } v= obr->strandnodes[a].strand; - if(v==NULL) { + if (v==NULL) { int i; v= (StrandRen *)MEM_callocN(256*sizeof(StrandRen),"findOrAddStrand"); obr->strandnodes[a].strand= v; - for(i= (nr & 0xFFFFFF00), a=0; a<256; a++, i++) + for (i= (nr & 0xFFFFFF00), a=0; a<256; a++, i++) v[a].index= i; } v+= (nr & 255); @@ -733,22 +733,22 @@ void free_renderdata_vertnodes(VertTableNode *vertnodes) { int a; - if(vertnodes==NULL) return; + if (vertnodes==NULL) return; - for(a=0; vertnodes[a].vert; a++) { + for (a=0; vertnodes[a].vert; a++) { MEM_freeN(vertnodes[a].vert); - if(vertnodes[a].rad) + if (vertnodes[a].rad) MEM_freeN(vertnodes[a].rad); - if(vertnodes[a].sticky) + if (vertnodes[a].sticky) MEM_freeN(vertnodes[a].sticky); - if(vertnodes[a].strand) + if (vertnodes[a].strand) MEM_freeN(vertnodes[a].strand); - if(vertnodes[a].tangent) + if (vertnodes[a].tangent) MEM_freeN(vertnodes[a].tangent); - if(vertnodes[a].stress) + if (vertnodes[a].stress) MEM_freeN(vertnodes[a].stress); - if(vertnodes[a].winspeed) + if (vertnodes[a].winspeed) MEM_freeN(vertnodes[a].winspeed); } @@ -759,20 +759,20 @@ void free_renderdata_vlaknodes(VlakTableNode *vlaknodes) { int a; - if(vlaknodes==NULL) return; + if (vlaknodes==NULL) return; - for(a=0; vlaknodes[a].vlak; a++) { + for (a=0; vlaknodes[a].vlak; a++) { MEM_freeN(vlaknodes[a].vlak); - if(vlaknodes[a].mtface) + if (vlaknodes[a].mtface) MEM_freeN(vlaknodes[a].mtface); - if(vlaknodes[a].mcol) + if (vlaknodes[a].mcol) MEM_freeN(vlaknodes[a].mcol); - if(vlaknodes[a].surfnor) + if (vlaknodes[a].surfnor) MEM_freeN(vlaknodes[a].surfnor); - if(vlaknodes[a].tangent) + if (vlaknodes[a].tangent) MEM_freeN(vlaknodes[a].tangent); - if(vlaknodes[a].radface) + if (vlaknodes[a].radface) MEM_freeN(vlaknodes[a].radface); } @@ -783,22 +783,22 @@ static void free_renderdata_strandnodes(StrandTableNode *strandnodes) { int a; - if(strandnodes==NULL) return; + if (strandnodes==NULL) return; - for(a=0; strandnodes[a].strand; a++) { + for (a=0; strandnodes[a].strand; a++) { MEM_freeN(strandnodes[a].strand); - if(strandnodes[a].uv) + if (strandnodes[a].uv) MEM_freeN(strandnodes[a].uv); - if(strandnodes[a].mcol) + if (strandnodes[a].mcol) MEM_freeN(strandnodes[a].mcol); - if(strandnodes[a].winspeed) + if (strandnodes[a].winspeed) MEM_freeN(strandnodes[a].winspeed); - if(strandnodes[a].surfnor) + if (strandnodes[a].surfnor) MEM_freeN(strandnodes[a].surfnor); - if(strandnodes[a].simplify) + if (strandnodes[a].simplify) MEM_freeN(strandnodes[a].simplify); - if(strandnodes[a].face) + if (strandnodes[a].face) MEM_freeN(strandnodes[a].face); } @@ -812,7 +812,7 @@ void free_renderdata_tables(Render *re) StrandBuffer *strandbuf; int a=0; - for(obr=re->objecttable.first; obr; obr=obr->next) { + for (obr=re->objecttable.first; obr; obr=obr->next) { if (obr->vertnodes) { free_renderdata_vertnodes(obr->vertnodes); obr->vertnodes= NULL; @@ -827,7 +827,7 @@ void free_renderdata_tables(Render *re) } if (obr->bloha) { - for(a=0; obr->bloha[a]; a++) + for (a=0; obr->bloha[a]; a++) MEM_freeN(obr->bloha[a]); MEM_freeN(obr->bloha); @@ -842,9 +842,9 @@ void free_renderdata_tables(Render *re) } strandbuf= obr->strandbuf; - if(strandbuf) { - if(strandbuf->vert) MEM_freeN(strandbuf->vert); - if(strandbuf->bound) MEM_freeN(strandbuf->bound); + if (strandbuf) { + if (strandbuf->vert) MEM_freeN(strandbuf->vert); + if (strandbuf->bound) MEM_freeN(strandbuf->bound); MEM_freeN(strandbuf); } @@ -870,13 +870,13 @@ void free_renderdata_tables(Render *re) } } - if(re->objectinstance) { - for(obi=re->instancetable.first; obi; obi=obi->next) + if (re->objectinstance) { + for (obi=re->instancetable.first; obi; obi=obi->next) { - if(obi->vectors) + if (obi->vectors) MEM_freeN(obi->vectors); - if(obi->raytree) + if (obi->raytree) RE_rayobject_free(obi->raytree); } @@ -886,7 +886,7 @@ void free_renderdata_tables(Render *re) re->instancetable.first= re->instancetable.last= NULL; } - if(re->sortedhalos) { + if (re->sortedhalos) { MEM_freeN(re->sortedhalos); re->sortedhalos= NULL; } @@ -903,26 +903,26 @@ HaloRen *RE_findOrAddHalo(ObjectRen *obr, int nr) HaloRen *h, **temp; int a; - if(nr<0) { + if (nr<0) { printf("error in findOrAddHalo: %d\n",nr); return NULL; } a= nr>>8; - if (a>=obr->blohalen-1){ /* Need to allocate more columns..., and keep last element NULL for free loop */ + if (a>=obr->blohalen-1) { /* Need to allocate more columns..., and keep last element NULL for free loop */ //printf("Allocating %i more halo groups. %i total.\n", // TABLEINITSIZE, obr->blohalen+TABLEINITSIZE ); temp=obr->bloha; obr->bloha=(HaloRen**)MEM_callocN(sizeof(void*)*(obr->blohalen+TABLEINITSIZE) , "Bloha"); - if(temp) memcpy(obr->bloha, temp, obr->blohalen*sizeof(void*)); + if (temp) memcpy(obr->bloha, temp, obr->blohalen*sizeof(void*)); memset(&(obr->bloha[obr->blohalen]), 0, TABLEINITSIZE*sizeof(void*)); obr->blohalen+=TABLEINITSIZE; /*Does this really need to be power of 2?*/ - if(temp) MEM_freeN(temp); + if (temp) MEM_freeN(temp); } h= obr->bloha[a]; - if(h==NULL) { + if (h==NULL) { h= (HaloRen *)MEM_callocN(256*sizeof(HaloRen),"findOrAdHalo"); obr->bloha[a]= h; } @@ -940,13 +940,13 @@ HaloRen *RE_inithalo(Render *re, ObjectRen *obr, Material *ma, float *vec, f float tin, tr, tg, tb, ta; float xn, yn, zn, texvec[3], hoco[4], hoco1[4]; - if(hasize==0.0f) return NULL; + if (hasize==0.0f) return NULL; projectverto(vec, re->winmat, hoco); - if(hoco[3]==0.0f) return NULL; - if(vec1) { + if (hoco[3]==0.0f) return NULL; + if (vec1) { projectverto(vec1, re->winmat, hoco1); - if(hoco1[3]==0.0f) return NULL; + if (hoco1[3]==0.0f) return NULL; } har= RE_findOrAddHalo(obr, obr->tothalo++); @@ -963,13 +963,13 @@ HaloRen *RE_inithalo(Render *re, ObjectRen *obr, Material *ma, float *vec, f har->zBufDist = 0x7FFFFFFF*(hoco[2]/zn); /* halovect */ - if(vec1) { + if (vec1) { har->type |= HA_VECT; xn= har->xs - 0.5f*re->winx*(hoco1[0]/hoco1[3]); yn= har->ys - 0.5f*re->winy*(hoco1[1]/hoco1[3]); - if(xn==0.0f || (xn==0.0f && yn==0.0f)) zn= 0.0f; + if (xn==0.0f || (xn==0.0f && yn==0.0f)) zn= 0.0f; else zn= atan2(yn, xn); har->sin= sin(zn); @@ -982,7 +982,7 @@ HaloRen *RE_inithalo(Render *re, ObjectRen *obr, Material *ma, float *vec, f normalize_v3(har->no); } - if(ma->mode & MA_HALO_XALPHA) har->type |= HA_XALPHA; + if (ma->mode & MA_HALO_XALPHA) har->type |= HA_XALPHA; har->alfa= ma->alpha; har->r= ma->r; @@ -993,32 +993,32 @@ HaloRen *RE_inithalo(Render *re, ObjectRen *obr, Material *ma, float *vec, f har->hard= ma->har; har->seed= seed % 256; - if(ma->mode & MA_STAR) har->starpoints= ma->starc; - if(ma->mode & MA_HALO_LINES) har->linec= ma->linec; - if(ma->mode & MA_HALO_RINGS) har->ringc= ma->ringc; - if(ma->mode & MA_HALO_FLARE) har->flarec= ma->flarec; + if (ma->mode & MA_STAR) har->starpoints= ma->starc; + if (ma->mode & MA_HALO_LINES) har->linec= ma->linec; + if (ma->mode & MA_HALO_RINGS) har->ringc= ma->ringc; + if (ma->mode & MA_HALO_FLARE) har->flarec= ma->flarec; - if(ma->mtex[0]) { + if (ma->mtex[0]) { - if( (ma->mode & MA_HALOTEX) ) har->tex= 1; - else if(har->mat->septex & (1<<0)); /* only 1 level textures */ + if ( (ma->mode & MA_HALOTEX) ) har->tex= 1; + else if (har->mat->septex & (1<<0)); /* only 1 level textures */ else { mtex= ma->mtex[0]; copy_v3_v3(texvec, vec); - if(mtex->texco & TEXCO_NORM) { + if (mtex->texco & TEXCO_NORM) { ; } - else if(mtex->texco & TEXCO_OBJECT) { + else if (mtex->texco & TEXCO_OBJECT) { /* texvec[0]+= imatbase->ivec[0]; */ /* texvec[1]+= imatbase->ivec[1]; */ /* texvec[2]+= imatbase->ivec[2]; */ /* mul_m3_v3(imatbase->imat, texvec); */ } else { - if(orco) { + if (orco) { copy_v3_v3(texvec, orco); } } @@ -1028,16 +1028,16 @@ HaloRen *RE_inithalo(Render *re, ObjectRen *obr, Material *ma, float *vec, f yn= tin*mtex->colfac; //zn= tin*mtex->alphafac; - if(mtex->mapto & MAP_COL) { + if (mtex->mapto & MAP_COL) { zn= 1.0f-yn; har->r= (yn*tr+ zn*ma->r); har->g= (yn*tg+ zn*ma->g); har->b= (yn*tb+ zn*ma->b); } - if(mtex->texco & TEXCO_UV) { + if (mtex->texco & TEXCO_UV) { har->alfa= tin; } - if(mtex->mapto & MAP_ALPHA) + if (mtex->mapto & MAP_ALPHA) har->alfa= tin; } } @@ -1054,13 +1054,13 @@ HaloRen *RE_inithalo_particle(Render *re, ObjectRen *obr, DerivedMesh *dm, Mater float xn, yn, zn, texvec[3], hoco[4], hoco1[4], in[3],tex[3],out[3]; int i, hasrgb; - if(hasize==0.0f) return NULL; + if (hasize==0.0f) return NULL; projectverto(vec, re->winmat, hoco); - if(hoco[3]==0.0f) return NULL; - if(vec1) { + if (hoco[3]==0.0f) return NULL; + if (vec1) { projectverto(vec1, re->winmat, hoco1); - if(hoco1[3]==0.0f) return NULL; + if (hoco1[3]==0.0f) return NULL; } har= RE_findOrAddHalo(obr, obr->tothalo++); @@ -1077,13 +1077,13 @@ HaloRen *RE_inithalo_particle(Render *re, ObjectRen *obr, DerivedMesh *dm, Mater har->zBufDist = 0x7FFFFFFF*(hoco[2]/zn); /* halovect */ - if(vec1) { + if (vec1) { har->type |= HA_VECT; xn= har->xs - 0.5f*re->winx*(hoco1[0]/hoco1[3]); yn= har->ys - 0.5f*re->winy*(hoco1[1]/hoco1[3]); - if(xn==0.0f || (xn==0.0f && yn==0.0f)) zn= 0.0; + if (xn==0.0f || (xn==0.0f && yn==0.0f)) zn= 0.0; else zn= atan2(yn, xn); har->sin= sin(zn); @@ -1096,7 +1096,7 @@ HaloRen *RE_inithalo_particle(Render *re, ObjectRen *obr, DerivedMesh *dm, Mater normalize_v3(har->no); } - if(ma->mode & MA_HALO_XALPHA) har->type |= HA_XALPHA; + if (ma->mode & MA_HALO_XALPHA) har->type |= HA_XALPHA; har->alfa= ma->alpha; har->r= ma->r; @@ -1107,32 +1107,32 @@ HaloRen *RE_inithalo_particle(Render *re, ObjectRen *obr, DerivedMesh *dm, Mater har->hard= ma->har; har->seed= seed % 256; - if(ma->mode & MA_STAR) har->starpoints= ma->starc; - if(ma->mode & MA_HALO_LINES) har->linec= ma->linec; - if(ma->mode & MA_HALO_RINGS) har->ringc= ma->ringc; - if(ma->mode & MA_HALO_FLARE) har->flarec= ma->flarec; + if (ma->mode & MA_STAR) har->starpoints= ma->starc; + if (ma->mode & MA_HALO_LINES) har->linec= ma->linec; + if (ma->mode & MA_HALO_RINGS) har->ringc= ma->ringc; + if (ma->mode & MA_HALO_FLARE) har->flarec= ma->flarec; - if((ma->mode & MA_HALOTEX) && ma->mtex[0]) + if ((ma->mode & MA_HALOTEX) && ma->mtex[0]) har->tex= 1; - for(i=0; i<MAX_MTEX; i++) - if(ma->mtex[i] && (ma->septex & (1<<i))==0) { + for (i=0; i<MAX_MTEX; i++) + if (ma->mtex[i] && (ma->septex & (1<<i))==0) { mtex= ma->mtex[i]; copy_v3_v3(texvec, vec); - if(mtex->texco & TEXCO_NORM) { + if (mtex->texco & TEXCO_NORM) { ; } - else if(mtex->texco & TEXCO_OBJECT) { - if(mtex->object) + else if (mtex->texco & TEXCO_OBJECT) { + if (mtex->object) mul_m4_v3(mtex->object->imat_ren,texvec); } - else if(mtex->texco & TEXCO_GLOB){ + else if (mtex->texco & TEXCO_GLOB) { copy_v3_v3(texvec,vec); } - else if(mtex->texco & TEXCO_UV && uvco){ + else if (mtex->texco & TEXCO_UV && uvco) { int uv_index=CustomData_get_named_layer_index(&dm->faceData,CD_MTFACE,mtex->uvname); - if(uv_index<0) + if (uv_index<0) uv_index=CustomData_get_active_layer_index(&dm->faceData,CD_MTFACE); uv_index-=CustomData_get_layer_index(&dm->faceData,CD_MTFACE); @@ -1141,13 +1141,13 @@ HaloRen *RE_inithalo_particle(Render *re, ObjectRen *obr, DerivedMesh *dm, Mater texvec[1]=2.0f*uvco[2*uv_index+1]-1.0f; texvec[2]=0.0f; } - else if(mtex->texco & TEXCO_PARTICLE) { + else if (mtex->texco & TEXCO_PARTICLE) { /* particle coordinates in range [0,1] */ texvec[0] = 2.f * pa_co[0] - 1.f; texvec[1] = 2.f * pa_co[1] - 1.f; texvec[2] = pa_co[2]; } - else if(orco) { + else if (orco) { copy_v3_v3(texvec, orco); } @@ -1155,7 +1155,7 @@ HaloRen *RE_inithalo_particle(Render *re, ObjectRen *obr, DerivedMesh *dm, Mater //yn= tin*mtex->colfac; //zn= tin*mtex->alphafac; - if(mtex->mapto & MAP_COL) { + if (mtex->mapto & MAP_COL) { tex[0]=tr; tex[1]=tg; tex[2]=tb; @@ -1174,16 +1174,16 @@ HaloRen *RE_inithalo_particle(Render *re, ObjectRen *obr, DerivedMesh *dm, Mater } /* alpha returned, so let's use it instead of intensity */ - if(hasrgb) + if (hasrgb) tin = ta; - if(mtex->mapto & MAP_ALPHA) + if (mtex->mapto & MAP_ALPHA) har->alfa = texture_value_blend(mtex->def_var,har->alfa,tin,mtex->alphafac,mtex->blendtype); - if(mtex->mapto & MAP_HAR) + if (mtex->mapto & MAP_HAR) har->hard = 1.0f+126.0f*texture_value_blend(mtex->def_var,((float)har->hard)/127.0f,tin,mtex->hardfac,mtex->blendtype); - if(mtex->mapto & MAP_RAYMIRR) + if (mtex->mapto & MAP_RAYMIRR) har->hasize = 100.0f*texture_value_blend(mtex->def_var,har->hasize/100.0f,tin,mtex->raymirrfac,mtex->blendtype); - if(mtex->mapto & MAP_TRANSLU) { + if (mtex->mapto & MAP_TRANSLU) { float add = texture_value_blend(mtex->def_var,(float)har->add/255.0f,tin,mtex->translfac,mtex->blendtype); CLAMP(add, 0.f, 1.f); har->add = 255.0f*add; @@ -1206,19 +1206,19 @@ static int panotestclip(Render *re, int do_pano, float *v) float abs4; short c=0; - if(do_pano==0) return testclip(v); + if (do_pano==0) return testclip(v); abs4= fabs(v[3]); - if(v[2]< -abs4) c=16; /* this used to be " if(v[2]<0) ", see clippz() */ - else if(v[2]> abs4) c+= 32; + if (v[2]< -abs4) c=16; /* this used to be " if(v[2]<0) ", see clippz() */ + else if (v[2]> abs4) c+= 32; - if( v[1]>abs4) c+=4; - else if( v[1]< -abs4) c+=8; + if ( v[1]>abs4) c+=4; + else if ( v[1]< -abs4) c+=8; abs4*= re->xparts; - if( v[0]>abs4) c+=2; - else if( v[0]< -abs4) c+=1; + if ( v[0]>abs4) c+=2; + else if ( v[0]< -abs4) c+=1; return c; } @@ -1240,20 +1240,20 @@ void project_renderdata(Render *re, void (*projectfunc)(const float *, float mat float zn, vec[3], hoco[4]; int a; - if(do_pano) { + if (do_pano) { float panophi= xoffs; re->panosi= sin(panophi); re->panoco= cos(panophi); } - for(obr=re->objecttable.first; obr; obr=obr->next) { + for (obr=re->objecttable.first; obr; obr=obr->next) { /* calculate view coordinates (and zbuffer value) */ - for(a=0; a<obr->tothalo; a++) { - if((a & 255)==0) har= obr->bloha[a>>8]; + for (a=0; a<obr->tothalo; a++) { + if ((a & 255)==0) har= obr->bloha[a>>8]; else har++; - if(do_pano) { + if (do_pano) { vec[0]= re->panoco*har->co[0] + re->panosi*har->co[2]; vec[1]= har->co[1]; vec[2]= -re->panosi*har->co[0] + re->panoco*har->co[2]; @@ -1268,10 +1268,10 @@ void project_renderdata(Render *re, void (*projectfunc)(const float *, float mat hoco[0]*= 0.5f; hoco[1]*= 0.5f; - if( panotestclip(re, do_pano, hoco) ) { + if ( panotestclip(re, do_pano, hoco) ) { har->miny= har->maxy= -10000; /* that way render clips it */ } - else if(hoco[3]<0.0f) { + else if (hoco[3]<0.0f) { har->miny= har->maxy= -10000; /* render clips it */ } else /* do the projection...*/ @@ -1296,8 +1296,8 @@ void project_renderdata(Render *re, void (*projectfunc)(const float *, float mat har->rad= fabsf(har->xs- 0.5f*re->winx*(1.0f+hoco[0]/zn)); /* this clip is not really OK, to prevent stars to become too large */ - if(har->type & HA_ONLYSKY) { - if(har->rad>3.0f) har->rad= 3.0f; + if (har->type & HA_ONLYSKY) { + if (har->rad>3.0f) har->rad= 3.0f; } har->radsq= har->rad*har->rad; @@ -1334,7 +1334,7 @@ ObjectInstanceRen *RE_addRenderInstance(Render *re, ObjectRen *obr, Object *ob, obi->psysindex= psysindex; obi->lay= lay; - if(mat) { + if (mat) { copy_m4_m4(obi->mat, mat); copy_m3_m4(mat3, mat); invert_m3_m3(obi->nmat, mat3); @@ -1360,10 +1360,10 @@ void RE_makeRenderInstances(Render *re) newlist.first= newlist.last= NULL; obi= re->objectinstance; - for(oldobi=re->instancetable.first; oldobi; oldobi=oldobi->next) { + for (oldobi=re->instancetable.first; oldobi; oldobi=oldobi->next) { *obi= *oldobi; - if(obi->obr) { + if (obi->obr) { obi->prev= obi->next= NULL; BLI_addtail(&newlist, obi); obi++; @@ -1383,7 +1383,7 @@ int clip_render_object(float boundbox[][3], float *bounds, float winmat[][4]) copy_m4_m4(mat, winmat); - for(a=0; a<8; a++) { + for (a=0; a<8; a++) { vec[0]= (a & 1)? boundbox[0][0]: boundbox[1][0]; vec[1]= (a & 2)? boundbox[0][1]: boundbox[1][1]; vec[2]= (a & 4)? boundbox[0][2]: boundbox[1][2]; @@ -1391,25 +1391,25 @@ int clip_render_object(float boundbox[][3], float *bounds, float winmat[][4]) mul_m4_v4(mat, vec); fl= 0; - if(bounds) { - if(vec[0] < bounds[0]*vec[3]) fl |= 1; - else if(vec[0] > bounds[1]*vec[3]) fl |= 2; + if (bounds) { + if (vec[0] < bounds[0]*vec[3]) fl |= 1; + else if (vec[0] > bounds[1]*vec[3]) fl |= 2; - if(vec[1] > bounds[3]*vec[3]) fl |= 4; - else if(vec[1]< bounds[2]*vec[3]) fl |= 8; + if (vec[1] > bounds[3]*vec[3]) fl |= 4; + else if (vec[1]< bounds[2]*vec[3]) fl |= 8; } else { - if(vec[0] < -vec[3]) fl |= 1; - else if(vec[0] > vec[3]) fl |= 2; + if (vec[0] < -vec[3]) fl |= 1; + else if (vec[0] > vec[3]) fl |= 2; - if(vec[1] > vec[3]) fl |= 4; - else if(vec[1] < -vec[3]) fl |= 8; + if (vec[1] > vec[3]) fl |= 4; + else if (vec[1] < -vec[3]) fl |= 8; } - if(vec[2] < -vec[3]) fl |= 16; - else if(vec[2] > vec[3]) fl |= 32; + if (vec[2] < -vec[3]) fl |= 16; + else if (vec[2] > vec[3]) fl |= 32; flag &= fl; - if(flag==0) return 0; + if (flag==0) return 0; } return flag; diff --git a/source/blender/render/intern/source/shadbuf.c b/source/blender/render/intern/source/shadbuf.c index 49e331cc44c..25705a9fc99 100644 --- a/source/blender/render/intern/source/shadbuf.c +++ b/source/blender/render/intern/source/shadbuf.c @@ -91,14 +91,14 @@ static void copy_to_ztile(int *rectz, int size, int x1, int y1, int tile, char * x2= x1+tile; y2= y1+tile; - if(x2>=size) x2= size-1; - if(y2>=size) y2= size-1; + if (x2>=size) x2= size-1; + if (y2>=size) y2= size-1; - if(x1>=x2 || y1>=y2) return; + if (x1>=x2 || y1>=y2) return; len4= 4*(x2- x1); rz= rectz + size*y1 + x1; - for(; y1<y2; y1++) { + for (; y1<y2; y1++) { memcpy(r1, rz, len4); rz+= size; r1+= len4; @@ -132,12 +132,12 @@ static float *give_jitter_tab(int samp) static char ctab[17]= {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; int a, offset=0; - if(samp<2) samp= 2; - else if(samp>16) samp= 16; + if (samp<2) samp= 2; + else if (samp>16) samp= 16; - for(a=0; a<samp-1; a++) offset+= tab[a]; + for (a=0; a<samp-1; a++) offset+= tab[a]; - if(ctab[samp]==0) { + if (ctab[samp]==0) { ctab[samp]= 1; BLI_initjit(jit[offset], samp*samp); } @@ -154,10 +154,10 @@ static void make_jitter_weight_tab(Render *re, ShadBuf *shb, short filtertype) shb->weight= MEM_mallocN(sizeof(float)*tot, "weight tab lamp"); - for(jit= shb->jit, a=0; a<tot; a++, jit+=2) { - if(filtertype==LA_SHADBUF_TENT) + for (jit= shb->jit, a=0; a<tot; a++, jit+=2) { + if (filtertype==LA_SHADBUF_TENT) shb->weight[a]= 0.71f - sqrt(jit[0]*jit[0] + jit[1]*jit[1]); - else if(filtertype==LA_SHADBUF_GAUSS) + else if (filtertype==LA_SHADBUF_GAUSS) shb->weight[a]= RE_filter_value(R_FILTER_GAUSS, 1.8f*sqrt(jit[0]*jit[0] + jit[1]*jit[1])); else shb->weight[a]= 1.0f; @@ -166,7 +166,7 @@ static void make_jitter_weight_tab(Render *re, ShadBuf *shb, short filtertype) } totw= 1.0f/totw; - for(a=0; a<tot; a++) { + for (a=0; a<tot; a++) { shb->weight[a]*= totw; } } @@ -176,8 +176,8 @@ static int verg_deepsample(const void *poin1, const void *poin2) const DeepSample *ds1= (const DeepSample*)poin1; const DeepSample *ds2= (const DeepSample*)poin2; - if(ds1->z < ds2->z) return -1; - else if(ds1->z == ds2->z) return 0; + if (ds1->z < ds2->z) return -1; + else if (ds1->z == ds2->z) return 0; else return 1; } @@ -191,8 +191,8 @@ static int compress_deepsamples(DeepSample *dsample, int tot, float epsilon) int a, first, z, newtot= 0; #if 0 - if(print) { - for(a=0, ds=dsample; a<tot; a++, ds++) + if (print) { + for (a=0, ds=dsample; a<tot; a++, ds++) printf("%lf,%f ", ds->z/(double)0x7FFFFFFF, ds->v); printf("\n"); } @@ -204,17 +204,17 @@ static int compress_deepsamples(DeepSample *dsample, int tot, float epsilon) a= 0; /* as long as we are not at the end of the array */ - for(a++, ds++; a<tot; a++, ds++) { + for (a++, ds++; a<tot; a++, ds++) { slopemin= 0.0f; slopemax= 0.0f; first= 1; - for(; a<tot; a++, ds++) { + for (; a<tot; a++, ds++) { //dz= ds->z - newds->z; - if(ds->z == newds->z) { + if (ds->z == newds->z) { /* still in same z position, simply check * visibility difference against epsilon */ - if(!(fabs(newds->v - ds->v) <= epsilon)) { + if (!(fabs(newds->v - ds->v) <= epsilon)) { break; } } @@ -225,7 +225,7 @@ static int compress_deepsamples(DeepSample *dsample, int tot, float epsilon) max= ((ds->v + epsilon) - newds->v)*div; /* adapt existing slopes */ - if(first) { + if (first) { newmin= min; newmax= max; first= 0; @@ -235,7 +235,7 @@ static int compress_deepsamples(DeepSample *dsample, int tot, float epsilon) newmax= MIN2(slopemax, max); /* verify if there is still space between the slopes */ - if(newmin > newmax) { + if (newmin > newmax) { ds--; a--; break; @@ -247,7 +247,7 @@ static int compress_deepsamples(DeepSample *dsample, int tot, float epsilon) } } - if(a == tot) { + if (a == tot) { ds--; a--; } @@ -255,7 +255,7 @@ static int compress_deepsamples(DeepSample *dsample, int tot, float epsilon) /* always previous z */ z= ds->z; - if(first || a==tot-1) { + if (first || a==tot-1) { /* if slopes were not initialized, use last visibility */ v= ds->v; } @@ -272,12 +272,12 @@ static int compress_deepsamples(DeepSample *dsample, int tot, float epsilon) newds->v= v; } - if(newtot == 0 || (newds->v != (newds-1)->v)) + if (newtot == 0 || (newds->v != (newds-1)->v)) newtot++; #if 0 - if(print) { - for(a=0, ds=dsample; a<newtot; a++, ds++) + if (print) { + for (a=0, ds=dsample; a<newtot; a++, ds++) printf("%lf,%f ", ds->z/(double)0x7FFFFFFF, ds->v); printf("\n"); } @@ -291,7 +291,7 @@ static float deep_alpha(Render *re, int obinr, int facenr, int strand) ObjectInstanceRen *obi= &re->objectinstance[obinr]; Material *ma; - if(strand) { + if (strand) { StrandRen *strand= RE_findOrAddStrand(obi->obr, facenr-1); ma= strand->buffer->ma; } @@ -327,32 +327,32 @@ static void compress_deepshadowbuf(Render *re, ShadBuf *shb, APixstr *apixbuf, A ap= apixbuf; aps= apixbufstrand; - for(a=0; a<size*size; a++, ap++, aps++) { + for (a=0; a<size*size; a++, ap++, aps++) { /* count number of samples */ - for(c=0; c<totbuf; c++) + for (c=0; c<totbuf; c++) sampletot[c]= 0; tot= 0; - for(apn=ap; apn; apn=apn->next) - for(b=0; b<4; b++) - if(apn->p[b]) - for(c=0; c<totbuf; c++) - if(apn->mask[b] & (1<<c)) + for (apn=ap; apn; apn=apn->next) + for (b=0; b<4; b++) + if (apn->p[b]) + for (c=0; c<totbuf; c++) + if (apn->mask[b] & (1<<c)) sampletot[c]++; - if(apixbufstrand) { - for(apns=aps; apns; apns=apns->next) - for(b=0; b<4; b++) - if(apns->p[b]) - for(c=0; c<totbuf; c++) - if(apns->mask[b] & (1<<c)) + if (apixbufstrand) { + for (apns=aps; apns; apns=apns->next) + for (b=0; b<4; b++) + if (apns->p[b]) + for (c=0; c<totbuf; c++) + if (apns->mask[b] & (1<<c)) sampletot[c]++; } - for(c=0; c<totbuf; c++) + for (c=0; c<totbuf; c++) tot += sampletot[c]; - if(tot == 0) { + if (tot == 0) { shsample->deepbuf[a]= NULL; shsample->totbuf[a]= 0; continue; @@ -360,14 +360,14 @@ static void compress_deepshadowbuf(Render *re, ShadBuf *shb, APixstr *apixbuf, A /* fill samples */ ds[0]= sampleds[0]= MEM_callocN(sizeof(DeepSample)*tot*2, "deepsample"); - for(c=1; c<totbuf; c++) + for (c=1; c<totbuf; c++) ds[c]= sampleds[c]= sampleds[c-1] + sampletot[c-1]*2; - for(apn=ap; apn; apn=apn->next) { - for(b=0; b<4; b++) { - if(apn->p[b]) { - for(c=0; c<totbuf; c++) { - if(apn->mask[b] & (1<<c)) { + for (apn=ap; apn; apn=apn->next) { + for (b=0; b<4; b++) { + if (apn->p[b]) { + for (c=0; c<totbuf; c++) { + if (apn->mask[b] & (1<<c)) { /* two entries to create step profile */ ds[c]->z= apn->z[b]; ds[c]->v= 1.0f; /* not used */ @@ -381,12 +381,12 @@ static void compress_deepshadowbuf(Render *re, ShadBuf *shb, APixstr *apixbuf, A } } - if(apixbufstrand) { - for(apns=aps; apns; apns=apns->next) { - for(b=0; b<4; b++) { - if(apns->p[b]) { - for(c=0; c<totbuf; c++) { - if(apns->mask[b] & (1<<c)) { + if (apixbufstrand) { + for (apns=aps; apns; apns=apns->next) { + for (b=0; b<4; b++) { + if (apns->p[b]) { + for (c=0; c<totbuf; c++) { + if (apns->mask[b] & (1<<c)) { /* two entries to create step profile */ ds[c]->z= apns->z[b]; ds[c]->v= 1.0f; /* not used */ @@ -401,7 +401,7 @@ static void compress_deepshadowbuf(Render *re, ShadBuf *shb, APixstr *apixbuf, A } } - for(c=0; c<totbuf; c++) { + for (c=0; c<totbuf; c++) { /* sort by increasing z */ qsort(sampleds[c], sampletot[c], sizeof(DeepSample)*2, verg_deepsample); @@ -409,7 +409,7 @@ static void compress_deepshadowbuf(Render *re, ShadBuf *shb, APixstr *apixbuf, A visibility= 1.0f; ds[c]= sampleds[c]; - for(b=0; b<sampletot[c]; b++) { + for (b=0; b<sampletot[c]; b++) { /* two entries creating step profile */ ds[c]->v= visibility; ds[c]++; @@ -421,8 +421,8 @@ static void compress_deepshadowbuf(Render *re, ShadBuf *shb, APixstr *apixbuf, A /* halfway trick, probably won't work well for volumes? */ ds[c]= sampleds[c]; - for(b=0; b<sampletot[c]; b++) { - if(b+1 < sampletot[c]) { + for (b=0; b<sampletot[c]; b++) { + if (b+1 < sampletot[c]) { ds[c]->z= (ds[c]->z>>1) + ((ds[c]+2)->z>>1); ds[c]++; ds[c]->z= (ds[c]->z>>1) + ((ds[c]+2)->z>>1); @@ -450,27 +450,27 @@ static void compress_deepshadowbuf(Render *re, ShadBuf *shb, APixstr *apixbuf, A minz= 0; found= 0; - for(c=0; c<totbuf; c++) { - if(sampletot[c] && (!found || ds[c]->z < minz)) { + for (c=0; c<totbuf; c++) { + if (sampletot[c] && (!found || ds[c]->z < minz)) { minz= ds[c]->z; found= 1; } } - if(!found) + if (!found) break; dsb->z= minz; dsb->v= 0.0f; visibility= 0.0f; - for(c=0; c<totbuf; c++) { - if(sampletot[c] && ds[c]->z == minz) { + for (c=0; c<totbuf; c++) { + if (sampletot[c] && ds[c]->z == minz) { ds[c]++; sampletot[c]--; } - if(sampleds[c] == ds[c]) + if (sampleds[c] == ds[c]) visibility += totbuf_f_inv; else visibility += (ds[c]-1)->v / totbuf_f; @@ -488,7 +488,7 @@ static void compress_deepshadowbuf(Render *re, ShadBuf *shb, APixstr *apixbuf, A shsample->totbuf[a]= newtot; totsamplec += newtot; - if(newtot < prevtot) { + if (newtot < prevtot) { newbuf= MEM_mallocN(sizeof(DeepSample)*newtot, "cdeepsample"); memcpy(newbuf, shsample->deepbuf[a], sizeof(DeepSample)*newtot); MEM_freeN(shsample->deepbuf[a]); @@ -523,20 +523,20 @@ static void compress_shadowbuf(ShadBuf *shb, int *rectz, int square) /* help buffer */ rcline= MEM_mallocN(256*4+sizeof(int), "makeshadbuf2"); - for(y=0; y<size; y+=16) { - if(y< size/2) miny= y+15-size/2; + for (y=0; y<size; y+=16) { + if (y< size/2) miny= y+15-size/2; else miny= y-size/2; - for(x=0; x<size; x+=16) { + for (x=0; x<size; x+=16) { /* is tile within spotbundle? */ a= size/2; - if(x< a) minx= x+15-a; + if (x< a) minx= x+15-a; else minx= x-a; dist= sqrt( (float)(minx*minx+miny*miny) ); - if(square==0 && dist>(float)(a+12)) { /* 12, tested with a onlyshadow lamp */ + if (square==0 && dist>(float)(a+12)) { /* 12, tested with a onlyshadow lamp */ a= 256; verg= 0; /* 0x80000000; */ /* 0x7FFFFFFF; */ rz1= (&verg)+1; } @@ -546,11 +546,11 @@ static void compress_shadowbuf(ShadBuf *shb, int *rectz, int square) verg= (*rz1 & 0xFFFFFF00); - for(a=0;a<256;a++,rz1++) { - if( (*rz1 & 0xFFFFFF00) !=verg) break; + for (a=0;a<256;a++,rz1++) { + if ( (*rz1 & 0xFFFFFF00) !=verg) break; } } - if(a==256) { /* complete empty tile */ + if (a==256) { /* complete empty tile */ *ctile= 0; *ztile= *(rz1-1); } @@ -564,13 +564,13 @@ static void compress_shadowbuf(ShadBuf *shb, int *rectz, int square) verg1= rc[BCOMP]; rc+= 4; byt1= 1; byt2= 1; - for(a=1;a<256;a++,rc+=4) { + for (a=1;a<256;a++,rc+=4) { byt1 &= (verg==rc[ACOMP]); byt2 &= (verg1==rc[BCOMP]); - if(byt1==0) break; + if (byt1==0) break; } - if(byt1 && byt2) { /* only store byte */ + if (byt1 && byt2) { /* only store byte */ *ctile= 1; *ztile= (uintptr_t)MEM_mallocN(256+4, "tile1"); rz= (int *)*ztile; @@ -578,9 +578,9 @@ static void compress_shadowbuf(ShadBuf *shb, int *rectz, int square) zt= (char *)(rz+1); rc= rcline; - for(a=0; a<256; a++, zt++, rc+=4) *zt= rc[GCOMP]; + for (a=0; a<256; a++, zt++, rc+=4) *zt= rc[GCOMP]; } - else if(byt1) { /* only store short */ + else if (byt1) { /* only store short */ *ctile= 2; *ztile= (uintptr_t)MEM_mallocN(2*256+4,"Tile2"); rz= (int *)*ztile; @@ -588,7 +588,7 @@ static void compress_shadowbuf(ShadBuf *shb, int *rectz, int square) zt= (char *)(rz+1); rc= rcline; - for(a=0; a<256; a++, zt+=2, rc+=4) { + for (a=0; a<256; a++, zt+=2, rc+=4) { zt[0]= rc[BCOMP]; zt[1]= rc[GCOMP]; } @@ -599,7 +599,7 @@ static void compress_shadowbuf(ShadBuf *shb, int *rectz, int square) zt= (char *)*ztile; rc= rcline; - for(a=0; a<256; a++, zt+=3, rc+=4) { + for (a=0; a<256; a++, zt+=3, rc+=4) { zt[0]= rc[ACOMP]; zt[1]= rc[BCOMP]; zt[2]= rc[GCOMP]; @@ -630,19 +630,19 @@ static void shadowbuf_autoclip(Render *re, LampRen *lar) minz= 1.0e30f; maxz= -1.0e30f; copy_m4_m4(viewmat, lar->shb->viewmat); - if(lar->mode & (LA_LAYER|LA_LAYER_SHADOW)) lay= lar->lay; + if (lar->mode & (LA_LAYER|LA_LAYER_SHADOW)) lay= lar->lay; maxtotvert= 0; - for(obr=re->objecttable.first; obr; obr=obr->next) + for (obr=re->objecttable.first; obr; obr=obr->next) maxtotvert= MAX2(obr->totvert, maxtotvert); clipflag= MEM_callocN(sizeof(char)*maxtotvert, "autoclipflag"); /* set clip in vertices when face visible */ - for(i=0, obi=re->instancetable.first; obi; i++, obi=obi->next) { + for (i=0, obi=re->instancetable.first; obi; i++, obi=obi->next) { obr= obi->obr; - if(obi->flag & R_TRANSFORMED) + if (obi->flag & R_TRANSFORMED) mult_m4_m4m4(obviewmat, viewmat, obi->mat); else copy_m4_m4(obviewmat, viewmat); @@ -650,35 +650,35 @@ static void shadowbuf_autoclip(Render *re, LampRen *lar) memset(clipflag, 0, sizeof(char)*obr->totvert); /* clear clip, is being set if face is visible (clip is calculated for real later) */ - for(a=0; a<obr->totvlak; a++) { - if((a & 255)==0) vlr= obr->vlaknodes[a>>8].vlak; + for (a=0; a<obr->totvlak; a++) { + if ((a & 255)==0) vlr= obr->vlaknodes[a>>8].vlak; else vlr++; /* note; these conditions are copied from zbuffer_shadow() */ - if(vlr->mat!= ma) { + if (vlr->mat!= ma) { ma= vlr->mat; ok= 1; - if((ma->mode & MA_SHADBUF)==0) ok= 0; + if ((ma->mode & MA_SHADBUF)==0) ok= 0; } - if(ok && (obi->lay & lay)) { + if (ok && (obi->lay & lay)) { clipflag[vlr->v1->index]= 1; clipflag[vlr->v2->index]= 1; clipflag[vlr->v3->index]= 1; - if(vlr->v4) clipflag[vlr->v4->index]= 1; + if (vlr->v4) clipflag[vlr->v4->index]= 1; } } /* calculate min and max */ - for(a=0; a< obr->totvert;a++) { - if((a & 255)==0) ver= RE_findOrAddVert(obr, a); + for (a=0; a< obr->totvert;a++) { + if ((a & 255)==0) ver= RE_findOrAddVert(obr, a); else ver++; - if(clipflag[a]) { + if (clipflag[a]) { copy_v3_v3(vec, ver->co); mul_m4_v3(obviewmat, vec); /* Z on visible side of lamp space */ - if(vec[2] < 0.0f) { + if (vec[2] < 0.0f) { float inpr, z= -vec[2]; /* since vec is rotated in lampspace, this is how to get the cosine of angle */ @@ -687,9 +687,9 @@ static void shadowbuf_autoclip(Render *re, LampRen *lar) normalize_v3(vec); inpr= - vec[2]; - if(inpr>=lar->spotsi) { - if(z<minz) minz= z; - if(z>maxz) maxz= z; + if (inpr>=lar->spotsi) { + if (z<minz) minz= z; + if (z>maxz) maxz= z; } } } @@ -699,13 +699,13 @@ static void shadowbuf_autoclip(Render *re, LampRen *lar) MEM_freeN(clipflag); /* set clipping min and max */ - if(minz < maxz) { + if (minz < maxz) { float delta= (maxz - minz); /* threshold to prevent precision issues */ //printf("minz %f maxz %f delta %f\n", minz, maxz, delta); - if(lar->bufflag & LA_SHADBUF_AUTO_START) + if (lar->bufflag & LA_SHADBUF_AUTO_START) lar->shb->d= minz - delta*0.02f; /* 0.02 is arbitrary... needs more thinking! */ - if(lar->bufflag & LA_SHADBUF_AUTO_END) + if (lar->bufflag & LA_SHADBUF_AUTO_END) lar->shb->clipend= maxz + delta*0.1f; /* bias was calculated as percentage, we scale it to prevent animation issues */ @@ -723,12 +723,12 @@ static void makeflatshadowbuf(Render *re, LampRen *lar, float *jitbuf) /* zbuffering */ rectz= MEM_mapallocN(sizeof(int)*shb->size*shb->size, "makeshadbuf"); - for(samples=0; samples<shb->totbuf; samples++) { + for (samples=0; samples<shb->totbuf; samples++) { zbuffer_shadow(re, shb->persmat, lar, rectz, shb->size, jitbuf[2*samples], jitbuf[2*samples+1]); /* create Z tiles (for compression): this system is 24 bits!!! */ compress_shadowbuf(shb, rectz, lar->mode & LA_SQUARE); - if(re->test_break(re->tbh)) + if (re->test_break(re->tbh)) break; } @@ -744,7 +744,7 @@ static void makedeepshadowbuf(Render *re, LampRen *lar, float *jitbuf) /* zbuffering */ apixbuf= MEM_callocN(sizeof(APixstr)*shb->size*shb->size, "APixbuf"); - if(re->totstrand) + if (re->totstrand) apixbufstrand= MEM_callocN(sizeof(APixstrand)*shb->size*shb->size, "APixbufstrand"); zbuffer_abuf_shadow(re, lar, shb->persmat, apixbuf, apixbufstrand, &apsmbase, shb->size, @@ -754,7 +754,7 @@ static void makedeepshadowbuf(Render *re, LampRen *lar, float *jitbuf) compress_deepshadowbuf(re, shb, apixbuf, apixbufstrand); MEM_freeN(apixbuf); - if(apixbufstrand) + if (apixbufstrand) MEM_freeN(apixbufstrand); freepsA(&apsmbase); } @@ -764,11 +764,11 @@ void makeshadowbuf(Render *re, LampRen *lar) ShadBuf *shb= lar->shb; float wsize, *jitbuf, twozero[2]= {0.0f, 0.0f}, angle, temp; - if(lar->bufflag & (LA_SHADBUF_AUTO_START|LA_SHADBUF_AUTO_END)) + if (lar->bufflag & (LA_SHADBUF_AUTO_START|LA_SHADBUF_AUTO_END)) shadowbuf_autoclip(re, lar); /* just to enforce identical behavior of all irregular buffers */ - if(lar->buftype==LA_SHADBUF_IRREGULAR) + if (lar->buftype==LA_SHADBUF_IRREGULAR) shb->size= 1024; /* matrices and window: in winmat the transformation is being put, @@ -782,7 +782,7 @@ void makeshadowbuf(Render *re, LampRen *lar) perspective_m4( shb->winmat,-wsize, wsize, -wsize, wsize, shb->d, shb->clipend); mult_m4_m4m4(shb->persmat, shb->winmat, shb->viewmat); - if(ELEM3(lar->buftype, LA_SHADBUF_REGULAR, LA_SHADBUF_HALFWAY, LA_SHADBUF_DEEP)) { + if (ELEM3(lar->buftype, LA_SHADBUF_REGULAR, LA_SHADBUF_HALFWAY, LA_SHADBUF_DEEP)) { shb->totbuf= lar->buffers; /* jitter, weights - not threadsafe! */ @@ -791,12 +791,12 @@ void makeshadowbuf(Render *re, LampRen *lar) make_jitter_weight_tab(re, shb, lar->filtertype); BLI_unlock_thread(LOCK_CUSTOM1); - if(shb->totbuf==4) jitbuf= give_jitter_tab(2); - else if(shb->totbuf==9) jitbuf= give_jitter_tab(3); + if (shb->totbuf==4) jitbuf= give_jitter_tab(2); + else if (shb->totbuf==9) jitbuf= give_jitter_tab(3); else jitbuf= twozero; /* zbuffering */ - if(lar->buftype == LA_SHADBUF_DEEP) { + if (lar->buftype == LA_SHADBUF_DEEP) { makedeepshadowbuf(re, lar, jitbuf); shb->totbuf= 1; } @@ -814,8 +814,8 @@ static void *do_shadow_thread(void *re_v) do { BLI_lock_thread(LOCK_CUSTOM1); - for(lar=re->lampren.first; lar; lar=lar->next) { - if(lar->shb && !lar->thread_assigned) { + for (lar=re->lampren.first; lar; lar=lar->next) { + if (lar->shb && !lar->thread_assigned) { lar->thread_assigned= 1; break; } @@ -823,7 +823,7 @@ static void *do_shadow_thread(void *re_v) BLI_unlock_thread(LOCK_CUSTOM1); /* if type is irregular, this only sets the perspective matrix and autoclips */ - if(lar) { + if (lar) { makeshadowbuf(re, lar); BLI_lock_thread(LOCK_CUSTOM1); lar->thread_ready= 1; @@ -848,9 +848,9 @@ void threaded_makeshadowbufs(Render *re) int (*test_break)(void *); /* count number of threads to use */ - if(G.rendering) { - for(lar=re->lampren.first; lar; lar= lar->next) - if(lar->shb) + if (G.rendering) { + for (lar=re->lampren.first; lar; lar= lar->next) + if (lar->shb) totthread++; totthread= MIN2(totthread, re->r.threads); @@ -858,10 +858,10 @@ void threaded_makeshadowbufs(Render *re) else totthread= 1; /* preview render */ - if(totthread <= 1) { - for(lar=re->lampren.first; lar; lar= lar->next) { - if(re->test_break(re->tbh)) break; - if(lar->shb) { + if (totthread <= 1) { + for (lar=re->lampren.first; lar; lar= lar->next) { + if (re->test_break(re->tbh)) break; + if (lar->shb) { /* if type is irregular, this only sets the perspective matrix and autoclips */ makeshadowbuf(re, lar); } @@ -872,26 +872,26 @@ void threaded_makeshadowbufs(Render *re) test_break= re->test_break; re->test_break= thread_break; - for(lar=re->lampren.first; lar; lar= lar->next) { + for (lar=re->lampren.first; lar; lar= lar->next) { lar->thread_assigned= 0; lar->thread_ready= 0; } BLI_init_threads(&threads, do_shadow_thread, totthread); - for(a=0; a<totthread; a++) + for (a=0; a<totthread; a++) BLI_insert_thread(&threads, re); /* keep rendering as long as there are shadow buffers not ready */ do { - if((g_break=test_break(re->tbh))) + if ((g_break=test_break(re->tbh))) break; PIL_sleep_ms(50); BLI_lock_thread(LOCK_CUSTOM1); - for(lar=re->lampren.first; lar; lar= lar->next) - if(lar->shb && !lar->thread_ready) + for (lar=re->lampren.first; lar; lar= lar->next) + if (lar->shb && !lar->thread_ready) break; BLI_unlock_thread(LOCK_CUSTOM1); } while(lar); @@ -906,16 +906,16 @@ void threaded_makeshadowbufs(Render *re) void freeshadowbuf(LampRen *lar) { - if(lar->shb) { + if (lar->shb) { ShadBuf *shb= lar->shb; ShadSampleBuf *shsample; int b, v; - for(shsample= shb->buffers.first; shsample; shsample= shsample->next) { - if(shsample->deepbuf) { + for (shsample= shb->buffers.first; shsample; shsample= shsample->next) { + if (shsample->deepbuf) { v= shb->size*shb->size; - for(b=0; b<v; b++) - if(shsample->deepbuf[b]) + for (b=0; b<v; b++) + if (shsample->deepbuf[b]) MEM_freeN(shsample->deepbuf[b]); MEM_freeN(shsample->deepbuf); @@ -926,8 +926,8 @@ void freeshadowbuf(LampRen *lar) char *ctile= shsample->cbuf; v= (shb->size*shb->size)/256; - for(b=0; b<v; b++, ztile++, ctile++) - if(*ctile) MEM_freeN((void *) *ztile); + for (b=0; b<v; b++, ztile++, ctile++) + if (*ctile) MEM_freeN((void *) *ztile); MEM_freeN(shsample->zbuf); MEM_freeN(shsample->cbuf); @@ -935,7 +935,7 @@ void freeshadowbuf(LampRen *lar) } BLI_freelistN(&shb->buffers); - if(shb->weight) MEM_freeN(shb->weight); + if (shb->weight) MEM_freeN(shb->weight); MEM_freeN(lar->shb); lar->shb= NULL; @@ -949,22 +949,22 @@ static int firstreadshadbuf(ShadBuf *shb, ShadSampleBuf *shsample, int **rz, int int ofs; char *ct; - if(shsample->deepbuf) + if (shsample->deepbuf) return 0; /* always test borders of shadowbuffer */ - if(xs<0) xs= 0; else if(xs>=shb->size) xs= shb->size-1; - if(ys<0) ys= 0; else if(ys>=shb->size) ys= shb->size-1; + if (xs<0) xs= 0; else if (xs>=shb->size) xs= shb->size-1; + if (ys<0) ys= 0; else if (ys>=shb->size) ys= shb->size-1; /* calc z */ ofs= (ys>>4)*(shb->size>>4) + (xs>>4); ct= shsample->cbuf+ofs; - if(*ct==0) { - if(nr==0) { + if (*ct==0) { + if (nr==0) { *rz= *( (int **)(shsample->zbuf+ofs) ); return 1; } - else if(*rz!= *( (int **)(shsample->zbuf+ofs) )) return 0; + else if (*rz!= *( (int **)(shsample->zbuf+ofs) )) return 0; return 1; } @@ -983,21 +983,21 @@ static float readdeepvisibility(DeepSample *dsample, int tot, int z, int bias, f ds= dsample; for (a=0; a<tot && (z-bias > ds->z); a++, ds++) {} - if(a == tot) { - if(biast) + if (a == tot) { + if (biast) *biast= 0.0f; return (ds-1)->v; /* completely behind all samples */ } /* check if this read needs bias blending */ - if(biast) { - if(z > ds->z) + if (biast) { + if (z > ds->z) *biast= (float)(z - ds->z)/(float)bias; else *biast= 0.0f; } - if(a == 0) + if (a == 0) return 1.0f; /* completely in front of all samples */ /* converting to float early here because ds->z - prevds->z can overflow */ @@ -1011,18 +1011,18 @@ static float readdeepshadowbuf(ShadBuf *shb, ShadSampleBuf *shsample, int bias, float v, biasv, biast; int ofs, tot; - if(zs < - 0x7FFFFE00 + bias) + if (zs < - 0x7FFFFE00 + bias) return 1.0; /* extreme close to clipstart */ /* calc z */ ofs= ys*shb->size + xs; tot= shsample->totbuf[ofs]; - if(tot == 0) + if (tot == 0) return 1.0f; v= readdeepvisibility(shsample->deepbuf[ofs], tot, zs, bias, &biast); - if(biast != 0.0f) { + if (biast != 0.0f) { /* in soft bias area */ biasv= readdeepvisibility(shsample->deepbuf[ofs], tot, zs, 0, 0); @@ -1046,10 +1046,10 @@ static float readshadowbuf(ShadBuf *shb, ShadSampleBuf *shsample, int bias, int /* if(xs>=shb->size || ys>=shb->size) return 1.0; */ /* always test borders of shadowbuffer */ - if(xs<0) xs= 0; else if(xs>=shb->size) xs= shb->size-1; - if(ys<0) ys= 0; else if(ys>=shb->size) ys= shb->size-1; + if (xs<0) xs= 0; else if (xs>=shb->size) xs= shb->size-1; + if (ys<0) ys= 0; else if (ys>=shb->size) ys= shb->size-1; - if(shsample->deepbuf) + if (shsample->deepbuf) return readdeepshadowbuf(shb, shsample, bias, xs, ys, zs); /* calc z */ @@ -1057,14 +1057,14 @@ static float readshadowbuf(ShadBuf *shb, ShadSampleBuf *shsample, int bias, int ct= shsample->cbuf+ofs; rz= *( (int **)(shsample->zbuf+ofs) ); - if(*ct==3) { + if (*ct==3) { ct= ((char *)rz)+3*16*(ys & 15)+3*(xs & 15); cz= (char *)&zsamp; cz[ACOMP]= ct[0]; cz[BCOMP]= ct[1]; cz[GCOMP]= ct[2]; } - else if(*ct==2) { + else if (*ct==2) { ct= ((char *)rz); ct+= 4+2*16*(ys & 15)+2*(xs & 15); zsamp= *rz; @@ -1073,7 +1073,7 @@ static float readshadowbuf(ShadBuf *shb, ShadSampleBuf *shsample, int bias, int cz[BCOMP]= ct[0]; cz[GCOMP]= ct[1]; } - else if(*ct==1) { + else if (*ct==1) { ct= ((char *)rz); ct+= 4+16*(ys & 15)+(xs & 15); zsamp= *rz; @@ -1090,9 +1090,9 @@ static float readshadowbuf(ShadBuf *shb, ShadSampleBuf *shsample, int bias, int /* tricky stuff here; we use ints which can overflow easily with bias values */ - if(zsamp > zs) return 1.0; /* absolute no shadow */ - else if(zs < - 0x7FFFFE00 + bias) return 1.0; /* extreme close to clipstart */ - else if(zsamp < zs-bias) return 0.0 ; /* absolute in shadow */ + if (zsamp > zs) return 1.0; /* absolute no shadow */ + else if (zs < - 0x7FFFFE00 + bias) return 1.0; /* extreme close to clipstart */ + else if (zsamp < zs-bias) return 0.0; /* absolute in shadow */ else { /* soft area */ temp= ( (float)(zs- zsamp) )/(float)bias; @@ -1112,7 +1112,7 @@ static void shadowbuf_project_co(float *x, float *y, float *z, ShadBuf *shb, con *x= size*(1.0f+hco[0]/hco[3]); *y= size*(1.0f+hco[1]/hco[3]); - if(z) *z= (hco[2]/hco[3]); + if (z) *z= (hco[2]/hco[3]); } /* the externally called shadow testing (reading) function */ @@ -1126,11 +1126,11 @@ float testshadowbuf(Render *re, ShadBuf *shb, const float co[3], const float dxc short a, num; /* crash preventer */ - if(shb->buffers.first==NULL) + if (shb->buffers.first==NULL) return 1.0f; /* when facing away, assume fully in shadow */ - if(inp <= 0.0f) + if (inp <= 0.0f) return 0.0f; /* project coordinate to pixel space */ @@ -1138,9 +1138,9 @@ float testshadowbuf(Render *re, ShadBuf *shb, const float co[3], const float dxc /* clip z coordinate, z is projected so that (-1.0, 1.0) matches * (clipstart, clipend), so we can do this simple test */ - if(zs1>=1.0f) + if (zs1>=1.0f) return 0.0f; - else if(zs1<= -1.0f) + else if (zs1<= -1.0f) return 1.0f; zs= ((float)0x7FFFFFFF)*zs1; @@ -1151,15 +1151,15 @@ float testshadowbuf(Render *re, ShadBuf *shb, const float co[3], const float dxc fac= shb->soft; /* compute z bias */ - if(mat_bias!=0.0f) biasf= shb->bias*mat_bias; + if (mat_bias!=0.0f) biasf= shb->bias*mat_bias; else biasf= shb->bias; /* with inp==1.0, bias is half the size. correction value was 1.1, giving errors * on cube edges, with one side being almost frontal lighted (ton) */ bias= (1.5f-inp*inp)*biasf; /* in case of no filtering we can do things simpler */ - if(num==1) { - for(shsample= shb->buffers.first; shsample; shsample= shsample->next) + if (num==1) { + for (shsample= shb->buffers.first; shsample; shsample= shsample->next) shadfac += readshadowbuf(shb, shsample, bias, (int)xs1, (int)ys1, zs); return shadfac/(float)shb->totbuf; @@ -1178,20 +1178,20 @@ float testshadowbuf(Render *re, ShadBuf *shb, const float co[3], const float dxc xres= fac*(fabs(dx[0]) + fabs(dy[0])); yres= fac*(fabs(dx[1]) + fabs(dy[1])); - if(xres<1.0f) xres= 1.0f; - if(yres<1.0f) yres= 1.0f; + if (xres<1.0f) xres= 1.0f; + if (yres<1.0f) yres= 1.0f; /* make xs1/xs1 corner of sample area */ xs1 -= xres*0.5f; ys1 -= yres*0.5f; /* in case we have a constant value in a tile, we can do quicker lookup */ - if(xres<16.0f && yres<16.0f) { + if (xres<16.0f && yres<16.0f) { shsample= shb->buffers.first; - if(firstreadshadbuf(shb, shsample, &rz, (int)xs1, (int)ys1, 0)) { - if(firstreadshadbuf(shb, shsample, &rz, (int)(xs1+xres), (int)ys1, 1)) { - if(firstreadshadbuf(shb, shsample, &rz, (int)xs1, (int)(ys1+yres), 1)) { - if(firstreadshadbuf(shb, shsample, &rz, (int)(xs1+xres), (int)(ys1+yres), 1)) { + if (firstreadshadbuf(shb, shsample, &rz, (int)xs1, (int)ys1, 0)) { + if (firstreadshadbuf(shb, shsample, &rz, (int)(xs1+xres), (int)ys1, 1)) { + if (firstreadshadbuf(shb, shsample, &rz, (int)xs1, (int)(ys1+yres), 1)) { + if (firstreadshadbuf(shb, shsample, &rz, (int)(xs1+xres), (int)(ys1+yres), 1)) { return readshadowbuf(shb, shsample, bias,(int)xs1, (int)ys1, zs); } } @@ -1200,11 +1200,11 @@ float testshadowbuf(Render *re, ShadBuf *shb, const float co[3], const float dxc } /* full jittered shadow buffer lookup */ - for(shsample= shb->buffers.first; shsample; shsample= shsample->next) { + for (shsample= shb->buffers.first; shsample; shsample= shsample->next) { jit= shb->jit; weight= shb->weight; - for(a=num; a>0; a--, jit+=2, weight++) { + for (a=num; a>0; a--, jit+=2, weight++) { /* instead of jit i tried random: ugly! */ /* note: the plus 0.5 gives best sampling results, jit goes from -0.5 to 0.5 */ /* xs1 and ys1 are already corrected to be corner of sample area */ @@ -1232,15 +1232,15 @@ static float readshadowbuf_halo(ShadBuf *shb, ShadSampleBuf *shsample, int xs, i bias= -shb->bias; /* simpleclip */ - if(xs<0 || ys<0) return 0.0; - if(xs>=shb->size || ys>=shb->size) return 0.0; + if (xs<0 || ys<0) return 0.0; + if (xs>=shb->size || ys>=shb->size) return 0.0; /* calc z */ ofs= (ys>>4)*(shb->size>>4) + (xs>>4); ct= shsample->cbuf+ofs; rz= *( (int **)(shsample->zbuf+ofs) ); - if(*ct==3) { + if (*ct==3) { ct= ((char *)rz)+3*16*(ys & 15)+3*(xs & 15); cz= (char *)&zsamp; zsamp= 0; @@ -1248,7 +1248,7 @@ static float readshadowbuf_halo(ShadBuf *shb, ShadSampleBuf *shsample, int xs, i cz[BCOMP]= ct[1]; cz[GCOMP]= ct[2]; } - else if(*ct==2) { + else if (*ct==2) { ct= ((char *)rz); ct+= 4+2*16*(ys & 15)+2*(xs & 15); zsamp= *rz; @@ -1257,7 +1257,7 @@ static float readshadowbuf_halo(ShadBuf *shb, ShadSampleBuf *shsample, int xs, i cz[BCOMP]= ct[0]; cz[GCOMP]= ct[1]; } - else if(*ct==1) { + else if (*ct==1) { ct= ((char *)rz); ct+= 4+16*(ys & 15)+(xs & 15); zsamp= *rz; @@ -1274,16 +1274,16 @@ static float readshadowbuf_halo(ShadBuf *shb, ShadSampleBuf *shsample, int xs, i /* NO schadow when sampled at 'eternal' distance */ - if(zsamp >= 0x7FFFFE00) return 1.0; + if (zsamp >= 0x7FFFFE00) return 1.0; - if(zsamp > zs) return 1.0; /* absolute no shadww */ + if (zsamp > zs) return 1.0; /* absolute no shadww */ else { /* bias is negative, so the (zs-bias) can be beyond 0x7fffffff */ zbias= 0x7fffffff - zs; - if(zbias > -bias) { - if( zsamp < zs-bias) return 0.0 ; /* absolute in shadow */ + if (zbias > -bias) { + if ( zsamp < zs-bias) return 0.0; /* absolute in shadow */ } - else return 0.0 ; /* absolute shadow */ + else return 0.0; /* absolute shadow */ } /* soft area */ @@ -1331,8 +1331,8 @@ float shadow_halo(LampRen *lar, const float p1[3], const float p2[3]) xs1= (int)xf1; ys1= (int)yf1; - if(xf1 != xf2) { - if(xf2-xf1 > 0.0f) { + if (xf1 != xf2) { + if (xf2-xf1 > 0.0f) { labdax= (xf1-xs1-1.0f)/(xf1-xf2); ldx= -shb->shadhalostep/(xf1-xf2); dx= shb->shadhalostep; @@ -1348,8 +1348,8 @@ float shadow_halo(LampRen *lar, const float p1[3], const float p2[3]) ldx= 0.0; } - if(yf1 != yf2) { - if(yf2-yf1 > 0.0f) { + if (yf1 != yf2) { + if (yf2-yf1 > 0.0f) { labday= (yf1-ys1-1.0f)/(yf1-yf2); ldy= -shb->shadhalostep/(yf1-yf2); dy= shb->shadhalostep; @@ -1374,42 +1374,43 @@ float shadow_halo(LampRen *lar, const float p1[3], const float p2[3]) while(1) { labdao= labda; - if(labdax==labday) { + if (labdax==labday) { labdax+= ldx; x+= dx; labday+= ldy; y+= dy; } else { - if(labdax<labday) { + if (labdax<labday) { labdax+= ldx; x+= dx; - } else { + } + else { labday+= ldy; y+= dy; } } labda= MIN2(labdax, labday); - if(labda==labdao || labda>=1.0f) break; + if (labda==labdao || labda>=1.0f) break; zf= zf1 + labda*(zf2-zf1); count+= (float)shb->totbuf; - if(zf<= -1.0f) lightcount += 1.0f; /* close to the spot */ + if (zf<= -1.0f) lightcount += 1.0f; /* close to the spot */ else { /* make sure, behind the clipend we extend halolines. */ - if(zf>=1.0f) z= 0x7FFFF000; + if (zf>=1.0f) z= 0x7FFFF000; else z= (int)(0x7FFFF000*zf); - for(shsample= shb->buffers.first; shsample; shsample= shsample->next) + for (shsample= shb->buffers.first; shsample; shsample= shsample->next) lightcount+= readshadowbuf_halo(shb, shsample, x, y, z); } } - if(count!=0.0f) return (lightcount/count); + if (count!=0.0f) return (lightcount/count); return 0.0f; } @@ -1473,21 +1474,21 @@ static void init_box(Boxf *box) /* use v1 to calculate boundbox */ static void bound_boxf(Boxf *box, const float v1[3]) { - if(v1[0] < box->xmin) box->xmin = v1[0]; - if(v1[0] > box->xmax) box->xmax = v1[0]; - if(v1[1] < box->ymin) box->ymin = v1[1]; - if(v1[1] > box->ymax) box->ymax = v1[1]; - if(v1[2] < box->zmin) box->zmin= v1[2]; - if(v1[2] > box->zmax) box->zmax= v1[2]; + if (v1[0] < box->xmin) box->xmin = v1[0]; + if (v1[0] > box->xmax) box->xmax = v1[0]; + if (v1[1] < box->ymin) box->ymin = v1[1]; + if (v1[1] > box->ymax) box->ymax = v1[1]; + if (v1[2] < box->zmin) box->zmin= v1[2]; + if (v1[2] > box->zmax) box->zmax= v1[2]; } /* use v1 to calculate boundbox */ static void bound_rectf(rctf *box, const float v1[2]) { - if(v1[0] < box->xmin) box->xmin = v1[0]; - if(v1[0] > box->xmax) box->xmax = v1[0]; - if(v1[1] < box->ymin) box->ymin = v1[1]; - if(v1[1] > box->ymax) box->ymax = v1[1]; + if (v1[0] < box->xmin) box->xmin = v1[0]; + if (v1[0] > box->xmax) box->xmax = v1[0]; + if (v1[1] < box->ymin) box->ymin = v1[1]; + if (v1[1] > box->ymax) box->ymax = v1[1]; } @@ -1496,7 +1497,7 @@ static void isb_bsp_split_init(ISBBranch *root, MemArena *mem, int level) { /* if level > 0 we create new branches and go deeper*/ - if(level > 0) { + if (level > 0) { ISBBranch *left, *right; int i; @@ -1505,7 +1506,7 @@ static void isb_bsp_split_init(ISBBranch *root, MemArena *mem, int level) root->divider[1]= 0.5f*(root->box.ymin+root->box.ymax); /* find best splitpoint */ - if(root->box.xmax-root->box.xmin > root->box.ymax-root->box.ymin) + if (root->box.xmax-root->box.xmin > root->box.ymax-root->box.ymin) i= root->index= 0; else i= root->index= 1; @@ -1516,7 +1517,7 @@ static void isb_bsp_split_init(ISBBranch *root, MemArena *mem, int level) /* box info */ left->box= root->box; right->box= root->box; - if(i==0) { + if (i==0) { left->box.xmax = root->divider[0]; right->box.xmin = root->divider[0]; } @@ -1542,7 +1543,7 @@ static void isb_bsp_split(ISBBranch *root, MemArena *mem) /* splitpoint */ root->divider[0]= root->divider[1]= 0.0f; - for(a=BSPMAX_SAMPLE-1; a>=0; a--) { + for (a=BSPMAX_SAMPLE-1; a>=0; a--) { root->divider[0]+= root->samples[a]->zco[0]; root->divider[1]+= root->samples[a]->zco[1]; } @@ -1550,7 +1551,7 @@ static void isb_bsp_split(ISBBranch *root, MemArena *mem) root->divider[1]/= BSPMAX_SAMPLE; /* find best splitpoint */ - if(root->box.xmax-root->box.xmin > root->box.ymax-root->box.ymin) + if (root->box.xmax-root->box.xmin > root->box.ymax-root->box.ymin) i= root->index= 0; else i= root->index= 1; @@ -1564,15 +1565,15 @@ static void isb_bsp_split(ISBBranch *root, MemArena *mem) right->samples= samples; // tmp /* split samples */ - for(a=BSPMAX_SAMPLE-1; a>=0; a--) { + for (a=BSPMAX_SAMPLE-1; a>=0; a--) { int comp= 0; /* this prevents adding samples all to 1 branch when divider is equal to samples */ - if(root->samples[a]->zco[i] == root->divider[i]) + if (root->samples[a]->zco[i] == root->divider[i]) comp= a & 1; - else if(root->samples[a]->zco[i] < root->divider[i]) + else if (root->samples[a]->zco[i] < root->divider[i]) comp= 1; - if(comp==1) { + if (comp==1) { left->samples[left->totsamp]= root->samples[a]; left->totsamp++; } @@ -1590,7 +1591,7 @@ static void isb_bsp_split(ISBBranch *root, MemArena *mem) /* box info */ left->box= root->box; right->box= root->box; - if(i==0) { + if (i==0) { left->box.xmax = root->divider[0]; right->box.xmin = root->divider[0]; } @@ -1613,7 +1614,7 @@ static int isb_bsp_insert(ISBBranch *root, MemArena *memarena, ISBSample *sample /* going over branches until last one found */ while(bspn->left) { - if(zco[bspn->index] <= bspn->divider[bspn->index]) + if (zco[bspn->index] <= bspn->divider[bspn->index]) bspn= bspn->left; else bspn= bspn->right; @@ -1621,7 +1622,7 @@ static int isb_bsp_insert(ISBBranch *root, MemArena *memarena, ISBSample *sample } /* bspn now is the last branch */ - if(bspn->totsamp==BSPMAX_SAMPLE) { + if (bspn->totsamp==BSPMAX_SAMPLE) { printf("error in bsp branch\n"); /* only for debug, cannot happen */ return 1; } @@ -1631,8 +1632,8 @@ static int isb_bsp_insert(ISBBranch *root, MemArena *memarena, ISBSample *sample bspn->totsamp++; /* split if allowed and needed */ - if(bspn->totsamp==BSPMAX_SAMPLE) { - if(i==BSPMAX_DEPTH) { + if (bspn->totsamp==BSPMAX_SAMPLE) { + if (i==BSPMAX_DEPTH) { bspn->totsamp--; /* stop filling in... will give errors */ return 1; } @@ -1648,7 +1649,7 @@ static void bspface_init_strand(BSPFace *face) face->radline= 0.5f* len_v2v2(face->v1, face->v2); mid_v3_v3v3(face->vec1, face->v1, face->v2); - if(face->v4) + if (face->v4) mid_v3_v3v3(face->vec2, face->v3, face->v4); else copy_v3_v3(face->vec2, face->v3); @@ -1659,7 +1660,7 @@ static void bspface_init_strand(BSPFace *face) face->len= face->rc[0]*face->rc[0]+ face->rc[1]*face->rc[1]; - if(face->len!=0.0f) { + if (face->len!=0.0f) { face->radline_end= face->radline/sqrt(face->len); face->len= 1.0f/face->len; } @@ -1673,18 +1674,18 @@ static int point_behind_strand(const float p[3], BSPFace *face) /* using code from dist_to_line_segment_v2(), distance vec to line-piece */ - if(face->len==0.0f) { + if (face->len==0.0f) { rc[0]= p[0]-face->vec1[0]; rc[1]= p[1]-face->vec1[1]; dist= (float)(sqrt(rc[0]*rc[0]+ rc[1]*rc[1])); - if(dist < face->radline) + if (dist < face->radline) return 1; } else { float labda= ( face->rc[0]*(p[0]-face->vec1[0]) + face->rc[1]*(p[1]-face->vec1[1]) )*face->len; - if(labda > -face->radline_end && labda < 1.0f+face->radline_end) { + if (labda > -face->radline_end && labda < 1.0f+face->radline_end) { /* hesse for dist: */ //dist= (float)(fabs( (p[0]-vec2[0])*rc[1] + (p[1]-vec2[1])*rc[0])/len); @@ -1695,9 +1696,9 @@ static int point_behind_strand(const float p[3], BSPFace *face) rc[1]= pt[1]-p[1]; dist= (float)sqrt(rc[0]*rc[0]+ rc[1]*rc[1]); - if(dist < face->radline) { + if (dist < face->radline) { float zval= face->vec1[2] + labda*face->rc[2]; - if(p[2] > zval) + if (p[2] > zval) return 1; } } @@ -1718,7 +1719,7 @@ static int point_behind_tria2d(const float p[3], const float v1[3], const float c[1] = v3[1] - v1[1]; div = a[0]*c[1] - a[1]*c[0]; - if(div==0.0f) + if (div==0.0f) return 0; h[0] = p[0] - v1[0]; @@ -1727,13 +1728,13 @@ static int point_behind_tria2d(const float p[3], const float v1[3], const float div = 1.0f/div; u = (h[0]*c[1] - h[1]*c[0])*div; - if(u >= 0.0f) { + if (u >= 0.0f) { v = (a[0]*h[1] - a[1]*h[0])*div; - if(v >= 0.0f) { - if( u + v <= 1.0f) { + if (v >= 0.0f) { + if ( u + v <= 1.0f) { /* inside, now check if point p is behind */ float z= (1.0f-u-v)*v1[2] + u*v2[2] + v*v3[2]; - if(z <= p[2]) + if (z <= p[2]) return 1; } } @@ -1758,10 +1759,10 @@ static int rect_outside_line(rctf *rect, const float v1[3], const float v2[3], c side= a*v3[0] + b*v3[1] + c < 0.0f; /* the four quad points */ - if( side==(rect->xmin*a + rect->ymin*b + c >= 0.0f) ) - if( side==(rect->xmax*a + rect->ymin*b + c >= 0.0f) ) - if( side==(rect->xmax*a + rect->ymax*b + c >= 0.0f) ) - if( side==(rect->xmin*a + rect->ymax*b + c >= 0.0f) ) + if ( side==(rect->xmin*a + rect->ymin*b + c >= 0.0f) ) + if ( side==(rect->xmax*a + rect->ymin*b + c >= 0.0f) ) + if ( side==(rect->xmax*a + rect->ymax*b + c >= 0.0f) ) + if ( side==(rect->xmin*a + rect->ymax*b + c >= 0.0f) ) return 1; return 0; } @@ -1769,11 +1770,11 @@ static int rect_outside_line(rctf *rect, const float v1[3], const float v2[3], c /* check if one of the triangle edges separates all rect points on 1 side */ static int rect_isect_tria(rctf *rect, const float v1[3], const float v2[3], const float v3[3]) { - if(rect_outside_line(rect, v1, v2, v3)) + if (rect_outside_line(rect, v1, v2, v3)) return 0; - if(rect_outside_line(rect, v2, v3, v1)) + if (rect_outside_line(rect, v2, v3, v1)) return 0; - if(rect_outside_line(rect, v3, v1, v2)) + if (rect_outside_line(rect, v3, v1, v2)) return 0; return 1; } @@ -1784,18 +1785,18 @@ static void isb_bsp_face_inside(ISBBranch *bspn, BSPFace *face) { /* are we descending? */ - if(bspn->left) { + if (bspn->left) { /* hrmf, the box struct cannot be addressed with index */ - if(bspn->index==0) { - if(face->box.xmin <= bspn->divider[0]) + if (bspn->index==0) { + if (face->box.xmin <= bspn->divider[0]) isb_bsp_face_inside(bspn->left, face); - if(face->box.xmax > bspn->divider[0]) + if (face->box.xmax > bspn->divider[0]) isb_bsp_face_inside(bspn->right, face); } else { - if(face->box.ymin <= bspn->divider[1]) + if (face->box.ymin <= bspn->divider[1]) isb_bsp_face_inside(bspn->left, face); - if(face->box.ymax > bspn->divider[1]) + if (face->box.ymax > bspn->divider[1]) isb_bsp_face_inside(bspn->right, face); } } @@ -1803,42 +1804,42 @@ static void isb_bsp_face_inside(ISBBranch *bspn, BSPFace *face) /* else: end branch reached */ int a; - if(bspn->totsamp==0) return; + if (bspn->totsamp==0) return; /* check for nodes entirely in shadow, can be skipped */ - if(bspn->totsamp==bspn->full) + if (bspn->totsamp==bspn->full) return; /* if bsp node is entirely in front of face, give up */ - if(bspn->box.zmax < face->box.zmin) + if (bspn->box.zmax < face->box.zmin) return; /* if face boundbox is outside of branch rect, give up */ - if(0==BLI_isect_rctf((rctf *)&face->box, (rctf *)&bspn->box, NULL)) + if (0==BLI_isect_rctf((rctf *)&face->box, (rctf *)&bspn->box, NULL)) return; /* test all points inside branch */ - for(a=bspn->totsamp-1; a>=0; a--) { + for (a=bspn->totsamp-1; a>=0; a--) { ISBSample *samp= bspn->samples[a]; - if((samp->facenr!=face->facenr || samp->obi!=face->obi) && samp->shadfac) { - if(face->box.zmin < samp->zco[2]) { - if(BLI_in_rctf((rctf *)&face->box, samp->zco[0], samp->zco[1])) { + if ((samp->facenr!=face->facenr || samp->obi!=face->obi) && samp->shadfac) { + if (face->box.zmin < samp->zco[2]) { + if (BLI_in_rctf((rctf *)&face->box, samp->zco[0], samp->zco[1])) { int inshadow= 0; - if(face->type) { - if(point_behind_strand(samp->zco, face)) + if (face->type) { + if (point_behind_strand(samp->zco, face)) inshadow= 1; } - else if( point_behind_tria2d(samp->zco, face->v1, face->v2, face->v3)) + else if ( point_behind_tria2d(samp->zco, face->v1, face->v2, face->v3)) inshadow= 1; - else if(face->v4 && point_behind_tria2d(samp->zco, face->v1, face->v3, face->v4)) + else if (face->v4 && point_behind_tria2d(samp->zco, face->v1, face->v3, face->v4)) inshadow= 1; - if(inshadow) { + if (inshadow) { *(samp->shadfac) += face->shad_alpha; /* optimize; is_full means shad_alpha==4096 */ - if(*(samp->shadfac) >= 4096 || face->is_full) { + if (*(samp->shadfac) >= 4096 || face->is_full) { bspn->full++; samp->shadfac= NULL; } @@ -1853,15 +1854,15 @@ static void isb_bsp_face_inside(ISBBranch *bspn, BSPFace *face) /* based on available samples, recalculate the bounding box for bsp nodes, recursive */ static void isb_bsp_recalc_box(ISBBranch *root) { - if(root->left) { + if (root->left) { isb_bsp_recalc_box(root->left); isb_bsp_recalc_box(root->right); } - else if(root->totsamp) { + else if (root->totsamp) { int a; init_box(&root->box); - for(a=root->totsamp-1; a>=0; a--) + for (a=root->totsamp-1; a>=0; a--) bound_boxf(&root->box, root->samples[a]->zco); } } @@ -1878,7 +1879,7 @@ static void isb_bsp_test_strand(ZSpan *zspan, int obi, int zvlnr, float *v1, flo face.obi= obi; face.facenr= zvlnr & ~RE_QUAD_OFFS; face.type= R_STRAND; - if(R.osa) + if (R.osa) face.shad_alpha= (short)ceil(4096.0f*zspan->shad_alpha/(float)R.osa); else face.shad_alpha= (short)ceil(4096.0f*zspan->shad_alpha); @@ -1890,7 +1891,7 @@ static void isb_bsp_test_strand(ZSpan *zspan, int obi, int zvlnr, float *v1, flo bound_boxf(&face.box, v1); bound_boxf(&face.box, v2); bound_boxf(&face.box, v3); - if(v4) + if (v4) bound_boxf(&face.box, v4); /* optimize values */ @@ -1912,7 +1913,7 @@ static void isb_bsp_test_face(ZSpan *zspan, int obi, int zvlnr, float *v1, float face.obi= obi; face.facenr= zvlnr & ~RE_QUAD_OFFS; face.type= 0; - if(R.osa) + if (R.osa) face.shad_alpha= (short)ceil(4096.0f*zspan->shad_alpha/(float)R.osa); else face.shad_alpha= (short)ceil(4096.0f*zspan->shad_alpha); @@ -1924,7 +1925,7 @@ static void isb_bsp_test_face(ZSpan *zspan, int obi, int zvlnr, float *v1, float bound_boxf(&face.box, v1); bound_boxf(&face.box, v2); bound_boxf(&face.box, v3); - if(v4) + if (v4) bound_boxf(&face.box, v4); isb_bsp_face_inside((ISBBranch *)zspan->rectz, &face); @@ -1935,11 +1936,11 @@ static int testclip_minmax(const float ho[4], const float minmax[4]) float wco= ho[3]; int flag= 0; - if( ho[0] > minmax[1]*wco) flag = 1; - else if( ho[0]< minmax[0]*wco) flag = 2; + if ( ho[0] > minmax[1]*wco) flag = 1; + else if ( ho[0]< minmax[0]*wco) flag = 2; - if( ho[1] > minmax[3]*wco) flag |= 4; - else if( ho[1]< minmax[2]*wco) flag |= 8; + if ( ho[1] > minmax[3]*wco) flag |= 4; + else if ( ho[1]< minmax[2]*wco) flag |= 8; return flag; } @@ -1966,7 +1967,7 @@ static void isb_bsp_fillfaces(Render *re, LampRen *lar, ISBBranch *root) minmaxf[2]= (2.0f*root->box.ymin - size-2.0f)/size; minmaxf[3]= (2.0f*root->box.ymax - size+2.0f)/size; - if(lar->mode & (LA_LAYER|LA_LAYER_SHADOW)) lay= lar->lay; + if (lar->mode & (LA_LAYER|LA_LAYER_SHADOW)) lay= lar->lay; /* (ab)use zspan, since we use zbuffer clipping code */ zbuf_alloc_span(&zspan, size, size, re->clipcrop); @@ -1985,29 +1986,29 @@ static void isb_bsp_fillfaces(Render *re, LampRen *lar, ISBBranch *root) zspan.zbuffunc= isb_bsp_test_face; zspanstrand.zbuffunc= isb_bsp_test_strand; - for(i=0, obi=re->instancetable.first; obi; i++, obi=obi->next) { + for (i=0, obi=re->instancetable.first; obi; i++, obi=obi->next) { obr= obi->obr; - if(obi->flag & R_TRANSFORMED) + if (obi->flag & R_TRANSFORMED) mult_m4_m4m4(winmat, shb->persmat, obi->mat); else copy_m4_m4(winmat, shb->persmat); - for(a=0; a<obr->totvlak; a++) { + for (a=0; a<obr->totvlak; a++) { - if((a & 255)==0) vlr= obr->vlaknodes[a>>8].vlak; + if ((a & 255)==0) vlr= obr->vlaknodes[a>>8].vlak; else vlr++; /* note, these conditions are copied in shadowbuf_autoclip() */ - if(vlr->mat!= ma) { + if (vlr->mat!= ma) { ma= vlr->mat; ok= 1; - if((ma->mode & MA_SHADBUF)==0) ok= 0; - if(ma->material_type == MA_TYPE_WIRE) ok= 0; + if ((ma->mode & MA_SHADBUF)==0) ok= 0; + if (ma->material_type == MA_TYPE_WIRE) ok= 0; zspanstrand.shad_alpha= zspan.shad_alpha= ma->shad_alpha; } - if(ok && (obi->lay & lay)) { + if (ok && (obi->lay & lay)) { float hoco[4][4]; int c1, c2, c3, c4=0; int d1, d2, d3, d4=0; @@ -2017,32 +2018,32 @@ static void isb_bsp_fillfaces(Render *re, LampRen *lar, ISBBranch *root) projectvert(vlr->v1->co, winmat, hoco[0]); d1= testclip_minmax(hoco[0], minmaxf); projectvert(vlr->v2->co, winmat, hoco[1]); d2= testclip_minmax(hoco[1], minmaxf); projectvert(vlr->v3->co, winmat, hoco[2]); d3= testclip_minmax(hoco[2], minmaxf); - if(vlr->v4) { + if (vlr->v4) { projectvert(vlr->v4->co, winmat, hoco[3]); d4= testclip_minmax(hoco[3], minmaxf); } /* minmax clipping */ - if(vlr->v4) partclip= d1 & d2 & d3 & d4; + if (vlr->v4) partclip= d1 & d2 & d3 & d4; else partclip= d1 & d2 & d3; - if(partclip==0) { + if (partclip==0) { /* window clipping */ c1= testclip(hoco[0]); c2= testclip(hoco[1]); c3= testclip(hoco[2]); - if(vlr->v4) + if (vlr->v4) c4= testclip(hoco[3]); /* ***** NO WIRE YET */ - if(ma->material_type == MA_TYPE_WIRE) { - if(vlr->v4) + if (ma->material_type == MA_TYPE_WIRE) { + if (vlr->v4) zbufclipwire(&zspan, i, a+1, vlr->ec, hoco[0], hoco[1], hoco[2], hoco[3], c1, c2, c3, c4); else zbufclipwire(&zspan, i, a+1, vlr->ec, hoco[0], hoco[1], hoco[2], 0, c1, c2, c3, 0); } - else if(vlr->v4) { - if(vlr->flag & R_STRAND) + else if (vlr->v4) { + if (vlr->flag & R_STRAND) zbufclip4(&zspanstrand, i, a+1, hoco[0], hoco[1], hoco[2], hoco[3], c1, c2, c3, c4); else zbufclip4(&zspan, i, a+1, hoco[0], hoco[1], hoco[2], hoco[3], c1, c2, c3, c4); @@ -2066,7 +2067,7 @@ static int viewpixel_to_lampbuf(ShadBuf *shb, ObjectInstanceRen *obi, VlakRen *v RE_vlakren_get_normal(&R, obi, vlr, nor); copy_v3_v3(v1, vlr->v1->co); - if(obi->flag & R_TRANSFORMED) + if (obi->flag & R_TRANSFORMED) mul_m4_v3(obi->mat, v1); /* from shadepixel() */ @@ -2074,7 +2075,7 @@ static int viewpixel_to_lampbuf(ShadBuf *shb, ObjectInstanceRen *obi, VlakRen *v hoco[3]= 1.0f; /* ortho viewplane cannot intersect using view vector originating in (0,0,0) */ - if(R.r.mode & R_ORTHO) { + if (R.r.mode & R_ORTHO) { /* x and y 3d coordinate can be derived from pixel coord and winmat */ float fx= 2.0f/(R.winx*R.winmat[0][0]); float fy= 2.0f/(R.winy*R.winmat[1][1]); @@ -2083,7 +2084,7 @@ static int viewpixel_to_lampbuf(ShadBuf *shb, ObjectInstanceRen *obi, VlakRen *v hoco[1]= (y - 0.5f*R.winy)*fy - R.winmat[3][1]/R.winmat[1][1]; /* using a*x + b*y + c*z = d equation, (a b c) is normal */ - if(nor[2]!=0.0f) + if (nor[2]!=0.0f) hoco[2]= (dface - nor[0]*hoco[0] - nor[1]*hoco[1])/nor[2]; else hoco[2]= 0.0f; @@ -2110,11 +2111,11 @@ static int viewpixel_to_lampbuf(ShadBuf *shb, ObjectInstanceRen *obi, VlakRen *v /* clip We can test for -1.0/1.0 because of the properties of the * coordinate transformations. */ fac= fabs(hoco[3]); - if(hoco[0]<-fac || hoco[0]>fac) + if (hoco[0]<-fac || hoco[0]>fac) return 0; - if(hoco[1]<-fac || hoco[1]>fac) + if (hoco[1]<-fac || hoco[1]>fac) return 0; - if(hoco[2]<-fac || hoco[2]>fac) + if (hoco[2]<-fac || hoco[2]>fac) return 0; siz= 0.5f*(float)shb->size; @@ -2135,7 +2136,7 @@ static void isb_add_shadfac(ISBShadfacA **isbsapp, MemArena *mem, int obi, int f float shadfacf; /* in osa case, the samples were filled in with factor 1.0/R.osa. if fewer samples we have to correct */ - if(R.osa) + if (R.osa) shadfacf= ((float)shadfac*R.osa)/(4096.0f*samples); else shadfacf= ((float)shadfac)/(4096.0f); @@ -2144,7 +2145,7 @@ static void isb_add_shadfac(ISBShadfacA **isbsapp, MemArena *mem, int obi, int f new->obi= obi; new->facenr= facenr & ~RE_QUAD_OFFS; new->shadfac= shadfacf; - if(*isbsapp) + if (*isbsapp) new->next= (*isbsapp); else new->next= NULL; @@ -2161,25 +2162,25 @@ static int isb_add_samples(RenderPart *pa, ISBBranch *root, MemArena *memarena, /* bsp split doesn't like to handle regular sequences */ xcos= MEM_mallocN( pa->rectx*sizeof(int), "xcos"); ycos= MEM_mallocN( pa->recty*sizeof(int), "ycos"); - for(xi=0; xi<pa->rectx; xi++) + for (xi=0; xi<pa->rectx; xi++) xcos[xi]= xi; - for(yi=0; yi<pa->recty; yi++) + for (yi=0; yi<pa->recty; yi++) ycos[yi]= yi; BLI_array_randomize(xcos, sizeof(int), pa->rectx, 12345); BLI_array_randomize(ycos, sizeof(int), pa->recty, 54321); - for(sample=0; sample<(R.osa?R.osa:1); sample++) { + for (sample=0; sample<(R.osa?R.osa:1); sample++) { ISBSample *samp= samplebuf[sample], *samp1; - for(yi=0; yi<pa->recty; yi++) { + for (yi=0; yi<pa->recty; yi++) { int y= ycos[yi]; - for(xi=0; xi<pa->rectx; xi++) { + for (xi=0; xi<pa->rectx; xi++) { int x= xcos[xi]; samp1= samp + y*pa->rectx + x; - if(samp1->facenr) + if (samp1->facenr) bsp_err |= isb_bsp_insert(root, memarena, samp1); } - if(bsp_err) break; + if (bsp_err) break; } } @@ -2215,11 +2216,11 @@ static void isb_make_buffer(RenderPart *pa, LampRen *lar) BLI_memarena_use_calloc(memarena); /* samplebuf is in camera view space (pixels) */ - for(sample=0; sample<(R.osa?R.osa:1); sample++) + for (sample=0; sample<(R.osa?R.osa:1); sample++) samplebuf[sample]= MEM_callocN(sizeof(ISBSample)*pa->rectx*pa->recty, "isb samplebuf"); /* for end result, ISBSamples point to this in non OSA case, otherwise to pixstruct->shadfac */ - if(R.osa==0) + if (R.osa==0) isbdata->shadfacs= MEM_callocN(pa->rectx*pa->recty*sizeof(short), "isb shadfacs"); /* setup bsp root */ @@ -2228,34 +2229,34 @@ static void isb_make_buffer(RenderPart *pa, LampRen *lar) root.box.ymin = (float)shb->size; /* create the sample buffers */ - for(sindex=0, y=0; y<pa->recty; y++) { - for(x=0; x<pa->rectx; x++, sindex++) { + for (sindex=0, y=0; y<pa->recty; y++) { + for (x=0; x<pa->rectx; x++, sindex++) { /* this makes it a long function, but splitting it out would mean 10+ arguments */ /* first check OSA case */ - if(R.osa) { + if (R.osa) { rd= pa->rectdaps + sindex; - if(*rd) { + if (*rd) { float xs= (float)(x + pa->disprect.xmin); float ys= (float)(y + pa->disprect.ymin); - for(sample=0; sample<R.osa; sample++) { + for (sample=0; sample<R.osa; sample++) { PixStr *ps= (PixStr *)(*rd); int mask= (1<<sample); while(ps) { - if(ps->mask & mask) + if (ps->mask & mask) break; ps= ps->next; } - if(ps && ps->facenr>0) { + if (ps && ps->facenr>0) { ObjectInstanceRen *obi= &R.objectinstance[ps->obi]; ObjectRen *obr= obi->obr; VlakRen *vlr= RE_findOrAddVlak(obr, (ps->facenr-1) & RE_QUAD_MASK); samp= samplebuf[sample] + sindex; /* convert image plane pixel location to lamp buffer space */ - if(viewpixel_to_lampbuf(shb, obi, vlr, xs + R.jit[sample][0], ys + R.jit[sample][1], samp->zco)) { + if (viewpixel_to_lampbuf(shb, obi, vlr, xs + R.jit[sample][0], ys + R.jit[sample][1], samp->zco)) { samp->obi= ps->obi; samp->facenr= ps->facenr & ~RE_QUAD_OFFS; ps->shadfac= 0; @@ -2269,7 +2270,7 @@ static void isb_make_buffer(RenderPart *pa, LampRen *lar) else { rectp= pa->rectp + sindex; recto= pa->recto + sindex; - if(*rectp>0) { + if (*rectp>0) { ObjectInstanceRen *obi= &R.objectinstance[*recto]; ObjectRen *obr= obi->obr; VlakRen *vlr= RE_findOrAddVlak(obr, (*rectp-1) & RE_QUAD_MASK); @@ -2278,7 +2279,7 @@ static void isb_make_buffer(RenderPart *pa, LampRen *lar) samp= samplebuf[0] + sindex; /* convert image plane pixel location to lamp buffer space */ - if(viewpixel_to_lampbuf(shb, obi, vlr, xs, ys, samp->zco)) { + if (viewpixel_to_lampbuf(shb, obi, vlr, xs, ys, samp->zco)) { samp->obi= *recto; samp->facenr= *rectp & ~RE_QUAD_OFFS; samp->shadfac= isbdata->shadfacs + sindex; @@ -2290,7 +2291,7 @@ static void isb_make_buffer(RenderPart *pa, LampRen *lar) } /* simple method to see if we have samples */ - if(root.box.xmin != (float)shb->size) { + if (root.box.xmin != (float)shb->size) { /* now create a regular split, root.box has the initial bounding box of all pixels */ /* split bsp 8 levels deep, in regular grid (16 x 16) */ isb_bsp_split_init(&root, memarena, 8); @@ -2298,24 +2299,24 @@ static void isb_make_buffer(RenderPart *pa, LampRen *lar) /* insert all samples in BSP now */ bsp_err= isb_add_samples(pa, &root, memarena, samplebuf); - if(bsp_err==0) { + if (bsp_err==0) { /* go over all faces and fill in shadow values */ isb_bsp_fillfaces(&R, lar, &root); /* shb->persmat should have been calculated */ /* copy shadow samples to persistent buffer, reduce memory overhead */ - if(R.osa) { + if (R.osa) { ISBShadfacA **isbsa= isbdata->shadfaca= MEM_callocN(pa->rectx*pa->recty*sizeof(void *), "isb shadfacs"); isbdata->memarena = BLI_memarena_new(0x8000 * sizeof(ISBSampleA), "isb arena"); BLI_memarena_use_calloc(isbdata->memarena); - for(rd= pa->rectdaps, x=pa->rectx*pa->recty; x>0; x--, rd++, isbsa++) { + for (rd= pa->rectdaps, x=pa->rectx*pa->recty; x>0; x--, rd++, isbsa++) { - if(*rd) { + if (*rd) { PixStr *ps= (PixStr *)(*rd); while(ps) { - if(ps->shadfac) + if (ps->shadfac) isb_add_shadfac(isbsa, isbdata->memarena, ps->obi, ps->facenr, ps->shadfac, count_mask(ps->mask)); ps= ps->next; } @@ -2325,7 +2326,7 @@ static void isb_make_buffer(RenderPart *pa, LampRen *lar) } } else { - if(isbdata->shadfacs) { + if (isbdata->shadfacs) { MEM_freeN(isbdata->shadfacs); isbdata->shadfacs= NULL; } @@ -2335,10 +2336,10 @@ static void isb_make_buffer(RenderPart *pa, LampRen *lar) BLI_memarena_free(memarena); /* free samples */ - for(x=0; x<(R.osa?R.osa:1); x++) + for (x=0; x<(R.osa?R.osa:1); x++) MEM_freeN(samplebuf[x]); - if(bsp_err) printf("error in filling bsp\n"); + if (bsp_err) printf("error in filling bsp\n"); } /* add sample to buffer, isbsa is the root sample in a buffer */ @@ -2347,7 +2348,7 @@ static ISBSampleA *isb_alloc_sample_transp(ISBSampleA **isbsa, MemArena *mem) ISBSampleA *new; new= BLI_memarena_alloc(mem, sizeof(ISBSampleA)); - if(*isbsa) + if (*isbsa) new->next= (*isbsa); else new->next= NULL; @@ -2365,19 +2366,19 @@ static int isb_add_samples_transp(RenderPart *pa, ISBBranch *root, MemArena *mem /* bsp split doesn't like to handle regular sequences */ xcos= MEM_mallocN( pa->rectx*sizeof(int), "xcos"); ycos= MEM_mallocN( pa->recty*sizeof(int), "ycos"); - for(xi=0; xi<pa->rectx; xi++) + for (xi=0; xi<pa->rectx; xi++) xcos[xi]= xi; - for(yi=0; yi<pa->recty; yi++) + for (yi=0; yi<pa->recty; yi++) ycos[yi]= yi; BLI_array_randomize(xcos, sizeof(int), pa->rectx, 12345); BLI_array_randomize(ycos, sizeof(int), pa->recty, 54321); - for(sample=0; sample<(R.osa?R.osa:1); sample++) { + for (sample=0; sample<(R.osa?R.osa:1); sample++) { ISBSampleA **samp= samplebuf[sample], *samp1; - for(yi=0; yi<pa->recty; yi++) { + for (yi=0; yi<pa->recty; yi++) { int y= ycos[yi]; - for(xi=0; xi<pa->rectx; xi++) { + for (xi=0; xi<pa->rectx; xi++) { int x= xcos[xi]; samp1= *(samp + y*pa->rectx + x); @@ -2386,7 +2387,7 @@ static int isb_add_samples_transp(RenderPart *pa, ISBBranch *root, MemArena *mem samp1= samp1->next; } } - if(bsp_err) break; + if (bsp_err) break; } } @@ -2423,7 +2424,7 @@ static void isb_make_buffer_transp(RenderPart *pa, APixstr *apixbuf, LampRen *la BLI_memarena_use_calloc(memarena); /* samplebuf is in camera view space (pixels) */ - for(sample=0; sample<(R.osa?R.osa:1); sample++) + for (sample=0; sample<(R.osa?R.osa:1); sample++) samplebuf[sample]= MEM_callocN(sizeof(void *)*pa->rectx*pa->recty, "isb alpha samplebuf"); /* setup bsp root */ @@ -2432,18 +2433,18 @@ static void isb_make_buffer_transp(RenderPart *pa, APixstr *apixbuf, LampRen *la root.box.ymin = (float)shb->size; /* create the sample buffers */ - for(ap= apixbuf, sindex=0, y=0; y<pa->recty; y++) { - for(x=0; x<pa->rectx; x++, sindex++, ap++) { + for (ap= apixbuf, sindex=0, y=0; y<pa->recty; y++) { + for (x=0; x<pa->rectx; x++, sindex++, ap++) { - if(ap->p[0]) { + if (ap->p[0]) { APixstr *apn; float xs= (float)(x + pa->disprect.xmin); float ys= (float)(y + pa->disprect.ymin); - for(apn=ap; apn; apn= apn->next) { + for (apn=ap; apn; apn= apn->next) { int a; - for(a=0; a<4; a++) { - if(apn->p[a]) { + for (a=0; a<4; a++) { + if (apn->p[a]) { ObjectInstanceRen *obi= &R.objectinstance[apn->obi[a]]; ObjectRen *obr= obi->obr; VlakRen *vlr= RE_findOrAddVlak(obr, (apn->p[a]-1) & RE_QUAD_MASK); @@ -2452,14 +2453,14 @@ static void isb_make_buffer_transp(RenderPart *pa, APixstr *apixbuf, LampRen *la /* here we store shadfac, easier to create the end storage buffer. needs zero'ed, multiple shadowbufs use it */ apn->shadfac[a]= 0; - if(R.osa) { - for(sample=0; sample<R.osa; sample++) { + if (R.osa) { + for (sample=0; sample<R.osa; sample++) { int mask= (1<<sample); - if(apn->mask[a] & mask) { + if (apn->mask[a] & mask) { /* convert image plane pixel location to lamp buffer space */ - if(viewpixel_to_lampbuf(shb, obi, vlr, xs + R.jit[sample][0], ys + R.jit[sample][1], zco)) { + if (viewpixel_to_lampbuf(shb, obi, vlr, xs + R.jit[sample][0], ys + R.jit[sample][1], zco)) { samp= isb_alloc_sample_transp(samplebuf[sample] + sindex, memarena); samp->obi= apn->obi[a]; samp->facenr= apn->p[a] & ~RE_QUAD_OFFS; @@ -2474,7 +2475,7 @@ static void isb_make_buffer_transp(RenderPart *pa, APixstr *apixbuf, LampRen *la else { /* convert image plane pixel location to lamp buffer space */ - if(viewpixel_to_lampbuf(shb, obi, vlr, xs, ys, zco)) { + if (viewpixel_to_lampbuf(shb, obi, vlr, xs, ys, zco)) { samp= isb_alloc_sample_transp(samplebuf[0] + sindex, memarena); samp->obi= apn->obi[a]; @@ -2493,7 +2494,7 @@ static void isb_make_buffer_transp(RenderPart *pa, APixstr *apixbuf, LampRen *la } /* simple method to see if we have samples */ - if(root.box.xmin != (float)shb->size) { + if (root.box.xmin != (float)shb->size) { /* now create a regular split, root.box has the initial bounding box of all pixels */ /* split bsp 8 levels deep, in regular grid (16 x 16) */ isb_bsp_split_init(&root, memarena, 8); @@ -2501,7 +2502,7 @@ static void isb_make_buffer_transp(RenderPart *pa, APixstr *apixbuf, LampRen *la /* insert all samples in BSP now */ bsp_err= isb_add_samples_transp(pa, &root, memarena, samplebuf); - if(bsp_err==0) { + if (bsp_err==0) { ISBShadfacA **isbsa; /* go over all faces and fill in shadow values */ @@ -2512,15 +2513,15 @@ static void isb_make_buffer_transp(RenderPart *pa, APixstr *apixbuf, LampRen *la isbdata->memarena = BLI_memarena_new(0x8000 * sizeof(ISBSampleA), "isb arena"); - for(ap= apixbuf, x=pa->rectx*pa->recty; x>0; x--, ap++, isbsa++) { + for (ap= apixbuf, x=pa->rectx*pa->recty; x>0; x--, ap++, isbsa++) { - if(ap->p[0]) { + if (ap->p[0]) { APixstr *apn; - for(apn=ap; apn; apn= apn->next) { + for (apn=ap; apn; apn= apn->next) { int a; - for(a=0; a<4; a++) { - if(apn->p[a] && apn->shadfac[a]) { - if(R.osa) + for (a=0; a<4; a++) { + if (apn->p[a] && apn->shadfac[a]) { + if (R.osa) isb_add_shadfac(isbsa, isbdata->memarena, apn->obi[a], apn->p[a], apn->shadfac[a], count_mask(apn->mask[a])); else isb_add_shadfac(isbsa, isbdata->memarena, apn->obi[a], apn->p[a], apn->shadfac[a], 0); @@ -2536,10 +2537,10 @@ static void isb_make_buffer_transp(RenderPart *pa, APixstr *apixbuf, LampRen *la BLI_memarena_free(memarena); /* free samples */ - for(x=0; x<(R.osa?R.osa:1); x++) + for (x=0; x<(R.osa?R.osa:1); x++) MEM_freeN(samplebuf[x]); - if(bsp_err) printf("error in filling bsp\n"); + if (bsp_err) printf("error in filling bsp\n"); } @@ -2551,18 +2552,18 @@ static void isb_make_buffer_transp(RenderPart *pa, APixstr *apixbuf, LampRen *la float ISB_getshadow(ShadeInput *shi, ShadBuf *shb) { /* if raytracing, we can't accept irregular shadow */ - if(shi->depth==0) { + if (shi->depth==0) { ISBData *isbdata= shb->isb_result[shi->thread]; - if(isbdata) { - if(isbdata->shadfacs || isbdata->shadfaca) { + if (isbdata) { + if (isbdata->shadfacs || isbdata->shadfaca) { int x= shi->xs - isbdata->minx; - if(x >= 0 && x < isbdata->rectx) { + if (x >= 0 && x < isbdata->rectx) { int y= shi->ys - isbdata->miny; - if(y >= 0 && y < isbdata->recty) { - if(isbdata->shadfacs) { + if (y >= 0 && y < isbdata->recty) { + if (isbdata->shadfacs) { short *sp= isbdata->shadfacs + y*isbdata->rectx + x; return *sp>=4096?0.0f:1.0f - ((float)*sp)/4096.0f; } @@ -2572,7 +2573,7 @@ float ISB_getshadow(ShadeInput *shi, ShadBuf *shb) ISBShadfacA *isbsa= *(isbdata->shadfaca + sindex); while(isbsa) { - if(isbsa->facenr==shi->facenr+1 && isbsa->obi==obi) + if (isbsa->facenr==shi->facenr+1 && isbsa->obi==obi) return isbsa->shadfac>=1.0f?0.0f:1.0f - isbsa->shadfac; isbsa= isbsa->next; } @@ -2591,15 +2592,15 @@ void ISB_create(RenderPart *pa, APixstr *apixbuf) GroupObject *go; /* go over all lamps, and make the irregular buffers */ - for(go=R.lights.first; go; go= go->next) { + for (go=R.lights.first; go; go= go->next) { LampRen *lar= go->lampren; - if(lar->type==LA_SPOT && lar->shb && lar->buftype==LA_SHADBUF_IRREGULAR) { + if (lar->type==LA_SPOT && lar->shb && lar->buftype==LA_SHADBUF_IRREGULAR) { /* create storage for shadow, per thread */ lar->shb->isb_result[pa->thread]= MEM_callocN(sizeof(ISBData), "isb data"); - if(apixbuf) + if (apixbuf) isb_make_buffer_transp(pa, apixbuf, lar); else isb_make_buffer(pa, lar); @@ -2614,19 +2615,19 @@ void ISB_free(RenderPart *pa) GroupObject *go; /* go over all lamps, and free the irregular buffers */ - for(go=R.lights.first; go; go= go->next) { + for (go=R.lights.first; go; go= go->next) { LampRen *lar= go->lampren; - if(lar->type==LA_SPOT && lar->shb && lar->buftype==LA_SHADBUF_IRREGULAR) { + if (lar->type==LA_SPOT && lar->shb && lar->buftype==LA_SHADBUF_IRREGULAR) { ISBData *isbdata= lar->shb->isb_result[pa->thread]; - if(isbdata) { - if(isbdata->shadfacs) + if (isbdata) { + if (isbdata->shadfacs) MEM_freeN(isbdata->shadfacs); - if(isbdata->shadfaca) + if (isbdata->shadfaca) MEM_freeN(isbdata->shadfaca); - if(isbdata->memarena) + if (isbdata->memarena) BLI_memarena_free(isbdata->memarena); MEM_freeN(isbdata); diff --git a/source/blender/render/intern/source/shadeinput.c b/source/blender/render/intern/source/shadeinput.c index 29c1318727c..611c21cf0f2 100644 --- a/source/blender/render/intern/source/shadeinput.c +++ b/source/blender/render/intern/source/shadeinput.c @@ -108,7 +108,7 @@ void shade_material_loop(ShadeInput *shi, ShadeResult *shr) shade_lamp_loop(shi, shr); /* clears shr */ - if(shi->translucency!=0.0f) { + if (shi->translucency!=0.0f) { ShadeResult shr_t; float fac= shi->translucency; @@ -121,11 +121,11 @@ void shade_material_loop(ShadeInput *shi, ShadeResult *shr) /* a couple of passes */ VECADDISFAC(shr->combined, shr_t.combined, fac); - if(shi->passflag & SCE_PASS_SPEC) + if (shi->passflag & SCE_PASS_SPEC) VECADDISFAC(shr->spec, shr_t.spec, fac); - if(shi->passflag & SCE_PASS_DIFFUSE) + if (shi->passflag & SCE_PASS_DIFFUSE) VECADDISFAC(shr->diff, shr_t.diff, fac); - if(shi->passflag & SCE_PASS_SHADOW) + if (shi->passflag & SCE_PASS_SHADOW) VECADDISFAC(shr->shad, shr_t.shad, fac); negate_v3(shi->vn); @@ -133,20 +133,20 @@ void shade_material_loop(ShadeInput *shi, ShadeResult *shr) } /* depth >= 1 when ray-shading */ - if(shi->depth==0 || shi->volume_depth > 0) { - if(R.r.mode & R_RAYTRACE) { - if(shi->ray_mirror!=0.0f || ((shi->mode & MA_TRANSP) && (shi->mode & MA_RAYTRANSP) && shr->alpha!=1.0f)) { + if (shi->depth==0 || shi->volume_depth > 0) { + if (R.r.mode & R_RAYTRACE) { + if (shi->ray_mirror!=0.0f || ((shi->mode & MA_TRANSP) && (shi->mode & MA_RAYTRANSP) && shr->alpha!=1.0f)) { /* ray trace works on combined, but gives pass info */ ray_trace(shi, shr); } } /* disable adding of sky for raytransp */ - if((shi->mode & MA_TRANSP) && (shi->mode & MA_RAYTRANSP)) - if((shi->layflag & SCE_LAY_SKY) && (R.r.alphamode==R_ADDSKY)) + if ((shi->mode & MA_TRANSP) && (shi->mode & MA_RAYTRANSP)) + if ((shi->layflag & SCE_LAY_SKY) && (R.r.alphamode==R_ADDSKY)) shr->alpha= 1.0f; } - if(R.r.mode & R_RAYTRACE) { + if (R.r.mode & R_RAYTRACE) { if (R.render_volumes_inside.first) shade_volume_inside(shi, shr); } @@ -163,7 +163,7 @@ void shade_input_do_shade(ShadeInput *shi, ShadeResult *shr) memset(&shi->raycounter, 0, sizeof(shi->raycounter)); #endif - if(shi->mat->nodetree && shi->mat->use_nodes) { + if (shi->mat->nodetree && shi->mat->use_nodes) { ntreeShaderExecTree(shi->mat->nodetree, shi, shr); } else { @@ -171,36 +171,37 @@ void shade_input_do_shade(ShadeInput *shi, ShadeResult *shr) shade_input_init_material(shi); if (shi->mat->material_type == MA_TYPE_VOLUME) { - if(R.r.mode & R_RAYTRACE) { + if (R.r.mode & R_RAYTRACE) { shade_volume_outside(shi, shr); } - } else { /* MA_TYPE_SURFACE, MA_TYPE_WIRE */ + } + else { /* MA_TYPE_SURFACE, MA_TYPE_WIRE */ shade_material_loop(shi, shr); } } /* copy additional passes */ - if(shi->passflag & (SCE_PASS_VECTOR|SCE_PASS_NORMAL)) { + if (shi->passflag & (SCE_PASS_VECTOR|SCE_PASS_NORMAL)) { copy_v4_v4(shr->winspeed, shi->winspeed); copy_v3_v3(shr->nor, shi->vn); } /* MIST */ - if((shi->passflag & SCE_PASS_MIST) || ((R.wrld.mode & WO_MIST) && (shi->mat->mode & MA_NOMIST)==0)) { - if(R.r.mode & R_ORTHO) + if ((shi->passflag & SCE_PASS_MIST) || ((R.wrld.mode & WO_MIST) && (shi->mat->mode & MA_NOMIST)==0)) { + if (R.r.mode & R_ORTHO) shr->mist= mistfactor(-shi->co[2], shi->co); else shr->mist= mistfactor(len_v3(shi->co), shi->co); } else shr->mist= 0.0f; - if((R.wrld.mode & WO_MIST) && (shi->mat->mode & MA_NOMIST)==0 ) { + if ((R.wrld.mode & WO_MIST) && (shi->mat->mode & MA_NOMIST)==0 ) { alpha= shr->mist; } else alpha= 1.0f; /* add mist and premul color */ - if(shr->alpha!=1.0f || alpha!=1.0f) { + if (shr->alpha!=1.0f || alpha!=1.0f) { float fac= alpha*(shr->alpha); shr->combined[3]= fac; @@ -215,7 +216,7 @@ void shade_input_do_shade(ShadeInput *shi, ShadeResult *shr) /* RAYHITS */ #if 0 - if(1 || shi->passflag & SCE_PASS_RAYHITS) { + if (1 || shi->passflag & SCE_PASS_RAYHITS) { shr->rayhits[0] = (float)shi->raycounter.faces.test; shr->rayhits[1] = (float)shi->raycounter.bb.hit; shr->rayhits[2] = 0.0; @@ -240,15 +241,15 @@ void vlr_set_uv_indices(VlakRen *vlr, int *i1, int *i2, int *i3) /* 1---2 1---2 0 = orig face, 1 = new face */ /* Update vert nums to point to correct verts of original face */ - if(vlr->flag & R_DIVIDE_24) { - if(vlr->flag & R_FACE_SPLIT) { + if (vlr->flag & R_DIVIDE_24) { + if (vlr->flag & R_FACE_SPLIT) { (*i1)++; (*i2)++; (*i3)++; } else { (*i3)++; } } - else if(vlr->flag & R_FACE_SPLIT) { + else if (vlr->flag & R_FACE_SPLIT) { (*i2)++; (*i3)++; } } @@ -282,12 +283,12 @@ void shade_input_set_triangle_i(ShadeInput *shi, ObjectInstanceRen *obi, VlakRen RE_vlakren_get_normal(&R, obi, vlr, shi->facenor); /* calculate vertexnormals */ - if(vlr->flag & R_SMOOTH) { + if (vlr->flag & R_SMOOTH) { copy_v3_v3(shi->n1, shi->v1->n); copy_v3_v3(shi->n2, shi->v2->n); copy_v3_v3(shi->n3, shi->v3->n); - if(obi->flag & R_TRANSFORMED) { + if (obi->flag & R_TRANSFORMED) { mul_m3_v3(obi->nmat, shi->n1); normalize_v3(shi->n1); mul_m3_v3(obi->nmat, shi->n2); normalize_v3(shi->n2); mul_m3_v3(obi->nmat, shi->n3); normalize_v3(shi->n3); @@ -302,14 +303,14 @@ void shade_input_set_triangle_i(ShadeInput *shi, ObjectInstanceRen *obi, VlakRen /* copy data from face to ShadeInput, scanline case */ void shade_input_set_triangle(ShadeInput *shi, volatile int obi, volatile int facenr, int UNUSED(normal_flip)) { - if(facenr>0) { + if (facenr>0) { shi->obi= &R.objectinstance[obi]; shi->obr= shi->obi->obr; shi->facenr= (facenr-1) & RE_QUAD_MASK; - if( shi->facenr < shi->obr->totvlak ) { + if ( shi->facenr < shi->obr->totvlak ) { VlakRen *vlr= RE_findOrAddVlak(shi->obr, shi->facenr); - if(facenr & RE_QUAD_OFFS) + if (facenr & RE_QUAD_OFFS) shade_input_set_triangle_i(shi, shi->obi, vlr, 0, 2, 3); else shade_input_set_triangle_i(shi, shi->obi, vlr, 0, 1, 2); @@ -345,7 +346,7 @@ void shade_input_set_strand(ShadeInput *shi, StrandRen *strand, StrandPoint *spo shi->xs= (int)spoint->x; shi->ys= (int)spoint->y; - if(shi->osatex || (R.r.mode & R_SHADOW)) { + if (shi->osatex || (R.r.mode & R_SHADOW)) { copy_v3_v3(shi->dxco, spoint->dtco); copy_v3_v3(shi->dyco, spoint->dsco); } @@ -356,7 +357,7 @@ void shade_input_set_strand(ShadeInput *shi, StrandRen *strand, StrandPoint *spo copy_v3_v3(shi->facenor, spoint->nor); /* shade_input_set_normals equivalent */ - if(shi->mat->mode & MA_TANGENT_STR) { + if (shi->mat->mode & MA_TANGENT_STR) { copy_v3_v3(shi->vn, spoint->tan); } else { @@ -366,7 +367,7 @@ void shade_input_set_strand(ShadeInput *shi, StrandRen *strand, StrandPoint *spo cross_v3_v3v3(shi->vn, cross, spoint->tan); normalize_v3(shi->vn); - if(dot_v3v3(shi->vn, shi->view) < 0.0f) + if (dot_v3v3(shi->vn, shi->view) < 0.0f) negate_v3(shi->vn); } @@ -381,57 +382,57 @@ void shade_input_set_strand_texco(ShadeInput *shi, StrandRen *strand, StrandVert int mode= shi->mode; /* or-ed result for all nodes */ short texco= shi->mat->texco; - if((shi->mat->texco & TEXCO_REFL)) { + if ((shi->mat->texco & TEXCO_REFL)) { /* shi->dxview, shi->dyview, not supported */ } - if(shi->osatex && (texco & (TEXCO_NORM|TEXCO_REFL))) { + if (shi->osatex && (texco & (TEXCO_NORM|TEXCO_REFL))) { /* not supported */ } - if(mode & (MA_TANGENT_V|MA_NORMAP_TANG)) { + if (mode & (MA_TANGENT_V|MA_NORMAP_TANG)) { copy_v3_v3(shi->tang, spoint->tan); copy_v3_v3(shi->nmaptang, spoint->tan); } - if(mode & MA_STR_SURFDIFF) { + if (mode & MA_STR_SURFDIFF) { float *surfnor= RE_strandren_get_surfnor(obr, strand, 0); - if(surfnor) + if (surfnor) copy_v3_v3(shi->surfnor, surfnor); else copy_v3_v3(shi->surfnor, shi->vn); - if(shi->mat->strand_surfnor > 0.0f) { + if (shi->mat->strand_surfnor > 0.0f) { shi->surfdist= 0.0f; - for(sv=strand->vert; sv!=svert; sv++) + for (sv=strand->vert; sv!=svert; sv++) shi->surfdist+=len_v3v3(sv->co, (sv+1)->co); shi->surfdist += spoint->t*len_v3v3(sv->co, (sv+1)->co); } } - if(R.r.mode & R_SPEED) { + if (R.r.mode & R_SPEED) { float *speed; speed= RE_strandren_get_winspeed(shi->obi, strand, 0); - if(speed) + if (speed) copy_v4_v4(shi->winspeed, speed); else shi->winspeed[0]= shi->winspeed[1]= shi->winspeed[2]= shi->winspeed[3]= 0.0f; } /* shade_input_set_shade_texco equivalent */ - if(texco & NEED_UV) { - if(texco & TEXCO_ORCO) { + if (texco & NEED_UV) { + if (texco & TEXCO_ORCO) { copy_v3_v3(shi->lo, strand->orco); /* no shi->osatex, orco derivatives are zero */ } - if(texco & TEXCO_GLOB) { + if (texco & TEXCO_GLOB) { copy_v3_v3(shi->gl, shi->co); mul_m4_v3(R.viewinv, shi->gl); - if(shi->osatex) { + if (shi->osatex) { copy_v3_v3(shi->dxgl, shi->dxco); mul_mat3_m4_v3(R.viewinv, shi->dxgl); copy_v3_v3(shi->dygl, shi->dyco); @@ -439,16 +440,16 @@ void shade_input_set_strand_texco(ShadeInput *shi, StrandRen *strand, StrandVert } } - if(texco & TEXCO_STRAND) { + if (texco & TEXCO_STRAND) { shi->strandco= spoint->strandco; - if(shi->osatex) { + if (shi->osatex) { shi->dxstrand= spoint->dtstrandco; shi->dystrand= 0.0f; } } - if((texco & TEXCO_UV) || (mode & (MA_VERTEXCOL|MA_VERTEXCOLP|MA_FACETEXTURE))) { + if ((texco & TEXCO_UV) || (mode & (MA_VERTEXCOL|MA_VERTEXCOLP|MA_FACETEXTURE))) { MCol *mcol; float *uv; char *name; @@ -459,7 +460,7 @@ void shade_input_set_strand_texco(ShadeInput *shi, StrandRen *strand, StrandVert shi->actuv= obr->actmtface; shi->actcol= obr->actmcol; - if(mode & (MA_VERTEXCOL|MA_VERTEXCOLP)) { + if (mode & (MA_VERTEXCOL|MA_VERTEXCOLP)) { for (i=0; (mcol=RE_strandren_get_mcol(obr, strand, i, &name, 0)); i++) { ShadeInputCol *scol= &shi->col[i]; char *cp= (char*)mcol; @@ -473,7 +474,7 @@ void shade_input_set_strand_texco(ShadeInput *shi, StrandRen *strand, StrandVert scol->col[3]= cp[0]/255.0f; } - if(shi->totcol) { + if (shi->totcol) { shi->vcol[0]= shi->col[shi->actcol].col[0]; shi->vcol[1]= shi->col[shi->actcol].col[1]; shi->vcol[2]= shi->col[shi->actcol].col[2]; @@ -493,7 +494,7 @@ void shade_input_set_strand_texco(ShadeInput *shi, StrandRen *strand, StrandVert shi->totuv++; suv->name= name; - if(strandbuf->overrideuv == i) { + if (strandbuf->overrideuv == i) { suv->uv[0]= -1.0f; suv->uv[1]= spoint->strandco; suv->uv[2]= 0.0f; @@ -504,15 +505,15 @@ void shade_input_set_strand_texco(ShadeInput *shi, StrandRen *strand, StrandVert suv->uv[2]= 0.0f; /* texture.c assumes there are 3 coords */ } - if(shi->osatex) { + if (shi->osatex) { suv->dxuv[0]= 0.0f; suv->dxuv[1]= 0.0f; suv->dyuv[0]= 0.0f; suv->dyuv[1]= 0.0f; } - if((mode & MA_FACETEXTURE) && i==obr->actmtface) { - if((mode & (MA_VERTEXCOL|MA_VERTEXCOLP))==0) { + if ((mode & MA_FACETEXTURE) && i==obr->actmtface) { + if ((mode & (MA_VERTEXCOL|MA_VERTEXCOLP))==0) { shi->vcol[0]= 1.0f; shi->vcol[1]= 1.0f; shi->vcol[2]= 1.0f; @@ -521,14 +522,14 @@ void shade_input_set_strand_texco(ShadeInput *shi, StrandRen *strand, StrandVert } } - if(shi->totuv == 0) { + if (shi->totuv == 0) { ShadeInputUV *suv= &shi->uv[0]; suv->uv[0]= 0.0f; suv->uv[1]= spoint->strandco; suv->uv[2]= 0.0f; /* texture.c assumes there are 3 coords */ - if(mode & MA_FACETEXTURE) { + if (mode & MA_FACETEXTURE) { /* no tface? set at 1.0f */ shi->vcol[0]= 1.0f; shi->vcol[1]= 1.0f; @@ -539,18 +540,18 @@ void shade_input_set_strand_texco(ShadeInput *shi, StrandRen *strand, StrandVert } - if(texco & TEXCO_NORM) { + if (texco & TEXCO_NORM) { shi->orn[0]= -shi->vn[0]; shi->orn[1]= -shi->vn[1]; shi->orn[2]= -shi->vn[2]; } - if(texco & TEXCO_STRESS) { + if (texco & TEXCO_STRESS) { /* not supported */ } - if(texco & TEXCO_TANGENT) { - if((mode & MA_TANGENT_V)==0) { + if (texco & TEXCO_TANGENT) { + if ((mode & MA_TANGENT_V)==0) { /* just prevent surprises */ shi->tang[0]= shi->tang[1]= shi->tang[2]= 0.0f; shi->nmaptang[0]= shi->nmaptang[1]= shi->nmaptang[2]= 0.0f; @@ -559,14 +560,14 @@ void shade_input_set_strand_texco(ShadeInput *shi, StrandRen *strand, StrandVert } /* this only avalailable for scanline renders */ - if(shi->depth==0) { - if(texco & TEXCO_WINDOW) { + if (shi->depth==0) { + if (texco & TEXCO_WINDOW) { shi->winco[0]= -1.0f + 2.0f*spoint->x/(float)R.winx; shi->winco[1]= -1.0f + 2.0f*spoint->y/(float)R.winy; shi->winco[2]= 0.0f; /* not supported */ - if(shi->osatex) { + if (shi->osatex) { shi->dxwin[0]= 0.0f; shi->dywin[1]= 0.0f; shi->dxwin[0]= 0.0f; @@ -574,13 +575,13 @@ void shade_input_set_strand_texco(ShadeInput *shi, StrandRen *strand, StrandVert } } - if(texco & TEXCO_STICKY) { + if (texco & TEXCO_STICKY) { /* not supported */ } } if (shi->do_manage) { - if(mode & (MA_VERTEXCOL|MA_VERTEXCOLP|MA_FACETEXTURE)) { + if (mode & (MA_VERTEXCOL|MA_VERTEXCOLP|MA_FACETEXTURE)) { srgb_to_linearrgb_v3_v3(shi->vcol, shi->vcol); } } @@ -593,10 +594,10 @@ void shade_input_calc_viewco(ShadeInput *shi, float x, float y, float z, float v /* returns not normalized, so is in viewplane coords */ calc_view_vector(view, x, y); - if(shi->mat->material_type == MA_TYPE_WIRE) { + if (shi->mat->material_type == MA_TYPE_WIRE) { /* wire cannot use normal for calculating shi->co, so * we reconstruct the coordinate less accurate */ - if(R.r.mode & R_ORTHO) + if (R.r.mode & R_ORTHO) calc_renderco_ortho(co, x, y, z); else calc_renderco_zbuf(co, view, z); @@ -606,13 +607,13 @@ void shade_input_calc_viewco(ShadeInput *shi, float x, float y, float z, float v float fac, dface, v1[3]; copy_v3_v3(v1, shi->v1->co); - if(shi->obi->flag & R_TRANSFORMED) + if (shi->obi->flag & R_TRANSFORMED) mul_m4_v3(shi->obi->mat, v1); dface = dot_v3v3(v1, shi->facenor); /* ortho viewplane cannot intersect using view vector originating in (0,0,0) */ - if(R.r.mode & R_ORTHO) { + if (R.r.mode & R_ORTHO) { /* x and y 3d coordinate can be derived from pixel coord and winmat */ float fx= 2.0f/(R.winx*R.winmat[0][0]); float fy= 2.0f/(R.winy*R.winmat[1][1]); @@ -621,28 +622,28 @@ void shade_input_calc_viewco(ShadeInput *shi, float x, float y, float z, float v co[1]= (y - 0.5f*R.winy)*fy - R.winmat[3][1]/R.winmat[1][1]; /* using a*x + b*y + c*z = d equation, (a b c) is normal */ - if(shi->facenor[2]!=0.0f) + if (shi->facenor[2]!=0.0f) co[2]= (dface - shi->facenor[0]*co[0] - shi->facenor[1]*co[1])/shi->facenor[2]; else co[2]= 0.0f; - if(dxco && dyco) { + if (dxco && dyco) { dxco[0]= fx; dxco[1]= 0.0f; - if(shi->facenor[2]!=0.0f) + if (shi->facenor[2]!=0.0f) dxco[2]= -(shi->facenor[0]*fx)/shi->facenor[2]; else dxco[2]= 0.0f; dyco[0]= 0.0f; dyco[1]= fy; - if(shi->facenor[2]!=0.0f) + if (shi->facenor[2]!=0.0f) dyco[2]= -(shi->facenor[1]*fy)/shi->facenor[2]; else dyco[2]= 0.0f; - if(dxyview) { - if(co[2]!=0.0f) fac= 1.0f/co[2]; else fac= 0.0f; + if (dxyview) { + if (co[2]!=0.0f) fac= 1.0f/co[2]; else fac= 0.0f; dxyview[0]= -R.viewdx*fac; dxyview[1]= -R.viewdy*fac; } @@ -660,7 +661,7 @@ void shade_input_calc_viewco(ShadeInput *shi, float x, float y, float z, float v co[2]= fac*view[2]; /* pixel dx/dy for render coord */ - if(dxco && dyco) { + if (dxco && dyco) { float u= dface/(div - R.viewdx*shi->facenor[0]); float v= dface/(div - R.viewdy*shi->facenor[1]); @@ -672,8 +673,8 @@ void shade_input_calc_viewco(ShadeInput *shi, float x, float y, float z, float v dyco[1]= co[1]- (view[1]-R.viewdy)*v; dyco[2]= co[2]- (view[2])*v; - if(dxyview) { - if(fac!=0.0f) fac= 1.0f/fac; + if (dxyview) { + if (fac!=0.0f) fac= 1.0f/fac; dxyview[0]= -R.viewdx*fac; dxyview[1]= -R.viewdy*fac; } @@ -704,11 +705,11 @@ void shade_input_set_viewco(ShadeInput *shi, float x, float y, float xs, float y shi->scanco[2]= z; /* check if we need derivatives */ - if(shi->osatex || (R.r.mode & R_SHADOW)) { + if (shi->osatex || (R.r.mode & R_SHADOW)) { dxco= shi->dxco; dyco= shi->dyco; - if((shi->mat->texco & TEXCO_REFL)) + if ((shi->mat->texco & TEXCO_REFL)) dxyview= &shi->dxview; } @@ -720,27 +721,27 @@ void shade_input_set_uv(ShadeInput *shi) { VlakRen *vlr= shi->vlr; - if((vlr->flag & R_SMOOTH) || (shi->mat->texco & NEED_UV) || (shi->passflag & SCE_PASS_UV)) { + if ((vlr->flag & R_SMOOTH) || (shi->mat->texco & NEED_UV) || (shi->passflag & SCE_PASS_UV)) { float v1[3], v2[3], v3[3]; copy_v3_v3(v1, shi->v1->co); copy_v3_v3(v2, shi->v2->co); copy_v3_v3(v3, shi->v3->co); - if(shi->obi->flag & R_TRANSFORMED) { + if (shi->obi->flag & R_TRANSFORMED) { mul_m4_v3(shi->obi->mat, v1); mul_m4_v3(shi->obi->mat, v2); mul_m4_v3(shi->obi->mat, v3); } /* exception case for wire render of edge */ - if(vlr->v2==vlr->v3) { + if (vlr->v2==vlr->v3) { float lend, lenc; lend= len_v3v3(v2, v1); lenc= len_v3v3(shi->co, v1); - if(lend==0.0f) { + if (lend==0.0f) { shi->u=shi->v= 0.0f; } else { @@ -748,7 +749,7 @@ void shade_input_set_uv(ShadeInput *shi) shi->v= 0.0f; } - if(shi->osatex) { + if (shi->osatex) { shi->dx_u= 0.0f; shi->dx_v= 0.0f; shi->dy_u= 0.0f; @@ -774,7 +775,7 @@ void shade_input_set_uv(ShadeInput *shi) shi->u= (shi->co[axis1]-v3[axis1])*t11-(shi->co[axis2]-v3[axis2])*t10; shi->v= (shi->co[axis2]-v3[axis2])*t00-(shi->co[axis1]-v3[axis1])*t01; - if(shi->osatex) { + if (shi->osatex) { shi->dx_u= shi->dxco[axis1]*t11- shi->dxco[axis2]*t10; shi->dx_v= shi->dxco[axis2]*t00- shi->dxco[axis1]*t01; shi->dy_u= shi->dyco[axis1]*t11- shi->dyco[axis2]*t10; @@ -796,18 +797,18 @@ void shade_input_set_normals(ShadeInput *shi) shi->flippednor = 0; /* test flip normals to viewing direction */ - if(!(shi->vlr->flag & R_TANGENT)) { - if(dot_v3v3(shi->facenor, shi->view) < 0.0f) { + if (!(shi->vlr->flag & R_TANGENT)) { + if (dot_v3v3(shi->facenor, shi->view) < 0.0f) { negate_v3(shi->facenor); shi->flippednor= 1; } } /* calculate vertexnormals */ - if(shi->vlr->flag & R_SMOOTH) { + if (shi->vlr->flag & R_SMOOTH) { float *n1= shi->n1, *n2= shi->n2, *n3= shi->n3; - if(shi->flippednor) { + if (shi->flippednor) { negate_v3(n1); negate_v3(n2); negate_v3(n3); @@ -831,8 +832,8 @@ void shade_input_set_normals(ShadeInput *shi) copy_v3_v3(shi->vno, shi->vn); /* flip normals to viewing direction */ - if(!(shi->vlr->flag & R_TANGENT)) - if(dot_v3v3(shi->facenor, shi->view) < 0.0f) + if (!(shi->vlr->flag & R_TANGENT)) + if (dot_v3v3(shi->facenor, shi->view) < 0.0f) shade_input_flip_normals(shi); } @@ -843,7 +844,7 @@ void shade_input_set_vertex_normals(ShadeInput *shi) float l= 1.0f+u+v; /* calculate vertexnormals */ - if(shi->vlr->flag & R_SMOOTH) { + if (shi->vlr->flag & R_SMOOTH) { float *n1= shi->n1, *n2= shi->n2, *n3= shi->n3; shi->vn[0]= l*n3[0]-u*n1[0]-v*n2[0]; @@ -898,9 +899,9 @@ void shade_input_set_shade_texco(ShadeInput *shi) short texco= shi->mat->texco; /* calculate dxno */ - if(shi->vlr->flag & R_SMOOTH) { + if (shi->vlr->flag & R_SMOOTH) { - if(shi->osatex && (texco & (TEXCO_NORM|TEXCO_REFL)) ) { + if (shi->osatex && (texco & (TEXCO_NORM|TEXCO_REFL)) ) { float *n1= shi->n1, *n2= shi->n2, *n3= shi->n3; dl= shi->dx_u+shi->dx_v; @@ -920,7 +921,7 @@ void shade_input_set_shade_texco(ShadeInput *shi) float *tangent, *s1, *s2, *s3; float tl, tu, tv; - if(shi->vlr->flag & R_SMOOTH) { + if (shi->vlr->flag & R_SMOOTH) { tl= l; tu= u; tv= v; @@ -936,17 +937,17 @@ void shade_input_set_shade_texco(ShadeInput *shi) shi->tang[0]= shi->tang[1]= shi->tang[2]= 0.0f; shi->nmaptang[0]= shi->nmaptang[1]= shi->nmaptang[2]= 0.0f; - if(mode & MA_TANGENT_V) { + if (mode & MA_TANGENT_V) { s1 = RE_vertren_get_tangent(obr, v1, 0); s2 = RE_vertren_get_tangent(obr, v2, 0); s3 = RE_vertren_get_tangent(obr, v3, 0); - if(s1 && s2 && s3) { + if (s1 && s2 && s3) { shi->tang[0]= (tl*s3[0] - tu*s1[0] - tv*s2[0]); shi->tang[1]= (tl*s3[1] - tu*s1[1] - tv*s2[1]); shi->tang[2]= (tl*s3[2] - tu*s1[2] - tv*s2[2]); - if(obi->flag & R_TRANSFORMED) + if (obi->flag & R_TRANSFORMED) mul_m3_v3(obi->nmat, shi->tang); normalize_v3(shi->tang); @@ -954,10 +955,10 @@ void shade_input_set_shade_texco(ShadeInput *shi) } } - if(mode & MA_NORMAP_TANG || R.flag & R_NEED_TANGENT) { + if (mode & MA_NORMAP_TANG || R.flag & R_NEED_TANGENT) { tangent= RE_vlakren_get_nmap_tangent(obr, shi->vlr, 0); - if(tangent) { + if (tangent) { int j1= shi->i1, j2= shi->i2, j3= shi->i3; float c0[3], c1[3], c2[3]; @@ -988,12 +989,12 @@ void shade_input_set_shade_texco(ShadeInput *shi) } } - if(mode & MA_STR_SURFDIFF) { + if (mode & MA_STR_SURFDIFF) { float *surfnor= RE_vlakren_get_surfnor(obr, shi->vlr, 0); - if(surfnor) { + if (surfnor) { copy_v3_v3(shi->surfnor, surfnor); - if(obi->flag & R_TRANSFORMED) + if (obi->flag & R_TRANSFORMED) mul_m3_v3(obi->nmat, shi->surfnor); } else @@ -1002,13 +1003,13 @@ void shade_input_set_shade_texco(ShadeInput *shi) shi->surfdist= 0.0f; } - if(R.r.mode & R_SPEED) { + if (R.r.mode & R_SPEED) { float *s1, *s2, *s3; s1= RE_vertren_get_winspeed(obi, v1, 0); s2= RE_vertren_get_winspeed(obi, v2, 0); s3= RE_vertren_get_winspeed(obi, v3, 0); - if(s1 && s2 && s3) { + if (s1 && s2 && s3) { shi->winspeed[0]= (l*s3[0] - u*s1[0] - v*s2[0]); shi->winspeed[1]= (l*s3[1] - u*s1[1] - v*s2[1]); shi->winspeed[2]= (l*s3[2] - u*s1[2] - v*s2[2]); @@ -1020,14 +1021,14 @@ void shade_input_set_shade_texco(ShadeInput *shi) } /* pass option forces UV calc */ - if(shi->passflag & SCE_PASS_UV) + if (shi->passflag & SCE_PASS_UV) texco |= (NEED_UV|TEXCO_UV); /* texture coordinates. shi->dxuv shi->dyuv have been set */ - if(texco & NEED_UV) { + if (texco & NEED_UV) { - if(texco & TEXCO_ORCO) { - if(v1->orco) { + if (texco & TEXCO_ORCO) { + if (v1->orco) { float *o1, *o2, *o3; o1= v1->orco; @@ -1038,7 +1039,7 @@ void shade_input_set_shade_texco(ShadeInput *shi) shi->lo[1]= l*o3[1]-u*o1[1]-v*o2[1]; shi->lo[2]= l*o3[2]-u*o1[2]-v*o2[2]; - if(shi->osatex) { + if (shi->osatex) { dl= shi->dx_u+shi->dx_v; shi->dxlo[0]= dl*o3[0]-shi->dx_u*o1[0]-shi->dx_v*o2[0]; shi->dxlo[1]= dl*o3[1]-shi->dx_u*o1[1]-shi->dx_v*o2[1]; @@ -1053,10 +1054,10 @@ void shade_input_set_shade_texco(ShadeInput *shi) copy_v3_v3(shi->duplilo, obi->dupliorco); } - if(texco & TEXCO_GLOB) { + if (texco & TEXCO_GLOB) { copy_v3_v3(shi->gl, shi->co); mul_m4_v3(R.viewinv, shi->gl); - if(shi->osatex) { + if (shi->osatex) { copy_v3_v3(shi->dxgl, shi->dxco); mul_mat3_m4_v3(R.viewinv, shi->dxgl); copy_v3_v3(shi->dygl, shi->dyco); @@ -1064,9 +1065,9 @@ void shade_input_set_shade_texco(ShadeInput *shi) } } - if(texco & TEXCO_STRAND) { + if (texco & TEXCO_STRAND) { shi->strandco= (l*v3->accum - u*v1->accum - v*v2->accum); - if(shi->osatex) { + if (shi->osatex) { dl= shi->dx_u+shi->dx_v; shi->dxstrand= dl*v3->accum-shi->dx_u*v1->accum-shi->dx_v*v2->accum; dl= shi->dy_u+shi->dy_v; @@ -1074,7 +1075,7 @@ void shade_input_set_shade_texco(ShadeInput *shi) } } - if((texco & TEXCO_UV) || (mode & (MA_VERTEXCOL|MA_VERTEXCOLP|MA_FACETEXTURE))) { + if ((texco & TEXCO_UV) || (mode & (MA_VERTEXCOL|MA_VERTEXCOLP|MA_FACETEXTURE))) { VlakRen *vlr= shi->vlr; MTFace *tface; MCol *mcol; @@ -1089,7 +1090,7 @@ void shade_input_set_shade_texco(ShadeInput *shi) shi->actuv= obr->actmtface; shi->actcol= obr->actmcol; - if(mode & (MA_VERTEXCOL|MA_VERTEXCOLP)) { + if (mode & (MA_VERTEXCOL|MA_VERTEXCOLP)) { for (i=0; (mcol=RE_vlakren_get_mcol(obr, vlr, i, &name, 0)); i++) { ShadeInputCol *scol= &shi->col[i]; char *cp1, *cp2, *cp3; @@ -1119,7 +1120,7 @@ void shade_input_set_shade_texco(ShadeInput *shi) } } - if(shi->totcol) { + if (shi->totcol) { shi->vcol[0]= shi->col[shi->actcol].col[0]; shi->vcol[1]= shi->col[shi->actcol].col[1]; shi->vcol[2]= shi->col[shi->actcol].col[2]; @@ -1148,7 +1149,7 @@ void shade_input_set_shade_texco(ShadeInput *shi) suv->uv[1]= -1.0f + 2.0f*(l*uv3[1]-u*uv1[1]-v*uv2[1]); suv->uv[2]= 0.0f; /* texture.c assumes there are 3 coords */ - if(shi->osatex) { + if (shi->osatex) { float duv[2]; dl= shi->dx_u+shi->dx_v; @@ -1166,14 +1167,14 @@ void shade_input_set_shade_texco(ShadeInput *shi) suv->dyuv[1]= 2.0f*(dl*uv3[1]-duv[0]*uv1[1]-duv[1]*uv2[1]); } - if((mode & MA_FACETEXTURE) && i==obr->actmtface) { - if((mode & (MA_VERTEXCOL|MA_VERTEXCOLP))==0) { + if ((mode & MA_FACETEXTURE) && i==obr->actmtface) { + if ((mode & (MA_VERTEXCOL|MA_VERTEXCOLP))==0) { shi->vcol[0]= 1.0f; shi->vcol[1]= 1.0f; shi->vcol[2]= 1.0f; shi->vcol[3]= 1.0f; } - if(tface->tpage) { + if (tface->tpage) { render_realtime_texture(shi, tface->tpage); } } @@ -1185,14 +1186,14 @@ void shade_input_set_shade_texco(ShadeInput *shi) shi->dupliuv[1]= -1.0f + 2.0f*obi->dupliuv[1]; shi->dupliuv[2]= 0.0f; - if(shi->totuv == 0) { + if (shi->totuv == 0) { ShadeInputUV *suv= &shi->uv[0]; suv->uv[0]= 2.0f*(u+.5f); suv->uv[1]= 2.0f*(v+.5f); suv->uv[2]= 0.0f; /* texture.c assumes there are 3 coords */ - if(mode & MA_FACETEXTURE) { + if (mode & MA_FACETEXTURE) { /* no tface? set at 1.0f */ shi->vcol[0]= 1.0f; shi->vcol[1]= 1.0f; @@ -1202,28 +1203,28 @@ void shade_input_set_shade_texco(ShadeInput *shi) } } - if(texco & TEXCO_NORM) { + if (texco & TEXCO_NORM) { shi->orn[0]= -shi->vn[0]; shi->orn[1]= -shi->vn[1]; shi->orn[2]= -shi->vn[2]; } - if(texco & TEXCO_STRESS) { + if (texco & TEXCO_STRESS) { float *s1, *s2, *s3; s1= RE_vertren_get_stress(obr, v1, 0); s2= RE_vertren_get_stress(obr, v2, 0); s3= RE_vertren_get_stress(obr, v3, 0); - if(s1 && s2 && s3) { + if (s1 && s2 && s3) { shi->stress= l*s3[0] - u*s1[0] - v*s2[0]; - if(shi->stress<1.0f) shi->stress-= 1.0f; + if (shi->stress<1.0f) shi->stress-= 1.0f; else shi->stress= (shi->stress-1.0f)/shi->stress; } else shi->stress= 0.0f; } - if(texco & TEXCO_TANGENT) { - if((mode & MA_TANGENT_V)==0) { + if (texco & TEXCO_TANGENT) { + if ((mode & MA_TANGENT_V)==0) { /* just prevent surprises */ shi->tang[0]= shi->tang[1]= shi->tang[2]= 0.0f; shi->nmaptang[0]= shi->nmaptang[1]= shi->nmaptang[2]= 0.0f; @@ -1232,15 +1233,15 @@ void shade_input_set_shade_texco(ShadeInput *shi) } /* this only avalailable for scanline renders */ - if(shi->depth==0) { + if (shi->depth==0) { float x= shi->xs; float y= shi->ys; - if(texco & TEXCO_WINDOW) { + if (texco & TEXCO_WINDOW) { shi->winco[0]= -1.0f + 2.0f*x/(float)R.winx; shi->winco[1]= -1.0f + 2.0f*y/(float)R.winy; shi->winco[2]= 0.0f; - if(shi->osatex) { + if (shi->osatex) { shi->dxwin[0]= 2.0f/(float)R.winx; shi->dywin[1]= 2.0f/(float)R.winy; shi->dxwin[1]= shi->dxwin[2]= 0.0f; @@ -1248,14 +1249,14 @@ void shade_input_set_shade_texco(ShadeInput *shi) } } - if(texco & TEXCO_STICKY) { + if (texco & TEXCO_STICKY) { float *s1, *s2, *s3; s1= RE_vertren_get_sticky(obr, v1, 0); s2= RE_vertren_get_sticky(obr, v2, 0); s3= RE_vertren_get_sticky(obr, v3, 0); - if(s1 && s2 && s3) { + if (s1 && s2 && s3) { float obwinmat[4][4], winmat[4][4], ho1[4], ho2[4], ho3[4]; float Zmulx, Zmuly; float hox, hoy, l, dl, u, v; @@ -1265,7 +1266,7 @@ void shade_input_set_shade_texco(ShadeInput *shi) Zmulx= ((float)R.winx)/2.0f; Zmuly= ((float)R.winy)/2.0f; zbuf_make_winmat(&R, winmat); - if(shi->obi->flag & R_TRANSFORMED) + if (shi->obi->flag & R_TRANSFORMED) mult_m4_m4m4(obwinmat, winmat, obi->mat); else copy_m4_m4(obwinmat, winmat); @@ -1295,7 +1296,7 @@ void shade_input_set_shade_texco(ShadeInput *shi) shi->sticky[1]= l*s3[1]-u*s1[1]-v*s2[1]; shi->sticky[2]= 0.0f; - if(shi->osatex) { + if (shi->osatex) { float dxuv[2], dyuv[2]; dxuv[0]= s11/Zmulx; dxuv[1]= - s01/Zmulx; @@ -1318,7 +1319,7 @@ void shade_input_set_shade_texco(ShadeInput *shi) * else un-initialized values are used */ if (shi->do_manage) { - if(mode & (MA_VERTEXCOL|MA_VERTEXCOLP|MA_FACETEXTURE)) { + if (mode & (MA_VERTEXCOL|MA_VERTEXCOLP|MA_FACETEXTURE)) { srgb_to_linearrgb_v3_v3(shi->vcol, shi->vcol); } } @@ -1355,7 +1356,7 @@ void shade_sample_initialize(ShadeSample *ssamp, RenderPart *pa, RenderLayer *rl tot= R.osa==0?1:R.osa; - for(a=0; a<tot; a++) { + for (a=0; a<tot; a++) { shade_input_initialize(&ssamp->shi[a], pa, rl, a); memset(&ssamp->shr[a], 0, sizeof(ShadeResult)); } @@ -1366,19 +1367,19 @@ void shade_sample_initialize(ShadeSample *ssamp, RenderPart *pa, RenderLayer *rl /* Do AO or (future) GI */ void shade_samples_do_AO(ShadeSample *ssamp) { - if(!(R.r.mode & R_SHADOW)) + if (!(R.r.mode & R_SHADOW)) return; - if(!(R.r.mode & R_RAYTRACE) && !(R.wrld.ao_gather_method == WO_AOGATHER_APPROX)) + if (!(R.r.mode & R_RAYTRACE) && !(R.wrld.ao_gather_method == WO_AOGATHER_APPROX)) return; - if(R.wrld.mode & (WO_AMB_OCC|WO_ENV_LIGHT|WO_INDIRECT_LIGHT)) { + if (R.wrld.mode & (WO_AMB_OCC|WO_ENV_LIGHT|WO_INDIRECT_LIGHT)) { ShadeInput *shi= &ssamp->shi[0]; int sample; - if(((shi->passflag & SCE_PASS_COMBINED) && (shi->combinedflag & (SCE_PASS_AO|SCE_PASS_ENVIRONMENT|SCE_PASS_INDIRECT))) + if (((shi->passflag & SCE_PASS_COMBINED) && (shi->combinedflag & (SCE_PASS_AO|SCE_PASS_ENVIRONMENT|SCE_PASS_INDIRECT))) || (shi->passflag & (SCE_PASS_AO|SCE_PASS_ENVIRONMENT|SCE_PASS_INDIRECT))) - for(sample=0; sample<ssamp->tot; shi++, sample++) - if(!(shi->mode & MA_SHLESS)) + for (sample=0; sample<ssamp->tot; shi++, sample++) + if (!(shi->mode & MA_SHLESS)) ambient_occlusion(shi); /* stores in shi->ao[] */ } } @@ -1391,23 +1392,23 @@ void shade_samples_fill_with_ps(ShadeSample *ssamp, PixStr *ps, int x, int y) ssamp->tot= 0; - for(shi= ssamp->shi; ps; ps= ps->next) { + for (shi= ssamp->shi; ps; ps= ps->next) { shade_input_set_triangle(shi, ps->obi, ps->facenr, 1); - if(shi->vlr) { /* NULL happens for env material or for 'all z' */ + if (shi->vlr) { /* NULL happens for env material or for 'all z' */ unsigned short curmask= ps->mask; /* full osa is only set for OSA renders */ - if(shi->vlr->flag & R_FULL_OSA) { + if (shi->vlr->flag & R_FULL_OSA) { short shi_cp= 0, samp; - for(samp=0; samp<R.osa; samp++) { - if(curmask & (1<<samp)) { + for (samp=0; samp<R.osa; samp++) { + if (curmask & (1<<samp)) { /* zbuffer has this inverse corrected, ensures xs,ys are inside pixel */ xs= (float)x + R.jit[samp][0] + 0.5f; ys= (float)y + R.jit[samp][1] + 0.5f; - if(shi_cp) + if (shi_cp) shade_input_copy_triangle(shi, shi-1); shi->mask= (1<<samp); @@ -1415,7 +1416,7 @@ void shade_samples_fill_with_ps(ShadeSample *ssamp, PixStr *ps, int x, int y) shi->samplenr= R.shadowsamplenr[shi->thread]++; /* this counter is not being reset per pixel */ shade_input_set_viewco(shi, x, y, xs, ys, (float)ps->z); shade_input_set_uv(shi); - if(shi_cp==0) + if (shi_cp==0) shade_input_set_normals(shi); else /* XXX shi->flippednor messes up otherwise */ shade_input_set_vertex_normals(shi); @@ -1426,7 +1427,7 @@ void shade_samples_fill_with_ps(ShadeSample *ssamp, PixStr *ps, int x, int y) } } else { - if(R.osa) { + if (R.osa) { short b= R.samples->centmask[curmask]; xs= (float)x + R.samples->centLut[b & 15] + 0.5f; ys= (float)y + R.samples->centLut[b>>4] + 0.5f; @@ -1445,7 +1446,7 @@ void shade_samples_fill_with_ps(ShadeSample *ssamp, PixStr *ps, int x, int y) } /* total sample amount, shi->sample is static set in initialize */ - if(shi!=ssamp->shi) + if (shi!=ssamp->shi) ssamp->tot= (shi-1)->sample + 1; } } @@ -1456,7 +1457,7 @@ int shade_samples(ShadeSample *ssamp, PixStr *ps, int x, int y) { shade_samples_fill_with_ps(ssamp, ps, x, y); - if(ssamp->tot) { + if (ssamp->tot) { ShadeInput *shi= ssamp->shi; ShadeResult *shr= ssamp->shr; int samp; @@ -1465,15 +1466,15 @@ int shade_samples(ShadeSample *ssamp, PixStr *ps, int x, int y) shade_samples_do_AO(ssamp); /* if shade (all shadepinputs have same passflag) */ - if(ssamp->shi[0].passflag & ~(SCE_PASS_Z|SCE_PASS_INDEXOB|SCE_PASS_INDEXMA)) { + if (ssamp->shi[0].passflag & ~(SCE_PASS_Z|SCE_PASS_INDEXOB|SCE_PASS_INDEXMA)) { - for(samp=0; samp<ssamp->tot; samp++, shi++, shr++) { + for (samp=0; samp<ssamp->tot; samp++, shi++, shr++) { shade_input_set_shade_texco(shi); shade_input_do_shade(shi, shr); } } - else if(shi->passflag & SCE_PASS_Z) { - for(samp=0; samp<ssamp->tot; samp++, shi++, shr++) + else if (shi->passflag & SCE_PASS_Z) { + for (samp=0; samp<ssamp->tot; samp++, shi++, shr++) shr->z= -shi->co[2]; } diff --git a/source/blender/render/intern/source/shadeoutput.c b/source/blender/render/intern/source/shadeoutput.c index 04fde7bf0b9..ece6e464bdf 100644 --- a/source/blender/render/intern/source/shadeoutput.c +++ b/source/blender/render/intern/source/shadeoutput.c @@ -66,11 +66,11 @@ extern struct Render R; ListBase *get_lights(ShadeInput *shi) { - if(R.r.scemode & R_PREVIEWBUTS) + if (R.r.scemode & R_PREVIEWBUTS) return &R.lights; - if(shi->light_override) + if (shi->light_override) return &shi->light_override->gobject; - if(shi->mat && shi->mat->group) + if (shi->mat && shi->mat->group) return &shi->mat->group->gobject; return &R.lights; @@ -96,7 +96,7 @@ static void fogcolor(float *colf, float *rco, float *view) dview[2]= -stepsize; startdist= -rco[2] + BLI_frand(); - for(dist= startdist; dist>R.wrld.miststa; dist-= stepsize) { + for (dist= startdist; dist>R.wrld.miststa; dist-= stepsize) { hor[0]= R.wrld.horr; hor[1]= R.wrld.horg; hor[2]= R.wrld.horb; alpha= 1.0f; @@ -127,13 +127,13 @@ float mistfactor(float zcor, float const co[3]) /* fac= -co[2]-R.wrld.miststa; */ - if(fac>0.0f) { - if(fac< R.wrld.mistdist) { + if (fac>0.0f) { + if (fac< R.wrld.mistdist) { fac= (fac/(R.wrld.mistdist)); - if(R.wrld.mistype==0) fac*= fac; - else if(R.wrld.mistype==1); + if (R.wrld.mistype==0) fac*= fac; + else if (R.wrld.mistype==1); else fac= sqrt(fac); } else fac= 1.0f; @@ -141,13 +141,13 @@ float mistfactor(float zcor, float const co[3]) else fac= 0.0f; /* height switched off mist */ - if(R.wrld.misthi!=0.0f && fac!=0.0f) { + if (R.wrld.misthi!=0.0f && fac!=0.0f) { /* at height misthi the mist is completely gone */ hi= R.viewinv[0][2]*co[0]+R.viewinv[1][2]*co[1]+R.viewinv[2][2]*co[2]+R.viewinv[3][2]; - if(hi>R.wrld.misthi) fac= 0.0f; - else if(hi>0.0f) { + if (hi>R.wrld.misthi) fac= 0.0f; + else if (hi>0.0f) { hi= (R.wrld.misthi-hi)/R.wrld.misthi; fac*= hi*hi; } @@ -166,7 +166,7 @@ static void spothalo(struct LampRen *lar, ShadeInput *shi, float *intens) *intens= 0.0f; haint= lar->haint; - if(R.r.mode & R_ORTHO) { + if (R.r.mode & R_ORTHO) { /* camera pos (view vector) cannot be used... */ /* camera position (cox,coy,0) rotate around lamp */ p1[0]= shi->co[0]-lar->co[0]; @@ -186,17 +186,17 @@ static void spothalo(struct LampRen *lar, ShadeInput *shi, float *intens) copy_v3db_v3fl(nray, shi->view); mul_m3_v3_double(lar->imat, nray); - if(R.wrld.mode & WO_MIST) { + if (R.wrld.mode & WO_MIST) { /* patchy... */ haint *= mistfactor(-lar->co[2], lar->co); - if(haint==0.0f) { + if (haint==0.0f) { return; } } /* rotate maxz */ - if(shi->co[2]==0.0f) doclip= 0; /* for when halo at sky */ + if (shi->co[2]==0.0f) doclip= 0; /* for when halo at sky */ else { p1[0]= shi->co[0]-lar->co[0]; p1[1]= shi->co[1]-lar->co[1]; @@ -206,7 +206,7 @@ static void spothalo(struct LampRen *lar, ShadeInput *shi, float *intens) maxz*= lar->sh_zfac; maxy= lar->imat[0][1]*p1[0]+lar->imat[1][1]*p1[1]+lar->imat[2][1]*p1[2]; - if( fabs(nray[2]) < FLT_EPSILON ) use_yco= 1; + if ( fabs(nray[2]) < FLT_EPSILON ) use_yco= 1; } /* scale z to make sure volume is normalized */ @@ -230,7 +230,7 @@ static void spothalo(struct LampRen *lar, ShadeInput *shi, float *intens) else { disc = b*b - a*c; - if(disc==0.0) { + if (disc==0.0) { t1=t2= (-b)/ a; snijp= 2; } @@ -241,11 +241,11 @@ static void spothalo(struct LampRen *lar, ShadeInput *shi, float *intens) snijp= 2; } } - if(snijp==2) { + if (snijp==2) { int ok1=0, ok2=0; /* sort */ - if(t1>t2) { + if (t1>t2) { a= t1; t1= t2; t2= a; } @@ -254,52 +254,52 @@ static void spothalo(struct LampRen *lar, ShadeInput *shi, float *intens) p2[2]= npos[2] + t2*nray[2]; /* evaluate both points */ - if(p1[2]<=0.0f) ok1= 1; - if(p2[2]<=0.0f && t1!=t2) ok2= 1; + if (p1[2]<=0.0f) ok1= 1; + if (p2[2]<=0.0f && t1!=t2) ok2= 1; /* at least 1 point with negative z */ - if(ok1==0 && ok2==0) return; + if (ok1==0 && ok2==0) return; /* intersction point with -ladist, the bottom of the cone */ - if(use_yco==0) { + if (use_yco==0) { t3= ((double)(-ladist)-npos[2])/nray[2]; /* de we have to replace one of the intersection points? */ - if(ok1) { - if(p1[2]<-ladist) t1= t3; + if (ok1) { + if (p1[2]<-ladist) t1= t3; } else { t1= t3; } - if(ok2) { - if(p2[2]<-ladist) t2= t3; + if (ok2) { + if (p2[2]<-ladist) t2= t3; } else { t2= t3; } } - else if(ok1==0 || ok2==0) return; + else if (ok1==0 || ok2==0) return; /* at least 1 visible interesction point */ - if(t1<0.0 && t2<0.0) return; + if (t1<0.0 && t2<0.0) return; - if(t1<0.0) t1= 0.0; - if(t2<0.0) t2= 0.0; + if (t1<0.0) t1= 0.0; + if (t2<0.0) t2= 0.0; - if(t1==t2) return; + if (t1==t2) return; /* sort again to be sure */ - if(t1>t2) { + if (t1>t2) { a= t1; t1= t2; t2= a; } /* calculate t0: is the maximum visible z (when halo is intersected by face) */ - if(doclip) { - if(use_yco==0) t0= (maxz-npos[2])/nray[2]; + if (doclip) { + if (use_yco==0) t0= (maxz-npos[2])/nray[2]; else t0= (maxy-npos[1])/nray[1]; - if(t0<t1) return; - if(t0<t2) t2= t0; + if (t0<t1) return; + if (t0<t2) t2= t0; } /* calc points */ @@ -327,7 +327,7 @@ static void spothalo(struct LampRen *lar, ShadeInput *shi, float *intens) /* WATCH IT: do not clip a,b en c at 1.0, this gives nasty little overflows * at the edges (especially with narrow halos) */ - if(*intens<=0.0f) return; + if (*intens<=0.0f) return; /* soft area */ /* not needed because t0 has been used for p1/p2 as well */ @@ -337,7 +337,7 @@ static void spothalo(struct LampRen *lar, ShadeInput *shi, float *intens) *intens *= haint; - if(lar->shb && lar->shb->shadhalostep) { + if (lar->shb && lar->shb->shadhalostep) { *intens *= shadow_halo(lar, p1, p2); } @@ -351,23 +351,23 @@ void renderspothalo(ShadeInput *shi, float col[4], float alpha) LampRen *lar; float i; - if(alpha==0.0f) return; + if (alpha==0.0f) return; lights= get_lights(shi); - for(go=lights->first; go; go= go->next) { + for (go=lights->first; go; go= go->next) { lar= go->lampren; - if(lar==NULL) continue; + if (lar==NULL) continue; - if(lar->type==LA_SPOT && (lar->mode & LA_HALO) && (lar->buftype != LA_SHADBUF_DEEP) && lar->haint>0) { + if (lar->type==LA_SPOT && (lar->mode & LA_HALO) && (lar->buftype != LA_SHADBUF_DEEP) && lar->haint>0) { - if(lar->mode & LA_LAYER) - if(shi->vlr && (lar->lay & shi->obi->lay)==0) + if (lar->mode & LA_LAYER) + if (shi->vlr && (lar->lay & shi->obi->lay)==0) continue; - if((lar->lay & shi->lay)==0) + if ((lar->lay & shi->lay)==0) continue; spothalo(lar, shi, &i); - if(i>0.0f) { + if (i>0.0f) { col[3]+= i*alpha; // all premul col[0]+= i*lar->r*alpha; col[1]+= i*lar->g*alpha; @@ -376,7 +376,7 @@ void renderspothalo(ShadeInput *shi, float col[4], float alpha) } } /* clip alpha, is needed for unified 'alpha threshold' (vanillaRenderPipe.c) */ - if(col[3]>1.0f) col[3]= 1.0f; + if (col[3]>1.0f) col[3]= 1.0f; } @@ -389,13 +389,14 @@ static double Normalize_d(double *n) d= n[0]*n[0]+n[1]*n[1]+n[2]*n[2]; - if(d>0.00000000000000001) { + if (d>0.00000000000000001) { d= sqrt(d); n[0]/=d; n[1]/=d; n[2]/=d; - } else { + } + else { n[0]=n[1]=n[2]= 0.0; d= 0.0; } @@ -407,23 +408,23 @@ float fresnel_fac(float *view, float *vn, float grad, float fac) { float t1, t2; - if(fac==0.0f) return 1.0f; + if (fac==0.0f) return 1.0f; t1= (view[0]*vn[0] + view[1]*vn[1] + view[2]*vn[2]); - if(t1>0.0f) t2= 1.0f+t1; + if (t1>0.0f) t2= 1.0f+t1; else t2= 1.0f-t1; t2= grad + (1.0f-grad)*powf(t2, fac); - if(t2<0.0f) return 0.0f; - else if(t2>1.0f) return 1.0f; + if (t2<0.0f) return 0.0f; + else if (t2>1.0f) return 1.0f; return t2; } static double saacos_d(double fac) { - if(fac<= -1.0) return M_PI; - else if(fac>=1.0) return 0.0; + if (fac<= -1.0) return M_PI; + else if (fac>=1.0) return 0.0; else return acos(fac); } @@ -473,7 +474,7 @@ static float area_lamp_energy(float (*area)[3], float *co, float *vn) fac+= rad[2]*(vn[0]*cross[2][0]+ vn[1]*cross[2][1]+ vn[2]*cross[2][2]); fac+= rad[3]*(vn[0]*cross[3][0]+ vn[1]*cross[3][1]+ vn[2]*cross[3][2]); - if(fac<=0.0) return 0.0; + if (fac<=0.0) return 0.0; return fac; } @@ -486,10 +487,10 @@ static float area_lamp_energy_multisample(LampRen *lar, float *co, float *vn) /* test if co is behind lamp */ sub_v3_v3v3(vec, co, lar->co); - if(dot_v3v3(vec, lar->vec) < 0.0f) + if (dot_v3v3(vec, lar->vec) < 0.0f) return 0.0f; - while(a--) { + while (a--) { vec[0]= jitlamp[0]; vec[1]= jitlamp[1]; vec[2]= 0.0f; @@ -513,35 +514,35 @@ static float spec(float inp, int hard) { float b1; - if(inp>=1.0f) return 1.0f; + if (inp>=1.0f) return 1.0f; else if (inp<=0.0f) return 0.0f; b1= inp*inp; /* avoid FPE */ - if(b1<0.01f) b1= 0.01f; + if (b1<0.01f) b1= 0.01f; - if((hard & 1)==0) inp= 1.0f; - if(hard & 2) inp*= b1; + if ((hard & 1)==0) inp= 1.0f; + if (hard & 2) inp*= b1; b1*= b1; - if(hard & 4) inp*= b1; + if (hard & 4) inp*= b1; b1*= b1; - if(hard & 8) inp*= b1; + if (hard & 8) inp*= b1; b1*= b1; - if(hard & 16) inp*= b1; + if (hard & 16) inp*= b1; b1*= b1; /* avoid FPE */ - if(b1<0.001f) b1= 0.0f; + if (b1<0.001f) b1= 0.0f; - if(hard & 32) inp*= b1; + if (hard & 32) inp*= b1; b1*= b1; - if(hard & 64) inp*=b1; + if (hard & 64) inp*=b1; b1*= b1; - if(hard & 128) inp*=b1; + if (hard & 128) inp*=b1; - if(b1<0.001f) b1= 0.0f; + if (b1<0.001f) b1= 0.0f; - if(hard & 256) { + if (hard & 256) { b1*= b1; inp*=b1; } @@ -560,9 +561,9 @@ static float Phong_Spec( float *n, float *l, float *v, int hard, int tangent ) normalize_v3(h); rslt = h[0]*n[0] + h[1]*n[1] + h[2]*n[2]; - if(tangent) rslt= sasqrt(1.0f - rslt*rslt); + if (tangent) rslt= sasqrt(1.0f - rslt*rslt); - if( rslt > 0.0f ) rslt= spec(rslt, hard); + if ( rslt > 0.0f ) rslt= spec(rslt, hard); else rslt = 0.0f; return rslt; @@ -580,12 +581,12 @@ static float CookTorr_Spec(float *n, float *l, float *v, int hard, int tangent) normalize_v3(h); nh= n[0]*h[0]+n[1]*h[1]+n[2]*h[2]; - if(tangent) nh= sasqrt(1.0f - nh*nh); - else if(nh<0.0f) return 0.0f; + if (tangent) nh= sasqrt(1.0f - nh*nh); + else if (nh<0.0f) return 0.0f; nv= n[0]*v[0]+n[1]*v[1]+n[2]*v[2]; - if(tangent) nv= sasqrt(1.0f - nv*nv); - else if(nv<0.0f) nv= 0.0f; + if (tangent) nv= sasqrt(1.0f - nv*nv); + else if (nv<0.0f) nv= 0.0f; i= spec(nh, hard); @@ -599,11 +600,11 @@ static float Blinn_Spec(float *n, float *l, float *v, float refrac, float spec_p float i, nh, nv, nl, vh, h[3]; float a, b, c, g=0.0f, p, f, ang; - if(refrac < 1.0f) return 0.0f; - if(spec_power == 0.0f) return 0.0f; + if (refrac < 1.0f) return 0.0f; + if (spec_power == 0.0f) return 0.0f; /* conversion from 'hardness' (1-255) to 'spec_power' (50 maps at 0.1) */ - if(spec_power<100.0f) + if (spec_power<100.0f) spec_power= sqrt(1.0f/spec_power); else spec_power= 10.0f/spec_power; @@ -613,36 +614,36 @@ static float Blinn_Spec(float *n, float *l, float *v, float refrac, float spec_p normalize_v3(h); nh= n[0]*h[0]+n[1]*h[1]+n[2]*h[2]; /* Dot product between surface normal and half-way vector */ - if(tangent) nh= sasqrt(1.0f - nh*nh); - else if(nh<0.0f) return 0.0f; + if (tangent) nh= sasqrt(1.0f - nh*nh); + else if (nh<0.0f) return 0.0f; nv= n[0]*v[0]+n[1]*v[1]+n[2]*v[2]; /* Dot product between surface normal and view vector */ - if(tangent) nv= sasqrt(1.0f - nv*nv); - if(nv<=0.01f) nv= 0.01f; /* hrms... */ + if (tangent) nv= sasqrt(1.0f - nv*nv); + if (nv<=0.01f) nv= 0.01f; /* hrms... */ nl= n[0]*l[0]+n[1]*l[1]+n[2]*l[2]; /* Dot product between surface normal and light vector */ - if(tangent) nl= sasqrt(1.0f - nl*nl); - if(nl<=0.01f) { + if (tangent) nl= sasqrt(1.0f - nl*nl); + if (nl<=0.01f) { return 0.0f; } vh= v[0]*h[0]+v[1]*h[1]+v[2]*h[2]; /* Dot product between view vector and half-way vector */ - if(vh<=0.0f) vh= 0.01f; + if (vh<=0.0f) vh= 0.01f; a = 1.0f; b = (2.0f*nh*nv)/vh; c = (2.0f*nh*nl)/vh; - if( a < b && a < c ) g = a; - else if( b < a && b < c ) g = b; - else if( c < a && c < b ) g = c; + if ( a < b && a < c ) g = a; + else if ( b < a && b < c ) g = b; + else if ( c < a && c < b ) g = c; p = sqrt( (double)((refrac * refrac)+(vh*vh)-1.0f) ); f = (((p-vh)*(p-vh))/((p+vh)*(p+vh)))*(1+((((vh*(p+vh))-1.0f)*((vh*(p+vh))-1.0f))/(((vh*(p-vh))+1.0f)*((vh*(p-vh))+1.0f)))); ang = saacos(nh); i= f * g * exp((double)(-(ang*ang) / (2.0f*spec_power*spec_power))); - if(i<0.0f) i= 0.0f; + if (i<0.0f) i= 0.0f; return i; } @@ -660,12 +661,12 @@ static float Toon_Spec( float *n, float *l, float *v, float size, float smooth, normalize_v3(h); rslt = h[0]*n[0] + h[1]*n[1] + h[2]*n[2]; - if(tangent) rslt = sasqrt(1.0f - rslt*rslt); + if (tangent) rslt = sasqrt(1.0f - rslt*rslt); ang = saacos( rslt ); - if( ang < size ) rslt = 1.0f; - else if( ang >= (size + smooth) || smooth == 0.0f ) rslt = 0.0f; + if ( ang < size ) rslt = 1.0f; + else if ( ang >= (size + smooth) || smooth == 0.0f ) rslt = 0.0f; else rslt = 1.0f - ((ang - size) / smooth); return rslt; @@ -684,16 +685,16 @@ static float WardIso_Spec( float *n, float *l, float *v, float rms, int tangent) normalize_v3(h); nh = n[0]*h[0]+n[1]*h[1]+n[2]*h[2]; /* Dot product between surface normal and half-way vector */ - if(tangent) nh = sasqrt(1.0f - nh*nh); - if(nh<=0.0f) nh = 0.001f; + if (tangent) nh = sasqrt(1.0f - nh*nh); + if (nh<=0.0f) nh = 0.001f; nv = n[0]*v[0]+n[1]*v[1]+n[2]*v[2]; /* Dot product between surface normal and view vector */ - if(tangent) nv = sasqrt(1.0f - nv*nv); - if(nv<=0.0f) nv = 0.001f; + if (tangent) nv = sasqrt(1.0f - nv*nv); + if (nv<=0.0f) nv = 0.001f; nl = n[0]*l[0]+n[1]*l[1]+n[2]*l[2]; /* Dot product between surface normal and light vector */ - if(tangent) nl = sasqrt(1.0f - nl*nl); - if(nl<=0.0f) nl = 0.001f; + if (tangent) nl = sasqrt(1.0f - nl*nl); + if (nl<=0.0f) nl = 0.001f; angle = tan(saacos(nh)); alpha = MAX2(rms, 0.001f); @@ -712,8 +713,8 @@ static float Toon_Diff( float *n, float *l, float *UNUSED(v), float size, float ang = saacos( (double)(rslt) ); - if( ang < size ) rslt = 1.0f; - else if( ang >= (size + smooth) || smooth == 0.0f ) rslt = 0.0f; + if ( ang < size ) rslt = 1.0f; + else if ( ang >= (size + smooth) || smooth == 0.0f ) rslt = 0.0f; else rslt = 1.0f - ((ang - size) / smooth); return rslt; @@ -738,11 +739,11 @@ static float OrenNayar_Diff(float nl, float *n, float *l, float *v, float rough /* if(nh<0.0f) nh = 0.0f; */ nv= n[0]*v[0]+n[1]*v[1]+n[2]*v[2]; /* Dot product between surface normal and view vector */ - if(nv<=0.0f) nv= 0.0f; + if (nv<=0.0f) nv= 0.0f; realnl= n[0]*l[0]+n[1]*l[1]+n[2]*l[2]; /* Dot product between surface normal and light vector */ - if(realnl<=0.0f) return 0.0f; - if(nl<0.0f) return 0.0f; /* value from area light */ + if (realnl<=0.0f) return 0.0f; + if (nl<0.0f) return 0.0f; /* value from area light */ /* vh= v[0]*h[0]+v[1]*h[1]+v[2]*h[2]; */ /* Dot product between view vector and halfway vector */ /* if(vh<=0.0f) vh= 0.0f; */ @@ -761,9 +762,9 @@ static float OrenNayar_Diff(float nl, float *n, float *l, float *v, float rough normalize_v3( View_B ); t = Lit_B[0]*View_B[0] + Lit_B[1]*View_B[1] + Lit_B[2]*View_B[2]; - if( t < 0 ) t = 0; + if ( t < 0 ) t = 0; - if( Lit_A > View_A ) { + if ( Lit_A > View_A ) { a = Lit_A; b = View_A; } @@ -822,8 +823,8 @@ void calc_R_ref(ShadeInput *shi) shi->ref[0]= (shi->view[0]+i*shi->vn[0]); shi->ref[1]= (shi->view[1]+i*shi->vn[1]); shi->ref[2]= (shi->view[2]+i*shi->vn[2]); - if(shi->osatex) { - if(shi->vlr->flag & R_SMOOTH) { + if (shi->osatex) { + if (shi->vlr->flag & R_SMOOTH) { i= -2*( (shi->vn[0]+shi->dxno[0])*(shi->view[0]+shi->dxview) + (shi->vn[1]+shi->dxno[1])*shi->view[1]+ (shi->vn[2]+shi->dxno[2])*shi->view[2] ); @@ -864,24 +865,24 @@ void shade_color(ShadeInput *shi, ShadeResult *shr) { Material *ma= shi->mat; - if(ma->mode & (MA_FACETEXTURE)) { + if (ma->mode & (MA_FACETEXTURE)) { shi->r= shi->vcol[0]; shi->g= shi->vcol[1]; shi->b= shi->vcol[2]; - if(ma->mode & (MA_FACETEXTURE_ALPHA)) + if (ma->mode & (MA_FACETEXTURE_ALPHA)) shi->alpha= shi->vcol[3]; } - else if(ma->mode & (MA_VERTEXCOLP)) { + else if (ma->mode & (MA_VERTEXCOLP)) { float neg_alpha = 1.0f - shi->vcol[3]; shi->r= shi->r*neg_alpha + shi->vcol[0]*shi->vcol[3]; shi->g= shi->g*neg_alpha + shi->vcol[1]*shi->vcol[3]; shi->b= shi->b*neg_alpha + shi->vcol[2]*shi->vcol[3]; } - if(ma->texco) + if (ma->texco) do_material_tex(shi, &R); - if(ma->fresnel_tra!=0.0f) + if (ma->fresnel_tra!=0.0f) shi->alpha*= fresnel_fac(shi->view, shi->vn, ma->fresnel_tra_i, ma->fresnel_tra); if (!(shi->mode & MA_TRANSP)) shi->alpha= 1.0f; @@ -898,8 +899,8 @@ static void ramp_diffuse_result(float *diff, ShadeInput *shi) Material *ma= shi->mat; float col[4]; - if(ma->ramp_col) { - if(ma->rampin_col==MA_RAMP_IN_RESULT) { + if (ma->ramp_col) { + if (ma->rampin_col==MA_RAMP_IN_RESULT) { float fac = rgb_to_grayscale(diff); do_colorband(ma->ramp_col, fac, col); @@ -916,10 +917,10 @@ static void add_to_diffuse(float *diff, ShadeInput *shi, float is, float r, floa { Material *ma= shi->mat; - if(ma->ramp_col && (ma->mode & MA_RAMP_COL)) { + if (ma->ramp_col && (ma->mode & MA_RAMP_COL)) { /* MA_RAMP_IN_RESULT is exceptional */ - if(ma->rampin_col==MA_RAMP_IN_RESULT) { + if (ma->rampin_col==MA_RAMP_IN_RESULT) { // normal add diff[0] += r * shi->r; diff[1] += g * shi->g; @@ -973,7 +974,7 @@ static void ramp_spec_result(float spec_col[3], ShadeInput *shi) { Material *ma= shi->mat; - if(ma->ramp_spec && (ma->rampin_spec==MA_RAMP_IN_RESULT)) { + if (ma->ramp_spec && (ma->rampin_spec==MA_RAMP_IN_RESULT)) { float col[4]; float fac = rgb_to_grayscale(spec_col); @@ -997,7 +998,7 @@ static void do_specular_ramp(ShadeInput *shi, float is, float t, float spec[3]) spec[2]= shi->specb; /* MA_RAMP_IN_RESULT is exception */ - if(ma->ramp_spec && (ma->rampin_spec!=MA_RAMP_IN_RESULT)) { + if (ma->ramp_spec && (ma->rampin_spec!=MA_RAMP_IN_RESULT)) { float fac; float col[4]; @@ -1030,10 +1031,10 @@ static void do_specular_ramp(ShadeInput *shi, float is, float t, float spec[3]) /* preprocess, textures were not done, don't use shi->amb for that reason */ void ambient_occlusion(ShadeInput *shi) { - if((R.wrld.ao_gather_method == WO_AOGATHER_APPROX) && shi->mat->amb!=0.0f) { + if ((R.wrld.ao_gather_method == WO_AOGATHER_APPROX) && shi->mat->amb!=0.0f) { sample_occ(&R, shi); } - else if((R.r.mode & R_RAYTRACE) && shi->mat->amb!=0.0f) { + else if ((R.r.mode & R_RAYTRACE) && shi->mat->amb!=0.0f) { ray_ao(shi, shi->ao, shi->env); } else { @@ -1050,21 +1051,21 @@ static void ambient_occlusion_apply(ShadeInput *shi, ShadeResult *shr) float f= R.wrld.aoenergy; float tmp[3], tmpspec[3]; - if(!((R.r.mode & R_RAYTRACE) || R.wrld.ao_gather_method == WO_AOGATHER_APPROX)) + if (!((R.r.mode & R_RAYTRACE) || R.wrld.ao_gather_method == WO_AOGATHER_APPROX)) return; - if(f == 0.0f) + if (f == 0.0f) return; - if(R.wrld.aomix==WO_AOADD) { + if (R.wrld.aomix==WO_AOADD) { shr->combined[0] += shi->ao[0]*shi->r*shi->refl*f; shr->combined[1] += shi->ao[1]*shi->g*shi->refl*f; shr->combined[2] += shi->ao[2]*shi->b*shi->refl*f; } - else if(R.wrld.aomix==WO_AOMUL) { + else if (R.wrld.aomix==WO_AOMUL) { mul_v3_v3v3(tmp, shr->combined, shi->ao); mul_v3_v3v3(tmpspec, shr->spec, shi->ao); - if(f == 1.0f) { + if (f == 1.0f) { copy_v3_v3(shr->combined, tmp); copy_v3_v3(shr->spec, tmpspec); } @@ -1079,9 +1080,9 @@ void environment_lighting_apply(ShadeInput *shi, ShadeResult *shr) { float f= R.wrld.ao_env_energy*shi->amb; - if(!((R.r.mode & R_RAYTRACE) || R.wrld.ao_gather_method == WO_AOGATHER_APPROX)) + if (!((R.r.mode & R_RAYTRACE) || R.wrld.ao_gather_method == WO_AOGATHER_APPROX)) return; - if(f == 0.0f) + if (f == 0.0f) return; shr->combined[0] += shi->env[0]*shi->r*shi->refl*f; @@ -1093,9 +1094,9 @@ static void indirect_lighting_apply(ShadeInput *shi, ShadeResult *shr) { float f= R.wrld.ao_indirect_energy; - if(!((R.r.mode & R_RAYTRACE) || R.wrld.ao_gather_method == WO_AOGATHER_APPROX)) + if (!((R.r.mode & R_RAYTRACE) || R.wrld.ao_gather_method == WO_AOGATHER_APPROX)) return; - if(f == 0.0f) + if (f == 0.0f) return; shr->combined[0] += shi->indirect[0]*shi->r*shi->refl*f; @@ -1108,21 +1109,21 @@ void lamp_get_shadow(LampRen *lar, ShadeInput *shi, float inp, float shadfac[4], { LampShadowSubSample *lss= &(lar->shadsamp[shi->thread].s[shi->sample]); - if(do_real || lss->samplenr!=shi->samplenr) { + if (do_real || lss->samplenr!=shi->samplenr) { shadfac[0]= shadfac[1]= shadfac[2]= shadfac[3]= 1.0f; - if(lar->shb) { - if(lar->buftype==LA_SHADBUF_IRREGULAR) + if (lar->shb) { + if (lar->buftype==LA_SHADBUF_IRREGULAR) shadfac[3]= ISB_getshadow(shi, lar->shb); else shadfac[3] = testshadowbuf(&R, lar->shb, shi->co, shi->dxco, shi->dyco, inp, shi->mat->lbias); } - else if(lar->mode & LA_SHAD_RAY) { + else if (lar->mode & LA_SHAD_RAY) { ray_shadow(shi, lar, shadfac); } - if(shi->depth==0) { + if (shi->depth==0) { copy_v4_v4(lss->shadfac, shadfac); lss->samplenr= shi->samplenr; } @@ -1135,7 +1136,7 @@ void lamp_get_shadow(LampRen *lar, ShadeInput *shi, float inp, float shadfac[4], /* lampdistance and spot angle, writes in lv and dist */ float lamp_get_visibility(LampRen *lar, const float co[3], float lv[3], float *dist) { - if(lar->type==LA_SUN || lar->type==LA_HEMI) { + if (lar->type==LA_SUN || lar->type==LA_HEMI) { *dist= 1.0f; copy_v3_v3(lv, lar->vec); return 1.0f; @@ -1149,7 +1150,7 @@ float lamp_get_visibility(LampRen *lar, const float co[3], float lv[3], float *d mul_v3_fl(lv, t); /* area type has no quad or sphere option */ - if(lar->type==LA_AREA) { + if (lar->type==LA_AREA) { /* area is single sided */ //if(dot_v3v3(lv, lar->vec) > 0.0f) // visifac= 1.0f; @@ -1174,9 +1175,9 @@ float lamp_get_visibility(LampRen *lar, const float co[3], float lv[3], float *d visifac = lar->dist / (lar->dist + dist[0]*dist[0]); break; case LA_FALLOFF_SLIDERS: - if(lar->ld1>0.0f) + if (lar->ld1>0.0f) visifac= lar->dist/(lar->dist+lar->ld1*dist[0]); - if(lar->ld2>0.0f) + if (lar->ld2>0.0f) visifac*= lar->distkw/(lar->distkw+lar->ld2*dist[0]*dist[0]); break; case LA_FALLOFF_CURVE: @@ -1184,20 +1185,20 @@ float lamp_get_visibility(LampRen *lar, const float co[3], float lv[3], float *d break; } - if(lar->mode & LA_SPHERE) { + if (lar->mode & LA_SPHERE) { float t= lar->dist - dist[0]; - if(t<=0.0f) + if (t<=0.0f) visifac= 0.0f; else visifac*= t/lar->dist; } - if(visifac > 0.0f) { - if(lar->type==LA_SPOT) { + if (visifac > 0.0f) { + if (lar->type==LA_SPOT) { float inpr; - if(lar->mode & LA_SQUARE) { - if(dot_v3v3(lv, lar->vec) > 0.0f) { + if (lar->mode & LA_SQUARE) { + if (dot_v3v3(lv, lar->vec) > 0.0f) { float lvrot[3], x; /* rotate view to lampspace */ @@ -1216,11 +1217,11 @@ float lamp_get_visibility(LampRen *lar, const float co[3], float lv[3], float *d } t= lar->spotsi; - if(inpr<=t) + if (inpr<=t) visifac= 0.0f; else { t= inpr-t; - if(t<lar->spotbl && lar->spotbl!=0.0f) { + if (t<lar->spotbl && lar->spotbl!=0.0f) { /* soft area */ float i= t/lar->spotbl; t= i*i; @@ -1259,11 +1260,11 @@ static void shade_one_light(LampRen *lar, ShadeInput *shi, ShadeResult *shr, int /* lampdist, spot angle, area side, ... */ visifac= lamp_get_visibility(lar, shi->co, lv, &lampdist); - if(visifac==0.0f) + if (visifac==0.0f) return; - if(lar->type==LA_SPOT) { - if(lar->mode & LA_OSATEX) { + if (lar->type==LA_SPOT) { + if (lar->mode & LA_OSATEX) { shi->osatex= 1; /* signal for multitex() */ shi->dxlv[0]= lv[0] - (shi->co[0]-lar->co[0]+shi->dxco[0])/lampdist; @@ -1285,15 +1286,15 @@ static void shade_one_light(LampRen *lar, ShadeInput *shi, ShadeResult *shr, int lashdw[1]= lar->shdwg; lashdw[2]= lar->shdwb; - if(lar->mode & LA_TEXTURE) do_lamp_tex(lar, lv, shi, lacol, LA_TEXTURE); - if(lar->mode & LA_SHAD_TEX) do_lamp_tex(lar, lv, shi, lashdw, LA_SHAD_TEX); + if (lar->mode & LA_TEXTURE) do_lamp_tex(lar, lv, shi, lacol, LA_TEXTURE); + if (lar->mode & LA_SHAD_TEX) do_lamp_tex(lar, lv, shi, lashdw, LA_SHAD_TEX); /* tangent case; calculate fake face normal, aligned with lampvector */ /* note, vnor==vn is used as tangent trigger for buffer shadow */ - if(vlr->flag & R_TANGENT) { + if (vlr->flag & R_TANGENT) { float cross[3], nstrand[3], blend; - if(ma->mode & MA_STR_SURFDIFF) { + if (ma->mode & MA_STR_SURFDIFF) { cross_v3_v3v3(cross, shi->surfnor, vn); cross_v3_v3v3(nstrand, vn, cross); @@ -1310,8 +1311,8 @@ static void shade_one_light(LampRen *lar, ShadeInput *shi, ShadeResult *shr, int normalize_v3(vnor); } - if(ma->strand_surfnor > 0.0f) { - if(ma->strand_surfnor > shi->surfdist) { + if (ma->strand_surfnor > 0.0f) { + if (ma->strand_surfnor > shi->surfdist) { blend= (ma->strand_surfnor - shi->surfdist)/ma->strand_surfnor; interp_v3_v3v3(vnor, vnor, shi->surfnor, blend); normalize_v3(vnor); @@ -1336,18 +1337,18 @@ static void shade_one_light(LampRen *lar, ShadeInput *shi, ShadeResult *shr, int /* phong threshold to prevent backfacing faces having artefacts on ray shadow (terminator problem) */ /* this complex construction screams for a nicer implementation! (ton) */ - if(R.r.mode & R_SHADOW) { - if(ma->mode & MA_SHADOW) { - if(lar->type==LA_HEMI || lar->type==LA_AREA); - else if((ma->mode & MA_RAYBIAS) && (lar->mode & LA_SHAD_RAY) && (vlr->flag & R_SMOOTH)) { + if (R.r.mode & R_SHADOW) { + if (ma->mode & MA_SHADOW) { + if (lar->type==LA_HEMI || lar->type==LA_AREA); + else if ((ma->mode & MA_RAYBIAS) && (lar->mode & LA_SHAD_RAY) && (vlr->flag & R_SMOOTH)) { float thresh= shi->obr->ob->smoothresh; - if(inp>thresh) + if (inp>thresh) phongcorr= (inp-thresh)/(inp*(1.0f-thresh)); else phongcorr= 0.0f; } - else if(ma->sbias!=0.0f && ((lar->mode & LA_SHAD_RAY) || lar->shb)) { - if(inp>ma->sbias) + else if (ma->sbias!=0.0f && ((lar->mode & LA_SHAD_RAY) || lar->shb)) { + if (inp>ma->sbias) phongcorr= (inp-ma->sbias)/(inp*(1.0f-ma->sbias)); else phongcorr= 0.0f; @@ -1356,57 +1357,57 @@ static void shade_one_light(LampRen *lar, ShadeInput *shi, ShadeResult *shr, int } /* diffuse shaders */ - if(lar->mode & LA_NO_DIFF) { + if (lar->mode & LA_NO_DIFF) { is= 0.0f; // skip shaders } - else if(lar->type==LA_HEMI) { + else if (lar->type==LA_HEMI) { is= 0.5f*inp + 0.5f; } else { - if(lar->type==LA_AREA) + if (lar->type==LA_AREA) inp= area_lamp_energy_multisample(lar, shi->co, vn); /* diffuse shaders (oren nayer gets inp from area light) */ - if(ma->diff_shader==MA_DIFF_ORENNAYAR) is= OrenNayar_Diff(inp, vn, lv, view, ma->roughness); - else if(ma->diff_shader==MA_DIFF_TOON) is= Toon_Diff(vn, lv, view, ma->param[0], ma->param[1]); - else if(ma->diff_shader==MA_DIFF_MINNAERT) is= Minnaert_Diff(inp, vn, view, ma->darkness); - else if(ma->diff_shader==MA_DIFF_FRESNEL) is= Fresnel_Diff(vn, lv, view, ma->param[0], ma->param[1]); + if (ma->diff_shader==MA_DIFF_ORENNAYAR) is= OrenNayar_Diff(inp, vn, lv, view, ma->roughness); + else if (ma->diff_shader==MA_DIFF_TOON) is= Toon_Diff(vn, lv, view, ma->param[0], ma->param[1]); + else if (ma->diff_shader==MA_DIFF_MINNAERT) is= Minnaert_Diff(inp, vn, view, ma->darkness); + else if (ma->diff_shader==MA_DIFF_FRESNEL) is= Fresnel_Diff(vn, lv, view, ma->param[0], ma->param[1]); else is= inp; // Lambert } /* 'is' is diffuse */ - if((ma->shade_flag & MA_CUBIC) && is>0.0f && is<1.0f) + if ((ma->shade_flag & MA_CUBIC) && is>0.0f && is<1.0f) is= 3.0f*is*is - 2.0f*is*is*is; // nicer termination of shades i= is*phongcorr; - if(i>0.0f) { + if (i>0.0f) { i*= visifac*shi->refl; } i_noshad= i; vn= shi->vn; // bring back original vector, we use special specular shaders for tangent - if(ma->mode & MA_TANGENT_V) + if (ma->mode & MA_TANGENT_V) vn= shi->tang; /* init transp shadow */ shadfac[0]= shadfac[1]= shadfac[2]= shadfac[3]= 1.0f; /* shadow and spec, (visifac==0 outside spot) */ - if(visifac> 0.0f) { + if (visifac> 0.0f) { - if((R.r.mode & R_SHADOW)) { - if(ma->mode & MA_SHADOW) { - if(lar->shb || (lar->mode & LA_SHAD_RAY)) { + if ((R.r.mode & R_SHADOW)) { + if (ma->mode & MA_SHADOW) { + if (lar->shb || (lar->mode & LA_SHAD_RAY)) { - if(vn==vnor) /* tangent trigger */ + if (vn==vnor) /* tangent trigger */ lamp_get_shadow(lar, shi, dot_v3v3(shi->vn, lv), shadfac, shi->depth); else lamp_get_shadow(lar, shi, inp, shadfac, shi->depth); /* warning, here it skips the loop */ - if((lar->mode & LA_ONLYSHADOW) && i>0.0f) { + if ((lar->mode & LA_ONLYSHADOW) && i>0.0f) { shadfac[3]= i*lar->energy*(1.0f-shadfac[3]); shr->shad[0] -= shadfac[3]*shi->r*(1.0f-lashdw[0]); @@ -1427,9 +1428,9 @@ static void shade_one_light(LampRen *lar, ShadeInput *shi, ShadeResult *shr, int } /* in case 'no diffuse' we still do most calculus, spec can be in shadow.*/ - if(!(lar->mode & LA_NO_DIFF)) { - if(i>0.0f) { - if(ma->mode & MA_SHADOW_TRA) + if (!(lar->mode & LA_NO_DIFF)) { + if (i>0.0f) { + if (ma->mode & MA_SHADOW_TRA) add_to_diffuse(shr->shad, shi, is, i*shadfac[0]*lacol[0], i*shadfac[1]*lacol[1], i*shadfac[2]*lacol[2]); else add_to_diffuse(shr->shad, shi, is, i*lacol[0], i*lacol[1], i*lacol[2]); @@ -1438,8 +1439,8 @@ static void shade_one_light(LampRen *lar, ShadeInput *shi, ShadeResult *shr, int if (i_noshad>i && !(lashdw[0]==0 && lashdw[1]==0 && lashdw[2]==0)) { add_to_diffuse(shr->shad, shi, is, lashdw[0]*(i_noshad-i)*lacol[0], lashdw[1]*(i_noshad-i)*lacol[1], lashdw[2]*(i_noshad-i)*lacol[2]); } - if(i_noshad>0.0f) { - if(passflag & (SCE_PASS_DIFFUSE|SCE_PASS_SHADOW)) { + if (i_noshad>0.0f) { + if (passflag & (SCE_PASS_DIFFUSE|SCE_PASS_SHADOW)) { add_to_diffuse(shr->diff, shi, is, i_noshad*lacol[0], i_noshad*lacol[1], i_noshad*lacol[2]); } else @@ -1450,10 +1451,10 @@ static void shade_one_light(LampRen *lar, ShadeInput *shi, ShadeResult *shr, int /* specularity */ shadfac[3]*= phongcorr; /* note, shadfac not allowed to be stored nonlocal */ - if(shadfac[3]>0.0f && shi->spec!=0.0f && !(lar->mode & LA_NO_SPEC) && !(lar->mode & LA_ONLYSHADOW)) { + if (shadfac[3]>0.0f && shi->spec!=0.0f && !(lar->mode & LA_NO_SPEC) && !(lar->mode & LA_ONLYSHADOW)) { - if(!(passflag & (SCE_PASS_COMBINED|SCE_PASS_SPEC))); - else if(lar->type==LA_HEMI) { + if (!(passflag & (SCE_PASS_COMBINED|SCE_PASS_SPEC))); + else if (lar->type==LA_HEMI) { float t; /* hemi uses no spec shaders (yet) */ @@ -1465,7 +1466,7 @@ static void shade_one_light(LampRen *lar, ShadeInput *shi, ShadeResult *shr, int t= vn[0]*lv[0]+vn[1]*lv[1]+vn[2]*lv[2]; - if(lar->type==LA_HEMI) { + if (lar->type==LA_HEMI) { t= 0.5f*t+0.5f; } @@ -1479,23 +1480,23 @@ static void shade_one_light(LampRen *lar, ShadeInput *shi, ShadeResult *shr, int /* specular shaders */ float specfac, t; - if(ma->spec_shader==MA_SPEC_PHONG) + if (ma->spec_shader==MA_SPEC_PHONG) specfac= Phong_Spec(vn, lv, view, shi->har, (vlr->flag & R_TANGENT) || (ma->mode & MA_TANGENT_V)); - else if(ma->spec_shader==MA_SPEC_COOKTORR) + else if (ma->spec_shader==MA_SPEC_COOKTORR) specfac= CookTorr_Spec(vn, lv, view, shi->har, (vlr->flag & R_TANGENT) || (ma->mode & MA_TANGENT_V)); - else if(ma->spec_shader==MA_SPEC_BLINN) + else if (ma->spec_shader==MA_SPEC_BLINN) specfac= Blinn_Spec(vn, lv, view, ma->refrac, (float)shi->har, (vlr->flag & R_TANGENT) || (ma->mode & MA_TANGENT_V)); - else if(ma->spec_shader==MA_SPEC_WARDISO) + else if (ma->spec_shader==MA_SPEC_WARDISO) specfac= WardIso_Spec( vn, lv, view, ma->rms, (vlr->flag & R_TANGENT) || (ma->mode & MA_TANGENT_V)); else specfac= Toon_Spec(vn, lv, view, ma->param[2], ma->param[3], (vlr->flag & R_TANGENT) || (ma->mode & MA_TANGENT_V)); /* area lamp correction */ - if(lar->type==LA_AREA) specfac*= inp; + if (lar->type==LA_AREA) specfac*= inp; t= shadfac[3]*shi->spec*visifac*specfac; - if(ma->mode & MA_RAMP_SPEC) { + if (ma->mode & MA_RAMP_SPEC) { float spec[3]; do_specular_ramp(shi, specfac, t, spec); shr->spec[0]+= t*(lacol[0] * spec[0]); @@ -1515,7 +1516,7 @@ static void shade_one_light(LampRen *lar, ShadeInput *shi, ShadeResult *shr, int static void shade_lamp_loop_only_shadow(ShadeInput *shi, ShadeResult *shr) { - if(R.r.mode & R_SHADOW) { + if (R.r.mode & R_SHADOW) { ListBase *lights; LampRen *lar; GroupObject *go; @@ -1529,28 +1530,28 @@ static void shade_lamp_loop_only_shadow(ShadeInput *shi, ShadeResult *shr) accum= ir= 0.0f; lights= get_lights(shi); - for(go=lights->first; go; go= go->next) { + for (go=lights->first; go; go= go->next) { lar= go->lampren; - if(lar==NULL) continue; + if (lar==NULL) continue; /* yafray: ignore shading by photonlights, not used in Blender */ if (lar->type==LA_YF_PHOTON) continue; - if(lar->mode & LA_LAYER) if((lar->lay & shi->obi->lay)==0) continue; - if((lar->lay & shi->lay)==0) continue; + if (lar->mode & LA_LAYER) if((lar->lay & shi->obi->lay)==0) continue; + if ((lar->lay & shi->lay)==0) continue; - if(lar->shb || (lar->mode & LA_SHAD_RAY)) { + if (lar->shb || (lar->mode & LA_SHAD_RAY)) { visifac= lamp_get_visibility(lar, shi->co, lv, &lampdist); ir+= 1.0f; - if(visifac <= 0.0f) { + if (visifac <= 0.0f) { if (shi->mat->shadowonly_flag == MA_SO_OLD) accum+= 1.0f; continue; } inpr= dot_v3v3(shi->vn, lv); - if(inpr <= 0.0f) { + if (inpr <= 0.0f) { if (shi->mat->shadowonly_flag == MA_SO_OLD) accum+= 1.0f; @@ -1574,7 +1575,7 @@ static void shade_lamp_loop_only_shadow(ShadeInput *shi, ShadeResult *shr) } /* Apply shadows as alpha */ - if(ir>0.0f) { + if (ir>0.0f) { if (shi->mat->shadowonly_flag == MA_SO_OLD) { accum = 1.0f - accum/ir; } @@ -1604,13 +1605,13 @@ static void shade_lamp_loop_only_shadow(ShadeInput *shi, ShadeResult *shr) } /* quite disputable this... also note it doesn't mirror-raytrace */ - if((R.wrld.mode & (WO_AMB_OCC|WO_ENV_LIGHT)) && shi->amb!=0.0f) { + if ((R.wrld.mode & (WO_AMB_OCC|WO_ENV_LIGHT)) && shi->amb!=0.0f) { float f; - if(R.wrld.mode & WO_AMB_OCC) { + if (R.wrld.mode & WO_AMB_OCC) { f= R.wrld.aoenergy*shi->amb; - if(R.wrld.aomix==WO_AOADD) { + if (R.wrld.aomix==WO_AOADD) { if (shi->mat->shadowonly_flag == MA_SO_OLD) { f= f*(1.0f - rgb_to_grayscale(shi->ao)); shr->alpha= (shr->alpha + f)*f; @@ -1624,7 +1625,7 @@ static void shade_lamp_loop_only_shadow(ShadeInput *shi, ShadeResult *shr) shr->alpha= (1.0f - f)*shr->alpha + f*(1.0f - (1.0f - shr->alpha)*rgb_to_grayscale(shi->ao)); } - if(R.wrld.mode & WO_ENV_LIGHT) { + if (R.wrld.mode & WO_ENV_LIGHT) { if (shi->mat->shadowonly_flag == MA_SO_OLD) { f= R.wrld.ao_env_energy*shi->amb*(1.0f - rgb_to_grayscale(shi->env)); shr->alpha= (shr->alpha + f)*f; @@ -1654,10 +1655,10 @@ void shade_lamp_loop(ShadeInput *shi, ShadeResult *shr) memset(shr, 0, sizeof(ShadeResult)); - if(!(shi->mode & MA_TRANSP)) shi->alpha = 1.0f; + if (!(shi->mode & MA_TRANSP)) shi->alpha = 1.0f; /* separate loop */ - if(ma->mode & MA_ONLYSHADOW) { + if (ma->mode & MA_ONLYSHADOW) { shade_lamp_loop_only_shadow(shi, shr); return; } @@ -1666,21 +1667,21 @@ void shade_lamp_loop(ShadeInput *shi, ShadeResult *shr) shi->refcol[0]= shi->refcol[1]= shi->refcol[2]= shi->refcol[3]= 0.0f; /* material color itself */ - if(passflag & (SCE_PASS_COMBINED|SCE_PASS_RGBA)) { - if(ma->mode & (MA_FACETEXTURE)) { + if (passflag & (SCE_PASS_COMBINED|SCE_PASS_RGBA)) { + if (ma->mode & (MA_FACETEXTURE)) { shi->r= shi->vcol[0]; shi->g= shi->vcol[1]; shi->b= shi->vcol[2]; - if(ma->mode & (MA_FACETEXTURE_ALPHA)) + if (ma->mode & (MA_FACETEXTURE_ALPHA)) shi->alpha= shi->vcol[3]; } - else if(ma->mode & (MA_VERTEXCOLP)) { + else if (ma->mode & (MA_VERTEXCOLP)) { float neg_alpha = 1.0f - shi->vcol[3]; shi->r= shi->r*neg_alpha + shi->vcol[0]*shi->vcol[3]; shi->g= shi->g*neg_alpha + shi->vcol[1]*shi->vcol[3]; shi->b= shi->b*neg_alpha + shi->vcol[2]*shi->vcol[3]; } - if(ma->texco){ + if (ma->texco) { do_material_tex(shi, &R); if (!(shi->mode & MA_TRANSP)) shi->alpha = 1.0f; } @@ -1690,8 +1691,8 @@ void shade_lamp_loop(ShadeInput *shi, ShadeResult *shr) shr->col[2]= shi->b*shi->alpha; shr->col[3]= shi->alpha; - if((ma->sss_flag & MA_DIFF_SSS) && !sss_pass_done(&R, ma)) { - if(ma->sss_texfac == 0.0f) { + if ((ma->sss_flag & MA_DIFF_SSS) && !sss_pass_done(&R, ma)) { + if (ma->sss_texfac == 0.0f) { shi->r= shi->g= shi->b= shi->alpha= 1.0f; shr->col[0]= shr->col[1]= shr->col[2]= shr->col[3]= 1.0f; } @@ -1709,7 +1710,7 @@ void shade_lamp_loop(ShadeInput *shi, ShadeResult *shr) } } - if(ma->mode & MA_SHLESS) { + if (ma->mode & MA_SHLESS) { shr->combined[0]= shi->r; shr->combined[1]= shi->g; shr->combined[2]= shi->b; @@ -1717,7 +1718,7 @@ void shade_lamp_loop(ShadeInput *shi, ShadeResult *shr) return; } - if( (ma->mode & (MA_VERTEXCOL|MA_VERTEXCOLP))== MA_VERTEXCOL ) { // vertexcolor light + if ( (ma->mode & (MA_VERTEXCOL|MA_VERTEXCOLP))== MA_VERTEXCOL ) { // vertexcolor light shr->emit[0]= shi->r*(shi->emit+shi->vcol[0]*shi->vcol[3]); shr->emit[1]= shi->g*(shi->emit+shi->vcol[1]*shi->vcol[3]); shr->emit[2]= shi->b*(shi->emit+shi->vcol[2]*shi->vcol[3]); @@ -1729,12 +1730,12 @@ void shade_lamp_loop(ShadeInput *shi, ShadeResult *shr) } /* AO pass */ - if(R.wrld.mode & (WO_AMB_OCC|WO_ENV_LIGHT|WO_INDIRECT_LIGHT)) { - if(((passflag & SCE_PASS_COMBINED) && (shi->combinedflag & (SCE_PASS_AO|SCE_PASS_ENVIRONMENT|SCE_PASS_INDIRECT))) + if (R.wrld.mode & (WO_AMB_OCC|WO_ENV_LIGHT|WO_INDIRECT_LIGHT)) { + if (((passflag & SCE_PASS_COMBINED) && (shi->combinedflag & (SCE_PASS_AO|SCE_PASS_ENVIRONMENT|SCE_PASS_INDIRECT))) || (passflag & (SCE_PASS_AO|SCE_PASS_ENVIRONMENT|SCE_PASS_INDIRECT))) { - if(R.r.mode & R_SHADOW) { + if (R.r.mode & R_SHADOW) { /* AO was calculated for scanline already */ - if(shi->depth || shi->volume_depth) + if (shi->depth || shi->volume_depth) ambient_occlusion(shi); copy_v3_v3(shr->ao, shi->ao); copy_v3_v3(shr->env, shi->env); // XXX multiply @@ -1744,22 +1745,22 @@ void shade_lamp_loop(ShadeInput *shi, ShadeResult *shr) } /* lighting pass */ - if(passflag & (SCE_PASS_COMBINED|SCE_PASS_DIFFUSE|SCE_PASS_SPEC|SCE_PASS_SHADOW)) { + if (passflag & (SCE_PASS_COMBINED|SCE_PASS_DIFFUSE|SCE_PASS_SPEC|SCE_PASS_SHADOW)) { GroupObject *go; ListBase *lights; LampRen *lar; lights= get_lights(shi); - for(go=lights->first; go; go= go->next) { + for (go=lights->first; go; go= go->next) { lar= go->lampren; - if(lar==NULL) continue; + if (lar==NULL) continue; /* yafray: ignore shading by photonlights, not used in Blender */ if (lar->type==LA_YF_PHOTON) continue; /* test for lamp layer */ - if(lar->mode & LA_LAYER) if((lar->lay & shi->obi->lay)==0) continue; - if((lar->lay & shi->lay)==0) continue; + if (lar->mode & LA_LAYER) if((lar->lay & shi->obi->lay)==0) continue; + if ((lar->lay & shi->lay)==0) continue; /* accumulates in shr->diff and shr->spec and shr->shad (diffuse with shadow!) */ shade_one_light(lar, shi, shr, passflag); @@ -1775,18 +1776,18 @@ void shade_lamp_loop(ShadeInput *shi, ShadeResult *shr) if (shr->shad[1] < 0) shr->shad[1] = 0; if (shr->shad[2] < 0) shr->shad[2] = 0; - if(ma->sss_flag & MA_DIFF_SSS) { + if (ma->sss_flag & MA_DIFF_SSS) { float sss[3], col[3], invalpha, texfac= ma->sss_texfac; /* this will return false in the preprocess stage */ - if(sample_sss(&R, ma, shi->co, sss)) { + if (sample_sss(&R, ma, shi->co, sss)) { invalpha= (shr->col[3] > FLT_EPSILON)? 1.0f/shr->col[3]: 1.0f; - if(texfac==0.0f) { + if (texfac==0.0f) { copy_v3_v3(col, shr->col); mul_v3_fl(col, invalpha); } - else if(texfac==1.0f) { + else if (texfac==1.0f) { col[0]= col[1]= col[2]= 1.0f; mul_v3_fl(col, invalpha); } @@ -1802,7 +1803,7 @@ void shade_lamp_loop(ShadeInput *shi, ShadeResult *shr) shr->diff[1]= sss[1]*col[1]; shr->diff[2]= sss[2]*col[2]; - if(shi->combinedflag & SCE_PASS_SHADOW) { + if (shi->combinedflag & SCE_PASS_SHADOW) { shr->shad[0]= shr->diff[0]; shr->shad[1]= shr->diff[1]; shr->shad[2]= shr->diff[2]; @@ -1810,43 +1811,43 @@ void shade_lamp_loop(ShadeInput *shi, ShadeResult *shr) } } - if(shi->combinedflag & SCE_PASS_SHADOW) + if (shi->combinedflag & SCE_PASS_SHADOW) copy_v3_v3(shr->combined, shr->shad); /* note, no ';' ! */ else copy_v3_v3(shr->combined, shr->diff); /* calculate shadow pass, we use a multiplication mask */ /* if diff = 0,0,0 it doesn't matter what the shadow pass is, so leave it as is */ - if(passflag & SCE_PASS_SHADOW && !(shr->diff[0]==0.0f && shr->diff[1]==0.0f && shr->diff[2]==0.0f)) { - if(shr->diff[0]!=0.0f) shr->shad[0]= shr->shad[0]/shr->diff[0]; + if (passflag & SCE_PASS_SHADOW && !(shr->diff[0]==0.0f && shr->diff[1]==0.0f && shr->diff[2]==0.0f)) { + if (shr->diff[0]!=0.0f) shr->shad[0]= shr->shad[0]/shr->diff[0]; /* can't determine proper shadow from shad/diff (0/0), so use shadow intensity */ - else if(shr->shad[0]==0.0f) shr->shad[0]= shr->shad[3]; + else if (shr->shad[0]==0.0f) shr->shad[0]= shr->shad[3]; - if(shr->diff[1]!=0.0f) shr->shad[1]= shr->shad[1]/shr->diff[1]; - else if(shr->shad[1]==0.0f) shr->shad[1]= shr->shad[3]; + if (shr->diff[1]!=0.0f) shr->shad[1]= shr->shad[1]/shr->diff[1]; + else if (shr->shad[1]==0.0f) shr->shad[1]= shr->shad[3]; - if(shr->diff[2]!=0.0f) shr->shad[2]= shr->shad[2]/shr->diff[2]; - else if(shr->shad[2]==0.0f) shr->shad[2]= shr->shad[3]; + if (shr->diff[2]!=0.0f) shr->shad[2]= shr->shad[2]/shr->diff[2]; + else if (shr->shad[2]==0.0f) shr->shad[2]= shr->shad[3]; } /* exposure correction */ - if((R.wrld.exp!=0.0f || R.wrld.range!=1.0f) && !R.sss_points) { + if ((R.wrld.exp!=0.0f || R.wrld.range!=1.0f) && !R.sss_points) { wrld_exposure_correct(shr->combined); /* has no spec! */ wrld_exposure_correct(shr->spec); } } /* alpha in end, spec can influence it */ - if(passflag & (SCE_PASS_COMBINED)) { - if((ma->fresnel_tra!=0.0f) && (shi->mode & MA_TRANSP)) + if (passflag & (SCE_PASS_COMBINED)) { + if ((ma->fresnel_tra!=0.0f) && (shi->mode & MA_TRANSP)) shi->alpha*= fresnel_fac(shi->view, shi->vn, ma->fresnel_tra_i, ma->fresnel_tra); /* note: shi->mode! */ - if(shi->mode & MA_TRANSP && (shi->mode & (MA_ZTRANSP|MA_RAYTRANSP))) { - if(shi->spectra!=0.0f) { + if (shi->mode & MA_TRANSP && (shi->mode & (MA_ZTRANSP|MA_RAYTRANSP))) { + if (shi->spectra!=0.0f) { float t = MAX3(shr->spec[0], shr->spec[1], shr->spec[2]); t *= shi->spectra; - if(t>1.0f) t= 1.0f; + if (t>1.0f) t= 1.0f; shi->alpha= (1.0f-t)*shi->alpha+t; } } @@ -1854,19 +1855,19 @@ void shade_lamp_loop(ShadeInput *shi, ShadeResult *shr) shr->alpha= shi->alpha; /* from now stuff everything in shr->combined: ambient, AO, radio, ramps, exposure */ - if(!(ma->sss_flag & MA_DIFF_SSS) || !sss_pass_done(&R, ma)) { - if(R.r.mode & R_SHADOW) { + if (!(ma->sss_flag & MA_DIFF_SSS) || !sss_pass_done(&R, ma)) { + if (R.r.mode & R_SHADOW) { /* add AO in combined? */ - if(R.wrld.mode & WO_AMB_OCC) - if(shi->combinedflag & SCE_PASS_AO) + if (R.wrld.mode & WO_AMB_OCC) + if (shi->combinedflag & SCE_PASS_AO) ambient_occlusion_apply(shi, shr); - if(R.wrld.mode & WO_ENV_LIGHT) - if(shi->combinedflag & SCE_PASS_ENVIRONMENT) + if (R.wrld.mode & WO_ENV_LIGHT) + if (shi->combinedflag & SCE_PASS_ENVIRONMENT) environment_lighting_apply(shi, shr); - if(R.wrld.mode & WO_INDIRECT_LIGHT) - if(shi->combinedflag & SCE_PASS_INDIRECT) + if (R.wrld.mode & WO_INDIRECT_LIGHT) + if (shi->combinedflag & SCE_PASS_INDIRECT) indirect_lighting_apply(shi, shr); } @@ -1874,36 +1875,36 @@ void shade_lamp_loop(ShadeInput *shi, ShadeResult *shr) shr->combined[1]+= shi->ambg; shr->combined[2]+= shi->ambb; - if(ma->mode & MA_RAMP_COL) ramp_diffuse_result(shr->combined, shi); + if (ma->mode & MA_RAMP_COL) ramp_diffuse_result(shr->combined, shi); } - if(ma->mode & MA_RAMP_SPEC) ramp_spec_result(shr->spec, shi); + if (ma->mode & MA_RAMP_SPEC) ramp_spec_result(shr->spec, shi); /* refcol is for envmap only */ - if(shi->refcol[0]!=0.0f) { + if (shi->refcol[0]!=0.0f) { float result[3]; result[0]= shi->mirr*shi->refcol[1] + (1.0f - shi->mirr*shi->refcol[0])*shr->combined[0]; result[1]= shi->mirg*shi->refcol[2] + (1.0f - shi->mirg*shi->refcol[0])*shr->combined[1]; result[2]= shi->mirb*shi->refcol[3] + (1.0f - shi->mirb*shi->refcol[0])*shr->combined[2]; - if(passflag & SCE_PASS_REFLECT) + if (passflag & SCE_PASS_REFLECT) sub_v3_v3v3(shr->refl, result, shr->combined); - if(shi->combinedflag & SCE_PASS_REFLECT) + if (shi->combinedflag & SCE_PASS_REFLECT) copy_v3_v3(shr->combined, result); } /* and add emit and spec */ - if(shi->combinedflag & SCE_PASS_EMIT) + if (shi->combinedflag & SCE_PASS_EMIT) add_v3_v3(shr->combined, shr->emit); - if(shi->combinedflag & SCE_PASS_SPEC) + if (shi->combinedflag & SCE_PASS_SPEC) add_v3_v3(shr->combined, shr->spec); /* modulate by the object color */ - if((ma->shade_flag & MA_OBCOLOR) && shi->obr->ob) { - if(!(ma->sss_flag & MA_DIFF_SSS) || !sss_pass_done(&R, ma)) { + if ((ma->shade_flag & MA_OBCOLOR) && shi->obr->ob) { + if (!(ma->sss_flag & MA_DIFF_SSS) || !sss_pass_done(&R, ma)) { float obcol[4]; copy_v4_v4(obcol, shi->obr->ob->col); diff --git a/source/blender/render/intern/source/sss.c b/source/blender/render/intern/source/sss.c index 6e37c81b882..dd1bddc5020 100644 --- a/source/blender/render/intern/source/sss.c +++ b/source/blender/render/intern/source/sss.c @@ -184,26 +184,26 @@ static float compute_reduced_albedo(ScatterSettings *ss) fxn= f_Rd(xn, ss->A, ss->ro); fxn_1= f_Rd(xn_1, ss->A, ss->ro); - for(i= 0; i < max_iteration_count; i++) { + for (i= 0; i < max_iteration_count; i++) { fsub= (fxn - fxn_1); - if(fabsf(fsub) < tolerance) + if (fabsf(fsub) < tolerance) break; d= ((xn - xn_1)/fsub)*fxn; - if(fabsf(d) < tolerance) + if (fabsf(d) < tolerance) break; xn_1= xn; fxn_1= fxn; xn= xn - d; - if(xn > 1.0f) xn= 1.0f; - if(xn_1 > 1.0f) xn_1= 1.0f; + if (xn > 1.0f) xn= 1.0f; + if (xn_1 > 1.0f) xn_1= 1.0f; fxn= f_Rd(xn, ss->A, ss->ro); } /* avoid division by zero later */ - if(xn <= 0.0f) + if (xn <= 0.0f) xn= 0.00001f; return xn; @@ -240,15 +240,15 @@ static void approximate_Rd_rgb(ScatterSettings **ss, float rr, float *rd) float indexf, t, idxf; int index; - if(rr > (RD_TABLE_RANGE_2*RD_TABLE_RANGE_2)); - else if(rr > RD_TABLE_RANGE) { + if (rr > (RD_TABLE_RANGE_2*RD_TABLE_RANGE_2)); + else if (rr > RD_TABLE_RANGE) { rr= sqrt(rr); indexf= rr*(RD_TABLE_SIZE/RD_TABLE_RANGE_2); index= (int)indexf; idxf= (float)index; t= indexf - idxf; - if(index >= 0 && index < RD_TABLE_SIZE) { + if (index >= 0 && index < RD_TABLE_SIZE) { rd[0]= (ss[0]->tableRd2[index]*(1-t) + ss[0]->tableRd2[index+1]*t); rd[1]= (ss[1]->tableRd2[index]*(1-t) + ss[1]->tableRd2[index+1]*t); rd[2]= (ss[2]->tableRd2[index]*(1-t) + ss[2]->tableRd2[index+1]*t); @@ -261,7 +261,7 @@ static void approximate_Rd_rgb(ScatterSettings **ss, float rr, float *rd) idxf= (float)index; t= indexf - idxf; - if(index >= 0 && index < RD_TABLE_SIZE) { + if (index >= 0 && index < RD_TABLE_SIZE) { rd[0]= (ss[0]->tableRd[index]*(1-t) + ss[0]->tableRd[index+1]*t); rd[1]= (ss[1]->tableRd[index]*(1-t) + ss[1]->tableRd[index+1]*t); rd[2]= (ss[2]->tableRd[index]*(1-t) + ss[2]->tableRd[index+1]*t); @@ -283,7 +283,7 @@ static void build_Rd_table(ScatterSettings *ss) ss->tableRd= MEM_mallocN(sizeof(float)*size, "scatterTableRd"); ss->tableRd2= MEM_mallocN(sizeof(float)*size, "scatterTableRd"); - for(i= 0; i < size; i++) { + for (i= 0; i < size; i++) { r= i*(RD_TABLE_RANGE/RD_TABLE_SIZE); /*if(r < ss->invsigma_t_*ss->invsigma_t_) r= ss->invsigma_t_*ss->invsigma_t_;*/ @@ -353,7 +353,7 @@ static void add_radiance(ScatterTree *tree, float *frontrad, float *backrad, flo approximate_Rd_rgb(tree->ss, rr, rd); - if(frontrad && area) { + if (frontrad && area) { frontrd[0] = rd[0]*area; frontrd[1] = rd[1]*area; frontrd[2] = rd[2]*area; @@ -366,7 +366,7 @@ static void add_radiance(ScatterTree *tree, float *frontrad, float *backrad, flo result->rdsum[1] += frontrd[1]; result->rdsum[2] += frontrd[2]; } - if(backrad && backarea) { + if (backrad && backarea) { backrd[0] = rd[0]*backarea; backrd[1] = rd[1]*backarea; backrd[2] = rd[2]*backarea; @@ -386,15 +386,15 @@ static void traverse_octree(ScatterTree *tree, ScatterNode *node, float *co, int float sub[3], dist; int i, index = 0; - if(node->totpoint > 0) { + if (node->totpoint > 0) { /* leaf - add radiance from all samples */ - for(i=0; i<node->totpoint; i++) { + for (i=0; i<node->totpoint; i++) { ScatterPoint *p= &node->points[i]; sub_v3_v3v3(sub, co, p->co); dist= dot_v3v3(sub, sub); - if(p->back) + if (p->back) add_radiance(tree, NULL, p->rad, 0.0f, p->area, dist, result); else add_radiance(tree, p->rad, NULL, p->area, 0.0f, dist, result); @@ -405,11 +405,11 @@ static void traverse_octree(ScatterTree *tree, ScatterNode *node, float *co, int if (self) index = SUBNODE_INDEX(co, node->split); - for(i=0; i<8; i++) { - if(node->child[i]) { + for (i=0; i<8; i++) { + if (node->child[i]) { ScatterNode *subnode= node->child[i]; - if(self && index == i) { + if (self && index == i) { /* always traverse node containing the point */ traverse_octree(tree, subnode, co, 1, result); } @@ -419,7 +419,7 @@ static void traverse_octree(ScatterTree *tree, ScatterNode *node, float *co, int dist= dot_v3v3(sub, sub); /* actually area/dist > error, but this avoids division */ - if(subnode->area+subnode->backarea>tree->error*dist) { + if (subnode->area+subnode->backarea>tree->error*dist) { traverse_octree(tree, subnode, co, 0, result); } else { @@ -456,13 +456,13 @@ static void compute_radiance(ScatterTree *tree, float *co, float *rad) copy_v3_v3(rdsum, result.rdsum); add_v3_v3v3(backrdsum, result.rdsum, result.backrdsum); - if(rdsum[0] > 1e-16f) rad[0]= tree->ss[0]->color*rad[0]/rdsum[0]; - if(rdsum[1] > 1e-16f) rad[1]= tree->ss[1]->color*rad[1]/rdsum[1]; - if(rdsum[2] > 1e-16f) rad[2]= tree->ss[2]->color*rad[2]/rdsum[2]; + if (rdsum[0] > 1e-16f) rad[0]= tree->ss[0]->color*rad[0]/rdsum[0]; + if (rdsum[1] > 1e-16f) rad[1]= tree->ss[1]->color*rad[1]/rdsum[1]; + if (rdsum[2] > 1e-16f) rad[2]= tree->ss[2]->color*rad[2]/rdsum[2]; - if(backrdsum[0] > 1e-16f) backrad[0]= tree->ss[0]->color*backrad[0]/backrdsum[0]; - if(backrdsum[1] > 1e-16f) backrad[1]= tree->ss[1]->color*backrad[1]/backrdsum[1]; - if(backrdsum[2] > 1e-16f) backrad[2]= tree->ss[2]->color*backrad[2]/backrdsum[2]; + if (backrdsum[0] > 1e-16f) backrad[0]= tree->ss[0]->color*backrad[0]/backrdsum[0]; + if (backrdsum[1] > 1e-16f) backrad[1]= tree->ss[1]->color*backrad[1]/backrdsum[1]; + if (backrdsum[2] > 1e-16f) backrad[2]= tree->ss[2]->color*backrad[2]/backrdsum[2]; rad[0]= MAX2(rad[0], backrad[0]); rad[1]= MAX2(rad[1], backrad[1]); @@ -483,7 +483,7 @@ static void sum_leaf_radiance(ScatterTree *UNUSED(tree), ScatterNode *node) /* compute total rad, rad weighted average position, * and total area */ - for(i=0; i<node->totpoint; i++) { + for (i=0; i<node->totpoint; i++) { p= &node->points[i]; rad= p->area*fabsf(p->rad[0] + p->rad[1] + p->rad[2]); @@ -493,7 +493,7 @@ static void sum_leaf_radiance(ScatterTree *UNUSED(tree), ScatterNode *node) node->co[1] += rad*p->co[1]; node->co[2] += rad*p->co[2]; - if(p->back) { + if (p->back) { node->backrad[0] += p->rad[0]*p->area; node->backrad[1] += p->rad[1]*p->area; node->backrad[2] += p->rad[2]*p->area; @@ -509,20 +509,20 @@ static void sum_leaf_radiance(ScatterTree *UNUSED(tree), ScatterNode *node) } } - if(node->area > 1e-16f) { + if (node->area > 1e-16f) { inv= 1.0f/node->area; node->rad[0] *= inv; node->rad[1] *= inv; node->rad[2] *= inv; } - if(node->backarea > 1e-16f) { + if (node->backarea > 1e-16f) { inv= 1.0f/node->backarea; node->backrad[0] *= inv; node->backrad[1] *= inv; node->backrad[2] *= inv; } - if(totrad > 1e-16f) { + if (totrad > 1e-16f) { inv= 1.0f/totrad; node->co[0] *= inv; node->co[1] *= inv; @@ -531,7 +531,7 @@ static void sum_leaf_radiance(ScatterTree *UNUSED(tree), ScatterNode *node) else { /* make sure that if radiance is 0.0f, we still have these points in * the tree at a good position, they count for rdsum too */ - for(i=0; i<node->totpoint; i++) { + for (i=0; i<node->totpoint; i++) { p= &node->points[i]; node->co[0] += p->co[0]; @@ -557,8 +557,8 @@ static void sum_branch_radiance(ScatterTree *UNUSED(tree), ScatterNode *node) /* compute total rad, rad weighted average position, * and total area */ - for(i=0; i<8; i++) { - if(node->child[i] == NULL) + for (i=0; i<8; i++) { + if (node->child[i] == NULL) continue; subnode= node->child[i]; @@ -583,20 +583,20 @@ static void sum_branch_radiance(ScatterTree *UNUSED(tree), ScatterNode *node) node->backarea += subnode->backarea; } - if(node->area > 1e-16f) { + if (node->area > 1e-16f) { inv= 1.0f/node->area; node->rad[0] *= inv; node->rad[1] *= inv; node->rad[2] *= inv; } - if(node->backarea > 1e-16f) { + if (node->backarea > 1e-16f) { inv= 1.0f/node->backarea; node->backrad[0] *= inv; node->backrad[1] *= inv; node->backrad[2] *= inv; } - if(totrad > 1e-16f) { + if (totrad > 1e-16f) { inv= 1.0f/totrad; node->co[0] *= inv; node->co[1] *= inv; @@ -607,8 +607,8 @@ static void sum_branch_radiance(ScatterTree *UNUSED(tree), ScatterNode *node) * the tree at a good position, they count for rdsum too */ totnode= 0; - for(i=0; i<8; i++) { - if(node->child[i]) { + for (i=0; i<8; i++) { + if (node->child[i]) { subnode= node->child[i]; node->co[0] += subnode->co[0]; @@ -627,14 +627,14 @@ static void sum_branch_radiance(ScatterTree *UNUSED(tree), ScatterNode *node) static void sum_radiance(ScatterTree *tree, ScatterNode *node) { - if(node->totpoint > 0) { + if (node->totpoint > 0) { sum_leaf_radiance(tree, node); } else { int i; - for(i=0; i<8; i++) - if(node->child[i]) + for (i=0; i<8; i++) + if (node->child[i]) sum_radiance(tree, node->child[i]); sum_branch_radiance(tree, node); @@ -658,8 +658,8 @@ static void create_octree_node(ScatterTree *tree, ScatterNode *node, float *mid, float submid[3], subsize[3]; /* stopping condition */ - if(node->totpoint <= MAX_OCTREE_NODE_POINTS || depth == MAX_OCTREE_DEPTH) { - for(i=0; i<node->totpoint; i++) + if (node->totpoint <= MAX_OCTREE_NODE_POINTS || depth == MAX_OCTREE_DEPTH) { + for (i=0; i<node->totpoint; i++) node->points[i]= *(refpoints[i]); return; @@ -677,7 +677,7 @@ static void create_octree_node(ScatterTree *tree, ScatterNode *node, float *mid, memset(noffset, 0, sizeof(noffset)); /* count points in subnodes */ - for(i=0; i<node->totpoint; i++) { + for (i=0; i<node->totpoint; i++) { index= SUBNODE_INDEX(refpoints[i]->co, node->split); tmppoints[i]= refpoints[i]; nsize[index]++; @@ -686,31 +686,31 @@ static void create_octree_node(ScatterTree *tree, ScatterNode *node, float *mid, /* here we check if only one subnode is used. if this is the case, we don't * create a new node, but rather call this function again, with different * size and middle position for the same node. */ - for(usedi=0, usednodes=0, i=0; i<8; i++) { - if(nsize[i]) { + for (usedi=0, usednodes=0, i=0; i<8; i++) { + if (nsize[i]) { usednodes++; usedi = i; } - if(i != 0) + if (i != 0) noffset[i]= noffset[i-1]+nsize[i-1]; } - if(usednodes<=1) { + if (usednodes<=1) { subnode_middle(usedi, mid, subsize, submid); create_octree_node(tree, node, submid, subsize, refpoints, depth+1); return; } /* reorder refpoints by subnode */ - for(i=0; i<node->totpoint; i++) { + for (i=0; i<node->totpoint; i++) { index= SUBNODE_INDEX(tmppoints[i]->co, node->split); refpoints[noffset[index]]= tmppoints[i]; noffset[index]++; } /* create subnodes */ - for(subco=0, i=0; i<8; subco+=nsize[i], i++) { - if(nsize[i] > 0) { + for (subco=0, i=0; i<8; subco+=nsize[i], i++) { + if (nsize[i] > 0) { subnode= BLI_memarena_alloc(tree->arena, sizeof(ScatterNode)); node->child[i]= subnode; subnode->points= node->points + subco; @@ -758,7 +758,7 @@ ScatterTree *scatter_tree_new(ScatterSettings *ss[3], float scale, float error, /* build points */ INIT_MINMAX(tree->min, tree->max); - for(i=0; i<totpoint; i++) { + for (i=0; i<totpoint; i++) { copy_v3_v3(points[i].co, co[i]); copy_v3_v3(points[i].rad, color[i]); points[i].area= fabsf(area[i])/(tree->scale*tree->scale); @@ -857,7 +857,7 @@ static void sss_create_tree_mat(Render *re, Material *mat) float (*co)[3] = NULL, (*color)[3] = NULL, *area = NULL; int totpoint = 0, osa, osaflag, partsdone; - if(re->test_break(re->tbh)) + if (re->test_break(re->tbh)) return; points.first= points.last= NULL; @@ -878,14 +878,14 @@ static void sss_create_tree_mat(Render *re, Material *mat) re->sss_mat= mat; re->i.partsdone= 0; - if(!(re->r.scemode & R_PREVIEWBUTS)) + if (!(re->r.scemode & R_PREVIEWBUTS)) re->result= NULL; BLI_rw_mutex_unlock(&re->resultmutex); RE_TileProcessor(re); BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE); - if(!(re->r.scemode & R_PREVIEWBUTS)) { + if (!(re->r.scemode & R_PREVIEWBUTS)) { RE_FreeRenderResult(re->result); re->result= rr; } @@ -898,19 +898,19 @@ static void sss_create_tree_mat(Render *re, Material *mat) if (osaflag) re->r.mode |= R_OSA; /* no points? no tree */ - if(!points.first) + if (!points.first) return; /* merge points together into a single buffer */ - if(!re->test_break(re->tbh)) { - for(totpoint=0, p=points.first; p; p=p->next) + if (!re->test_break(re->tbh)) { + for (totpoint=0, p=points.first; p; p=p->next) totpoint += p->totpoint; co= MEM_mallocN(sizeof(*co)*totpoint, "SSSCo"); color= MEM_mallocN(sizeof(*color)*totpoint, "SSSColor"); area= MEM_mallocN(sizeof(*area)*totpoint, "SSSArea"); - for(totpoint=0, p=points.first; p; p=p->next) { + for (totpoint=0, p=points.first; p; p=p->next) { memcpy(co+totpoint, p->co, sizeof(*co)*p->totpoint); memcpy(color+totpoint, p->color, sizeof(*color)*p->totpoint); memcpy(area+totpoint, p->area, sizeof(*area)*p->totpoint); @@ -919,7 +919,7 @@ static void sss_create_tree_mat(Render *re, Material *mat) } /* free points */ - for(p=points.first; p; p=p->next) { + for (p=points.first; p; p=p->next) { MEM_freeN(p->co); MEM_freeN(p->color); MEM_freeN(p->area); @@ -927,7 +927,7 @@ static void sss_create_tree_mat(Render *re, Material *mat) BLI_freelistN(&points); /* build tree */ - if(!re->test_break(re->tbh)) { + if (!re->test_break(re->tbh)) { SSSData *sss= MEM_callocN(sizeof(*sss), "SSSData"); float ior= mat->sss_ior, cfac= mat->sss_colfac; float *radius= mat->sss_radius; @@ -935,7 +935,7 @@ static void sss_create_tree_mat(Render *re, Material *mat) float error = mat->sss_error; error= get_render_aosss_error(&re->r, error); - if((re->r.scemode & R_PREVIEWBUTS) && error < 0.5f) + if ((re->r.scemode & R_PREVIEWBUTS) && error < 0.5f) error= 0.5f; sss->ss[0]= scatter_settings_new(mat->sss_col[0], radius[0], ior, cfac, fw, bw); @@ -963,7 +963,7 @@ void sss_add_points(Render *re, float (*co)[3], float (*color)[3], float *area, { SSSPoints *p; - if(totpoint > 0) { + if (totpoint > 0) { p= MEM_callocN(sizeof(SSSPoints), "SSSPoints"); p->co= co; @@ -997,15 +997,15 @@ void make_sss_tree(Render *re) re->i.infostr= "SSS preprocessing"; re->stats_draw(re->sdh, &re->i); - for(mat= re->main->mat.first; mat; mat= mat->id.next) - if(mat->id.us && (mat->flag & MA_IS_USED) && (mat->sss_flag & MA_DIFF_SSS)) + for (mat= re->main->mat.first; mat; mat= mat->id.next) + if (mat->id.us && (mat->flag & MA_IS_USED) && (mat->sss_flag & MA_DIFF_SSS)) sss_create_tree_mat(re, mat); /* XXX preview exception */ /* localizing preview render data is not fun for node trees :( */ - if(re->main!=G.main) { - for(mat= G.main->mat.first; mat; mat= mat->id.next) - if(mat->id.us && (mat->flag & MA_IS_USED) && (mat->sss_flag & MA_DIFF_SSS)) + if (re->main!=G.main) { + for (mat= G.main->mat.first; mat; mat= mat->id.next) + if (mat->id.us && (mat->flag & MA_IS_USED) && (mat->sss_flag & MA_DIFF_SSS)) sss_create_tree_mat(re, mat); } @@ -1013,10 +1013,10 @@ void make_sss_tree(Render *re) void free_sss(Render *re) { - if(re->sss_hash) { + if (re->sss_hash) { GHashIterator *it= BLI_ghashIterator_new(re->sss_hash); - while(!BLI_ghashIterator_isDone(it)) { + while (!BLI_ghashIterator_isDone(it)) { sss_free_tree(BLI_ghashIterator_getValue(it)); BLI_ghashIterator_step(it); } @@ -1029,10 +1029,10 @@ void free_sss(Render *re) int sample_sss(Render *re, Material *mat, float *co, float *color) { - if(re->sss_hash) { + if (re->sss_hash) { SSSData *sss= BLI_ghash_lookup(re->sss_hash, mat); - if(sss) { + if (sss) { scatter_tree_sample(sss->tree, co, color); return 1; } diff --git a/source/blender/render/intern/source/strand.c b/source/blender/render/intern/source/strand.c index b5ace10fc07..9a24e1dbe75 100644 --- a/source/blender/render/intern/source/strand.c +++ b/source/blender/render/intern/source/strand.c @@ -74,8 +74,8 @@ static float strand_eval_width(Material *ma, float strandco) strandco= 0.5f*(strandco + 1.0f); - if(ma->strand_ease!=0.0f) { - if(ma->strand_ease<0.0f) + if (ma->strand_ease!=0.0f) { + if (ma->strand_ease<0.0f) fac= pow(strandco, 1.0f+ma->strand_ease); else fac= pow(strandco, 1.0f/(1.0f-ma->strand_ease)); @@ -103,27 +103,27 @@ void strand_eval_point(StrandSegment *sseg, StrandPoint *spoint) copy_v3_v3(p[2], sseg->v[2]->co); copy_v3_v3(p[3], sseg->v[3]->co); - if(sseg->obi->flag & R_TRANSFORMED) { + if (sseg->obi->flag & R_TRANSFORMED) { mul_m4_v3(sseg->obi->mat, p[0]); mul_m4_v3(sseg->obi->mat, p[1]); mul_m4_v3(sseg->obi->mat, p[2]); mul_m4_v3(sseg->obi->mat, p[3]); } - if(t == 0.0f) { + if (t == 0.0f) { copy_v3_v3(spoint->co, p[1]); spoint->strandco= sseg->v[1]->strandco; spoint->dtstrandco= (sseg->v[2]->strandco - sseg->v[0]->strandco); - if(sseg->v[0] != sseg->v[1]) + if (sseg->v[0] != sseg->v[1]) spoint->dtstrandco *= 0.5f; } - else if(t == 1.0f) { + else if (t == 1.0f) { copy_v3_v3(spoint->co, p[2]); spoint->strandco= sseg->v[2]->strandco; spoint->dtstrandco= (sseg->v[3]->strandco - sseg->v[1]->strandco); - if(sseg->v[3] != sseg->v[2]) + if (sseg->v[3] != sseg->v[2]) spoint->dtstrandco *= 0.5f; } else { @@ -157,17 +157,17 @@ void strand_eval_point(StrandSegment *sseg, StrandPoint *spoint) dy= strandbuf->winy*cross[1]*strandbuf->winmat[1][1]/w; w= sqrt(dx*dx + dy*dy); - if(w > 0.0f) { - if(strandbuf->flag & R_STRAND_B_UNITS) { + if (w > 0.0f) { + if (strandbuf->flag & R_STRAND_B_UNITS) { const float crosslen= len_v3(cross); w= 2.0f*crosslen*strandbuf->minwidth/w; - if(spoint->width < w) { + if (spoint->width < w) { spoint->alpha= spoint->width/w; spoint->width= w; } - if(simplify) + if (simplify) /* squared because we only change width, not length */ spoint->width *= simplify[0]*simplify[0]; @@ -211,45 +211,45 @@ static void interpolate_shade_result(ShadeResult *shr1, ShadeResult *shr2, float interpolate_vec4(shr1->combined, shr2->combined, t, negt, shr->combined); - if(addpassflag & SCE_PASS_VECTOR) { + if (addpassflag & SCE_PASS_VECTOR) { interpolate_vec4(shr1->winspeed, shr2->winspeed, t, negt, shr->winspeed); } /* optim... */ - if(addpassflag & ~(SCE_PASS_VECTOR)) { - if(addpassflag & SCE_PASS_Z) + if (addpassflag & ~(SCE_PASS_VECTOR)) { + if (addpassflag & SCE_PASS_Z) interpolate_vec1(&shr1->z, &shr2->z, t, negt, &shr->z); - if(addpassflag & SCE_PASS_RGBA) + if (addpassflag & SCE_PASS_RGBA) interpolate_vec4(shr1->col, shr2->col, t, negt, shr->col); - if(addpassflag & SCE_PASS_NORMAL) { + if (addpassflag & SCE_PASS_NORMAL) { interpolate_vec3(shr1->nor, shr2->nor, t, negt, shr->nor); normalize_v3(shr->nor); } - if(addpassflag & SCE_PASS_EMIT) + if (addpassflag & SCE_PASS_EMIT) interpolate_vec3(shr1->emit, shr2->emit, t, negt, shr->emit); - if(addpassflag & SCE_PASS_DIFFUSE) + if (addpassflag & SCE_PASS_DIFFUSE) interpolate_vec3(shr1->diff, shr2->diff, t, negt, shr->diff); - if(addpassflag & SCE_PASS_SPEC) + if (addpassflag & SCE_PASS_SPEC) interpolate_vec3(shr1->spec, shr2->spec, t, negt, shr->spec); - if(addpassflag & SCE_PASS_SHADOW) + if (addpassflag & SCE_PASS_SHADOW) interpolate_vec3(shr1->shad, shr2->shad, t, negt, shr->shad); - if(addpassflag & SCE_PASS_AO) + if (addpassflag & SCE_PASS_AO) interpolate_vec3(shr1->ao, shr2->ao, t, negt, shr->ao); - if(addpassflag & SCE_PASS_ENVIRONMENT) + if (addpassflag & SCE_PASS_ENVIRONMENT) interpolate_vec3(shr1->env, shr2->env, t, negt, shr->env); - if(addpassflag & SCE_PASS_INDIRECT) + if (addpassflag & SCE_PASS_INDIRECT) interpolate_vec3(shr1->indirect, shr2->indirect, t, negt, shr->indirect); - if(addpassflag & SCE_PASS_REFLECT) + if (addpassflag & SCE_PASS_REFLECT) interpolate_vec3(shr1->refl, shr2->refl, t, negt, shr->refl); - if(addpassflag & SCE_PASS_REFRACT) + if (addpassflag & SCE_PASS_REFRACT) interpolate_vec3(shr1->refr, shr2->refr, t, negt, shr->refr); - if(addpassflag & SCE_PASS_MIST) + if (addpassflag & SCE_PASS_MIST) interpolate_vec1(&shr1->mist, &shr2->mist, t, negt, &shr->mist); } } static void strand_apply_shaderesult_alpha(ShadeResult *shr, float alpha) { - if(alpha < 1.0f) { + if (alpha < 1.0f) { shr->combined[0] *= alpha; shr->combined[1] *= alpha; shr->combined[2] *= alpha; @@ -273,7 +273,7 @@ static void strand_shade_point(Render *re, ShadeSample *ssamp, StrandSegment *ss memset(&vlr, 0, sizeof(vlr)); vlr.flag= R_SMOOTH; - if(sseg->buffer->ma->mode & MA_TANGENT_STR) + if (sseg->buffer->ma->mode & MA_TANGENT_STR) vlr.flag |= R_TANGENT; shi->vlr= &vlr; @@ -308,8 +308,8 @@ static void strand_shade_point(Render *re, ShadeSample *ssamp, StrandSegment *ss strand_apply_shaderesult_alpha(shr, spoint->alpha); /* include lamphalos for strand, since halo layer was added already */ - if(re->flag & R_LAMPHALO) - if(shi->layflag & SCE_LAY_HALO) + if (re->flag & R_LAMPHALO) + if (shi->layflag & SCE_LAY_HALO) renderspothalo(shi, shr->combined, shr->combined[3]); shi->strand= NULL; @@ -352,7 +352,7 @@ static void strand_shade_get(Render *re, StrandShadeCache *cache, ShadeSample *s hashshr= BLI_ghash_lookup(cache->resulthash, svert); refcount= BLI_ghash_lookup(cache->refcounthash, svert); - if(!hashshr) { + if (!hashshr) { /* not shaded yet, shade and insert into hash */ p.t= (sseg->v[1] == svert)? 0.0f: 1.0f; strand_eval_point(sseg, &p); @@ -368,7 +368,7 @@ static void strand_shade_get(Render *re, StrandShadeCache *cache, ShadeSample *s /* lower reference count and remove if not needed anymore by any samples */ (*refcount)--; - if(*refcount == 0) { + if (*refcount == 0) { BLI_ghash_remove(cache->resulthash, svert, NULL, (GHashValFreeFP)MEM_freeN); BLI_ghash_remove(cache->refcounthash, svert, NULL, NULL); } @@ -387,7 +387,7 @@ void strand_shade_segment(Render *re, StrandShadeCache *cache, StrandSegment *ss interpolate_shade_result(&shr1, &shr2, t, ssamp->shr, addpassflag); /* apply alpha along width */ - if(sseg->buffer->widthfade != 0.0f) { + if (sseg->buffer->widthfade != 0.0f) { s = 1.0f - pow(fabs(s), sseg->buffer->widthfade); strand_apply_shaderesult_alpha(ssamp->shr, s); @@ -402,7 +402,7 @@ void strand_shade_unref(StrandShadeCache *cache, StrandVert *svert) refcount= BLI_ghash_lookup(cache->refcounthash, svert); (*refcount)--; - if(*refcount == 0) { + if (*refcount == 0) { BLI_ghash_remove(cache->resulthash, svert, NULL, (GHashValFreeFP)MEM_freeN); BLI_ghash_remove(cache->refcounthash, svert, NULL, NULL); } @@ -412,7 +412,7 @@ static void strand_shade_refcount(StrandShadeCache *cache, StrandVert *svert) { int *refcount= BLI_ghash_lookup(cache->refcounthash, svert); - if(!refcount) { + if (!refcount) { refcount= BLI_memarena_alloc(cache->memarena, sizeof(int)); *refcount= 1; BLI_ghash_insert(cache->refcounthash, svert, refcount); @@ -454,9 +454,9 @@ static int compare_strand_segment(const void *poin1, const void *poin2) const StrandSortSegment *seg1= (const StrandSortSegment*)poin1; const StrandSortSegment *seg2= (const StrandSortSegment*)poin2; - if(seg1->z < seg2->z) + if (seg1->z < seg2->z) return -1; - else if(seg1->z == seg2->z) + else if (seg1->z == seg2->z) return 0; else return 1; @@ -493,7 +493,7 @@ static APixstrand *addpsmainAstrand(ListBase *lb) static APixstrand *addpsAstrand(ZSpan *zspan) { /* make new PS */ - if(zspan->apstrandmcounter==0) { + if (zspan->apstrandmcounter==0) { zspan->curpstrand= addpsmainAstrand(zspan->apsmbase); zspan->apstrandmcounter= 4095; } @@ -524,19 +524,19 @@ static void do_strand_fillac(void *handle, int x, int y, float u, float v, float /* check against solid z-buffer */ zverg= (int)z; - if(spart->rectdaps) { + if (spart->rectdaps) { /* find the z of the sample */ PixStr *ps; intptr_t *rd= spart->rectdaps + offset; bufferz= 0x7FFFFFFF; - if(spart->rectmask) maskz= 0x7FFFFFFF; + if (spart->rectmask) maskz= 0x7FFFFFFF; - if(*rd) { - for(ps= (PixStr *)(*rd); ps; ps= ps->next) { - if(mask & ps->mask) { + if (*rd) { + for (ps= (PixStr *)(*rd); ps; ps= ps->next) { + if (mask & ps->mask) { bufferz= ps->z; - if(spart->rectmask) + if (spart->rectmask) maskz= ps->maskz; break; } @@ -545,25 +545,25 @@ static void do_strand_fillac(void *handle, int x, int y, float u, float v, float } else { bufferz= (spart->rectz)? spart->rectz[offset]: 0x7FFFFFFF; - if(spart->rectmask) + if (spart->rectmask) maskz= spart->rectmask[offset]; } #define CHECK_ADD(n) \ - if(apn->p[n]==strnr && apn->obi[n]==obi && apn->seg[n]==seg) \ + if (apn->p[n]==strnr && apn->obi[n]==obi && apn->seg[n]==seg) \ { if(!(apn->mask[n] & mask)) { apn->mask[n] |= mask; apn->v[n] += t; apn->u[n] += s; } break; } #define CHECK_ASSIGN(n) \ - if(apn->p[n]==0) \ + if (apn->p[n]==0) \ {apn->obi[n]= obi; apn->p[n]= strnr; apn->z[n]= zverg; apn->mask[n]= mask; apn->v[n]= t; apn->u[n]= s; apn->seg[n]= seg; break; } /* add to pixel list */ - if(zverg < bufferz && (spart->totapixbuf[offset] < MAX_ZROW)) { - if(!spart->rectmask || zverg > maskz) { + if (zverg < bufferz && (spart->totapixbuf[offset] < MAX_ZROW)) { + if (!spart->rectmask || zverg > maskz) { t = u*spart->t[0] + v*spart->t[1] + (1.0f-u-v)*spart->t[2]; s = fabs(u*spart->s[0] + v*spart->s[1] + (1.0f-u-v)*spart->s[2]); apn= spart->apixbuf + offset; - while(apn) { + while (apn) { CHECK_ADD(0); CHECK_ADD(1); CHECK_ADD(2); @@ -579,7 +579,7 @@ static void do_strand_fillac(void *handle, int x, int y, float u, float v, float CHECK_ASSIGN(0); } - if(cache) { + if (cache) { strand_shade_refcount(cache, sseg->v[1]); strand_shade_refcount(cache, sseg->v[2]); } @@ -599,11 +599,11 @@ static int strand_test_clip(float winmat[][4], ZSpan *UNUSED(zspan), float *boun /* we compare z without perspective division for segment sorting */ *zcomp= hoco[2]; - if(hoco[0]+widthx < bounds[0]*hoco[3]) clipflag |= 1; - else if(hoco[0]-widthx > bounds[1]*hoco[3]) clipflag |= 2; + if (hoco[0]+widthx < bounds[0]*hoco[3]) clipflag |= 1; + else if (hoco[0]-widthx > bounds[1]*hoco[3]) clipflag |= 2; - if(hoco[1]-widthy > bounds[3]*hoco[3]) clipflag |= 4; - else if(hoco[1]+widthy < bounds[2]*hoco[3]) clipflag |= 8; + if (hoco[1]-widthy > bounds[3]*hoco[3]) clipflag |= 4; + else if (hoco[1]+widthy < bounds[2]*hoco[3]) clipflag |= 8; clipflag |= testclip(hoco); @@ -619,7 +619,7 @@ static void do_scanconvert_strand(Render *UNUSED(re), StrandPart *spart, ZSpan * copy_v3_v3(jco3, co3); copy_v3_v3(jco4, co4); - if(spart->jit) { + if (spart->jit) { jx= -spart->jit[sample][0]; jy= -spart->jit[sample][1]; @@ -651,13 +651,13 @@ static void do_scanconvert_strand(Render *UNUSED(re), StrandPart *spart, ZSpan * static void strand_render(Render *re, StrandSegment *sseg, float winmat[][4], StrandPart *spart, ZSpan *zspan, int totzspan, StrandPoint *p1, StrandPoint *p2) { - if(spart) { + if (spart) { float t= p2->t; float dt= p2->t - p1->t; int a; - if(re->osa) { - for(a=0; a<re->osa; a++) + if (re->osa) { + for (a=0; a<re->osa; a++) do_scanconvert_strand(re, spart, zspan, t, dt, p1->zco2, p1->zco1, p2->zco1, p2->zco2, a); } else @@ -674,7 +674,7 @@ static void strand_render(Render *re, StrandSegment *sseg, float winmat[][4], St projectvert(p2->co, winmat, hoco2); - for(a=0; a<totzspan; a++) { + for (a=0; a<totzspan; a++) { #if 0 /* render both strand and single pixel wire to counter aliasing */ zbufclip4(re, &zspan[a], obi, index, p1->hoco2, p1->hoco1, p2->hoco1, p2->hoco2, p1->clip2, p1->clip1, p2->clip1, p2->clip2); @@ -692,7 +692,7 @@ static int strand_segment_recursive(Render *re, float winmat[][4], StrandPart *s StrandBuffer *buffer= sseg->buffer; float dot, d1[2], d2[2], len1, len2; - if(depth == buffer->maxdepth) + if (depth == buffer->maxdepth) return 0; p.t= (p1->t + p2->t)*0.5f; @@ -707,14 +707,14 @@ static int strand_segment_recursive(Render *re, float winmat[][4], StrandPart *s d2[1]= (p2->y - p.y); len2= d2[0]*d2[0] + d2[1]*d2[1]; - if(len1 == 0.0f || len2 == 0.0f) + if (len1 == 0.0f || len2 == 0.0f) return 0; dot= d1[0]*d2[0] + d1[1]*d2[1]; - if(dot*dot > sseg->sqadaptcos*len1*len2) + if (dot*dot > sseg->sqadaptcos*len1*len2) return 0; - if(spart) { + if (spart) { do_strand_point_project(winmat, zspan, p.co1, p.hoco1, p.zco1); do_strand_point_project(winmat, zspan, p.co2, p.hoco2, p.zco2); } @@ -727,9 +727,9 @@ static int strand_segment_recursive(Render *re, float winmat[][4], StrandPart *s #endif } - if(!strand_segment_recursive(re, winmat, spart, zspan, totzspan, sseg, p1, &p, depth+1)) + if (!strand_segment_recursive(re, winmat, spart, zspan, totzspan, sseg, p1, &p, depth+1)) strand_render(re, sseg, winmat, spart, zspan, totzspan, p1, &p); - if(!strand_segment_recursive(re, winmat, spart, zspan, totzspan, sseg, &p, p2, depth+1)) + if (!strand_segment_recursive(re, winmat, spart, zspan, totzspan, sseg, &p, p2, depth+1)) strand_render(re, sseg, winmat, spart, zspan, totzspan, &p, p2); return 1; @@ -749,7 +749,7 @@ void render_strand_segment(Render *re, float winmat[][4], StrandPart *spart, ZSp strand_eval_point(sseg, p2); strand_project_point(buffer->winmat, buffer->winx, buffer->winy, p2); - if(spart) { + if (spart) { do_strand_point_project(winmat, zspan, p1->co1, p1->hoco1, p1->zco1); do_strand_point_project(winmat, zspan, p1->co2, p1->hoco2, p1->zco2); do_strand_point_project(winmat, zspan, p2->co1, p2->hoco1, p2->zco1); @@ -768,7 +768,7 @@ void render_strand_segment(Render *re, float winmat[][4], StrandPart *spart, ZSp #endif } - if(!strand_segment_recursive(re, winmat, spart, zspan, totzspan, sseg, p1, p2, 0)) + if (!strand_segment_recursive(re, winmat, spart, zspan, totzspan, sseg, p1, p2, 0)) strand_render(re, sseg, winmat, spart, zspan, totzspan, p1, p2); } @@ -788,9 +788,9 @@ int zbuffer_strands_abuf(Render *re, RenderPart *pa, APixstrand *apixbuf, ListBa float z[4], bounds[4], obwinmat[4][4]; int a, b, c, i, totsegment, clip[4]; - if(re->test_break(re->tbh)) + if (re->test_break(re->tbh)) return 0; - if(re->totstrand == 0) + if (re->totstrand == 0) return 0; /* setup StrandPart */ @@ -818,7 +818,7 @@ int zbuffer_strands_abuf(Render *re, RenderPart *pa, APixstrand *apixbuf, ListBa zspan.zofsy= -pa->disprect.ymin; /* to center the sample position */ - if(!shadow) { + if (!shadow) { zspan.zofsx -= 0.5f; zspan.zofsy -= 0.5f; } @@ -836,17 +836,17 @@ int zbuffer_strands_abuf(Render *re, RenderPart *pa, APixstrand *apixbuf, ListBa totsegment= 0; /* for all object instances */ - for(obi=re->instancetable.first, i=0; obi; obi=obi->next, i++) { + for (obi=re->instancetable.first, i=0; obi; obi=obi->next, i++) { Material *ma; float widthx, widthy; obr= obi->obr; - if(!obr->strandbuf || !(obr->strandbuf->lay & lay)) + if (!obr->strandbuf || !(obr->strandbuf->lay & lay)) continue; /* compute matrix and try clipping whole object */ - if(obi->flag & R_TRANSFORMED) + if (obi->flag & R_TRANSFORMED) mult_m4_m4m4(obwinmat, winmat, obi->mat); else copy_m4_m4(obwinmat, winmat); @@ -854,12 +854,12 @@ int zbuffer_strands_abuf(Render *re, RenderPart *pa, APixstrand *apixbuf, ListBa /* test if we should skip it */ ma = obr->strandbuf->ma; - if(shadow && !(ma->mode & MA_SHADBUF)) + if (shadow && !(ma->mode & MA_SHADBUF)) continue; - else if(!shadow && (ma->mode & MA_ONLYCAST)) + else if (!shadow && (ma->mode & MA_ONLYCAST)) continue; - if(clip_render_object(obi->obr->boundbox, bounds, obwinmat)) + if (clip_render_object(obi->obr->boundbox, bounds, obwinmat)) continue; widthx= obr->strandbuf->maxwidth*obwinmat[0][0]; @@ -867,12 +867,12 @@ int zbuffer_strands_abuf(Render *re, RenderPart *pa, APixstrand *apixbuf, ListBa /* for each bounding box containing a number of strands */ sbound= obr->strandbuf->bound; - for(c=0; c<obr->strandbuf->totbound; c++, sbound++) { - if(clip_render_object(sbound->boundbox, bounds, obwinmat)) + for (c=0; c<obr->strandbuf->totbound; c++, sbound++) { + if (clip_render_object(sbound->boundbox, bounds, obwinmat)) continue; /* for each strand in this bounding box */ - for(a=sbound->start; a<sbound->end; a++) { + for (a=sbound->start; a<sbound->end; a++) { strand= RE_findOrAddStrand(obr, a); svert= strand->vert; @@ -881,9 +881,9 @@ int zbuffer_strands_abuf(Render *re, RenderPart *pa, APixstrand *apixbuf, ListBa clip[2]= strand_test_clip(obwinmat, &zspan, bounds, (svert+1)->co, &z[2], widthx, widthy); clip[0]= clip[1]; z[0]= z[1]; - for(b=0; b<strand->totvert-1; b++, svert++) { + for (b=0; b<strand->totvert-1; b++, svert++) { /* compute 4th point clipping and z depth */ - if(b < strand->totvert-2) { + if (b < strand->totvert-2) { clip[3]= strand_test_clip(obwinmat, &zspan, bounds, (svert+2)->co, &z[3], widthx, widthy); } else { @@ -891,7 +891,7 @@ int zbuffer_strands_abuf(Render *re, RenderPart *pa, APixstrand *apixbuf, ListBa } /* check clipping and add to sortsegments buffer */ - if(!(clip[0] & clip[1] & clip[2] & clip[3])) { + if (!(clip[0] & clip[1] & clip[2] & clip[3])) { sortseg= BLI_memarena_alloc(memarena, sizeof(StrandSortSegment)); sortseg->obi= i; sortseg->strand= strand->index; @@ -913,10 +913,10 @@ int zbuffer_strands_abuf(Render *re, RenderPart *pa, APixstrand *apixbuf, ListBa } } - if(!re->test_break(re->tbh)) { + if (!re->test_break(re->tbh)) { /* convert list to array and sort */ sortsegments= MEM_mallocN(sizeof(StrandSortSegment)*totsegment, "StrandSortSegment"); - for(a=0, sortseg=firstseg; a<totsegment; a++, sortseg=sortseg->next) + for (a=0, sortseg=firstseg; a<totsegment; a++, sortseg=sortseg->next) sortsegments[a]= *sortseg; qsort(sortsegments, totsegment, sizeof(StrandSortSegment), compare_strand_segment); } @@ -925,11 +925,11 @@ int zbuffer_strands_abuf(Render *re, RenderPart *pa, APixstrand *apixbuf, ListBa spart.totapixbuf= MEM_callocN(sizeof(int)*pa->rectx*pa->recty, "totapixbuf"); - if(!re->test_break(re->tbh)) { + if (!re->test_break(re->tbh)) { /* render segments in sorted order */ sortseg= sortsegments; - for(a=0; a<totsegment; a++, sortseg++) { - if(re->test_break(re->tbh)) + for (a=0; a<totsegment; a++, sortseg++) { + if (re->test_break(re->tbh)) break; obi= &re->objectinstance[sortseg->obi]; @@ -954,7 +954,7 @@ int zbuffer_strands_abuf(Render *re, RenderPart *pa, APixstrand *apixbuf, ListBa } } - if(sortsegments) + if (sortsegments) MEM_freeN(sortsegments); MEM_freeN(spart.totapixbuf); @@ -976,12 +976,12 @@ StrandSurface *cache_strand_surface(Render *re, ObjectRen *obr, DerivedMesh *dm, totvert= dm->getNumVerts(dm); totface= dm->getNumTessFaces(dm); - for(mesh=re->strandsurface.first; mesh; mesh=mesh->next) - if(mesh->obr.ob == obr->ob && mesh->obr.par == obr->par + for (mesh=re->strandsurface.first; mesh; mesh=mesh->next) + if (mesh->obr.ob == obr->ob && mesh->obr.par == obr->par && mesh->obr.index == obr->index && mesh->totvert==totvert && mesh->totface==totface) break; - if(!mesh) { + if (!mesh) { mesh= MEM_callocN(sizeof(StrandSurface), "StrandSurface"); mesh->obr= *obr; mesh->totvert= totvert; @@ -993,23 +993,23 @@ StrandSurface *cache_strand_surface(Render *re, ObjectRen *obr, DerivedMesh *dm, BLI_addtail(&re->strandsurface, mesh); } - if(timeoffset == -1 && !mesh->prevco) + if (timeoffset == -1 && !mesh->prevco) mesh->prevco= co= MEM_callocN(sizeof(float)*3*mesh->totvert, "StrandSurfCo"); - else if(timeoffset == 0 && !mesh->co) + else if (timeoffset == 0 && !mesh->co) mesh->co= co= MEM_callocN(sizeof(float)*3*mesh->totvert, "StrandSurfCo"); - else if(timeoffset == 1 && !mesh->nextco) + else if (timeoffset == 1 && !mesh->nextco) mesh->nextco= co= MEM_callocN(sizeof(float)*3*mesh->totvert, "StrandSurfCo"); else return mesh; mvert= dm->getVertArray(dm); - for(a=0; a<mesh->totvert; a++, mvert++) { + for (a=0; a<mesh->totvert; a++, mvert++) { copy_v3_v3(co[a], mvert->co); mul_m4_v3(mat, co[a]); } mface= dm->getTessFaceArray(dm); - for(a=0; a<mesh->totface; a++, mface++) { + for (a=0; a<mesh->totface; a++, mface++) { mesh->face[a][0]= mface->v1; mesh->face[a][1]= mface->v2; mesh->face[a][2]= mface->v3; @@ -1023,14 +1023,14 @@ void free_strand_surface(Render *re) { StrandSurface *mesh; - for(mesh=re->strandsurface.first; mesh; mesh=mesh->next) { - if(mesh->co) MEM_freeN(mesh->co); - if(mesh->prevco) MEM_freeN(mesh->prevco); - if(mesh->nextco) MEM_freeN(mesh->nextco); - if(mesh->ao) MEM_freeN(mesh->ao); - if(mesh->env) MEM_freeN(mesh->env); - if(mesh->indirect) MEM_freeN(mesh->indirect); - if(mesh->face) MEM_freeN(mesh->face); + for (mesh=re->strandsurface.first; mesh; mesh=mesh->next) { + if (mesh->co) MEM_freeN(mesh->co); + if (mesh->prevco) MEM_freeN(mesh->prevco); + if (mesh->nextco) MEM_freeN(mesh->nextco); + if (mesh->ao) MEM_freeN(mesh->ao); + if (mesh->env) MEM_freeN(mesh->env); + if (mesh->indirect) MEM_freeN(mesh->indirect); + if (mesh->face) MEM_freeN(mesh->face); } BLI_freelistN(&re->strandsurface); @@ -1042,11 +1042,11 @@ void strand_minmax(StrandRen *strand, float *min, float *max, float width) float vec[3], width2= 2.0f*width; int a; - for(a=0, svert=strand->vert; a<strand->totvert; a++, svert++) { + for (a=0, svert=strand->vert; a<strand->totvert; a++, svert++) { copy_v3_v3(vec, svert->co); DO_MINMAX(vec, min, max); - if(width!=0.0f) { + if (width!=0.0f) { vec[0]+= width; vec[1]+= width; vec[2]+= width; DO_MINMAX(vec, min, max); vec[0]-= width2; vec[1]-= width2; vec[2]-= width2; diff --git a/source/blender/render/intern/source/sunsky.c b/source/blender/render/intern/source/sunsky.c index 1ecf197f694..1fa18c4ebb4 100644 --- a/source/blender/render/intern/source/sunsky.c +++ b/source/blender/render/intern/source/sunsky.c @@ -273,7 +273,7 @@ void GetSkyXYZRadiance(struct SunSky* sunsky, float theta, float phi, float colo y = PerezFunction(sunsky, sunsky->perez_y, theta, gamma, sunsky->zenith_y); Y = 6.666666667e-5f * nfade * hfade * PerezFunction(sunsky, sunsky->perez_Y, theta, gamma, sunsky->zenith_Y); - if(sunsky->sky_exposure!=0.0f) + if (sunsky->sky_exposure!=0.0f) Y = 1.0 - exp(Y*sunsky->sky_exposure); X = (x / y) * Y; @@ -335,7 +335,7 @@ static void ComputeAttenuatedSunlight(float theta, int turbidity, float fTau[3]) m = 1.0f/(cosf(theta) + 0.15f*powf(93.885f-theta/(float)M_PI*180.0f,-1.253f)); - for(i = 0; i < 3; i++) + for (i = 0; i < 3; i++) { // Rayleigh Scattering fTauR = expf( -m * 0.008735f * powf(fLambda[i], (float)(-4.08f))); diff --git a/source/blender/render/intern/source/volume_precache.c b/source/blender/render/intern/source/volume_precache.c index f99eb0298bf..bd01c75ef3f 100644 --- a/source/blender/render/intern/source/volume_precache.c +++ b/source/blender/render/intern/source/volume_precache.c @@ -89,7 +89,8 @@ static int intersect_outside_volume(RayObject *tree, Isect *isect, float *offset isect->orig.ob= isect->hit.ob; return intersect_outside_volume(tree, isect, offset, limit-1, depth+1); - } else { + } + else { return depth; } } @@ -140,14 +141,14 @@ void global_bounds_obi(Render *re, ObjectInstanceRen *obi, float *bbmin, float * INIT_MINMAX(bbmin, bbmax); - for(a=0; a<obr->totvert; a++) { - if((a & 255)==0) ver= obr->vertnodes[a>>8].vert; + for (a=0; a<obr->totvert; a++) { + if ((a & 255)==0) ver= obr->vertnodes[a>>8].vert; else ver++; copy_v3_v3(co, ver->co); /* transformed object instance in camera space */ - if(obi->flag & R_TRANSFORMED) + if (obi->flag & R_TRANSFORMED) mul_m4_v3(obi->mat, co); /* convert to global space */ @@ -409,7 +410,7 @@ static void multiple_scattering_diffusion(Render *re, VolumePrecache *vp, Materi sb[j] += vp->data_b[i]; /* Displays progress every second */ - if(time-lasttime>1.0) { + if (time-lasttime>1.0) { char str[64]; BLI_snprintf(str, sizeof(str), "Simulating multiple scattering: %d%%", (int)(100.0f * (c / total))); re->i.infostr= str; @@ -446,7 +447,8 @@ static void multiple_scattering_diffusion(Render *re, VolumePrecache *vp, Materi /* conserve energy - half single, half multiple */ origf = 0.5f; fac *= 0.5f; - } else { + } + else { origf = 0.0f; } @@ -735,25 +737,25 @@ static void vol_precache_objectinstance_threads(Render *re, ObjectInstanceRen *o queue.done = BLI_thread_queue_init(); BLI_thread_queue_nowait(queue.work); - for(pa= re->volume_precache_parts.first; pa; pa= pa->next) + for (pa= re->volume_precache_parts.first; pa; pa= pa->next) BLI_thread_queue_push(queue.work, pa); /* launch threads */ BLI_init_threads(&threads, vol_precache_part, totthread); - for(thread= 0; thread<totthread; thread++) + for (thread= 0; thread<totthread; thread++) BLI_insert_thread(&threads, &queue); /* loop waiting for work to be done */ - while(counter < totparts) { - if(re->test_break && re->test_break(re->tbh)) + while (counter < totparts) { + if (re->test_break && re->test_break(re->tbh)) break; - if(BLI_thread_queue_pop_timeout(queue.done, 50)) + if (BLI_thread_queue_pop_timeout(queue.done, 50)) counter++; time= PIL_check_seconds_timer(); - if(time-lasttime>1.0) { + if (time-lasttime>1.0) { char str[64]; BLI_snprintf(str, sizeof(str), "Precaching volume: %d%%", (int)(100.0f * ((float)counter / (float)totparts))); re->i.infostr= str; @@ -769,7 +771,7 @@ static void vol_precache_objectinstance_threads(Render *re, ObjectInstanceRen *o BLI_thread_queue_free(queue.done); BLI_freelistN(&re->volume_precache_parts); - if(tree) { + if (tree) { //TODO: makeraytree_object creates a tree and saves it on OBI, if we free this tree we should also clear other pointers to it //RE_rayobject_free(tree); //tree= NULL; @@ -799,18 +801,18 @@ void volume_precache(Render *re) re->i.infostr= "Volume preprocessing"; re->stats_draw(re->sdh, &re->i); - for(vo= re->volumes.first; vo; vo= vo->next) { + for (vo= re->volumes.first; vo; vo= vo->next) { if (using_lightcache(vo->ma)) { - for(obi= re->instancetable.first; obi; obi= obi->next) { + for (obi= re->instancetable.first; obi; obi= obi->next) { if (obi->obr == vo->obr) { vol_precache_objectinstance_threads(re, obi, vo->ma); - if(re->test_break && re->test_break(re->tbh)) + if (re->test_break && re->test_break(re->tbh)) break; } } - if(re->test_break && re->test_break(re->tbh)) + if (re->test_break && re->test_break(re->tbh)) break; } } @@ -823,7 +825,7 @@ void free_volume_precache(Render *re) { ObjectInstanceRen *obi; - for(obi= re->instancetable.first; obi; obi= obi->next) { + for (obi= re->instancetable.first; obi; obi= obi->next) { if (obi->volume_precache != NULL) { MEM_freeN(obi->volume_precache->data_r); MEM_freeN(obi->volume_precache->data_g); diff --git a/source/blender/render/intern/source/volumetric.c b/source/blender/render/intern/source/volumetric.c index 17c4601264a..9c4afaea0fe 100644 --- a/source/blender/render/intern/source/volumetric.c +++ b/source/blender/render/intern/source/volumetric.c @@ -79,21 +79,23 @@ static float vol_get_shadow(ShadeInput *shi, LampRen *lar, const float co[3]) { float visibility = 1.f; - if(lar->shb) { + if (lar->shb) { float dxco[3]={0.f, 0.f, 0.f}, dyco[3]={0.f, 0.f, 0.f}; visibility = testshadowbuf(&R, lar->shb, co, dxco, dyco, 1.0, 0.0); - } else if (lar->mode & LA_SHAD_RAY) { + } + else if (lar->mode & LA_SHAD_RAY) { /* trace shadow manually, no good lamp api atm */ Isect is; copy_v3_v3(is.start, co); - if(lar->type==LA_SUN || lar->type==LA_HEMI) { + if (lar->type==LA_SUN || lar->type==LA_HEMI) { is.dir[0] = -lar->vec[0]; is.dir[1] = -lar->vec[1]; is.dir[2] = -lar->vec[2]; is.dist = R.maxdist; - } else { + } + else { sub_v3_v3v3(is.dir, lar->co, is.start); is.dist = normalize_v3( is.dir ); } @@ -102,7 +104,7 @@ static float vol_get_shadow(ShadeInput *shi, LampRen *lar, const float co[3]) is.check = RE_CHECK_VLR_NON_SOLID_MATERIAL; is.skip = 0; - if(lar->mode & (LA_LAYER|LA_LAYER_SHADOW)) + if (lar->mode & (LA_LAYER|LA_LAYER_SHADOW)) is.lay= lar->lay; else is.lay= -1; @@ -111,7 +113,7 @@ static float vol_get_shadow(ShadeInput *shi, LampRen *lar, const float co[3]) is.orig.face = NULL; is.last_hit = lar->last_hit[shi->thread]; - if(RE_rayobject_raycast(R.raytree,&is)) { + if (RE_rayobject_raycast(R.raytree,&is)) { visibility = 0.f; } @@ -142,7 +144,7 @@ static int vol_get_bounds(ShadeInput *shi, const float co[3], const float vec[3] isect->orig.ob = NULL; } - if(RE_rayobject_raycast(R.raytree, isect)) { + if (RE_rayobject_raycast(R.raytree, isect)) { hitco[0] = isect->start[0] + isect->dist*isect->dir[0]; hitco[1] = isect->start[1] + isect->dist*isect->dir[1]; hitco[2] = isect->start[2] + isect->dist*isect->dir[2]; @@ -203,9 +205,10 @@ static void vol_trace_behind(ShadeInput *shi, VlakRen *vlr, const float co[3], f isect.lay= -1; /* check to see if there's anything behind the volume, otherwise shade the sky */ - if(RE_rayobject_raycast(R.raytree, &isect)) { + if (RE_rayobject_raycast(R.raytree, &isect)) { shade_intersection(shi, col_r, &isect); - } else { + } + else { shadeSkyView(col_r, co, shi->view, NULL, shi->thread); shadeSunView(col_r, shi->view); } @@ -377,7 +380,8 @@ static float vol_get_phasefunc(ShadeInput *UNUSED(shi), float g, const float w[3 if (g == 0.f) { /* isotropic */ return normalize * 1.f; - } else { /* schlick */ + } + else { /* schlick */ const float k = 1.55f * g - .55f * g * g * g; const float kcostheta = k * dot_v3v3(w, wp); return normalize * (1.f - k*k) / ((1.f - kcostheta) * (1.f - kcostheta)); @@ -479,7 +483,7 @@ static void vol_shade_one_lamp(struct ShadeInput *shi, const float co[3], const copy_v3_v3(lacol, &lar->r); - if(lar->mode & LA_TEXTURE) { + if (lar->mode & LA_TEXTURE) { shi->osatex= 0; do_lamp_tex(lar, lv, shi, lacol, LA_TEXTURE); } @@ -517,7 +521,8 @@ static void vol_shade_one_lamp(struct ShadeInput *shi, const float co[3], const atten_co = hitco; else if ( lampdist < dist ) { atten_co = lar->co; - } else + } + else atten_co = hitco; vol_get_transmittance(shi, tr, co, atten_co); @@ -554,7 +559,7 @@ void vol_get_scattering(ShadeInput *shi, float scatter_col[3], const float co[3] zero_v3(scatter_col); lights= get_lights(shi); - for(go=lights->first; go; go= go->next) + for (go=lights->first; go; go= go->next) { float lacol[3] = {0.f, 0.f, 0.f}; lar= go->lampren; @@ -627,7 +632,8 @@ static void volumeintegrate(struct ShadeInput *shi, float col[4], const float co p2[2] = p[2] + (step_vec[2] * 0.5f); vol_get_precached_scattering(&R, shi, scatter_col, p2); - } else + } + else vol_get_scattering(shi, scatter_col, p, shi->view); radiance[0] += stepd * tr[0] * (emit_col[0] + scatter_col[0]); @@ -694,7 +700,8 @@ static void volume_trace(struct ShadeInput *shi, struct ShadeResult *shr, int in if (!ztransp) /* trace behind the volume object */ vol_trace_behind(shi, shi->vlr, endco, col); - } else { + } + else { /* we're tracing through the volume between the camera * and a solid surface, so use that pre-shaded radiance */ copy_v4_v4(col, shr->combined); @@ -716,7 +723,8 @@ static void volume_trace(struct ShadeInput *shi, struct ShadeResult *shr, int in if (vlr->mat == shi->mat) { /* trace behind the 2nd (raytrace) hit point */ vol_trace_behind(shi, (VlakRen *)is.hit.face, endco, col); - } else { + } + else { shade_intersection(shi, col, &is); } } diff --git a/source/blender/render/intern/source/voxeldata.c b/source/blender/render/intern/source/voxeldata.c index 6b625d1a59a..1f49b654ef8 100644 --- a/source/blender/render/intern/source/voxeldata.c +++ b/source/blender/render/intern/source/voxeldata.c @@ -83,15 +83,15 @@ static int load_frame_blendervoxel(VoxelData *vd, FILE *fp, int frame) const size_t size = vd_resol_size(vd); size_t offset = sizeof(VoxelDataHeader); - if(is_vd_res_ok(vd) == FALSE) + if (is_vd_res_ok(vd) == FALSE) return 0; vd->dataset = MEM_mapallocN(sizeof(float)*size, "voxel dataset"); - if(vd->dataset == NULL) return 0; + if (vd->dataset == NULL) return 0; - if(fseek(fp, frame*size*sizeof(float)+offset, 0) == -1) + if (fseek(fp, frame*size*sizeof(float)+offset, 0) == -1) return 0; - if(fread(vd->dataset, sizeof(float), size, fp) != size) + if (fread(vd->dataset, sizeof(float), size, fp) != size) return 0; vd->cachedframe = frame; @@ -105,25 +105,25 @@ static int load_frame_raw8(VoxelData *vd, FILE *fp, int frame) char *data_c; int i; - if(is_vd_res_ok(vd) == FALSE) + if (is_vd_res_ok(vd) == FALSE) return 0; vd->dataset = MEM_mapallocN(sizeof(float)*size, "voxel dataset"); - if(vd->dataset == NULL) return 0; + if (vd->dataset == NULL) return 0; data_c = (char *)MEM_mallocN(sizeof(char)*size, "temporary voxel file reading storage"); - if(data_c == NULL) { + if (data_c == NULL) { MEM_freeN(vd->dataset); vd->dataset= NULL; return 0; } - if(fseek(fp,(frame-1)*size*sizeof(char),0) == -1) { + if (fseek(fp,(frame-1)*size*sizeof(char),0) == -1) { MEM_freeN(data_c); MEM_freeN(vd->dataset); vd->dataset= NULL; return 0; } - if(fread(data_c, sizeof(char), size, fp) != size) { + if (fread(data_c, sizeof(char), size, fp) != size) { MEM_freeN(data_c); MEM_freeN(vd->dataset); vd->dataset= NULL; @@ -204,7 +204,7 @@ static int read_voxeldata_header(FILE *fp, struct VoxelData *vd) VoxelDataHeader *h=(VoxelDataHeader *)MEM_mallocN(sizeof(VoxelDataHeader), "voxel data header"); rewind(fp); - if(fread(h,sizeof(VoxelDataHeader),1,fp) != 1) { + if (fread(h,sizeof(VoxelDataHeader),1,fp) != 1) { MEM_freeN(h); return 0; } @@ -232,8 +232,8 @@ static void init_frame_smoke(VoxelData *vd, float cfra) SmokeModifierData *smd = (SmokeModifierData *)md; - if(smd->domain && smd->domain->fluid) { - if(cfra < smd->domain->point_cache[0]->startframe) + if (smd->domain && smd->domain->fluid) { + if (cfra < smd->domain->point_cache[0]->startframe) ; /* don't show smoke before simulation starts, this could be made an option in the future */ else if (vd->smoked_type == TEX_VD_SMOKEHEAT) { size_t totRes; @@ -284,7 +284,8 @@ static void init_frame_smoke(VoxelData *vd, float cfra) if (smd->domain->flags & MOD_SMOKE_HIGHRES) { smoke_turbulence_get_res(smd->domain->wt, vd->resol); density = smoke_turbulence_get_density(smd->domain->wt); - } else { + } + else { copy_v3_v3_int(vd->resol, smd->domain->res); density = smoke_get_density(smd->domain->fluid); } @@ -345,7 +346,7 @@ void cache_voxeldata(Tex *tex, int scene_frame) fp = BLI_fopen(path,"rb"); if (!fp) return; - if(read_voxeldata_header(fp, vd)) + if (read_voxeldata_header(fp, vd)) load_frame_blendervoxel(vd, fp, curframe-1); fclose(fp); @@ -371,7 +372,7 @@ void make_voxeldata(struct Render *re) /* XXX: should be doing only textures used in this render */ for (tex= re->main->tex.first; tex; tex= tex->id.next) { - if(tex->id.us && tex->type==TEX_VOXELDATA) { + if (tex->id.us && tex->type==TEX_VOXELDATA) { cache_voxeldata(tex, re->r.cfra); } } diff --git a/source/blender/render/intern/source/zbuf.c b/source/blender/render/intern/source/zbuf.c index 46520001d2d..e3068d12265 100644 --- a/source/blender/render/intern/source/zbuf.c +++ b/source/blender/render/intern/source/zbuf.c @@ -101,9 +101,9 @@ void zbuf_alloc_span(ZSpan *zspan, int rectx, int recty, float clipcrop) void zbuf_free_span(ZSpan *zspan) { - if(zspan) { - if(zspan->span1) MEM_freeN(zspan->span1); - if(zspan->span2) MEM_freeN(zspan->span2); + if (zspan) { + if (zspan->span1) MEM_freeN(zspan->span1); + if (zspan->span2) MEM_freeN(zspan->span2); zspan->span1= zspan->span2= NULL; } } @@ -122,7 +122,7 @@ static void zbuf_add_to_span(ZSpan *zspan, float *v1, float *v2) float xx1, dx0, xs0; int y, my0, my2; - if(v1[1]<v2[1]) { + if (v1[1]<v2[1]) { minv= v1; maxv= v2; } else { @@ -132,18 +132,18 @@ static void zbuf_add_to_span(ZSpan *zspan, float *v1, float *v2) my0= ceil(minv[1]); my2= floor(maxv[1]); - if(my2<0 || my0>= zspan->recty) return; + if (my2<0 || my0>= zspan->recty) return; /* clip top */ - if(my2>=zspan->recty) my2= zspan->recty-1; + if (my2>=zspan->recty) my2= zspan->recty-1; /* clip bottom */ - if(my0<0) my0= 0; + if (my0<0) my0= 0; - if(my0>my2) return; + if (my0>my2) return; /* if(my0>my2) should still fill in, that way we get spans that skip nicely */ xx1= maxv[1]-minv[1]; - if(xx1>FLT_EPSILON) { + if (xx1>FLT_EPSILON) { dx0= (minv[0]-maxv[0])/xx1; xs0= dx0*(minv[1]-my2) + minv[0]; } @@ -153,11 +153,11 @@ static void zbuf_add_to_span(ZSpan *zspan, float *v1, float *v2) } /* empty span */ - if(zspan->maxp1 == NULL) { + if (zspan->maxp1 == NULL) { span= zspan->span1; } else { /* does it complete left span? */ - if( maxv == zspan->minp1 || minv==zspan->maxp1) { + if ( maxv == zspan->minp1 || minv==zspan->maxp1) { span= zspan->span1; } else { @@ -165,30 +165,30 @@ static void zbuf_add_to_span(ZSpan *zspan, float *v1, float *v2) } } - if(span==zspan->span1) { + if (span==zspan->span1) { // printf("left span my0 %d my2 %d\n", my0, my2); - if(zspan->minp1==NULL || zspan->minp1[1] > minv[1] ) { + if (zspan->minp1==NULL || zspan->minp1[1] > minv[1] ) { zspan->minp1= minv; } - if(zspan->maxp1==NULL || zspan->maxp1[1] < maxv[1] ) { + if (zspan->maxp1==NULL || zspan->maxp1[1] < maxv[1] ) { zspan->maxp1= maxv; } - if(my0<zspan->miny1) zspan->miny1= my0; - if(my2>zspan->maxy1) zspan->maxy1= my2; + if (my0<zspan->miny1) zspan->miny1= my0; + if (my2>zspan->maxy1) zspan->maxy1= my2; } else { // printf("right span my0 %d my2 %d\n", my0, my2); - if(zspan->minp2==NULL || zspan->minp2[1] > minv[1] ) { + if (zspan->minp2==NULL || zspan->minp2[1] > minv[1] ) { zspan->minp2= minv; } - if(zspan->maxp2==NULL || zspan->maxp2[1] < maxv[1] ) { + if (zspan->maxp2==NULL || zspan->maxp2[1] < maxv[1] ) { zspan->maxp2= maxv; } - if(my0<zspan->miny2) zspan->miny2= my0; - if(my2>zspan->maxy2) zspan->maxy2= my2; + if (my0<zspan->miny2) zspan->miny2= my0; + if (my2>zspan->maxy2) zspan->maxy2= my2; } - for(y=my2; y>=my0; y--, xs0+= dx0) { + for (y=my2; y>=my0; y--, xs0+= dx0) { /* xs0 is the xcoord! */ span[y]= xs0; } @@ -204,7 +204,7 @@ void fillrect(int *rect, int x, int y, int val) len= x*y; drect= rect; - while(len>0) { + while (len>0) { len--; *drect= val; drect++; @@ -216,24 +216,24 @@ static short cliptestf(float a, float b, float c, float d, float *u1, float *u2) { float p= a + b, q= c + d, r; - if(p<0.0f) { - if(q<p) return 0; - else if(q<0.0f) { + if (p<0.0f) { + if (q<p) return 0; + else if (q<0.0f) { r= q/p; - if(r>*u2) return 0; - else if(r>*u1) *u1=r; + if (r>*u2) return 0; + else if (r>*u1) *u1=r; } } else { - if(p>0.0f) { - if(q<0.0f) return 0; - else if(q<p) { + if (p>0.0f) { + if (q<0.0f) return 0; + else if (q<p) { r= q/p; - if(r<*u1) return 0; - else if(r<*u2) *u2=r; + if (r<*u1) return 0; + else if (r<*u2) *u2=r; } } - else if(q<0.0f) return 0; + else if (q<0.0f) return 0; } return 1; } @@ -247,14 +247,14 @@ int testclip(const float v[4]) * prevents issues with vertices lying exact on borders */ abs4= fabsf(v[3]) + FLT_EPSILON; - if( v[0] < -abs4) c+=1; - else if( v[0] > abs4) c+=2; + if ( v[0] < -abs4) c+=1; + else if ( v[0] > abs4) c+=2; - if( v[1] > abs4) c+=4; - else if( v[1] < -abs4) c+=8; + if ( v[1] > abs4) c+=4; + else if ( v[1] < -abs4) c+=8; - if(v[2] < -abs4) c+=16; /* this used to be " if(v[2]<0) ", see clippz() */ - else if(v[2]> abs4) c+= 32; + if (v[2] < -abs4) c+=16; /* this used to be " if(v[2]<0) ", see clippz() */ + else if (v[2]> abs4) c+= 32; return c; } @@ -279,9 +279,9 @@ void freepsA(ListBase *lb) { APixstrMain *psm, *psmnext; - for(psm= lb->first; psm; psm= psmnext) { + for (psm= lb->first; psm; psm= psmnext) { psmnext= psm->next; - if(psm->ps) + if (psm->ps) MEM_freeN(psm->ps); MEM_freeN(psm); } @@ -290,7 +290,7 @@ void freepsA(ListBase *lb) static APixstr *addpsA(ZSpan *zspan) { /* make new PS */ - if(zspan->apsmcounter==0) { + if (zspan->apsmcounter==0) { zspan->curpstr= addpsmainA(zspan->apsmbase); zspan->apsmcounter= 4095; } @@ -317,7 +317,7 @@ static void zbuffillAc4(ZSpan *zspan, int obi, int zvlnr, float *v1, float *v2, /* set spans */ zbuf_add_to_span(zspan, v1, v2); zbuf_add_to_span(zspan, v2, v3); - if(v4) { + if (v4) { zbuf_add_to_span(zspan, v3, v4); zbuf_add_to_span(zspan, v4, v1); } @@ -325,12 +325,12 @@ static void zbuffillAc4(ZSpan *zspan, int obi, int zvlnr, float *v1, float *v2, zbuf_add_to_span(zspan, v3, v1); /* clipped */ - if(zspan->minp2==NULL || zspan->maxp2==NULL) return; + if (zspan->minp2==NULL || zspan->maxp2==NULL) return; - if(zspan->miny1 < zspan->miny2) my0= zspan->miny2; else my0= zspan->miny1; - if(zspan->maxy1 > zspan->maxy2) my2= zspan->maxy2; else my2= zspan->maxy1; + if (zspan->miny1 < zspan->miny2) my0= zspan->miny2; else my0= zspan->miny1; + if (zspan->maxy1 > zspan->maxy2) my2= zspan->maxy2; else my2= zspan->maxy1; - if(my2<my0) return; + if (my2<my0) return; /* ZBUF DX DY, in floats still */ x1= v1[0]- v2[0]; @@ -343,7 +343,7 @@ static void zbuffillAc4(ZSpan *zspan, int obi, int zvlnr, float *v1, float *v2, y0= z1*x2-x1*z2; z0= x1*y2-y1*x2; - if(z0==0.0f) return; + if (z0==0.0f) return; xx1= (x0*v1[0] + y0*v1[1])/z0 + v1[2]; @@ -360,7 +360,7 @@ static void zbuffillAc4(ZSpan *zspan, int obi, int zvlnr, float *v1, float *v2, /* correct span */ sn1= (my0 + my2)/2; - if(zspan->span1[sn1] < zspan->span2[sn1]) { + if (zspan->span1[sn1] < zspan->span2[sn1]) { span1= zspan->span1+my2; span2= zspan->span2+my2; } @@ -369,16 +369,16 @@ static void zbuffillAc4(ZSpan *zspan, int obi, int zvlnr, float *v1, float *v2, span2= zspan->span1+my2; } - for(y=my2; y>=my0; y--, span1--, span2--) { + for (y=my2; y>=my0; y--, span1--, span2--) { sn1= floor(*span1); sn2= floor(*span2); sn1++; - if(sn2>=rectx) sn2= rectx-1; - if(sn1<0) sn1= 0; + if (sn2>=rectx) sn2= rectx-1; + if (sn1<0) sn1= 0; - if(sn2>=sn1) { + if (sn2>=sn1) { int intzverg; zverg= (double)sn1*zxd + zy0; @@ -389,23 +389,23 @@ static void zbuffillAc4(ZSpan *zspan, int obi, int zvlnr, float *v1, float *v2, zverg-= zspan->polygon_offset; - while(x>=0) { + while (x>=0) { intzverg= (int)CLAMPIS(zverg, INT_MIN, INT_MAX); - if( intzverg < *rz) { - if(!zspan->rectmask || intzverg > *rm) { + if ( intzverg < *rz) { + if (!zspan->rectmask || intzverg > *rm) { apn= ap; - while(apn) { - if(apn->p[0]==0) {apn->obi[0]= obi; apn->p[0]= zvlnr; apn->z[0]= intzverg; apn->mask[0]= mask; break; } - if(apn->p[0]==zvlnr && apn->obi[0]==obi) {apn->mask[0]|= mask; break; } - if(apn->p[1]==0) {apn->obi[1]= obi; apn->p[1]= zvlnr; apn->z[1]= intzverg; apn->mask[1]= mask; break; } - if(apn->p[1]==zvlnr && apn->obi[1]==obi) {apn->mask[1]|= mask; break; } - if(apn->p[2]==0) {apn->obi[2]= obi; apn->p[2]= zvlnr; apn->z[2]= intzverg; apn->mask[2]= mask; break; } - if(apn->p[2]==zvlnr && apn->obi[2]==obi) {apn->mask[2]|= mask; break; } - if(apn->p[3]==0) {apn->obi[3]= obi; apn->p[3]= zvlnr; apn->z[3]= intzverg; apn->mask[3]= mask; break; } - if(apn->p[3]==zvlnr && apn->obi[3]==obi) {apn->mask[3]|= mask; break; } - if(apn->next==NULL) apn->next= addpsA(zspan); + while (apn) { + if (apn->p[0]==0) {apn->obi[0]= obi; apn->p[0]= zvlnr; apn->z[0]= intzverg; apn->mask[0]= mask; break; } + if (apn->p[0]==zvlnr && apn->obi[0]==obi) {apn->mask[0]|= mask; break; } + if (apn->p[1]==0) {apn->obi[1]= obi; apn->p[1]= zvlnr; apn->z[1]= intzverg; apn->mask[1]= mask; break; } + if (apn->p[1]==zvlnr && apn->obi[1]==obi) {apn->mask[1]|= mask; break; } + if (apn->p[2]==0) {apn->obi[2]= obi; apn->p[2]= zvlnr; apn->z[2]= intzverg; apn->mask[2]= mask; break; } + if (apn->p[2]==zvlnr && apn->obi[2]==obi) {apn->mask[2]|= mask; break; } + if (apn->p[3]==0) {apn->obi[3]= obi; apn->p[3]= zvlnr; apn->z[3]= intzverg; apn->mask[3]= mask; break; } + if (apn->p[3]==zvlnr && apn->obi[3]==obi) {apn->mask[3]|= mask; break; } + if (apn->next==NULL) apn->next= addpsA(zspan); apn= apn->next; } } @@ -441,10 +441,10 @@ static void zbuflineAc(ZSpan *zspan, int obi, int zvlnr, float *vec1, float *vec mask= zspan->mask; - if(fabs(dx) > fabs(dy)) { + if (fabs(dx) > fabs(dy)) { /* all lines from left to right */ - if(vec1[0]<vec2[0]) { + if (vec1[0]<vec2[0]) { copy_v3_v3(v1, vec1); copy_v3_v3(v2, vec2); } @@ -456,7 +456,7 @@ static void zbuflineAc(ZSpan *zspan, int obi, int zvlnr, float *vec1, float *vec start= floor(v1[0]); end= start+floor(dx); - if(end>=zspan->rectx) end= zspan->rectx-1; + if (end>=zspan->rectx) end= zspan->rectx-1; oldy= floor(v1[1]); dy/= dx; @@ -464,40 +464,40 @@ static void zbuflineAc(ZSpan *zspan, int obi, int zvlnr, float *vec1, float *vec vergz= v1[2]; vergz-= zspan->polygon_offset; dz= (v2[2]-v1[2])/dx; - if(vergz>0x50000000 && dz>0) maxtest= 1; // prevent overflow + if (vergz>0x50000000 && dz>0) maxtest= 1; // prevent overflow rectz= (int *)(zspan->arectz+zspan->rectx*(oldy) +start); rectmask= (int *)(zspan->rectmask+zspan->rectx*(oldy) +start); ap= (zspan->apixbuf+ zspan->rectx*(oldy) +start); - if(dy<0) ofs= -zspan->rectx; + if (dy<0) ofs= -zspan->rectx; else ofs= zspan->rectx; - for(x= start; x<=end; x++, rectz++, rectmask++, ap++) { + for (x= start; x<=end; x++, rectz++, rectmask++, ap++) { y= floor(v1[1]); - if(y!=oldy) { + if (y!=oldy) { oldy= y; rectz+= ofs; rectmask+= ofs; ap+= ofs; } - if(x>=0 && y>=0 && y<zspan->recty) { - if(vergz<*rectz) { - if(!zspan->rectmask || vergz>*rectmask) { + if (x>=0 && y>=0 && y<zspan->recty) { + if (vergz<*rectz) { + if (!zspan->rectmask || vergz>*rectmask) { apn= ap; - while(apn) { /* loop unrolled */ - if(apn->p[0]==0) {apn->obi[0]= obi; apn->p[0]= zvlnr; apn->z[0]= vergz; apn->mask[0]= mask; break; } - if(apn->p[0]==zvlnr && apn->obi[0]==obi) {apn->mask[0]|= mask; break; } - if(apn->p[1]==0) {apn->obi[1]= obi; apn->p[1]= zvlnr; apn->z[1]= vergz; apn->mask[1]= mask; break; } - if(apn->p[1]==zvlnr && apn->obi[1]==obi) {apn->mask[1]|= mask; break; } - if(apn->p[2]==0) {apn->obi[2]= obi; apn->p[2]= zvlnr; apn->z[2]= vergz; apn->mask[2]= mask; break; } - if(apn->p[2]==zvlnr && apn->obi[2]==obi) {apn->mask[2]|= mask; break; } - if(apn->p[3]==0) {apn->obi[3]= obi; apn->p[3]= zvlnr; apn->z[3]= vergz; apn->mask[3]= mask; break; } - if(apn->p[3]==zvlnr && apn->obi[3]==obi) {apn->mask[3]|= mask; break; } - if(apn->next==0) apn->next= addpsA(zspan); + while (apn) { /* loop unrolled */ + if (apn->p[0]==0) {apn->obi[0]= obi; apn->p[0]= zvlnr; apn->z[0]= vergz; apn->mask[0]= mask; break; } + if (apn->p[0]==zvlnr && apn->obi[0]==obi) {apn->mask[0]|= mask; break; } + if (apn->p[1]==0) {apn->obi[1]= obi; apn->p[1]= zvlnr; apn->z[1]= vergz; apn->mask[1]= mask; break; } + if (apn->p[1]==zvlnr && apn->obi[1]==obi) {apn->mask[1]|= mask; break; } + if (apn->p[2]==0) {apn->obi[2]= obi; apn->p[2]= zvlnr; apn->z[2]= vergz; apn->mask[2]= mask; break; } + if (apn->p[2]==zvlnr && apn->obi[2]==obi) {apn->mask[2]|= mask; break; } + if (apn->p[3]==0) {apn->obi[3]= obi; apn->p[3]= zvlnr; apn->z[3]= vergz; apn->mask[3]= mask; break; } + if (apn->p[3]==zvlnr && apn->obi[3]==obi) {apn->mask[3]|= mask; break; } + if (apn->next==0) apn->next= addpsA(zspan); apn= apn->next; } } @@ -505,14 +505,14 @@ static void zbuflineAc(ZSpan *zspan, int obi, int zvlnr, float *vec1, float *vec } v1[1]+= dy; - if(maxtest && (vergz > 0x7FFFFFF0 - dz)) vergz= 0x7FFFFFF0; + if (maxtest && (vergz > 0x7FFFFFF0 - dz)) vergz= 0x7FFFFFF0; else vergz+= dz; } } else { /* all lines from top to bottom */ - if(vec1[1]<vec2[1]) { + if (vec1[1]<vec2[1]) { copy_v3_v3(v1, vec1); copy_v3_v3(v2, vec2); } @@ -525,9 +525,9 @@ static void zbuflineAc(ZSpan *zspan, int obi, int zvlnr, float *vec1, float *vec start= floor(v1[1]); end= start+floor(dy); - if(start>=zspan->recty || end<0) return; + if (start>=zspan->recty || end<0) return; - if(end>=zspan->recty) end= zspan->recty-1; + if (end>=zspan->recty) end= zspan->recty-1; oldx= floor(v1[0]); dx/= dy; @@ -535,40 +535,40 @@ static void zbuflineAc(ZSpan *zspan, int obi, int zvlnr, float *vec1, float *vec vergz= v1[2]; vergz-= zspan->polygon_offset; dz= (v2[2]-v1[2])/dy; - if(vergz>0x50000000 && dz>0) maxtest= 1; // prevent overflow + if (vergz>0x50000000 && dz>0) maxtest= 1; // prevent overflow rectz= (int *)( zspan->arectz+ (start)*zspan->rectx+ oldx ); rectmask= (int *)( zspan->rectmask+ (start)*zspan->rectx+ oldx ); ap= (zspan->apixbuf+ zspan->rectx*(start) +oldx); - if(dx<0) ofs= -1; + if (dx<0) ofs= -1; else ofs= 1; - for(y= start; y<=end; y++, rectz+=zspan->rectx, rectmask+=zspan->rectx, ap+=zspan->rectx) { + for (y= start; y<=end; y++, rectz+=zspan->rectx, rectmask+=zspan->rectx, ap+=zspan->rectx) { x= floor(v1[0]); - if(x!=oldx) { + if (x!=oldx) { oldx= x; rectz+= ofs; rectmask+= ofs; ap+= ofs; } - if(x>=0 && y>=0 && x<zspan->rectx) { - if(vergz<*rectz) { - if(!zspan->rectmask || vergz>*rectmask) { + if (x>=0 && y>=0 && x<zspan->rectx) { + if (vergz<*rectz) { + if (!zspan->rectmask || vergz>*rectmask) { apn= ap; - while(apn) { /* loop unrolled */ - if(apn->p[0]==0) {apn->obi[0]= obi; apn->p[0]= zvlnr; apn->z[0]= vergz; apn->mask[0]= mask; break; } - if(apn->p[0]==zvlnr) {apn->mask[0]|= mask; break; } - if(apn->p[1]==0) {apn->obi[1]= obi; apn->p[1]= zvlnr; apn->z[1]= vergz; apn->mask[1]= mask; break; } - if(apn->p[1]==zvlnr) {apn->mask[1]|= mask; break; } - if(apn->p[2]==0) {apn->obi[2]= obi; apn->p[2]= zvlnr; apn->z[2]= vergz; apn->mask[2]= mask; break; } - if(apn->p[2]==zvlnr) {apn->mask[2]|= mask; break; } - if(apn->p[3]==0) {apn->obi[3]= obi; apn->p[3]= zvlnr; apn->z[3]= vergz; apn->mask[3]= mask; break; } - if(apn->p[3]==zvlnr) {apn->mask[3]|= mask; break; } - if(apn->next==0) apn->next= addpsA(zspan); + while (apn) { /* loop unrolled */ + if (apn->p[0]==0) {apn->obi[0]= obi; apn->p[0]= zvlnr; apn->z[0]= vergz; apn->mask[0]= mask; break; } + if (apn->p[0]==zvlnr) {apn->mask[0]|= mask; break; } + if (apn->p[1]==0) {apn->obi[1]= obi; apn->p[1]= zvlnr; apn->z[1]= vergz; apn->mask[1]= mask; break; } + if (apn->p[1]==zvlnr) {apn->mask[1]|= mask; break; } + if (apn->p[2]==0) {apn->obi[2]= obi; apn->p[2]= zvlnr; apn->z[2]= vergz; apn->mask[2]= mask; break; } + if (apn->p[2]==zvlnr) {apn->mask[2]|= mask; break; } + if (apn->p[3]==0) {apn->obi[3]= obi; apn->p[3]= zvlnr; apn->z[3]= vergz; apn->mask[3]= mask; break; } + if (apn->p[3]==zvlnr) {apn->mask[3]|= mask; break; } + if (apn->next==0) apn->next= addpsA(zspan); apn= apn->next; } } @@ -576,7 +576,7 @@ static void zbuflineAc(ZSpan *zspan, int obi, int zvlnr, float *vec1, float *vec } v1[0]+= dx; - if(maxtest && (vergz > 0x7FFFFFF0 - dz)) vergz= 0x7FFFFFF0; + if (maxtest && (vergz > 0x7FFFFFF0 - dz)) vergz= 0x7FFFFFF0; else vergz+= dz; } } @@ -595,10 +595,10 @@ static void zbufline(ZSpan *zspan, int obi, int zvlnr, float *vec1, float *vec2) dx= vec2[0]-vec1[0]; dy= vec2[1]-vec1[1]; - if(fabs(dx) > fabs(dy)) { + if (fabs(dx) > fabs(dy)) { /* all lines from left to right */ - if(vec1[0]<vec2[0]) { + if (vec1[0]<vec2[0]) { copy_v3_v3(v1, vec1); copy_v3_v3(v2, vec2); } @@ -610,27 +610,27 @@ static void zbufline(ZSpan *zspan, int obi, int zvlnr, float *vec1, float *vec2) start= floor(v1[0]); end= start+floor(dx); - if(end>=zspan->rectx) end= zspan->rectx-1; + if (end>=zspan->rectx) end= zspan->rectx-1; oldy= floor(v1[1]); dy/= dx; vergz= floor(v1[2]); dz= floor((v2[2]-v1[2])/dx); - if(vergz>0x50000000 && dz>0) maxtest= 1; // prevent overflow + if (vergz>0x50000000 && dz>0) maxtest= 1; // prevent overflow rectz= zspan->rectz + oldy*zspan->rectx+ start; rectp= zspan->rectp + oldy*zspan->rectx+ start; recto= zspan->recto + oldy*zspan->rectx+ start; rectmask= zspan->rectmask + oldy*zspan->rectx+ start; - if(dy<0) ofs= -zspan->rectx; + if (dy<0) ofs= -zspan->rectx; else ofs= zspan->rectx; - for(x= start; x<=end; x++, rectz++, rectp++, recto++, rectmask++) { + for (x= start; x<=end; x++, rectz++, rectp++, recto++, rectmask++) { y= floor(v1[1]); - if(y!=oldy) { + if (y!=oldy) { oldy= y; rectz+= ofs; rectp+= ofs; @@ -638,9 +638,9 @@ static void zbufline(ZSpan *zspan, int obi, int zvlnr, float *vec1, float *vec2) rectmask+= ofs; } - if(x>=0 && y>=0 && y<zspan->recty) { - if(vergz<*rectz) { - if(!zspan->rectmask || vergz>*rectmask) { + if (x>=0 && y>=0 && y<zspan->recty) { + if (vergz<*rectz) { + if (!zspan->rectmask || vergz>*rectmask) { *recto= obi; *rectz= vergz; *rectp= zvlnr; @@ -650,13 +650,13 @@ static void zbufline(ZSpan *zspan, int obi, int zvlnr, float *vec1, float *vec2) v1[1]+= dy; - if(maxtest && (vergz > 0x7FFFFFF0 - dz)) vergz= 0x7FFFFFF0; + if (maxtest && (vergz > 0x7FFFFFF0 - dz)) vergz= 0x7FFFFFF0; else vergz+= dz; } } else { /* all lines from top to bottom */ - if(vec1[1]<vec2[1]) { + if (vec1[1]<vec2[1]) { copy_v3_v3(v1, vec1); copy_v3_v3(v2, vec2); } @@ -669,27 +669,27 @@ static void zbufline(ZSpan *zspan, int obi, int zvlnr, float *vec1, float *vec2) start= floor(v1[1]); end= start+floor(dy); - if(end>=zspan->recty) end= zspan->recty-1; + if (end>=zspan->recty) end= zspan->recty-1; oldx= floor(v1[0]); dx/= dy; vergz= floor(v1[2]); dz= floor((v2[2]-v1[2])/dy); - if(vergz>0x50000000 && dz>0) maxtest= 1; // prevent overflow + if (vergz>0x50000000 && dz>0) maxtest= 1; // prevent overflow rectz= zspan->rectz + start*zspan->rectx+ oldx; rectp= zspan->rectp + start*zspan->rectx+ oldx; recto= zspan->recto + start*zspan->rectx+ oldx; rectmask= zspan->rectmask + start*zspan->rectx+ oldx; - if(dx<0) ofs= -1; + if (dx<0) ofs= -1; else ofs= 1; - for(y= start; y<=end; y++, rectz+=zspan->rectx, rectp+=zspan->rectx, recto+=zspan->rectx, rectmask+=zspan->rectx) { + for (y= start; y<=end; y++, rectz+=zspan->rectx, rectp+=zspan->rectx, recto+=zspan->rectx, rectmask+=zspan->rectx) { x= floor(v1[0]); - if(x!=oldx) { + if (x!=oldx) { oldx= x; rectz+= ofs; rectp+= ofs; @@ -697,9 +697,9 @@ static void zbufline(ZSpan *zspan, int obi, int zvlnr, float *vec1, float *vec2) rectmask+= ofs; } - if(x>=0 && y>=0 && x<zspan->rectx) { - if(vergz<*rectz) { - if(!zspan->rectmask || vergz>*rectmask) { + if (x>=0 && y>=0 && x<zspan->rectx) { + if (vergz<*rectz) { + if (!zspan->rectmask || vergz>*rectmask) { *rectz= vergz; *rectp= zvlnr; *recto= obi; @@ -708,7 +708,7 @@ static void zbufline(ZSpan *zspan, int obi, int zvlnr, float *vec1, float *vec2) } v1[0]+= dx; - if(maxtest && (vergz > 0x7FFFFFF0 - dz)) vergz= 0x7FFFFFF0; + if (maxtest && (vergz > 0x7FFFFFF0 - dz)) vergz= 0x7FFFFFF0; else vergz+= dz; } } @@ -725,10 +725,10 @@ static void zbufline_onlyZ(ZSpan *zspan, int UNUSED(obi), int UNUSED(zvlnr), flo dx= vec2[0]-vec1[0]; dy= vec2[1]-vec1[1]; - if(fabs(dx) > fabs(dy)) { + if (fabs(dx) > fabs(dy)) { /* all lines from left to right */ - if(vec1[0]<vec2[0]) { + if (vec1[0]<vec2[0]) { copy_v3_v3(v1, vec1); copy_v3_v3(v2, vec2); } @@ -740,51 +740,51 @@ static void zbufline_onlyZ(ZSpan *zspan, int UNUSED(obi), int UNUSED(zvlnr), flo start= floor(v1[0]); end= start+floor(dx); - if(end>=zspan->rectx) end= zspan->rectx-1; + if (end>=zspan->rectx) end= zspan->rectx-1; oldy= floor(v1[1]); dy/= dx; vergz= floor(v1[2]); dz= floor((v2[2]-v1[2])/dx); - if(vergz>0x50000000 && dz>0) maxtest= 1; // prevent overflow + if (vergz>0x50000000 && dz>0) maxtest= 1; // prevent overflow rectz= zspan->rectz + oldy*zspan->rectx+ start; - if(zspan->rectz1) + if (zspan->rectz1) rectz1= zspan->rectz1 + oldy*zspan->rectx+ start; - if(dy<0) ofs= -zspan->rectx; + if (dy<0) ofs= -zspan->rectx; else ofs= zspan->rectx; - for(x= start; x<=end; x++, rectz++) { + for (x= start; x<=end; x++, rectz++) { y= floor(v1[1]); - if(y!=oldy) { + if (y!=oldy) { oldy= y; rectz+= ofs; - if(rectz1) rectz1+= ofs; + if (rectz1) rectz1+= ofs; } - if(x>=0 && y>=0 && y<zspan->recty) { - if(vergz < *rectz) { - if(rectz1) *rectz1= *rectz; + if (x>=0 && y>=0 && y<zspan->recty) { + if (vergz < *rectz) { + if (rectz1) *rectz1= *rectz; *rectz= vergz; } - else if(rectz1 && vergz < *rectz1) + else if (rectz1 && vergz < *rectz1) *rectz1= vergz; } v1[1]+= dy; - if(maxtest && (vergz > 0x7FFFFFF0 - dz)) vergz= 0x7FFFFFF0; + if (maxtest && (vergz > 0x7FFFFFF0 - dz)) vergz= 0x7FFFFFF0; else vergz+= dz; - if(rectz1) rectz1++; + if (rectz1) rectz1++; } } else { /* all lines from top to bottom */ - if(vec1[1]<vec2[1]) { + if (vec1[1]<vec2[1]) { copy_v3_v3(v1, vec1); copy_v3_v3(v2, vec2); } @@ -797,45 +797,45 @@ static void zbufline_onlyZ(ZSpan *zspan, int UNUSED(obi), int UNUSED(zvlnr), flo start= floor(v1[1]); end= start+floor(dy); - if(end>=zspan->recty) end= zspan->recty-1; + if (end>=zspan->recty) end= zspan->recty-1; oldx= floor(v1[0]); dx/= dy; vergz= floor(v1[2]); dz= floor((v2[2]-v1[2])/dy); - if(vergz>0x50000000 && dz>0) maxtest= 1; // prevent overflow + if (vergz>0x50000000 && dz>0) maxtest= 1; // prevent overflow rectz= zspan->rectz + start*zspan->rectx+ oldx; - if(zspan->rectz1) + if (zspan->rectz1) rectz1= zspan->rectz1 + start*zspan->rectx+ oldx; - if(dx<0) ofs= -1; + if (dx<0) ofs= -1; else ofs= 1; - for(y= start; y<=end; y++, rectz+=zspan->rectx) { + for (y= start; y<=end; y++, rectz+=zspan->rectx) { x= floor(v1[0]); - if(x!=oldx) { + if (x!=oldx) { oldx= x; rectz+= ofs; - if(rectz1) rectz1+= ofs; + if (rectz1) rectz1+= ofs; } - if(x>=0 && y>=0 && x<zspan->rectx) { - if(vergz < *rectz) { - if(rectz1) *rectz1= *rectz; + if (x>=0 && y>=0 && x<zspan->rectx) { + if (vergz < *rectz) { + if (rectz1) *rectz1= *rectz; *rectz= vergz; } - else if(rectz1 && vergz < *rectz1) + else if (rectz1 && vergz < *rectz1) *rectz1= vergz; } v1[0]+= dx; - if(maxtest && (vergz > 0x7FFFFFF0 - dz)) vergz= 0x7FFFFFF0; + if (maxtest && (vergz > 0x7FFFFFF0 - dz)) vergz= 0x7FFFFFF0; else vergz+= dz; - if(rectz1) + if (rectz1) rectz1+=zspan->rectx; } } @@ -854,28 +854,28 @@ static int clipline(float v1[4], float v2[4]) /* return 0: do not draw */ * filled in with zbufwire correctly when rendering in parts. otherwise * you see line endings at edges... */ - if(cliptestf(-dz, -dw, v1[3], v1[2], &u1,&u2)) { - if(cliptestf(dz, -dw, v1[3], -v1[2], &u1,&u2)) { + if (cliptestf(-dz, -dw, v1[3], v1[2], &u1,&u2)) { + if (cliptestf(dz, -dw, v1[3], -v1[2], &u1,&u2)) { dx= v2[0]-v1[0]; dz= 1.01f*(v2[3]-v1[3]); v13= 1.01f*v1[3]; - if(cliptestf(-dx, -dz, v1[0], v13, &u1,&u2)) { - if(cliptestf(dx, -dz, v13, -v1[0], &u1,&u2)) { + if (cliptestf(-dx, -dz, v1[0], v13, &u1,&u2)) { + if (cliptestf(dx, -dz, v13, -v1[0], &u1,&u2)) { dy= v2[1]-v1[1]; - if(cliptestf(-dy, -dz, v1[1], v13, &u1,&u2)) { - if(cliptestf(dy, -dz, v13, -v1[1], &u1,&u2)) { + if (cliptestf(-dy, -dz, v1[1], v13, &u1,&u2)) { + if (cliptestf(dy, -dz, v13, -v1[1], &u1,&u2)) { - if(u2<1.0f) { + if (u2<1.0f) { v2[0]= v1[0]+u2*dx; v2[1]= v1[1]+u2*dy; v2[2]= v1[2]+u2*dz; v2[3]= v1[3]+u2*dw; } - if(u1>0.0f) { + if (u1>0.0f) { v1[0]= v1[0]+u1*dx; v1[1]= v1[1]+u1*dy; v1[2]= v1[2]+u1*dz; @@ -908,9 +908,9 @@ void zbufclipwire(ZSpan *zspan, int obi, int zvlnr, int ec, float *ho1, float *h int and, or; /* edgecode: 1= draw */ - if(ec==0) return; + if (ec==0) return; - if(ho4) { + if (ho4) { and= (c1 & c2 & c3 & c4); or= (c1 | c2 | c3 | c4); } @@ -919,44 +919,44 @@ void zbufclipwire(ZSpan *zspan, int obi, int zvlnr, int ec, float *ho1, float *h or= (c1 | c2 | c3); } - if(or) { /* not in the middle */ - if(and) { /* out completely */ + if (or) { /* not in the middle */ + if (and) { /* out completely */ return; } else { /* clipping */ - if(ec & ME_V1V2) { + if (ec & ME_V1V2) { copy_v4_v4(vez, ho1); copy_v4_v4(vez+4, ho2); - if( clipline(vez, vez+4)) { + if ( clipline(vez, vez+4)) { hoco_to_zco(zspan, vez, vez); hoco_to_zco(zspan, vez+4, vez+4); zspan->zbuflinefunc(zspan, obi, zvlnr, vez, vez+4); } } - if(ec & ME_V2V3) { + if (ec & ME_V2V3) { copy_v4_v4(vez, ho2); copy_v4_v4(vez+4, ho3); - if( clipline(vez, vez+4)) { + if ( clipline(vez, vez+4)) { hoco_to_zco(zspan, vez, vez); hoco_to_zco(zspan, vez+4, vez+4); zspan->zbuflinefunc(zspan, obi, zvlnr, vez, vez+4); } } - if(ho4) { - if(ec & ME_V3V4) { + if (ho4) { + if (ec & ME_V3V4) { copy_v4_v4(vez, ho3); copy_v4_v4(vez+4, ho4); - if( clipline(vez, vez+4)) { + if ( clipline(vez, vez+4)) { hoco_to_zco(zspan, vez, vez); hoco_to_zco(zspan, vez+4, vez+4); zspan->zbuflinefunc(zspan, obi, zvlnr, vez, vez+4); } } - if(ec & ME_V4V1) { + if (ec & ME_V4V1) { copy_v4_v4(vez, ho4); copy_v4_v4(vez+4, ho1); - if( clipline(vez, vez+4)) { + if ( clipline(vez, vez+4)) { hoco_to_zco(zspan, vez, vez); hoco_to_zco(zspan, vez+4, vez+4); zspan->zbuflinefunc(zspan, obi, zvlnr, vez, vez+4); @@ -964,10 +964,10 @@ void zbufclipwire(ZSpan *zspan, int obi, int zvlnr, int ec, float *ho1, float *h } } else { - if(ec & ME_V3V1) { + if (ec & ME_V3V1) { copy_v4_v4(vez, ho3); copy_v4_v4(vez+4, ho1); - if( clipline(vez, vez+4)) { + if ( clipline(vez, vez+4)) { hoco_to_zco(zspan, vez, vez); hoco_to_zco(zspan, vez+4, vez+4); zspan->zbuflinefunc(zspan, obi, zvlnr, vez, vez+4); @@ -982,18 +982,18 @@ void zbufclipwire(ZSpan *zspan, int obi, int zvlnr, int ec, float *ho1, float *h hoco_to_zco(zspan, vez, ho1); hoco_to_zco(zspan, vez+4, ho2); hoco_to_zco(zspan, vez+8, ho3); - if(ho4) { + if (ho4) { hoco_to_zco(zspan, vez+12, ho4); - if(ec & ME_V3V4) zspan->zbuflinefunc(zspan, obi, zvlnr, vez+8, vez+12); - if(ec & ME_V4V1) zspan->zbuflinefunc(zspan, obi, zvlnr, vez+12, vez); + if (ec & ME_V3V4) zspan->zbuflinefunc(zspan, obi, zvlnr, vez+8, vez+12); + if (ec & ME_V4V1) zspan->zbuflinefunc(zspan, obi, zvlnr, vez+12, vez); } else { - if(ec & ME_V3V1) zspan->zbuflinefunc(zspan, obi, zvlnr, vez+8, vez); + if (ec & ME_V3V1) zspan->zbuflinefunc(zspan, obi, zvlnr, vez+8, vez); } - if(ec & ME_V1V2) zspan->zbuflinefunc(zspan, obi, zvlnr, vez, vez+4); - if(ec & ME_V2V3) zspan->zbuflinefunc(zspan, obi, zvlnr, vez+4, vez+8); + if (ec & ME_V1V2) zspan->zbuflinefunc(zspan, obi, zvlnr, vez, vez+4); + if (ec & ME_V2V3) zspan->zbuflinefunc(zspan, obi, zvlnr, vez+4, vez+8); } @@ -1005,12 +1005,12 @@ void zbufsinglewire(ZSpan *zspan, int obi, int zvlnr, const float ho1[4], const c1= testclip(ho1); c2= testclip(ho2); - if(c1 | c2) { /* not in the middle */ - if(!(c1 & c2)) { /* not out completely */ + if (c1 | c2) { /* not in the middle */ + if (!(c1 & c2)) { /* not out completely */ copy_v4_v4(f1, ho1); copy_v4_v4(f2, ho2); - if(clipline(f1, f2)) { + if (clipline(f1, f2)) { hoco_to_zco(zspan, f1, f1); hoco_to_zco(zspan, f2, f2); zspan->zbuflinefunc(zspan, obi, zvlnr, f1, f2); @@ -1057,7 +1057,7 @@ static void zbuffillGLinv4(ZSpan *zspan, int obi, int zvlnr, float *v1, float *v /* set spans */ zbuf_add_to_span(zspan, v1, v2); zbuf_add_to_span(zspan, v2, v3); - if(v4) { + if (v4) { zbuf_add_to_span(zspan, v3, v4); zbuf_add_to_span(zspan, v4, v1); } @@ -1065,13 +1065,13 @@ static void zbuffillGLinv4(ZSpan *zspan, int obi, int zvlnr, float *v1, float *v zbuf_add_to_span(zspan, v3, v1); /* clipped */ - if(zspan->minp2==NULL || zspan->maxp2==NULL) return; + if (zspan->minp2==NULL || zspan->maxp2==NULL) return; - if(zspan->miny1 < zspan->miny2) my0= zspan->miny2; else my0= zspan->miny1; - if(zspan->maxy1 > zspan->maxy2) my2= zspan->maxy2; else my2= zspan->maxy1; + if (zspan->miny1 < zspan->miny2) my0= zspan->miny2; else my0= zspan->miny1; + if (zspan->maxy1 > zspan->maxy2) my2= zspan->maxy2; else my2= zspan->maxy1; // printf("my %d %d\n", my0, my2); - if(my2<my0) return; + if (my2<my0) return; /* ZBUF DX DY, in floats still */ @@ -1085,7 +1085,7 @@ static void zbuffillGLinv4(ZSpan *zspan, int obi, int zvlnr, float *v1, float *v y0= z1*x2-x1*z2; z0= x1*y2-y1*x2; - if(z0==0.0f) return; + if (z0==0.0f) return; xx1= (x0*v1[0] + y0*v1[1])/z0 + v1[2]; @@ -1102,7 +1102,7 @@ static void zbuffillGLinv4(ZSpan *zspan, int obi, int zvlnr, float *v1, float *v /* correct span */ sn1= (my0 + my2)/2; - if(zspan->span1[sn1] < zspan->span2[sn1]) { + if (zspan->span1[sn1] < zspan->span2[sn1]) { span1= zspan->span1+my2; span2= zspan->span2+my2; } @@ -1111,16 +1111,16 @@ static void zbuffillGLinv4(ZSpan *zspan, int obi, int zvlnr, float *v1, float *v span2= zspan->span1+my2; } - for(y=my2; y>=my0; y--, span1--, span2--) { + for (y=my2; y>=my0; y--, span1--, span2--) { sn1= floor(*span1); sn2= floor(*span2); sn1++; - if(sn2>=rectx) sn2= rectx-1; - if(sn1<0) sn1= 0; + if (sn2>=rectx) sn2= rectx-1; + if (sn1<0) sn1= 0; - if(sn2>=sn1) { + if (sn2>=sn1) { int intzverg; zverg= (double)sn1*zxd + zy0; @@ -1130,11 +1130,11 @@ static void zbuffillGLinv4(ZSpan *zspan, int obi, int zvlnr, float *v1, float *v rm= rectmaskofs+sn1; x= sn2-sn1; - while(x>=0) { + while (x>=0) { intzverg= (int)CLAMPIS(zverg, INT_MIN, INT_MAX); - if( intzverg > *rz || *rz==0x7FFFFFFF) { /* UNIQUE LINE: see comment above */ - if(!zspan->rectmask || intzverg > *rm) { + if ( intzverg > *rz || *rz==0x7FFFFFFF) { /* UNIQUE LINE: see comment above */ + if (!zspan->rectmask || intzverg > *rm) { *ro= obi; /* UNIQUE LINE: see comment above (order differs) */ *rz= intzverg; *rp= zvlnr; @@ -1179,7 +1179,7 @@ static void zbuffillGL4(ZSpan *zspan, int obi, int zvlnr, float *v1, float *v2, /* set spans */ zbuf_add_to_span(zspan, v1, v2); zbuf_add_to_span(zspan, v2, v3); - if(v4) { + if (v4) { zbuf_add_to_span(zspan, v3, v4); zbuf_add_to_span(zspan, v4, v1); } @@ -1187,13 +1187,13 @@ static void zbuffillGL4(ZSpan *zspan, int obi, int zvlnr, float *v1, float *v2, zbuf_add_to_span(zspan, v3, v1); /* clipped */ - if(zspan->minp2==NULL || zspan->maxp2==NULL) return; + if (zspan->minp2==NULL || zspan->maxp2==NULL) return; - if(zspan->miny1 < zspan->miny2) my0= zspan->miny2; else my0= zspan->miny1; - if(zspan->maxy1 > zspan->maxy2) my2= zspan->maxy2; else my2= zspan->maxy1; + if (zspan->miny1 < zspan->miny2) my0= zspan->miny2; else my0= zspan->miny1; + if (zspan->maxy1 > zspan->maxy2) my2= zspan->maxy2; else my2= zspan->maxy1; // printf("my %d %d\n", my0, my2); - if(my2<my0) return; + if (my2<my0) return; /* ZBUF DX DY, in floats still */ @@ -1207,7 +1207,7 @@ static void zbuffillGL4(ZSpan *zspan, int obi, int zvlnr, float *v1, float *v2, y0= z1*x2-x1*z2; z0= x1*y2-y1*x2; - if(z0==0.0f) return; + if (z0==0.0f) return; xx1= (x0*v1[0] + y0*v1[1])/z0 + v1[2]; @@ -1224,7 +1224,7 @@ static void zbuffillGL4(ZSpan *zspan, int obi, int zvlnr, float *v1, float *v2, /* correct span */ sn1= (my0 + my2)/2; - if(zspan->span1[sn1] < zspan->span2[sn1]) { + if (zspan->span1[sn1] < zspan->span2[sn1]) { span1= zspan->span1+my2; span2= zspan->span2+my2; } @@ -1233,16 +1233,16 @@ static void zbuffillGL4(ZSpan *zspan, int obi, int zvlnr, float *v1, float *v2, span2= zspan->span1+my2; } - for(y=my2; y>=my0; y--, span1--, span2--) { + for (y=my2; y>=my0; y--, span1--, span2--) { sn1= floor(*span1); sn2= floor(*span2); sn1++; - if(sn2>=rectx) sn2= rectx-1; - if(sn1<0) sn1= 0; + if (sn2>=rectx) sn2= rectx-1; + if (sn1<0) sn1= 0; - if(sn2>=sn1) { + if (sn2>=sn1) { int intzverg; zverg= (double)sn1*zxd + zy0; @@ -1252,11 +1252,11 @@ static void zbuffillGL4(ZSpan *zspan, int obi, int zvlnr, float *v1, float *v2, rm= rectmaskofs+sn1; x= sn2-sn1; - while(x>=0) { + while (x>=0) { intzverg= (int)CLAMPIS(zverg, INT_MIN, INT_MAX); - if(intzverg < *rz) { /* ONLY UNIQUE LINE: see comment above */ - if(!zspan->rectmask || intzverg > *rm) { + if (intzverg < *rz) { /* ONLY UNIQUE LINE: see comment above */ + if (!zspan->rectmask || intzverg > *rm) { *rz= intzverg; *rp= zvlnr; *ro= obi; /* UNIQUE LINE: see comment above (order differs) */ @@ -1306,7 +1306,7 @@ static void zbuffillGL_onlyZ(ZSpan *zspan, int UNUSED(obi), int UNUSED(zvlnr), f /* set spans */ zbuf_add_to_span(zspan, v1, v2); zbuf_add_to_span(zspan, v2, v3); - if(v4) { + if (v4) { zbuf_add_to_span(zspan, v3, v4); zbuf_add_to_span(zspan, v4, v1); } @@ -1314,13 +1314,13 @@ static void zbuffillGL_onlyZ(ZSpan *zspan, int UNUSED(obi), int UNUSED(zvlnr), f zbuf_add_to_span(zspan, v3, v1); /* clipped */ - if(zspan->minp2==NULL || zspan->maxp2==NULL) return; + if (zspan->minp2==NULL || zspan->maxp2==NULL) return; - if(zspan->miny1 < zspan->miny2) my0= zspan->miny2; else my0= zspan->miny1; - if(zspan->maxy1 > zspan->maxy2) my2= zspan->maxy2; else my2= zspan->maxy1; + if (zspan->miny1 < zspan->miny2) my0= zspan->miny2; else my0= zspan->miny1; + if (zspan->maxy1 > zspan->maxy2) my2= zspan->maxy2; else my2= zspan->maxy1; // printf("my %d %d\n", my0, my2); - if(my2<my0) return; + if (my2<my0) return; /* ZBUF DX DY, in floats still */ @@ -1334,7 +1334,7 @@ static void zbuffillGL_onlyZ(ZSpan *zspan, int UNUSED(obi), int UNUSED(zvlnr), f y0= z1*x2-x1*z2; z0= x1*y2-y1*x2; - if(z0==0.0f) return; + if (z0==0.0f) return; xx1= (x0*v1[0] + y0*v1[1])/z0 + v1[2]; @@ -1345,12 +1345,12 @@ static void zbuffillGL_onlyZ(ZSpan *zspan, int UNUSED(obi), int UNUSED(zvlnr), f /* start-offset in rect */ rectx= zspan->rectx; rectzofs= (zspan->rectz+rectx*my2); - if(zspan->rectz1) + if (zspan->rectz1) rectzofs1= (zspan->rectz1+rectx*my2); /* correct span */ sn1= (my0 + my2)/2; - if(zspan->span1[sn1] < zspan->span2[sn1]) { + if (zspan->span1[sn1] < zspan->span2[sn1]) { span1= zspan->span1+my2; span2= zspan->span2+my2; } @@ -1359,30 +1359,30 @@ static void zbuffillGL_onlyZ(ZSpan *zspan, int UNUSED(obi), int UNUSED(zvlnr), f span2= zspan->span1+my2; } - for(y=my2; y>=my0; y--, span1--, span2--) { + for (y=my2; y>=my0; y--, span1--, span2--) { sn1= floor(*span1); sn2= floor(*span2); sn1++; - if(sn2>=rectx) sn2= rectx-1; - if(sn1<0) sn1= 0; + if (sn2>=rectx) sn2= rectx-1; + if (sn1<0) sn1= 0; - if(sn2>=sn1) { + if (sn2>=sn1) { zverg= (double)sn1*zxd + zy0; rz= rectzofs+sn1; rz1= rectzofs1+sn1; x= sn2-sn1; - while(x>=0) { + while (x>=0) { int zvergi= (int)CLAMPIS(zverg, INT_MIN, INT_MAX); /* option: maintain two depth values, closest and 2nd closest */ - if(zvergi < *rz) { - if(rectzofs1) *rz1= *rz; + if (zvergi < *rz) { + if (rectzofs1) *rz1= *rz; *rz= zvergi; } - else if(rectzofs1 && zvergi < *rz1) + else if (rectzofs1 && zvergi < *rz1) *rz1= zvergi; zverg+= zxd; @@ -1395,7 +1395,7 @@ static void zbuffillGL_onlyZ(ZSpan *zspan, int UNUSED(obi), int UNUSED(zvlnr), f zy0-=zyd; rectzofs-= rectx; - if(rectzofs1) rectzofs1-= rectx; + if (rectzofs1) rectzofs1-= rectx; } } @@ -1416,13 +1416,13 @@ void zspan_scanconvert_strand(ZSpan *zspan, void *handle, float *v1, float *v2, zbuf_add_to_span(zspan, v3, v1); /* clipped */ - if(zspan->minp2==NULL || zspan->maxp2==NULL) return; + if (zspan->minp2==NULL || zspan->maxp2==NULL) return; - if(zspan->miny1 < zspan->miny2) my0= zspan->miny2; else my0= zspan->miny1; - if(zspan->maxy1 > zspan->maxy2) my2= zspan->maxy2; else my2= zspan->maxy1; + if (zspan->miny1 < zspan->miny2) my0= zspan->miny2; else my0= zspan->miny1; + if (zspan->maxy1 > zspan->maxy2) my2= zspan->maxy2; else my2= zspan->maxy1; // printf("my %d %d\n", my0, my2); - if(my2<my0) return; + if (my2<my0) return; /* ZBUF DX DY, in floats still */ x1= v1[0]- v2[0]; @@ -1436,7 +1436,7 @@ void zspan_scanconvert_strand(ZSpan *zspan, void *handle, float *v1, float *v2, y0= z1*x2-x1*z2; z0= x1*y2-y1*x2; - if(z0==0.0f) return; + if (z0==0.0f) return; xx1= (x0*v1[0] + y0*v1[1])/z0 + v1[2]; zxd= -(double)x0/(double)z0; @@ -1467,7 +1467,7 @@ void zspan_scanconvert_strand(ZSpan *zspan, void *handle, float *v1, float *v2, /* correct span */ sn1= (my0 + my2)/2; - if(zspan->span1[sn1] < zspan->span2[sn1]) { + if (zspan->span1[sn1] < zspan->span2[sn1]) { span1= zspan->span1+my2; span2= zspan->span2+my2; } @@ -1476,20 +1476,20 @@ void zspan_scanconvert_strand(ZSpan *zspan, void *handle, float *v1, float *v2, span2= zspan->span1+my2; } - for(y=my2; y>=my0; y--, span1--, span2--) { + for (y=my2; y>=my0; y--, span1--, span2--) { sn1= floor(*span1); sn2= floor(*span2); sn1++; - if(sn2>=rectx) sn2= rectx-1; - if(sn1<0) sn1= 0; + if (sn2>=rectx) sn2= rectx-1; + if (sn1<0) sn1= 0; u= (double)sn1*uxd + uy0; v= (double)sn1*vxd + vy0; z= (double)sn1*zxd + zy0; - for(x= sn1; x<=sn2; x++, u+=uxd, v+=vxd, z+=zxd) + for (x= sn1; x<=sn2; x++, u+=uxd, v+=vxd, z+=zxd) func(handle, x, y, u, v, z); uy0 -= uyd; @@ -1516,13 +1516,13 @@ void zspan_scanconvert(ZSpan *zspan, void *handle, float *v1, float *v2, float * zbuf_add_to_span(zspan, v3, v1); /* clipped */ - if(zspan->minp2==NULL || zspan->maxp2==NULL) return; + if (zspan->minp2==NULL || zspan->maxp2==NULL) return; - if(zspan->miny1 < zspan->miny2) my0= zspan->miny2; else my0= zspan->miny1; - if(zspan->maxy1 > zspan->maxy2) my2= zspan->maxy2; else my2= zspan->maxy1; + if (zspan->miny1 < zspan->miny2) my0= zspan->miny2; else my0= zspan->miny1; + if (zspan->maxy1 > zspan->maxy2) my2= zspan->maxy2; else my2= zspan->maxy1; // printf("my %d %d\n", my0, my2); - if(my2<my0) return; + if (my2<my0) return; /* ZBUF DX DY, in floats still */ x1= v1[0]- v2[0]; @@ -1537,7 +1537,7 @@ void zspan_scanconvert(ZSpan *zspan, void *handle, float *v1, float *v2, float * y0= z1*x2-x1*z2; z0= x1*y2-y1*x2; - if(z0==0.0f) return; + if (z0==0.0f) return; xx1= (x0*v1[0] + y0*v1[1])/z0 + 1.0f; uxd= -(double)x0/(double)z0; @@ -1557,7 +1557,7 @@ void zspan_scanconvert(ZSpan *zspan, void *handle, float *v1, float *v2, float * /* correct span */ sn1= (my0 + my2)/2; - if(zspan->span1[sn1] < zspan->span2[sn1]) { + if (zspan->span1[sn1] < zspan->span2[sn1]) { span1= zspan->span1+my2; span2= zspan->span2+my2; } @@ -1566,19 +1566,19 @@ void zspan_scanconvert(ZSpan *zspan, void *handle, float *v1, float *v2, float * span2= zspan->span1+my2; } - for(y=my2; y>=my0; y--, span1--, span2--) { + for (y=my2; y>=my0; y--, span1--, span2--) { sn1= floor(*span1); sn2= floor(*span2); sn1++; - if(sn2>=rectx) sn2= rectx-1; - if(sn1<0) sn1= 0; + if (sn2>=rectx) sn2= rectx-1; + if (sn1<0) sn1= 0; u= (double)sn1*uxd + uy0; v= (double)sn1*vxd + vy0; - for(x= sn1; x<=sn2; x++, u+=uxd, v+=vxd) + for (x= sn1; x<=sn2; x++, u+=uxd, v+=vxd) func(handle, x, y, u, v); uy0 -= uyd; @@ -1612,7 +1612,7 @@ static void clippyra(float *labda, float *v1, float *v2, int *b2, int *b3, int a da= v2[a]-v1[a]; /* prob; we clip slightly larger, osa renders add 2 pixels on edges, should become variable? */ /* or better; increase r.winx/y size, but thats quite a complex one. do it later */ - if(a==2) { + if (a==2) { dw= (v2[3]-v1[3]); v13= v1[3]; } @@ -1627,18 +1627,21 @@ static void clippyra(float *labda, float *v1, float *v2, int *b2, int *b3, int a * who would have thought that of L&B! */ - if(cliptestf(-da, -dw, v13, v1[a], &u1,&u2)) { - if(cliptestf(da, -dw, v13, -v1[a], &u1,&u2)) { + if (cliptestf(-da, -dw, v13, v1[a], &u1,&u2)) { + if (cliptestf(da, -dw, v13, -v1[a], &u1,&u2)) { *b3=1; - if(u2<1.0f) { + if (u2<1.0f) { labda[1]= u2; *b2=1; } else labda[1]=1.0; /* u2 */ - if(u1>0.0f) { - labda[0]= u1; - *b2=1; - } else labda[0]=0.0; + if (u1>0.0f) { + labda[0] = u1; + *b2 = 1; + } + else { + labda[0] = 0.0; + } } } } @@ -1665,8 +1668,8 @@ static void makevertpyra(float *vez, float *labda, float **trias, float *v1, flo l1= labda[0]; l2= labda[1]; - if(l1!= -1.0f) { - if(l1!= 0.0f) { + if (l1!= -1.0f) { + if (l1!= 0.0f) { adr= vez+4*(*clve); trias[*b1]=adr; (*clve)++; @@ -1679,8 +1682,8 @@ static void makevertpyra(float *vez, float *labda, float **trias, float *v1, flo (*b1)++; } - if(l2!= -1.0f) { - if(l2!= 1.0f) { + if (l2!= -1.0f) { + if (l2!= 1.0f) { adr= vez+4*(*clve); trias[*b1]=adr; (*clve)++; @@ -1740,11 +1743,11 @@ static void zbuf_project_cache_clear(ZbufProjectCache *cache, int size) { int i; - if(size > ZBUF_PROJECT_CACHE_SIZE) + if (size > ZBUF_PROJECT_CACHE_SIZE) size= ZBUF_PROJECT_CACHE_SIZE; memset(cache, 0, sizeof(ZbufProjectCache)*size); - for(i=0; i<size; i++) + for (i=0; i<size; i++) cache[i].index= -1; } @@ -1752,7 +1755,7 @@ static int zbuf_shadow_project(ZbufProjectCache *cache, int index, float winmat[ { int cindex= index & 255; - if(cache[cindex].index == index) { + if (cache[cindex].index == index) { copy_v4_v4(ho, cache[cindex].ho); return cache[cindex].clip; } @@ -1782,7 +1785,7 @@ static int zbuf_part_project(ZbufProjectCache *cache, int index, float winmat[][ float vec[3]; int cindex= index & 255; - if(cache[cindex].index == index) { + if (cache[cindex].index == index) { copy_v4_v4(ho, cache[cindex].ho); return cache[cindex].clip; } @@ -1793,10 +1796,10 @@ static int zbuf_part_project(ZbufProjectCache *cache, int index, float winmat[][ projectvert(co, winmat, ho); wco= ho[3]; - if(ho[0] < bounds[0]*wco) clipflag |= 1; - else if(ho[0] > bounds[1]*wco) clipflag |= 2; - if(ho[1] > bounds[3]*wco) clipflag |= 4; - else if(ho[1] < bounds[2]*wco) clipflag |= 8; + if (ho[0] < bounds[0]*wco) clipflag |= 1; + else if (ho[0] > bounds[1]*wco) clipflag |= 2; + if (ho[1] > bounds[3]*wco) clipflag |= 4; + else if (ho[1] < bounds[2]*wco) clipflag |= 8; copy_v4_v4(cache[cindex].ho, ho); cache[cindex].clip= clipflag; @@ -1816,7 +1819,7 @@ void zbuf_render_project(float winmat[][4], const float co[3], float ho[4]) void zbuf_make_winmat(Render *re, float winmat[][4]) { - if(re->r.mode & R_PANORAMA) { + if (re->r.mode & R_PANORAMA) { float panomat[4][4]= MAT4_UNITY; panomat[0][0]= re->panoco; @@ -1837,10 +1840,11 @@ void zbufclip(ZSpan *zspan, int obi, int zvlnr, float *f1, float *f2, float *f3, float *vlzp[32][3], labda[3][2]; float vez[400], *trias[40]; - if(c1 | c2 | c3) { /* not in middle */ - if(c1 & c2 & c3) { /* completely out */ + if (c1 | c2 | c3) { /* not in middle */ + if (c1 & c2 & c3) { /* completely out */ return; - } else { /* clipping */ + } + else { /* clipping */ int arg, v, b, clipflag[3], b1, b2, b3, c4, clve=3, clvlo, clvl=1; vez[0]= f1[0]; vez[1]= f1[1]; vez[2]= f1[2]; vez[3]= f1[3]; @@ -1852,24 +1856,24 @@ void zbufclip(ZSpan *zspan, int obi, int zvlnr, float *f1, float *f2, float *f3, vlzp[0][2]= vez+8; clipflag[0]= ( (c1 & 48) | (c2 & 48) | (c3 & 48) ); - if(clipflag[0]==0) { /* othwerwise it needs to be calculated again, after the first (z) clip */ + if (clipflag[0]==0) { /* othwerwise it needs to be calculated again, after the first (z) clip */ clipflag[1]= ( (c1 & 3) | (c2 & 3) | (c3 & 3) ); clipflag[2]= ( (c1 & 12) | (c2 & 12) | (c3 & 12) ); } else clipflag[1]=clipflag[2]= 0; - for(b=0;b<3;b++) { + for (b=0;b<3;b++) { - if(clipflag[b]) { + if (clipflag[b]) { clvlo= clvl; - for(v=0; v<clvlo; v++) { + for (v=0; v<clvlo; v++) { - if(vlzp[v][0]!=NULL) { /* face is still there */ + if (vlzp[v][0]!=NULL) { /* face is still there */ b2= b3 =0; /* clip flags */ - if(b==0) arg= 2; + if (b==0) arg= 2; else if (b==1) arg= 0; else arg= 1; @@ -1877,27 +1881,29 @@ void zbufclip(ZSpan *zspan, int obi, int zvlnr, float *f1, float *f2, float *f3, clippyra(labda[1], vlzp[v][1],vlzp[v][2], &b2,&b3, arg, zspan->clipcrop); clippyra(labda[2], vlzp[v][2],vlzp[v][0], &b2,&b3, arg, zspan->clipcrop); - if(b2==0 && b3==1) { + if (b2==0 && b3==1) { /* completely 'in', but we copy because of last for() loop in this section */; vlzp[clvl][0]= vlzp[v][0]; vlzp[clvl][1]= vlzp[v][1]; vlzp[clvl][2]= vlzp[v][2]; vlzp[v][0]= NULL; clvl++; - } else if(b3==0) { + } + else if (b3==0) { vlzp[v][0]= NULL; /* completely 'out' */; - } else { + } + else { b1=0; makevertpyra(vez, labda[0], trias, vlzp[v][0],vlzp[v][1], &b1,&clve); makevertpyra(vez, labda[1], trias, vlzp[v][1],vlzp[v][2], &b1,&clve); makevertpyra(vez, labda[2], trias, vlzp[v][2],vlzp[v][0], &b1,&clve); /* after front clip done: now set clip flags */ - if(b==0) { + if (b==0) { clipflag[1]= clipflag[2]= 0; f1= vez; - for(b3=0; b3<clve; b3++) { + for (b3=0; b3<clve; b3++) { c4= testclip(f1); clipflag[1] |= (c4 & 3); clipflag[2] |= (c4 & 12); @@ -1906,8 +1912,8 @@ void zbufclip(ZSpan *zspan, int obi, int zvlnr, float *f1, float *f2, float *f3, } vlzp[v][0]= NULL; - if(b1>2) { - for(b3=3; b3<=b1; b3++) { + if (b1>2) { + for (b3=3; b3<=b1; b3++) { vlzp[clvl][0]= trias[0]; vlzp[clvl][1]= trias[b3-2]; vlzp[clvl][2]= trias[b3-1]; @@ -1921,16 +1927,16 @@ void zbufclip(ZSpan *zspan, int obi, int zvlnr, float *f1, float *f2, float *f3, } /* warning, this should never happen! */ - if(clve>38 || clvl>31) printf("clip overflow: clve clvl %d %d\n",clve,clvl); + if (clve>38 || clvl>31) printf("clip overflow: clve clvl %d %d\n",clve,clvl); /* perspective division */ f1=vez; - for(c1=0;c1<clve;c1++) { + for (c1=0;c1<clve;c1++) { hoco_to_zco(zspan, f1, f1); f1+=4; } - for(b=1;b<clvl;b++) { - if(vlzp[b][0]) { + for (b=1;b<clvl;b++) { + if (vlzp[b][0]) { zspan->zbuffunc(zspan, obi, zvlnr, vlzp[b][0],vlzp[b][1],vlzp[b][2], NULL); } } @@ -1949,10 +1955,11 @@ void zbufclip4(ZSpan *zspan, int obi, int zvlnr, float *f1, float *f2, float *f3 { float vez[16]; - if(c1 | c2 | c3 | c4) { /* not in middle */ - if(c1 & c2 & c3 & c4) { /* completely out */ + if (c1 | c2 | c3 | c4) { /* not in middle */ + if (c1 & c2 & c3 & c4) { /* completely out */ return; - } else { /* clipping */ + } + else { /* clipping */ zbufclip(zspan, obi, zvlnr, f1, f2, f3, c1, c2, c3); zbufclip(zspan, obi, zvlnr, f1, f3, f4, c1, c3, c4); } @@ -1970,7 +1977,7 @@ void zbufclip4(ZSpan *zspan, int obi, int zvlnr, float *f1, float *f2, float *f3 /* ************** ZMASK ******************************** */ -#define EXTEND_PIXEL(a) if(temprectp[a]) {z+= rectz[a]; tot++;} +#define EXTEND_PIXEL(a) if (temprectp[a]) {z+= rectz[a]; tot++;} /* changes the zbuffer to be ready for z-masking: applies an extend-filter, and then clears */ static void zmask_rect(int *rectz, int *rectp, int xs, int ys, int neg) @@ -1983,21 +1990,21 @@ static void zmask_rect(int *rectz, int *rectp, int xs, int ys, int neg) /* extend: if pixel is not filled in, we check surrounding pixels and average z value */ - for(y=1; y<=ys; y++) { + for (y=1; y<=ys; y++) { /* setup row indices */ row1= (y-2)*xs; row2= row1 + xs; row3= row2 + xs; - if(y==1) + if (y==1) row1= row2; - else if(y==ys) + else if (y==ys) row3= row2; curp= rectp + (y-1)*xs; curz= rectz + (y-1)*xs; - for(x=0; x<xs; x++, curp++, curz++) { - if(curp[0]==0) { + for (x=0; x<xs; x++, curp++, curz++) { + if (curp[0]==0) { int tot= 0; float z= 0.0f; @@ -2006,19 +2013,19 @@ static void zmask_rect(int *rectz, int *rectp, int xs, int ys, int neg) EXTEND_PIXEL(row3); EXTEND_PIXEL(row1 + 1); EXTEND_PIXEL(row3 + 1); - if(x!=xs-1) { + if (x!=xs-1) { EXTEND_PIXEL(row1 + 2); EXTEND_PIXEL(row2 + 2); EXTEND_PIXEL(row3 + 2); } - if(tot) { + if (tot) { len++; curz[0]= (int)(z/(float)tot); curp[0]= -1; /* env */ } } - if(x!=0) { + if (x!=0) { row1++; row2++; row3++; } } @@ -2026,11 +2033,11 @@ static void zmask_rect(int *rectz, int *rectp, int xs, int ys, int neg) MEM_freeN(temprectp); - if(neg); /* z values for negative are already correct */ + if (neg); /* z values for negative are already correct */ else { /* clear not filled z values */ - for(len= xs*ys -1; len>=0; len--) { - if(rectp[len]==0) { + for (len= xs*ys -1; len>=0; len--) { + if (rectp[len]==0) { rectz[len] = -0x7FFFFFFF; rectp[len]= -1; /* env code */ } @@ -2065,7 +2072,7 @@ void zbuffer_solid(RenderPart *pa, RenderLayer *rl, void(*fillfunc)(RenderPart*, samples= (R.osa? R.osa: 1); samples= MIN2(4, samples-pa->sample); - for(zsample=0; zsample<samples; zsample++) { + for (zsample=0; zsample<samples; zsample++) { zspan= &zspans[zsample]; zbuffer_part_bounds(R.winx, R.winy, pa, bounds); @@ -2075,11 +2082,11 @@ void zbuffer_solid(RenderPart *pa, RenderLayer *rl, void(*fillfunc)(RenderPart*, zspan->zmulx= ((float)R.winx)/2.0f; zspan->zmuly= ((float)R.winy)/2.0f; - if(R.osa) { + if (R.osa) { zspan->zofsx= -pa->disprect.xmin - R.jit[pa->sample+zsample][0]; zspan->zofsy= -pa->disprect.ymin - R.jit[pa->sample+zsample][1]; } - else if(R.i.curblur) { + else if (R.i.curblur) { zspan->zofsx= -pa->disprect.xmin - R.mblur_jit[R.i.curblur-1][0]; zspan->zofsy= -pa->disprect.ymin - R.mblur_jit[R.i.curblur-1][1]; } @@ -2092,11 +2099,11 @@ void zbuffer_solid(RenderPart *pa, RenderLayer *rl, void(*fillfunc)(RenderPart*, zspan->zofsy -= 0.5f; /* the buffers */ - if(zsample == samples-1) { + if (zsample == samples-1) { zspan->rectp= pa->rectp; zspan->recto= pa->recto; - if(neg_zmask) + if (neg_zmask) zspan->rectz= pa->rectmask; else zspan->rectz= pa->rectz; @@ -2113,17 +2120,17 @@ void zbuffer_solid(RenderPart *pa, RenderLayer *rl, void(*fillfunc)(RenderPart*, } /* in case zmask we fill Z for objects in lay_zmask first, then clear Z, and then do normal zbuffering */ - if(rl->layflag & SCE_LAY_ZMASK) + if (rl->layflag & SCE_LAY_ZMASK) zmaskpass= 1; - for(; zmaskpass >=0; zmaskpass--) { + for (; zmaskpass >=0; zmaskpass--) { ma= NULL; /* filling methods */ - for(zsample=0; zsample<samples; zsample++) { + for (zsample=0; zsample<samples; zsample++) { zspan= &zspans[zsample]; - if(zmaskpass && neg_zmask) + if (zmaskpass && neg_zmask) zspan->zbuffunc= zbuffillGLinv4; else zspan->zbuffunc= zbuffillGL4; @@ -2131,48 +2138,48 @@ void zbuffer_solid(RenderPart *pa, RenderLayer *rl, void(*fillfunc)(RenderPart*, } /* regular zbuffering loop, does all sample buffers */ - for(i=0, obi=R.instancetable.first; obi; i++, obi=obi->next) { + for (i=0, obi=R.instancetable.first; obi; i++, obi=obi->next) { obr= obi->obr; /* continue happens in 2 different ways... zmaskpass only does lay_zmask stuff */ - if(zmaskpass) { - if((obi->lay & lay_zmask)==0) + if (zmaskpass) { + if ((obi->lay & lay_zmask)==0) continue; } - else if(!all_z && !(obi->lay & (lay|lay_zmask))) + else if (!all_z && !(obi->lay & (lay|lay_zmask))) continue; - if(obi->flag & R_TRANSFORMED) + if (obi->flag & R_TRANSFORMED) mult_m4_m4m4(obwinmat, winmat, obi->mat); else copy_m4_m4(obwinmat, winmat); - if(clip_render_object(obi->obr->boundbox, bounds, obwinmat)) + if (clip_render_object(obi->obr->boundbox, bounds, obwinmat)) continue; zbuf_project_cache_clear(cache, obr->totvert); - for(v=0; v<obr->totvlak; v++) { - if((v & 255)==0) vlr= obr->vlaknodes[v>>8].vlak; + for (v=0; v<obr->totvlak; v++) { + if ((v & 255)==0) vlr= obr->vlaknodes[v>>8].vlak; else vlr++; /* the cases: visible for render, only z values, zmask, nothing */ - if(obi->lay & lay) { - if(vlr->mat!=ma) { + if (obi->lay & lay) { + if (vlr->mat!=ma) { ma= vlr->mat; nofill= (ma->mode & MA_ONLYCAST) || ((ma->mode & MA_TRANSP) && (ma->mode & MA_ZTRANSP)); env= (ma->mode & MA_ENV); wire= (ma->material_type == MA_TYPE_WIRE); - for(zsample=0; zsample<samples; zsample++) { - if(ma->mode & MA_ZINV || (zmaskpass && neg_zmask)) + for (zsample=0; zsample<samples; zsample++) { + if (ma->mode & MA_ZINV || (zmaskpass && neg_zmask)) zspans[zsample].zbuffunc= zbuffillGLinv4; else zspans[zsample].zbuffunc= zbuffillGL4; } } } - else if(all_z || (obi->lay & lay_zmask)) { + else if (all_z || (obi->lay & lay_zmask)) { env= 1; nofill= 0; ma= NULL; @@ -2182,7 +2189,7 @@ void zbuffer_solid(RenderPart *pa, RenderLayer *rl, void(*fillfunc)(RenderPart*, ma= NULL; /* otherwise nofill can hang */ } - if(!(vlr->flag & R_HIDDEN) && nofill==0) { + if (!(vlr->flag & R_HIDDEN) && nofill==0) { unsigned short partclip; v1= vlr->v1; @@ -2196,39 +2203,39 @@ void zbuffer_solid(RenderPart *pa, RenderLayer *rl, void(*fillfunc)(RenderPart*, /* partclipping doesn't need viewplane clipping */ partclip= c1 & c2 & c3; - if(v4) { + if (v4) { c4= zbuf_part_project(cache, v4->index, obwinmat, bounds, v4->co, ho4); partclip &= c4; } - if(partclip==0) { + if (partclip==0) { - if(env) zvlnr= -1; + if (env) zvlnr= -1; else zvlnr= v+1; c1= testclip(ho1); c2= testclip(ho2); c3= testclip(ho3); - if(v4) + if (v4) c4= testclip(ho4); - for(zsample=0; zsample<samples; zsample++) { + for (zsample=0; zsample<samples; zsample++) { zspan= &zspans[zsample]; - if(wire) { - if(v4) + if (wire) { + if (v4) zbufclipwire(zspan, i, zvlnr, vlr->ec, ho1, ho2, ho3, ho4, c1, c2, c3, c4); else zbufclipwire(zspan, i, zvlnr, vlr->ec, ho1, ho2, ho3, 0, c1, c2, c3, 0); } else { /* strands allow to be filled in as quad */ - if(v4 && (vlr->flag & R_STRAND)) { + if (v4 && (vlr->flag & R_STRAND)) { zbufclip4(zspan, i, zvlnr, ho1, ho2, ho3, ho4, c1, c2, c3, c4); } else { zbufclip(zspan, i, zvlnr, ho1, ho2, ho3, c1, c2, c3); - if(v4) + if (v4) zbufclip(zspan, i, (env)? zvlnr: zvlnr+RE_QUAD_OFFS, ho1, ho3, ho4, c1, c3, c4); } } @@ -2239,13 +2246,13 @@ void zbuffer_solid(RenderPart *pa, RenderLayer *rl, void(*fillfunc)(RenderPart*, } /* clear all z to close value, so it works as mask for next passes (ztra+strand) */ - if(zmaskpass) { - for(zsample=0; zsample<samples; zsample++) { + if (zmaskpass) { + for (zsample=0; zsample<samples; zsample++) { zspan= &zspans[zsample]; - if(neg_zmask) { + if (neg_zmask) { zspan->rectmask= zspan->rectz; - if(zsample == samples-1) + if (zsample == samples-1) zspan->rectz= pa->rectz; else zspan->rectz= MEM_mallocN(sizeof(int)*pa->rectx*pa->recty, "rectz"); @@ -2259,17 +2266,17 @@ void zbuffer_solid(RenderPart *pa, RenderLayer *rl, void(*fillfunc)(RenderPart*, } } - for(zsample=0; zsample<samples; zsample++) { + for (zsample=0; zsample<samples; zsample++) { zspan= &zspans[zsample]; - if(fillfunc) + if (fillfunc) fillfunc(pa, zspan, pa->sample+zsample, data); - if(zsample != samples-1) { + if (zsample != samples-1) { MEM_freeN(zspan->rectz); MEM_freeN(zspan->rectp); MEM_freeN(zspan->recto); - if(zspan->rectmask) + if (zspan->rectmask) MEM_freeN(zspan->rectmask); } @@ -2292,7 +2299,7 @@ void zbuffer_shadow(Render *re, float winmat[][4], LampRen *lar, int *rectz, int float obwinmat[4][4], ho1[4], ho2[4], ho3[4], ho4[4]; int a, b, c, i, c1, c2, c3, c4, ok=1, lay= -1; - if(lar->mode & (LA_LAYER|LA_LAYER_SHADOW)) lay= lar->lay; + if (lar->mode & (LA_LAYER|LA_LAYER_SHADOW)) lay= lar->lay; /* 1.0f for clipping in clippyra()... bad stuff actually */ zbuf_alloc_span(&zspan, size, size, 1.0f); @@ -2305,7 +2312,7 @@ void zbuffer_shadow(Render *re, float winmat[][4], LampRen *lar, int *rectz, int /* the buffers */ zspan.rectz= rectz; fillrect(rectz, size, size, 0x7FFFFFFE); - if(lar->buftype==LA_SHADBUF_HALFWAY) { + if (lar->buftype==LA_SHADBUF_HALFWAY) { zspan.rectz1= MEM_mallocN(size*size*sizeof(int), "seconday z buffer"); fillrect(zspan.rectz1, size, size, 0x7FFFFFFE); } @@ -2314,44 +2321,44 @@ void zbuffer_shadow(Render *re, float winmat[][4], LampRen *lar, int *rectz, int zspan.zbuflinefunc= zbufline_onlyZ; zspan.zbuffunc= zbuffillGL_onlyZ; - for(i=0, obi=re->instancetable.first; obi; i++, obi=obi->next) { + for (i=0, obi=re->instancetable.first; obi; i++, obi=obi->next) { obr= obi->obr; - if(obr->ob==re->excludeob) + if (obr->ob==re->excludeob) continue; - else if(!(obi->lay & lay)) + else if (!(obi->lay & lay)) continue; - if(obi->flag & R_TRANSFORMED) + if (obi->flag & R_TRANSFORMED) mult_m4_m4m4(obwinmat, winmat, obi->mat); else copy_m4_m4(obwinmat, winmat); - if(clip_render_object(obi->obr->boundbox, NULL, obwinmat)) + if (clip_render_object(obi->obr->boundbox, NULL, obwinmat)) continue; zbuf_project_cache_clear(cache, obr->totvert); /* faces */ - for(a=0; a<obr->totvlak; a++) { + for (a=0; a<obr->totvlak; a++) { - if((a & 255)==0) vlr= obr->vlaknodes[a>>8].vlak; + if ((a & 255)==0) vlr= obr->vlaknodes[a>>8].vlak; else vlr++; /* note, these conditions are copied in shadowbuf_autoclip() */ - if(vlr->mat!= ma) { + if (vlr->mat!= ma) { ma= vlr->mat; ok= 1; - if((ma->mode & MA_SHADBUF)==0) ok= 0; + if ((ma->mode & MA_SHADBUF)==0) ok= 0; } - if(ok && (obi->lay & lay) && !(vlr->flag & R_HIDDEN)) { + if (ok && (obi->lay & lay) && !(vlr->flag & R_HIDDEN)) { c1= zbuf_shadow_project(cache, vlr->v1->index, obwinmat, vlr->v1->co, ho1); c2= zbuf_shadow_project(cache, vlr->v2->index, obwinmat, vlr->v2->co, ho2); c3= zbuf_shadow_project(cache, vlr->v3->index, obwinmat, vlr->v3->co, ho3); - if((ma->material_type == MA_TYPE_WIRE) || (vlr->flag & R_STRAND)) { - if(vlr->v4) { + if ((ma->material_type == MA_TYPE_WIRE) || (vlr->flag & R_STRAND)) { + if (vlr->v4) { c4= zbuf_shadow_project(cache, vlr->v4->index, obwinmat, vlr->v4->co, ho4); zbufclipwire(&zspan, 0, a+1, vlr->ec, ho1, ho2, ho3, ho4, c1, c2, c3, c4); } @@ -2359,7 +2366,7 @@ void zbuffer_shadow(Render *re, float winmat[][4], LampRen *lar, int *rectz, int zbufclipwire(&zspan, 0, a+1, vlr->ec, ho1, ho2, ho3, 0, c1, c2, c3, 0); } else { - if(vlr->v4) { + if (vlr->v4) { c4= zbuf_shadow_project(cache, vlr->v4->index, obwinmat, vlr->v4->co, ho4); zbufclip4(&zspan, 0, 0, ho1, ho2, ho3, ho4, c1, c2, c3, c4); } @@ -2368,20 +2375,20 @@ void zbuffer_shadow(Render *re, float winmat[][4], LampRen *lar, int *rectz, int } } - if((a & 255)==255 && re->test_break(re->tbh)) + if ((a & 255)==255 && re->test_break(re->tbh)) break; } /* strands */ - if(obr->strandbuf) { + if (obr->strandbuf) { /* for each bounding box containing a number of strands */ sbound= obr->strandbuf->bound; - for(c=0; c<obr->strandbuf->totbound; c++, sbound++) { - if(clip_render_object(sbound->boundbox, NULL, obwinmat)) + for (c=0; c<obr->strandbuf->totbound; c++, sbound++) { + if (clip_render_object(sbound->boundbox, NULL, obwinmat)) continue; /* for each strand in this bounding box */ - for(a=sbound->start; a<sbound->end; a++) { + for (a=sbound->start; a<sbound->end; a++) { strand= RE_findOrAddStrand(obr, a); sseg.obi= obi; @@ -2392,16 +2399,16 @@ void zbuffer_shadow(Render *re, float winmat[][4], LampRen *lar, int *rectz, int svert= strand->vert; /* note, these conditions are copied in shadowbuf_autoclip() */ - if(sseg.buffer->ma!= ma) { + if (sseg.buffer->ma!= ma) { ma= sseg.buffer->ma; ok= 1; - if((ma->mode & MA_SHADBUF)==0) ok= 0; + if ((ma->mode & MA_SHADBUF)==0) ok= 0; } - if(ok && (sseg.buffer->lay & lay)) { + if (ok && (sseg.buffer->lay & lay)) { zbuf_project_cache_clear(cache, strand->totvert); - for(b=0; b<strand->totvert-1; b++, svert++) { + for (b=0; b<strand->totvert-1; b++, svert++) { sseg.v[0]= (b > 0)? (svert-1): svert; sseg.v[1]= svert; sseg.v[2]= svert+1; @@ -2412,24 +2419,24 @@ void zbuffer_shadow(Render *re, float winmat[][4], LampRen *lar, int *rectz, int c3= zbuf_shadow_project(cache, sseg.v[2]-strand->vert, obwinmat, sseg.v[2]->co, ho3); c4= zbuf_shadow_project(cache, sseg.v[3]-strand->vert, obwinmat, sseg.v[3]->co, ho4); - if(!(c1 & c2 & c3 & c4)) + if (!(c1 & c2 & c3 & c4)) render_strand_segment(re, winmat, NULL, &zspan, 1, &sseg); } } - if((a & 255)==255 && re->test_break(re->tbh)) + if ((a & 255)==255 && re->test_break(re->tbh)) break; } } } - if(re->test_break(re->tbh)) + if (re->test_break(re->tbh)) break; } /* merge buffers */ - if(lar->buftype==LA_SHADBUF_HALFWAY) { - for(a=size*size -1; a>=0; a--) + if (lar->buftype==LA_SHADBUF_HALFWAY) { + for (a=size*size -1; a>=0; a--) rectz[a]= (rectz[a]>>1) + (zspan.rectz1[a]>>1); MEM_freeN(zspan.rectz1); @@ -2449,7 +2456,7 @@ static void zbuffill_sss(ZSpan *zspan, int obi, int zvlnr, float *v1, float *v2, /* set spans */ zbuf_add_to_span(zspan, v1, v2); zbuf_add_to_span(zspan, v2, v3); - if(v4) { + if (v4) { zbuf_add_to_span(zspan, v3, v4); zbuf_add_to_span(zspan, v4, v1); } @@ -2457,12 +2464,12 @@ static void zbuffill_sss(ZSpan *zspan, int obi, int zvlnr, float *v1, float *v2, zbuf_add_to_span(zspan, v3, v1); /* clipped */ - if(zspan->minp2==NULL || zspan->maxp2==NULL) return; + if (zspan->minp2==NULL || zspan->maxp2==NULL) return; - if(zspan->miny1 < zspan->miny2) my0= zspan->miny2; else my0= zspan->miny1; - if(zspan->maxy1 > zspan->maxy2) my2= zspan->maxy2; else my2= zspan->maxy1; + if (zspan->miny1 < zspan->miny2) my0= zspan->miny2; else my0= zspan->miny1; + if (zspan->maxy1 > zspan->maxy2) my2= zspan->maxy2; else my2= zspan->maxy1; - if(my2<my0) return; + if (my2<my0) return; /* ZBUF DX DY, in floats still */ x1= v1[0]- v2[0]; @@ -2476,7 +2483,7 @@ static void zbuffill_sss(ZSpan *zspan, int obi, int zvlnr, float *v1, float *v2, y0= z1*x2-x1*z2; z0= x1*y2-y1*x2; - if(z0==0.0f) return; + if (z0==0.0f) return; xx1= (x0*v1[0] + y0*v1[1])/z0 + v1[2]; zxd= -(double)x0/(double)z0; @@ -2485,7 +2492,7 @@ static void zbuffill_sss(ZSpan *zspan, int obi, int zvlnr, float *v1, float *v2, /* correct span */ sn1= (my0 + my2)/2; - if(zspan->span1[sn1] < zspan->span2[sn1]) { + if (zspan->span1[sn1] < zspan->span2[sn1]) { span1= zspan->span1+my2; span2= zspan->span2+my2; } @@ -2494,17 +2501,17 @@ static void zbuffill_sss(ZSpan *zspan, int obi, int zvlnr, float *v1, float *v2, span2= zspan->span1+my2; } - for(y=my2; y>=my0; y--, span1--, span2--) { + for (y=my2; y>=my0; y--, span1--, span2--) { sn1= floor(*span1); sn2= floor(*span2); sn1++; - if(sn2>=rectx) sn2= rectx-1; - if(sn1<0) sn1= 0; + if (sn2>=rectx) sn2= rectx-1; + if (sn1<0) sn1= 0; z= (double)sn1*zxd + zy0; - for(x= sn1; x<=sn2; x++, z+=zxd) + for (x= sn1; x<=sn2; x++, z+=zxd) zspan->sss_func(zspan->sss_handle, obi, zvlnr, x, y, z); zy0 -= zyd; @@ -2544,41 +2551,41 @@ void zbuffer_sss(RenderPart *pa, unsigned int lay, void *handle, void (*func)(vo zspan.zbuffunc= zbuffill_sss; /* fill front and back zbuffer */ - if(pa->rectz) { + if (pa->rectz) { fillrect(pa->recto, pa->rectx, pa->recty, 0); fillrect(pa->rectp, pa->rectx, pa->recty, 0); fillrect(pa->rectz, pa->rectx, pa->recty, 0x7FFFFFFF); } - if(pa->rectbackz) { + if (pa->rectbackz) { fillrect(pa->rectbacko, pa->rectx, pa->recty, 0); fillrect(pa->rectbackp, pa->rectx, pa->recty, 0); fillrect(pa->rectbackz, pa->rectx, pa->recty, -0x7FFFFFFF); } - for(i=0, obi=R.instancetable.first; obi; i++, obi=obi->next) { + for (i=0, obi=R.instancetable.first; obi; i++, obi=obi->next) { obr= obi->obr; - if(!(obi->lay & lay)) + if (!(obi->lay & lay)) continue; - if(obi->flag & R_TRANSFORMED) + if (obi->flag & R_TRANSFORMED) mult_m4_m4m4(obwinmat, winmat, obi->mat); else copy_m4_m4(obwinmat, winmat); - if(clip_render_object(obi->obr->boundbox, bounds, obwinmat)) + if (clip_render_object(obi->obr->boundbox, bounds, obwinmat)) continue; zbuf_project_cache_clear(cache, obr->totvert); - for(v=0; v<obr->totvlak; v++) { - if((v & 255)==0) vlr= obr->vlaknodes[v>>8].vlak; + for (v=0; v<obr->totvlak; v++) { + if ((v & 255)==0) vlr= obr->vlaknodes[v>>8].vlak; else vlr++; - if(material_in_material(vlr->mat, sss_ma)) { + if (material_in_material(vlr->mat, sss_ma)) { /* three cases, visible for render, only z values and nothing */ - if(obi->lay & lay) { - if(vlr->mat!=ma) { + if (obi->lay & lay) { + if (vlr->mat!=ma) { ma= vlr->mat; nofill= ma->mode & MA_ONLYCAST; env= (ma->mode & MA_ENV); @@ -2590,7 +2597,7 @@ void zbuffer_sss(RenderPart *pa, unsigned int lay, void *handle, void (*func)(vo ma= NULL; /* otherwise nofill can hang */ } - if(nofill==0 && wire==0 && env==0) { + if (nofill==0 && wire==0 && env==0) { unsigned short partclip; v1= vlr->v1; @@ -2604,19 +2611,19 @@ void zbuffer_sss(RenderPart *pa, unsigned int lay, void *handle, void (*func)(vo /* partclipping doesn't need viewplane clipping */ partclip= c1 & c2 & c3; - if(v4) { + if (v4) { c4= zbuf_part_project(cache, v4->index, obwinmat, bounds, v4->co, ho4); partclip &= c4; } - if(partclip==0) { + if (partclip==0) { c1= testclip(ho1); c2= testclip(ho2); c3= testclip(ho3); zvlnr= v+1; zbufclip(&zspan, i, zvlnr, ho1, ho2, ho3, c1, c2, c3); - if(v4) { + if (v4) { c4= testclip(ho4); zbufclip(&zspan, i, zvlnr+RE_QUAD_OFFS, ho1, ho3, ho4, c1, c3, c4); } @@ -2658,13 +2665,13 @@ static void zbuf_fill_in_rgba(ZSpan *zspan, DrawBufPixel *col, float *v1, float zbuf_add_to_span(zspan, v4, v1); /* clipped */ - if(zspan->minp2==NULL || zspan->maxp2==NULL) return; + if (zspan->minp2==NULL || zspan->maxp2==NULL) return; - if(zspan->miny1 < zspan->miny2) my0= zspan->miny2; else my0= zspan->miny1; - if(zspan->maxy1 > zspan->maxy2) my2= zspan->maxy2; else my2= zspan->maxy1; + if (zspan->miny1 < zspan->miny2) my0= zspan->miny2; else my0= zspan->miny1; + if (zspan->maxy1 > zspan->maxy2) my2= zspan->maxy2; else my2= zspan->maxy1; // printf("my %d %d\n", my0, my2); - if(my2<my0) return; + if (my2<my0) return; /* ZBUF DX DY, in floats still */ x1= v1[0]- v2[0]; @@ -2677,7 +2684,7 @@ static void zbuf_fill_in_rgba(ZSpan *zspan, DrawBufPixel *col, float *v1, float y0= z1*x2-x1*z2; z0= x1*y2-y1*x2; - if(z0==0.0f) return; + if (z0==0.0f) return; xx1= (x0*v1[0] + y0*v1[1])/z0 + v1[2]; @@ -2692,7 +2699,7 @@ static void zbuf_fill_in_rgba(ZSpan *zspan, DrawBufPixel *col, float *v1, float /* correct span */ sn1= (my0 + my2)/2; - if(zspan->span1[sn1] < zspan->span2[sn1]) { + if (zspan->span1[sn1] < zspan->span2[sn1]) { span1= zspan->span1+my2; span2= zspan->span2+my2; } @@ -2701,23 +2708,23 @@ static void zbuf_fill_in_rgba(ZSpan *zspan, DrawBufPixel *col, float *v1, float span2= zspan->span1+my2; } - for(y=my2; y>=my0; y--, span1--, span2--) { + for (y=my2; y>=my0; y--, span1--, span2--) { sn1= floor(*span1); sn2= floor(*span2); sn1++; - if(sn2>=rectx) sn2= rectx-1; - if(sn1<0) sn1= 0; + if (sn2>=rectx) sn2= rectx-1; + if (sn1<0) sn1= 0; - if(sn2>=sn1) { + if (sn2>=sn1) { zverg= (double)sn1*zxd + zy0; rz= rectzofs+sn1; rp= rectpofs+sn1; x= sn2-sn1; - while(x>=0) { - if( zverg < *rz) { + while (x>=0) { + if ( zverg < *rz) { *rz= zverg; *rp= *col; } @@ -2743,14 +2750,14 @@ void antialias_tagbuf(int xsize, int ysize, char *rectmove) int a, x, y, step; /* 1: tag pixels to be candidate for AA */ - for(y=2; y<ysize; y++) { + for (y=2; y<ysize; y++) { /* setup rows */ row1= rectmove + (y-2)*xsize; row2= row1 + xsize; row3= row2 + xsize; - for(x=2; x<xsize; x++, row1++, row2++, row3++) { - if(row2[1]) { - if(row2[0]==0 || row2[2]==0 || row1[1]==0 || row3[1]==0) + for (x=2; x<xsize; x++, row1++, row2++, row3++) { + if (row2[1]) { + if (row2[0]==0 || row2[2]==0 || row1[1]==0 || row3[1]==0) row2[1]= 128; } } @@ -2758,22 +2765,22 @@ void antialias_tagbuf(int xsize, int ysize, char *rectmove) /* 2: evaluate horizontal scanlines and calculate alphas */ row1= rectmove; - for(y=0; y<ysize; y++) { + for (y=0; y<ysize; y++) { row1++; - for(x=1; x<xsize; x++, row1++) { - if(row1[0]==128 && row1[1]==128) { + for (x=1; x<xsize; x++, row1++) { + if (row1[0]==128 && row1[1]==128) { /* find previous color and next color and amount of steps to blend */ prev= row1[-1]; step= 1; - while(x+step<xsize && row1[step]==128) + while (x+step<xsize && row1[step]==128) step++; - if(x+step!=xsize) { + if (x+step!=xsize) { /* now we can blend values */ next= row1[step]; /* note, prev value can be next value, but we do this loop to clear 128 then */ - for(a=0; a<step; a++) { + for (a=0; a<step; a++) { int fac, mfac; fac= ((a+1)<<8)/(step+1); @@ -2788,22 +2795,22 @@ void antialias_tagbuf(int xsize, int ysize, char *rectmove) /* 3: evaluate vertical scanlines and calculate alphas */ /* use for reading a copy of the original tagged buffer */ - for(x=0; x<xsize; x++) { + for (x=0; x<xsize; x++) { row1= rectmove + x+xsize; - for(y=1; y<ysize; y++, row1+=xsize) { - if(row1[0]==128 && row1[xsize]==128) { + for (y=1; y<ysize; y++, row1+=xsize) { + if (row1[0]==128 && row1[xsize]==128) { /* find previous color and next color and amount of steps to blend */ prev= row1[-xsize]; step= 1; - while(y+step<ysize && row1[step*xsize]==128) + while (y+step<ysize && row1[step*xsize]==128) step++; - if(y+step!=ysize) { + if (y+step!=ysize) { /* now we can blend values */ next= row1[step*xsize]; /* note, prev value can be next value, but we do this loop to clear 128 then */ - for(a=0; a<step; a++) { + for (a=0; a<step; a++) { int fac, mfac; fac= ((a+1)<<8)/(step+1); @@ -2817,14 +2824,14 @@ void antialias_tagbuf(int xsize, int ysize, char *rectmove) } /* last: pixels with 0 we fill in zbuffer, with 1 we skip for mask */ - for(y=2; y<ysize; y++) { + for (y=2; y<ysize; y++) { /* setup rows */ row1= rectmove + (y-2)*xsize; row2= row1 + xsize; row3= row2 + xsize; - for(x=2; x<xsize; x++, row1++, row2++, row3++) { - if(row2[1]==0) { - if(row2[0]>1 || row2[2]>1 || row1[1]>1 || row3[1]>1) + for (x=2; x<xsize; x++, row1++, row2++, row3++) { + if (row2[1]==0) { + if (row2[0]>1 || row2[2]>1 || row1[1]>1 || row3[1]>1) row2[1]= 1; } } @@ -2895,16 +2902,16 @@ void RE_zbuf_accumulate_vecblur(NodeBlurData *nbd, int xsize, int ysize, float * /* debug... check if PASS_VECTOR_MAX still is in buffers */ dvec1= vecbufrect; - for(x= 4*xsize*ysize; x>0; x--, dvec1++) { - if(dvec1[0]==PASS_VECTOR_MAX) { + for (x= 4*xsize*ysize; x>0; x--, dvec1++) { + if (dvec1[0]==PASS_VECTOR_MAX) { dvec1[0]= 0.0f; tsktsk= 1; } } - if(tsktsk) printf("Found uninitialized speed in vector buffer... fixed.\n"); + if (tsktsk) printf("Found uninitialized speed in vector buffer... fixed.\n"); /* min speed? then copy speedbuffer to recalculate speed vectors */ - if(nbd->minspeed) { + if (nbd->minspeed) { float minspeed= (float)nbd->minspeed; float minspeedsq= minspeed*minspeed; @@ -2912,14 +2919,14 @@ void RE_zbuf_accumulate_vecblur(NodeBlurData *nbd, int xsize, int ysize, float * dvec1= vecbufrect; dvec2= minvecbufrect; - for(x= 2*xsize*ysize; x>0; x--, dvec1+=2, dvec2+=2) { - if(dvec1[0]==0.0f && dvec1[1]==0.0f) { + for (x= 2*xsize*ysize; x>0; x--, dvec1+=2, dvec2+=2) { + if (dvec1[0]==0.0f && dvec1[1]==0.0f) { dvec2[0]= dvec1[0]; dvec2[1]= dvec1[1]; } else { float speedsq= dvec1[0]*dvec1[0] + dvec1[1]*dvec1[1]; - if(speedsq <= minspeedsq) { + if (speedsq <= minspeedsq) { dvec2[0]= 0.0f; dvec2[1]= 0.0f; } @@ -2936,70 +2943,70 @@ void RE_zbuf_accumulate_vecblur(NodeBlurData *nbd, int xsize, int ysize, float * /* make vertex buffer with averaged speed and zvalues */ rectvz= MEM_mapallocN(4*sizeof(float)*(xsize+1)*(ysize+1), "vertices"); dvz= rectvz; - for(y=0; y<=ysize; y++) { + for (y=0; y<=ysize; y++) { - if(y==0) + if (y==0) dvec1= vecbufrect + 4*y*xsize; else dvec1= vecbufrect + 4*(y-1)*xsize; - if(y==ysize) + if (y==ysize) dvec2= vecbufrect + 4*(y-1)*xsize; else dvec2= vecbufrect + 4*y*xsize; - for(x=0; x<=xsize; x++) { + for (x=0; x<=xsize; x++) { /* two vectors, so a step loop */ - for(step=0; step<2; step++, dvec1+=2, dvec2+=2, dvz+=2) { + for (step=0; step<2; step++, dvec1+=2, dvec2+=2, dvz+=2) { /* average on minimal speed */ int div= 0; - if(x!=0) { - if(dvec1[-4]!=0.0f || dvec1[-3]!=0.0f) { + if (x!=0) { + if (dvec1[-4]!=0.0f || dvec1[-3]!=0.0f) { dvz[0]= dvec1[-4]; dvz[1]= dvec1[-3]; div++; } - if(dvec2[-4]!=0.0f || dvec2[-3]!=0.0f) { - if(div==0) { + if (dvec2[-4]!=0.0f || dvec2[-3]!=0.0f) { + if (div==0) { dvz[0]= dvec2[-4]; dvz[1]= dvec2[-3]; div++; } - else if( (ABS(dvec2[-4]) + ABS(dvec2[-3]))< (ABS(dvz[0]) + ABS(dvz[1])) ) { + else if ( (ABS(dvec2[-4]) + ABS(dvec2[-3]))< (ABS(dvz[0]) + ABS(dvz[1])) ) { dvz[0]= dvec2[-4]; dvz[1]= dvec2[-3]; } } } - if(x!=xsize) { - if(dvec1[0]!=0.0f || dvec1[1]!=0.0f) { - if(div==0) { + if (x!=xsize) { + if (dvec1[0]!=0.0f || dvec1[1]!=0.0f) { + if (div==0) { dvz[0]= dvec1[0]; dvz[1]= dvec1[1]; div++; } - else if( (ABS(dvec1[0]) + ABS(dvec1[1]))< (ABS(dvz[0]) + ABS(dvz[1])) ) { + else if ( (ABS(dvec1[0]) + ABS(dvec1[1]))< (ABS(dvz[0]) + ABS(dvz[1])) ) { dvz[0]= dvec1[0]; dvz[1]= dvec1[1]; } } - if(dvec2[0]!=0.0f || dvec2[1]!=0.0f) { - if(div==0) { + if (dvec2[0]!=0.0f || dvec2[1]!=0.0f) { + if (div==0) { dvz[0]= dvec2[0]; dvz[1]= dvec2[1]; } - else if( (ABS(dvec2[0]) + ABS(dvec2[1]))< (ABS(dvz[0]) + ABS(dvz[1])) ) { + else if ( (ABS(dvec2[0]) + ABS(dvec2[1]))< (ABS(dvz[0]) + ABS(dvz[1])) ) { dvz[0]= dvec2[0]; dvz[1]= dvec2[1]; } } } - if(maxspeed) { + if (maxspeed) { float speedsq= dvz[0]*dvz[0] + dvz[1]*dvz[1]; - if(speedsq > maxspeedsq) { + if (speedsq > maxspeedsq) { speedsq= (float)maxspeed/sqrt(speedsq); dvz[0]*= speedsq; dvz[1]*= speedsq; @@ -3012,7 +3019,7 @@ void RE_zbuf_accumulate_vecblur(NodeBlurData *nbd, int xsize, int ysize, float * /* set border speeds to keep border speeds on border */ dz1= rectvz; dz2= rectvz+4*(ysize)*(xsize+1); - for(x=0; x<=xsize; x++, dz1+=4, dz2+=4) { + for (x=0; x<=xsize; x++, dz1+=4, dz2+=4) { dz1[1]= 0.0f; dz2[1]= 0.0f; dz1[3]= 0.0f; @@ -3020,7 +3027,7 @@ void RE_zbuf_accumulate_vecblur(NodeBlurData *nbd, int xsize, int ysize, float * } dz1= rectvz; dz2= rectvz+4*(xsize); - for(y=0; y<=ysize; y++, dz1+=4*(xsize+1), dz2+=4*(xsize+1)) { + for (y=0; y<=ysize; y++, dz1+=4*(xsize+1), dz2+=4*(xsize+1)) { dz1[0]= 0.0f; dz2[0]= 0.0f; dz1[2]= 0.0f; @@ -3030,15 +3037,15 @@ void RE_zbuf_accumulate_vecblur(NodeBlurData *nbd, int xsize, int ysize, float * /* tag moving pixels, only these faces we draw */ dm= rectmove; dvec1= vecbufrect; - for(x=xsize*ysize; x>0; x--, dm++, dvec1+=4) { - if((dvec1[0]!=0.0f || dvec1[1]!=0.0f || dvec1[2]!=0.0f || dvec1[3]!=0.0f)) + for (x=xsize*ysize; x>0; x--, dm++, dvec1+=4) { + if ((dvec1[0]!=0.0f || dvec1[1]!=0.0f || dvec1[2]!=0.0f || dvec1[3]!=0.0f)) *dm= 255; } antialias_tagbuf(xsize, ysize, rectmove); /* has to become static, the init-jit calls a random-seed, screwing up texture noise node */ - if(firsttime) { + if (firsttime) { firsttime= 0; BLI_initjit(jit[0], 256); } @@ -3047,26 +3054,26 @@ void RE_zbuf_accumulate_vecblur(NodeBlurData *nbd, int xsize, int ysize, float * /* accumulate */ samples/= 2; - for(step= 1; step<=samples; step++) { + for (step= 1; step<=samples; step++) { float speedfac= 0.5f*nbd->fac*(float)step/(float)(samples+1); int side; - for(side=0; side<2; side++) { + for (side=0; side<2; side++) { float blendfac, ipodata[4]; /* clear zbuf, if we draw future we fill in not moving pixels */ - if(0) - for(x= xsize*ysize-1; x>=0; x--) rectz[x]= 10e16; + if (0) + for (x= xsize*ysize-1; x>=0; x--) rectz[x]= 10e16; else - for(x= xsize*ysize-1; x>=0; x--) { - if(rectmove[x]==0) + for (x= xsize*ysize-1; x>=0; x--) { + if (rectmove[x]==0) rectz[x]= zbufrect[x]; else rectz[x]= 10e16; } /* clear drawing buffer */ - for(x= xsize*ysize-1; x>=0; x--) rectdraw[x].colpoin= NULL; + for (x= xsize*ysize-1; x>=0; x--) rectdraw[x].colpoin= NULL; dimg= imgrect; dm= rectmove; @@ -3074,8 +3081,8 @@ void RE_zbuf_accumulate_vecblur(NodeBlurData *nbd, int xsize, int ysize, float * dz1= rectvz; dz2= rectvz + 4*(xsize + 1); - if(side) { - if(nbd->curved==0) { + if (side) { + if (nbd->curved==0) { dz1+= 2; dz2+= 2; } @@ -3084,15 +3091,15 @@ void RE_zbuf_accumulate_vecblur(NodeBlurData *nbd, int xsize, int ysize, float * set_quad_bezier_ipo(0.5f + 0.5f*speedfac, ipodata); - for(fy= -0.5f+jit[step & 255][0], y=0; y<ysize; y++, fy+=1.0f) { - for(fx= -0.5f+jit[step & 255][1], x=0; x<xsize; x++, fx+=1.0f, dimg+=4, dz1+=4, dz2+=4, dm++, dz++) { - if(*dm>1) { + for (fy= -0.5f+jit[step & 255][0], y=0; y<ysize; y++, fy+=1.0f) { + for (fx= -0.5f+jit[step & 255][1], x=0; x<xsize; x++, fx+=1.0f, dimg+=4, dz1+=4, dz2+=4, dm++, dz++) { + if (*dm>1) { float jfx = fx + 0.5f; float jfy = fy + 0.5f; DrawBufPixel col; /* make vertices */ - if(nbd->curved) { /* curved */ + if (nbd->curved) { /* curved */ quad_bezier_2d(v1, dz1, dz1+2, ipodata); v1[0]+= jfx; v1[1]+= jfy; v1[2]= *dz; @@ -3111,8 +3118,8 @@ void RE_zbuf_accumulate_vecblur(NodeBlurData *nbd, int xsize, int ysize, float * v3[0]= speedfac*dz2[4]+jfx+1.0f; v3[1]= speedfac*dz2[5]+jfy+1.0f; v3[2]= *dz; v4[0]= speedfac*dz2[0]+jfx; v4[1]= speedfac*dz2[1]+jfy+1.0f; v4[2]= *dz; } - if(*dm==255) col.alpha= 1.0f; - else if(*dm<2) col.alpha= 0.0f; + if (*dm==255) col.alpha= 1.0f; + else if (*dm<2) col.alpha= 0.0f; else col.alpha= ((float)*dm)/255.0f; col.colpoin= dimg; @@ -3137,8 +3144,8 @@ void RE_zbuf_accumulate_vecblur(NodeBlurData *nbd, int xsize, int ysize, float * /* accum */ rw= rectweight; rm= rectmax; - for(dr= rectdraw, dz2=newrect, x= xsize*ysize-1; x>=0; x--, dr++, dz2+=4, rw++, rm++) { - if(dr->colpoin) { + for (dr= rectdraw, dz2=newrect, x= xsize*ysize-1; x>=0; x--, dr++, dz2+=4, rw++, rm++) { + if (dr->colpoin) { float bfac= dr->alpha*blendfac; dz2[0] += bfac*dr->colpoin[0]; @@ -3158,7 +3165,7 @@ void RE_zbuf_accumulate_vecblur(NodeBlurData *nbd, int xsize, int ysize, float * rm= rectmax; ro= imgrect; dm= rectmove; - for(dz2=newrect, x= xsize*ysize-1; x>=0; x--, dz2+=4, ro+=4, rw++, rm++, dm++) { + for (dz2=newrect, x= xsize*ysize-1; x>=0; x--, dz2+=4, ro+=4, rw++, rm++, dm++) { float mfac = *rm; float fac = (*rw == 0.0f)? 0.0f: mfac/(*rw); float nfac = 1.0f - mfac; @@ -3175,7 +3182,7 @@ void RE_zbuf_accumulate_vecblur(NodeBlurData *nbd, int xsize, int ysize, float * MEM_freeN(rectvz); MEM_freeN(rectweight); MEM_freeN(rectmax); - if(minvecbufrect) MEM_freeN(vecbufrect); /* rects were swapped! */ + if (minvecbufrect) MEM_freeN(vecbufrect); /* rects were swapped! */ zbuf_free_span(&zspan); } @@ -3191,18 +3198,18 @@ static void copyto_abufz(RenderPart *pa, int *arectz, int *rectmask, int sample) int x, y, *rza, *rma; intptr_t *rd; - if(R.osa==0) { - if(!pa->rectz) + if (R.osa==0) { + if (!pa->rectz) fillrect(arectz, pa->rectx, pa->recty, 0x7FFFFFFE); else memcpy(arectz, pa->rectz, sizeof(int)*pa->rectx*pa->recty); - if(rectmask && pa->rectmask) + if (rectmask && pa->rectmask) memcpy(rectmask, pa->rectmask, sizeof(int)*pa->rectx*pa->recty); return; } - else if(!pa->rectdaps) { + else if (!pa->rectdaps) { fillrect(arectz, pa->rectx, pa->recty, 0x7FFFFFFE); return; } @@ -3213,17 +3220,17 @@ static void copyto_abufz(RenderPart *pa, int *arectz, int *rectmask, int sample) sample= (1<<sample); - for(y=0; y<pa->recty; y++) { - for(x=0; x<pa->rectx; x++) { + for (y=0; y<pa->recty; y++) { + for (x=0; x<pa->rectx; x++) { *rza= 0x7FFFFFFF; - if(rectmask) *rma= 0x7FFFFFFF; - if(*rd) { + if (rectmask) *rma= 0x7FFFFFFF; + if (*rd) { /* when there's a sky pixstruct, fill in sky-Z, otherwise solid Z */ - for(ps= (PixStr *)(*rd); ps; ps= ps->next) { - if(sample & ps->mask) { + for (ps= (PixStr *)(*rd); ps; ps= ps->next) { + if (sample & ps->mask) { *rza= ps->z; - if(rectmask) *rma= ps->maskz; + if (rectmask) *rma= ps->maskz; break; } } @@ -3257,7 +3264,7 @@ static int zbuffer_abuf(Render *re, RenderPart *pa, APixstr *APixbuf, ListBase * zbuffer_part_bounds(winx, winy, pa, bounds); - for(zsample=0; zsample<samples; zsample++) { + for (zsample=0; zsample<samples; zsample++) { zspan= &zspans[zsample]; zbuf_alloc_span(zspan, pa->rectx, pa->recty, re->clipcrop); @@ -3271,7 +3278,7 @@ static int zbuffer_abuf(Render *re, RenderPart *pa, APixstr *APixbuf, ListBase * zspan->apixbuf= APixbuf; zspan->apsmbase= apsmbase; - if(negzmask) + if (negzmask) zspan->rectmask= MEM_mallocN(sizeof(int)*pa->rectx*pa->recty, "Arectmask"); /* filling methods */ @@ -3281,7 +3288,7 @@ static int zbuffer_abuf(Render *re, RenderPart *pa, APixstr *APixbuf, ListBase * copyto_abufz(pa, zspan->arectz, zspan->rectmask, zsample); /* init zbuffer */ zspan->mask= 1<<zsample; - if(jit) { + if (jit) { zspan->zofsx= -pa->disprect.xmin - jit[zsample][0]; zspan->zofsy= -pa->disprect.ymin - jit[zsample][1]; } @@ -3298,37 +3305,37 @@ static int zbuffer_abuf(Render *re, RenderPart *pa, APixstr *APixbuf, ListBase * /* we use this to test if nothing was filled in */ zvlnr= 0; - for(i=0, obi=re->instancetable.first; obi; i++, obi=obi->next) { + for (i=0, obi=re->instancetable.first; obi; i++, obi=obi->next) { obr= obi->obr; - if(!(obi->lay & lay)) + if (!(obi->lay & lay)) continue; - if(obi->flag & R_TRANSFORMED) + if (obi->flag & R_TRANSFORMED) mult_m4_m4m4(obwinmat, winmat, obi->mat); else copy_m4_m4(obwinmat, winmat); - if(clip_render_object(obi->obr->boundbox, bounds, obwinmat)) + if (clip_render_object(obi->obr->boundbox, bounds, obwinmat)) continue; zbuf_project_cache_clear(cache, obr->totvert); - for(v=0; v<obr->totvlak; v++) { - if((v & 255)==0) + for (v=0; v<obr->totvlak; v++) { + if ((v & 255)==0) vlr= obr->vlaknodes[v>>8].vlak; else vlr++; - if(vlr->mat!=ma) { + if (vlr->mat!=ma) { ma= vlr->mat; - if(shadow) + if (shadow) dofill= (ma->mode & MA_SHADBUF); else dofill= (((ma->mode & MA_TRANSP) && (ma->mode & MA_ZTRANSP)) && !(ma->mode & MA_ONLYCAST)); } - if(dofill) { - if(!(vlr->flag & R_HIDDEN) && (obi->lay & lay)) { + if (dofill) { + if (!(vlr->flag & R_HIDDEN) && (obi->lay & lay)) { unsigned short partclip; v1= vlr->v1; @@ -3342,14 +3349,14 @@ static int zbuffer_abuf(Render *re, RenderPart *pa, APixstr *APixbuf, ListBase * /* partclipping doesn't need viewplane clipping */ partclip= c1 & c2 & c3; - if(v4) { + if (v4) { c4= zbuf_part_project(cache, v4->index, obwinmat, bounds, v4->co, ho4); partclip &= c4; } - if(partclip==0) { + if (partclip==0) { /* a little advantage for transp rendering (a z offset) */ - if(!shadow && ma->zoffs != 0.0f) { + if (!shadow && ma->zoffs != 0.0f) { mul= 0x7FFFFFFF; zval= mul*(1.0f+ho1[2]/ho1[3]); @@ -3368,45 +3375,45 @@ static int zbuffer_abuf(Render *re, RenderPart *pa, APixstr *APixbuf, ListBase * c1= testclip(ho1); c2= testclip(ho2); c3= testclip(ho3); - if(v4) + if (v4) c4= testclip(ho4); - for(zsample=0; zsample<samples; zsample++) { + for (zsample=0; zsample<samples; zsample++) { zspan= &zspans[zsample]; zspan->polygon_offset= polygon_offset; - if(ma->material_type == MA_TYPE_WIRE) { - if(v4) + if (ma->material_type == MA_TYPE_WIRE) { + if (v4) zbufclipwire(zspan, i, zvlnr, vlr->ec, ho1, ho2, ho3, ho4, c1, c2, c3, c4); else zbufclipwire(zspan, i, zvlnr, vlr->ec, ho1, ho2, ho3, 0, c1, c2, c3, 0); } else { - if(v4 && (vlr->flag & R_STRAND)) { + if (v4 && (vlr->flag & R_STRAND)) { zbufclip4(zspan, i, zvlnr, ho1, ho2, ho3, ho4, c1, c2, c3, c4); } else { zbufclip(zspan, i, zvlnr, ho1, ho2, ho3, c1, c2, c3); - if(v4) + if (v4) zbufclip(zspan, i, zvlnr+RE_QUAD_OFFS, ho1, ho3, ho4, c1, c3, c4); } } } } - if((v & 255)==255) - if(re->test_break(re->tbh)) + if ((v & 255)==255) + if (re->test_break(re->tbh)) break; } } } - if(re->test_break(re->tbh)) break; + if (re->test_break(re->tbh)) break; } - for(zsample=0; zsample<samples; zsample++) { + for (zsample=0; zsample<samples; zsample++) { zspan= &zspans[zsample]; MEM_freeN(zspan->arectz); - if(zspan->rectmask) + if (zspan->rectmask) MEM_freeN(zspan->rectmask); zbuf_free_span(zspan); } @@ -3422,18 +3429,18 @@ static int zbuffer_abuf_render(RenderPart *pa, APixstr *APixbuf, APixstrand *APi samples= (R.osa)? R.osa: 1; negzmask= ((rl->layflag & SCE_LAY_ZMASK) && (rl->layflag & SCE_LAY_NEG_ZMASK)); - if(R.osa) + if (R.osa) jit= R.jit; - else if(R.i.curblur) + else if (R.i.curblur) jit= &R.mblur_jit[R.i.curblur-1]; else jit= NULL; zbuf_make_winmat(&R, winmat); - if(rl->layflag & SCE_LAY_ZTRA) + if (rl->layflag & SCE_LAY_ZTRA) doztra+= zbuffer_abuf(&R, pa, APixbuf, apsmbase, rl->lay, negzmask, winmat, R.winx, R.winy, samples, jit, R.clipcrop, 0); - if((rl->layflag & SCE_LAY_STRAND) && APixbufstrand) + if ((rl->layflag & SCE_LAY_STRAND) && APixbufstrand) doztra+= zbuffer_strands_abuf(&R, pa, APixbufstrand, apsmbase, rl->lay, negzmask, winmat, R.winx, R.winy, samples, jit, R.clipcrop, 0, sscache); return doztra; @@ -3444,7 +3451,7 @@ void zbuffer_abuf_shadow(Render *re, LampRen *lar, float winmat[][4], APixstr *A RenderPart pa; int lay= -1; - if(lar->mode & LA_LAYER) lay= lar->lay; + if (lar->mode & LA_LAYER) lay= lar->lay; memset(&pa, 0, sizeof(RenderPart)); pa.rectx= size; @@ -3455,7 +3462,7 @@ void zbuffer_abuf_shadow(Render *re, LampRen *lar, float winmat[][4], APixstr *A pa.disprect.ymax = size; zbuffer_abuf(re, &pa, APixbuf, apsmbase, lay, 0, winmat, size, size, samples, jit, 1.0f, 1); - if(APixbufstrand) + if (APixbufstrand) zbuffer_strands_abuf(re, &pa, APixbufstrand, apsmbase, lay, 0, winmat, size, size, samples, jit, 1.0f, 1, NULL); } @@ -3467,27 +3474,27 @@ void add_transp_speed(RenderLayer *rl, int offset, float *speed, float alpha, in { RenderPass *rpass; - for(rpass= rl->passes.first; rpass; rpass= rpass->next) { - if(rpass->passtype==SCE_PASS_VECTOR) { + for (rpass= rl->passes.first; rpass; rpass= rpass->next) { + if (rpass->passtype==SCE_PASS_VECTOR) { float *fp= rpass->rect + 4*offset; - if(speed==NULL) { + if (speed==NULL) { /* clear */ - if(fp[0]==PASS_VECTOR_MAX) fp[0]= 0.0f; - if(fp[1]==PASS_VECTOR_MAX) fp[1]= 0.0f; - if(fp[2]==PASS_VECTOR_MAX) fp[2]= 0.0f; - if(fp[3]==PASS_VECTOR_MAX) fp[3]= 0.0f; + if (fp[0]==PASS_VECTOR_MAX) fp[0]= 0.0f; + if (fp[1]==PASS_VECTOR_MAX) fp[1]= 0.0f; + if (fp[2]==PASS_VECTOR_MAX) fp[2]= 0.0f; + if (fp[3]==PASS_VECTOR_MAX) fp[3]= 0.0f; } - else if(rdrect==NULL || rdrect[offset]==0 || alpha>0.95f) { + else if (rdrect==NULL || rdrect[offset]==0 || alpha>0.95f) { copy_v4_v4(fp, speed); } else { /* add minimum speed in pixel */ - if( (ABS(speed[0]) + ABS(speed[1]))< (ABS(fp[0]) + ABS(fp[1])) ) { + if ( (ABS(speed[0]) + ABS(speed[1]))< (ABS(fp[0]) + ABS(fp[1])) ) { fp[0]= speed[0]; fp[1]= speed[1]; } - if( (ABS(speed[2]) + ABS(speed[3]))< (ABS(fp[2]) + ABS(fp[3])) ) { + if ( (ABS(speed[2]) + ABS(speed[3]))< (ABS(fp[2]) + ABS(fp[3])) ) { fp[2]= speed[2]; fp[3]= speed[3]; } @@ -3501,8 +3508,8 @@ static void add_transp_obindex(RenderLayer *rl, int offset, Object *ob) { RenderPass *rpass; - for(rpass= rl->passes.first; rpass; rpass= rpass->next) { - if(rpass->passtype == SCE_PASS_INDEXOB||rpass->passtype == SCE_PASS_INDEXMA) { + for (rpass= rl->passes.first; rpass; rpass= rpass->next) { + if (rpass->passtype == SCE_PASS_INDEXOB||rpass->passtype == SCE_PASS_INDEXMA) { float *fp= rpass->rect + offset; *fp= (float)ob->index; break; @@ -3518,7 +3525,7 @@ void merge_transp_passes(RenderLayer *rl, ShadeResult *shr) float weight= 1.0f/((float)R.osa); int delta= sizeof(ShadeResult)/4; - for(rpass= rl->passes.first; rpass; rpass= rpass->next) { + for (rpass= rl->passes.first; rpass; rpass= rpass->next) { float *col= NULL; int pixsize= 3; @@ -3573,16 +3580,16 @@ void merge_transp_passes(RenderLayer *rl, ShadeResult *shr) int samp; /* add minimum speed in pixel */ - for(samp= 1; samp<R.osa; samp++, shr_t++) { + for (samp= 1; samp<R.osa; samp++, shr_t++) { - if(shr_t->combined[3] > 0.0f) { + if (shr_t->combined[3] > 0.0f) { float *speed= shr_t->winspeed; - if( (ABS(speed[0]) + ABS(speed[1]))< (ABS(fp[0]) + ABS(fp[1])) ) { + if ( (ABS(speed[0]) + ABS(speed[1]))< (ABS(fp[0]) + ABS(fp[1])) ) { fp[0]= speed[0]; fp[1]= speed[1]; } - if( (ABS(speed[2]) + ABS(speed[3]))< (ABS(fp[2]) + ABS(fp[3])) ) { + if ( (ABS(speed[2]) + ABS(speed[3]))< (ABS(fp[2]) + ABS(fp[3])) ) { fp[2]= speed[2]; fp[3]= speed[3]; } @@ -3591,23 +3598,23 @@ void merge_transp_passes(RenderLayer *rl, ShadeResult *shr) } break; } - if(col) { + if (col) { float *fp= col+delta; int samp; - for(samp= 1; samp<R.osa; samp++, fp+=delta) { + for (samp= 1; samp<R.osa; samp++, fp+=delta) { col[0]+= fp[0]; - if(pixsize>1) { + if (pixsize>1) { col[1]+= fp[1]; col[2]+= fp[2]; - if(pixsize==4) col[3]+= fp[3]; + if (pixsize==4) col[3]+= fp[3]; } } col[0]*= weight; - if(pixsize>1) { + if (pixsize>1) { col[1]*= weight; col[2]*= weight; - if(pixsize==4) col[3]*= weight; + if (pixsize==4) col[3]*= weight; } } } @@ -3618,14 +3625,14 @@ void add_transp_passes(RenderLayer *rl, int offset, ShadeResult *shr, float alph { RenderPass *rpass; - for(rpass= rl->passes.first; rpass; rpass= rpass->next) { + for (rpass= rl->passes.first; rpass; rpass= rpass->next) { float *fp, *col= NULL; int pixsize= 3; switch(rpass->passtype) { case SCE_PASS_Z: fp= rpass->rect + offset; - if(shr->z < *fp) + if (shr->z < *fp) *fp= shr->z; break; case SCE_PASS_RGBA: @@ -3667,11 +3674,11 @@ void add_transp_passes(RenderLayer *rl, int offset, ShadeResult *shr, float alph pixsize= 1; break; } - if(col) { + if (col) { fp= rpass->rect + pixsize*offset; fp[0]= col[0] + (1.0f-alpha)*fp[0]; - if(pixsize==3) { + if (pixsize==3) { fp[1]= col[1] + (1.0f-alpha)*fp[1]; fp[2]= col[2] + (1.0f-alpha)*fp[2]; } @@ -3692,8 +3699,8 @@ static int vergzvlak(const void *a1, const void *a2) { const ZTranspRow *r1 = a1, *r2 = a2; - if(r1->z < r2->z) return 1; - else if(r1->z > r2->z) return -1; + if (r1->z < r2->z) return 1; + else if (r1->z > r2->z) return -1; return 0; } @@ -3732,10 +3739,10 @@ static void unref_strand_samples(StrandShadeCache *cache, ZTranspRow *row, int t /* remove references to samples that are not being rendered, but we still * need to remove them so that the reference count of strand vertex shade * samples correctly drops to zero */ - while(totface > 0) { + while (totface > 0) { totface--; - if(row[totface].segment != -1) { + if (row[totface].segment != -1) { obi= R.objectinstance + row[totface].obi; obr= obi->obr; strand= RE_findOrAddStrand(obr, row[totface].p-1); @@ -3757,18 +3764,18 @@ static void shade_tra_samples_fill(ShadeSample *ssamp, int x, int y, int z, int shade_input_set_triangle(shi, obi, facenr, 1); /* officially should always be true... we have no sky info */ - if(shi->vlr) { + if (shi->vlr) { /* full osa is only set for OSA renders */ - if(shi->vlr->flag & R_FULL_OSA) { + if (shi->vlr->flag & R_FULL_OSA) { short shi_inc= 0, samp; - for(samp=0; samp<R.osa; samp++) { - if(curmask & (1<<samp)) { + for (samp=0; samp<R.osa; samp++) { + if (curmask & (1<<samp)) { xs= (float)x + R.jit[samp][0] + 0.5f; /* zbuffer has this inverse corrected, ensures xs,ys are inside pixel */ ys= (float)y + R.jit[samp][1] + 0.5f; - if(shi_inc) { + if (shi_inc) { shade_input_copy_triangle(shi+1, shi); shi++; } @@ -3776,7 +3783,7 @@ static void shade_tra_samples_fill(ShadeSample *ssamp, int x, int y, int z, int shi->samplenr= R.shadowsamplenr[shi->thread]++; shade_input_set_viewco(shi, x, y, xs, ys, (float)z); shade_input_set_uv(shi); - if(shi_inc==0) + if (shi_inc==0) shade_input_set_normals(shi); else /* XXX shi->flippednor messes up otherwise */ shade_input_set_vertex_normals(shi); @@ -3786,7 +3793,7 @@ static void shade_tra_samples_fill(ShadeSample *ssamp, int x, int y, int z, int } } else { - if(R.osa) { + if (R.osa) { short b= R.samples->centmask[curmask]; xs= (float)x + R.samples->centLut[b & 15] + 0.5f; ys= (float)y + R.samples->centLut[b>>4] + 0.5f; @@ -3809,14 +3816,14 @@ static void shade_tra_samples_fill(ShadeSample *ssamp, int x, int y, int z, int static int shade_tra_samples(ShadeSample *ssamp, StrandShadeCache *cache, int x, int y, ZTranspRow *row, int addpassflag) { - if(row->segment != -1) { + if (row->segment != -1) { shade_strand_samples(cache, ssamp, x, y, row, addpassflag); return 1; } shade_tra_samples_fill(ssamp, x, y, row->z, row->obi, row->p, row->mask); - if(ssamp->tot) { + if (ssamp->tot) { ShadeInput *shi= ssamp->shi; ShadeResult *shr= ssamp->shr; int samp; @@ -3825,19 +3832,19 @@ static int shade_tra_samples(ShadeSample *ssamp, StrandShadeCache *cache, int x, shade_samples_do_AO(ssamp); /* if shade (all shadepinputs have same passflag) */ - if(shi->passflag & ~(SCE_PASS_Z|SCE_PASS_INDEXOB|SCE_PASS_INDEXMA)) { - for(samp=0; samp<ssamp->tot; samp++, shi++, shr++) { + if (shi->passflag & ~(SCE_PASS_Z|SCE_PASS_INDEXOB|SCE_PASS_INDEXMA)) { + for (samp=0; samp<ssamp->tot; samp++, shi++, shr++) { shade_input_set_shade_texco(shi); shade_input_do_shade(shi, shr); /* include lamphalos for ztra, since halo layer was added already */ - if(R.flag & R_LAMPHALO) - if(shi->layflag & SCE_LAY_HALO) + if (R.flag & R_LAMPHALO) + if (shi->layflag & SCE_LAY_HALO) renderspothalo(shi, shr->combined, shr->combined[3]); } } - else if(shi->passflag & SCE_PASS_Z) { - for(samp=0; samp<ssamp->tot; samp++, shi++, shr++) + else if (shi->passflag & SCE_PASS_Z) { + for (samp=0; samp<ssamp->tot; samp++, shi++, shr++) shr->z= -shi->co[2]; } @@ -3857,66 +3864,66 @@ static int addtosamp_shr(ShadeResult *samp_shr, ShadeSample *ssamp, int addpassf { int a, sample, osa = (R.osa? R.osa: 1), retval = osa; - for(a=0; a < osa; a++, samp_shr++) { + for (a=0; a < osa; a++, samp_shr++) { ShadeInput *shi= ssamp->shi; ShadeResult *shr= ssamp->shr; - for(sample=0; sample<ssamp->tot; sample++, shi++, shr++) { + for (sample=0; sample<ssamp->tot; sample++, shi++, shr++) { - if(shi->mask & (1<<a)) { + if (shi->mask & (1<<a)) { float fac= (1.0f - samp_shr->combined[3])*shr->combined[3]; addAlphaUnderFloat(samp_shr->combined, shr->combined); samp_shr->z= MIN2(samp_shr->z, shr->z); - if(addpassflag & SCE_PASS_VECTOR) { + if (addpassflag & SCE_PASS_VECTOR) { copy_v4_v4(samp_shr->winspeed, shr->winspeed); } /* optim... */ - if(addpassflag & ~(SCE_PASS_VECTOR)) { + if (addpassflag & ~(SCE_PASS_VECTOR)) { - if(addpassflag & SCE_PASS_RGBA) + if (addpassflag & SCE_PASS_RGBA) addAlphaUnderFloat(samp_shr->col, shr->col); - if(addpassflag & SCE_PASS_NORMAL) + if (addpassflag & SCE_PASS_NORMAL) addvecmul(samp_shr->nor, shr->nor, fac); - if(addpassflag & SCE_PASS_EMIT) + if (addpassflag & SCE_PASS_EMIT) addvecmul(samp_shr->emit, shr->emit, fac); - if(addpassflag & SCE_PASS_DIFFUSE) + if (addpassflag & SCE_PASS_DIFFUSE) addvecmul(samp_shr->diff, shr->diff, fac); - if(addpassflag & SCE_PASS_SPEC) + if (addpassflag & SCE_PASS_SPEC) addvecmul(samp_shr->spec, shr->spec, fac); - if(addpassflag & SCE_PASS_SHADOW) + if (addpassflag & SCE_PASS_SHADOW) addvecmul(samp_shr->shad, shr->shad, fac); - if(addpassflag & SCE_PASS_AO) + if (addpassflag & SCE_PASS_AO) addvecmul(samp_shr->ao, shr->ao, fac); - if(addpassflag & SCE_PASS_ENVIRONMENT) + if (addpassflag & SCE_PASS_ENVIRONMENT) addvecmul(samp_shr->env, shr->env, fac); - if(addpassflag & SCE_PASS_INDIRECT) + if (addpassflag & SCE_PASS_INDIRECT) addvecmul(samp_shr->indirect, shr->indirect, fac); - if(addpassflag & SCE_PASS_REFLECT) + if (addpassflag & SCE_PASS_REFLECT) addvecmul(samp_shr->refl, shr->refl, fac); - if(addpassflag & SCE_PASS_REFRACT) + if (addpassflag & SCE_PASS_REFRACT) addvecmul(samp_shr->refr, shr->refr, fac); - if(addpassflag & SCE_PASS_MIST) + if (addpassflag & SCE_PASS_MIST) samp_shr->mist= samp_shr->mist+fac*shr->mist; } } } - if(samp_shr->combined[3]>0.999f) retval--; + if (samp_shr->combined[3]>0.999f) retval--; } return retval; } @@ -3929,11 +3936,11 @@ static void reset_sky_speedvectors(RenderPart *pa, RenderLayer *rl, float *rectf int a; fp= RE_RenderLayerGetPass(rl, SCE_PASS_VECTOR); - if(fp==NULL) return; + if (fp==NULL) return; col= rectf+3; - for(a= 4*pa->rectx*pa->recty -4; a>=0; a-=4) { - if(col[a]==0.0f) { + for (a= 4*pa->rectx*pa->recty -4; a>=0; a-=4) { + if (col[a]==0.0f) { fp[a]= PASS_VECTOR_MAX; fp[a+1]= PASS_VECTOR_MAX; fp[a+2]= PASS_VECTOR_MAX; @@ -3966,17 +3973,17 @@ unsigned short *zbuffer_transp_shade(RenderPart *pa, RenderLayer *rl, float *pas unsigned short *ztramask= NULL, filled; /* looks nicer for calling code */ - if(R.test_break(R.tbh)) + if (R.test_break(R.tbh)) return NULL; - if(R.osa>16) { /* MAX_OSA */ + if (R.osa>16) { /* MAX_OSA */ printf("zbuffer_transp_shade: osa too large\n"); G.afbreek= 1; return NULL; } APixbuf= MEM_callocN(pa->rectx*pa->recty*sizeof(APixstr), "APixbuf"); - if(R.totstrand && (rl->layflag & SCE_LAY_STRAND)) { + if (R.totstrand && (rl->layflag & SCE_LAY_STRAND)) { APixbufstrand= MEM_callocN(pa->rectx*pa->recty*sizeof(APixstrand), "APixbufstrand"); sscache= strand_shade_cache_create(); } @@ -3985,7 +3992,7 @@ unsigned short *zbuffer_transp_shade(RenderPart *pa, RenderLayer *rl, float *pas shade_sample_initialize(&ssamp, pa, rl); addpassflag= rl->passflag & ~(SCE_PASS_COMBINED); - if(R.osa) + if (R.osa) sampalpha= 1.0f/(float)R.osa; else sampalpha= 1.0f; @@ -3993,12 +4000,12 @@ unsigned short *zbuffer_transp_shade(RenderPart *pa, RenderLayer *rl, float *pas /* fill the Apixbuf */ doztra= zbuffer_abuf_render(pa, APixbuf, APixbufstrand, &apsmbase, rl, sscache); - if(doztra == 0) { + if (doztra == 0) { /* nothing filled in */ MEM_freeN(APixbuf); - if(APixbufstrand) + if (APixbufstrand) MEM_freeN(APixbufstrand); - if(sscache) + if (sscache) strand_shade_cache_free(sscache); freepsA(&apsmbase); return NULL; @@ -4012,20 +4019,20 @@ unsigned short *zbuffer_transp_shade(RenderPart *pa, RenderLayer *rl, float *pas totfullsample= get_sample_layers(pa, rl, rlpp); /* irregular shadowb buffer creation */ - if(R.r.mode & R_SHADOW) + if (R.r.mode & R_SHADOW) ISB_create(pa, APixbuf); /* masks, to have correct alpha combine */ - if(R.osa && (rl->layflag & SCE_LAY_SOLID) && pa->fullresult.first==NULL) + if (R.osa && (rl->layflag & SCE_LAY_SOLID) && pa->fullresult.first==NULL) ztramask= MEM_callocN(pa->rectx*pa->recty*sizeof(short), "ztramask"); /* zero alpha pixels get speed vector max again */ - if(addpassflag & SCE_PASS_VECTOR) - if(rl->layflag & SCE_LAY_SOLID) + if (addpassflag & SCE_PASS_VECTOR) + if (rl->layflag & SCE_LAY_SOLID) reset_sky_speedvectors(pa, rl, rl->acolrect?rl->acolrect:rl->rectf); /* if acolrect is set we use it */ /* filtered render, for now we assume only 1 filter size */ - if(pa->crop) { + if (pa->crop) { crop= 1; offs= pa->rectx + 1; passrect+= 4*offs; @@ -4039,35 +4046,35 @@ unsigned short *zbuffer_transp_shade(RenderPart *pa, RenderLayer *rl, float *pas rr->renlay= rl; /* render the tile */ - for(y=pa->disprect.ymin+crop; y<pa->disprect.ymax-crop; y++, rr->renrect.ymax++) { + for (y=pa->disprect.ymin+crop; y<pa->disprect.ymax-crop; y++, rr->renrect.ymax++) { pass= passrect; ap= aprect; apstrand= aprectstrand; od= offs; - if(R.test_break(R.tbh)) + if (R.test_break(R.tbh)) break; - for(x=pa->disprect.xmin+crop; x<pa->disprect.xmax-crop; x++, ap++, apstrand++, pass+=4, od++) { + for (x=pa->disprect.xmin+crop; x<pa->disprect.xmax-crop; x++, ap++, apstrand++, pass+=4, od++) { - if(ap->p[0]==0 && (!APixbufstrand || apstrand->p[0]==0)) { - if(addpassflag & SCE_PASS_VECTOR) + if (ap->p[0]==0 && (!APixbufstrand || apstrand->p[0]==0)) { + if (addpassflag & SCE_PASS_VECTOR) add_transp_speed(rl, od, NULL, 0.0f, rdrect); } else { /* sort in z */ totface= 0; apn= ap; - while(apn) { - for(a=0; a<4; a++) { - if(apn->p[a]) { + while (apn) { + for (a=0; a<4; a++) { + if (apn->p[a]) { zrow[totface].obi= apn->obi[a]; zrow[totface].z= apn->z[a]; zrow[totface].p= apn->p[a]; zrow[totface].mask= apn->mask[a]; zrow[totface].segment= -1; totface++; - if(totface>=MAX_ZROW) totface= MAX_ZROW-1; + if (totface>=MAX_ZROW) totface= MAX_ZROW-1; } else break; } @@ -4075,19 +4082,19 @@ unsigned short *zbuffer_transp_shade(RenderPart *pa, RenderLayer *rl, float *pas } apnstrand= (APixbufstrand)? apstrand: NULL; - while(apnstrand) { - for(a=0; a<4; a++) { - if(apnstrand->p[a]) { + while (apnstrand) { + for (a=0; a<4; a++) { + if (apnstrand->p[a]) { zrow[totface].obi= apnstrand->obi[a]; zrow[totface].z= apnstrand->z[a]; zrow[totface].p= apnstrand->p[a]; zrow[totface].mask= apnstrand->mask[a]; zrow[totface].segment= apnstrand->seg[a]; - if(R.osa) { + if (R.osa) { totsample= 0; - for(b=0; b<R.osa; b++) - if(zrow[totface].mask & (1<<b)) + for (b=0; b<R.osa; b++) + if (zrow[totface].mask & (1<<b)) totsample++; } else @@ -4096,43 +4103,43 @@ unsigned short *zbuffer_transp_shade(RenderPart *pa, RenderLayer *rl, float *pas zrow[totface].u= apnstrand->u[a]/totsample; zrow[totface].v= apnstrand->v[a]/totsample; totface++; - if(totface>=MAX_ZROW) totface= MAX_ZROW-1; + if (totface>=MAX_ZROW) totface= MAX_ZROW-1; } } apnstrand= apnstrand->next; } - if(totface==2) { - if(zrow[0].z < zrow[1].z) { + if (totface==2) { + if (zrow[0].z < zrow[1].z) { SWAP(ZTranspRow, zrow[0], zrow[1]); } } - else if(totface>2) { + else if (totface>2) { qsort(zrow, totface, sizeof(ZTranspRow), vergzvlak); } /* front face does index pass for transparent, no AA or filters, but yes FSA */ - if(addpassflag & SCE_PASS_INDEXOB) { + if (addpassflag & SCE_PASS_INDEXOB) { ObjectRen *obr= R.objectinstance[zrow[totface-1].obi].obr; - if(obr->ob) { - for(a= 0; a<totfullsample; a++) + if (obr->ob) { + for (a= 0; a<totfullsample; a++) add_transp_obindex(rlpp[a], od, obr->ob); } } - if(addpassflag & SCE_PASS_INDEXMA) { + if (addpassflag & SCE_PASS_INDEXMA) { ObjectRen *obr= R.objectinstance[zrow[totface-1].obi].obr; - if(obr->ob) { - for(a= 0; a<totfullsample; a++) + if (obr->ob) { + for (a= 0; a<totfullsample; a++) add_transp_obindex(rlpp[a], od, obr->ob); } } /* for each mask-sample we alpha-under colors. then in end it's added using filter */ memset(samp_shr, 0, sizeof(ShadeResult)*osa); - for(a=0; a<osa; a++) { + for (a=0; a<osa; a++) { samp_shr[a].z= 10e10f; - if(addpassflag & SCE_PASS_VECTOR) { + if (addpassflag & SCE_PASS_VECTOR) { samp_shr[a].winspeed[0]= PASS_VECTOR_MAX; samp_shr[a].winspeed[1]= PASS_VECTOR_MAX; samp_shr[a].winspeed[2]= PASS_VECTOR_MAX; @@ -4140,16 +4147,16 @@ unsigned short *zbuffer_transp_shade(RenderPart *pa, RenderLayer *rl, float *pas } } - if(R.osa==0) { - while(totface>0) { + if (R.osa==0) { + while (totface>0) { totface--; - if(shade_tra_samples(&ssamp, sscache, x, y, &zrow[totface], addpassflag)) { + if (shade_tra_samples(&ssamp, sscache, x, y, &zrow[totface], addpassflag)) { filled= addtosamp_shr(samp_shr, &ssamp, addpassflag); addAlphaUnderFloat(pass, ssamp.shr[0].combined); - if(filled == 0) { - if(sscache) + if (filled == 0) { + if (sscache) unref_strand_samples(sscache, zrow, totface); break; } @@ -4157,25 +4164,25 @@ unsigned short *zbuffer_transp_shade(RenderPart *pa, RenderLayer *rl, float *pas } alpha= samp_shr->combined[3]; - if(alpha!=0.0f) { + if (alpha!=0.0f) { add_transp_passes(rl, od, samp_shr, alpha); - if(addpassflag & SCE_PASS_VECTOR) + if (addpassflag & SCE_PASS_VECTOR) add_transp_speed(rl, od, samp_shr->winspeed, alpha, rdrect); } } else { short *sp= (short *)(ztramask+od); - while(totface>0) { + while (totface>0) { totface--; - if(shade_tra_samples(&ssamp, sscache, x, y, &zrow[totface], addpassflag)) { + if (shade_tra_samples(&ssamp, sscache, x, y, &zrow[totface], addpassflag)) { filled= addtosamp_shr(samp_shr, &ssamp, addpassflag); - if(ztramask) + if (ztramask) *sp |= zrow[totface].mask; - if(filled==0) { - if(sscache) + if (filled==0) { + if (sscache) unref_strand_samples(sscache, zrow, totface); break; } @@ -4183,16 +4190,16 @@ unsigned short *zbuffer_transp_shade(RenderPart *pa, RenderLayer *rl, float *pas } /* multisample buffers or filtered mask filling? */ - if(pa->fullresult.first) { - for(a=0; a<R.osa; a++) { + if (pa->fullresult.first) { + for (a=0; a<R.osa; a++) { alpha= samp_shr[a].combined[3]; - if(alpha!=0.0f) { + if (alpha!=0.0f) { RenderLayer *rl= ssamp.rlpp[a]; addAlphaOverFloat(rl->rectf + 4*od, samp_shr[a].combined); add_transp_passes(rl, od, &samp_shr[a], alpha); - if(addpassflag & SCE_PASS_VECTOR) + if (addpassflag & SCE_PASS_VECTOR) add_transp_speed(rl, od, samp_shr[a].winspeed, alpha, rdrect); } } @@ -4201,19 +4208,19 @@ unsigned short *zbuffer_transp_shade(RenderPart *pa, RenderLayer *rl, float *pas alpha= 0.0f; /* note; cannot use pass[3] for alpha due to filtermask */ - for(a=0; a<R.osa; a++) { + for (a=0; a<R.osa; a++) { add_filt_fmask(1<<a, samp_shr[a].combined, pass, rr->rectx); alpha+= samp_shr[a].combined[3]; } - if(addpassflag) { + if (addpassflag) { alpha*= sampalpha; /* merge all in one, and then add */ merge_transp_passes(rl, samp_shr); add_transp_passes(rl, od, samp_shr, alpha); - if(addpassflag & SCE_PASS_VECTOR) + if (addpassflag & SCE_PASS_VECTOR) add_transp_speed(rl, od, samp_shr[0].winspeed, alpha, rdrect); } } @@ -4231,13 +4238,13 @@ unsigned short *zbuffer_transp_shade(RenderPart *pa, RenderLayer *rl, float *pas rr->renlay= NULL; MEM_freeN(APixbuf); - if(APixbufstrand) + if (APixbufstrand) MEM_freeN(APixbufstrand); - if(sscache) + if (sscache) strand_shade_cache_free(sscache); freepsA(&apsmbase); - if(R.r.mode & R_SHADOW) + if (R.r.mode & R_SHADOW) ISB_free(pa); return ztramask; diff --git a/source/creator/creator.c b/source/creator/creator.c index 63e25e1d820..698e1e7be20 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -533,11 +533,13 @@ static int set_output(int argc, const char **argv, void *data) Scene *scene= CTX_data_scene(C); if (scene) { BLI_strncpy(scene->r.pic, argv[1], sizeof(scene->r.pic)); - } else { + } + else { printf("\nError: no blend loaded. cannot use '-o / --render-output'.\n"); } return 1; - } else { + } + else { printf("\nError: you must specify a path after '-o / --render-output'.\n"); return 0; } @@ -560,7 +562,7 @@ static int set_engine(int argc, const char **argv, void *data) if (scene) { RenderData *rd = &scene->r; - if(BLI_findstring(&R_engines, argv[1], offsetof(RenderEngineType, idname))) { + if (BLI_findstring(&R_engines, argv[1], offsetof(RenderEngineType, idname))) { BLI_strncpy_utf8(rd->engine, argv[1], sizeof(rd->engine)); } } @@ -597,7 +599,8 @@ static int set_image_type(int argc, const char **argv, void *data) printf("\nError: no blend loaded. order the arguments so '-F / --render-format' is after the blend is loaded.\n"); } return 1; - } else { + } + else { printf("\nError: you must specify a format after '-F / --render-foramt'.\n"); return 0; } @@ -606,13 +609,15 @@ static int set_image_type(int argc, const char **argv, void *data) static int set_threads(int argc, const char **argv, void *UNUSED(data)) { if (argc >= 1) { - if(G.background) { + if (G.background) { RE_set_max_threads(atoi(argv[1])); - } else { + } + else { printf("Warning: threads can only be set in background mode\n"); } return 1; - } else { + } + else { printf("\nError: you must specify a number of threads between 0 and 8 '-t / --threads'.\n"); return 0; } @@ -626,16 +631,20 @@ static int set_extension(int argc, const char **argv, void *data) if (scene) { if (argv[1][0] == '0') { scene->r.scemode &= ~R_EXTENSION; - } else if (argv[1][0] == '1') { + } + else if (argv[1][0] == '1') { scene->r.scemode |= R_EXTENSION; - } else { + } + else { printf("\nError: Use '-x 1 / -x 0' To set the extension option or '--use-extension'\n"); } - } else { + } + else { printf("\nError: no blend loaded. order the arguments so '-o ' is after '-x '.\n"); } return 1; - } else { + } + else { printf("\nError: you must specify a path after '- '.\n"); return 0; } @@ -677,7 +686,8 @@ static int set_ge_parameters(int argc, const char **argv, void *data) } /* name arg eaten */ - } else { + } + else { #ifdef WITH_GAMEENGINE SYS_WriteCommandLineInt(syshandle,argv[a],1); #endif @@ -729,11 +739,13 @@ static int render_frame(int argc, const char **argv, void *data) RE_BlenderAnim(re, bmain, scene, NULL, scene->lay, frame, frame, scene->r.frame_step); RE_SetReports(re, NULL); return 1; - } else { + } + else { printf("\nError: frame number must follow '-f / --render-frame'.\n"); return 0; } - } else { + } + else { printf("\nError: no blend loaded. cannot use '-f / --render-frame'.\n"); return 0; } @@ -760,14 +772,15 @@ static int render_animation(int UNUSED(argc), const char **UNUSED(argv), void *d static int set_scene(int argc, const char **argv, void *data) { - if(argc > 1) { + if (argc > 1) { bContext *C= data; Scene *scene= set_scene_name(CTX_data_main(C), argv[1]); - if(scene) { + if (scene) { CTX_data_scene_set(C, scene); } return 1; - } else { + } + else { printf("\nError: Scene name must follow '-S / --scene'.\n"); return 0; } @@ -782,11 +795,13 @@ static int set_start_frame(int argc, const char **argv, void *data) int frame = atoi(argv[1]); (scene->r.sfra) = CLAMPIS(frame, MINFRAME, MAXFRAME); return 1; - } else { + } + else { printf("\nError: frame number must follow '-s / --frame-start'.\n"); return 0; } - } else { + } + else { printf("\nError: no blend loaded. cannot use '-s / --frame-start'.\n"); return 0; } @@ -801,11 +816,13 @@ static int set_end_frame(int argc, const char **argv, void *data) int frame = atoi(argv[1]); (scene->r.efra) = CLAMPIS(frame, MINFRAME, MAXFRAME); return 1; - } else { + } + else { printf("\nError: frame number must follow '-e / --frame-end'.\n"); return 0; } - } else { + } + else { printf("\nError: no blend loaded. cannot use '-e / --frame-end'.\n"); return 0; } @@ -820,11 +837,13 @@ static int set_skip_frame(int argc, const char **argv, void *data) int frame = atoi(argv[1]); (scene->r.frame_step) = CLAMPIS(frame, 1, MAXFRAME); return 1; - } else { + } + else { printf("\nError: number of frames to step must follow '-j / --frame-jump'.\n"); return 0; } - } else { + } + else { printf("\nError: no blend loaded. cannot use '-j / --frame-jump'.\n"); return 0; } @@ -837,7 +856,7 @@ static int set_skip_frame(int argc, const char **argv, void *data) wmWindowManager *wm= CTX_wm_manager(C); \ wmWindow *prevwin= CTX_wm_window(C); \ Scene *prevscene= CTX_data_scene(C); \ - if(wm->windows.first) { \ + if (wm->windows.first) { \ CTX_wm_window_set(C, wm->windows.first); \ _cmd; \ CTX_wm_window_set(C, prevwin); \ @@ -867,7 +886,8 @@ static int run_python(int argc, const char **argv, void *data) BPY_CTX_SETUP(BPY_filepath_exec(C, filename, NULL)) return 1; - } else { + } + else { printf("\nError: you must specify a Python script after '-P / --python'.\n"); return 0; } @@ -940,7 +960,7 @@ static int load_file(int UNUSED(argc), const char **argv, void *data) wmWindowManager *wm= CTX_wm_manager(C); /* special case, 2.4x files */ - if(wm==NULL && CTX_data_main(C)->wm.first==NULL) { + if (wm==NULL && CTX_data_main(C)->wm.first==NULL) { extern void wm_add_default(bContext *C); /* wm_add_default() needs the screen to be set. */ @@ -971,7 +991,8 @@ static int load_file(int UNUSED(argc), const char **argv, void *data) /* happens for the UI on file reading too (huh? (ton))*/ // XXX BKE_reset_undo(); // BKE_write_undo("original"); /* save current state */ - } else { + } + else { /* we are not running in background mode here, but start blender in UI mode with * a file - this should do everything a 'load file' does */ ReportList reports; @@ -1213,7 +1234,7 @@ int main(int argc, const char **argv) G.background= 1; /* python module mode ALWAYS runs in background mode (for now) */ #else /* for all platforms, even windos has it! */ - if(G.background) signal(SIGINT, blender_esc); /* ctrl c out bg render */ + if (G.background) signal(SIGINT, blender_esc); /* ctrl c out bg render */ #endif /* background render uses this font too */ @@ -1225,7 +1246,7 @@ int main(int argc, const char **argv) init_def_material(); - if(G.background==0) { + if (G.background==0) { BLI_argsParse(ba, 2, NULL, NULL); BLI_argsParse(ba, 3, NULL, NULL); @@ -1286,11 +1307,11 @@ int main(int argc, const char **argv) WM_exit(C); } else { - if((G.fileflags & G_FILE_AUTOPLAY) && (G.f & G_SCRIPT_AUTOEXEC)) { - if(WM_init_game(C)) + if ((G.fileflags & G_FILE_AUTOPLAY) && (G.f & G_SCRIPT_AUTOEXEC)) { + if (WM_init_game(C)) return 0; } - else if(!G.file_loaded) { + else if (!G.file_loaded) { WM_init_splash(C); } } |