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/blender/editors/object | |
parent | 5a90ea77bc1333efe4e1e54984a080550ed3f707 (diff) |
style cleanup: follow style guide for formatting of if/for/while loops, and else if's
Diffstat (limited to 'source/blender/editors/object')
-rw-r--r-- | source/blender/editors/object/object_add.c | 287 | ||||
-rw-r--r-- | source/blender/editors/object/object_bake.c | 286 | ||||
-rw-r--r-- | source/blender/editors/object/object_constraint.c | 24 | ||||
-rw-r--r-- | source/blender/editors/object/object_edit.c | 364 | ||||
-rw-r--r-- | source/blender/editors/object/object_group.c | 24 | ||||
-rw-r--r-- | source/blender/editors/object/object_hook.c | 121 | ||||
-rw-r--r-- | source/blender/editors/object/object_lattice.c | 52 | ||||
-rw-r--r-- | source/blender/editors/object/object_modifier.c | 213 | ||||
-rw-r--r-- | source/blender/editors/object/object_ops.c | 13 | ||||
-rw-r--r-- | source/blender/editors/object/object_relations.c | 332 | ||||
-rw-r--r-- | source/blender/editors/object/object_select.c | 121 | ||||
-rw-r--r-- | source/blender/editors/object/object_shapekey.c | 82 | ||||
-rw-r--r-- | source/blender/editors/object/object_transform.c | 137 | ||||
-rw-r--r-- | source/blender/editors/object/object_vgroup.c | 443 |
14 files changed, 1269 insertions, 1230 deletions
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); |