From e2c453b5f9d3a0a26333b6585f07ebf9e3a24819 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 28 Apr 2012 15:42:27 +0000 Subject: style cleanup: editors / mesh & object --- source/blender/editors/mesh/editmesh_rip.c | 6 +- source/blender/editors/mesh/editmesh_select.c | 2 +- source/blender/editors/mesh/editmesh_slide.c | 14 +- source/blender/editors/mesh/mesh_intern.h | 2 +- source/blender/editors/mesh/mesh_navmesh.c | 2 +- source/blender/editors/object/object_add.c | 681 ++++++++--------- source/blender/editors/object/object_bake.c | 824 ++++++++++---------- source/blender/editors/object/object_constraint.c | 458 +++++------ source/blender/editors/object/object_edit.c | 705 ++++++++--------- source/blender/editors/object/object_group.c | 90 +-- source/blender/editors/object/object_hook.c | 318 ++++---- source/blender/editors/object/object_intern.h | 2 +- source/blender/editors/object/object_lattice.c | 198 ++--- source/blender/editors/object/object_modifier.c | 424 +++++----- source/blender/editors/object/object_ops.c | 42 +- source/blender/editors/object/object_relations.c | 830 ++++++++++---------- source/blender/editors/object/object_select.c | 320 ++++---- source/blender/editors/object/object_shapekey.c | 166 ++-- source/blender/editors/object/object_transform.c | 272 +++---- source/blender/editors/object/object_vgroup.c | 891 +++++++++++----------- 20 files changed, 3125 insertions(+), 3122 deletions(-) (limited to 'source') diff --git a/source/blender/editors/mesh/editmesh_rip.c b/source/blender/editors/mesh/editmesh_rip.c index b490dbe49c8..b74e8797d72 100644 --- a/source/blender/editors/mesh/editmesh_rip.c +++ b/source/blender/editors/mesh/editmesh_rip.c @@ -112,9 +112,9 @@ static float edbm_rip_edge_side_measure(BMEdge *e, BMLoop *e_l, score = len_v2v2(e_v1_co, e_v2_co); if (dist_to_line_segment_v2(fmval_tweak, e_v1_co, e_v2_co) > - dist_to_line_segment_v2(fmval, e_v1_co, e_v2_co)) + dist_to_line_segment_v2(fmval, e_v1_co, e_v2_co)) { - return score; + return score; } else { return -score; @@ -348,7 +348,7 @@ static int edbm_rip_call_edgesplit(BMEditMesh *em, wmOperator *op) BMOperator bmop; if (!EDBM_op_init(em, &bmop, op, "edgesplit edges=%he verts=%hv use_verts=%b", - BM_ELEM_TAG, BM_ELEM_SELECT, TRUE)) { + BM_ELEM_TAG, BM_ELEM_SELECT, TRUE)) { return FALSE; } BMO_op_exec(em->bm, &bmop); diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c index 0a0eb7964f6..32e70e798fe 100644 --- a/source/blender/editors/mesh/editmesh_select.c +++ b/source/blender/editors/mesh/editmesh_select.c @@ -1512,7 +1512,7 @@ int mouse_mesh(bContext *C, const int mval[2], short extend) vc.obedit->actcol = efa->mat_nr + 1; vc.em->mat_nr = efa->mat_nr; - WM_event_add_notifier(C, NC_MATERIAL|ND_SHADING, NULL); + WM_event_add_notifier(C, NC_MATERIAL | ND_SHADING, NULL); } diff --git a/source/blender/editors/mesh/editmesh_slide.c b/source/blender/editors/mesh/editmesh_slide.c index 6c3af98dee9..a82f34a4649 100644 --- a/source/blender/editors/mesh/editmesh_slide.c +++ b/source/blender/editors/mesh/editmesh_slide.c @@ -88,7 +88,7 @@ typedef struct VertexSlideOp { int disk_edges; /* Edges */ - BMEdge** edge_frame; + BMEdge **edge_frame; /* Slide Frame Endpoints */ float (*vtx_frame)[3]; @@ -194,7 +194,7 @@ static void vtx_slide_confirm(bContext *C, wmOperator *op) { VertexSlideOp *vso = op->customdata; BMEditMesh *em = BMEdit_FromObject(vso->obj); - BMesh* bm = em->bm; + BMesh *bm = em->bm; /* Select new edge */ BM_edge_select_set(bm, vso->sel_edge, TRUE); @@ -204,7 +204,7 @@ static void vtx_slide_confirm(bContext *C, wmOperator *op) if (vso->snap_n_merge) { float other_d; - BMVert* other = BM_edge_other_vert(vso->sel_edge, vso->start_vtx); + BMVert *other = BM_edge_other_vert(vso->sel_edge, vso->start_vtx); other_d = len_v3v3(vso->interp, other->co); /* Only snap if within threshold */ @@ -339,12 +339,12 @@ static void vtx_slide_draw(const bContext *C, ARegion *UNUSED(ar), void *arg) } } -static BMEdge* vtx_slide_nrst_in_frame(VertexSlideOp *vso, const float mval[2]) +static BMEdge *vtx_slide_nrst_in_frame(VertexSlideOp *vso, const float mval[2]) { - BMEdge* cl_edge = NULL; + BMEdge *cl_edge = NULL; if (vso->disk_edges > 0) { int i = 0; - BMEdge* edge = NULL; + BMEdge *edge = NULL; float v1_proj[3], v2_proj[3]; float dist = 0; @@ -481,7 +481,7 @@ static int vtx_slide_set_frame(VertexSlideOp *vso) { BMEdge *edge; float (*vtx_frame)[3] = NULL; - BMEdge** edge_frame = NULL; + BMEdge **edge_frame = NULL; BMVert *curr_vert = NULL; BLI_array_declare(vtx_frame); BLI_array_declare(edge_frame); diff --git a/source/blender/editors/mesh/mesh_intern.h b/source/blender/editors/mesh/mesh_intern.h index 70ae9704d3e..b6403f33bc9 100644 --- a/source/blender/editors/mesh/mesh_intern.h +++ b/source/blender/editors/mesh/mesh_intern.h @@ -106,7 +106,7 @@ void MESH_OT_duplicate(struct wmOperatorType *ot); extern int EM_view3d_poll(struct bContext *C); -struct wmKeyMap* knifetool_modal_keymap(struct wmKeyConfig *keyconf); +struct wmKeyMap *knifetool_modal_keymap(struct wmKeyConfig *keyconf); /* ******************* knifetool.c */ diff --git a/source/blender/editors/mesh/mesh_navmesh.c b/source/blender/editors/mesh/mesh_navmesh.c index d9f35aaeedd..43cd89af3ac 100644 --- a/source/blender/editors/mesh/mesh_navmesh.c +++ b/source/blender/editors/mesh/mesh_navmesh.c @@ -430,7 +430,7 @@ static int navmesh_create_exec(bContext *C, wmOperator *op) LinkNode *obs = NULL; Base *navmeshBase = NULL; - CTX_DATA_BEGIN (C, Base*, base, selected_editable_bases) { + CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases) { if (base->object->type == OB_MESH) { if (base->object->body_type == OB_BODY_TYPE_NAVMESH) { if (!navmeshBase || base == scene->basact) { diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index 082b6f6dc93..21c9f776b94 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -111,8 +111,8 @@ void ED_object_location_from_view(bContext *C, float *loc) { - View3D *v3d= CTX_wm_view3d(C); - Scene *scene= CTX_data_scene(C); + View3D *v3d = CTX_wm_view3d(C); + Scene *scene = CTX_data_scene(C); float *cursor; cursor = give_cursor(scene, v3d); @@ -122,11 +122,11 @@ 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); + RegionView3D *rv3d = CTX_wm_region_view3d(C); if (rv3d) { float quat[4]; copy_qt_qt(quat, rv3d->viewquat); - quat[0]= -quat[0]; + quat[0] = -quat[0]; quat_to_eul(rot, quat); } else { @@ -136,8 +136,8 @@ void ED_object_rotation_from_view(bContext *C, float *rot) void ED_object_base_init_transform(bContext *C, Base *base, float *loc, float *rot) { - Object *ob= base->object; - Scene *scene= CTX_data_scene(C); + Object *ob = base->object; + Scene *scene = CTX_data_scene(C); if (!scene) return; @@ -195,19 +195,19 @@ void ED_object_add_generic_props(wmOperatorType *ot, int 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); + "Enter editmode when adding this object"); + RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); } prop = RNA_def_float_vector_xyz(ot->srna, "location", 3, NULL, -FLT_MAX, FLT_MAX, "Location", - "Location for the newly added object", -FLT_MAX, FLT_MAX); + "Location for the newly added object", -FLT_MAX, FLT_MAX); RNA_def_property_flag(prop, PROP_SKIP_SAVE); prop = RNA_def_float_rotation(ot->srna, "rotation", 3, NULL, -FLT_MAX, FLT_MAX, "Rotation", - "Rotation for the newly added object", (float)-M_PI * 2.0f, (float)M_PI * 2.0f); + "Rotation for the newly added object", (float)-M_PI * 2.0f, (float)M_PI * 2.0f); RNA_def_property_flag(prop, PROP_SKIP_SAVE); prop = RNA_def_boolean_layer_member(ot->srna, "layers", 20, NULL, "Layer", ""); - RNA_def_property_flag(prop, PROP_HIDDEN|PROP_SKIP_SAVE); + RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); } static void object_add_generic_invoke_options(bContext *C, wmOperator *op) @@ -229,14 +229,14 @@ static void object_add_generic_invoke_options(bContext *C, wmOperator *op) int a, values[20], layer; if (v3d) { - layer = (v3d->scenelock && !v3d->localvd)? scene->layact: v3d->layact; + layer = (v3d->scenelock && !v3d->localvd) ? scene->layact : v3d->layact; } else { layer = scene->layact; } - for (a=0; a<20; a++) { - values[a]= (layer & (1<ptr, "layers", values); @@ -250,7 +250,7 @@ int ED_object_add_generic_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(ev } int ED_object_add_generic_get_opts(bContext *C, wmOperator *op, float *loc, - float *rot, int *enter_editmode, unsigned int *layer, int *is_view_aligned) + float *rot, int *enter_editmode, unsigned int *layer, int *is_view_aligned) { View3D *v3d = CTX_wm_view3d(C); int a, layer_values[20]; @@ -263,8 +263,8 @@ int ED_object_add_generic_get_opts(bContext *C, wmOperator *op, float *loc, 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++) { + *layer = 0; + for (a = 0; a < 20; a++) { if (layer_values[a]) *layer |= (1 << a); else @@ -314,18 +314,18 @@ int ED_object_add_generic_get_opts(bContext *C, wmOperator *op, float *loc, /* for object add primitive operators */ /* do not call undo push in this function (users of this function have to) */ Object *ED_object_add_type(bContext *C, int type, float *loc, float *rot, - int enter_editmode, unsigned int layer) + int enter_editmode, unsigned int layer) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); Object *ob; /* for as long scene has editmode... */ if (CTX_data_edit_object(C)) - ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR|EM_DO_UNDO); /* freedata, and undo */ + ED_object_exit_editmode(C, EM_FREEDATA | EM_FREEUNDO | EM_WAITCURSOR | EM_DO_UNDO); /* freedata, and undo */ /* deselects all, sets scene->basact */ - ob= add_object(scene, type); + ob = add_object(scene, type); BASACT->lay = ob->lay = layer; /* editor level activate, notifiers */ ED_base_object_activate(C, BASACT); @@ -342,7 +342,7 @@ Object *ED_object_add_type(bContext *C, int type, float *loc, float *rot, if (enter_editmode) ED_object_enter_editmode(C, EM_IGNORE_LAYER); - WM_event_add_notifier(C, NC_SCENE|ND_LAYER_CONTENT, scene); + WM_event_add_notifier(C, NC_SCENE | ND_LAYER_CONTENT, scene); return ob; } @@ -376,7 +376,7 @@ void OBJECT_OT_add(wmOperatorType *ot) ot->poll = ED_operator_objectmode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_enum(ot->srna, "type", object_type_items, 0, "Type", ""); @@ -414,20 +414,20 @@ static Object *effector_add_type(bContext *C, wmOperator *op, int type) if (!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL)) return NULL; - if (type==PFIELD_GUIDE) { - ob= ED_object_add_type(C, OB_CURVE, loc, rot, FALSE, layer); + if (type == PFIELD_GUIDE) { + ob = ED_object_add_type(C, OB_CURVE, loc, rot, FALSE, layer); rename_id(&ob->id, "CurveGuide"); - ((Curve*)ob->data)->flag |= CU_PATH|CU_3D; + ((Curve *)ob->data)->flag |= CU_PATH | CU_3D; ED_object_enter_editmode(C, 0); 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)); + BLI_addtail(object_editcurve_get(ob), add_nurbs_primitive(C, mat, CU_NURBS | CU_PRIM_PATH, 1)); if (!enter_editmode) ED_object_exit_editmode(C, EM_FREEDATA); } else { - ob= ED_object_add_type(C, OB_EMPTY, loc, rot, FALSE, layer); + ob = ED_object_add_type(C, OB_EMPTY, loc, rot, FALSE, layer); rename_id(&ob->id, "Field"); switch (type) { @@ -438,7 +438,7 @@ static Object *effector_add_type(bContext *C, wmOperator *op, int type) } } - ob->pd= object_add_collision_fields(type); + ob->pd = object_add_collision_fields(type); DAG_scene_sort(CTX_data_main(C), CTX_data_scene(C)); @@ -468,7 +468,7 @@ void OBJECT_OT_effector_add(wmOperatorType *ot) ot->poll = ED_operator_objectmode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; ot->prop = RNA_def_enum(ot->srna, "type", field_type_items, 0, "Type", ""); @@ -480,7 +480,7 @@ void OBJECT_OT_effector_add(wmOperatorType *ot) static int object_camera_add_exec(bContext *C, wmOperator *op) { View3D *v3d = CTX_wm_view3d(C); - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); Object *ob; int enter_editmode; unsigned int layer; @@ -494,12 +494,12 @@ static int object_camera_add_exec(bContext *C, wmOperator *op) 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); + ob = ED_object_add_type(C, OB_CAMERA, loc, rot, FALSE, layer); if (v3d) { if (v3d->camera == NULL) v3d->camera = ob; - if (v3d->scenelock && scene->camera==NULL) { + if (v3d->scenelock && scene->camera == NULL) { scene->camera = ob; } } @@ -521,12 +521,12 @@ void OBJECT_OT_camera_add(wmOperatorType *ot) ot->poll = ED_operator_objectmode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; ED_object_add_generic_props(ot, TRUE); /* hide this for cameras, default */ - prop= RNA_struct_type_find_property(ot->srna, "view_align"); + prop = RNA_struct_type_find_property(ot->srna, "view_align"); RNA_def_property_flag(prop, PROP_HIDDEN); } @@ -535,9 +535,9 @@ void OBJECT_OT_camera_add(wmOperatorType *ot) /* ***************** add primitives *************** */ static int object_metaball_add_exec(bContext *C, wmOperator *op) { - Object *obedit= CTX_data_edit_object(C); + Object *obedit = CTX_data_edit_object(C); /*MetaElem *elem;*/ /*UNUSED*/ - int newob= 0; + int newob = 0; int enter_editmode; unsigned int layer; float loc[3], rot[3]; @@ -548,8 +548,8 @@ static int object_metaball_add_exec(bContext *C, wmOperator *op) 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) { - obedit= ED_object_add_type(C, OB_MBALL, loc, rot, TRUE, layer); + if (obedit == NULL || obedit->type != OB_MBALL) { + obedit = ED_object_add_type(C, OB_MBALL, loc, rot, TRUE, layer); newob = 1; } else DAG_id_tag_update(&obedit->id, OB_RECALC_DATA); @@ -563,21 +563,21 @@ static int object_metaball_add_exec(bContext *C, wmOperator *op) ED_object_exit_editmode(C, EM_FREEDATA); } - WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, obedit); + WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, obedit); return OPERATOR_FINISHED; } static int object_metaball_add_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { - Object *obedit= CTX_data_edit_object(C); + Object *obedit = CTX_data_edit_object(C); uiPopupMenu *pup; uiLayout *layout; object_add_generic_invoke_options(C, op); - pup= uiPupMenuBegin(C, op->type->name, ICON_NONE); - layout= uiPupMenuLayout(pup); + pup = uiPupMenuBegin(C, op->type->name, ICON_NONE); + layout = uiPupMenuLayout(pup); if (!obedit || obedit->type == OB_MBALL) uiItemsEnumO(layout, op->type->idname, "type"); else @@ -600,7 +600,7 @@ void OBJECT_OT_metaball_add(wmOperatorType *ot) ot->poll = ED_operator_scene_editable; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_enum(ot->srna, "type", metaelem_type_items, 0, "Primitive", ""); ED_object_add_generic_props(ot, TRUE); @@ -608,7 +608,7 @@ void OBJECT_OT_metaball_add(wmOperatorType *ot) static int object_add_text_exec(bContext *C, wmOperator *op) { - Object *obedit= CTX_data_edit_object(C); + Object *obedit = CTX_data_edit_object(C); int enter_editmode; unsigned int layer; float loc[3], rot[3]; @@ -617,12 +617,12 @@ static int object_add_text_exec(bContext *C, wmOperator *op) 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); + obedit = ED_object_add_type(C, OB_FONT, loc, rot, enter_editmode, layer); - WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, obedit); + WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, obedit); return OPERATOR_FINISHED; } @@ -640,16 +640,16 @@ void OBJECT_OT_text_add(wmOperatorType *ot) ot->poll = ED_operator_objectmode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; ED_object_add_generic_props(ot, TRUE); } static int object_armature_add_exec(bContext *C, wmOperator *op) { - Object *obedit= CTX_data_edit_object(C); - View3D *v3d= CTX_wm_view3d(C); - RegionView3D *rv3d= CTX_wm_region_view3d(C); - int newob= 0; + Object *obedit = CTX_data_edit_object(C); + View3D *v3d = CTX_wm_view3d(C); + RegionView3D *rv3d = CTX_wm_region_view3d(C); + int newob = 0; int enter_editmode; unsigned int layer; float loc[3], rot[3]; @@ -658,14 +658,14 @@ static int object_armature_add_exec(bContext *C, wmOperator *op) 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)) { - obedit= ED_object_add_type(C, OB_ARMATURE, loc, rot, TRUE, layer); + if ((obedit == NULL) || (obedit->type != OB_ARMATURE)) { + obedit = ED_object_add_type(C, OB_ARMATURE, loc, rot, TRUE, layer); ED_object_enter_editmode(C, 0); newob = 1; } 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; } @@ -677,7 +677,7 @@ static int object_armature_add_exec(bContext *C, wmOperator *op) if (newob && !enter_editmode) ED_object_exit_editmode(C, EM_FREEDATA); - WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, obedit); + WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, obedit); return OPERATOR_FINISHED; } @@ -695,7 +695,7 @@ void OBJECT_OT_armature_add(wmOperatorType *ot) ot->poll = ED_operator_objectmode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; ED_object_add_generic_props(ot, TRUE); } @@ -714,10 +714,10 @@ static const char *get_lamp_defname(int type) static int object_lamp_add_exec(bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); Object *ob; Lamp *la; - int type= RNA_enum_get(op->ptr, "type"); + int type = RNA_enum_get(op->ptr, "type"); int enter_editmode; unsigned int layer; float loc[3], rot[3]; @@ -726,16 +726,16 @@ static int object_lamp_add_exec(bContext *C, wmOperator *op) 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); - la= (Lamp*)ob->data; + ob = ED_object_add_type(C, OB_LAMP, loc, rot, FALSE, layer); + la = (Lamp *)ob->data; - la->type= type; + la->type = type; rename_id(&ob->id, get_lamp_defname(type)); rename_id(&la->id, get_lamp_defname(type)); if (scene_use_new_shading_nodes(scene)) { ED_node_shader_default(scene, &la->id); - la->use_nodes= 1; + la->use_nodes = 1; } return OPERATOR_FINISHED; @@ -762,7 +762,7 @@ void OBJECT_OT_lamp_add(wmOperatorType *ot) ot->poll = ED_operator_objectmode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ ot->prop = RNA_def_enum(ot->srna, "type", lamp_type_items, 0, "Type", ""); @@ -772,7 +772,7 @@ void OBJECT_OT_lamp_add(wmOperatorType *ot) static int group_instance_add_exec(bContext *C, wmOperator *op) { - Group *group= BLI_findlink(&CTX_data_main(C)->group, RNA_enum_get(op->ptr, "group")); + Group *group = BLI_findlink(&CTX_data_main(C)->group, RNA_enum_get(op->ptr, "group")); int enter_editmode; unsigned int layer; @@ -783,18 +783,18 @@ static int group_instance_add_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; 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); - rename_id(&ob->id, group->id.name+2); - ob->dup_group= 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); + rename_id(&ob->id, group->id.name + 2); + ob->dup_group = group; ob->transflag |= OB_DUPLIGROUP; id_lib_extern(&group->id); /* works without this except if you try render right after, see: 22027 */ DAG_scene_sort(bmain, scene); - WM_event_add_notifier(C, NC_SCENE|ND_OB_ACTIVE, CTX_data_scene(C)); + WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, CTX_data_scene(C)); return OPERATOR_FINISHED; } @@ -814,7 +814,7 @@ static int object_speaker_add_exec(bContext *C, wmOperator *op) 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); + ob = ED_object_add_type(C, OB_SPEAKER, loc, rot, FALSE, layer); /* to make it easier to start using this immediately in NLA, a default sound clip is created * ready to be moved around to retime the sound and/or make new sound clips @@ -834,7 +834,7 @@ static int object_speaker_add_exec(bContext *C, wmOperator *op) strcpy(nlt->name, "SoundTrack"); BKE_nlastrip_validate_name(adt, strip); - WM_event_add_notifier(C, NC_ANIMATION|ND_NLA|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); } return OPERATOR_FINISHED; @@ -852,7 +852,7 @@ void OBJECT_OT_speaker_add(wmOperatorType *ot) ot->poll = ED_operator_objectmode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; ED_object_add_generic_props(ot, TRUE); } @@ -874,10 +874,10 @@ void OBJECT_OT_group_instance_add(wmOperatorType *ot) ot->poll = ED_operator_objectmode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ - prop= RNA_def_enum(ot->srna, "group", DummyRNA_NULL_items, 0, "Group", ""); + prop = RNA_def_enum(ot->srna, "group", DummyRNA_NULL_items, 0, "Group", ""); RNA_def_enum_funcs(prop, RNA_group_itemf); ot->prop = prop; ED_object_add_generic_props(ot, FALSE); @@ -892,21 +892,21 @@ 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); } static int object_delete_exec(bContext *C, wmOperator *op) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); - const short use_global= RNA_boolean_get(op->ptr, "use_global"); + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + const short use_global = RNA_boolean_get(op->ptr, "use_global"); /* int islamp= 0; */ /* UNUSED */ if (CTX_data_edit_object(C)) return OPERATOR_CANCELLED; - CTX_DATA_BEGIN (C, Base*, base, selected_bases) { + CTX_DATA_BEGIN (C, Base *, base, selected_bases) { /* if (base->object->type==OB_LAMP) islamp= 1; */ @@ -920,9 +920,9 @@ static int object_delete_exec(bContext *C, wmOperator *op) Scene *scene_iter; Base *base_other; - for (scene_iter= bmain->scene.first; scene_iter; scene_iter= scene_iter->id.next) { + for (scene_iter = bmain->scene.first; scene_iter; scene_iter = scene_iter->id.next) { if (scene_iter != scene && !(scene_iter->id.lib)) { - base_other= object_in_scene(base->object, scene_iter); + base_other = object_in_scene(base->object, scene_iter); if (base_other) { ED_base_object_free_and_unlink(bmain, scene_iter, base_other); } @@ -937,8 +937,8 @@ static int object_delete_exec(bContext *C, wmOperator *op) DAG_scene_sort(bmain, scene); DAG_ids_flush_update(bmain, 0); - WM_event_add_notifier(C, NC_SCENE|ND_OB_ACTIVE, scene); - WM_event_add_notifier(C, NC_SCENE|ND_LAYER_CONTENT, scene); + WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene); + WM_event_add_notifier(C, NC_SCENE | ND_LAYER_CONTENT, scene); return OPERATOR_FINISHED; } @@ -956,7 +956,7 @@ void OBJECT_OT_delete(wmOperatorType *ot) ot->poll = ED_operator_objectmode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_boolean(ot->srna, "use_global", 0, "Delete Globally", "Remove object from all scenes"); } @@ -966,81 +966,81 @@ void OBJECT_OT_delete(wmOperatorType *ot) /* after copying objects, copied data should get new pointers */ static void copy_object_set_idnew(bContext *C, int dupflag) { - Main *bmain= CTX_data_main(C); + Main *bmain = CTX_data_main(C); Material *ma, *mao; ID *id; int a; /* XXX check object pointers */ - CTX_DATA_BEGIN (C, Object*, ob, selected_editable_objects) { + CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) { object_relink(ob); } CTX_DATA_END; /* materials */ - if ( dupflag & USER_DUP_MAT) { - mao= bmain->mat.first; + if (dupflag & USER_DUP_MAT) { + mao = bmain->mat.first; while (mao) { if (mao->id.newid) { - ma= (Material *)mao->id.newid; + ma = (Material *)mao->id.newid; if (dupflag & USER_DUP_TEX) { - for (a=0; amtex[a]) { - id= (ID *)ma->mtex[a]->tex; + id = (ID *)ma->mtex[a]->tex; if (id) { ID_NEW_US(ma->mtex[a]->tex) - else ma->mtex[a]->tex= copy_texture(ma->mtex[a]->tex); + else ma->mtex[a]->tex = copy_texture(ma->mtex[a]->tex); id->us--; } } } } #if 0 // XXX old animation system - id= (ID *)ma->ipo; + id = (ID *)ma->ipo; if (id) { ID_NEW_US(ma->ipo) - else ma->ipo= copy_ipo(ma->ipo); + else ma->ipo = copy_ipo(ma->ipo); id->us--; } #endif // XXX old animation system } - mao= mao->id.next; + mao = mao->id.next; } } #if 0 // XXX old animation system - /* lamps */ - if ( dupflag & USER_DUP_IPO) { - Lamp *la= bmain->lamp.first; + /* lamps */ + if (dupflag & USER_DUP_IPO) { + Lamp *la = bmain->lamp.first; while (la) { if (la->id.newid) { - Lamp *lan= (Lamp *)la->id.newid; - id= (ID *)lan->ipo; + Lamp *lan = (Lamp *)la->id.newid; + id = (ID *)lan->ipo; if (id) { ID_NEW_US(lan->ipo) - else lan->ipo= copy_ipo(lan->ipo); + else lan->ipo = copy_ipo(lan->ipo); id->us--; } } - la= la->id.next; + la = la->id.next; } } /* ipos */ - ipo= bmain->ipo.first; + ipo = bmain->ipo.first; while (ipo) { - if (ipo->id.lib==NULL && ipo->id.newid) { - Ipo *ipon= (Ipo *)ipo->id.newid; + 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) { + for (icu = ipon->curve.first; icu; icu = icu->next) { if (icu->driver) { ID_NEW(icu->driver->ob); } } } - ipo= ipo->id.next; + ipo = ipo->id.next; } #endif // XXX old animation system @@ -1057,42 +1057,42 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base, { ListBase *lb; DupliObject *dob; - GHash *dupli_gh= NULL, *parent_gh= NULL; + GHash *dupli_gh = NULL, *parent_gh = NULL; if (!(base->object->transflag & OB_DUPLI)) return; - lb= object_duplilist(scene, base->object); + lb = object_duplilist(scene, base->object); 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"); + 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); + 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); - ob->flag= basen->flag; - basen->lay= base->lay; - BLI_addhead(&scene->base, basen); /* addhead: othwise eternal loop */ - basen->object= ob; + basen = MEM_dupallocN(base); + basen->flag &= ~(OB_FROMDUPLI | OB_FROMGROUP); + ob->flag = basen->flag; + basen->lay = base->lay; + BLI_addhead(&scene->base, basen); /* addhead: othwise eternal loop */ + basen->object = ob; /* make sure apply works */ BKE_free_animdata(&ob->id); ob->adt = NULL; - ob->parent= NULL; - ob->constraints.first= ob->constraints.last= NULL; - ob->disp.first= ob->disp.last= NULL; + ob->parent = NULL; + ob->constraints.first = ob->constraints.last = NULL; + ob->disp.first = ob->disp.last = NULL; ob->transflag &= ~OB_DUPLI; - ob->lay= base->lay; + ob->lay = base->lay; copy_m4_m4(ob->obmat, dob->mat); object_apply_mat4(ob, ob->obmat, FALSE, FALSE); @@ -1104,13 +1104,13 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base, } 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; + Object *ob_src = dob->ob; + Object *ob_src_par = ob_src->parent; - Object *ob_dst= BLI_ghash_lookup(dupli_gh, dob); - Object *ob_dst_par= NULL; + Object *ob_dst = BLI_ghash_lookup(dupli_gh, dob); + Object *ob_dst_par = NULL; /* find parent that was also made real */ if (ob_src_par) { @@ -1121,19 +1121,19 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base, if (ob_dst_par) { /* allow for all possible parent types */ - ob_dst->partype= ob_src->partype; + ob_dst->partype = ob_src->partype; BLI_strncpy(ob_dst->parsubstr, ob_src->parsubstr, sizeof(ob_dst->parsubstr)); - ob_dst->par1= ob_src->par1; - ob_dst->par2= ob_src->par2; - ob_dst->par3= ob_src->par3; + ob_dst->par1 = ob_src->par1; + ob_dst->par2 = ob_src->par2; + ob_dst->par3 = ob_src->par3; copy_m4_m4(ob_dst->parentinv, ob_src->parentinv); - ob_dst->parent= ob_dst_par; + ob_dst->parent = ob_dst_par; } else if (use_base_parent) { - ob_dst->parent= base->object; - ob_dst->partype= PAROBJECT; + ob_dst->parent = base->object; + ob_dst->partype = PAROBJECT; } if (ob_dst->parent) { @@ -1151,12 +1151,12 @@ 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); + Object *ob_dst = BLI_ghash_lookup(dupli_gh, dob); - ob_dst->parent= base->object; - ob_dst->partype= PAROBJECT; + ob_dst->parent = base->object; + ob_dst->partype = PAROBJECT; /* similer to the code above, see comments */ invert_m4_m4(ob_dst->parentinv, dob->mat); @@ -1181,26 +1181,26 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base, static int object_duplicates_make_real_exec(bContext *C, wmOperator *op) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); - const short use_base_parent= RNA_boolean_get(op->ptr, "use_base_parent"); - const short use_hierarchy= RNA_boolean_get(op->ptr, "use_hierarchy"); + const short use_base_parent = RNA_boolean_get(op->ptr, "use_base_parent"); + const short use_hierarchy = RNA_boolean_get(op->ptr, "use_hierarchy"); clear_id_newpoins(); - CTX_DATA_BEGIN (C, Base*, base, selected_editable_bases) { + CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases) { make_object_duplilist_real(C, scene, base, use_base_parent, use_hierarchy); /* dependencies were changed */ - WM_event_add_notifier(C, NC_OBJECT|ND_PARENT, base->object); + WM_event_add_notifier(C, NC_OBJECT | ND_PARENT, base->object); } CTX_DATA_END; DAG_scene_sort(bmain, scene); DAG_ids_flush_update(bmain, 0); WM_event_add_notifier(C, NC_SCENE, scene); - WM_main_add_notifier(NC_OBJECT|ND_DRAW, NULL); + WM_main_add_notifier(NC_OBJECT | ND_DRAW, NULL); return OPERATOR_FINISHED; } @@ -1219,7 +1219,7 @@ void OBJECT_OT_duplicates_make_real(wmOperatorType *ot) ot->poll = ED_operator_objectmode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_boolean(ot->srna, "use_base_parent", 0, "Parent", "Parent newly created objects to the original duplicator"); RNA_def_boolean(ot->srna, "use_hierarchy", 0, "Keep Hierarchy", "Maintain parent child relationships"); @@ -1227,15 +1227,16 @@ void OBJECT_OT_duplicates_make_real(wmOperatorType *ot) /**************************** Convert **************************/ -static EnumPropertyItem convert_target_items[]= { +static EnumPropertyItem convert_target_items[] = { {OB_CURVE, "CURVE", ICON_OUTLINER_OB_CURVE, "Curve from Mesh/Text", ""}, {OB_MESH, "MESH", ICON_OUTLINER_OB_MESH, "Mesh from Curve/Meta/Surf/Text", ""}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} +}; static void curvetomesh(Scene *scene, Object *ob) { if (ob->disp.first == NULL) - makeDispListCurveTypes(scene, ob, 0); /* force creation */ + makeDispListCurveTypes(scene, ob, 0); /* force creation */ nurbs_to_mesh(ob); /* also does users */ @@ -1245,8 +1246,8 @@ static void curvetomesh(Scene *scene, Object *ob) static int convert_poll(bContext *C) { - Object *obact= CTX_data_active_object(C); - Scene *scene= CTX_data_scene(C); + Object *obact = CTX_data_active_object(C); + Scene *scene = CTX_data_scene(C); return (!scene->id.lib && obact && scene->obedit != obact && (obact->flag & SELECT) && !(obact->id.lib)); } @@ -1258,16 +1259,16 @@ static Base *duplibase_for_convert(Scene *scene, Base *base, Object *ob) Base *basen; if (ob == NULL) { - ob= base->object; + ob = base->object; } - obn= copy_object(ob); - obn->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; + obn = copy_object(ob); + obn->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME; - basen= MEM_mallocN(sizeof(Base), "duplibase"); - *basen= *base; - BLI_addhead(&scene->base, basen); /* addhead: otherwise eternal loop */ - basen->object= obn; + basen = MEM_mallocN(sizeof(Base), "duplibase"); + *basen = *base; + BLI_addhead(&scene->base, basen); /* addhead: otherwise eternal loop */ + basen->object = obn; basen->flag |= SELECT; obn->flag |= SELECT; base->flag &= ~SELECT; @@ -1278,24 +1279,24 @@ static Base *duplibase_for_convert(Scene *scene, Base *base, Object *ob) static int convert_exec(bContext *C, wmOperator *op) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); - Base *basen=NULL, *basact=NULL, *basedel=NULL; - Object *ob, *ob1, *newob, *obact= CTX_data_active_object(C); + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + Base *basen = NULL, *basact = NULL, *basedel = NULL; + Object *ob, *ob1, *newob, *obact = CTX_data_active_object(C); DerivedMesh *dm; Curve *cu; Nurb *nu; MetaBall *mb; Mesh *me; - const short target= RNA_enum_get(op->ptr, "target"); - const short keep_original= RNA_boolean_get(op->ptr, "keep_original"); - int a, mballConverted= 0; + const short target = RNA_enum_get(op->ptr, "target"); + const short keep_original = RNA_boolean_get(op->ptr, "keep_original"); + int a, mballConverted = 0; /* don't forget multiple users! */ /* reset flags */ - CTX_DATA_BEGIN (C, Base*, base, selected_editable_bases) { - ob= base->object; + CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases) { + ob = base->object; ob->flag &= ~OB_DONE; /* flag data thats not been edited (only needed for !keep_original) */ @@ -1305,8 +1306,8 @@ static int convert_exec(bContext *C, wmOperator *op) } CTX_DATA_END; - CTX_DATA_BEGIN (C, Base*, base, selected_editable_bases) { - ob= base->object; + CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases) { + ob = base->object; if (ob->flag & OB_DONE || !IS_TAGGED(ob->data)) { if (ob->type != target) { @@ -1319,23 +1320,23 @@ static int convert_exec(bContext *C, wmOperator *op) /* 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) { - object_free_modifiers(ob); /* after derivedmesh calls! */ + object_free_modifiers(ob); /* after derivedmesh calls! */ } } } - else if (ob->type==OB_MESH && target == OB_CURVE) { + else if (ob->type == OB_MESH && target == OB_CURVE) { ob->flag |= OB_DONE; if (keep_original) { - basen= duplibase_for_convert(scene, base, NULL); - newob= basen->object; + basen = duplibase_for_convert(scene, base, NULL); + newob = basen->object; /* decrement original mesh's usage count */ - me= newob->data; + me = newob->data; me->id.us--; /* make a new copy of the mesh */ - newob->data= copy_mesh(me); + newob->data = copy_mesh(me); } else { newob = ob; @@ -1343,33 +1344,33 @@ static int convert_exec(bContext *C, wmOperator *op) mesh_to_curve(scene, newob); - if (newob->type==OB_CURVE) - object_free_modifiers(newob); /* after derivedmesh calls! */ + 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) { - basen= duplibase_for_convert(scene, base, NULL); - newob= basen->object; + basen = duplibase_for_convert(scene, base, NULL); + newob = basen->object; /* decrement original mesh's usage count */ - me= newob->data; + me = newob->data; me->id.us--; /* make a new copy of the mesh */ - newob->data= copy_mesh(me); + newob->data = copy_mesh(me); } else { newob = ob; - ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; + ob->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME; } /* make new mesh data from the original copy */ /* note: get the mesh from the original, not from the copy in some * cases this doesnt give correct results (when MDEF is used for eg) */ - dm= mesh_get_derived_final(scene, newob, CD_MASK_MESH); + dm = mesh_get_derived_final(scene, newob, CD_MASK_MESH); /* dm= mesh_create_derived_no_deform(ob1, NULL); this was called original (instead of get_derived). man o man why! (ton) */ DM_to_mesh(dm, newob->data, newob); @@ -1377,64 +1378,64 @@ static int convert_exec(bContext *C, wmOperator *op) /* re-tessellation is called by DM_to_mesh */ dm->release(dm); - object_free_modifiers(newob); /* after derivedmesh calls! */ + 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) { - basen= duplibase_for_convert(scene, base, NULL); - newob= basen->object; + basen = duplibase_for_convert(scene, base, NULL); + newob = basen->object; /* decrement original curve's usage count */ ((Curve *)newob->data)->id.us--; /* make a new copy of the curve */ - newob->data= copy_curve(ob->data); + newob->data = copy_curve(ob->data); } else { - newob= ob; + newob = ob; } - cu= newob->data; + cu = newob->data; if (!newob->disp.first) makeDispListCurveTypes(scene, newob, 0); - newob->type= OB_CURVE; - cu->type= OB_CURVE; + newob->type = OB_CURVE; + cu->type = OB_CURVE; if (cu->vfont) { cu->vfont->id.us--; - cu->vfont= NULL; + cu->vfont = NULL; } if (cu->vfontb) { cu->vfontb->id.us--; - cu->vfontb= NULL; + cu->vfontb = NULL; } if (cu->vfonti) { cu->vfonti->id.us--; - cu->vfonti= NULL; + cu->vfonti = NULL; } if (cu->vfontbi) { cu->vfontbi->id.us--; - cu->vfontbi= NULL; + 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) { - ob1->type= OB_CURVE; - ob1->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; + 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; } } } } - for (nu=cu->nurb.first; nu; nu=nu->next) - nu->charidx= 0; + for (nu = cu->nurb.first; nu; nu = nu->next) + nu->charidx = 0; if (target == OB_MESH) { curvetomesh(scene, newob); @@ -1448,17 +1449,17 @@ static int convert_exec(bContext *C, wmOperator *op) if (target == OB_MESH) { if (keep_original) { - basen= duplibase_for_convert(scene, base, NULL); - newob= basen->object; + basen = duplibase_for_convert(scene, base, NULL); + newob = basen->object; /* decrement original curve's usage count */ ((Curve *)newob->data)->id.us--; /* make a new copy of the curve */ - newob->data= copy_curve(ob->data); + newob->data = copy_curve(ob->data); } else { - newob= ob; + newob = ob; /* meshes doesn't use displist */ freedisplist(&newob->disp); @@ -1467,13 +1468,13 @@ 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; ob->flag &= ~SELECT; - baseob= find_basis_mball(scene, ob); + baseob = find_basis_mball(scene, ob); if (ob != baseob) { /* if motherball is converting it would be marked as done later */ @@ -1487,29 +1488,29 @@ static int convert_exec(bContext *C, wmOperator *op) if (!(baseob->flag & OB_DONE)) { baseob->flag |= OB_DONE; - basen= duplibase_for_convert(scene, base, baseob); - newob= basen->object; + basen = duplibase_for_convert(scene, base, baseob); + newob = basen->object; - mb= newob->data; + mb = newob->data; mb->id.us--; - newob->data= add_mesh("Mesh"); - newob->type= OB_MESH; + newob->data = add_mesh("Mesh"); + newob->type = OB_MESH; - me= newob->data; - me->totcol= mb->totcol; + me = newob->data; + me->totcol = mb->totcol; if (newob->totcol) { - me->mat= MEM_dupallocN(mb->mat); - for (a=0; atotcol; a++) id_us_plus((ID *)me->mat[a]); + me->mat = MEM_dupallocN(mb->mat); + for (a = 0; a < newob->totcol; a++) id_us_plus((ID *)me->mat[a]); } mball_to_mesh(&baseob->disp, newob->data); if (obact->type == OB_MBALL) { - basact= basen; + basact = basen; } - mballConverted= 1; + mballConverted = 1; } } else { @@ -1522,10 +1523,10 @@ static int convert_exec(bContext *C, wmOperator *op) if (basen) { if (ob == obact) { /* store new active base to update BASACT */ - basact= basen; + basact = basen; } - basen= NULL; + basen = NULL; } if (!keep_original && (ob->flag & OB_DONE)) { @@ -1545,11 +1546,11 @@ static int convert_exec(bContext *C, wmOperator *op) if (!keep_original) { if (mballConverted) { - Base *base= scene->base.first, *tmpbase; + Base *base = scene->base.first, *tmpbase; while (base) { - ob= base->object; - tmpbase= base; - base= base->next; + ob = base->object; + tmpbase = base; + base = base->next; if (ob->type == OB_MBALL) { ED_base_object_free_and_unlink(bmain, scene, tmpbase); @@ -1567,16 +1568,16 @@ static int convert_exec(bContext *C, wmOperator *op) if (basact) { /* active base was changed */ ED_base_object_activate(C, basact); - BASACT= basact; + BASACT = basact; } 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); + WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, BASACT->object); + WM_event_add_notifier(C, NC_OBJECT | ND_DATA, BASACT->object); } DAG_scene_sort(bmain, scene); - WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, scene); - WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); + WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, scene); + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); return OPERATOR_FINISHED; } @@ -1595,7 +1596,7 @@ void OBJECT_OT_convert(wmOperatorType *ot) ot->poll = convert_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ ot->prop = RNA_def_enum(ot->srna, "target", convert_target_items, OB_MESH, "Target", "Type of object to convert to"); @@ -1614,28 +1615,28 @@ void OBJECT_OT_convert(wmOperatorType *ot) /* leaves selection of base/object unaltered */ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base, int dupflag) { - Base *basen= NULL; + Base *basen = NULL; Material ***matarar; Object *ob, *obn; ID *id; int a, didit; - ob= base->object; + ob = base->object; if (ob->mode & OB_MODE_POSE) { ; /* nothing? */ } else { - obn= copy_object(ob); - obn->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; + obn = copy_object(ob); + obn->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME; - basen= MEM_mallocN(sizeof(Base), "duplibase"); - *basen= *base; - BLI_addhead(&scene->base, basen); /* addhead: prevent eternal loop */ - basen->object= obn; + basen = MEM_mallocN(sizeof(Base), "duplibase"); + *basen = *base; + BLI_addhead(&scene->base, basen); /* addhead: prevent eternal loop */ + basen->object = obn; if (basen->flag & OB_FROMGROUP) { Group *group; - for (group= bmain->group.first; group; group= group->id.next) { + for (group = bmain->group.first; group; group = group->id.next) { if (object_in_group(ob, group)) add_to_group(group, obn, scene, basen); } @@ -1647,11 +1648,11 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base } if (dupflag & USER_DUP_MAT) { - for (a=0; atotcol; a++) { - id= (ID *)obn->mat[a]; + for (a = 0; a < obn->totcol; a++) { + id = (ID *)obn->mat[a]; if (id) { ID_NEW_US(obn->mat[a]) - else obn->mat[a]= copy_material(obn->mat[a]); + else obn->mat[a] = copy_material(obn->mat[a]); id->us--; if (dupflag & USER_DUP_ACT) { @@ -1662,11 +1663,11 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base } if (dupflag & USER_DUP_PSYS) { ParticleSystem *psys; - for (psys=obn->particlesystem.first; psys; psys=psys->next) { - id= (ID*) psys->part; + for (psys = obn->particlesystem.first; psys; psys = psys->next) { + id = (ID *) psys->part; if (id) { ID_NEW_US(psys->part) - else psys->part= psys_copy_settings(psys->part); + else psys->part = psys_copy_settings(psys->part); if (dupflag & USER_DUP_ACT) { BKE_copy_animdata_id_action(&psys->part->id); @@ -1677,71 +1678,71 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base } } - id= obn->data; - didit= 0; + id = obn->data; + didit = 0; switch (obn->type) { case OB_MESH: if (dupflag & USER_DUP_MESH) { - ID_NEW_US2( obn->data ) + ID_NEW_US2(obn->data) else { - obn->data= copy_mesh(obn->data); + obn->data = copy_mesh(obn->data); if (obn->fluidsimSettings) { obn->fluidsimSettings->orgMesh = (Mesh *)obn->data; } - didit= 1; + didit = 1; } id->us--; } break; case OB_CURVE: if (dupflag & USER_DUP_CURVE) { - ID_NEW_US2(obn->data ) + ID_NEW_US2(obn->data) else { - obn->data= copy_curve(obn->data); - didit= 1; + obn->data = copy_curve(obn->data); + didit = 1; } id->us--; } break; case OB_SURF: if (dupflag & USER_DUP_SURF) { - ID_NEW_US2( obn->data ) + ID_NEW_US2(obn->data) else { - obn->data= copy_curve(obn->data); - didit= 1; + obn->data = copy_curve(obn->data); + didit = 1; } id->us--; } break; case OB_FONT: if (dupflag & USER_DUP_FONT) { - ID_NEW_US2( obn->data ) + ID_NEW_US2(obn->data) else { - obn->data= copy_curve(obn->data); - didit= 1; + obn->data = copy_curve(obn->data); + didit = 1; } id->us--; } break; case OB_MBALL: if (dupflag & USER_DUP_MBALL) { - ID_NEW_US2(obn->data ) + ID_NEW_US2(obn->data) else { - obn->data= copy_mball(obn->data); - didit= 1; + obn->data = copy_mball(obn->data); + didit = 1; } id->us--; } break; case OB_LAMP: if (dupflag & USER_DUP_LAMP) { - ID_NEW_US2(obn->data ) + ID_NEW_US2(obn->data) else { - obn->data= copy_lamp(obn->data); - didit= 1; + obn->data = copy_lamp(obn->data); + didit = 1; } id->us--; } @@ -1751,44 +1752,44 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base obn->recalc |= OB_RECALC_DATA; if (obn->pose) obn->pose->flag |= POSE_RECALC; - if (dupflag & USER_DUP_ARM) { - ID_NEW_US2(obn->data ) - else { - obn->data= copy_armature(obn->data); - armature_rebuild_pose(obn, obn->data); - didit= 1; - } - id->us--; + if (dupflag & USER_DUP_ARM) { + ID_NEW_US2(obn->data) + else { + obn->data = copy_armature(obn->data); + armature_rebuild_pose(obn, obn->data); + didit = 1; } + id->us--; + } - break; + break; case OB_LATTICE: - if (dupflag!=0) { - ID_NEW_US2(obn->data ) + if (dupflag != 0) { + ID_NEW_US2(obn->data) else { - obn->data= copy_lattice(obn->data); - didit= 1; + obn->data = copy_lattice(obn->data); + didit = 1; } id->us--; } break; case OB_CAMERA: - if (dupflag!=0) { - ID_NEW_US2(obn->data ) + if (dupflag != 0) { + ID_NEW_US2(obn->data) else { - obn->data= copy_camera(obn->data); - didit= 1; + obn->data = copy_camera(obn->data); + didit = 1; } id->us--; } break; case OB_SPEAKER: - if (dupflag!=0) { - ID_NEW_US2(obn->data ) + if (dupflag != 0) { + ID_NEW_US2(obn->data) else { - obn->data= copy_speaker(obn->data); - didit= 1; + obn->data = copy_speaker(obn->data); + didit = 1; } id->us--; } @@ -1805,13 +1806,13 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base BKE_copy_animdata_id_action((ID *)obn->data); if (key) { - BKE_copy_animdata_id_action((ID*)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) { - bActionActuator* actact = (bActionActuator*) act->data; + bActionActuator *actact = (bActionActuator *) act->data; if (ob->adt && actact->act == ob->adt->action) { actact->act = obn->adt->action; } @@ -1820,13 +1821,13 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base } if (dupflag & USER_DUP_MAT) { - matarar= give_matarar(obn); + matarar = give_matarar(obn); if (matarar) { - for (a=0; atotcol; a++) { - id= (ID *)(*matarar)[a]; + for (a = 0; a < obn->totcol; a++) { + id = (ID *)(*matarar)[a]; if (id) { - ID_NEW_US( (*matarar)[a] ) - else (*matarar)[a]= copy_material((*matarar)[a]); + ID_NEW_US( (*matarar)[a]) + else (*matarar)[a] = copy_material((*matarar)[a]); id->us--; } @@ -1847,14 +1848,14 @@ Base *ED_object_add_duplicate(Main *bmain, Scene *scene, Base *base, int dupflag Object *ob; clear_id_newpoins(); - clear_sca_new_poins(); /* sensor/contr/act */ + clear_sca_new_poins(); /* sensor/contr/act */ - basen= object_add_duplicate_internal(bmain, scene, base, dupflag); + basen = object_add_duplicate_internal(bmain, scene, base, dupflag); if (basen == NULL) { return NULL; } - ob= basen->object; + ob = basen->object; /* link own references to the newly duplicated data [#26816] */ object_relink(ob); @@ -1871,16 +1872,16 @@ Base *ED_object_add_duplicate(Main *bmain, Scene *scene, Base *base, int dupflag /* contextual operator dupli */ static int duplicate_exec(bContext *C, wmOperator *op) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); - int linked= RNA_boolean_get(op->ptr, "linked"); - int dupflag= (linked)? 0: U.dupflag; + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + int linked = RNA_boolean_get(op->ptr, "linked"); + int dupflag = (linked) ? 0 : U.dupflag; clear_id_newpoins(); - clear_sca_new_poins(); /* sensor/contr/act */ + clear_sca_new_poins(); /* sensor/contr/act */ - CTX_DATA_BEGIN (C, Base*, base, selected_editable_bases) { - Base *basen= object_add_duplicate_internal(bmain, scene, base, dupflag); + CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases) { + Base *basen = object_add_duplicate_internal(bmain, scene, base, dupflag); /* note that this is safe to do with this context iterator, * the list is made in advance */ @@ -1891,7 +1892,7 @@ 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) { @@ -1905,7 +1906,7 @@ static int duplicate_exec(bContext *C, wmOperator *op) DAG_scene_sort(bmain, scene); DAG_ids_flush_update(bmain, 0); - WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); return OPERATOR_FINISHED; } @@ -1924,11 +1925,11 @@ void OBJECT_OT_duplicate(wmOperatorType *ot) ot->poll = ED_operator_objectmode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* to give to transform */ RNA_def_boolean(ot->srna, "linked", 0, "Linked", "Duplicate object but not object data, linking to the original data"); - prop= RNA_def_enum(ot->srna, "mode", transform_mode_types, TFM_TRANSLATION, "Mode", ""); + prop = RNA_def_enum(ot->srna, "mode", transform_mode_types, TFM_TRANSLATION, "Mode", ""); RNA_def_property_flag(prop, PROP_HIDDEN); } @@ -1937,36 +1938,36 @@ void OBJECT_OT_duplicate(wmOperatorType *ot) static int add_named_exec(bContext *C, wmOperator *op) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); Base *basen, *base; Object *ob; - int linked= RNA_boolean_get(op->ptr, "linked"); - int dupflag= (linked)? 0: U.dupflag; - char name[MAX_ID_NAME-2]; + int linked = RNA_boolean_get(op->ptr, "linked"); + int dupflag = (linked) ? 0 : U.dupflag; + char name[MAX_ID_NAME - 2]; /* find object, create fake base */ RNA_string_get(op->ptr, "name", name); - ob= (Object *)find_id("OB", name); - if (ob==NULL) + ob = (Object *)find_id("OB", name); + if (ob == NULL) return OPERATOR_CANCELLED; - base= MEM_callocN(sizeof(Base), "duplibase"); - base->object= ob; - base->flag= ob->flag; + base = MEM_callocN(sizeof(Base), "duplibase"); + base->object = ob; + base->flag = ob->flag; /* prepare dupli */ clear_id_newpoins(); - clear_sca_new_poins(); /* sensor/contr/act */ + clear_sca_new_poins(); /* sensor/contr/act */ - basen= object_add_duplicate_internal(bmain, scene, base, dupflag); + basen = object_add_duplicate_internal(bmain, scene, base, dupflag); if (basen == NULL) { MEM_freeN(base); return OPERATOR_CANCELLED; } - basen->lay= basen->object->lay= scene->lay; + basen->lay = basen->object->lay = scene->lay; ED_object_location_from_view(C, basen->object->loc); ED_base_object_activate(C, basen); @@ -1978,7 +1979,7 @@ static int add_named_exec(bContext *C, wmOperator *op) MEM_freeN(base); - WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); return OPERATOR_FINISHED; } @@ -1995,10 +1996,10 @@ void OBJECT_OT_add_named(wmOperatorType *ot) ot->poll = ED_operator_objectmode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_boolean(ot->srna, "linked", 0, "Linked", "Duplicate object but not object data, linking to the original data"); - RNA_def_string(ot->srna, "name", "Cube", MAX_ID_NAME-2, "Name", "Object name to add"); + RNA_def_string(ot->srna, "name", "Cube", MAX_ID_NAME - 2, "Name", "Object name to add"); } @@ -2006,7 +2007,7 @@ void OBJECT_OT_add_named(wmOperatorType *ot) /**************************** Join *************************/ static int join_poll(bContext *C) { - Object *ob= CTX_data_active_object(C); + Object *ob = CTX_data_active_object(C); if (!ob || ob->id.lib) return 0; @@ -2019,8 +2020,8 @@ static int join_poll(bContext *C) static int join_exec(bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); - Object *ob= CTX_data_active_object(C); + Scene *scene = CTX_data_scene(C); + Object *ob = CTX_data_active_object(C); if (scene->obedit) { BKE_report(op->reports, RPT_ERROR, "This data does not support joining in editmode"); @@ -2053,13 +2054,13 @@ void OBJECT_OT_join(wmOperatorType *ot) ot->poll = join_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /**************************** Join as Shape Key*************************/ static int join_shapes_poll(bContext *C) { - Object *ob= CTX_data_active_object(C); + Object *ob = CTX_data_active_object(C); if (!ob || ob->id.lib) return 0; @@ -2072,8 +2073,8 @@ static int join_shapes_poll(bContext *C) static int join_shapes_exec(bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); - Object *ob= CTX_data_active_object(C); + Scene *scene = CTX_data_scene(C); + Object *ob = CTX_data_active_object(C); if (scene->obedit) { BKE_report(op->reports, RPT_ERROR, "This data does not support joining in editmode"); @@ -2102,5 +2103,5 @@ void OBJECT_OT_join_shapes(wmOperatorType *ot) ot->poll = join_shapes_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } diff --git a/source/blender/editors/object/object_bake.c b/source/blender/editors/object/object_bake.c index dffcaad42fd..9e8381a72c6 100644 --- a/source/blender/editors/object/object_bake.c +++ b/source/blender/editors/object/object_bake.c @@ -115,9 +115,9 @@ typedef void (*MPassKnownData)(DerivedMesh *lores_dm, DerivedMesh *hires_dm, con const int face_index, const int lvl, const float st[2], float tangmat[3][3], const int x, const int y); -typedef void* (*MInitBakeData)(MultiresBakeRender *bkr, Image* ima); -typedef void (*MApplyBakeData)(void *bake_data); -typedef void (*MFreeBakeData)(void *bake_data); +typedef void * (*MInitBakeData)(MultiresBakeRender *bkr, Image *ima); +typedef void (*MApplyBakeData)(void *bake_data); +typedef void (*MFreeBakeData)(void *bake_data); typedef struct { MVert *mvert; @@ -157,25 +157,25 @@ typedef struct { static void multiresbake_get_normal(const MResolvePixelData *data, float norm[], const int face_num, const int vert_index) { - unsigned int indices[]= {data->mface[face_num].v1, data->mface[face_num].v2, - data->mface[face_num].v3, data->mface[face_num].v4}; - const int smoothnormal= (data->mface[face_num].flag & ME_SMOOTH); + unsigned int indices[] = {data->mface[face_num].v1, data->mface[face_num].v2, + 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) { - copy_v3_v3(norm, &data->precomputed_normals[3*face_num]); + copy_v3_v3(norm, &data->precomputed_normals[3 * face_num]); } else { float nor[3]; float *p0, *p1, *p2; - const int iGetNrVerts= data->mface[face_num].v4!=0 ? 4 : 3; + const int iGetNrVerts = data->mface[face_num].v4 != 0 ? 4 : 3; - p0= data->mvert[indices[0]].co; - p1= data->mvert[indices[1]].co; - p2= data->mvert[indices[2]].co; + p0 = data->mvert[indices[0]].co; + p1 = data->mvert[indices[1]].co; + p2 = data->mvert[indices[2]].co; - if (iGetNrVerts==4) { - float *p3= data->mvert[indices[3]].co; + if (iGetNrVerts == 4) { + float *p3 = data->mvert[indices[3]].co; normal_quad_v3(nor, p0, p1, p2, p3); } else { @@ -186,7 +186,7 @@ static void multiresbake_get_normal(const MResolvePixelData *data, float norm[], } } else { - short *no= data->mvert[indices[vert_index]].no; + short *no = data->mvert[indices[vert_index]].no; normal_short_to_float_v3(norm, no); normalize_v3(norm); @@ -198,15 +198,15 @@ static void init_bake_rast(MBakeRast *bake_rast, const ImBuf *ibuf, const MResol memset(bake_rast, 0, sizeof(MBakeRast)); bake_rast->texels = ibuf->userdata; - bake_rast->w= ibuf->x; - bake_rast->h= ibuf->y; - bake_rast->data= data; - bake_rast->flush_pixel= flush_pixel; + bake_rast->w = ibuf->x; + bake_rast->h = ibuf->y; + bake_rast->data = data; + bake_rast->flush_pixel = flush_pixel; } static void flush_pixel(const MResolvePixelData *data, const int x, const int y) { - float st[2]= {(x+0.5f)/data->w, (y+0.5f)/data->h}; + float st[2] = {(x + 0.5f) / data->w, (y + 0.5f) / data->h}; float *st0, *st1, *st2; float *tang0, *tang1, *tang2; float no0[3], no1[3], no2[3]; @@ -214,37 +214,37 @@ static void flush_pixel(const MResolvePixelData *data, const int x, const int y) float u, v, w, sign; int r; - const int i0= data->i0; - const int i1= data->i1; - const int i2= data->i2; + const int i0 = data->i0; + const int i1 = data->i1; + const int i2 = data->i2; - st0= data->mtface[data->face_index].uv[i0]; - st1= data->mtface[data->face_index].uv[i1]; - st2= data->mtface[data->face_index].uv[i2]; + st0 = data->mtface[data->face_index].uv[i0]; + st1 = data->mtface[data->face_index].uv[i1]; + st2 = data->mtface[data->face_index].uv[i2]; - tang0= data->pvtangent + data->face_index*16 + i0*4; - tang1= data->pvtangent + data->face_index*16 + i1*4; - tang2= data->pvtangent + data->face_index*16 + i2*4; + tang0 = data->pvtangent + data->face_index * 16 + i0 * 4; + tang1 = data->pvtangent + data->face_index * 16 + i1 * 4; + tang2 = data->pvtangent + data->face_index * 16 + i2 * 4; - multiresbake_get_normal(data, no0, data->face_index, i0); /* can optimize these 3 into one call */ + multiresbake_get_normal(data, no0, data->face_index, i0); /* can optimize these 3 into one call */ multiresbake_get_normal(data, no1, data->face_index, i1); multiresbake_get_normal(data, no2, data->face_index, i2); resolve_tri_uv(fUV, st, st0, st1, st2); - u= fUV[0]; - v= fUV[1]; - w= 1-u-v; + u = fUV[0]; + v = fUV[1]; + w = 1 - u - v; /* the sign is the same at all face vertices for any non degenerate face. * Just in case we clamp the interpolated value though. */ - sign= (tang0[3]*u + tang1[3]*v + tang2[3]*w)<0 ? (-1.0f) : 1.0f; + sign = (tang0[3] * u + tang1[3] * v + tang2[3] * w) < 0 ? (-1.0f) : 1.0f; /* 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++) { - 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; + 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; } cross_v3_v3v3(from_tang[1], from_tang[2], from_tang[0]); /* B = sign * cross(N, T) */ @@ -258,13 +258,13 @@ static void flush_pixel(const MResolvePixelData *data, const int x, const int y) static void set_rast_triangle(const MBakeRast *bake_rast, const int x, const int y) { - const int w= bake_rast->w; - const int h= bake_rast->h; + const int w = bake_rast->w; + const int h = bake_rast->h; - if (x>=0 && x=0 && ytexels[y*w+x])==0) { + if (x >= 0 && x < 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; + bake_rast->texels[y * w + x] = FILTER_MASK_USED; } } } @@ -274,35 +274,35 @@ static void rasterize_half(const MBakeRast *bake_rast, const float s0_l, const float t0_l, const float s1_l, const float t1_l, const int y0_in, const int y1_in, const int is_mid_right) { - const int s_stable= fabsf(t1_s-t0_s)>FLT_EPSILON ? 1 : 0; - const int l_stable= fabsf(t1_l-t0_l)>FLT_EPSILON ? 1 : 0; - const int w= bake_rast->w; - const int h= bake_rast->h; + const int s_stable = fabsf(t1_s - t0_s) > FLT_EPSILON ? 1 : 0; + const int l_stable = fabsf(t1_l - t0_l) > FLT_EPSILON ? 1 : 0; + const int w = bake_rast->w; + 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; + y0 = y0_in < 0 ? 0 : y0_in; + y1 = y1_in >= h ? h : y1_in; - for (y= y0; y0 && iXl=w?w:iXr; + if (iXr > 0 && iXl < w) { + iXl = iXl < 0 ? 0 : iXl; + iXr = iXr >= w ? w : iXr; - for (x= iXl; xw; - const int h= bake_rast->h; - float slo= st0_in[0]*w - 0.5f; - float tlo= st0_in[1]*h - 0.5f; - float smi= st1_in[0]*w - 0.5f; - float tmi= st1_in[1]*h - 0.5f; - float shi= st2_in[0]*w - 0.5f; - float thi= st2_in[1]*h - 0.5f; - int is_mid_right= 0, ylo, yhi, yhi_beg; + const int w = bake_rast->w; + const int h = bake_rast->h; + float slo = st0_in[0] * w - 0.5f; + float tlo = st0_in[1] * h - 0.5f; + float smi = st1_in[0] * w - 0.5f; + float tmi = st1_in[1] * h - 0.5f; + float shi = st2_in[0] * w - 0.5f; + float thi = st2_in[1] * h - 0.5f; + 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); } /* check if mid point is to the left or to the right of the lo-hi edge */ - is_mid_right= (-(shi-slo)*(tmi-thi) + (thi-tlo)*(smi-shi))>0 ? 1 : 0; - ylo= (int) ceilf(tlo); - yhi_beg= (int) ceilf(tmi); - yhi= (int) ceilf(thi); + is_mid_right = (-(shi - slo) * (tmi - thi) + (thi - tlo) * (smi - shi)) > 0 ? 1 : 0; + ylo = (int) ceilf(tlo); + yhi_beg = (int) ceilf(tmi); + yhi = (int) ceilf(thi); /*if (fTmi>ceilf(fTlo))*/ rasterize_half(bake_rast, slo, tlo, smi, tmi, slo, tlo, shi, thi, ylo, yhi_beg, is_mid_right); @@ -360,69 +360,69 @@ static int multiresbake_test_break(MultiresBakeRender *bkr) return G.afbreek; } -static void do_multires_bake(MultiresBakeRender *bkr, Image* ima, MPassKnownData passKnownData, +static void do_multires_bake(MultiresBakeRender *bkr, Image *ima, MPassKnownData passKnownData, MInitBakeData initBakeData, MApplyBakeData applyBakeData, MFreeBakeData freeBakeData) { - DerivedMesh *dm= bkr->lores_dm; - ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL); - const int lvl= bkr->lvl; - const int tot_face= dm->getNumTessFaces(dm); - MVert *mvert= dm->getVertArray(dm); - MFace *mface= dm->getTessFaceArray(dm); - MTFace *mtface= dm->getTessFaceDataArray(dm, CD_MTFACE); - float *pvtangent= NULL; + DerivedMesh *dm = bkr->lores_dm; + ImBuf *ibuf = BKE_image_get_ibuf(ima, NULL); + const int lvl = bkr->lvl; + const int tot_face = dm->getNumTessFaces(dm); + MVert *mvert = dm->getVertArray(dm); + MFace *mface = dm->getTessFaceArray(dm); + MTFace *mtface = dm->getTessFaceDataArray(dm, CD_MTFACE); + float *pvtangent = NULL; if (CustomData_get_layer_index(&dm->faceData, CD_TANGENT) == -1) DM_add_tangent_layer(dm); - pvtangent= DM_get_tessface_data_layer(dm, CD_TANGENT); + pvtangent = DM_get_tessface_data_layer(dm, CD_TANGENT); if (tot_face > 0) { /* sanity check */ - int f= 0; + int f = 0; MBakeRast bake_rast; - MResolvePixelData data={NULL}; - - data.mface= mface; - data.mvert= mvert; - data.mtface= mtface; - data.pvtangent= pvtangent; - data.precomputed_normals= dm->getTessFaceDataArray(dm, CD_NORMAL); /* don't strictly need this */ - data.w= ibuf->x; - data.h= ibuf->y; - data.lores_dm= dm; - data.hires_dm= bkr->hires_dm; - data.lvl= lvl; - data.pass_data= passKnownData; + MResolvePixelData data = {NULL}; + + data.mface = mface; + data.mvert = mvert; + data.mtface = mtface; + data.pvtangent = pvtangent; + data.precomputed_normals = dm->getTessFaceDataArray(dm, CD_NORMAL); /* don't strictly need this */ + data.w = ibuf->x; + data.h = ibuf->y; + data.lores_dm = dm; + data.hires_dm = bkr->hires_dm; + data.lvl = lvl; + data.pass_data = passKnownData; if (initBakeData) - data.bake_data= initBakeData(bkr, ima); + data.bake_data = initBakeData(bkr, ima); init_bake_rast(&bake_rast, ibuf, &data, flush_pixel); - for (f= 0; ftpage!=ima) + if (mtfate->tpage != ima) continue; - data.face_index= f; + data.face_index = f; /* might support other forms of diagonal splits later on such as * split by shortest diagonal.*/ - verts[0][0]=0; - verts[1][0]=1; - verts[2][0]=2; + verts[0][0] = 0; + verts[1][0] = 1; + verts[2][0] = 2; - verts[0][1]=0; - verts[1][1]=2; - verts[2][1]=3; + verts[0][1] = 0; + verts[1][1] = 2; + verts[2][1] = 3; - nr_tris= mface[f].v4!=0 ? 2 : 1; - for (t= 0; tbaked_faces++; if (bkr->do_update) - *bkr->do_update= 1; + *bkr->do_update = 1; if (bkr->progress) - *bkr->progress= ((float)bkr->baked_objects + (float)bkr->baked_faces / tot_face) / bkr->tot_obj; + *bkr->progress = ((float)bkr->baked_objects + (float)bkr->baked_faces / tot_face) / bkr->tot_obj; } if (applyBakeData) @@ -452,13 +452,13 @@ static void interp_bilinear_quad_data(float data[4][3], float u, float v, float float vec[3]; copy_v3_v3(res, data[0]); - mul_v3_fl(res, (1-u)*(1-v)); + mul_v3_fl(res, (1 - u) * (1 - v)); copy_v3_v3(vec, data[1]); - mul_v3_fl(vec, u*(1-v)); add_v3_v3(res, vec); + mul_v3_fl(vec, u * (1 - v)); add_v3_v3(res, vec); copy_v3_v3(vec, data[2]); - mul_v3_fl(vec, u*v); add_v3_v3(res, vec); + mul_v3_fl(vec, u * v); add_v3_v3(res, vec); copy_v3_v3(vec, data[3]); - mul_v3_fl(vec, (1-u)*v); add_v3_v3(res, vec); + mul_v3_fl(vec, (1 - u) * v); add_v3_v3(res, vec); } static void interp_barycentric_tri_data(float data[3][3], float u, float v, float res[3]) @@ -470,7 +470,7 @@ static void interp_barycentric_tri_data(float data[3][3], float u, float v, floa copy_v3_v3(vec, data[1]); mul_v3_fl(vec, v); add_v3_v3(res, vec); copy_v3_v3(vec, data[2]); - mul_v3_fl(vec, 1.0f-u-v); add_v3_v3(res, vec); + mul_v3_fl(vec, 1.0f - u - v); add_v3_v3(res, vec); } /* mode = 0: interpolate normals, @@ -481,14 +481,14 @@ static void interp_bilinear_grid(DMGridData *grid, int grid_size, float crn_x, f float u, v; float data[4][3]; - x0= (int) crn_x; - x1= x0>=(grid_size-1) ? (grid_size-1) : (x0+1); + x0 = (int) crn_x; + x1 = x0 >= (grid_size - 1) ? (grid_size - 1) : (x0 + 1); - y0= (int) crn_y; - y1= y0>=(grid_size-1) ? (grid_size-1) : (y0+1); + y0 = (int) crn_y; + y1 = y0 >= (grid_size - 1) ? (grid_size - 1) : (y0 + 1); - u= crn_x-x0; - v= crn_y-y0; + u = crn_x - x0; + v = crn_y - y0; if (mode == 0) { copy_v3_v3(data[0], grid[y0 * grid_size + x0].no); @@ -516,30 +516,30 @@ static void get_ccgdm_data(DerivedMesh *lodm, DerivedMesh *hidm, const int *orig lodm->getTessFace(lodm, face_index, &mface); - grid_size= hidm->getGridSize(hidm); - grid_data= hidm->getGridData(hidm); - grid_offset= hidm->getGridOffset(hidm); + grid_size = hidm->getGridSize(hidm); + grid_data = hidm->getGridData(hidm); + grid_offset = hidm->getGridOffset(hidm); - face_side= (grid_size<<1)-1; + face_side = (grid_size << 1) - 1; - 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); + 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 { - int side= (1 << (lvl-1)) + 1; - int grid_index= origindex[face_index]; - int loc_offs= face_index % (1<<(2*lvl)); - int cell_index= loc_offs % ((side-1)*(side-1)); - int cell_side= grid_size / (side-1); - int row= cell_index / (side-1); - int col= cell_index % (side-1); - - S= face_index / (1<<(2*(lvl-1))) - grid_offset[grid_index]; - g_index= grid_offset[grid_index]; - - crn_y= (row * cell_side) + u * cell_side; - crn_x= (col * cell_side) + v * cell_side; + int side = (1 << (lvl - 1)) + 1; + int grid_index = origindex[face_index]; + int loc_offs = face_index % (1 << (2 * lvl)); + int cell_index = loc_offs % ((side - 1) * (side - 1)); + int cell_side = grid_size / (side - 1); + int row = cell_index / (side - 1); + int col = cell_index % (side - 1); + + S = face_index / (1 << (2 * (lvl - 1))) - grid_offset[grid_index]; + g_index = grid_offset[grid_index]; + + crn_y = (row * cell_side) + u * cell_side; + crn_x = (col * cell_side) + v * cell_side; } CLAMP(crn_x, 0.0f, grid_size); @@ -597,95 +597,95 @@ static void interp_barycentric_mface(DerivedMesh *dm, MFace *mface, const float static void *init_heights_data(MultiresBakeRender *bkr, Image *ima) { MHeightBakeData *height_data; - ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL); - DerivedMesh *lodm= bkr->lores_dm; + ImBuf *ibuf = BKE_image_get_ibuf(ima, NULL); + DerivedMesh *lodm = bkr->lores_dm; - height_data= MEM_callocN(sizeof(MHeightBakeData), "MultiresBake heightData"); + height_data = MEM_callocN(sizeof(MHeightBakeData), "MultiresBake heightData"); - height_data->ima= ima; - height_data->heights= MEM_callocN(sizeof(float)*ibuf->x*ibuf->y, "MultiresBake heights"); - height_data->height_max= -FLT_MAX; - height_data->height_min= FLT_MAX; + height_data->ima = ima; + height_data->heights = MEM_callocN(sizeof(float) * ibuf->x * ibuf->y, "MultiresBake heights"); + height_data->height_max = -FLT_MAX; + height_data->height_min = FLT_MAX; if (!bkr->use_lores_mesh) { - SubsurfModifierData smd= {{NULL}}; - int ss_lvl= bkr->tot_lvl - bkr->lvl; + SubsurfModifierData smd = {{NULL}}; + int ss_lvl = bkr->tot_lvl - bkr->lvl; CLAMP(ss_lvl, 0, 6); - smd.levels= smd.renderLevels= ss_lvl; - smd.flags|= eSubsurfModifierFlag_SubsurfUv; + smd.levels = smd.renderLevels = ss_lvl; + smd.flags |= eSubsurfModifierFlag_SubsurfUv; if (bkr->simple) - smd.subdivType= ME_SIMPLE_SUBSURF; + smd.subdivType = ME_SIMPLE_SUBSURF; - height_data->ssdm= subsurf_make_derived_from_derived(bkr->lores_dm, &smd, 0, NULL, 0, 0, 0); + height_data->ssdm = subsurf_make_derived_from_derived(bkr->lores_dm, &smd, 0, NULL, 0, 0, 0); } - height_data->origindex= lodm->getTessFaceDataArray(lodm, CD_ORIGINDEX); + height_data->origindex = lodm->getTessFaceDataArray(lodm, CD_ORIGINDEX); - return (void*)height_data; + return (void *)height_data; } static void *init_normal_data(MultiresBakeRender *bkr, Image *UNUSED(ima)) { MNormalBakeData *normal_data; - DerivedMesh *lodm= bkr->lores_dm; + DerivedMesh *lodm = bkr->lores_dm; - normal_data= MEM_callocN(sizeof(MNormalBakeData), "MultiresBake normalData"); + normal_data = MEM_callocN(sizeof(MNormalBakeData), "MultiresBake normalData"); - normal_data->origindex= lodm->getTessFaceDataArray(lodm, CD_ORIGINDEX); + normal_data->origindex = lodm->getTessFaceDataArray(lodm, CD_ORIGINDEX); - return (void*)normal_data; + return (void *)normal_data; } static void free_normal_data(void *bake_data) { - MNormalBakeData *normal_data= (MNormalBakeData*)bake_data; + MNormalBakeData *normal_data = (MNormalBakeData *)bake_data; MEM_freeN(normal_data); } static void apply_heights_data(void *bake_data) { - MHeightBakeData *height_data= (MHeightBakeData*)bake_data; - ImBuf *ibuf= BKE_image_get_ibuf(height_data->ima, NULL); + MHeightBakeData *height_data = (MHeightBakeData *)bake_data; + ImBuf *ibuf = BKE_image_get_ibuf(height_data->ima, NULL); int x, y, i; - float height, *heights= height_data->heights; - float min= height_data->height_min, max= height_data->height_max; + float height, *heights = height_data->heights; + float min = height_data->height_min, max = height_data->height_max; - for (x= 0; xx; x++) { - for (y =0; yy; y++) { - i= ibuf->x*y + x; + 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) { - float *rrgbf= ibuf->rect_float + i*4; + float *rrgbf = ibuf->rect_float + i * 4; - if (max-min > 1e-5f) height= (heights[i]-min)/(max-min); - else height= 0; + if (max - min > 1e-5f) height = (heights[i] - min) / (max - min); + else height = 0; - rrgbf[0]=rrgbf[1]=rrgbf[2]= height; + rrgbf[0] = rrgbf[1] = rrgbf[2] = height; } else { - char *rrgb= (char*)ibuf->rect + i*4; + char *rrgb = (char *)ibuf->rect + i * 4; - if (max-min > 1e-5f) height= (heights[i]-min)/(max-min); - else height= 0; + if (max - min > 1e-5f) height = (heights[i] - min) / (max - min); + else height = 0; - rrgb[0]=rrgb[1]=rrgb[2]= FTOCHAR(height); + rrgb[0] = rrgb[1] = rrgb[2] = FTOCHAR(height); } } } - ibuf->userflags= IB_RECT_INVALID; + ibuf->userflags = IB_RECT_INVALID; } static void free_heights_data(void *bake_data) { - MHeightBakeData *height_data= (MHeightBakeData*)bake_data; + MHeightBakeData *height_data = (MHeightBakeData *)bake_data; if (height_data->ssdm) height_data->ssdm->release(height_data->ssdm); @@ -704,23 +704,23 @@ static void apply_heights_callback(DerivedMesh *lores_dm, DerivedMesh *hires_dm, const int face_index, const int lvl, const float st[2], float UNUSED(tangmat[3][3]), const int x, const int y) { - MTFace *mtface= CustomData_get_layer(&lores_dm->faceData, CD_MTFACE); + MTFace *mtface = CustomData_get_layer(&lores_dm->faceData, CD_MTFACE); MFace mface; - Image *ima= mtface[face_index].tpage; - ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL); - MHeightBakeData *height_data= (MHeightBakeData*)bake_data; + Image *ima = mtface[face_index].tpage; + ImBuf *ibuf = BKE_image_get_ibuf(ima, NULL); + MHeightBakeData *height_data = (MHeightBakeData *)bake_data; float uv[2], *st0, *st1, *st2, *st3; - int pixel= ibuf->x*y + x; + int pixel = ibuf->x * y + x; float vec[3], p0[3], p1[3], n[3], len; lores_dm->getTessFace(lores_dm, face_index, &mface); - st0= mtface[face_index].uv[0]; - st1= mtface[face_index].uv[1]; - st2= mtface[face_index].uv[2]; + st0 = mtface[face_index].uv[0]; + st1 = mtface[face_index].uv[1]; + st2 = mtface[face_index].uv[2]; if (mface.v4) { - st3= mtface[face_index].uv[3]; + st3 = mtface[face_index].uv[3]; resolve_quad_uv(uv, st, st0, st1, st2, st3); } else @@ -748,21 +748,21 @@ static void apply_heights_callback(DerivedMesh *lores_dm, DerivedMesh *hires_dm, } sub_v3_v3v3(vec, p1, p0); - len= dot_v3v3(n, vec); + len = dot_v3v3(n, vec); - height_data->heights[pixel]= len; - if (lenheight_min) height_data->height_min= len; - if (len>height_data->height_max) height_data->height_max= len; + 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 (ibuf->rect_float) { - float *rrgbf= ibuf->rect_float + pixel*4; - rrgbf[3]= 1.0f; + float *rrgbf = ibuf->rect_float + pixel * 4; + rrgbf[3] = 1.0f; - ibuf->userflags= IB_RECT_INVALID; + ibuf->userflags = IB_RECT_INVALID; } else { - char *rrgb= (char*)ibuf->rect + pixel*4; - rrgb[3]= 255; + char *rrgb = (char *)ibuf->rect + pixel * 4; + rrgb[3] = 255; } } @@ -775,23 +775,23 @@ static void apply_tangmat_callback(DerivedMesh *lores_dm, DerivedMesh *hires_dm, const int face_index, const int lvl, const float st[2], float tangmat[3][3], const int x, const int y) { - MTFace *mtface= CustomData_get_layer(&lores_dm->faceData, CD_MTFACE); + MTFace *mtface = CustomData_get_layer(&lores_dm->faceData, CD_MTFACE); MFace mface; - Image *ima= mtface[face_index].tpage; - ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL); - MNormalBakeData *normal_data= (MNormalBakeData*)bake_data; + Image *ima = mtface[face_index].tpage; + ImBuf *ibuf = BKE_image_get_ibuf(ima, NULL); + MNormalBakeData *normal_data = (MNormalBakeData *)bake_data; float uv[2], *st0, *st1, *st2, *st3; - int pixel= ibuf->x*y + x; - float n[3], vec[3], tmp[3]= {0.5, 0.5, 0.5}; + int pixel = ibuf->x * y + x; + float n[3], vec[3], tmp[3] = {0.5, 0.5, 0.5}; lores_dm->getTessFace(lores_dm, face_index, &mface); - st0= mtface[face_index].uv[0]; - st1= mtface[face_index].uv[1]; - st2= mtface[face_index].uv[2]; + st0 = mtface[face_index].uv[0]; + st1 = mtface[face_index].uv[1]; + st2 = mtface[face_index].uv[2]; if (mface.v4) { - st3= mtface[face_index].uv[3]; + st3 = mtface[face_index].uv[3]; resolve_quad_uv(uv, st, st0, st1, st2, st3); } else @@ -808,59 +808,59 @@ static void apply_tangmat_callback(DerivedMesh *lores_dm, DerivedMesh *hires_dm, add_v3_v3(vec, tmp); if (ibuf->rect_float) { - float *rrgbf= ibuf->rect_float + pixel*4; - rrgbf[0]= vec[0]; - rrgbf[1]= vec[1]; - rrgbf[2]= vec[2]; - rrgbf[3]= 1.0f; + float *rrgbf = ibuf->rect_float + pixel * 4; + rrgbf[0] = vec[0]; + rrgbf[1] = vec[1]; + rrgbf[2] = vec[2]; + rrgbf[3] = 1.0f; - ibuf->userflags= IB_RECT_INVALID; + ibuf->userflags = IB_RECT_INVALID; } else { - unsigned char *rrgb= (unsigned char *)ibuf->rect + pixel*4; + unsigned char *rrgb = (unsigned char *)ibuf->rect + pixel * 4; rgb_float_to_uchar(rrgb, vec); - rrgb[3]= 255; + rrgb[3] = 255; } } static void count_images(MultiresBakeRender *bkr) { int a, totface; - DerivedMesh *dm= bkr->lores_dm; - MTFace *mtface= CustomData_get_layer(&dm->faceData, CD_MTFACE); + DerivedMesh *dm = bkr->lores_dm; + MTFace *mtface = CustomData_get_layer(&dm->faceData, CD_MTFACE); - bkr->image.first= bkr->image.last= NULL; - bkr->tot_image= 0; + bkr->image.first = bkr->image.last = NULL; + bkr->tot_image = 0; - totface= dm->getNumTessFaces(dm); + totface = dm->getNumTessFaces(dm); - for (a= 0; aid.flag&= ~LIB_DOIT; + for (a = 0; a < totface; a++) + mtface[a].tpage->id.flag &= ~LIB_DOIT; - for (a= 0; aid.flag&LIB_DOIT)==0) { - LinkData *data= BLI_genericNodeN(ima); + for (a = 0; a < totface; a++) { + Image *ima = mtface[a].tpage; + if ((ima->id.flag & LIB_DOIT) == 0) { + LinkData *data = BLI_genericNodeN(ima); BLI_addtail(&bkr->image, data); bkr->tot_image++; - ima->id.flag|= LIB_DOIT; + ima->id.flag |= LIB_DOIT; } } - for (a= 0; aid.flag&= ~LIB_DOIT; + for (a = 0; a < totface; a++) + mtface[a].tpage->id.flag &= ~LIB_DOIT; } static void bake_images(MultiresBakeRender *bkr) { LinkData *link; - for (link= bkr->image.first; link; link= link->next) { - Image *ima= (Image*)link->data; - ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL); + 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) { - ibuf->userdata= MEM_callocN(ibuf->y*ibuf->x, "MultiresBake imbuf mask"); + if (ibuf->x > 0 && ibuf->y > 0) { + ibuf->userdata = MEM_callocN(ibuf->y * ibuf->x, "MultiresBake imbuf mask"); switch (bkr->mode) { case RE_BAKE_NORMALS: @@ -873,7 +873,7 @@ static void bake_images(MultiresBakeRender *bkr) } } - ima->id.flag|= LIB_DOIT; + ima->id.flag |= LIB_DOIT; } } @@ -881,28 +881,28 @@ static void finish_images(MultiresBakeRender *bkr) { LinkData *link; - for (link= bkr->image.first; link; link= link->next) { - Image *ima= (Image*)link->data; - ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL); + 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; + ibuf->userflags |= IB_BITMAPDIRTY; if (ibuf->rect_float) - ibuf->userflags|= IB_RECT_INVALID; + ibuf->userflags |= IB_RECT_INVALID; if (ibuf->mipmap[0]) { - ibuf->userflags|= IB_MIPMAP_INVALID; + ibuf->userflags |= IB_MIPMAP_INVALID; imb_freemipmapImBuf(ibuf); } if (ibuf->userdata) { MEM_freeN(ibuf->userdata); - ibuf->userdata= NULL; + ibuf->userdata = NULL; } } } @@ -916,38 +916,38 @@ static void multiresbake_start(MultiresBakeRender *bkr) static int multiresbake_check(bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); Object *ob; Mesh *me; MultiresModifierData *mmd; - int ok= 1, a; + int ok = 1, a; - CTX_DATA_BEGIN (C, Base*, base, selected_editable_bases) { - ob= base->object; + CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases) { + ob = base->object; 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; + ok = 0; break; } - me= (Mesh*)ob->data; - mmd= get_multires_modifier(scene, ob, 0); + me = (Mesh *)ob->data; + mmd = get_multires_modifier(scene, ob, 0); /* Multi-resolution should be and be last in the stack */ if (ok && mmd) { ModifierData *md; - ok= mmd->totlvl>0; + 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; + ok = 0; } } } - else ok= 0; + else ok = 0; if (!ok) { BKE_report(op->reports, RPT_ERROR, "Multires data baking requires multi-resolution object"); @@ -958,7 +958,7 @@ static int multiresbake_check(bContext *C, wmOperator *op) if (!me->mtpoly) { BKE_report(op->reports, RPT_ERROR, "Mesh should be unwrapped before multires data baking"); - ok= 0; + ok = 0; } else { a = me->totpoly; @@ -968,22 +968,22 @@ static int multiresbake_check(bContext *C, wmOperator *op) if (!ima) { BKE_report(op->reports, RPT_ERROR, "You should have active texture to use multires baker"); - ok= 0; + ok = 0; } else { - ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL); + ImBuf *ibuf = BKE_image_get_ibuf(ima, NULL); if (!ibuf) { BKE_report(op->reports, RPT_ERROR, "Baking should happend to image with image buffer"); - ok= 0; + ok = 0; } else { - if (ibuf->rect==NULL && ibuf->rect_float==NULL) - ok= 0; + if (ibuf->rect == NULL && ibuf->rect_float == NULL) + ok = 0; - if (ibuf->rect_float && !(ibuf->channels==0 || ibuf->channels==4)) - ok= 0; + if (ibuf->rect_float && !(ibuf->channels == 0 || ibuf->channels == 4)) + ok = 0; if (!ok) BKE_report(op->reports, RPT_ERROR, "Baking to unsupported image type"); @@ -1003,23 +1003,23 @@ static int multiresbake_check(bContext *C, wmOperator *op) static DerivedMesh *multiresbake_create_loresdm(Scene *scene, Object *ob, int *lvl) { DerivedMesh *dm; - MultiresModifierData *mmd= get_multires_modifier(scene, ob, 0); - Mesh *me= (Mesh*)ob->data; + MultiresModifierData *mmd = get_multires_modifier(scene, ob, 0); + Mesh *me = (Mesh *)ob->data; - *lvl= mmd->lvl; + *lvl = mmd->lvl; - if (*lvl==0) { - DerivedMesh *tmp_dm= CDDM_from_mesh(me, ob); - dm= CDDM_copy(tmp_dm); + if (*lvl == 0) { + DerivedMesh *tmp_dm = CDDM_from_mesh(me, ob); + dm = CDDM_copy(tmp_dm); tmp_dm->release(tmp_dm); } else { - MultiresModifierData tmp_mmd= *mmd; - DerivedMesh *cddm= CDDM_from_mesh(me, ob); + MultiresModifierData tmp_mmd = *mmd; + DerivedMesh *cddm = CDDM_from_mesh(me, ob); - tmp_mmd.lvl= *lvl; - tmp_mmd.sculptlvl= *lvl; - dm= multires_dm_create_from_derived(&tmp_mmd, 1, cddm, ob, 0); + tmp_mmd.lvl = *lvl; + tmp_mmd.sculptlvl = *lvl; + dm = multires_dm_create_from_derived(&tmp_mmd, 1, cddm, ob, 0); cddm->release(cddm); } @@ -1028,18 +1028,18 @@ static DerivedMesh *multiresbake_create_loresdm(Scene *scene, Object *ob, int *l static DerivedMesh *multiresbake_create_hiresdm(Scene *scene, Object *ob, int *lvl, int *simple) { - Mesh *me= (Mesh*)ob->data; - MultiresModifierData *mmd= get_multires_modifier(scene, ob, 0); - MultiresModifierData tmp_mmd= *mmd; - DerivedMesh *cddm= CDDM_from_mesh(me, ob); + Mesh *me = (Mesh *)ob->data; + MultiresModifierData *mmd = get_multires_modifier(scene, ob, 0); + MultiresModifierData tmp_mmd = *mmd; + DerivedMesh *cddm = CDDM_from_mesh(me, ob); DerivedMesh *dm; - *lvl= mmd->totlvl; - *simple= mmd->simple; + *lvl = mmd->totlvl; + *simple = mmd->simple; - tmp_mmd.lvl= mmd->totlvl; - tmp_mmd.sculptlvl= mmd->totlvl; - dm= multires_dm_create_from_derived(&tmp_mmd, 1, cddm, ob, 0); + tmp_mmd.lvl = mmd->totlvl; + tmp_mmd.sculptlvl = mmd->totlvl; + dm = multires_dm_create_from_derived(&tmp_mmd, 1, cddm, ob, 0); cddm->release(cddm); return dm; @@ -1048,67 +1048,67 @@ static DerivedMesh *multiresbake_create_hiresdm(Scene *scene, Object *ob, int *l static void clear_images(MTFace *mtface, int totface) { int a; - 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}; + const float vec_alpha[4] = {0.0f, 0.0f, 0.0f, 0.0f}; + const float vec_solid[4] = {0.0f, 0.0f, 0.0f, 1.0f}; - for (a= 0; aid.flag&= ~LIB_DOIT; + for (a = 0; a < totface; a++) + mtface[a].tpage->id.flag &= ~LIB_DOIT; - for (a= 0; aid.flag&LIB_DOIT)==0) { - ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL); + 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); - ima->id.flag|= LIB_DOIT; + ima->id.flag |= LIB_DOIT; } } - for (a= 0; aid.flag&= ~LIB_DOIT; + for (a = 0; a < totface; a++) + mtface[a].tpage->id.flag &= ~LIB_DOIT; } static int multiresbake_image_exec_locked(bContext *C, wmOperator *op) { Object *ob; - Scene *scene= CTX_data_scene(C); - int objects_baked= 0; + Scene *scene = CTX_data_scene(C); + int objects_baked = 0; if (!multiresbake_check(C, op)) return OPERATOR_CANCELLED; - if (scene->r.bake_flag&R_BAKE_CLEAR) { /* clear images */ - CTX_DATA_BEGIN (C, Base*, base, selected_editable_bases) { + if (scene->r.bake_flag & R_BAKE_CLEAR) { /* clear images */ + CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases) { Mesh *me; - ob= base->object; - me= (Mesh*)ob->data; + ob = base->object; + me = (Mesh *)ob->data; clear_images(me->mtface, me->totface); } CTX_DATA_END; } - CTX_DATA_BEGIN (C, Base*, base, selected_editable_bases) { - MultiresBakeRender bkr= {0}; + CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases) { + MultiresBakeRender bkr = {0}; - ob= base->object; + ob = base->object; multires_force_update(ob); /* copy data stored in job descriptor */ - bkr.bake_filter= scene->r.bake_filter; - bkr.mode= scene->r.bake_mode; - bkr.use_lores_mesh= scene->r.bake_flag&R_BAKE_LORES_MESH; + bkr.bake_filter = scene->r.bake_filter; + bkr.mode = scene->r.bake_mode; + bkr.use_lores_mesh = scene->r.bake_flag & R_BAKE_LORES_MESH; /* create low-resolution DM (to bake to) and hi-resolution DM (to bake from) */ - bkr.lores_dm= multiresbake_create_loresdm(scene, ob, &bkr.lvl); + bkr.lores_dm = multiresbake_create_loresdm(scene, ob, &bkr.lvl); if (!bkr.lores_dm) continue; - bkr.hires_dm= multiresbake_create_hiresdm(scene, ob, &bkr.tot_lvl, &bkr.simple); + bkr.hires_dm = multiresbake_create_hiresdm(scene, ob, &bkr.tot_lvl, &bkr.simple); multiresbake_start(&bkr); @@ -1130,20 +1130,20 @@ static int multiresbake_image_exec_locked(bContext *C, wmOperator *op) /* Multiresbake adopted for job-system executing */ static void init_multiresbake_job(bContext *C, MultiresBakeJob *bkj) { - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); Object *ob; /* backup scene settings, so their changing in UI would take no effect on baker */ - bkj->bake_filter= scene->r.bake_filter; - bkj->mode= scene->r.bake_mode; - bkj->use_lores_mesh= scene->r.bake_flag&R_BAKE_LORES_MESH; - bkj->bake_clear= scene->r.bake_flag&R_BAKE_CLEAR; + bkj->bake_filter = scene->r.bake_filter; + bkj->mode = scene->r.bake_mode; + bkj->use_lores_mesh = scene->r.bake_flag & R_BAKE_LORES_MESH; + bkj->bake_clear = scene->r.bake_flag & R_BAKE_CLEAR; - CTX_DATA_BEGIN (C, Base*, base, selected_editable_bases) { + CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases) { MultiresBakerJobData *data; DerivedMesh *lores_dm; int lvl; - ob= base->object; + ob = base->object; multires_force_update(ob); @@ -1151,7 +1151,7 @@ static void init_multiresbake_job(bContext *C, MultiresBakeJob *bkj) if (!lores_dm) continue; - data= MEM_callocN(sizeof(MultiresBakerJobData), "multiresBaker derivedMesh_data"); + data = MEM_callocN(sizeof(MultiresBakerJobData), "multiresBaker derivedMesh_data"); data->lores_dm = lores_dm; data->lvl = lvl; data->hires_dm = multiresbake_create_hiresdm(scene, ob, &data->tot_lvl, &data->simple); @@ -1164,42 +1164,42 @@ static void init_multiresbake_job(bContext *C, MultiresBakeJob *bkj) static void multiresbake_startjob(void *bkv, short *stop, short *do_update, float *progress) { MultiresBakerJobData *data; - MultiresBakeJob *bkj= bkv; - int baked_objects= 0, tot_obj; + MultiresBakeJob *bkj = bkv; + int baked_objects = 0, tot_obj; - tot_obj= BLI_countlist(&bkj->data); + tot_obj = BLI_countlist(&bkj->data); 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); + for (data = bkj->data.first; data; data = data->next) { + DerivedMesh *dm = data->lores_dm; + MTFace *mtface = CustomData_get_layer(&dm->faceData, CD_MTFACE); clear_images(mtface, dm->getNumTessFaces(dm)); } } - for (data= bkj->data.first; data; data= data->next) { - MultiresBakeRender bkr= {0}; + for (data = bkj->data.first; data; data = data->next) { + MultiresBakeRender bkr = {0}; /* copy data stored in job descriptor */ - bkr.bake_filter= bkj->bake_filter; - bkr.mode= bkj->mode; - bkr.use_lores_mesh= bkj->use_lores_mesh; + bkr.bake_filter = bkj->bake_filter; + bkr.mode = bkj->mode; + bkr.use_lores_mesh = bkj->use_lores_mesh; /* create low-resolution DM (to bake to) and hi-resolution DM (to bake from) */ - bkr.lores_dm= data->lores_dm; - bkr.hires_dm= data->hires_dm; - bkr.tot_lvl= data->tot_lvl; - bkr.lvl= data->lvl; - bkr.simple= data->simple; + bkr.lores_dm = data->lores_dm; + bkr.hires_dm = data->hires_dm; + bkr.tot_lvl = data->tot_lvl; + bkr.lvl = data->lvl; + bkr.simple = data->simple; /* needed for proper progress bar */ - bkr.tot_obj= tot_obj; - bkr.baked_objects= baked_objects; + bkr.tot_obj = tot_obj; + bkr.baked_objects = baked_objects; - bkr.stop= stop; - bkr.do_update= do_update; - bkr.progress= progress; + bkr.stop = stop; + bkr.do_update = do_update; + bkr.progress = progress; multiresbake_start(&bkr); @@ -1211,16 +1211,16 @@ static void multiresbake_startjob(void *bkv, short *stop, short *do_update, floa static void multiresbake_freejob(void *bkv) { - MultiresBakeJob *bkj= bkv; + MultiresBakeJob *bkj = bkv; MultiresBakerJobData *data, *next; - data= bkj->data.first; + data = bkj->data.first; while (data) { - next= data->next; + next = data->next; data->lores_dm->release(data->lores_dm); data->hires_dm->release(data->hires_dm); MEM_freeN(data); - data= next; + data = next; } MEM_freeN(bkj); @@ -1228,14 +1228,14 @@ static void multiresbake_freejob(void *bkv) static int multiresbake_image_exec(bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); MultiresBakeJob *bkr; wmJob *steve; if (!multiresbake_check(C, op)) return OPERATOR_CANCELLED; - bkr= MEM_callocN(sizeof(MultiresBakeJob), "MultiresBakeJob data"); + bkr = MEM_callocN(sizeof(MultiresBakeJob), "MultiresBakeJob data"); init_multiresbake_job(C, bkr); if (!bkr->data.first) { @@ -1244,12 +1244,12 @@ static int multiresbake_image_exec(bContext *C, wmOperator *op) } /* setup job */ - steve= WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene, "Multires Bake", WM_JOB_EXCL_RENDER|WM_JOB_PRIORITY|WM_JOB_PROGRESS); + steve = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene, "Multires Bake", WM_JOB_EXCL_RENDER | WM_JOB_PRIORITY | WM_JOB_PROGRESS); WM_jobs_customdata(steve, bkr, multiresbake_freejob); WM_jobs_timer(steve, 0.2, NC_IMAGE, 0); /* TODO - only draw bake image, can we enforce this */ WM_jobs_callbacks(steve, multiresbake_startjob, NULL, NULL, NULL); - G.afbreek= 0; + G.afbreek = 0; WM_jobs_start(CTX_wm_manager(C), steve); WM_cursor_wait(0); @@ -1294,12 +1294,12 @@ typedef struct BakeRender { /* use by exec and invoke */ static int test_bake_internal(bContext *C, ReportList *reports) { - Scene *scene= CTX_data_scene(C); + 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 { @@ -1311,23 +1311,23 @@ static int test_bake_internal(bContext *C, ReportList *reports) static void init_bake_internal(BakeRender *bkr, bContext *C) { - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); /* get editmode results */ ED_object_exit_editmode(C, 0); /* 0 = does not exit editmode */ - bkr->sa= BKE_screen_find_big_area(CTX_wm_screen(C), SPACE_IMAGE, 10); /* can be NULL */ - bkr->main= CTX_data_main(C); - bkr->scene= scene; - bkr->actob= (scene->r.bake_flag & R_BAKE_TO_ACTIVE) ? OBACT : NULL; - bkr->re= RE_NewRender("_Bake View_"); + bkr->sa = BKE_screen_find_big_area(CTX_wm_screen(C), SPACE_IMAGE, 10); /* can be NULL */ + bkr->main = CTX_data_main(C); + bkr->scene = scene; + 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; } @@ -1338,20 +1338,20 @@ 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->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->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) { - ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL); + 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) { GPU_free_image(ima); @@ -1361,7 +1361,7 @@ static void finish_bake_internal(BakeRender *bkr) /* freed when baking is done, but if its canceled we need to free here */ if (ibuf->userdata) { MEM_freeN(ibuf->userdata); - ibuf->userdata= NULL; + ibuf->userdata = NULL; } } } @@ -1371,52 +1371,52 @@ static void finish_bake_internal(BakeRender *bkr) static void *do_bake_render(void *bake_v) { - BakeRender *bkr= bake_v; + BakeRender *bkr = bake_v; - bkr->result= RE_bake_shade_all_selected(bkr->re, bkr->scene->r.bake_mode, bkr->actob, NULL, bkr->progress); - bkr->ready= 1; + bkr->result = RE_bake_shade_all_selected(bkr->re, bkr->scene->r.bake_mode, bkr->actob, NULL, bkr->progress); + bkr->ready = 1; return NULL; } static void bake_startjob(void *bkv, short *stop, short *do_update, float *progress) { - BakeRender *bkr= bkv; - Scene *scene= bkr->scene; - Main *bmain= bkr->main; + BakeRender *bkr = bkv; + Scene *scene = bkr->scene; + Main *bmain = bkr->main; - bkr->stop= stop; - bkr->do_update= do_update; - bkr->progress= progress; + bkr->stop = stop; + bkr->do_update = do_update; + bkr->progress = progress; RE_test_break_cb(bkr->re, NULL, thread_break); - G.afbreek= 0; /* blender_test_break uses this global */ + G.afbreek = 0; /* blender_test_break uses this global */ RE_Database_Baking(bkr->re, bmain, scene, scene->lay, scene->r.bake_mode, bkr->actob); /* baking itself is threaded, cannot use test_break in threads. we also update optional imagewindow */ - bkr->result= RE_bake_shade_all_selected(bkr->re, scene->r.bake_mode, bkr->actob, bkr->do_update, bkr->progress); + bkr->result = RE_bake_shade_all_selected(bkr->re, scene->r.bake_mode, bkr->actob, bkr->do_update, bkr->progress); } static void bake_update(void *bkv) { - BakeRender *bkr= bkv; + BakeRender *bkr = bkv; - if (bkr->sa && bkr->sa->spacetype==SPACE_IMAGE) { /* in case the user changed while baking */ - SpaceImage *sima= bkr->sa->spacedata.first; + if (bkr->sa && bkr->sa->spacetype == SPACE_IMAGE) { /* in case the user changed while baking */ + SpaceImage *sima = bkr->sa->spacedata.first; if (sima) - sima->image= RE_bake_shade_get_image(); + sima->image = RE_bake_shade_get_image(); } } static void bake_freejob(void *bkv) { - BakeRender *bkr= 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); @@ -1427,8 +1427,8 @@ 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))) - return OPERATOR_FINISHED|OPERATOR_PASS_THROUGH; + if (0 == WM_jobs_test(CTX_wm_manager(C), CTX_data_scene(C))) + return OPERATOR_FINISHED | OPERATOR_PASS_THROUGH; /* running render */ switch (event->type) { @@ -1441,7 +1441,7 @@ static int objects_bake_render_modal(bContext *C, wmOperator *UNUSED(op), wmEven static int is_multires_bake(Scene *scene) { - if ( ELEM(scene->r.bake_mode, RE_BAKE_NORMALS, RE_BAKE_DISPLACEMENT)) + if (ELEM(scene->r.bake_mode, RE_BAKE_NORMALS, RE_BAKE_DISPLACEMENT)) return scene->r.bake_flag & R_BAKE_MULTIRES; return 0; @@ -1449,34 +1449,34 @@ static int is_multires_bake(Scene *scene) static int objects_bake_render_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(_event)) { - Scene *scene= CTX_data_scene(C); - int result= OPERATOR_CANCELLED; + Scene *scene = CTX_data_scene(C); + int result = OPERATOR_CANCELLED; if (is_multires_bake(scene)) { - result= multiresbake_image_exec(C, op); + result = multiresbake_image_exec(C, op); } else { /* only one render job at a time */ 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 { - BakeRender *bkr= MEM_callocN(sizeof(BakeRender), "render bake"); + BakeRender *bkr = MEM_callocN(sizeof(BakeRender), "render bake"); wmJob *steve; init_bake_internal(bkr, C); - bkr->reports= op->reports; + bkr->reports = op->reports; /* setup job */ - steve= WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene, "Texture Bake", WM_JOB_EXCL_RENDER|WM_JOB_PRIORITY|WM_JOB_PROGRESS); + steve = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene, "Texture Bake", WM_JOB_EXCL_RENDER | WM_JOB_PRIORITY | WM_JOB_PROGRESS); WM_jobs_customdata(steve, bkr, bake_freejob); WM_jobs_timer(steve, 0.2, NC_IMAGE, 0); /* TODO - only draw bake image, can we enforce this */ WM_jobs_callbacks(steve, bake_startjob, NULL, bake_update, NULL); - G.afbreek= 0; + G.afbreek = 0; G.rendering = 1; WM_jobs_start(CTX_wm_manager(C), steve); @@ -1487,10 +1487,10 @@ static int objects_bake_render_invoke(bContext *C, wmOperator *op, wmEvent *UNUS WM_event_add_modal_handler(C, op); } - result= OPERATOR_RUNNING_MODAL; + result = OPERATOR_RUNNING_MODAL; } - WM_event_add_notifier(C, NC_SCENE|ND_RENDER_RESULT, scene); + WM_event_add_notifier(C, NC_SCENE | ND_RENDER_RESULT, scene); return result; } @@ -1498,35 +1498,35 @@ static int objects_bake_render_invoke(bContext *C, wmOperator *op, wmEvent *UNUS static int bake_image_exec(bContext *C, wmOperator *op) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); - int result= OPERATOR_CANCELLED; + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + int result = OPERATOR_CANCELLED; if (is_multires_bake(scene)) { - result= multiresbake_image_exec_locked(C, op); + result = multiresbake_image_exec_locked(C, op); } else { - if (test_bake_internal(C, op->reports)==0) { + if (test_bake_internal(C, op->reports) == 0) { return OPERATOR_CANCELLED; } else { ListBase threads; - BakeRender bkr= {NULL}; + BakeRender bkr = {NULL}; init_bake_internal(&bkr, C); - bkr.reports= op->reports; + bkr.reports = op->reports; RE_test_break_cb(bkr.re, NULL, thread_break); - G.afbreek= 0; /* blender_test_break uses this global */ + G.afbreek = 0; /* blender_test_break uses this global */ - RE_Database_Baking(bkr.re, bmain, scene, scene->lay, scene->r.bake_mode, (scene->r.bake_flag & R_BAKE_TO_ACTIVE)? OBACT: NULL); + RE_Database_Baking(bkr.re, bmain, scene, scene->lay, scene->r.bake_mode, (scene->r.bake_flag & R_BAKE_TO_ACTIVE) ? OBACT : NULL); /* baking itself is threaded, cannot use test_break in threads */ BLI_init_threads(&threads, do_bake_render, 1); - bkr.ready= 0; + bkr.ready = 0; BLI_insert_thread(&threads, &bkr); - while (bkr.ready==0) { + while (bkr.ready == 0) { PIL_sleep_ms(50); if (bkr.ready) break; @@ -1537,18 +1537,18 @@ 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); - result= OPERATOR_FINISHED; + result = OPERATOR_FINISHED; } } - WM_event_add_notifier(C, NC_SCENE|ND_RENDER_RESULT, scene); + WM_event_add_notifier(C, NC_SCENE | ND_RENDER_RESULT, scene); return result; } diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c index 158d323b802..a865b1d015d 100644 --- a/source/blender/editors/object/object_constraint.c +++ b/source/blender/editors/object/object_constraint.c @@ -81,7 +81,7 @@ /* -------------- Get Active Constraint Data ---------------------- */ /* if object in posemode, active bone constraints, else object constraints */ -ListBase *get_active_constraints (Object *ob) +ListBase *get_active_constraints(Object *ob) { if (ob == NULL) return NULL; @@ -100,10 +100,10 @@ ListBase *get_active_constraints (Object *ob) } /* Find the list that a given constraint belongs to, and/or also get the posechannel this is from (if applicable) */ -ListBase *get_constraint_lb (Object *ob, bConstraint *con, bPoseChannel **pchan_r) +ListBase *get_constraint_lb(Object *ob, bConstraint *con, bPoseChannel **pchan_r) { if (pchan_r) - *pchan_r= NULL; + *pchan_r = NULL; if (ELEM(NULL, ob, con)) return NULL; @@ -120,11 +120,11 @@ ListBase *get_constraint_lb (Object *ob, bConstraint *con, bPoseChannel **pchan_ /* try each bone in order * NOTE: it's not possible to directly look up the active bone yet, so this will have to do */ - for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { + for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { if ((BLI_findindex(&pchan->constraints, con) != -1)) { if (pchan_r) - *pchan_r= pchan; + *pchan_r = pchan; return &pchan->constraints; } @@ -136,7 +136,7 @@ ListBase *get_constraint_lb (Object *ob, bConstraint *con, bPoseChannel **pchan_ } /* single constraint */ -bConstraint *get_active_constraint (Object *ob) +bConstraint *get_active_constraint(Object *ob) { return constraints_get_active(get_active_constraints(ob)); } @@ -146,25 +146,25 @@ bConstraint *get_active_constraint (Object *ob) /* ------------- PyConstraints ------------------ */ /* this callback sets the text-file to be used for selected menu item */ -static void validate_pyconstraint_cb (void *arg1, void *arg2) +static void validate_pyconstraint_cb(void *arg1, void *arg2) { bPythonConstraint *data = arg1; - Text *text= NULL; + Text *text = NULL; int index = *((int *)arg2); int i; /* exception for no script */ if (index) { /* innovative use of a for...loop to search */ - for (text=G.main->text.first, i=1; text && index!=i; i++, text=text->id.next); + for (text = G.main->text.first, i = 1; text && index != i; i++, text = text->id.next) ; } data->text = text; } /* this returns a string for the list of usable pyconstraint script names */ -static char *buildmenu_pyconstraints (Text *con_text, int *pyconindex) +static char *buildmenu_pyconstraints(Text *con_text, int *pyconindex) { - DynStr *pupds= BLI_dynstr_new(); + DynStr *pupds = BLI_dynstr_new(); Text *text; char *str; char buf[64]; @@ -176,16 +176,16 @@ static char *buildmenu_pyconstraints (Text *con_text, int *pyconindex) /* init active-index first */ if (con_text == NULL) - *pyconindex= 0; + *pyconindex = 0; /* loop through markers, adding them */ - for (text=G.main->text.first, i=1; text; i++, text=text->id.next) { + for (text = G.main->text.first, i = 1; text; i++, text = text->id.next) { /* this is important to ensure that right script is shown as active */ if (text == con_text) *pyconindex = i; /* only include valid pyconstraint scripts */ if (BPY_is_pyconstraint(text)) { - BLI_dynstr_append(pupds, text->id.name+2); + BLI_dynstr_append(pupds, text->id.name + 2); sprintf(buf, "%%x%d", i); BLI_dynstr_append(pupds, buf); @@ -196,7 +196,7 @@ static char *buildmenu_pyconstraints (Text *con_text, int *pyconindex) } /* convert to normal MEM_malloc'd string */ - str= BLI_dynstr_get_cstring(pupds); + str = BLI_dynstr_get_cstring(pupds); BLI_dynstr_free(pupds); return str; @@ -205,14 +205,14 @@ static char *buildmenu_pyconstraints (Text *con_text, int *pyconindex) #if 0 // UNUSED, until pyconstraints are added back. /* this callback gets called when the 'refresh' button of a pyconstraint gets pressed */ -static void update_pyconstraint_cb (void *arg1, void *arg2) +static void update_pyconstraint_cb(void *arg1, void *arg2) { #ifndef WITH_PYTHON (void)arg1; /* unused */ (void)arg2; /* unused */ #else - Object *owner= (Object *)arg1; - bConstraint *con= (bConstraint *)arg2; + Object *owner = (Object *)arg1; + bConstraint *con = (bConstraint *)arg2; if (owner && con) BPY_pyconstraint_update(owner, con); #endif @@ -220,30 +220,30 @@ static void update_pyconstraint_cb (void *arg1, void *arg2) #endif // UNUSED /* helper function for add_constriant - sets the last target for the active constraint */ -static void set_constraint_nth_target (bConstraint *con, Object *target, const char subtarget[], int index) +static void set_constraint_nth_target(bConstraint *con, Object *target, const char subtarget[], int index) { - bConstraintTypeInfo *cti= constraint_get_typeinfo(con); + bConstraintTypeInfo *cti = constraint_get_typeinfo(con); ListBase targets = {NULL, NULL}; bConstraintTarget *ct; int num_targets, i; if (cti && cti->get_constraint_targets) { cti->get_constraint_targets(con, &targets); - num_targets= BLI_countlist(&targets); + num_targets = BLI_countlist(&targets); if (index < 0) { if (abs(index) < num_targets) - index= num_targets - abs(index); + index = num_targets - abs(index); else - index= num_targets - 1; + index = num_targets - 1; } else if (index >= num_targets) { - index= num_targets - 1; + index = num_targets - 1; } - for (ct=targets.first, i=0; ct; ct= ct->next, i++) { + for (ct = targets.first, i = 0; ct; ct = ct->next, i++) { if (i == index) { - ct->tar= target; + ct->tar = target; BLI_strncpy(ct->subtarget, subtarget, sizeof(ct->subtarget)); break; } @@ -259,13 +259,13 @@ static void set_constraint_nth_target (bConstraint *con, Object *target, const c /* checks validity of object pointers, and NULLs, * if Bone doesnt exist it sets the CONSTRAINT_DISABLE flag. */ -static void test_constraints (Object *owner, bPoseChannel *pchan) +static void test_constraints(Object *owner, bPoseChannel *pchan) { bConstraint *curcon; - ListBase *conlist= NULL; + ListBase *conlist = NULL; int type; - if (owner==NULL) return; + if (owner == NULL) return; /* Check parents */ if (pchan) { @@ -293,8 +293,8 @@ static void test_constraints (Object *owner, bPoseChannel *pchan) /* Check all constraints - is constraint valid? */ if (conlist) { - for (curcon = conlist->first; curcon; curcon=curcon->next) { - bConstraintTypeInfo *cti= constraint_get_typeinfo(curcon); + for (curcon = conlist->first; curcon; curcon = curcon->next) { + bConstraintTypeInfo *cti = constraint_get_typeinfo(curcon); ListBase targets = {NULL, NULL}; bConstraintTarget *ct; @@ -339,7 +339,7 @@ static void test_constraints (Object *owner, bPoseChannel *pchan) bPivotConstraint *data = curcon->data; /* target doesn't have to exist, but if it is non-null, it must exist! */ - if (data->tar && exist_object(data->tar)==0) { + if (data->tar && exist_object(data->tar) == 0) { data->tar = NULL; curcon->flag |= CONSTRAINT_DISABLE; } @@ -363,26 +363,26 @@ static void test_constraints (Object *owner, bPoseChannel *pchan) bFollowPathConstraint *data = curcon->data; /* don't allow track/up axes to be the same */ - if (data->upflag==data->trackflag) + if (data->upflag == data->trackflag) curcon->flag |= CONSTRAINT_DISABLE; - if (data->upflag+3==data->trackflag) + if (data->upflag + 3 == data->trackflag) curcon->flag |= CONSTRAINT_DISABLE; } else if (curcon->type == CONSTRAINT_TYPE_TRACKTO) { bTrackToConstraint *data = curcon->data; /* don't allow track/up axes to be the same */ - if (data->reserved2==data->reserved1) + if (data->reserved2 == data->reserved1) curcon->flag |= CONSTRAINT_DISABLE; - if (data->reserved2+3==data->reserved1) + if (data->reserved2 + 3 == data->reserved1) curcon->flag |= CONSTRAINT_DISABLE; } else if (curcon->type == CONSTRAINT_TYPE_LOCKTRACK) { bLockTrackConstraint *data = curcon->data; - if (data->lockflag==data->trackflag) + if (data->lockflag == data->trackflag) curcon->flag |= CONSTRAINT_DISABLE; - if (data->lockflag+3==data->trackflag) + if (data->lockflag + 3 == data->trackflag) curcon->flag |= CONSTRAINT_DISABLE; } else if (curcon->type == CONSTRAINT_TYPE_SPLINEIK) { @@ -391,7 +391,7 @@ static void test_constraints (Object *owner, bPoseChannel *pchan) /* if the number of points does not match the amount required by the chain length, * free the points array and request a rebind... */ - if ((data->points == NULL) || (data->numpoints != data->chainlen+1)) { + if ((data->points == NULL) || (data->numpoints != data->chainlen + 1)) { /* free the points array */ if (data->points) { MEM_freeN(data->points); @@ -405,15 +405,15 @@ 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->flag & CAMERASOLVER_ACTIVECLIP) == 0) { if (data->clip != NULL && data->track[0]) { - MovieTracking *tracking= &data->clip->tracking; + MovieTracking *tracking = &data->clip->tracking; MovieTrackingObject *tracking_object; if (data->object[0]) - tracking_object= BKE_tracking_named_object(tracking, data->object); + tracking_object = BKE_tracking_named_object(tracking, data->object); else - tracking_object= BKE_tracking_get_camera_object(tracking); + tracking_object = BKE_tracking_get_camera_object(tracking); if (!tracking_object) { curcon->flag |= CONSTRAINT_DISABLE; @@ -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; } @@ -444,7 +444,7 @@ static void test_constraints (Object *owner, bPoseChannel *pchan) cti->get_constraint_targets(curcon, &targets); /* disable and clear constraints targets that are incorrect */ - for (ct= targets.first; ct; ct= ct->next) { + for (ct = targets.first; ct; ct = ct->next) { /* general validity checks (for those constraints that need this) */ if (exist_object(ct->tar) == 0) { /* object doesn't exist, but constraint requires target */ @@ -475,11 +475,11 @@ static void test_constraints (Object *owner, bPoseChannel *pchan) if (ELEM3(curcon->type, CONSTRAINT_TYPE_FOLLOWPATH, CONSTRAINT_TYPE_CLAMPTO, CONSTRAINT_TYPE_SPLINEIK)) { if (ct->tar) { if (ct->tar->type != OB_CURVE) { - ct->tar= NULL; + ct->tar = NULL; curcon->flag |= CONSTRAINT_DISABLE; } else { - Curve *cu= ct->tar->data; + Curve *cu = ct->tar->data; /* auto-set 'Path' setting on curve so this works */ cu->flag |= CU_PATH; @@ -496,15 +496,15 @@ static void test_constraints (Object *owner, bPoseChannel *pchan) } } -void object_test_constraints (Object *owner) +void object_test_constraints(Object *owner) { if (owner->constraints.first) test_constraints(owner, NULL); - if (owner->type==OB_ARMATURE && owner->pose) { + if (owner->type == OB_ARMATURE && owner->pose) { bPoseChannel *pchan; - for (pchan= owner->pose->chanbase.first; pchan; pchan= pchan->next) { + for (pchan = owner->pose->chanbase.first; pchan; pchan = pchan->next) { if (pchan->constraints.first) test_constraints(owner, pchan); } @@ -514,8 +514,8 @@ void object_test_constraints (Object *owner) /************************ generic functions for operators using constraint names and data context *********************/ -#define EDIT_CONSTRAINT_OWNER_OBJECT 0 -#define EDIT_CONSTRAINT_OWNER_BONE 1 +#define EDIT_CONSTRAINT_OWNER_OBJECT 0 +#define EDIT_CONSTRAINT_OWNER_BONE 1 static EnumPropertyItem constraint_owner_items[] = { {EDIT_CONSTRAINT_OWNER_OBJECT, "OBJECT", 0, "Object", "Edit a constraint on the active object"}, @@ -525,11 +525,11 @@ static EnumPropertyItem constraint_owner_items[] = { static int edit_constraint_poll_generic(bContext *C, StructRNA *rna_type) { - PointerRNA ptr= CTX_data_pointer_get_type(C, "constraint", rna_type); - Object *ob= (ptr.id.data) ? ptr.id.data : ED_object_active_context(C); + PointerRNA ptr = CTX_data_pointer_get_type(C, "constraint", rna_type); + Object *ob = (ptr.id.data) ? ptr.id.data : ED_object_active_context(C); if (!ob || ob->id.lib) return 0; - if (ptr.id.data && ((ID*)ptr.id.data)->lib) return 0; + if (ptr.id.data && ((ID *)ptr.id.data)->lib) return 0; return 1; } @@ -547,8 +547,8 @@ static void edit_constraint_properties(wmOperatorType *ot) static int edit_constraint_invoke_properties(bContext *C, wmOperator *op) { - PointerRNA ptr= CTX_data_pointer_get_type(C, "constraint", &RNA_Constraint); - Object *ob= (ptr.id.data)?ptr.id.data:ED_object_active_context(C); + PointerRNA ptr = CTX_data_pointer_get_type(C, "constraint", &RNA_Constraint); + Object *ob = (ptr.id.data) ? ptr.id.data : ED_object_active_context(C); bConstraint *con; ListBase *list; @@ -577,7 +577,7 @@ static bConstraint *edit_constraint_property_get(wmOperator *op, Object *ob, int char constraint_name[MAX_NAME]; int owner = RNA_enum_get(op->ptr, "owner"); bConstraint *con; - ListBase *list=NULL; + ListBase *list = NULL; RNA_string_get(op->ptr, "constraint", constraint_name); @@ -585,7 +585,7 @@ static bConstraint *edit_constraint_property_get(wmOperator *op, Object *ob, int list = &ob->constraints; } else if (owner == EDIT_CONSTRAINT_OWNER_BONE) { - bPoseChannel *pchan= get_active_posechannel(ob); + bPoseChannel *pchan = get_active_posechannel(ob); if (pchan) list = &pchan->constraints; else { @@ -615,11 +615,11 @@ static bConstraint *edit_constraint_property_get(wmOperator *op, Object *ob, int /* ---------- Distance-Dependent Constraints ---------- */ /* StretchTo, Limit Distance */ -static int stretchto_reset_exec (bContext *C, wmOperator *op) +static int stretchto_reset_exec(bContext *C, wmOperator *op) { Object *ob = ED_object_active_context(C); bConstraint *con = edit_constraint_property_get(op, ob, CONSTRAINT_TYPE_STRETCHTO); - bStretchToConstraint *data= (con) ? (bStretchToConstraint *)con->data : NULL; + bStretchToConstraint *data = (con) ? (bStretchToConstraint *)con->data : NULL; /* despite 3 layers of checks, we may still not be able to find a constraint */ if (data == NULL) @@ -629,7 +629,7 @@ static int stretchto_reset_exec (bContext *C, wmOperator *op) data->orglength = 0.0f; ED_object_constraint_update(ob); - WM_event_add_notifier(C, NC_OBJECT|ND_CONSTRAINT, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, NULL); return OPERATOR_FINISHED; } @@ -641,7 +641,7 @@ static int stretchto_reset_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(e return OPERATOR_CANCELLED; } -void CONSTRAINT_OT_stretchto_reset (wmOperatorType *ot) +void CONSTRAINT_OT_stretchto_reset(wmOperatorType *ot) { /* identifiers */ ot->name = "Reset Original Length"; @@ -653,16 +653,16 @@ void CONSTRAINT_OT_stretchto_reset (wmOperatorType *ot) ot->poll = edit_constraint_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; edit_constraint_properties(ot); } -static int limitdistance_reset_exec (bContext *C, wmOperator *op) +static int limitdistance_reset_exec(bContext *C, wmOperator *op) { Object *ob = ED_object_active_context(C); bConstraint *con = edit_constraint_property_get(op, ob, CONSTRAINT_TYPE_DISTLIMIT); - bDistLimitConstraint *data= (con) ? (bDistLimitConstraint *)con->data : NULL; + bDistLimitConstraint *data = (con) ? (bDistLimitConstraint *)con->data : NULL; /* despite 3 layers of checks, we may still not be able to find a constraint */ if (data == NULL) @@ -672,7 +672,7 @@ static int limitdistance_reset_exec (bContext *C, wmOperator *op) data->dist = 0.0f; ED_object_constraint_update(ob); - WM_event_add_notifier(C, NC_OBJECT|ND_CONSTRAINT, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, NULL); return OPERATOR_FINISHED; } @@ -684,7 +684,7 @@ static int limitdistance_reset_invoke(bContext *C, wmOperator *op, wmEvent *UNUS return OPERATOR_CANCELLED; } -void CONSTRAINT_OT_limitdistance_reset (wmOperatorType *ot) +void CONSTRAINT_OT_limitdistance_reset(wmOperatorType *ot) { /* identifiers */ ot->name = "Reset Distance"; @@ -696,16 +696,16 @@ void CONSTRAINT_OT_limitdistance_reset (wmOperatorType *ot) ot->poll = edit_constraint_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; edit_constraint_properties(ot); } /* ------------- Child-Of Constraint ------------------ */ -static void child_get_inverse_matrix (Scene *scene, Object *ob, bConstraint *con, float invmat[4][4]) +static void child_get_inverse_matrix(Scene *scene, Object *ob, bConstraint *con, float invmat[4][4]) { bConstraint *lastcon = NULL; - bPoseChannel *pchan= NULL; + bPoseChannel *pchan = NULL; /* nullify inverse matrix first */ unit_m4(invmat); @@ -713,13 +713,13 @@ static void child_get_inverse_matrix (Scene *scene, Object *ob, bConstraint *con /* try to find a pose channel - assume that this is the constraint owner */ // TODO: get from context instead? if (ob && ob->pose) - pchan= get_active_posechannel(ob); + pchan = get_active_posechannel(ob); /* calculate/set inverse matrix: - * We just calculate all transform-stack eval up to but not including this constraint. - * This is because inverse should just inverse correct for just the constraint's influence - * when it gets applied; that is, at the time of application, we don't know anything about - * what follows. + * We just calculate all transform-stack eval up to but not including this constraint. + * This is because inverse should just inverse correct for just the constraint's influence + * when it gets applied; that is, at the time of application, we don't know anything about + * what follows. */ if (pchan) { float imat[4][4], tmat[4][4]; @@ -781,23 +781,23 @@ static void child_get_inverse_matrix (Scene *scene, Object *ob, bConstraint *con } /* ChildOf Constraint - set inverse callback */ -static int childof_set_inverse_exec (bContext *C, wmOperator *op) +static int childof_set_inverse_exec(bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); Object *ob = ED_object_active_context(C); bConstraint *con = edit_constraint_property_get(op, ob, CONSTRAINT_TYPE_CHILDOF); - bChildOfConstraint *data= (con) ? (bChildOfConstraint *)con->data : NULL; + bChildOfConstraint *data = (con) ? (bChildOfConstraint *)con->data : NULL; /* despite 3 layers of checks, we may still not be able to find a constraint */ if (data == NULL) { - printf("DEBUG: Child-Of Set Inverse - object = '%s'\n", (ob)? ob->id.name+2 : ""); + printf("DEBUG: Child-Of Set Inverse - object = '%s'\n", (ob) ? ob->id.name + 2 : ""); BKE_report(op->reports, RPT_ERROR, "Couldn't find constraint data for Child-Of Set Inverse"); return OPERATOR_CANCELLED; } child_get_inverse_matrix(scene, ob, con, data->invmat); - WM_event_add_notifier(C, NC_OBJECT|ND_CONSTRAINT, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, ob); return OPERATOR_FINISHED; } @@ -810,7 +810,7 @@ static int childof_set_inverse_invoke(bContext *C, wmOperator *op, wmEvent *UNUS return OPERATOR_CANCELLED; } -void CONSTRAINT_OT_childof_set_inverse (wmOperatorType *ot) +void CONSTRAINT_OT_childof_set_inverse(wmOperatorType *ot) { /* identifiers */ ot->name = "Set Inverse"; @@ -822,18 +822,18 @@ void CONSTRAINT_OT_childof_set_inverse (wmOperatorType *ot) ot->poll = edit_constraint_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; edit_constraint_properties(ot); } /* ChildOf Constraint - clear inverse callback */ -static int childof_clear_inverse_exec (bContext *C, wmOperator *op) +static int childof_clear_inverse_exec(bContext *C, wmOperator *op) { Object *ob = ED_object_active_context(C); bConstraint *con = edit_constraint_property_get(op, ob, CONSTRAINT_TYPE_CHILDOF); - bChildOfConstraint *data= (con) ? (bChildOfConstraint *)con->data : NULL; + 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; } @@ -841,7 +841,7 @@ static int childof_clear_inverse_exec (bContext *C, wmOperator *op) /* simply clear the matrix */ unit_m4(data->invmat); - WM_event_add_notifier(C, NC_OBJECT|ND_CONSTRAINT, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, ob); return OPERATOR_FINISHED; } @@ -854,7 +854,7 @@ static int childof_clear_inverse_invoke(bContext *C, wmOperator *op, wmEvent *UN return OPERATOR_CANCELLED; } -void CONSTRAINT_OT_childof_clear_inverse (wmOperatorType *ot) +void CONSTRAINT_OT_childof_clear_inverse(wmOperatorType *ot) { /* identifiers */ ot->name = "Clear Inverse"; @@ -866,29 +866,29 @@ void CONSTRAINT_OT_childof_clear_inverse (wmOperatorType *ot) ot->poll = edit_constraint_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; edit_constraint_properties(ot); } /* ------------- Object Solver Constraint ------------------ */ -static int objectsolver_set_inverse_exec (bContext *C, wmOperator *op) +static int objectsolver_set_inverse_exec(bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); Object *ob = ED_object_active_context(C); bConstraint *con = edit_constraint_property_get(op, ob, CONSTRAINT_TYPE_OBJECTSOLVER); - bObjectSolverConstraint *data= (con) ? (bObjectSolverConstraint *)con->data : NULL; + bObjectSolverConstraint *data = (con) ? (bObjectSolverConstraint *)con->data : NULL; /* despite 3 layers of checks, we may still not be able to find a constraint */ if (data == NULL) { - printf("DEBUG: Child-Of Set Inverse - object = '%s'\n", (ob)? ob->id.name+2 : ""); + printf("DEBUG: Child-Of Set Inverse - object = '%s'\n", (ob) ? ob->id.name + 2 : ""); BKE_report(op->reports, RPT_ERROR, "Couldn't find constraint data for Child-Of Set Inverse"); return OPERATOR_CANCELLED; } child_get_inverse_matrix(scene, ob, con, data->invmat); - WM_event_add_notifier(C, NC_OBJECT|ND_CONSTRAINT, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, ob); return OPERATOR_FINISHED; } @@ -901,7 +901,7 @@ static int objectsolver_set_inverse_invoke(bContext *C, wmOperator *op, wmEvent return OPERATOR_CANCELLED; } -void CONSTRAINT_OT_objectsolver_set_inverse (wmOperatorType *ot) +void CONSTRAINT_OT_objectsolver_set_inverse(wmOperatorType *ot) { /* identifiers */ ot->name = "Set Inverse"; @@ -913,17 +913,17 @@ void CONSTRAINT_OT_objectsolver_set_inverse (wmOperatorType *ot) ot->poll = edit_constraint_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; edit_constraint_properties(ot); } -static int objectsolver_clear_inverse_exec (bContext *C, wmOperator *op) +static int objectsolver_clear_inverse_exec(bContext *C, wmOperator *op) { Object *ob = ED_object_active_context(C); bConstraint *con = edit_constraint_property_get(op, ob, CONSTRAINT_TYPE_OBJECTSOLVER); - bObjectSolverConstraint *data= (con) ? (bObjectSolverConstraint *)con->data : NULL; + 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; } @@ -931,7 +931,7 @@ static int objectsolver_clear_inverse_exec (bContext *C, wmOperator *op) /* simply clear the matrix */ unit_m4(data->invmat); - WM_event_add_notifier(C, NC_OBJECT|ND_CONSTRAINT, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, ob); return OPERATOR_FINISHED; } @@ -944,7 +944,7 @@ static int objectsolver_clear_inverse_invoke(bContext *C, wmOperator *op, wmEven return OPERATOR_CANCELLED; } -void CONSTRAINT_OT_objectsolver_clear_inverse (wmOperatorType *ot) +void CONSTRAINT_OT_objectsolver_clear_inverse(wmOperatorType *ot) { /* identifiers */ ot->name = "Clear Inverse"; @@ -956,7 +956,7 @@ void CONSTRAINT_OT_objectsolver_clear_inverse (wmOperatorType *ot) ot->poll = edit_constraint_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; edit_constraint_properties(ot); } @@ -981,7 +981,7 @@ void ED_object_constraint_update(Object *ob) 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,23 +989,23 @@ 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); } static int constraint_poll(bContext *C) { - PointerRNA ptr= CTX_data_pointer_get_type(C, "constraint", &RNA_Constraint); + PointerRNA ptr = CTX_data_pointer_get_type(C, "constraint", &RNA_Constraint); return (ptr.id.data && ptr.data); } -static int constraint_delete_exec (bContext *C, wmOperator *UNUSED(op)) +static int constraint_delete_exec(bContext *C, wmOperator *UNUSED(op)) { - PointerRNA ptr= CTX_data_pointer_get_type(C, "constraint", &RNA_Constraint); - Object *ob= ptr.id.data; - bConstraint *con= ptr.data; + PointerRNA ptr = CTX_data_pointer_get_type(C, "constraint", &RNA_Constraint); + Object *ob = ptr.id.data; + bConstraint *con = ptr.data; ListBase *lb = get_constraint_lb(ob, con, NULL); - const short is_ik= ELEM(con->type, CONSTRAINT_TYPE_KINEMATIC, CONSTRAINT_TYPE_SPLINEIK); + const short is_ik = ELEM(con->type, CONSTRAINT_TYPE_KINEMATIC, CONSTRAINT_TYPE_SPLINEIK); /* free the constraint */ if (remove_constraint(lb, con)) { @@ -1020,7 +1020,7 @@ static int constraint_delete_exec (bContext *C, wmOperator *UNUSED(op)) } /* notifiers */ - WM_event_add_notifier(C, NC_OBJECT|ND_CONSTRAINT|NA_REMOVED, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT | NA_REMOVED, ob); return OPERATOR_FINISHED; } @@ -1030,7 +1030,7 @@ static int constraint_delete_exec (bContext *C, wmOperator *UNUSED(op)) } } -void CONSTRAINT_OT_delete (wmOperatorType *ot) +void CONSTRAINT_OT_delete(wmOperatorType *ot) { /* identifiers */ ot->name = "Delete Constraint"; @@ -1042,23 +1042,23 @@ void CONSTRAINT_OT_delete (wmOperatorType *ot) ot->poll = constraint_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } -static int constraint_move_down_exec (bContext *C, wmOperator *op) +static int constraint_move_down_exec(bContext *C, wmOperator *op) { Object *ob = ED_object_active_context(C); bConstraint *con = edit_constraint_property_get(op, ob, 0); if (con && con->next) { - ListBase *conlist= get_constraint_lb(ob, con, NULL); - bConstraint *nextCon= con->next; + ListBase *conlist = get_constraint_lb(ob, con, NULL); + bConstraint *nextCon = con->next; /* insert the nominated constraint after the one that used to be after it */ BLI_remlink(conlist, con); BLI_insertlinkafter(conlist, nextCon, con); - WM_event_add_notifier(C, NC_OBJECT|ND_CONSTRAINT, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, ob); return OPERATOR_FINISHED; } @@ -1075,7 +1075,7 @@ static int constraint_move_down_invoke(bContext *C, wmOperator *op, wmEvent *UNU } -void CONSTRAINT_OT_move_down (wmOperatorType *ot) +void CONSTRAINT_OT_move_down(wmOperatorType *ot) { /* identifiers */ ot->name = "Move Constraint Down"; @@ -1088,25 +1088,25 @@ void CONSTRAINT_OT_move_down (wmOperatorType *ot) ot->poll = edit_constraint_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; edit_constraint_properties(ot); } -static int constraint_move_up_exec (bContext *C, wmOperator *op) +static int constraint_move_up_exec(bContext *C, wmOperator *op) { Object *ob = ED_object_active_context(C); bConstraint *con = edit_constraint_property_get(op, ob, 0); if (con && con->prev) { - ListBase *conlist= get_constraint_lb(ob, con, NULL); - bConstraint *prevCon= con->prev; + ListBase *conlist = get_constraint_lb(ob, con, NULL); + bConstraint *prevCon = con->prev; /* insert the nominated constraint before the one that used to be before it */ BLI_remlink(conlist, con); BLI_insertlinkbefore(conlist, prevCon, con); - WM_event_add_notifier(C, NC_OBJECT|ND_CONSTRAINT, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, ob); return OPERATOR_FINISHED; } @@ -1122,7 +1122,7 @@ static int constraint_move_up_invoke(bContext *C, wmOperator *op, wmEvent *UNUSE return OPERATOR_CANCELLED; } -void CONSTRAINT_OT_move_up (wmOperatorType *ot) +void CONSTRAINT_OT_move_up(wmOperatorType *ot) { /* identifiers */ ot->name = "Move Constraint Up"; @@ -1135,7 +1135,7 @@ void CONSTRAINT_OT_move_up (wmOperatorType *ot) ot->poll = edit_constraint_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; edit_constraint_properties(ot); } @@ -1145,25 +1145,25 @@ void CONSTRAINT_OT_move_up (wmOperatorType *ot) static int pose_constraints_clear_exec(bContext *C, wmOperator *UNUSED(op)) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); - Object *ob= object_pose_armature_get(CTX_data_active_object(C)); + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + Object *ob = object_pose_armature_get(CTX_data_active_object(C)); /* free constraints for all selected bones */ - CTX_DATA_BEGIN (C, bPoseChannel*, pchan, selected_pose_bones) { + CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones) { free_constraints(&pchan->constraints); - pchan->constflag &= ~(PCHAN_HAS_IK|PCHAN_HAS_SPLINEIK|PCHAN_HAS_CONST); + pchan->constflag &= ~(PCHAN_HAS_IK | PCHAN_HAS_SPLINEIK | PCHAN_HAS_CONST); } CTX_DATA_END; /* force depsgraph to get recalculated since relationships removed */ - DAG_scene_sort(bmain, scene); /* sort order of objects */ + DAG_scene_sort(bmain, scene); /* sort order of objects */ /* note, calling BIK_clear_data() isn't needed here */ /* do updates */ DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_OBJECT|ND_CONSTRAINT, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, ob); return OPERATOR_FINISHED; } @@ -1183,21 +1183,21 @@ void POSE_OT_constraints_clear(wmOperatorType *ot) static int object_constraints_clear_exec(bContext *C, wmOperator *UNUSED(op)) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); /* do freeing */ - CTX_DATA_BEGIN (C, Object*, ob, selected_editable_objects) { + CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) { free_constraints(&ob->constraints); DAG_id_tag_update(&ob->id, OB_RECALC_OB); } CTX_DATA_END; /* force depsgraph to get recalculated since relationships removed */ - DAG_scene_sort(bmain, scene); /* sort order of objects */ + DAG_scene_sort(bmain, scene); /* sort order of objects */ /* do updates */ - WM_event_add_notifier(C, NC_OBJECT|ND_CONSTRAINT, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, NULL); return OPERATOR_FINISHED; } @@ -1218,7 +1218,7 @@ void OBJECT_OT_constraints_clear(wmOperatorType *ot) static int pose_constraint_copy_exec(bContext *C, wmOperator *op) { - Main *bmain= CTX_data_main(C); + Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); bPoseChannel *pchan = CTX_data_active_pose_bone(C); @@ -1229,7 +1229,7 @@ static int pose_constraint_copy_exec(bContext *C, wmOperator *op) } /* copy all constraints from active posebone to all selected posebones */ - CTX_DATA_BEGIN (C, bPoseChannel*, chan, selected_pose_bones) { + CTX_DATA_BEGIN (C, bPoseChannel *, chan, selected_pose_bones) { /* if we're not handling the object we're copying from, copy all constraints over */ if (pchan != chan) { copy_constraints(&chan->constraints, &pchan->constraints, TRUE); @@ -1240,9 +1240,9 @@ static int pose_constraint_copy_exec(bContext *C, wmOperator *op) CTX_DATA_END; /* force depsgraph to get recalculated since new relationships added */ - DAG_scene_sort(bmain, scene); /* sort order of objects/bones */ + DAG_scene_sort(bmain, scene); /* sort order of objects/bones */ - WM_event_add_notifier(C, NC_OBJECT|ND_CONSTRAINT, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, NULL); return OPERATOR_FINISHED; } @@ -1259,17 +1259,17 @@ void POSE_OT_constraints_copy(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } static int object_constraint_copy_exec(bContext *C, wmOperator *UNUSED(op)) { - Main *bmain= CTX_data_main(C); + Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); Object *obact = ED_object_active_context(C); /* copy all constraints from active object to all selected objects */ - CTX_DATA_BEGIN (C, Object*, ob, selected_editable_objects) { + CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) { /* if we're not handling the object we're copying from, copy all constraints over */ if (obact != ob) { copy_constraints(&ob->constraints, &obact->constraints, TRUE); @@ -1279,10 +1279,10 @@ static int object_constraint_copy_exec(bContext *C, wmOperator *UNUSED(op)) CTX_DATA_END; /* force depsgraph to get recalculated since new relationships added */ - DAG_scene_sort(bmain, scene); /* sort order of objects */ + DAG_scene_sort(bmain, scene); /* sort order of objects */ /* notifiers for updates */ - WM_event_add_notifier(C, NC_OBJECT|ND_CONSTRAINT|NA_ADDED, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT | NA_ADDED, NULL); return OPERATOR_FINISHED; } @@ -1299,7 +1299,7 @@ void OBJECT_OT_constraints_copy(wmOperatorType *ot) ot->poll = ED_operator_object_active_editable; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /************************ add constraint operators *********************/ @@ -1307,25 +1307,25 @@ void OBJECT_OT_constraints_copy(wmOperatorType *ot) /* get the Object and/or PoseChannel to use as target */ static short get_new_constraint_target(bContext *C, int con_type, Object **tar_ob, bPoseChannel **tar_pchan, short add) { - Object *obact= ED_object_active_context(C); - bPoseChannel *pchanact= get_active_posechannel(obact); - short only_curve= 0, only_mesh= 0, only_ob= 0; - short found= 0; + Object *obact = ED_object_active_context(C); + bPoseChannel *pchanact = get_active_posechannel(obact); + short only_curve = 0, only_mesh = 0, only_ob = 0; + short found = 0; /* clear tar_ob and tar_pchan fields before use * - assume for now that both always exist... */ - *tar_ob= NULL; - *tar_pchan= NULL; + *tar_ob = NULL; + *tar_pchan = NULL; /* check if constraint type doesn't requires a target * - if so, no need to get any targets */ switch (con_type) { /* no-target constraints --------------------------- */ - /* null constraint - shouldn't even be added! */ + /* null constraint - shouldn't even be added! */ case CONSTRAINT_TYPE_NULL: - /* limit constraints - no targets needed */ + /* limit constraints - no targets needed */ case CONSTRAINT_TYPE_LOCLIMIT: case CONSTRAINT_TYPE_ROTLIMIT: case CONSTRAINT_TYPE_SIZELIMIT: @@ -1334,37 +1334,37 @@ static short get_new_constraint_target(bContext *C, int con_type, Object **tar_o /* restricted target-type constraints -------------- */ /* NOTE: for these, we cannot try to add a target object if no valid ones are found, since that doesn't work */ - /* curve-based constraints - set the only_curve and only_ob flags */ + /* curve-based constraints - set the only_curve and only_ob flags */ case CONSTRAINT_TYPE_CLAMPTO: case CONSTRAINT_TYPE_FOLLOWPATH: case CONSTRAINT_TYPE_SPLINEIK: - only_curve= 1; - only_ob= 1; - add= 0; + only_curve = 1; + only_ob = 1; + add = 0; break; - /* mesh only? */ + /* mesh only? */ case CONSTRAINT_TYPE_SHRINKWRAP: - only_mesh= 1; - only_ob= 1; - add= 0; + only_mesh = 1; + only_ob = 1; + add = 0; break; - /* object only - add here is ok? */ + /* object only - add here is ok? */ case CONSTRAINT_TYPE_RIGIDBODYJOINT: - only_ob= 1; + only_ob = 1; break; } /* if the active Object is Armature, and we can search for bones, do so... */ if ((obact->type == OB_ARMATURE) && (only_ob == 0)) { /* search in list of selected Pose-Channels for target */ - CTX_DATA_BEGIN (C, bPoseChannel*, pchan, selected_pose_bones) { + CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones) { /* just use the first one that we encounter, as long as it is not the active one */ if (pchan != pchanact) { - *tar_ob= obact; - *tar_pchan= pchan; - found= 1; + *tar_ob = obact; + *tar_pchan = pchan; + found = 1; break; } @@ -1375,22 +1375,22 @@ static short get_new_constraint_target(bContext *C, int con_type, Object **tar_o /* if not yet found, try selected Objects... */ if (found == 0) { /* search in selected objects context */ - CTX_DATA_BEGIN (C, Object*, ob, selected_objects) { + CTX_DATA_BEGIN (C, Object *, ob, selected_objects) { /* just use the first object we encounter (that isn't the active object) * and which fulfills the criteria for the object-target that we've got */ if ( (ob != obact) && - ((!only_curve) || (ob->type == OB_CURVE)) && - ((!only_mesh) || (ob->type == OB_MESH)) ) + ((!only_curve) || (ob->type == OB_CURVE)) && + ((!only_mesh) || (ob->type == OB_MESH)) ) { /* set target */ - *tar_ob= ob; - found= 1; + *tar_ob = ob; + found = 1; /* perform some special operations on the target */ if (only_curve) { /* Curve-Path option must be enabled for follow-path constraints to be able to work */ - Curve *cu= (Curve *)ob->data; + Curve *cu = (Curve *)ob->data; cu->flag |= CU_PATH; } @@ -1402,17 +1402,17 @@ static short get_new_constraint_target(bContext *C, int con_type, Object **tar_o /* if still not found, add a new empty to act as a target (if allowed) */ if ((found == 0) && (add)) { - Scene *scene= CTX_data_scene(C); - Base *base= BASACT, *newbase=NULL; + Scene *scene = CTX_data_scene(C); + Base *base = BASACT, *newbase = NULL; Object *obt; /* add new target object */ - obt= add_object(scene, OB_EMPTY); + obt = add_object(scene, OB_EMPTY); /* set layers OK */ - newbase= BASACT; - newbase->lay= base->lay; - obt->lay= newbase->lay; + newbase = BASACT; + newbase->lay = base->lay; + obt->lay = newbase->lay; /* transform cent to global coords for loc */ if (pchanact) { @@ -1429,12 +1429,12 @@ static short get_new_constraint_target(bContext *C, int con_type, Object **tar_o } /* restore, add_object sets active */ - BASACT= base; + BASACT = base; base->flag |= SELECT; /* make our new target the new object */ - *tar_ob= obt; - found= 1; + *tar_ob = obt; + found = 1; } /* return whether there's any target */ @@ -1444,16 +1444,16 @@ static short get_new_constraint_target(bContext *C, int con_type, Object **tar_o /* used by add constraint operators to add the constraint required */ static int constraint_add_exec(bContext *C, wmOperator *op, Object *ob, ListBase *list, int type, short setTarget) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); bPoseChannel *pchan; bConstraint *con; if (list == &ob->constraints) { - pchan= NULL; + pchan = NULL; } else { - pchan= get_active_posechannel(ob); + pchan = get_active_posechannel(ob); /* ensure not to confuse object/pose adding */ if (pchan == NULL) { @@ -1488,8 +1488,8 @@ static int constraint_add_exec(bContext *C, wmOperator *op, Object *ob, ListBase * - apart from the buttons-window add buttons, we shouldn't add in this way */ if (setTarget) { - Object *tar_ob= NULL; - bPoseChannel *tar_pchan= NULL; + Object *tar_ob = NULL; + bPoseChannel *tar_pchan = NULL; /* get the target objects, adding them as need be */ if (get_new_constraint_target(C, type, &tar_ob, &tar_pchan, 1)) { @@ -1509,7 +1509,7 @@ static int constraint_add_exec(bContext *C, wmOperator *op, Object *ob, ListBase { #ifdef WITH_PYTHON char *menustr; - int scriptint= 0; + int scriptint = 0; /* popup a list of usable scripts */ menustr = buildmenu_pyconstraints(NULL, &scriptint); // XXX scriptint = pupmenu(menustr); @@ -1539,17 +1539,17 @@ static int constraint_add_exec(bContext *C, wmOperator *op, Object *ob, ListBase /* force depsgraph to get recalculated since new relationships added */ - DAG_scene_sort(bmain, scene); /* sort order of objects */ + DAG_scene_sort(bmain, scene); /* sort order of objects */ - if ((ob->type==OB_ARMATURE) && (pchan)) { - ob->pose->flag |= POSE_RECALC; /* sort pose channels */ - DAG_id_tag_update(&ob->id, OB_RECALC_DATA|OB_RECALC_OB); + if ((ob->type == OB_ARMATURE) && (pchan)) { + ob->pose->flag |= POSE_RECALC; /* sort pose channels */ + DAG_id_tag_update(&ob->id, OB_RECALC_DATA | OB_RECALC_OB); } else DAG_id_tag_update(&ob->id, OB_RECALC_DATA); /* notifiers for updates */ - WM_event_add_notifier(C, NC_OBJECT|ND_CONSTRAINT|NA_ADDED, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT | NA_ADDED, ob); return OPERATOR_FINISHED; } @@ -1559,9 +1559,9 @@ static int constraint_add_exec(bContext *C, wmOperator *op, Object *ob, ListBase /* dummy operator callback */ static int object_constraint_add_exec(bContext *C, wmOperator *op) { - Object *ob=ED_object_active_context(C); - int type= RNA_enum_get(op->ptr, "type"); - short with_targets= 0; + Object *ob = ED_object_active_context(C); + int type = RNA_enum_get(op->ptr, "type"); + short with_targets = 0; if (!ob) { BKE_report(op->reports, RPT_ERROR, "No active object to add constraint to"); @@ -1572,7 +1572,7 @@ static int object_constraint_add_exec(bContext *C, wmOperator *op) * operator name included 'with_targets', since the menu doesn't allow multiple properties */ if (strstr(op->idname, "with_targets")) - with_targets= 1; + with_targets = 1; return constraint_add_exec(C, op, ob, &ob->constraints, type, with_targets); } @@ -1580,9 +1580,9 @@ static int object_constraint_add_exec(bContext *C, wmOperator *op) /* dummy operator callback */ static int pose_constraint_add_exec(bContext *C, wmOperator *op) { - Object *ob= object_pose_armature_get(ED_object_active_context(C)); - int type= RNA_enum_get(op->ptr, "type"); - short with_targets= 0; + Object *ob = object_pose_armature_get(ED_object_active_context(C)); + int type = RNA_enum_get(op->ptr, "type"); + short with_targets = 0; if (!ob) { BKE_report(op->reports, RPT_ERROR, "No active object to add constraint to"); @@ -1593,7 +1593,7 @@ static int pose_constraint_add_exec(bContext *C, wmOperator *op) * operator name included 'with_targets', since the menu doesn't allow multiple properties */ if (strstr(op->idname, "with_targets")) - with_targets= 1; + with_targets = 1; return constraint_add_exec(C, op, ob, get_active_constraints(ob), type, with_targets); } @@ -1613,7 +1613,7 @@ void OBJECT_OT_constraint_add(wmOperatorType *ot) ot->poll = ED_operator_object_active_editable; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ ot->prop = RNA_def_enum(ot->srna, "type", constraint_type_items, 0, "Type", ""); @@ -1632,7 +1632,7 @@ void OBJECT_OT_constraint_add_with_targets(wmOperatorType *ot) ot->poll = ED_operator_object_active_editable; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ ot->prop = RNA_def_enum(ot->srna, "type", constraint_type_items, 0, "Type", ""); @@ -1651,7 +1651,7 @@ void POSE_OT_constraint_add(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ ot->prop = RNA_def_enum(ot->srna, "type", constraint_type_items, 0, "Type", ""); @@ -1670,7 +1670,7 @@ void POSE_OT_constraint_add_with_targets(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ ot->prop = RNA_def_enum(ot->srna, "type", constraint_type_items, 0, "Type", ""); @@ -1683,14 +1683,14 @@ void POSE_OT_constraint_add_with_targets(wmOperatorType *ot) /* present menu with options + validation for targets to use */ static int pose_ik_add_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(evt)) { - Object *ob= object_pose_armature_get(CTX_data_active_object(C)); - bPoseChannel *pchan= get_active_posechannel(ob); - bConstraint *con= NULL; + Object *ob = object_pose_armature_get(CTX_data_active_object(C)); + bPoseChannel *pchan = get_active_posechannel(ob); + bConstraint *con = NULL; uiPopupMenu *pup; uiLayout *layout; - Object *tar_ob= NULL; - bPoseChannel *tar_pchan= NULL; + Object *tar_ob = NULL; + bPoseChannel *tar_pchan = NULL; /* must have active bone */ if (ELEM(NULL, ob, pchan)) { @@ -1699,8 +1699,8 @@ static int pose_ik_add_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(evt)) } /* bone must not have any constraints already */ - for (con= pchan->constraints.first; con; con= con->next) { - if (con->type==CONSTRAINT_TYPE_KINEMATIC) break; + for (con = pchan->constraints.first; con; con = con->next) { + if (con->type == CONSTRAINT_TYPE_KINEMATIC) break; } if (con) { BKE_report(op->reports, RPT_ERROR, "Bone already has IK Constraint"); @@ -1708,8 +1708,8 @@ static int pose_ik_add_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(evt)) } /* prepare popup menu to choose targetting options */ - pup= uiPupMenuBegin(C, "Add IK", ICON_NONE); - layout= uiPupMenuLayout(pup); + pup = uiPupMenuBegin(C, "Add IK", ICON_NONE); + layout = uiPupMenuLayout(pup); /* the type of targets we'll set determines the menu entries to show... */ if (get_new_constraint_target(C, CONSTRAINT_TYPE_KINEMATIC, &tar_ob, &tar_pchan, 0)) { @@ -1736,8 +1736,8 @@ static int pose_ik_add_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(evt)) /* call constraint_add_exec() to add the IK constraint */ static int pose_ik_add_exec(bContext *C, wmOperator *op) { - Object *ob= CTX_data_active_object(C); - int with_targets= RNA_boolean_get(op->ptr, "with_targets"); + Object *ob = CTX_data_active_object(C); + int with_targets = RNA_boolean_get(op->ptr, "with_targets"); /* add the constraint - all necessary checks should have been done by the invoke() callback already... */ return constraint_add_exec(C, op, ob, get_active_constraints(ob), CONSTRAINT_TYPE_KINEMATIC, with_targets); @@ -1756,7 +1756,7 @@ void POSE_OT_ik_add(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_boolean(ot->srna, "with_targets", 1, "With Targets", "Assign IK Constraint with targets derived from the select bones/objects"); @@ -1767,20 +1767,20 @@ void POSE_OT_ik_add(wmOperatorType *ot) /* remove IK constraints from selected bones */ static int pose_ik_clear_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *ob= object_pose_armature_get(CTX_data_active_object(C)); + Object *ob = object_pose_armature_get(CTX_data_active_object(C)); /* only remove IK Constraints */ - CTX_DATA_BEGIN (C, bPoseChannel*, pchan, selected_pose_bones) { + CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones) { bConstraint *con, *next; // TODO: should we be checking if these contraints were local before we try and remove them? - for (con= pchan->constraints.first; con; con= next) { - next= con->next; - if (con->type==CONSTRAINT_TYPE_KINEMATIC) { + for (con = pchan->constraints.first; con; con = next) { + next = con->next; + if (con->type == CONSTRAINT_TYPE_KINEMATIC) { remove_constraint(&pchan->constraints, con); } } - pchan->constflag &= ~(PCHAN_HAS_IK|PCHAN_HAS_TARGET); + pchan->constflag &= ~(PCHAN_HAS_IK | PCHAN_HAS_TARGET); } CTX_DATA_END; @@ -1788,7 +1788,7 @@ static int pose_ik_clear_exec(bContext *C, wmOperator *UNUSED(op)) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); /* note, notifier might evolve */ - WM_event_add_notifier(C, NC_OBJECT|ND_CONSTRAINT|NA_REMOVED, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT | NA_REMOVED, ob); return OPERATOR_FINISHED; } @@ -1805,6 +1805,6 @@ void POSE_OT_ik_clear(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 3043900bce4..874b04fe87d 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -101,7 +101,7 @@ #include "WM_api.h" #include "WM_types.h" -#include "object_intern.h" // own include +#include "object_intern.h" // own include /* ************* XXX **************** */ static void error(const char *UNUSED(arg)) {} @@ -109,7 +109,8 @@ static void waitcursor(int UNUSED(val)) {} static int pupmenu(const char *UNUSED(msg)) {return 0;} /* port over here */ -static void error_libdata(void) {} +static void error_libdata(void) { +} Object *ED_object_context(bContext *C) { @@ -120,10 +121,10 @@ Object *ED_object_context(bContext *C) * note: context can be NULL when called from a enum with PROP_ENUM_NO_CONTEXT */ Object *ED_object_active_context(bContext *C) { - Object *ob= NULL; + Object *ob = NULL; if (C) { - ob= ED_object_context(C); - if (!ob) ob= CTX_data_active_object(C); + ob = ED_object_context(C); + if (!ob) ob = CTX_data_active_object(C); } return ob; } @@ -132,15 +133,15 @@ Object *ED_object_active_context(bContext *C) /* ********* clear/set restrict view *********/ static int object_hide_view_clear_exec(bContext *C, wmOperator *UNUSED(op)) { - Main *bmain= CTX_data_main(C); - ScrArea *sa= CTX_wm_area(C); - View3D *v3d= sa->spacedata.first; - Scene *scene= CTX_data_scene(C); + Main *bmain = CTX_data_main(C); + ScrArea *sa = CTX_wm_area(C); + View3D *v3d = sa->spacedata.first; + Scene *scene = CTX_data_scene(C); Base *base; int changed = 0; /* XXX need a context loop to handle such cases */ - for (base = FIRSTBASE; base; base=base->next) { + 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; @@ -151,7 +152,7 @@ static int object_hide_view_clear_exec(bContext *C, wmOperator *UNUSED(op)) if (changed) { DAG_id_type_tag(bmain, ID_OB); DAG_scene_sort(bmain, scene); - WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); } return OPERATOR_FINISHED; @@ -170,24 +171,24 @@ void OBJECT_OT_hide_view_clear(wmOperatorType *ot) ot->poll = ED_operator_view3d_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } static int object_hide_view_set_exec(bContext *C, wmOperator *op) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); short changed = 0; - const int unselected= RNA_boolean_get(op->ptr, "unselected"); + const int unselected = RNA_boolean_get(op->ptr, "unselected"); - CTX_DATA_BEGIN (C, Base*, base, visible_bases) { + CTX_DATA_BEGIN (C, Base *, base, visible_bases) { if (!unselected) { if (base->flag & SELECT) { base->flag &= ~SELECT; base->object->flag = base->flag; base->object->restrictflag |= OB_RESTRICT_VIEW; changed = 1; - if (base==BASACT) { + if (base == BASACT) { ED_base_object_activate(C, NULL); } } @@ -205,7 +206,7 @@ static int object_hide_view_set_exec(bContext *C, wmOperator *op) DAG_id_type_tag(bmain, ID_OB); DAG_scene_sort(bmain, scene); - WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, CTX_data_scene(C)); + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, CTX_data_scene(C)); } @@ -224,7 +225,7 @@ void OBJECT_OT_hide_view_set(wmOperatorType *ot) ot->poll = ED_operator_view3d_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_boolean(ot->srna, "unselected", 0, "Unselected", "Hide unselected rather than selected objects"); @@ -233,19 +234,19 @@ void OBJECT_OT_hide_view_set(wmOperatorType *ot) /* 99% same as above except no need for scene refreshing (TODO, update render preview) */ static int object_hide_render_clear_exec(bContext *C, wmOperator *UNUSED(op)) { - short changed= 0; + short changed = 0; /* XXX need a context loop to handle such cases */ - CTX_DATA_BEGIN (C, Object*, ob, selected_editable_objects) { + CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) { if (ob->restrictflag & OB_RESTRICT_RENDER) { ob->restrictflag &= ~OB_RESTRICT_RENDER; - changed= 1; + changed = 1; } } CTX_DATA_END; if (changed) - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_OUTLINER, NULL); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_OUTLINER, NULL); return OPERATOR_FINISHED; } @@ -263,14 +264,14 @@ void OBJECT_OT_hide_render_clear(wmOperatorType *ot) ot->poll = ED_operator_view3d_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } static int object_hide_render_set_exec(bContext *C, wmOperator *op) { - const int unselected= RNA_boolean_get(op->ptr, "unselected"); + const int unselected = RNA_boolean_get(op->ptr, "unselected"); - CTX_DATA_BEGIN (C, Base*, base, visible_bases) { + CTX_DATA_BEGIN (C, Base *, base, visible_bases) { if (!unselected) { if (base->flag & SELECT) { base->object->restrictflag |= OB_RESTRICT_RENDER; @@ -283,7 +284,7 @@ static int object_hide_render_set_exec(bContext *C, wmOperator *op) } } CTX_DATA_END; - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_OUTLINER, NULL); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_OUTLINER, NULL); return OPERATOR_FINISHED; } @@ -299,7 +300,7 @@ void OBJECT_OT_hide_render_set(wmOperatorType *ot) ot->poll = ED_operator_view3d_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_boolean(ot->srna, "unselected", 0, "Unselected", "Hide unselected rather than selected objects"); } @@ -310,19 +311,19 @@ void ED_object_exit_editmode(bContext *C, int flag) { /* Note! only in exceptional cases should 'EM_DO_UNDO' NOT be in the flag */ - Scene *scene= CTX_data_scene(C); - Object *obedit= CTX_data_edit_object(C); + Scene *scene = CTX_data_scene(C); + 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) { - Mesh *me= obedit->data; + if (obedit->type == OB_MESH) { + Mesh *me = obedit->data; // 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; } @@ -332,14 +333,14 @@ void ED_object_exit_editmode(bContext *C, int flag) if (freedata) { EDBM_mesh_free(me->edit_btmesh); MEM_freeN(me->edit_btmesh); - me->edit_btmesh= NULL; + me->edit_btmesh = NULL; } 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) { + else if (obedit->type == OB_ARMATURE) { ED_armature_from_edit(obedit); if (freedata) ED_armature_edit_free(obedit); @@ -348,15 +349,15 @@ void ED_object_exit_editmode(bContext *C, int flag) load_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); } - else if (obedit->type==OB_LATTICE) { + else if (obedit->type == OB_LATTICE) { load_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); } @@ -367,11 +368,11 @@ void ED_object_exit_editmode(bContext *C, int flag) PTCacheID *pid; /* for example; displist make is different in editmode */ - scene->obedit= NULL; // XXX for context + scene->obedit = NULL; // XXX for context /* flag object caches as outdated */ BKE_ptcache_ids_from_object(&pidlist, obedit, NULL, 0); - for (pid=pidlist.first; pid; pid=pid->next) { + 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; } @@ -380,14 +381,14 @@ void ED_object_exit_editmode(bContext *C, int flag) BKE_ptcache_object_reset(scene, obedit, PTCACHE_RESET_OUTDATED); /* 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); + DAG_id_tag_update(&obedit->id, OB_RECALC_OB | OB_RECALC_DATA); if (flag & EM_DO_UNDO) ED_undo_push(C, "Editmode"); if (flag & EM_WAITCURSOR) waitcursor(0); - WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_MODE_OBJECT, scene); + WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_MODE_OBJECT, scene); obedit->mode &= ~OB_MODE_EDIT; } @@ -396,27 +397,27 @@ void ED_object_exit_editmode(bContext *C, int flag) void ED_object_enter_editmode(bContext *C, int flag) { - Scene *scene= CTX_data_scene(C); - Base *base= NULL; + Scene *scene = CTX_data_scene(C); + Base *base = NULL; Object *ob; - ScrArea *sa= CTX_wm_area(C); - View3D *v3d= NULL; - int ok= 0; + ScrArea *sa = CTX_wm_area(C); + View3D *v3d = NULL; + int ok = 0; if (scene->id.lib) return; - if (sa && sa->spacetype==SPACE_VIEW3D) - v3d= sa->spacedata.first; + if (sa && sa->spacetype == SPACE_VIEW3D) + v3d = sa->spacedata.first; - if ((flag & EM_IGNORE_LAYER)==0) { - base= CTX_data_active_base(C); /* active layer checked here for view3d */ + 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; + base = scene->basact; } if (ELEM3(NULL, base, base->object, base->object->data)) return; @@ -434,14 +435,14 @@ void ED_object_enter_editmode(bContext *C, int flag) /* 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; + ob->mode = OB_MODE_EDIT; - if (ob->type==OB_MESH) { + if (ob->type == OB_MESH) { BMEditMesh *em; - ok= 1; + ok = 1; scene->obedit = ob; /* context sees this */ EDBM_mesh_make(CTX_data_tool_settings(C), scene, ob); @@ -455,10 +456,10 @@ void ED_object_enter_editmode(bContext *C, int flag) BM_mesh_select_mode_flush(em->bm); } - WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_EDITMODE_MESH, scene); + WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_EDITMODE_MESH, scene); } - else if (ob->type==OB_ARMATURE) { - bArmature *arm= base->object->data; + else if (ob->type == OB_ARMATURE) { + bArmature *arm = base->object->data; if (!arm) return; /* * The function object_data_is_libdata make a problem here, the @@ -472,50 +473,50 @@ void ED_object_enter_editmode(bContext *C, int flag) error_libdata(); return; } - ok=1; - scene->obedit= ob; + ok = 1; + scene->obedit = ob; ED_armature_to_edit(ob); /* to ensure all goes in restposition and without striding */ - DAG_id_tag_update(&ob->id, OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME); // XXX: should this be OB_RECALC_DATA? + DAG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); // XXX: should this be OB_RECALC_DATA? - WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_EDITMODE_ARMATURE, scene); + WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_EDITMODE_ARMATURE, scene); } - else if (ob->type==OB_FONT) { - scene->obedit= ob; // XXX for context - ok= 1; + 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); + WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_EDITMODE_TEXT, scene); } - else if (ob->type==OB_MBALL) { - scene->obedit= ob; // XXX for context - ok= 1; + 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); + WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_EDITMODE_MBALL, scene); } - else if (ob->type==OB_LATTICE) { - scene->obedit= ob; // XXX for context - ok= 1; + 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); + WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_EDITMODE_LATTICE, scene); } - else if (ob->type==OB_SURF || ob->type==OB_CURVE) { - ok= 1; - scene->obedit= ob; // XXX for context + else if (ob->type == OB_SURF || ob->type == OB_CURVE) { + ok = 1; + scene->obedit = ob; // XXX for context make_editNurb(ob); - WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_EDITMODE_CURVE, scene); + WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_EDITMODE_CURVE, scene); } if (ok) { DAG_id_tag_update(&ob->id, OB_RECALC_DATA); } else { - scene->obedit= NULL; // XXX for context + scene->obedit = NULL; // XXX for context ob->mode &= ~OB_MODE_EDIT; - WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_MODE_OBJECT, scene); + WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_MODE_OBJECT, scene); } if (flag & EM_DO_UNDO) ED_undo_push(C, "Enter Editmode"); @@ -529,7 +530,7 @@ static int editmode_toggle_exec(bContext *C, wmOperator *UNUSED(op)) 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] */ + ED_object_exit_editmode(C, EM_FREEDATA | EM_FREEUNDO | EM_WAITCURSOR); /* had EM_DO_UNDO but op flag calls undo too [#24685] */ ED_space_image_uv_sculpt_update(CTX_wm_manager(C), toolsettings); @@ -567,18 +568,18 @@ void OBJECT_OT_editmode_toggle(wmOperatorType *ot) ot->poll = editmode_toggle_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* *************************** */ static int posemode_exec(bContext *C, wmOperator *UNUSED(op)) { - Base *base= CTX_data_active_base(C); + Base *base = CTX_data_active_base(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); + 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) @@ -604,7 +605,7 @@ void OBJECT_OT_posemode_toggle(wmOperatorType *ot) ot->poll = ED_operator_object_active_editable; /* flag */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } static void copymenu_properties(Scene *scene, View3D *v3d, Object *ob) @@ -612,53 +613,53 @@ static void copymenu_properties(Scene *scene, View3D *v3d, Object *ob) //XXX no longer used - to be removed - replaced by game_properties_copy_exec bProperty *prop; Base *base; - int nr, tot=0; + int nr, tot = 0; char *str; - prop= ob->prop.first; + prop = ob->prop.first; while (prop) { tot++; - prop= prop->next; + prop = prop->next; } - str= MEM_callocN(50 + 33*tot, "copymenu prop"); + str = MEM_callocN(50 + 33 * tot, "copymenu prop"); if (tot) strcpy(str, "Copy Property %t|Replace All|Merge All|%l"); else strcpy(str, "Copy Property %t|Clear All (no properties on active)"); - tot= 0; - prop= ob->prop.first; + tot = 0; + prop = ob->prop.first; while (prop) { tot++; strcat(str, "|"); strcat(str, prop->name); - prop= prop->next; + prop = prop->next; } - nr= pupmenu(str); + nr = pupmenu(str); - if ( nr==1 || nr==2 ) { - for (base= FIRSTBASE; base; base= base->next) { - if ((base != BASACT) &&(TESTBASELIB(v3d, base))) { - if (nr==1) { /* replace */ - copy_properties( &base->object->prop, &ob->prop ); + if (nr == 1 || nr == 2) { + 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 ) { + for (prop = ob->prop.first; prop; prop = prop->next) { set_ob_property(base->object, prop); } } } } } - else if (nr>0) { - prop = BLI_findlink(&ob->prop, nr-4); /* account for first 3 menu items & menu index starting at 1*/ + 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))) { + for (base = FIRSTBASE; base; base = base->next) { + if ((base != BASACT) && (TESTBASELIB(v3d, base))) { set_ob_property(base->object, prop); } } @@ -673,7 +674,7 @@ 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) { + for (base = FIRSTBASE; base; base = base->next) { if (base->object != ob) { if (TESTBASELIB(v3d, base)) { @@ -692,12 +693,12 @@ static void copymenu_logicbricks(Scene *scene, View3D *v3d, Object *ob) set_sca_new_poins_ob(base->object); /* some menu settings */ - base->object->scavisflag= ob->scavisflag; - base->object->scaflag= ob->scaflag; + base->object->scavisflag = ob->scavisflag; + base->object->scaflag = ob->scaflag; /* set the initial state */ - base->object->state= ob->state; - base->object->init_state= ob->init_state; + base->object->state = ob->state; + base->object->init_state = ob->init_state; } } } @@ -706,42 +707,42 @@ static void copymenu_logicbricks(Scene *scene, View3D *v3d, Object *ob) /* both pointers should exist */ static void copy_texture_space(Object *to, Object *ob) { - float *poin1= NULL, *poin2= NULL; - short texflag= 0; + float *poin1 = NULL, *poin2 = NULL; + short texflag = 0; - if (ob->type==OB_MESH) { - texflag= ((Mesh *)ob->data)->texflag; - poin2= ((Mesh *)ob->data)->loc; + if (ob->type == OB_MESH) { + texflag = ((Mesh *)ob->data)->texflag; + poin2 = ((Mesh *)ob->data)->loc; } else if (ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) { - texflag= ((Curve *)ob->data)->texflag; - poin2= ((Curve *)ob->data)->loc; + texflag = ((Curve *)ob->data)->texflag; + poin2 = ((Curve *)ob->data)->loc; } - else if (ob->type==OB_MBALL) { - texflag= ((MetaBall *)ob->data)->texflag; - poin2= ((MetaBall *)ob->data)->loc; + else if (ob->type == OB_MBALL) { + texflag = ((MetaBall *)ob->data)->texflag; + poin2 = ((MetaBall *)ob->data)->loc; } else return; - if (to->type==OB_MESH) { - ((Mesh *)to->data)->texflag= texflag; - poin1= ((Mesh *)to->data)->loc; + if (to->type == OB_MESH) { + ((Mesh *)to->data)->texflag = texflag; + poin1 = ((Mesh *)to->data)->loc; } else if (ELEM3(to->type, OB_CURVE, OB_SURF, OB_FONT)) { - ((Curve *)to->data)->texflag= texflag; - poin1= ((Curve *)to->data)->loc; + ((Curve *)to->data)->texflag = texflag; + poin1 = ((Curve *)to->data)->loc; } - else if (to->type==OB_MBALL) { - ((MetaBall *)to->data)->texflag= texflag; - poin1= ((MetaBall *)to->data)->loc; + else if (to->type == OB_MBALL) { + ((MetaBall *)to->data)->texflag = texflag; + poin1 = ((MetaBall *)to->data)->loc; } else return; - memcpy(poin1, poin2, 9*sizeof(float)); /* this was noted in DNA_mesh, curve, mball */ + 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) { @@ -760,125 +761,125 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event) Base *base; Curve *cu, *cu1; Nurb *nu; - int do_scene_sort= 0; + int do_scene_sort = 0; if (scene->id.lib) return; - if (!(ob=OBACT)) return; + if (!(ob = OBACT)) return; 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) { + 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 */ - 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 == 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 */ - base->object->sf= ob->sf; + else if (event == 5) { /* time offs */ + base->object->sf = ob->sf; } - else if (event==6) { /* dupli */ - base->object->dupon= ob->dupon; - base->object->dupoff= ob->dupoff; - base->object->dupsta= ob->dupsta; - base->object->dupend= ob->dupend; + else if (event == 6) { /* dupli */ + base->object->dupon = ob->dupon; + base->object->dupoff = ob->dupoff; + base->object->dupsta = ob->dupsta; + base->object->dupend = ob->dupend; base->object->transflag &= ~OB_DUPLI; base->object->transflag |= (ob->transflag & OB_DUPLI); - base->object->dup_group= ob->dup_group; + base->object->dup_group = ob->dup_group; if (ob->dup_group) id_lib_extern(&ob->dup_group->id); } - else if (event==7) { /* mass */ - base->object->mass= ob->mass; + else if (event == 7) { /* mass */ + base->object->mass = ob->mass; } - else if (event==8) { /* damping */ - base->object->damping= ob->damping; - base->object->rdamping= ob->rdamping; + 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; - base->object->damping= ob->damping; - base->object->rdamping= ob->rdamping; - base->object->min_vel= ob->min_vel; - base->object->max_vel= ob->max_vel; + base->object->damping = ob->damping; + base->object->rdamping = ob->rdamping; + base->object->min_vel = ob->min_vel; + base->object->max_vel = ob->max_vel; if (ob->gameflag & OB_BOUNDS) { base->object->collision_boundtype = ob->collision_boundtype; } - base->object->margin= ob->margin; - base->object->bsoft= copy_bulletsoftbody(ob->bsoft); + base->object->margin = ob->margin; + 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) { - cu= ob->data; - cu1= base->object->data; - - cu1->spacemode= cu->spacemode; - cu1->spacing= cu->spacing; - cu1->linedist= cu->linedist; - cu1->shear= cu->shear; - cu1->fsize= cu->fsize; - cu1->xof= cu->xof; - cu1->yof= cu->yof; - cu1->textoncurve= cu->textoncurve; - cu1->wordspace= cu->wordspace; - cu1->ulpos= cu->ulpos; - cu1->ulheight= cu->ulheight; + if (base->object->type == ob->type) { + cu = ob->data; + cu1 = base->object->data; + + cu1->spacemode = cu->spacemode; + cu1->spacing = cu->spacing; + cu1->linedist = cu->linedist; + cu1->shear = cu->shear; + cu1->fsize = cu->fsize; + cu1->xof = cu->xof; + cu1->yof = cu->yof; + cu1->textoncurve = cu->textoncurve; + cu1->wordspace = cu->wordspace; + cu1->ulpos = cu->ulpos; + cu1->ulheight = cu->ulheight; if (cu1->vfont) cu1->vfont->id.us--; - cu1->vfont= cu->vfont; + cu1->vfont = cu->vfont; id_us_plus((ID *)cu1->vfont); if (cu1->vfontb) cu1->vfontb->id.us--; - cu1->vfontb= cu->vfontb; + cu1->vfontb = cu->vfontb; id_us_plus((ID *)cu1->vfontb); if (cu1->vfonti) cu1->vfonti->id.us--; - cu1->vfonti= cu->vfonti; + cu1->vfonti = cu->vfonti; id_us_plus((ID *)cu1->vfonti); if (cu1->vfontbi) cu1->vfontbi->id.us--; - cu1->vfontbi= cu->vfontbi; + cu1->vfontbi = cu->vfontbi; id_us_plus((ID *)cu1->vfontbi); BKE_text_to_curve(bmain, scene, base->object, 0); /* needed? */ @@ -889,43 +890,43 @@ 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)) { - cu= ob->data; - cu1= base->object->data; + cu = ob->data; + cu1 = base->object->data; - cu1->bevobj= cu->bevobj; - cu1->taperobj= cu->taperobj; - cu1->width= cu->width; - cu1->bevresol= cu->bevresol; - cu1->ext1= cu->ext1; - cu1->ext2= cu->ext2; + cu1->bevobj = cu->bevobj; + cu1->taperobj = cu->taperobj; + cu1->width = cu->width; + cu1->bevresol = cu->bevresol; + cu1->ext1 = cu->ext1; + cu1->ext2 = cu->ext2; 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)) { - cu= ob->data; - cu1= base->object->data; + cu = ob->data; + cu1 = base->object->data; - cu1->resolu= cu->resolu; - cu1->resolu_ren= cu->resolu_ren; + cu1->resolu = cu->resolu; + cu1->resolu_ren = cu->resolu_ren; - nu= cu1->nurb.first; + nu = cu1->nurb.first; while (nu) { - nu->resolu= cu1->resolu; - nu= nu->next; + nu->resolu = cu1->resolu; + nu = nu->next; } base->object->recalc |= OB_RECALC_DATA; } } - else if (event==21) { - if (base->object->type==OB_MESH) { + else if (event == 21) { + if (base->object->type == OB_MESH) { ModifierData *md = modifiers_findByType(ob, eModifierType_Subsurf); if (md) { @@ -941,42 +942,42 @@ 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; + do_scene_sort = 1; } - else if (event==23) { - base->object->softflag= ob->softflag; + else if (event == 23) { + base->object->softflag = ob->softflag; if (base->object->soft) sbFree(base->object->soft); - base->object->soft= copy_softbody(ob->soft); + base->object->soft = copy_softbody(ob->soft); if (!modifiers_findByType(base->object, eModifierType_Softbody)) { 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 */ - if (base->object->type==OB_MESH) { - Mesh *me= ob->data; - Mesh *cme= base->object->data; - cme->smoothresh= me->smoothresh; + 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) cme->flag |= ME_AUTOSMOOTH; else cme->flag &= ~ME_AUTOSMOOTH; } } - else if (event==28) { /* UV orco */ + else if (event == 28) { /* UV orco */ if (ELEM(base->object->type, OB_CURVE, OB_SURF)) { - cu= ob->data; - cu1= base->object->data; + cu = ob->data; + cu1 = base->object->data; if (cu->flag & CU_UV_ORCO) cu1->flag |= CU_UV_ORCO; @@ -984,13 +985,13 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event) cu1->flag &= ~CU_UV_ORCO; } } - else if (event==29) { /* protected bits */ - base->object->protectflag= ob->protectflag; + else if (event == 29) { /* protected bits */ + base->object->protectflag = ob->protectflag; } - else if (event==30) { /* index object */ - base->object->index= ob->index; + 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); } } @@ -1003,13 +1004,13 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event) DAG_ids_flush_update(bmain, 0); } -static void UNUSED_FUNCTION(copy_attr_menu)(Main *bmain, Scene *scene, View3D *v3d) +static void UNUSED_FUNCTION(copy_attr_menu) (Main * bmain, Scene * scene, View3D * v3d) { Object *ob; 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) @@ -1028,8 +1029,8 @@ static void UNUSED_FUNCTION(copy_attr_menu)(Main *bmain, Scene *scene, View3D *v "Time Offset%x5|Dupli%x6|Object Color%x31|%l|Mass%x7|Damping%x8|All Physical Attributes%x11|Properties%x9|" "Logic Bricks%x10|Protected Transform%x29|%l"); - strcat (str, "|Object Constraints%x22"); - strcat (str, "|NLA Strips%x26"); + strcat(str, "|Object Constraints%x22"); + strcat(str, "|NLA Strips%x26"); // XXX if (OB_TYPE_SUPPORT_MATERIAL(ob->type)) { // strcat(str, "|Texture Space%x17"); @@ -1039,10 +1040,10 @@ static void UNUSED_FUNCTION(copy_attr_menu)(Main *bmain, Scene *scene, View3D *v if (ob->type == OB_CURVE) strcat(str, "|Bevel Settings%x19|UV Orco%x28"); if ((ob->type == OB_FONT) || (ob->type == OB_CURVE)) { - strcat(str, "|Curve Resolution%x25"); + strcat(str, "|Curve Resolution%x25"); } - if (ob->type==OB_MESH) { + if (ob->type == OB_MESH) { strcat(str, "|Subsurf Settings%x21|AutoSmooth%x27"); } @@ -1050,12 +1051,12 @@ static void UNUSED_FUNCTION(copy_attr_menu)(Main *bmain, Scene *scene, View3D *v 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; + event = pupmenu(str); + if (event <= 0) return; copy_attr(bmain, scene, v3d, event); } @@ -1074,7 +1075,7 @@ static int forcefield_toggle_exec(bContext *C, wmOperator *UNUSED(op)) else ob->pd->forcefield = 0; - WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, NULL); return OPERATOR_FINISHED; } @@ -1092,7 +1093,7 @@ void OBJECT_OT_forcefield_toggle(wmOperatorType *ot) ot->poll = ED_operator_object_active_editable; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ********************************************** */ @@ -1108,7 +1109,7 @@ void ED_objects_recalculate_paths(bContext *C, Scene *scene) ListBase targets = {NULL, NULL}; /* loop over objects in scene */ - CTX_DATA_BEGIN (C, Object*, ob, selected_editable_objects) { + CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) { /* set flag to force recalc, then grab the relevant bones to target */ ob->avs.recalc |= ANIMVIZ_RECALC_PATHS; animviz_get_object_motionpaths(ob, &targets); @@ -1123,12 +1124,12 @@ void ED_objects_recalculate_paths(bContext *C, Scene *scene) /* For the object with pose/action: create path curves for selected bones * This recalculates the WHOLE path within the pchan->pathsf and pchan->pathef range */ -static int object_calculate_paths_exec (bContext *C, wmOperator *op) +static int object_calculate_paths_exec(bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); /* set up path data for bones being calculated */ - CTX_DATA_BEGIN (C, Object*, ob, selected_editable_objects) + CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) { /* verify makes sure that the selected bone has a bone with the appropriate settings */ animviz_verify_motionpaths(op->reports, scene, ob, NULL); @@ -1140,12 +1141,12 @@ static int object_calculate_paths_exec (bContext *C, wmOperator *op) ED_objects_recalculate_paths(C, scene); /* notifiers for updates */ - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, NULL); return OPERATOR_FINISHED; } -void OBJECT_OT_paths_calculate (wmOperatorType *ot) +void OBJECT_OT_paths_calculate(wmOperatorType *ot) { /* identifiers */ ot->name = "Calculate Object Paths"; @@ -1157,7 +1158,7 @@ void OBJECT_OT_paths_calculate (wmOperatorType *ot) ot->poll = ED_operator_object_active_editable; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* --------- */ @@ -1166,11 +1167,11 @@ void OBJECT_OT_paths_calculate (wmOperatorType *ot) void ED_objects_clear_paths(bContext *C) { /* loop over objects in scene */ - CTX_DATA_BEGIN (C, Object*, ob, selected_editable_objects) + CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) { if (ob->mpath) { animviz_free_motionpath(ob->mpath); - ob->mpath= NULL; + ob->mpath = NULL; ob->avs.path_bakeflag &= ~MOTIONPATH_BAKE_HAS_PATHS; } } @@ -1178,18 +1179,18 @@ void ED_objects_clear_paths(bContext *C) } /* operator callback for this */ -static int object_clear_paths_exec (bContext *C, wmOperator *UNUSED(op)) +static int object_clear_paths_exec(bContext *C, wmOperator *UNUSED(op)) { /* use the backend function for this */ ED_objects_clear_paths(C); /* notifiers for updates */ - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, NULL); return OPERATOR_FINISHED; } -void OBJECT_OT_paths_clear (wmOperatorType *ot) +void OBJECT_OT_paths_clear(wmOperatorType *ot) { /* identifiers */ ot->name = "Clear Object Paths"; @@ -1201,7 +1202,7 @@ void OBJECT_OT_paths_clear (wmOperatorType *ot) ot->poll = ED_operator_object_active_editable; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1211,36 +1212,36 @@ static int shade_smooth_exec(bContext *C, wmOperator *op) { Curve *cu; Nurb *nu; - int clear= (strcmp(op->idname, "OBJECT_OT_shade_flat") == 0); - int done= 0; + int clear = (strcmp(op->idname, "OBJECT_OT_shade_flat") == 0); + int done = 0; - CTX_DATA_BEGIN (C, Object*, ob, selected_editable_objects) { + 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); - WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); - done= 1; + done = 1; } else if (ELEM(ob->type, OB_SURF, OB_CURVE)) { - cu= ob->data; + cu = ob->data; - for (nu=cu->nurb.first; nu; nu=nu->next) { + for (nu = cu->nurb.first; nu; nu = nu->next) { if (!clear) nu->flag |= ME_SMOOTH; else nu->flag &= ~ME_SMOOTH; } DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); - done= 1; + done = 1; } } CTX_DATA_END; - return (done)? OPERATOR_FINISHED: OPERATOR_CANCELLED; + return (done) ? OPERATOR_FINISHED : OPERATOR_CANCELLED; } static int shade_poll(bContext *C) @@ -1260,7 +1261,7 @@ void OBJECT_OT_shade_flat(wmOperatorType *ot) ot->exec = shade_smooth_exec; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } void OBJECT_OT_shade_smooth(wmOperatorType *ot) @@ -1275,12 +1276,12 @@ void OBJECT_OT_shade_smooth(wmOperatorType *ot) ot->exec = shade_smooth_exec; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ********************** */ -static void UNUSED_FUNCTION(image_aspect)(Scene *scene, View3D *v3d) +static void UNUSED_FUNCTION(image_aspect) (Scene * scene, View3D * v3d) { /* all selected objects with an image map: scale in image aspect */ Base *base; @@ -1290,42 +1291,42 @@ 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->obedit) return; // XXX get from context if (scene->id.lib) return; - for (base= FIRSTBASE; base; base= base->next) { + for (base = FIRSTBASE; base; base = base->next) { if (TESTBASELIB(v3d, base)) { - ob= base->object; - done= 0; + ob = base->object; + done = 0; - for (a=1; a<=ob->totcol; a++) { - ma= give_current_material(ob, a); + for (a = 1; a <= ob->totcol; a++) { + ma = give_current_material(ob, a); if (ma) { - for (b=0; bmtex[b] && ma->mtex[b]->tex) { - tex= ma->mtex[b]->tex; - if (tex->type==TEX_IMAGE && tex->ima) { - ImBuf *ibuf= BKE_image_get_ibuf(tex->ima, NULL); + tex = ma->mtex[b]->tex; + 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) { + space = 1.0; + if (ob->type == OB_MESH) { float size[3]; mesh_get_texspace(ob->data, NULL, NULL, size); - space= size[0]/size[1]; + space = size[0] / size[1]; } else if (ELEM3(ob->type, OB_CURVE, OB_FONT, OB_SURF)) { - Curve *cu= ob->data; - space= cu->size[0]/cu->size[1]; + Curve *cu = ob->data; + space = cu->size[0] / cu->size[1]; } - x= ibuf->x/space; - y= ibuf->y; + x = ibuf->x / space; + y = ibuf->y; - if (x>y) ob->size[0]= ob->size[1]*x/y; - else ob->size[1]= ob->size[0]*y/x; + if (x > y) ob->size[0] = ob->size[1] * x / y; + else ob->size[1] = ob->size[0] * y / x; - done= 1; + done = 1; DAG_id_tag_update(&ob->id, OB_RECALC_OB); } } @@ -1343,9 +1344,9 @@ static void UNUSED_FUNCTION(image_aspect)(Scene *scene, View3D *v3d) static EnumPropertyItem *object_mode_set_itemsf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), int *free) { EnumPropertyItem *input = object_mode_items; - EnumPropertyItem *item= NULL; + EnumPropertyItem *item = NULL; Object *ob; - int totitem= 0; + int totitem = 0; if (!C) /* needed for docs */ return object_mode_items; @@ -1368,7 +1369,7 @@ static EnumPropertyItem *object_mode_set_itemsf(bContext *C, PointerRNA *UNUSED( RNA_enum_item_end(&item, &totitem); - *free= 1; + *free = 1; return item; } @@ -1403,23 +1404,23 @@ static int object_mode_set_compat(bContext *UNUSED(C), wmOperator *op, Object *o 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)) - return 1; - return 0; - case OB_CURVE: - case OB_SURF: - case OB_FONT: - case OB_MBALL: - if (mode & (OB_MODE_EDIT)) - return 1; - return 0; - case OB_LATTICE: - if (mode & (OB_MODE_EDIT|OB_MODE_WEIGHT_PAINT)) - return 1; - case OB_ARMATURE: - if (mode & (OB_MODE_EDIT|OB_MODE_POSE)) - return 1; + 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)) + return 1; + return 0; + case OB_CURVE: + case OB_SURF: + case OB_FONT: + case OB_MBALL: + if (mode & (OB_MODE_EDIT)) + return 1; + return 0; + case OB_LATTICE: + if (mode & (OB_MODE_EDIT | OB_MODE_WEIGHT_PAINT)) + return 1; + case OB_ARMATURE: + if (mode & (OB_MODE_EDIT | OB_MODE_POSE)) + return 1; } } @@ -1428,7 +1429,7 @@ static int object_mode_set_compat(bContext *UNUSED(C), wmOperator *op, Object *o static int object_mode_set_exec(bContext *C, wmOperator *op) { - Object *ob= CTX_data_active_object(C); + Object *ob = CTX_data_active_object(C); ObjectMode mode = RNA_enum_get(op->ptr, "mode"); ObjectMode restore_mode = (ob) ? ob->mode : OB_MODE_OBJECT; int toggle = RNA_boolean_get(op->ptr, "toggle"); @@ -1475,7 +1476,7 @@ void OBJECT_OT_mode_set(wmOperatorType *ot) /* flags */ ot->flag = 0; /* no register/undo here, leave it to operators being called */ - prop= RNA_def_enum(ot->srna, "mode", object_mode_items, OB_MODE_OBJECT, "Mode", ""); + prop = RNA_def_enum(ot->srna, "mode", object_mode_items, OB_MODE_OBJECT, "Mode", ""); RNA_def_enum_funcs(prop, object_mode_set_itemsf); RNA_def_boolean(ot->srna, "toggle", 0, "Toggle", ""); @@ -1505,12 +1506,12 @@ void ED_object_toggle_modes(bContext *C, int mode) static int game_property_new(bContext *C, wmOperator *op) { - Object *ob= CTX_data_active_object(C); + Object *ob = CTX_data_active_object(C); bProperty *prop; char name[MAX_NAME]; - int type= RNA_enum_get(op->ptr, "type"); + int type = RNA_enum_get(op->ptr, "type"); - prop= new_property(type); + prop = new_property(type); BLI_addtail(&ob->prop, prop); RNA_string_get(op->ptr, "name", name); @@ -1537,7 +1538,7 @@ void OBJECT_OT_game_property_new(wmOperatorType *ot) ot->poll = ED_operator_object_active_editable; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_enum(ot->srna, "type", gameproperty_type_items, GPROP_FLOAT, "Type", "Type of game property to add"); RNA_def_string(ot->srna, "name", "", MAX_NAME, "Name", "Name of the game property to add"); @@ -1545,14 +1546,14 @@ void OBJECT_OT_game_property_new(wmOperatorType *ot) static int game_property_remove(bContext *C, wmOperator *op) { - Object *ob= CTX_data_active_object(C); + Object *ob = CTX_data_active_object(C); bProperty *prop; - int index= RNA_int_get(op->ptr, "index"); + int index = RNA_int_get(op->ptr, "index"); if (!ob) return OPERATOR_CANCELLED; - prop= BLI_findlink(&ob->prop, index); + prop = BLI_findlink(&ob->prop, index); if (prop) { BLI_remlink(&ob->prop, prop); @@ -1578,16 +1579,16 @@ void OBJECT_OT_game_property_remove(wmOperatorType *ot) ot->poll = ED_operator_object_active_editable; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_int(ot->srna, "index", 0, 0, INT_MAX, "Index", "Property index to remove ", 0, INT_MAX); } -#define COPY_PROPERTIES_REPLACE 1 -#define COPY_PROPERTIES_MERGE 2 -#define COPY_PROPERTIES_COPY 3 +#define COPY_PROPERTIES_REPLACE 1 +#define COPY_PROPERTIES_MERGE 2 +#define COPY_PROPERTIES_COPY 3 -static EnumPropertyItem game_properties_copy_operations[] ={ +static EnumPropertyItem game_properties_copy_operations[] = { {COPY_PROPERTIES_REPLACE, "REPLACE", 0, "Replace Properties", ""}, {COPY_PROPERTIES_MERGE, "MERGE", 0, "Merge Properties", ""}, {COPY_PROPERTIES_COPY, "COPY", 0, "Copy a Property", ""}, @@ -1598,40 +1599,40 @@ static EnumPropertyItem gameprops_items[]= { static EnumPropertyItem *gameprops_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), int *free) { - Object *ob= ED_object_active_context(C); + Object *ob = ED_object_active_context(C); EnumPropertyItem tmp = {0, "", 0, "", ""}; - EnumPropertyItem *item= NULL; + EnumPropertyItem *item = NULL; bProperty *prop; - int a, totitem= 0; + int a, totitem = 0; if (!ob) return gameprops_items; - for (a=1, prop= ob->prop.first; prop; prop=prop->next, a++) { - tmp.value= a; - tmp.identifier= prop->name; - tmp.name= prop->name; + for (a = 1, prop = ob->prop.first; prop; prop = prop->next, a++) { + tmp.value = a; + tmp.identifier = prop->name; + tmp.name = prop->name; RNA_enum_item_add(&item, &totitem, &tmp); } RNA_enum_item_end(&item, &totitem); - *free= 1; + *free = 1; return item; } static int game_property_copy_exec(bContext *C, wmOperator *op) { - Object *ob=ED_object_active_context(C); + Object *ob = ED_object_active_context(C); bProperty *prop; int type = RNA_enum_get(op->ptr, "operation"); - int propid= RNA_enum_get(op->ptr, "property"); + int propid = RNA_enum_get(op->ptr, "property"); if (propid > 0) { /* copy */ - prop = BLI_findlink(&ob->prop, propid-1); + prop = BLI_findlink(&ob->prop, propid - 1); if (prop) { - CTX_DATA_BEGIN (C, Object*, ob_iter, selected_editable_objects) { + CTX_DATA_BEGIN (C, Object *, ob_iter, selected_editable_objects) { if (ob != ob_iter) set_ob_property(ob_iter, prop); } CTX_DATA_END; @@ -1639,14 +1640,14 @@ static int game_property_copy_exec(bContext *C, wmOperator *op) } else { - CTX_DATA_BEGIN (C, Object*, ob_iter, selected_editable_objects) { + CTX_DATA_BEGIN (C, Object *, ob_iter, selected_editable_objects) { if (ob != ob_iter) { if (type == COPY_PROPERTIES_REPLACE) copy_properties(&ob_iter->prop, &ob->prop); /* 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); } } @@ -1668,17 +1669,17 @@ void OBJECT_OT_game_property_copy(wmOperatorType *ot) ot->poll = ED_operator_object_active_editable; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_enum(ot->srna, "operation", game_properties_copy_operations, 3, "Operation", ""); - prop=RNA_def_enum(ot->srna, "property", gameprops_items, 0, "Property", "Properties to copy"); + prop = RNA_def_enum(ot->srna, "property", gameprops_items, 0, "Property", "Properties to copy"); RNA_def_enum_funcs(prop, gameprops_itemf); ot->prop = prop; } static int game_property_clear_exec(bContext *C, wmOperator *UNUSED(op)) { - CTX_DATA_BEGIN (C, Object*, ob_iter, selected_editable_objects) { + CTX_DATA_BEGIN (C, Object *, ob_iter, selected_editable_objects) { free_properties(&ob_iter->prop); } CTX_DATA_END; @@ -1697,16 +1698,16 @@ void OBJECT_OT_game_property_clear(wmOperatorType *ot) ot->poll = ED_operator_object_active_editable; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /************************ Copy Logic Bricks ***********************/ static int logicbricks_copy_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *ob=ED_object_active_context(C); + Object *ob = ED_object_active_context(C); - CTX_DATA_BEGIN (C, Object*, ob_iter, selected_editable_objects) { + CTX_DATA_BEGIN (C, Object *, ob_iter, selected_editable_objects) { if (ob != ob_iter) { /* first: free all logic */ free_sensors(&ob_iter->sensors); @@ -1723,16 +1724,16 @@ static int logicbricks_copy_exec(bContext *C, wmOperator *UNUSED(op)) set_sca_new_poins_ob(ob_iter); /* some menu settings */ - ob_iter->scavisflag= ob->scavisflag; - ob_iter->scaflag= ob->scaflag; + ob_iter->scavisflag = ob->scavisflag; + ob_iter->scaflag = ob->scaflag; /* set the initial state */ - ob_iter->state= ob->state; - ob_iter->init_state= ob->init_state; + ob_iter->state = ob->state; + ob_iter->init_state = ob->init_state; - if (ob_iter->totcol==ob->totcol) { - ob_iter->actcol= ob->actcol; - WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob_iter); + if (ob_iter->totcol == ob->totcol) { + ob_iter->actcol = ob->actcol; + WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob_iter); } } } @@ -1755,14 +1756,14 @@ void OBJECT_OT_logic_bricks_copy(wmOperatorType *ot) ot->poll = ED_operator_object_active_editable; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } static int game_physics_copy_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *ob=ED_object_active_context(C); + Object *ob = ED_object_active_context(C); - CTX_DATA_BEGIN (C, Object*, ob_iter, selected_editable_objects) { + CTX_DATA_BEGIN (C, Object *, ob_iter, selected_editable_objects) { if (ob != ob_iter) { ob_iter->gameflag = ob->gameflag; ob_iter->gameflag2 = ob->gameflag2; @@ -1782,7 +1783,7 @@ static int game_physics_copy_exec(bContext *C, wmOperator *UNUSED(op)) ob_iter->bsoft = copy_bulletsoftbody(ob->bsoft); if (ob->restrictflag & OB_RESTRICT_RENDER) ob_iter->restrictflag |= OB_RESTRICT_RENDER; - else + else ob_iter->restrictflag &= ~OB_RESTRICT_RENDER; } } @@ -1803,5 +1804,5 @@ void OBJECT_OT_game_physics_copy(struct wmOperatorType *ot) ot->poll = ED_operator_object_active_editable; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } diff --git a/source/blender/editors/object/object_group.c b/source/blender/editors/object/object_group.c index 97367b2e340..702671d8d9b 100644 --- a/source/blender/editors/object/object_group.c +++ b/source/blender/editors/object/object_group.c @@ -61,9 +61,9 @@ static int objects_add_active_exec(bContext *C, wmOperator *op) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); - Object *ob= OBACT; + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + Object *ob = OBACT; Group *group; int ok = 0, cycle = 0; @@ -72,10 +72,10 @@ static int objects_add_active_exec(bContext *C, wmOperator *op) /* 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) { + 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) { + CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases) { if (base->object->dup_group != group) add_to_group(group, base->object, scene, base); else @@ -91,7 +91,7 @@ static int objects_add_active_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_WARNING, "Skipped some groups because of cycle detected"); DAG_scene_sort(bmain, scene); - WM_event_add_notifier(C, NC_GROUP|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_GROUP | NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -108,14 +108,14 @@ void GROUP_OT_objects_add_active(wmOperatorType *ot) ot->poll = ED_operator_objectmode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } static int objects_remove_active_exec(bContext *C, wmOperator *op) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); - Object *ob= OBACT; + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + Object *ob = OBACT; Group *group; int ok = 0; @@ -124,10 +124,10 @@ static int objects_remove_active_exec(bContext *C, wmOperator *op) /* 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) { + 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) { + CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases) { rem_from_group(group, base->object, scene, base); ok = 1; } @@ -138,7 +138,7 @@ static int objects_remove_active_exec(bContext *C, wmOperator *op) 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); + WM_event_add_notifier(C, NC_GROUP | NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -155,16 +155,16 @@ void GROUP_OT_objects_remove_active(wmOperatorType *ot) ot->poll = ED_operator_objectmode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } static int group_objects_remove_exec(bContext *C, wmOperator *UNUSED(op)) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); - Group *group= NULL; + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + Group *group = NULL; - CTX_DATA_BEGIN (C, Base*, base, selected_editable_bases) { + CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases) { group = NULL; while ((group = find_group(base->object, group))) rem_from_group(group, base->object, scene, base); @@ -172,7 +172,7 @@ static int group_objects_remove_exec(bContext *C, wmOperator *UNUSED(op)) CTX_DATA_END; DAG_scene_sort(bmain, scene); - WM_event_add_notifier(C, NC_GROUP|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_GROUP | NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -189,27 +189,27 @@ void GROUP_OT_objects_remove(wmOperatorType *ot) ot->poll = ED_operator_objectmode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } static int group_create_exec(bContext *C, wmOperator *op) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); - Group *group= NULL; - char name[MAX_ID_NAME-2]; /* id name */ + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + Group *group = NULL; + char name[MAX_ID_NAME - 2]; /* id name */ RNA_string_get(op->ptr, "name", name); - group= add_group(name); + group = add_group(name); - CTX_DATA_BEGIN (C, Base*, base, selected_editable_bases) { + CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases) { add_to_group(group, base->object, scene, base); } CTX_DATA_END; DAG_scene_sort(bmain, scene); - WM_event_add_notifier(C, NC_GROUP|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_GROUP | NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -226,26 +226,26 @@ void GROUP_OT_create(wmOperatorType *ot) ot->poll = ED_operator_objectmode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - RNA_def_string(ot->srna, "name", "Group", MAX_ID_NAME-2, "Name", "Name of the new group"); + RNA_def_string(ot->srna, "name", "Group", MAX_ID_NAME - 2, "Name", "Name of the new group"); } /****************** properties window operators *********************/ static int group_add_exec(bContext *C, wmOperator *UNUSED(op)) { - Scene *scene= CTX_data_scene(C); - Object *ob= ED_object_context(C); + Scene *scene = CTX_data_scene(C); + Object *ob = ED_object_context(C); Group *group; if (ob == NULL) return OPERATOR_CANCELLED; - group= add_group("Group"); + group = add_group("Group"); add_to_group(group, ob, scene, NULL); - WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); return OPERATOR_FINISHED; } @@ -261,21 +261,21 @@ void OBJECT_OT_group_add(wmOperatorType *ot) ot->exec = group_add_exec; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } static int group_link_exec(bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); - Object *ob= ED_object_context(C); - Group *group= BLI_findlink(&CTX_data_main(C)->group, RNA_enum_get(op->ptr, "group")); + Scene *scene = CTX_data_scene(C); + 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)) return OPERATOR_CANCELLED; add_to_group(group, ob, scene, NULL); - WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); return OPERATOR_FINISHED; } @@ -294,26 +294,26 @@ void OBJECT_OT_group_link(wmOperatorType *ot) ot->invoke = WM_enum_search_invoke; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ - prop= RNA_def_enum(ot->srna, "group", DummyRNA_NULL_items, 0, "Group", ""); + prop = RNA_def_enum(ot->srna, "group", DummyRNA_NULL_items, 0, "Group", ""); RNA_def_enum_funcs(prop, RNA_group_local_itemf); ot->prop = prop; } static int group_remove_exec(bContext *C, wmOperator *UNUSED(op)) { - Scene *scene= CTX_data_scene(C); - Object *ob= ED_object_context(C); - Group *group= CTX_data_pointer_get_type(C, "group", &RNA_Group).data; + Scene *scene = CTX_data_scene(C); + Object *ob = ED_object_context(C); + Group *group = CTX_data_pointer_get_type(C, "group", &RNA_Group).data; if (!ob || !group) return OPERATOR_CANCELLED; rem_from_group(group, ob, scene, NULL); /* base will be used if found */ - WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); return OPERATOR_FINISHED; } @@ -328,6 +328,6 @@ void OBJECT_OT_group_remove(wmOperatorType *ot) ot->exec = group_remove_exec; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } diff --git a/source/blender/editors/object/object_hook.c b/source/blender/editors/object/object_hook.c index 495f0b40802..4ffc3e8c19f 100644 --- a/source/blender/editors/object/object_hook.c +++ b/source/blender/editors/object/object_hook.c @@ -76,27 +76,27 @@ static int return_editmesh_indexar(BMEditMesh *em, int *tot, int **indexar, floa { BMVert *eve; BMIter iter; - int *index, nr, totvert=0; + int *index, nr, totvert = 0; BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) { 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; - nr= 0; + *indexar = index = MEM_mallocN(4 * totvert, "hook indexar"); + *tot = totvert; + nr = 0; zero_v3(cent); BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) { if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) { - *index= nr; index++; + *index = nr; index++; add_v3_v3(cent, eve->co); } nr++; } - mul_v3_fl(cent, 1.0f/(float)totvert); + mul_v3_fl(cent, 1.0f / (float)totvert); return totvert; } @@ -106,8 +106,8 @@ static int return_editmesh_vgroup(Object *obedit, BMEditMesh *em, char *name, fl zero_v3(cent); if (obedit->actdef) { - const int defgrp_index= obedit->actdef-1; - int totvert=0; + const int defgrp_index = obedit->actdef - 1; + int totvert = 0; MDeformVert *dvert; BMVert *eve; @@ -115,7 +115,7 @@ static int return_editmesh_vgroup(Object *obedit, BMEditMesh *em, char *name, fl /* find the vertices */ BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) { - dvert= CustomData_bmesh_get(&em->bm->vdata, eve->head.data, CD_MDEFORMVERT); + dvert = CustomData_bmesh_get(&em->bm->vdata, eve->head.data, CD_MDEFORMVERT); if (dvert) { if (defvert_find_weight(dvert, defgrp_index) > 0.0f) { @@ -127,7 +127,7 @@ static int return_editmesh_vgroup(Object *obedit, BMEditMesh *em, char *name, fl 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); + mul_v3_fl(cent, 1.0f / (float)totvert); return 1; } } @@ -137,19 +137,19 @@ static int return_editmesh_vgroup(Object *obedit, BMEditMesh *em, char *name, fl static void select_editbmesh_hook(Object *ob, HookModifierData *hmd) { - Mesh *me= ob->data; - BMEditMesh *em= me->edit_btmesh; + Mesh *me = ob->data; + BMEditMesh *em = me->edit_btmesh; BMVert *eve; BMIter iter; - int index=0, nr=0; + int index = 0, nr = 0; if (hmd->indexar == NULL) return; BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) { - if (nr==hmd->indexar[index]) { + if (nr == hmd->indexar[index]) { BM_vert_select_set(em->bm, eve, TRUE); - if (index < hmd->totindex-1) index++; + if (index < hmd->totindex - 1) index++; } nr++; @@ -161,31 +161,31 @@ static void select_editbmesh_hook(Object *ob, HookModifierData *hmd) static int return_editlattice_indexar(Lattice *editlatt, int *tot, int **indexar, float *cent) { BPoint *bp; - int *index, nr, totvert=0, a; + int *index, nr, totvert = 0, a; /* count */ - a= editlatt->pntsu*editlatt->pntsv*editlatt->pntsw; - bp= editlatt->def; + a = editlatt->pntsu * editlatt->pntsv * editlatt->pntsw; + bp = editlatt->def; while (a--) { if (bp->f1 & SELECT) { - if (bp->hide==0) totvert++; + 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; - nr= 0; + *indexar = index = MEM_mallocN(4 * totvert, "hook indexar"); + *tot = totvert; + nr = 0; zero_v3(cent); - a= editlatt->pntsu*editlatt->pntsv*editlatt->pntsw; - bp= editlatt->def; + a = editlatt->pntsu * editlatt->pntsv * editlatt->pntsw; + bp = editlatt->def; while (a--) { if (bp->f1 & SELECT) { - if (bp->hide==0) { - *index= nr; index++; + if (bp->hide == 0) { + *index = nr; index++; add_v3_v3(cent, bp->vec); } } @@ -193,25 +193,25 @@ static int return_editlattice_indexar(Lattice *editlatt, int *tot, int **indexar nr++; } - mul_v3_fl(cent, 1.0f/(float)totvert); + mul_v3_fl(cent, 1.0f / (float)totvert); return totvert; } static void select_editlattice_hook(Object *obedit, HookModifierData *hmd) { - Lattice *lt= obedit->data, *editlt; + Lattice *lt = obedit->data, *editlt; BPoint *bp; - int index=0, nr=0, a; + int index = 0, nr = 0, a; - editlt= lt->editlatt->latt; + editlt = lt->editlatt->latt; /* count */ - a= editlt->pntsu*editlt->pntsv*editlt->pntsw; - bp= editlt->def; + a = editlt->pntsu * editlt->pntsv * editlt->pntsw; + bp = editlt->def; while (a--) { - if (hmd->indexar[index]==nr) { + if (hmd->indexar[index] == nr) { bp->f1 |= SELECT; - if (index < hmd->totindex-1) index++; + if (index < hmd->totindex - 1) index++; } nr++; bp++; @@ -220,16 +220,16 @@ static void select_editlattice_hook(Object *obedit, HookModifierData *hmd) static int return_editcurve_indexar(Object *obedit, int *tot, int **indexar, float *cent) { - ListBase *editnurb= object_editcurve_get(obedit); + ListBase *editnurb = object_editcurve_get(obedit); Nurb *nu; BPoint *bp; BezTriple *bezt; - int *index, a, nr, totvert=0; + int *index, a, nr, totvert = 0; - for (nu= editnurb->first; nu; nu= nu->next) { + for (nu = editnurb->first; nu; nu = nu->next) { if (nu->type == CU_BEZIER) { - bezt= nu->bezt; - a= nu->pntsu; + bezt = nu->bezt; + a = nu->pntsu; while (a--) { if (bezt->f1 & SELECT) totvert++; if (bezt->f2 & SELECT) totvert++; @@ -238,38 +238,38 @@ static int return_editcurve_indexar(Object *obedit, int *tot, int **indexar, flo } } else { - bp= nu->bp; - a= nu->pntsu*nu->pntsv; + bp = nu->bp; + a = nu->pntsu * nu->pntsv; 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; + *indexar = index = MEM_mallocN(4 * totvert, "hook indexar"); + *tot = totvert; + nr = 0; zero_v3(cent); - for (nu= editnurb->first; nu; nu= nu->next) { + for (nu = editnurb->first; nu; nu = nu->next) { if (nu->type == CU_BEZIER) { - bezt= nu->bezt; - a= nu->pntsu; + bezt = nu->bezt; + a = nu->pntsu; while (a--) { if (bezt->f1 & SELECT) { - *index= nr; index++; + *index = nr; index++; add_v3_v3(cent, bezt->vec[0]); } nr++; if (bezt->f2 & SELECT) { - *index= nr; index++; + *index = nr; index++; add_v3_v3(cent, bezt->vec[1]); } nr++; if (bezt->f3 & SELECT) { - *index= nr; index++; + *index = nr; index++; add_v3_v3(cent, bezt->vec[2]); } nr++; @@ -277,11 +277,11 @@ static int return_editcurve_indexar(Object *obedit, int *tot, int **indexar, flo } } else { - bp= nu->bp; - a= nu->pntsu*nu->pntsv; + bp = nu->bp; + a = nu->pntsu * nu->pntsv; while (a--) { if (bp->f1 & SELECT) { - *index= nr; index++; + *index = nr; index++; add_v3_v3(cent, bp->vec); } nr++; @@ -290,21 +290,21 @@ static int return_editcurve_indexar(Object *obedit, int *tot, int **indexar, flo } } - mul_v3_fl(cent, 1.0f/(float)totvert); + mul_v3_fl(cent, 1.0f / (float)totvert); return totvert; } static int object_hook_index_array(Scene *scene, Object *obedit, int *tot, int **indexar, char *name, float *cent_r) { - *indexar= NULL; - *tot= 0; - name[0]= 0; + *indexar = NULL; + *tot = 0; + name[0] = 0; switch (obedit->type) { case OB_MESH: { - Mesh *me= obedit->data; + Mesh *me = obedit->data; BMEditMesh *em; @@ -314,7 +314,7 @@ 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 { @@ -327,7 +327,7 @@ static int object_hook_index_array(Scene *scene, Object *obedit, int *tot, int * return return_editcurve_indexar(obedit, tot, indexar, cent_r); case OB_LATTICE: { - Lattice *lt= obedit->data; + Lattice *lt = obedit->data; return return_editlattice_indexar(lt->editlatt->latt, tot, indexar, cent_r); } default: @@ -337,30 +337,30 @@ static int object_hook_index_array(Scene *scene, Object *obedit, int *tot, int * static void select_editcurve_hook(Object *obedit, HookModifierData *hmd) { - ListBase *editnurb= object_editcurve_get(obedit); + ListBase *editnurb = object_editcurve_get(obedit); Nurb *nu; BPoint *bp; BezTriple *bezt; - int index=0, a, nr=0; + int index = 0, a, nr = 0; - for (nu= editnurb->first; nu; nu= nu->next) { + for (nu = editnurb->first; nu; nu = nu->next) { if (nu->type == CU_BEZIER) { - bezt= nu->bezt; - a= nu->pntsu; + bezt = nu->bezt; + a = nu->pntsu; while (a--) { if (nr == hmd->indexar[index]) { bezt->f1 |= SELECT; - if (indextotindex-1) index++; + if (index < hmd->totindex - 1) index++; } nr++; if (nr == hmd->indexar[index]) { bezt->f2 |= SELECT; - if (indextotindex-1) index++; + if (index < hmd->totindex - 1) index++; } nr++; if (nr == hmd->indexar[index]) { bezt->f3 |= SELECT; - if (indextotindex-1) index++; + if (index < hmd->totindex - 1) index++; } nr++; @@ -368,12 +368,12 @@ static void select_editcurve_hook(Object *obedit, HookModifierData *hmd) } } else { - bp= nu->bp; - a= nu->pntsu*nu->pntsv; + bp = nu->bp; + a = nu->pntsu * nu->pntsv; while (a--) { if (nr == hmd->indexar[index]) { bp->f1 |= SELECT; - if (indextotindex-1) index++; + if (index < hmd->totindex - 1) index++; } nr++; bp++; @@ -387,17 +387,17 @@ 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 */ // TODO: check for properties window modifier context too as alternative? static int hook_op_edit_poll(bContext *C) { - Object *obedit= CTX_data_edit_object(C); + Object *obedit = CTX_data_edit_object(C); if (obedit) { if (ED_operator_editmesh(C)) return 1; @@ -414,7 +414,7 @@ static Object *add_hook_object_new(Scene *scene, Object *obedit) Base *base, *basedit; Object *ob; - ob= add_object(scene, OB_EMPTY); + ob = add_object(scene, OB_EMPTY); basedit = object_in_scene(obedit, scene); base = object_in_scene(ob, scene); @@ -429,7 +429,7 @@ static Object *add_hook_object_new(Scene *scene, Object *obedit) static void add_hook_object(Main *bmain, Scene *scene, Object *obedit, Object *ob, int mode) { - ModifierData *md=NULL; + ModifierData *md = NULL; HookModifierData *hmd = NULL; float cent[3]; int tot, ok, *indexar; @@ -437,9 +437,9 @@ static void add_hook_object(Main *bmain, Scene *scene, Object *obedit, Object *o ok = object_hook_index_array(scene, obedit, &tot, &indexar, name, cent); - if (!ok) return; // XXX error("Requires selected vertices or active Vertex Group"); + if (!ok) return; // XXX error("Requires selected vertices or active Vertex Group"); - if (mode==OBJECT_ADDHOOK_NEWOB && !ob) { + if (mode == OBJECT_ADDHOOK_NEWOB && !ob) { ob = add_hook_object_new(scene, obedit); @@ -448,19 +448,19 @@ static void add_hook_object(Main *bmain, Scene *scene, Object *obedit, Object *o } md = obedit->modifiers.first; - while (md && modifierType_getInfo(md->type)->type==eModifierTypeType_OnlyDeform) { + while (md && modifierType_getInfo(md->type)->type == eModifierTypeType_OnlyDeform) { md = md->next; } - hmd = (HookModifierData*) modifier_new(eModifierType_Hook); + hmd = (HookModifierData *) modifier_new(eModifierType_Hook); BLI_insertlinkbefore(&obedit->modifiers, md, hmd); - BLI_snprintf(hmd->modifier.name, sizeof(hmd->modifier.name), "Hook-%s", ob->id.name+2); - modifier_unique_name(&obedit->modifiers, (ModifierData*)hmd); + BLI_snprintf(hmd->modifier.name, sizeof(hmd->modifier.name), "Hook-%s", ob->id.name + 2); + modifier_unique_name(&obedit->modifiers, (ModifierData *)hmd); - hmd->object= ob; - hmd->indexar= indexar; + hmd->object = ob; + hmd->indexar = indexar; copy_v3_v3(hmd->cent, cent); - hmd->totindex= tot; + hmd->totindex = tot; BLI_strncpy(hmd->name, name, sizeof(hmd->name)); /* matrix calculus */ @@ -478,12 +478,12 @@ static void add_hook_object(Main *bmain, Scene *scene, Object *obedit, Object *o static int object_add_hook_selob_exec(bContext *C, wmOperator *op) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); Object *obedit = CTX_data_edit_object(C); - Object *obsel=NULL; + Object *obsel = NULL; - CTX_DATA_BEGIN (C, Object*, ob, selected_objects) { + CTX_DATA_BEGIN (C, Object *, ob, selected_objects) { if (ob != obedit) { obsel = ob; break; @@ -498,7 +498,7 @@ static int object_add_hook_selob_exec(bContext *C, wmOperator *op) add_hook_object(bmain, scene, obedit, obsel, OBJECT_ADDHOOK_SELOB); - WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, obedit); + WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, obedit); return OPERATOR_FINISHED; } @@ -514,19 +514,19 @@ void OBJECT_OT_hook_add_selobj(wmOperatorType *ot) ot->poll = hook_op_edit_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } static int object_add_hook_newob_exec(bContext *C, wmOperator *UNUSED(op)) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); Object *obedit = CTX_data_edit_object(C); add_hook_object(bmain, scene, obedit, NULL, OBJECT_ADDHOOK_NEWOB); - WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); - WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, obedit); + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); + WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, obedit); return OPERATOR_FINISHED; } @@ -542,14 +542,14 @@ void OBJECT_OT_hook_add_newobj(wmOperatorType *ot) ot->poll = hook_op_edit_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } static int object_hook_remove_exec(bContext *C, wmOperator *op) { - int num= RNA_enum_get(op->ptr, "modifier"); - Object *ob=NULL; - HookModifierData *hmd=NULL; + int num = RNA_enum_get(op->ptr, "modifier"); + Object *ob = NULL; + HookModifierData *hmd = NULL; ob = CTX_data_edit_object(C); hmd = (HookModifierData *)BLI_findlink(&ob->modifiers, num); @@ -565,7 +565,7 @@ static int object_hook_remove_exec(bContext *C, wmOperator *op) modifier_free((ModifierData *)hmd); DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); return OPERATOR_FINISHED; } @@ -574,25 +574,25 @@ static EnumPropertyItem *hook_mod_itemf(bContext *C, PointerRNA *UNUSED(ptr), Pr { Object *ob = CTX_data_edit_object(C); EnumPropertyItem tmp = {0, "", 0, "", ""}; - EnumPropertyItem *item= NULL; + EnumPropertyItem *item = NULL; ModifierData *md = NULL; - int a, totitem= 0; + int a, totitem = 0; if (!ob) return DummyRNA_NULL_items; - for (a=0, md=ob->modifiers.first; md; md= md->next, a++) { - if (md->type==eModifierType_Hook) { - tmp.value= 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; - tmp.identifier= md->name; - tmp.name= md->name; + tmp.identifier = md->name; + tmp.name = md->name; RNA_enum_item_add(&item, &totitem, &tmp); } } RNA_enum_item_end(&item, &totitem); - *free= 1; + *free = 1; return item; } @@ -614,26 +614,26 @@ void OBJECT_OT_hook_remove(wmOperatorType *ot) /* flags */ /* this operator removes modifier which isn't stored in local undo stack, * so redoing it from redo panel gives totally weird results */ - ot->flag = /*OPTYPE_REGISTER|*/OPTYPE_UNDO; + ot->flag = /*OPTYPE_REGISTER|*/ OPTYPE_UNDO; /* properties */ - prop= RNA_def_enum(ot->srna, "modifier", DummyRNA_NULL_items, 0, "Modifier", "Modifier number to remove"); + prop = RNA_def_enum(ot->srna, "modifier", DummyRNA_NULL_items, 0, "Modifier", "Modifier number to remove"); RNA_def_enum_funcs(prop, hook_mod_itemf); ot->prop = prop; } static int object_hook_reset_exec(bContext *C, wmOperator *op) { - PointerRNA ptr= CTX_data_pointer_get_type(C, "modifier", &RNA_HookModifier); - int num= RNA_enum_get(op->ptr, "modifier"); - Object *ob=NULL; - HookModifierData *hmd=NULL; + PointerRNA ptr = CTX_data_pointer_get_type(C, "modifier", &RNA_HookModifier); + int num = RNA_enum_get(op->ptr, "modifier"); + Object *ob = NULL; + HookModifierData *hmd = NULL; - if (ptr.data) { /* if modifier context is available, use that */ + if (ptr.data) { /* if modifier context is available, use that */ ob = ptr.id.data; - hmd= ptr.data; + hmd = ptr.data; } - else { /* use the provided property */ + else { /* use the provided property */ ob = CTX_data_edit_object(C); hmd = (HookModifierData *)BLI_findlink(&ob->modifiers, num); } @@ -644,7 +644,7 @@ static int object_hook_reset_exec(bContext *C, wmOperator *op) /* reset functionality */ if (hmd->object) { - bPoseChannel *pchan= get_pose_channel(hmd->object->pose, hmd->subtarget); + bPoseChannel *pchan = get_pose_channel(hmd->object->pose, hmd->subtarget); if (hmd->subtarget[0] && pchan) { float imat[4][4], mat[4][4]; @@ -662,7 +662,7 @@ static int object_hook_reset_exec(bContext *C, wmOperator *op) } DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); return OPERATOR_FINISHED; } @@ -681,27 +681,27 @@ void OBJECT_OT_hook_reset(wmOperatorType *ot) ot->poll = hook_op_edit_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ - prop= RNA_def_enum(ot->srna, "modifier", DummyRNA_NULL_items, 0, "Modifier", "Modifier number to assign to"); + prop = RNA_def_enum(ot->srna, "modifier", DummyRNA_NULL_items, 0, "Modifier", "Modifier number to assign to"); RNA_def_enum_funcs(prop, hook_mod_itemf); } static int object_hook_recenter_exec(bContext *C, wmOperator *op) { - PointerRNA ptr= CTX_data_pointer_get_type(C, "modifier", &RNA_HookModifier); - int num= RNA_enum_get(op->ptr, "modifier"); - Object *ob=NULL; - HookModifierData *hmd=NULL; + PointerRNA ptr = CTX_data_pointer_get_type(C, "modifier", &RNA_HookModifier); + int num = RNA_enum_get(op->ptr, "modifier"); + Object *ob = NULL; + HookModifierData *hmd = NULL; Scene *scene = CTX_data_scene(C); float bmat[3][3], imat[3][3]; - if (ptr.data) { /* if modifier context is available, use that */ + if (ptr.data) { /* if modifier context is available, use that */ ob = ptr.id.data; - hmd= ptr.data; + hmd = ptr.data; } - else { /* use the provided property */ + else { /* use the provided property */ ob = CTX_data_edit_object(C); hmd = (HookModifierData *)BLI_findlink(&ob->modifiers, num); } @@ -718,7 +718,7 @@ static int object_hook_recenter_exec(bContext *C, wmOperator *op) mul_m3_v3(imat, hmd->cent); DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); return OPERATOR_FINISHED; } @@ -737,29 +737,29 @@ void OBJECT_OT_hook_recenter(wmOperatorType *ot) ot->poll = hook_op_edit_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ - prop= RNA_def_enum(ot->srna, "modifier", DummyRNA_NULL_items, 0, "Modifier", "Modifier number to assign to"); + prop = RNA_def_enum(ot->srna, "modifier", DummyRNA_NULL_items, 0, "Modifier", "Modifier number to assign to"); RNA_def_enum_funcs(prop, hook_mod_itemf); } static int object_hook_assign_exec(bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); - PointerRNA ptr= CTX_data_pointer_get_type(C, "modifier", &RNA_HookModifier); - int num= RNA_enum_get(op->ptr, "modifier"); - Object *ob=NULL; - HookModifierData *hmd=NULL; + Scene *scene = CTX_data_scene(C); + PointerRNA ptr = CTX_data_pointer_get_type(C, "modifier", &RNA_HookModifier); + int num = RNA_enum_get(op->ptr, "modifier"); + Object *ob = NULL; + HookModifierData *hmd = NULL; float cent[3]; char name[MAX_NAME]; int *indexar, tot; - if (ptr.data) { /* if modifier context is available, use that */ + if (ptr.data) { /* if modifier context is available, use that */ ob = ptr.id.data; - hmd= ptr.data; + hmd = ptr.data; } - else { /* use the provided property */ + else { /* use the provided property */ ob = CTX_data_edit_object(C); hmd = (HookModifierData *)BLI_findlink(&ob->modifiers, num); } @@ -778,11 +778,11 @@ static int object_hook_assign_exec(bContext *C, wmOperator *op) MEM_freeN(hmd->indexar); copy_v3_v3(hmd->cent, cent); - hmd->indexar= indexar; - hmd->totindex= tot; + hmd->indexar = indexar; + hmd->totindex = tot; DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); return OPERATOR_FINISHED; } @@ -803,25 +803,25 @@ void OBJECT_OT_hook_assign(wmOperatorType *ot) /* flags */ /* this operator changes data stored in modifier which doesn't get pushed to undo stack, * so redoing it from redo panel gives totally weird results */ - ot->flag = /*OPTYPE_REGISTER|*/OPTYPE_UNDO; + ot->flag = /*OPTYPE_REGISTER|*/ OPTYPE_UNDO; /* properties */ - prop= RNA_def_enum(ot->srna, "modifier", DummyRNA_NULL_items, 0, "Modifier", "Modifier number to assign to"); + prop = RNA_def_enum(ot->srna, "modifier", DummyRNA_NULL_items, 0, "Modifier", "Modifier number to assign to"); RNA_def_enum_funcs(prop, hook_mod_itemf); } static int object_hook_select_exec(bContext *C, wmOperator *op) { - PointerRNA ptr= CTX_data_pointer_get_type(C, "modifier", &RNA_HookModifier); - int num= RNA_enum_get(op->ptr, "modifier"); - Object *ob=NULL; - HookModifierData *hmd=NULL; + PointerRNA ptr = CTX_data_pointer_get_type(C, "modifier", &RNA_HookModifier); + int num = RNA_enum_get(op->ptr, "modifier"); + Object *ob = NULL; + HookModifierData *hmd = NULL; - if (ptr.data) { /* if modifier context is available, use that */ + if (ptr.data) { /* if modifier context is available, use that */ ob = ptr.id.data; - hmd= ptr.data; + hmd = ptr.data; } - else { /* use the provided property */ + else { /* use the provided property */ ob = CTX_data_edit_object(C); hmd = (HookModifierData *)BLI_findlink(&ob->modifiers, num); } @@ -833,7 +833,7 @@ static int object_hook_select_exec(bContext *C, wmOperator *op) /* select functionality */ object_hook_select(ob, hmd); - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, ob->data); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, ob->data); return OPERATOR_FINISHED; } @@ -852,10 +852,10 @@ void OBJECT_OT_hook_select(wmOperatorType *ot) ot->poll = hook_op_edit_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ - prop= RNA_def_enum(ot->srna, "modifier", DummyRNA_NULL_items, 0, "Modifier", "Modifier number to remove"); + prop = RNA_def_enum(ot->srna, "modifier", DummyRNA_NULL_items, 0, "Modifier", "Modifier number to remove"); RNA_def_enum_funcs(prop, hook_mod_itemf); } diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h index b1738a960ce..ee9d776ea3b 100644 --- a/source/blender/editors/object/object_intern.h +++ b/source/blender/editors/object/object_intern.h @@ -185,7 +185,7 @@ void CONSTRAINT_OT_limitdistance_reset(struct wmOperatorType *ot); void CONSTRAINT_OT_childof_set_inverse(struct wmOperatorType *ot); void CONSTRAINT_OT_childof_clear_inverse(struct wmOperatorType *ot); void CONSTRAINT_OT_objectsolver_set_inverse(struct wmOperatorType *ot); -void CONSTRAINT_OT_objectsolver_clear_inverse (struct wmOperatorType *ot); +void CONSTRAINT_OT_objectsolver_clear_inverse(struct wmOperatorType *ot); /* object_vgroup.c */ void OBJECT_OT_vertex_group_add(struct wmOperatorType *ot); diff --git a/source/blender/editors/object/object_lattice.c b/source/blender/editors/object/object_lattice.c index 4ba62541c60..648f530881a 100644 --- a/source/blender/editors/object/object_lattice.c +++ b/source/blender/editors/object/object_lattice.c @@ -68,45 +68,45 @@ void free_editLatt(Object *ob) { - Lattice *lt= ob->data; + Lattice *lt = ob->data; if (lt->editlatt) { - Lattice *editlt= lt->editlatt->latt; + Lattice *editlt = lt->editlatt->latt; if (editlt->def) MEM_freeN(editlt->def); if (editlt->dvert) - free_dverts(editlt->dvert, editlt->pntsu*editlt->pntsv*editlt->pntsw); + free_dverts(editlt->dvert, editlt->pntsu * editlt->pntsv * editlt->pntsw); MEM_freeN(editlt); MEM_freeN(lt->editlatt); - lt->editlatt= NULL; + lt->editlatt = NULL; } } void make_editLatt(Object *obedit) { - Lattice *lt= obedit->data; + Lattice *lt = obedit->data; KeyBlock *actkey; free_editLatt(obedit); - actkey= ob_get_keyblock(obedit); + actkey = ob_get_keyblock(obedit); 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); + lt->editlatt = MEM_callocN(sizeof(EditLatt), "editlatt"); + lt->editlatt->latt = MEM_dupallocN(lt); + lt->editlatt->latt->def = MEM_dupallocN(lt->def); if (lt->dvert) { - int tot= lt->pntsu*lt->pntsv*lt->pntsw; - lt->editlatt->latt->dvert = MEM_mallocN (sizeof (MDeformVert)*tot, "Lattice MDeformVert"); + 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) @@ -117,52 +117,52 @@ void load_editLatt(Object *obedit) float *fp; int tot; - lt= obedit->data; - editlt= lt->editlatt->latt; + lt = obedit->data; + editlt = lt->editlatt->latt; if (lt->editlatt->shapenr) { - actkey= BLI_findlink(<->key->block, lt->editlatt->shapenr-1); + actkey = BLI_findlink(<->key->block, lt->editlatt->shapenr - 1); /* active key: vertices */ - tot= editlt->pntsu*editlt->pntsv*editlt->pntsw; + tot = editlt->pntsu * editlt->pntsv * editlt->pntsw; if (actkey->data) MEM_freeN(actkey->data); - fp=actkey->data= MEM_callocN(lt->key->elemsize*tot, "actkey->data"); - actkey->totelem= tot; + fp = actkey->data = MEM_callocN(lt->key->elemsize * tot, "actkey->data"); + actkey->totelem = tot; - bp= editlt->def; + bp = editlt->def; while (tot--) { copy_v3_v3(fp, bp->vec); - fp+= 3; + fp += 3; bp++; } } else { MEM_freeN(lt->def); - lt->def= MEM_dupallocN(editlt->def); + lt->def = MEM_dupallocN(editlt->def); - lt->flag= editlt->flag; + lt->flag = editlt->flag; - lt->pntsu= editlt->pntsu; - lt->pntsv= editlt->pntsv; - lt->pntsw= editlt->pntsw; + lt->pntsu = editlt->pntsu; + lt->pntsv = editlt->pntsv; + lt->pntsw = editlt->pntsw; - lt->typeu= editlt->typeu; - lt->typev= editlt->typev; - lt->typew= editlt->typew; + lt->typeu = editlt->typeu; + lt->typev = editlt->typev; + lt->typew = editlt->typew; } if (lt->dvert) { - free_dverts(lt->dvert, lt->pntsu*lt->pntsv*lt->pntsw); - lt->dvert= NULL; + free_dverts(lt->dvert, lt->pntsu * lt->pntsv * lt->pntsw); + lt->dvert = NULL; } if (editlt->dvert) { - tot= lt->pntsu*lt->pntsv*lt->pntsw; + tot = lt->pntsu * lt->pntsv * lt->pntsw; - lt->dvert = MEM_mallocN (sizeof (MDeformVert)*tot, "Lattice MDeformVert"); + lt->dvert = MEM_mallocN(sizeof (MDeformVert) * tot, "Lattice MDeformVert"); copy_dverts(lt->dvert, editlt->dvert, tot); } } @@ -171,17 +171,17 @@ void load_editLatt(Object *obedit) void ED_setflagsLatt(Object *obedit, int flag) { - Lattice *lt= obedit->data; + Lattice *lt = obedit->data; BPoint *bp; int a; - bp= lt->editlatt->latt->def; + bp = lt->editlatt->latt->def; - a= lt->editlatt->latt->pntsu*lt->editlatt->latt->pntsv*lt->editlatt->latt->pntsw; + a = lt->editlatt->latt->pntsu * lt->editlatt->latt->pntsv * lt->editlatt->latt->pntsw; while (a--) { - if (bp->hide==0) { - bp->f1= flag; + if (bp->hide == 0) { + bp->f1 = flag; } bp++; } @@ -189,8 +189,8 @@ void ED_setflagsLatt(Object *obedit, int flag) static int lattice_select_all_exec(bContext *C, wmOperator *op) { - Object *obedit= CTX_data_edit_object(C); - Lattice *lt= obedit->data; + Object *obedit = CTX_data_edit_object(C); + Lattice *lt = obedit->data; BPoint *bp; int a; int action = RNA_enum_get(op->ptr, "action"); @@ -198,11 +198,11 @@ static int lattice_select_all_exec(bContext *C, wmOperator *op) if (action == SEL_TOGGLE) { action = SEL_SELECT; - bp= lt->editlatt->latt->def; - a= lt->editlatt->latt->pntsu*lt->editlatt->latt->pntsv*lt->editlatt->latt->pntsw; + 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->hide == 0) { if (bp->f1) { action = SEL_DESELECT; break; @@ -213,26 +213,26 @@ static int lattice_select_all_exec(bContext *C, wmOperator *op) } switch (action) { - case SEL_SELECT: - ED_setflagsLatt(obedit, 1); - break; - case SEL_DESELECT: - ED_setflagsLatt(obedit, 0); - break; - case SEL_INVERT: - bp= lt->editlatt->latt->def; - a= lt->editlatt->latt->pntsu*lt->editlatt->latt->pntsv*lt->editlatt->latt->pntsw; - - while (a--) { - if (bp->hide==0) { - bp->f1 ^= 1; + case SEL_SELECT: + ED_setflagsLatt(obedit, 1); + break; + case SEL_DESELECT: + ED_setflagsLatt(obedit, 0); + break; + case SEL_INVERT: + bp = lt->editlatt->latt->def; + a = lt->editlatt->latt->pntsu * lt->editlatt->latt->pntsv * lt->editlatt->latt->pntsw; + + while (a--) { + if (bp->hide == 0) { + bp->f1 ^= 1; + } + bp++; } - bp++; - } - break; + break; } - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); return OPERATOR_FINISHED; } @@ -249,7 +249,7 @@ void LATTICE_OT_select_all(wmOperatorType *ot) ot->poll = ED_operator_editlattice; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; WM_operator_properties_select_all(ot); } @@ -260,27 +260,27 @@ static int make_regular_poll(bContext *C) if (ED_operator_editlattice(C)) return 1; - ob= CTX_data_active_object(C); - return (ob && ob->type==OB_LATTICE); + ob = CTX_data_active_object(C); + return (ob && ob->type == OB_LATTICE); } static int make_regular_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *ob= CTX_data_edit_object(C); + Object *ob = CTX_data_edit_object(C); Lattice *lt; if (ob) { - lt= ob->data; + lt = ob->data; resizelattice(lt->editlatt->latt, lt->pntsu, lt->pntsv, lt->pntsw, NULL); } else { - ob= CTX_data_active_object(C); - lt= ob->data; + ob = CTX_data_active_object(C); + lt = ob->data; resizelattice(lt, lt->pntsu, lt->pntsv, lt->pntsw, NULL); } DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_GEOM|ND_DATA, ob->data); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data); return OPERATOR_FINISHED; } @@ -297,7 +297,7 @@ void LATTICE_OT_make_regular(wmOperatorType *ot) ot->poll = make_regular_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /****************************** Mouse Selection *************************/ @@ -305,12 +305,12 @@ void LATTICE_OT_make_regular(wmOperatorType *ot) static void findnearestLattvert__doClosest(void *userData, BPoint *bp, int x, int y) { struct { BPoint *bp; short dist, select; int mval[2]; } *data = userData; - float temp = abs(data->mval[0]-x) + abs(data->mval[1]-y); + float temp = abs(data->mval[0] - x) + abs(data->mval[1] - y); - if ((bp->f1 & SELECT)==data->select) + if ((bp->f1 & SELECT) == data->select) temp += 5; - if (tempdist) { + if (temp < data->dist) { data->dist = temp; data->bp = bp; @@ -319,15 +319,15 @@ static void findnearestLattvert__doClosest(void *userData, BPoint *bp, int x, in static BPoint *findnearestLattvert(ViewContext *vc, const int mval[2], int sel) { - /* sel==1: selected gets a disadvantage */ - /* in nurb and bezt or bp the nearest is written */ - /* return 0 1 2: handlepunt */ + /* sel==1: selected gets a disadvantage */ + /* in nurb and bezt or bp the nearest is written */ + /* return 0 1 2: handlepunt */ struct { BPoint *bp; short dist, select; int mval[2]; } data = {NULL}; data.dist = 100; data.select = sel; - data.mval[0]= mval[0]; - data.mval[1]= mval[1]; + data.mval[0] = mval[0]; + data.mval[1] = mval[1]; ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); lattice_foreachScreenVert(vc, findnearestLattvert__doClosest, &data); @@ -338,20 +338,20 @@ static BPoint *findnearestLattvert(ViewContext *vc, const int mval[2], int sel) int mouse_lattice(bContext *C, const int mval[2], int extend) { ViewContext vc; - BPoint *bp= NULL; + BPoint *bp = NULL; view3d_set_viewcontext(C, &vc); - bp= findnearestLattvert(&vc, mval, 1); + bp = findnearestLattvert(&vc, mval, 1); if (bp) { - if (extend==0) { + if (extend == 0) { ED_setflagsLatt(vc.obedit, 0); bp->f1 |= SELECT; } else - bp->f1 ^= SELECT; /* swap */ + bp->f1 ^= SELECT; /* swap */ - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, vc.obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, vc.obedit->data); return 1; } @@ -368,29 +368,29 @@ typedef struct UndoLattice { static void undoLatt_to_editLatt(void *data, void *edata, void *UNUSED(obdata)) { - UndoLattice *ult= (UndoLattice*)data; - EditLatt *editlatt= (EditLatt *)edata; - int a= editlatt->latt->pntsu*editlatt->latt->pntsv*editlatt->latt->pntsw; + UndoLattice *ult = (UndoLattice *)data; + EditLatt *editlatt = (EditLatt *)edata; + int a = editlatt->latt->pntsu * editlatt->latt->pntsv * editlatt->latt->pntsw; - memcpy(editlatt->latt->def, ult->def, a*sizeof(BPoint)); + memcpy(editlatt->latt->def, ult->def, a * sizeof(BPoint)); } static void *editLatt_to_undoLatt(void *edata, void *UNUSED(obdata)) { - UndoLattice *ult= MEM_callocN(sizeof(UndoLattice), "UndoLattice"); - EditLatt *editlatt= (EditLatt *)edata; + UndoLattice *ult = MEM_callocN(sizeof(UndoLattice), "UndoLattice"); + EditLatt *editlatt = (EditLatt *)edata; - ult->def= MEM_dupallocN(editlatt->latt->def); - ult->pntsu= editlatt->latt->pntsu; - ult->pntsv= editlatt->latt->pntsv; - ult->pntsw= editlatt->latt->pntsw; + ult->def = MEM_dupallocN(editlatt->latt->def); + ult->pntsu = editlatt->latt->pntsu; + ult->pntsv = editlatt->latt->pntsv; + ult->pntsw = editlatt->latt->pntsw; return ult; } static void free_undoLatt(void *data) { - UndoLattice *ult= (UndoLattice*)data; + UndoLattice *ult = (UndoLattice *)data; if (ult->def) MEM_freeN(ult->def); MEM_freeN(ult); @@ -398,20 +398,20 @@ static void free_undoLatt(void *data) static int validate_undoLatt(void *data, void *edata) { - UndoLattice *ult= (UndoLattice*)data; - EditLatt *editlatt= (EditLatt *)edata; + UndoLattice *ult = (UndoLattice *)data; + EditLatt *editlatt = (EditLatt *)edata; return (ult->pntsu == editlatt->latt->pntsu && - ult->pntsv == editlatt->latt->pntsv && - ult->pntsw == editlatt->latt->pntsw); + ult->pntsv == editlatt->latt->pntsv && + ult->pntsw == editlatt->latt->pntsw); } static void *get_editlatt(bContext *C) { - Object *obedit= CTX_data_edit_object(C); + Object *obedit = CTX_data_edit_object(C); - if (obedit && obedit->type==OB_LATTICE) { - Lattice *lt= obedit->data; + 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 6eb1ad3a13d..bd69b3adc5e 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -87,16 +87,16 @@ ModifierData *ED_object_modifier_add(ReportList *reports, Main *bmain, Scene *scene, Object *ob, const char *name, int type) { - ModifierData *md=NULL, *new_md=NULL; + ModifierData *md = NULL, *new_md = NULL; 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)) { - BKE_reportf(reports, RPT_WARNING, "Modifiers cannot be added to Object '%s'", ob->id.name+2); + BKE_reportf(reports, RPT_WARNING, "Modifiers cannot be added to Object '%s'", ob->id.name + 2); return NULL; } - if (mti->flags&eModifierTypeFlag_Single) { + if (mti->flags & eModifierTypeFlag_Single) { if (modifiers_findByType(ob, type)) { BKE_report(reports, RPT_WARNING, "Only one modifier of this type allowed"); return NULL; @@ -111,12 +111,12 @@ ModifierData *ED_object_modifier_add(ReportList *reports, Main *bmain, Scene *sc } else { /* get new modifier data to add */ - new_md= modifier_new(type); + 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); @@ -134,15 +134,15 @@ ModifierData *ED_object_modifier_add(ReportList *reports, Main *bmain, Scene *sc /* special cases */ if (type == eModifierType_Softbody) { if (!ob->soft) { - ob->soft= sbNew(scene); - ob->softflag |= OB_SB_GOAL|OB_SB_EDGES; + ob->soft = sbNew(scene); + ob->softflag |= OB_SB_GOAL | OB_SB_EDGES; } } else if (type == eModifierType_Collision) { if (!ob->pd) - ob->pd= object_add_collision_fields(0); + ob->pd = object_add_collision_fields(0); - ob->pd->deflect= 1; + ob->pd->deflect = 1; DAG_scene_sort(bmain, scene); } else if (type == eModifierType_Surface) @@ -164,8 +164,8 @@ 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) @@ -173,22 +173,22 @@ static int object_modifier_remove(Object *ob, ModifierData *md, int *sort_depsgr /* special cases */ if (md->type == eModifierType_ParticleSystem) { - ParticleSystemModifierData *psmd=(ParticleSystemModifierData*)md; + ParticleSystemModifierData *psmd = (ParticleSystemModifierData *)md; BLI_remlink(&ob->particlesystem, psmd->psys); psys_free(ob, psmd->psys); - psmd->psys= NULL; + psmd->psys = NULL; } else if (md->type == eModifierType_Softbody) { if (ob->soft) { sbFree(ob->soft); - ob->soft= NULL; - ob->softflag= 0; + ob->soft = NULL; + ob->softflag = 0; } } else if (md->type == eModifierType_Collision) { if (ob->pd) - ob->pd->deflect= 0; + ob->pd->deflect = 0; *sort_depsgraph = 1; } @@ -202,13 +202,13 @@ static int object_modifier_remove(Object *ob, ModifierData *md, int *sort_depsgr ob->dt = OB_TEXTURE; } else if (md->type == eModifierType_Multires) { - int ok= 1; + 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) { - ok= 0; + for (tmpmd = ob->modifiers.first; tmpmd; tmpmd = tmpmd->next) + if (tmpmd != md && tmpmd->type == eModifierType_Multires) { + ok = 0; break; } @@ -218,7 +218,7 @@ static int object_modifier_remove(Object *ob, ModifierData *md, int *sort_depsgr } if (ELEM(md->type, eModifierType_Softbody, eModifierType_Cloth) && - ob->particlesystem.first == NULL) { + ob->particlesystem.first == NULL) { ob->mode &= ~OB_MODE_PARTICLE_EDIT; } @@ -233,7 +233,7 @@ int ED_object_modifier_remove(ReportList *reports, Main *bmain, Scene *scene, Ob int sort_depsgraph = 0; int ok; - ok= object_modifier_remove(ob, md, &sort_depsgraph); + ok = object_modifier_remove(ob, md, &sort_depsgraph); if (!ok) { BKE_reportf(reports, RPT_ERROR, "Modifier '%s' not in object '%s'", ob->id.name, md->name); @@ -260,11 +260,11 @@ void ED_object_modifier_clear(Main *bmain, Scene *scene, Object *ob) while (md) { ModifierData *next_md; - next_md= md->next; + next_md = md->next; object_modifier_remove(ob, md, &sort_depsgraph); - md= next_md; + md = next_md; } DAG_id_tag_update(&ob->id, OB_RECALC_DATA); @@ -279,10 +279,10 @@ int ED_object_modifier_move_up(ReportList *reports, Object *ob, ModifierData *md 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; } @@ -300,10 +300,10 @@ int ED_object_modifier_move_down(ReportList *reports, Object *ob, ModifierData * 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; } @@ -326,72 +326,72 @@ int ED_object_modifier_convert(ReportList *UNUSED(reports), Main *bmain, Scene * MVert *mvert; MEdge *medge; int a, k, kmax; - int totvert=0, totedge=0, cvert=0; - int totpart=0, totchild=0; + 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; - psys=((ParticleSystemModifierData *)md)->psys; - part= psys->part; + psys = ((ParticleSystemModifierData *)md)->psys; + part = psys->part; if (part->ren_as != PART_DRAW_PATH || psys->pathcache == NULL) return 0; - totpart= psys->totcached; - totchild= psys->totchildcache; + totpart = psys->totcached; + totchild = psys->totchildcache; - if (totchild && (part->draw&PART_DRAW_PARENT)==0) - totpart= 0; + if (totchild && (part->draw & PART_DRAW_PARENT) == 0) + totpart = 0; /* count */ - cache= psys->pathcache; - for (a=0; apathcache; + for (a = 0; a < totpart; a++) { + key = cache[a]; if (key->steps > 0) { - totvert+= key->steps+1; - totedge+= key->steps; + totvert += key->steps + 1; + totedge += key->steps; } } - cache= psys->childcache; - for (a=0; achildcache; + for (a = 0; a < totchild; a++) { + key = cache[a]; if (key->steps > 0) { - totvert+= key->steps+1; - totedge+= key->steps; + 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); - me= obn->data; + obn = add_object(scene, OB_MESH); + me = obn->data; - me->totvert= totvert; - me->totedge= totedge; + me->totvert = totvert; + me->totedge = totedge; - me->mvert= CustomData_add_layer(&me->vdata, CD_MVERT, CD_CALLOC, NULL, totvert); - me->medge= CustomData_add_layer(&me->edata, CD_MEDGE, CD_CALLOC, NULL, totedge); - me->mface= CustomData_add_layer(&me->fdata, CD_MFACE, CD_CALLOC, NULL, 0); + me->mvert = CustomData_add_layer(&me->vdata, CD_MVERT, CD_CALLOC, NULL, totvert); + me->medge = CustomData_add_layer(&me->edata, CD_MEDGE, CD_CALLOC, NULL, totedge); + me->mface = CustomData_add_layer(&me->fdata, CD_MFACE, CD_CALLOC, NULL, 0); - mvert= me->mvert; - medge= me->medge; + mvert = me->mvert; + medge = me->medge; /* copy coordinates */ - cache= psys->pathcache; - for (a=0; asteps; - for (k=0; k<=kmax; k++,key++,cvert++,mvert++) { - copy_v3_v3(mvert->co,key->co); + cache = psys->pathcache; + for (a = 0; a < totpart; a++) { + key = cache[a]; + kmax = key->steps; + for (k = 0; k <= kmax; k++, key++, cvert++, mvert++) { + copy_v3_v3(mvert->co, key->co); if (k) { - medge->v1= cvert-1; - medge->v2= cvert; - medge->flag= ME_EDGEDRAW|ME_EDGERENDER|ME_LOOSEEDGE; + medge->v1 = cvert - 1; + medge->v2 = cvert; + medge->flag = ME_EDGEDRAW | ME_EDGERENDER | ME_LOOSEEDGE; medge++; } else { @@ -401,16 +401,16 @@ int ED_object_modifier_convert(ReportList *UNUSED(reports), Main *bmain, Scene * } } - cache=psys->childcache; - for (a=0; asteps; - for (k=0; k<=kmax; k++,key++,cvert++,mvert++) { - copy_v3_v3(mvert->co,key->co); + cache = psys->childcache; + for (a = 0; a < totchild; a++) { + key = cache[a]; + kmax = key->steps; + for (k = 0; k <= kmax; k++, key++, cvert++, mvert++) { + copy_v3_v3(mvert->co, key->co); if (k) { - medge->v1=cvert-1; - medge->v2=cvert; - medge->flag= ME_EDGEDRAW|ME_EDGERENDER|ME_LOOSEEDGE; + medge->v1 = cvert - 1; + medge->v2 = cvert; + medge->flag = ME_EDGEDRAW | ME_EDGERENDER | ME_LOOSEEDGE; medge++; } else { @@ -427,9 +427,9 @@ int ED_object_modifier_convert(ReportList *UNUSED(reports), Main *bmain, Scene * static int modifier_apply_shape(ReportList *reports, Scene *scene, Object *ob, ModifierData *md) { - ModifierTypeInfo *mti= modifierType_getInfo(md->type); + ModifierTypeInfo *mti = modifierType_getInfo(md->type); - md->scene= scene; + md->scene = scene; if (mti->isDisabled && mti->isDisabled(md, 0)) { BKE_report(reports, RPT_ERROR, "Modifier is disabled, skipping apply"); @@ -447,10 +447,10 @@ static int modifier_apply_shape(ReportList *reports, Scene *scene, Object *ob, M * and then predominantly stated in comments in a half dozen headers. */ - if (ob->type==OB_MESH) { + if (ob->type == OB_MESH) { DerivedMesh *dm; - Mesh *me= ob->data; - Key *key=me->key; + Mesh *me = ob->data; + Key *key = me->key; KeyBlock *kb; if (!modifier_sameTopology(md) || mti->type == eModifierTypeType_NonGeometrical) { @@ -465,15 +465,15 @@ static int modifier_apply_shape(ReportList *reports, Scene *scene, Object *ob, M } if (key == NULL) { - key= me->key= add_key((ID *)me); - key->type= KEY_RELATIVE; + key = me->key = add_key((ID *)me); + key->type = KEY_RELATIVE; /* if that was the first key block added, then it was the basis. * Initialize it with the mesh, and add another for the modifier */ - kb= add_keyblock(key, NULL); + kb = add_keyblock(key, NULL); mesh_to_key(me, kb); } - kb= add_keyblock(key, md->name); + kb = add_keyblock(key, md->name); DM_to_meshkey(dm, me, kb); dm->release(dm); @@ -487,19 +487,19 @@ static int modifier_apply_shape(ReportList *reports, Scene *scene, Object *ob, M static int modifier_apply_obdata(ReportList *reports, Scene *scene, Object *ob, ModifierData *md) { - ModifierTypeInfo *mti= modifierType_getInfo(md->type); + ModifierTypeInfo *mti = modifierType_getInfo(md->type); - md->scene= scene; + md->scene = scene; if (mti->isDisabled && mti->isDisabled(md, 0)) { BKE_report(reports, RPT_ERROR, "Modifier is disabled, skipping apply"); return 0; } - if (ob->type==OB_MESH) { + if (ob->type == OB_MESH) { DerivedMesh *dm; Mesh *me = ob->data; - MultiresModifierData *mmd= find_multires_modifier_before(scene, md); + MultiresModifierData *mmd = find_multires_modifier_before(scene, md); if (me->key && mti->type != eModifierTypeType_NonGeometrical) { BKE_report(reports, RPT_ERROR, "Modifier cannot be applied to Mesh with Shape Keys"); @@ -510,8 +510,8 @@ static int modifier_apply_obdata(ReportList *reports, Scene *scene, Object *ob, 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 (mmd && mmd->totlvl && mti->type == eModifierTypeType_OnlyDeform) { + if (!multiresModifier_reshapeFromDeformMod(scene, mmd, ob, md)) { BKE_report(reports, RPT_ERROR, "Multires modifier returned error, skipping apply"); return 0; } @@ -562,7 +562,7 @@ static int modifier_apply_obdata(ReportList *reports, Scene *scene, Object *ob, ParticleSystem *psys = ob->particlesystem.first; - for (; psys; psys=psys->next) { + for (; psys; psys = psys->next) { if (psys->part->type != PART_HAIR) continue; @@ -582,27 +582,27 @@ int ED_object_modifier_apply(ReportList *reports, Scene *scene, Object *ob, Modi 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; } - if (md!=ob->modifiers.first) + if (md != ob->modifiers.first) BKE_report(reports, RPT_INFO, "Applied modifier was not first, result may not be as expected"); /* allow apply of a not-realtime modifier, by first re-enabling realtime. */ - prev_mode= md->mode; + prev_mode = md->mode; md->mode |= eModifierMode_Realtime; if (mode == MODIFIER_APPLY_SHAPE) { if (!modifier_apply_shape(reports, scene, ob, md)) { - md->mode= prev_mode; + md->mode = prev_mode; return 0; } } else { if (!modifier_apply_obdata(reports, scene, ob, md)) { - md->mode= prev_mode; + md->mode = prev_mode; return 0; } } @@ -629,34 +629,34 @@ int ED_object_modifier_copy(ReportList *UNUSED(reports), Object *ob, ModifierDat static int modifier_add_exec(bContext *C, wmOperator *op) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); Object *ob = ED_object_active_context(C); - int type= RNA_enum_get(op->ptr, "type"); + int type = RNA_enum_get(op->ptr, "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); + WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); return OPERATOR_FINISHED; } static EnumPropertyItem *modifier_add_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), int *free) { - Object *ob= ED_object_active_context(C); - EnumPropertyItem *item= NULL, *md_item, *group_item= NULL; + Object *ob = ED_object_active_context(C); + EnumPropertyItem *item = NULL, *md_item, *group_item = NULL; ModifierTypeInfo *mti; - int totitem= 0, a; + int totitem = 0, a; if (!ob) return modifier_type_items; - for (a=0; modifier_type_items[a].identifier; a++) { - md_item= &modifier_type_items[a]; + for (a = 0; modifier_type_items[a].identifier; a++) { + md_item = &modifier_type_items[a]; if (md_item->identifier[0]) { - mti= modifierType_getInfo(md_item->value); + mti = modifierType_getInfo(md_item->value); if (mti->flags & eModifierTypeFlag_NoUserAdd) continue; @@ -665,22 +665,22 @@ static EnumPropertyItem *modifier_add_itemf(bContext *C, PointerRNA *UNUSED(ptr) continue; } else { - group_item= md_item; - md_item= NULL; + group_item = md_item; + md_item = NULL; continue; } if (group_item) { RNA_enum_item_add(&item, &totitem, group_item); - group_item= NULL; + group_item = NULL; } RNA_enum_item_add(&item, &totitem, md_item); } RNA_enum_item_end(&item, &totitem); - *free= 1; + *free = 1; return item; } @@ -700,10 +700,10 @@ void OBJECT_OT_modifier_add(wmOperatorType *ot) ot->poll = ED_operator_object_active_editable; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ - prop= RNA_def_enum(ot->srna, "type", modifier_type_items, eModifierType_Subsurf, "Type", ""); + prop = RNA_def_enum(ot->srna, "type", modifier_type_items, eModifierType_Subsurf, "Type", ""); RNA_def_enum_funcs(prop, modifier_add_itemf); ot->prop = prop; } @@ -712,12 +712,12 @@ void OBJECT_OT_modifier_add(wmOperatorType *ot) static int edit_modifier_poll_generic(bContext *C, StructRNA *rna_type, int obtype_flag) { - PointerRNA ptr= CTX_data_pointer_get_type(C, "modifier", rna_type); - Object *ob= (ptr.id.data)?ptr.id.data:ED_object_active_context(C); + PointerRNA ptr = CTX_data_pointer_get_type(C, "modifier", rna_type); + Object *ob = (ptr.id.data) ? ptr.id.data : ED_object_active_context(C); if (!ob || ob->id.lib) return 0; - if (obtype_flag && ((1<type) & obtype_flag)==0) return 0; - if (ptr.id.data && ((ID*)ptr.id.data)->lib) return 0; + if (obtype_flag && ((1 << ob->type) & obtype_flag) == 0) return 0; + if (ptr.id.data && ((ID *)ptr.id.data)->lib) return 0; return 1; } @@ -734,7 +734,7 @@ static void edit_modifier_properties(wmOperatorType *ot) static int edit_modifier_invoke_properties(bContext *C, wmOperator *op) { - PointerRNA ptr= CTX_data_pointer_get_type(C, "modifier", &RNA_Modifier); + PointerRNA ptr = CTX_data_pointer_get_type(C, "modifier", &RNA_Modifier); ModifierData *md; if (RNA_struct_property_is_set(op->ptr, "modifier")) @@ -767,8 +767,8 @@ static ModifierData *edit_modifier_property_get(wmOperator *op, Object *ob, int static int modifier_remove_exec(bContext *C, wmOperator *op) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); Object *ob = ED_object_active_context(C); ModifierData *md = edit_modifier_property_get(op, ob, 0); int mode_orig = ob ? ob->mode : 0; @@ -776,13 +776,13 @@ static int modifier_remove_exec(bContext *C, wmOperator *op) 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); + 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) - WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_MODE_OBJECT, NULL); + 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; } @@ -806,7 +806,7 @@ void OBJECT_OT_modifier_remove(wmOperatorType *ot) ot->poll = edit_modifier_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; edit_modifier_properties(ot); } @@ -821,7 +821,7 @@ static int modifier_move_up_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); return OPERATOR_FINISHED; } @@ -845,7 +845,7 @@ void OBJECT_OT_modifier_move_up(wmOperatorType *ot) ot->poll = edit_modifier_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; edit_modifier_properties(ot); } @@ -860,7 +860,7 @@ static int modifier_move_down_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); return OPERATOR_FINISHED; } @@ -884,7 +884,7 @@ void OBJECT_OT_modifier_move_down(wmOperatorType *ot) ot->poll = edit_modifier_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; edit_modifier_properties(ot); } @@ -892,17 +892,17 @@ void OBJECT_OT_modifier_move_down(wmOperatorType *ot) static int modifier_apply_exec(bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); Object *ob = ED_object_active_context(C); ModifierData *md = edit_modifier_property_get(op, ob, 0); - int apply_as= RNA_enum_get(op->ptr, "apply_as"); + int apply_as = RNA_enum_get(op->ptr, "apply_as"); if (!ob || !md || !ED_object_modifier_apply(op->reports, scene, ob, md, apply_as)) { return OPERATOR_CANCELLED; } DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); return OPERATOR_FINISHED; } @@ -931,7 +931,7 @@ void OBJECT_OT_modifier_apply(wmOperatorType *ot) ot->poll = edit_modifier_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_enum(ot->srna, "apply_as", modifier_apply_as_items, MODIFIER_APPLY_DATA, "Apply as", "How to apply the modifier to the geometry"); edit_modifier_properties(ot); @@ -941,8 +941,8 @@ void OBJECT_OT_modifier_apply(wmOperatorType *ot) static int modifier_convert_exec(bContext *C, wmOperator *op) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); Object *ob = ED_object_active_context(C); ModifierData *md = edit_modifier_property_get(op, ob, 0); @@ -950,7 +950,7 @@ static int modifier_convert_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); return OPERATOR_FINISHED; } @@ -974,7 +974,7 @@ void OBJECT_OT_modifier_convert(wmOperatorType *ot) ot->poll = edit_modifier_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; edit_modifier_properties(ot); } @@ -989,7 +989,7 @@ static int modifier_copy_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); return OPERATOR_FINISHED; } @@ -1013,7 +1013,7 @@ void OBJECT_OT_modifier_copy(wmOperatorType *ot) ot->poll = edit_modifier_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; edit_modifier_properties(ot); } @@ -1021,7 +1021,7 @@ void OBJECT_OT_modifier_copy(wmOperatorType *ot) static int multires_poll(bContext *C) { - return edit_modifier_poll_generic(C, &RNA_MultiresModifier, (1<exec = multires_higher_levels_delete_exec; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; edit_modifier_properties(ot); } @@ -1075,7 +1075,7 @@ static int multires_subdivide_exec(bContext *C, wmOperator *op) multiresModifier_subdivide(mmd, ob, 0, mmd->simple); DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); return OPERATOR_FINISHED; } @@ -1099,7 +1099,7 @@ void OBJECT_OT_multires_subdivide(wmOperatorType *ot) ot->exec = multires_subdivide_exec; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; edit_modifier_properties(ot); } @@ -1107,21 +1107,21 @@ void OBJECT_OT_multires_subdivide(wmOperatorType *ot) static int multires_reshape_exec(bContext *C, wmOperator *op) { - Object *ob= ED_object_active_context(C), *secondob= NULL; - Scene *scene= CTX_data_scene(C); + Object *ob = ED_object_active_context(C), *secondob = NULL; + Scene *scene = CTX_data_scene(C); MultiresModifierData *mmd = (MultiresModifierData *)edit_modifier_property_get(op, ob, eModifierType_Multires); 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) { + CTX_DATA_BEGIN (C, Object *, selob, selected_editable_objects) { if (selob->type == OB_MESH && selob != ob) { - secondob= selob; + secondob = selob; break; } } @@ -1138,7 +1138,7 @@ static int multires_reshape_exec(bContext *C, wmOperator *op) } DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); return OPERATOR_FINISHED; } @@ -1162,7 +1162,7 @@ void OBJECT_OT_multires_reshape(wmOperatorType *ot) ot->exec = multires_reshape_exec; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; edit_modifier_properties(ot); } @@ -1173,9 +1173,9 @@ void OBJECT_OT_multires_reshape(wmOperatorType *ot) static int multires_external_save_exec(bContext *C, wmOperator *op) { Object *ob = ED_object_active_context(C); - Mesh *me= (ob)? ob->data: op->customdata; + Mesh *me = (ob) ? ob->data : op->customdata; char path[FILE_MAX]; - int relative= RNA_boolean_get(op->ptr, "relative_path"); + int relative = RNA_boolean_get(op->ptr, "relative_path"); if (!me) return OPERATOR_CANCELLED; @@ -1198,7 +1198,7 @@ static int multires_external_save_invoke(bContext *C, wmOperator *op, wmEvent *U { Object *ob = ED_object_active_context(C); MultiresModifierData *mmd; - Mesh *me= ob->data; + Mesh *me = ob->data; char path[FILE_MAX]; if (!edit_modifier_invoke_properties(C, op)) @@ -1215,9 +1215,9 @@ static int multires_external_save_invoke(bContext *C, wmOperator *op, wmEvent *U if (RNA_struct_property_is_set(op->ptr, "filepath")) return multires_external_save_exec(C, op); - op->customdata= me; + op->customdata = me; - BLI_snprintf(path, sizeof(path), "//%s.btx", me->id.name+2); + BLI_snprintf(path, sizeof(path), "//%s.btx", me->id.name + 2); RNA_string_set(op->ptr, "filepath", path); WM_event_add_fileselect(C, op); @@ -1237,9 +1237,9 @@ void OBJECT_OT_multires_external_save(wmOperatorType *ot) ot->poll = multires_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - WM_operator_properties_filesel(ot, FOLDERFILE|BTXFILE, FILE_SPECIAL, FILE_SAVE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY); + WM_operator_properties_filesel(ot, FOLDERFILE | BTXFILE, FILE_SPECIAL, FILE_SAVE, WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY); edit_modifier_properties(ot); } @@ -1248,7 +1248,7 @@ void OBJECT_OT_multires_external_save(wmOperatorType *ot) static int multires_external_pack_exec(bContext *C, wmOperator *UNUSED(op)) { Object *ob = ED_object_active_context(C); - Mesh *me= ob->data; + Mesh *me = ob->data; if (!CustomData_external_test(&me->ldata, CD_MDISPS)) return OPERATOR_CANCELLED; @@ -1269,7 +1269,7 @@ void OBJECT_OT_multires_external_pack(wmOperatorType *ot) ot->exec = multires_external_pack_exec; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /********************* multires apply base ***********************/ @@ -1284,7 +1284,7 @@ static int multires_base_apply_exec(bContext *C, wmOperator *op) multiresModifier_base_apply(mmd, ob); DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); return OPERATOR_FINISHED; } @@ -1309,7 +1309,7 @@ void OBJECT_OT_multires_base_apply(wmOperatorType *ot) ot->exec = multires_base_apply_exec; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; edit_modifier_properties(ot); } @@ -1318,12 +1318,12 @@ void OBJECT_OT_multires_base_apply(wmOperatorType *ot) static int meshdeform_poll(bContext *C) { - return edit_modifier_poll_generic(C, &RNA_MeshDeformModifier, (1<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; - mmd->dyninfluences= NULL; - mmd->bindinfluences= NULL; - mmd->bindoffsets= NULL; - mmd->dynverts= NULL; - mmd->bindweights= NULL; /* deprecated */ - mmd->bindcos= NULL; /* deprecated */ - mmd->totvert= 0; - mmd->totcagevert= 0; - mmd->totinfluence= 0; + if (mmd->bindweights) MEM_freeN(mmd->bindweights); /* deprecated */ + if (mmd->bindcos) MEM_freeN(mmd->bindcos); /* deprecated */ + + mmd->bindcagecos = NULL; + mmd->dyngrid = NULL; + mmd->dyninfluences = NULL; + mmd->bindinfluences = NULL; + mmd->bindoffsets = NULL; + mmd->dynverts = NULL; + mmd->bindweights = NULL; /* deprecated */ + mmd->bindcos = NULL; /* deprecated */ + mmd->totvert = 0; + mmd->totcagevert = 0; + mmd->totinfluence = 0; DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); } else { DerivedMesh *dm; - int mode= mmd->modifier.mode; + int mode = mmd->modifier.mode; /* force modifier to run, it will call binding routine */ - mmd->bindfunc= mesh_deform_bind; + mmd->bindfunc = mesh_deform_bind; mmd->modifier.mode |= eModifierMode_Realtime; if (ob->type == OB_MESH) { - dm= mesh_create_derived_view(scene, ob, 0); + dm = mesh_create_derived_view(scene, ob, 0); dm->release(dm); } 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)) { makeDispListCurveTypes(scene, ob, 0); } - mmd->bindfunc= NULL; - mmd->modifier.mode= mode; + mmd->bindfunc = NULL; + mmd->modifier.mode = mode; } return OPERATOR_FINISHED; @@ -1405,7 +1405,7 @@ void OBJECT_OT_meshdeform_bind(wmOperatorType *ot) ot->exec = meshdeform_bind_exec; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; edit_modifier_properties(ot); } @@ -1427,7 +1427,7 @@ static int explode_refresh_exec(bContext *C, wmOperator *op) emd->flag |= eExplodeFlag_CalcFaces; DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); return OPERATOR_FINISHED; } @@ -1452,7 +1452,7 @@ void OBJECT_OT_explode_refresh(wmOperatorType *ot) ot->exec = explode_refresh_exec; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; edit_modifier_properties(ot); } @@ -1476,11 +1476,11 @@ static void init_ocean_modifier_bake(struct Ocean *oc, struct OceanModifierData do_normals = (omd->flag & MOD_OCEAN_GENERATE_NORMALS); do_jacobian = (omd->flag & MOD_OCEAN_GENERATE_FOAM); - BKE_init_ocean(oc, omd->resolution*omd->resolution, omd->resolution*omd->resolution, omd->spatial_size, omd->spatial_size, - omd->wind_velocity, omd->smallest_wave, 1.0, omd->wave_direction, omd->damp, omd->wave_alignment, - omd->depth, omd->time, - do_heightfield, do_chop, do_normals, do_jacobian, - omd->seed); + BKE_init_ocean(oc, omd->resolution * omd->resolution, omd->resolution * omd->resolution, omd->spatial_size, omd->spatial_size, + omd->wind_velocity, omd->smallest_wave, 1.0, omd->wave_direction, omd->damp, omd->wave_alignment, + omd->depth, omd->time, + do_heightfield, do_chop, do_normals, do_jacobian, + omd->seed); } typedef struct OceanBakeJob { @@ -1496,7 +1496,7 @@ typedef struct OceanBakeJob { static void oceanbake_free(void *customdata) { - OceanBakeJob *oj= customdata; + OceanBakeJob *oj = customdata; MEM_freeN(oj); } @@ -1515,34 +1515,34 @@ static int oceanbake_breakjob(void *UNUSED(customdata)) /* called by oceanbake, wmJob sends notifier */ static void oceanbake_update(void *customdata, float progress, int *cancel) { - OceanBakeJob *oj= customdata; + OceanBakeJob *oj = customdata; if (oceanbake_breakjob(oj)) *cancel = 1; - *(oj->do_update)= 1; - *(oj->progress)= progress; + *(oj->do_update) = 1; + *(oj->progress) = progress; } static void oceanbake_startjob(void *customdata, short *stop, short *do_update, float *progress) { - OceanBakeJob *oj= customdata; + OceanBakeJob *oj = customdata; - oj->stop= stop; + oj->stop = stop; oj->do_update = do_update; oj->progress = progress; - G.afbreek= 0; /* XXX shared with render - replace with job 'stop' switch */ + G.afbreek = 0; /* XXX shared with render - replace with job 'stop' switch */ BKE_bake_ocean(oj->ocean, oj->och, oceanbake_update, (void *)oj); - *do_update= 1; + *do_update = 1; *stop = 0; } static void oceanbake_endjob(void *customdata) { - OceanBakeJob *oj= customdata; + OceanBakeJob *oj = customdata; if (oj->ocean) { BKE_free_ocean(oj->ocean); @@ -1560,8 +1560,8 @@ static int ocean_bake_exec(bContext *C, wmOperator *op) Scene *scene = CTX_data_scene(C); OceanCache *och; struct Ocean *ocean; - int f, cfra, i=0; - int free= RNA_boolean_get(op->ptr, "free"); + int f, cfra, i = 0; + int free = RNA_boolean_get(op->ptr, "free"); wmJob *steve; OceanBakeJob *oj; @@ -1572,7 +1572,7 @@ static int ocean_bake_exec(bContext *C, wmOperator *op) if (free) { omd->refresh |= MOD_OCEAN_REFRESH_CLEAR_CACHE; DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); return OPERATOR_FINISHED; } @@ -1580,12 +1580,12 @@ static int ocean_bake_exec(bContext *C, wmOperator *op) omd->bakestart, omd->bakeend, omd->wave_scale, omd->chop_amount, omd->foam_coverage, omd->foam_fade, omd->resolution); - och->time = MEM_mallocN(och->duration*sizeof(float), "foam bake time"); + och->time = MEM_mallocN(och->duration * sizeof(float), "foam bake time"); cfra = scene->r.cfra; /* precalculate time variable before baking */ - for (f=omd->bakestart; f<=omd->bakeend; f++) { + for (f = omd->bakestart; f <= omd->bakeend; f++) { /* from physics_fluid.c: * * XXX: This can't be used due to an anim sys optimization that ignores recalc object animation, @@ -1614,7 +1614,7 @@ static int ocean_bake_exec(bContext *C, wmOperator *op) init_ocean_modifier_bake(ocean, omd); #if 0 - BKE_bake_ocean(ocean, och); + BKE_bake_ocean(ocean, och); omd->oceancache = och; omd->cached = TRUE; @@ -1622,7 +1622,7 @@ static int ocean_bake_exec(bContext *C, wmOperator *op) scene->r.cfra = cfra; DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); #endif /* job stuff */ @@ -1630,14 +1630,14 @@ static int ocean_bake_exec(bContext *C, wmOperator *op) scene->r.cfra = cfra; /* setup job */ - steve= WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene, "Ocean Simulation", WM_JOB_PROGRESS); - oj= MEM_callocN(sizeof(OceanBakeJob), "ocean bake job"); + steve = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene, "Ocean Simulation", WM_JOB_PROGRESS); + oj = MEM_callocN(sizeof(OceanBakeJob), "ocean bake job"); oj->ocean = ocean; oj->och = och; oj->omd = omd; WM_jobs_customdata(steve, oj, oceanbake_free); - WM_jobs_timer(steve, 0.1, NC_OBJECT|ND_MODIFIER, NC_OBJECT|ND_MODIFIER); + WM_jobs_timer(steve, 0.1, NC_OBJECT | ND_MODIFIER, NC_OBJECT | ND_MODIFIER); WM_jobs_callbacks(steve, oceanbake_startjob, NULL, NULL, oceanbake_endjob); WM_jobs_start(CTX_wm_manager(C), steve); @@ -1667,7 +1667,7 @@ void OBJECT_OT_ocean_bake(wmOperatorType *ot) ot->exec = ocean_bake_exec; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; edit_modifier_properties(ot); RNA_def_boolean(ot->srna, "free", FALSE, "Free", "Free the bake, rather than generating it"); diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index 138cbad0a68..4cd18d91249 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) wmOperatorType *ot; wmOperatorTypeMacro *otmacro; - ot = WM_operatortype_append_macro("OBJECT_OT_duplicate_move", "Duplicate Objects", OPTYPE_UNDO|OPTYPE_REGISTER); + ot = WM_operatortype_append_macro("OBJECT_OT_duplicate_move", "Duplicate Objects", OPTYPE_UNDO | OPTYPE_REGISTER); if (ot) { ot->description = "Duplicate selected objects and move them"; WM_operatortype_macro_define(ot, "OBJECT_OT_duplicate"); @@ -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); + ot = WM_operatortype_append_macro("OBJECT_OT_duplicate_move_linked", "Duplicate Linked", OPTYPE_UNDO | OPTYPE_REGISTER); if (ot) { ot->description = "Duplicate selected objects and move them"; otmacro = WM_operatortype_macro_define(ot, "OBJECT_OT_duplicate"); @@ -241,10 +241,10 @@ 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); + ot = WM_operatortype_append_macro("OBJECT_OT_add_named_cursor", "Add named object at cursor", OPTYPE_UNDO | OPTYPE_REGISTER); 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"); + RNA_def_string(ot->srna, "name", "Cube", MAX_ID_NAME - 2, "Name", "Object name to add"); WM_operatortype_macro_define(ot, "VIEW3D_OT_cursor3d"); WM_operatortype_macro_define(ot, "OBJECT_OT_add_named"); @@ -253,7 +253,7 @@ void ED_operatormacros_object(void) static int object_mode_poll(bContext *C) { - Object *ob= CTX_data_active_object(C); + Object *ob = CTX_data_active_object(C); return (!ob || ob->mode == OB_MODE_OBJECT); } @@ -283,7 +283,7 @@ void ED_keymap_object(wmKeyConfig *keyconf) RNA_enum_set(kmi->ptr, "mode", OB_MODE_WEIGHT_PAINT); RNA_boolean_set(kmi->ptr, "toggle", TRUE); - WM_keymap_add_item(keymap, "OBJECT_OT_origin_set", CKEY, KM_PRESS, KM_ALT|KM_SHIFT|KM_CTRL, 0); + WM_keymap_add_item(keymap, "OBJECT_OT_origin_set", CKEY, KM_PRESS, KM_ALT | KM_SHIFT | KM_CTRL, 0); /* Object Mode ---------------------------------------------------------------- */ /* Note: this keymap gets disabled in non-objectmode, */ @@ -302,7 +302,7 @@ void ED_keymap_object(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "OBJECT_OT_select_linked", LKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "OBJECT_OT_select_grouped", GKEY, KM_PRESS, KM_SHIFT, 0); - WM_keymap_add_item(keymap, "OBJECT_OT_select_mirror", MKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0); + WM_keymap_add_item(keymap, "OBJECT_OT_select_mirror", MKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0); kmi = WM_keymap_add_item(keymap, "OBJECT_OT_select_hierarchy", LEFTBRACKETKEY, KM_PRESS, 0, 0); RNA_enum_set_identifier(kmi->ptr, "direction", "PARENT"); @@ -321,13 +321,13 @@ void ED_keymap_object(wmKeyConfig *keyconf) RNA_boolean_set(kmi->ptr, "extend", TRUE); WM_keymap_verify_item(keymap, "OBJECT_OT_parent_set", PKEY, KM_PRESS, KM_CTRL, 0); - WM_keymap_verify_item(keymap, "OBJECT_OT_parent_no_inverse_set", PKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0); + WM_keymap_verify_item(keymap, "OBJECT_OT_parent_no_inverse_set", PKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0); WM_keymap_verify_item(keymap, "OBJECT_OT_parent_clear", PKEY, KM_PRESS, KM_ALT, 0); WM_keymap_verify_item(keymap, "OBJECT_OT_track_set", TKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_verify_item(keymap, "OBJECT_OT_track_clear", TKEY, KM_PRESS, KM_ALT, 0); - WM_keymap_verify_item(keymap, "OBJECT_OT_constraint_add_with_targets", CKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0); - WM_keymap_verify_item(keymap, "OBJECT_OT_constraints_clear", CKEY, KM_PRESS, KM_CTRL|KM_ALT, 0); + WM_keymap_verify_item(keymap, "OBJECT_OT_constraint_add_with_targets", CKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0); + WM_keymap_verify_item(keymap, "OBJECT_OT_constraints_clear", CKEY, KM_PRESS, KM_CTRL | KM_ALT, 0); WM_keymap_verify_item(keymap, "OBJECT_OT_location_clear", GKEY, KM_PRESS, KM_ALT, 0); WM_keymap_verify_item(keymap, "OBJECT_OT_rotation_clear", RKEY, KM_PRESS, KM_ALT, 0); @@ -342,13 +342,13 @@ void ED_keymap_object(wmKeyConfig *keyconf) RNA_boolean_set(kmi->ptr, "unselected", TRUE); /* same as above but for rendering */ - WM_keymap_add_item(keymap, "OBJECT_OT_hide_render_clear", HKEY, KM_PRESS, KM_ALT|KM_CTRL, 0); + WM_keymap_add_item(keymap, "OBJECT_OT_hide_render_clear", HKEY, KM_PRESS, KM_ALT | KM_CTRL, 0); WM_keymap_add_item(keymap, "OBJECT_OT_hide_render_set", HKEY, KM_PRESS, KM_CTRL, 0); /* conflicts, removing */ #if 0 - kmi = WM_keymap_add_item(keymap, "OBJECT_OT_hide_render_set", HKEY, KM_PRESS, KM_SHIFT|KM_CTRL, 0) - RNA_boolean_set(kmi->ptr, "unselected", TRUE); + kmi = WM_keymap_add_item(keymap, "OBJECT_OT_hide_render_set", HKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0) + RNA_boolean_set(kmi->ptr, "unselected", TRUE); #endif WM_keymap_add_item(keymap, "OBJECT_OT_move_to_layer", MKEY, KM_PRESS, 0, 0); @@ -366,7 +366,7 @@ void ED_keymap_object(wmKeyConfig *keyconf) WM_keymap_add_menu(keymap, "INFO_MT_add", AKEY, KM_PRESS, KM_SHIFT, 0); - WM_keymap_add_item(keymap, "OBJECT_OT_duplicates_make_real", AKEY, KM_PRESS, KM_SHIFT|KM_CTRL, 0); + WM_keymap_add_item(keymap, "OBJECT_OT_duplicates_make_real", AKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0); WM_keymap_add_menu(keymap, "VIEW3D_MT_object_apply", AKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_menu(keymap, "VIEW3D_MT_make_single_user", UKEY, KM_PRESS, 0, 0); @@ -377,23 +377,23 @@ void ED_keymap_object(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "OBJECT_OT_join", JKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "OBJECT_OT_convert", CKEY, KM_PRESS, KM_ALT, 0); - WM_keymap_add_item(keymap, "OBJECT_OT_proxy_make", PKEY, KM_PRESS, KM_CTRL|KM_ALT, 0); + WM_keymap_add_item(keymap, "OBJECT_OT_proxy_make", PKEY, KM_PRESS, KM_CTRL | KM_ALT, 0); WM_keymap_add_item(keymap, "OBJECT_OT_make_local", LKEY, KM_PRESS, 0, 0); // XXX this should probably be in screen instead... here for testing purposes in the meantime... - Aligorith WM_keymap_verify_item(keymap, "ANIM_OT_keyframe_insert_menu", IKEY, KM_PRESS, 0, 0); WM_keymap_verify_item(keymap, "ANIM_OT_keyframe_delete_v3d", IKEY, KM_PRESS, KM_ALT, 0); - WM_keymap_verify_item(keymap, "ANIM_OT_keying_set_active_set", IKEY, KM_PRESS, KM_CTRL|KM_SHIFT|KM_ALT, 0); + WM_keymap_verify_item(keymap, "ANIM_OT_keying_set_active_set", IKEY, KM_PRESS, KM_CTRL | KM_SHIFT | KM_ALT, 0); WM_keymap_verify_item(keymap, "GROUP_OT_create", GKEY, KM_PRESS, KM_CTRL, 0); - WM_keymap_verify_item(keymap, "GROUP_OT_objects_remove", GKEY, KM_PRESS, KM_CTRL|KM_ALT, 0); - WM_keymap_verify_item(keymap, "GROUP_OT_objects_add_active", GKEY, KM_PRESS, KM_SHIFT|KM_CTRL, 0); - WM_keymap_verify_item(keymap, "GROUP_OT_objects_remove_active", GKEY, KM_PRESS, KM_SHIFT|KM_ALT, 0); + WM_keymap_verify_item(keymap, "GROUP_OT_objects_remove", GKEY, KM_PRESS, KM_CTRL | KM_ALT, 0); + WM_keymap_verify_item(keymap, "GROUP_OT_objects_add_active", GKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0); + WM_keymap_verify_item(keymap, "GROUP_OT_objects_remove_active", GKEY, KM_PRESS, KM_SHIFT | KM_ALT, 0); WM_keymap_add_menu(keymap, "VIEW3D_MT_object_specials", WKEY, KM_PRESS, 0, 0); - for (i=0; i<=5; i++) { - kmi = WM_keymap_add_item(keymap, "OBJECT_OT_subdivision_set", ZEROKEY+i, KM_PRESS, KM_CTRL, 0); + 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); } diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index 624d6e52926..3a00c69fc47 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -110,9 +110,9 @@ static int vertex_parent_set_poll(bContext *C) static int vertex_parent_set_exec(bContext *C, wmOperator *op) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); - Object *obedit= CTX_data_edit_object(C); + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + Object *obedit = CTX_data_edit_object(C); BMVert *eve; BMIter iter; Curve *cu; @@ -120,18 +120,18 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op) BezTriple *bezt; BPoint *bp; Object *par; - int a, v1=0, v2=0, v3=0, v4=0, nr=1; + int a, v1 = 0, v2 = 0, v3 = 0, v4 = 0, nr = 1; /* we need 1 to 3 selected vertices */ - if (obedit->type==OB_MESH) { - Mesh *me= obedit->data; + if (obedit->type == OB_MESH) { + Mesh *me = obedit->data; BMEditMesh *em; EDBM_mesh_load(obedit); EDBM_mesh_make(scene->toolsettings, scene, obedit); - em= me->edit_btmesh; + em = me->edit_btmesh; /* derivedMesh might be needed for solving parenting, * so re-create it here */ @@ -139,31 +139,31 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op) BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) { 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)) { - ListBase *editnurb= object_editcurve_get(obedit); + ListBase *editnurb = object_editcurve_get(obedit); - cu= obedit->data; + cu = obedit->data; - nu= editnurb->first; + nu = editnurb->first; while (nu) { if (nu->type == CU_BEZIER) { - bezt= nu->bezt; - a= nu->pntsu; + 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; + 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++; @@ -171,34 +171,34 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op) } } else { - bp= nu->bp; - a= nu->pntsu*nu->pntsv; + 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; + 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++; bp++; } } - nu= nu->next; + nu = nu->next; } } - else if (obedit->type==OB_LATTICE) { - Lattice *lt= obedit->data; + 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; + 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; + 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,19 +206,19 @@ 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) { + CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) { if (ob != obedit) { - ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; - par= obedit->parent; + ob->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME; + par = obedit->parent; while (par) { - if (par==ob) break; - par= par->parent; + if (par == ob) break; + par = par->parent; } if (par) { BKE_report(op->reports, RPT_ERROR, "Loop in parents"); @@ -226,20 +226,20 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op) else { Object workob; - ob->parent= BASACT->object; + ob->parent = BASACT->object; if (v3) { - ob->partype= PARVERT3; - ob->par1= v1-1; - ob->par2= v2-1; - ob->par3= v3-1; + ob->partype = PARVERT3; + ob->par1 = v1 - 1; + ob->par2 = v2 - 1; + ob->par3 = v3 - 1; /* inverse parent matrix */ what_does_parent(scene, ob, &workob); invert_m4_m4(ob->parentinv, workob.obmat); } else { - ob->partype= PARVERT1; - ob->par1= v1-1; + ob->partype = PARVERT1; + ob->par1 = v1 - 1; /* inverse parent matrix */ what_does_parent(scene, ob, &workob); @@ -270,16 +270,16 @@ void OBJECT_OT_vertex_parent_set(wmOperatorType *ot) ot->exec = vertex_parent_set_exec; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /********************** Make Proxy Operator *************************/ /* set the object to proxify */ -static int make_proxy_invoke (bContext *C, wmOperator *op, wmEvent *evt) +static int make_proxy_invoke(bContext *C, wmOperator *op, wmEvent *evt) { - Scene *scene= CTX_data_scene(C); - Object *ob= ED_object_active_context(C); + Scene *scene = CTX_data_scene(C); + Object *ob = ED_object_active_context(C); /* sanity checks */ if (!scene || scene->id.lib || !ob) @@ -294,8 +294,8 @@ static int make_proxy_invoke (bContext *C, wmOperator *op, wmEvent *evt) } else if (ob->id.lib) { - uiPopupMenu *pup= uiPupMenuBegin(C, "OK?", ICON_QUESTION); - uiLayout *layout= uiPupMenuLayout(pup); + uiPopupMenu *pup = uiPupMenuBegin(C, "OK?", ICON_QUESTION); + uiLayout *layout = uiPupMenuLayout(pup); /* create operator menu item with relevant properties filled in */ uiItemFullO_ptr(layout, op->type, op->type->name, ICON_NONE, NULL, WM_OP_EXEC_REGION_WIN, UI_ITEM_O_RETURN_PROPS); @@ -312,41 +312,41 @@ static int make_proxy_invoke (bContext *C, wmOperator *op, wmEvent *evt) return OPERATOR_CANCELLED; } -static int make_proxy_exec (bContext *C, wmOperator *op) +static int make_proxy_exec(bContext *C, wmOperator *op) { - Main *bmain= CTX_data_main(C); - Object *ob, *gob= ED_object_active_context(C); + Main *bmain = CTX_data_main(C); + Object *ob, *gob = ED_object_active_context(C); GroupObject *go; - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); if (gob->dup_group != NULL) { - go= BLI_findlink(&gob->dup_group->gobject, RNA_enum_get(op->ptr, "object")); - ob= go->ob; + go = BLI_findlink(&gob->dup_group->gobject, RNA_enum_get(op->ptr, "object")); + ob = go->ob; } else { - ob= gob; + ob = gob; gob = NULL; } if (ob) { Object *newob; - Base *newbase, *oldbase= BASACT; - char name[MAX_ID_NAME+4]; + Base *newbase, *oldbase = BASACT; + char name[MAX_ID_NAME + 4]; /* Add new object for the proxy */ - newob= add_object(scene, OB_EMPTY); + newob = add_object(scene, OB_EMPTY); - BLI_snprintf(name, sizeof(name), "%s_proxy", ((ID *)(gob ? gob : ob))->name+2); + BLI_snprintf(name, sizeof(name), "%s_proxy", ((ID *)(gob ? gob : ob))->name + 2); rename_id(&newob->id, name); /* set layers OK */ - newbase= BASACT; /* add_object sets active... */ - newbase->lay= oldbase->lay; - newob->lay= newbase->lay; + newbase = BASACT; /* add_object sets active... */ + newbase->lay = oldbase->lay; + newob->lay = newbase->lay; /* remove base, leave user count of object, it gets linked in object_make_proxy */ - if (gob==NULL) { + if (gob == NULL) { BLI_remlink(&scene->base, oldbase); MEM_freeN(oldbase); } @@ -355,8 +355,8 @@ static int make_proxy_exec (bContext *C, wmOperator *op) /* depsgraph flushes are needed for the new data */ DAG_scene_sort(bmain, scene); - DAG_id_tag_update(&newob->id, OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME); - WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, newob); + DAG_id_tag_update(&newob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); + WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, newob); } else { BKE_report(op->reports, RPT_ERROR, "No object to make proxy for"); @@ -369,29 +369,29 @@ static int make_proxy_exec (bContext *C, wmOperator *op) /* Generic itemf's for operators that take library args */ static EnumPropertyItem *proxy_group_object_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), int *free) { - EnumPropertyItem item_tmp= {0}, *item= NULL; - int totitem= 0; - int i= 0; - Object *ob= ED_object_active_context(C); + EnumPropertyItem item_tmp = {0}, *item = NULL; + int totitem = 0; + int i = 0; + Object *ob = ED_object_active_context(C); GroupObject *go; if (!ob || !ob->dup_group) return DummyRNA_DEFAULT_items; /* find the object to affect */ - for (go= ob->dup_group->gobject.first; go; go= go->next) { - item_tmp.identifier= item_tmp.name= go->ob->id.name+2; - item_tmp.value= i++; + for (go = ob->dup_group->gobject.first; go; go = go->next) { + item_tmp.identifier = item_tmp.name = go->ob->id.name + 2; + item_tmp.value = i++; RNA_enum_item_add(&item, &totitem, &item_tmp); } RNA_enum_item_end(&item, &totitem); - *free= 1; + *free = 1; return item; } -void OBJECT_OT_proxy_make (wmOperatorType *ot) +void OBJECT_OT_proxy_make(wmOperatorType *ot) { PropertyRNA *prop; @@ -406,10 +406,10 @@ void OBJECT_OT_proxy_make (wmOperatorType *ot) ot->poll = ED_operator_object_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ - prop= RNA_def_enum(ot->srna, "object", DummyRNA_DEFAULT_items, 0, "Proxy Object", "Name of lib-linked/grouped object to make a proxy for"); /* XXX, relies on hard coded ID at the moment */ + prop = RNA_def_enum(ot->srna, "object", DummyRNA_DEFAULT_items, 0, "Proxy Object", "Name of lib-linked/grouped object to make a proxy for"); /* XXX, relies on hard coded ID at the moment */ RNA_def_enum_funcs(prop, proxy_group_object_itemf); ot->prop = prop; } @@ -425,31 +425,31 @@ EnumPropertyItem prop_clear_parent_types[] = { void ED_object_parent_clear(bContext *C, int type) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); - CTX_DATA_BEGIN (C, Object*, ob, selected_editable_objects) { + CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) { if (ob->parent == NULL) continue; if (type == 0) { - ob->parent= NULL; + ob->parent = NULL; } else if (type == 1) { - ob->parent= NULL; + ob->parent = NULL; object_apply_mat4(ob, ob->obmat, TRUE, FALSE); } else if (type == 2) unit_m4(ob->parentinv); - ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; + ob->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME; } CTX_DATA_END; DAG_scene_sort(bmain, scene); DAG_ids_flush_update(bmain, 0); - WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); - WM_event_add_notifier(C, NC_OBJECT|ND_PARENT, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_PARENT, NULL); } /* note, poll should check for editable scene */ @@ -474,7 +474,7 @@ void OBJECT_OT_parent_clear(wmOperatorType *ot) ot->poll = ED_operator_object_active_editable; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; ot->prop = RNA_def_enum(ot->srna, "type", prop_clear_parent_types, 0, "Type", ""); } @@ -484,15 +484,15 @@ void OBJECT_OT_parent_clear(wmOperatorType *ot) void ED_object_parent(Object *ob, Object *par, int type, const char *substr) { if (!par || BKE_object_parent_loop_check(par, ob)) { - ob->parent= NULL; - ob->partype= PAROBJECT; - ob->parsubstr[0]= 0; + ob->parent = NULL; + ob->partype = PAROBJECT; + ob->parsubstr[0] = 0; return; } /* this could use some more checks */ - ob->parent= par; + ob->parent = par; ob->partype &= ~PARTYPE; ob->partype |= type; BLI_strncpy(ob->parsubstr, substr, sizeof(ob->parsubstr)); @@ -517,20 +517,20 @@ EnumPropertyItem prop_make_parent_types[] = { int ED_object_parent_set(ReportList *reports, Main *bmain, Scene *scene, Object *ob, Object *par, int partype) { - bPoseChannel *pchan= NULL; - int pararm= ELEM4(partype, PAR_ARMATURE, PAR_ARMATURE_NAME, PAR_ARMATURE_ENVELOPE, PAR_ARMATURE_AUTO); + bPoseChannel *pchan = NULL; + int pararm = ELEM4(partype, PAR_ARMATURE, PAR_ARMATURE_NAME, PAR_ARMATURE_ENVELOPE, PAR_ARMATURE_AUTO); 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; + Curve *cu = par->data; - if ((cu->flag & CU_PATH)==0) { - cu->flag |= CU_PATH|CU_FOLLOW; + 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; @@ -548,19 +548,19 @@ 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) - partype= PAR_OBJECT; + partype = PAR_OBJECT; } } - else if (partype==PAR_BONE) { - pchan= get_active_posechannel(par); + 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; } } - if (ob!=par) { + if (ob != par) { if (BKE_object_parent_loop_check(par, ob)) { BKE_report(reports, RPT_ERROR, "Loop in parents"); return 0; @@ -573,14 +573,14 @@ int ED_object_parent_set(ReportList *reports, Main *bmain, Scene *scene, Object /* set the parent (except for follow-path constraint option) */ if (partype != PAR_PATH_CONST) { - ob->parent= par; + ob->parent = par; } /* handle types */ if (pchan) BLI_strncpy(ob->parsubstr, pchan->name, sizeof(ob->parsubstr)); else - ob->parsubstr[0]= 0; + ob->parsubstr[0] = 0; if (partype == PAR_PATH_CONST) { /* don't do anything here, since this is not technically "parenting" */ @@ -589,7 +589,7 @@ int ED_object_parent_set(ReportList *reports, Main *bmain, Scene *scene, Object /* partype is now set to PAROBJECT so that invisible 'virtual' modifiers don't need to be created * NOTE: the old (2.4x) method was to set ob->partype = PARSKEL, creating the virtual modifiers */ - ob->partype= PAROBJECT; /* note, dna define, not operator property */ + ob->partype = PAROBJECT; /* note, dna define, not operator property */ //ob->partype= PARSKEL; /* note, dna define, not operator property */ /* BUT, to keep the deforms, we need a modifier, and then we need to set the object that it uses */ @@ -598,25 +598,25 @@ int ED_object_parent_set(ReportList *reports, Main *bmain, Scene *scene, Object ModifierData *md; switch (partype) { - case PAR_CURVE: /* curve deform */ - md= ED_object_modifier_add(reports, bmain, scene, ob, NULL, eModifierType_Curve); - ((CurveModifierData *)md)->object= par; - break; - case PAR_LATTICE: /* lattice deform */ - md= ED_object_modifier_add(reports, bmain, scene, ob, NULL, eModifierType_Lattice); - ((LatticeModifierData *)md)->object= par; - break; - default: /* armature deform */ - md= ED_object_modifier_add(reports, bmain, scene, ob, NULL, eModifierType_Armature); - ((ArmatureModifierData *)md)->object= par; - break; + case PAR_CURVE: /* curve deform */ + md = ED_object_modifier_add(reports, bmain, scene, ob, NULL, eModifierType_Curve); + ((CurveModifierData *)md)->object = par; + break; + case PAR_LATTICE: /* lattice deform */ + md = ED_object_modifier_add(reports, bmain, scene, ob, NULL, eModifierType_Lattice); + ((LatticeModifierData *)md)->object = par; + break; + default: /* armature deform */ + md = ED_object_modifier_add(reports, bmain, scene, ob, NULL, eModifierType_Armature); + ((ArmatureModifierData *)md)->object = par; + break; } } } else if (partype == PAR_BONE) - ob->partype= PARBONE; /* note, dna define, not operator property */ + ob->partype = PARBONE; /* note, dna define, not operator property */ else - ob->partype= PAROBJECT; /* note, dna define, not operator property */ + ob->partype = PAROBJECT; /* note, dna define, not operator property */ /* constraint */ if (partype == PAR_PATH_CONST) { @@ -636,7 +636,7 @@ 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) { + 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) @@ -647,7 +647,7 @@ int ED_object_parent_set(ReportList *reports, Main *bmain, Scene *scene, Object WM_cursor_wait(0); } /* get corrected inverse */ - ob->partype= PAROBJECT; + ob->partype = PAROBJECT; what_does_parent(scene, ob, &workob); invert_m4_m4(ob->parentinv, workob.obmat); @@ -658,7 +658,7 @@ int ED_object_parent_set(ReportList *reports, Main *bmain, Scene *scene, Object invert_m4_m4(ob->parentinv, workob.obmat); } - ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA; + ob->recalc |= OB_RECALC_OB | OB_RECALC_DATA; } } @@ -667,13 +667,13 @@ int ED_object_parent_set(ReportList *reports, Main *bmain, Scene *scene, Object static int parent_set_exec(bContext *C, wmOperator *op) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); - Object *par= ED_object_active_context(C); - int partype= RNA_enum_get(op->ptr, "type"); + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + Object *par = ED_object_active_context(C); + int partype = RNA_enum_get(op->ptr, "type"); int ok = 1; - CTX_DATA_BEGIN (C, Object*, ob, selected_editable_objects) { + CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) { if (!ED_object_parent_set(op->reports, bmain, scene, ob, par, partype)) { ok = 0; break; @@ -686,8 +686,8 @@ static int parent_set_exec(bContext *C, wmOperator *op) DAG_scene_sort(bmain, scene); DAG_ids_flush_update(bmain, 0); - WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); - WM_event_add_notifier(C, NC_OBJECT|ND_PARENT, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_PARENT, NULL); return OPERATOR_FINISHED; } @@ -695,22 +695,22 @@ static int parent_set_exec(bContext *C, wmOperator *op) static int parent_set_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *UNUSED(event)) { - Object *ob= ED_object_active_context(C); - uiPopupMenu *pup= uiPupMenuBegin(C, "Set Parent To", ICON_NONE); - uiLayout *layout= uiPupMenuLayout(pup); + Object *ob = ED_object_active_context(C); + uiPopupMenu *pup = uiPupMenuBegin(C, "Set Parent To", ICON_NONE); + uiLayout *layout = uiPupMenuLayout(pup); uiLayoutSetOperatorContext(layout, WM_OP_EXEC_DEFAULT); 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); @@ -739,7 +739,7 @@ void OBJECT_OT_parent_set(wmOperatorType *ot) ot->poll = ED_operator_object_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_enum(ot->srna, "type", prop_make_parent_types, 0, "Type", ""); } @@ -748,13 +748,13 @@ void OBJECT_OT_parent_set(wmOperatorType *ot) static int parent_noinv_set_exec(bContext *C, wmOperator *op) { - Main *bmain= CTX_data_main(C); - Object *par= ED_object_active_context(C); + Main *bmain = CTX_data_main(C); + Object *par = ED_object_active_context(C); par->recalc |= OB_RECALC_OB; /* context iterator */ - CTX_DATA_BEGIN (C, Object*, ob, selected_editable_objects) { + CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) { if (ob != par) { if (BKE_object_parent_loop_check(par, ob)) { BKE_report(op->reports, RPT_ERROR, "Loop in parents"); @@ -762,14 +762,14 @@ static int parent_noinv_set_exec(bContext *C, wmOperator *op) else { /* clear inverse matrix and also the object location */ unit_m4(ob->parentinv); - memset(ob->loc, 0, 3*sizeof(float)); + memset(ob->loc, 0, 3 * sizeof(float)); /* set recalc flags */ - ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA; + ob->recalc |= OB_RECALC_OB | OB_RECALC_DATA; /* set parenting type for object - object only... */ - ob->parent= par; - ob->partype= PAROBJECT; /* note, dna define, not operator property */ + ob->parent = par; + ob->partype = PAROBJECT; /* note, dna define, not operator property */ } } } @@ -777,7 +777,7 @@ static int parent_noinv_set_exec(bContext *C, wmOperator *op) DAG_scene_sort(bmain, CTX_data_scene(C)); DAG_ids_flush_update(bmain, 0); - WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); return OPERATOR_FINISHED; } @@ -795,17 +795,17 @@ void OBJECT_OT_parent_no_inverse_set(wmOperatorType *ot) ot->poll = ED_operator_object_active_editable; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /************************ Clear Slow Parent Operator *********************/ static int object_slow_parent_clear_exec(bContext *C, wmOperator *UNUSED(op)) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); - CTX_DATA_BEGIN (C, Object*, ob, selected_editable_objects) { + CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) { if (ob->parent) { if (ob->partype & PARSLOW) { ob->partype -= PARSLOW; @@ -837,17 +837,17 @@ void OBJECT_OT_slow_parent_clear(wmOperatorType *ot) ot->poll = ED_operator_view3d_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /********************** Make Slow Parent Operator *********************/ static int object_slow_parent_set_exec(bContext *C, wmOperator *UNUSED(op)) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); - CTX_DATA_BEGIN (C, Object*, ob, selected_editable_objects) { + CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) { if (ob->parent) ob->partype |= PARSLOW; @@ -876,7 +876,7 @@ void OBJECT_OT_slow_parent_set(wmOperatorType *ot) ot->poll = ED_operator_view3d_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ******************** Clear Track Operator ******************* */ @@ -890,24 +890,24 @@ static EnumPropertyItem prop_clear_track_types[] = { /* note, poll should check for editable scene */ static int object_track_clear_exec(bContext *C, wmOperator *op) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); - int type= RNA_enum_get(op->ptr, "type"); + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + int type = RNA_enum_get(op->ptr, "type"); if (CTX_data_edit_object(C)) { BKE_report(op->reports, RPT_ERROR, "Operation cannot be performed in EditMode"); return OPERATOR_CANCELLED; } - CTX_DATA_BEGIN (C, Object*, ob, selected_editable_objects) { + CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) { bConstraint *con, *pcon; /* remove track-object for old track */ - ob->track= NULL; - ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; + ob->track = NULL; + ob->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME; /* also remove all tracking constraints */ - for (con= ob->constraints.last; con; con= pcon) { - pcon= con->prev; + for (con = ob->constraints.last; con; con = pcon) { + pcon = con->prev; if (ELEM3(con->type, CONSTRAINT_TYPE_TRACKTO, CONSTRAINT_TYPE_LOCKTRACK, CONSTRAINT_TYPE_DAMPTRACK)) remove_constraint(&ob->constraints, con); } @@ -919,7 +919,7 @@ static int object_track_clear_exec(bContext *C, wmOperator *op) DAG_ids_flush_update(bmain, 0); DAG_scene_sort(bmain, scene); - WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); return OPERATOR_FINISHED; } @@ -938,7 +938,7 @@ void OBJECT_OT_track_clear(wmOperatorType *ot) ot->poll = ED_operator_objectmode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; ot->prop = RNA_def_enum(ot->srna, "type", prop_clear_track_types, 0, "Type", ""); } @@ -954,23 +954,23 @@ static EnumPropertyItem prop_make_track_types[] = { static int track_set_exec(bContext *C, wmOperator *op) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); - Object *obact= ED_object_active_context(C); + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + Object *obact = ED_object_active_context(C); - int type= RNA_enum_get(op->ptr, "type"); + int type = RNA_enum_get(op->ptr, "type"); if (type == 1) { bConstraint *con; bDampTrackConstraint *data; - CTX_DATA_BEGIN (C, Object*, ob, selected_editable_objects) { - if (ob!=obact) { + CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) { + if (ob != obact) { con = add_ob_constraint(ob, "AutoTrack", CONSTRAINT_TYPE_DAMPTRACK); data = con->data; data->tar = obact; - ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; + ob->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME; /* Lamp, Camera and Speaker track differently by default */ if (ob->type == OB_LAMP || ob->type == OB_CAMERA || ob->type == OB_SPEAKER) @@ -983,13 +983,13 @@ static int track_set_exec(bContext *C, wmOperator *op) bConstraint *con; bTrackToConstraint *data; - CTX_DATA_BEGIN (C, Object*, ob, selected_editable_objects) { - if (ob!=obact) { + CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) { + if (ob != obact) { con = add_ob_constraint(ob, "AutoTrack", CONSTRAINT_TYPE_TRACKTO); data = con->data; data->tar = obact; - ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; + ob->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME; /* Lamp, Camera and Speaker track differently by default */ if (ob->type == OB_LAMP || ob->type == OB_CAMERA || ob->type == OB_SPEAKER) { @@ -1004,13 +1004,13 @@ static int track_set_exec(bContext *C, wmOperator *op) bConstraint *con; bLockTrackConstraint *data; - CTX_DATA_BEGIN (C, Object*, ob, selected_editable_objects) { - if (ob!=obact) { + CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) { + if (ob != obact) { con = add_ob_constraint(ob, "AutoTrack", CONSTRAINT_TYPE_LOCKTRACK); data = con->data; data->tar = obact; - ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; + ob->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME; /* Lamp, Camera and Speaker track differently by default */ if (ob->type == OB_LAMP || ob->type == OB_CAMERA || ob->type == OB_SPEAKER) { @@ -1024,7 +1024,7 @@ static int track_set_exec(bContext *C, wmOperator *op) DAG_scene_sort(bmain, scene); DAG_ids_flush_update(bmain, 0); - WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); return OPERATOR_FINISHED; } @@ -1043,7 +1043,7 @@ void OBJECT_OT_track_set(wmOperatorType *ot) ot->poll = ED_operator_objectmode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ ot->prop = RNA_def_enum(ot->srna, "type", prop_make_track_types, 0, "Type", ""); @@ -1054,24 +1054,24 @@ void OBJECT_OT_track_set(wmOperatorType *ot) static unsigned int move_to_layer_init(bContext *C, wmOperator *op) { int values[20], a; - unsigned int lay= 0; + unsigned int lay = 0; 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) { + CTX_DATA_BEGIN (C, Base *, base, selected_bases) { lay |= base->lay; } CTX_DATA_END; - for (a=0; a<20; a++) - values[a]= (lay & (1<ptr, "layers", values); } else { RNA_boolean_get_array(op->ptr, "layers", values); - for (a=0; a<20; a++) + for (a = 0; a < 20; a++) if (values[a]) lay |= (1 << a); } @@ -1081,7 +1081,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); + View3D *v3d = CTX_wm_view3d(C); if (v3d && v3d->localvd) { return WM_operator_confirm_message(C, op, "Move from localview"); } @@ -1093,24 +1093,24 @@ static int move_to_layer_invoke(bContext *C, wmOperator *op, wmEvent *event) static int move_to_layer_exec(bContext *C, wmOperator *op) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); - View3D *v3d= CTX_wm_view3d(C); + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + View3D *v3d = CTX_wm_view3d(C); unsigned int lay, local; /* int islamp= 0; */ /* UNUSED */ - lay= move_to_layer_init(C, 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) { /* 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) { - lay= base->lay & ~v3d->lay; - base->lay= lay; - base->object->lay= lay; + CTX_DATA_BEGIN (C, Base *, base, selected_bases) { + lay = base->lay & ~v3d->lay; + base->lay = lay; + base->object->lay = lay; base->object->flag &= ~SELECT; base->flag &= ~SELECT; /* if (base->object->type==OB_LAMP) islamp= 1; */ @@ -1120,11 +1120,11 @@ static int move_to_layer_exec(bContext *C, wmOperator *op) else { /* normal non localview operation */ /* note: layers are set in bases, library objects work for this */ - CTX_DATA_BEGIN (C, Base*, base, selected_bases) { + CTX_DATA_BEGIN (C, Base *, base, selected_bases) { /* upper byte is used for local view */ - local= base->lay & 0xFF000000; - base->lay= lay + local; - base->object->lay= lay; + local = base->lay & 0xFF000000; + base->lay = lay + local; + base->object->lay = lay; /* if (base->object->type==OB_LAMP) islamp= 1; */ } CTX_DATA_END; @@ -1132,8 +1132,8 @@ static int move_to_layer_exec(bContext *C, wmOperator *op) /* warning, active object may be hidden now */ - WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, scene); - WM_event_add_notifier(C, NC_SCENE|ND_LAYER_CONTENT, scene); + WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, scene); + WM_event_add_notifier(C, NC_SCENE | ND_LAYER_CONTENT, scene); DAG_scene_sort(bmain, scene); @@ -1153,7 +1153,7 @@ void OBJECT_OT_move_to_layer(wmOperatorType *ot) ot->poll = ED_operator_objectmode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_boolean_layer_member(ot->srna, "layers", 20, NULL, "Layer", ""); @@ -1164,18 +1164,18 @@ void OBJECT_OT_move_to_layer(wmOperatorType *ot) #if 0 static void link_to_scene(Main *UNUSED(bmain), unsigned short UNUSED(nr)) { - Scene *sce= (Scene*) BLI_findlink(&bmain->scene, G.curscreen->scenenr-1); + Scene *sce = (Scene *) BLI_findlink(&bmain->scene, G.curscreen->scenenr - 1); Base *base, *nbase; - if (sce==0) return; + if (sce == 0) return; if (sce->id.lib) return; - for (base= FIRSTBASE; base; base= base->next) { + for (base = FIRSTBASE; base; base = base->next) { if (TESTBASE(v3d, base)) { - nbase= MEM_mallocN( sizeof(Base), "newbase"); - *nbase= *base; - BLI_addhead( &(sce->base), nbase); + nbase = MEM_mallocN(sizeof(Base), "newbase"); + *nbase = *base; + BLI_addhead(&(sce->base), nbase); id_us_plus((ID *)base->object); } } @@ -1184,10 +1184,10 @@ static void link_to_scene(Main *UNUSED(bmain), unsigned short UNUSED(nr)) 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")); + 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; } @@ -1202,11 +1202,11 @@ static int make_links_scene_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - CTX_DATA_BEGIN (C, Base*, base, selected_bases) { + CTX_DATA_BEGIN (C, Base *, base, selected_bases) { if (!object_in_scene(base->object, scene_to)) { - Base *nbase= MEM_mallocN( sizeof(Base), "newbase"); - *nbase= *base; - BLI_addhead( &(scene_to->base), nbase); + Base *nbase = MEM_mallocN(sizeof(Base), "newbase"); + *nbase = *base; + BLI_addhead(&(scene_to->base), nbase); id_us_plus((ID *)base->object); } } @@ -1236,7 +1236,7 @@ static int allow_make_links_data(int ev, Object *ob, Object *obt) break; case MAKE_LINKS_MATERIALS: if (OB_TYPE_SUPPORT_MATERIAL(ob->type) && - OB_TYPE_SUPPORT_MATERIAL(obt->type)) + OB_TYPE_SUPPORT_MATERIAL(obt->type)) { return 1; } @@ -1254,53 +1254,53 @@ static int allow_make_links_data(int ev, Object *ob, Object *obt) static int make_links_data_exec(bContext *C, wmOperator *op) { - Main *bmain= CTX_data_main(C); + Main *bmain = CTX_data_main(C); int event = RNA_enum_get(op->ptr, "type"); Object *ob; ID *id; int a; - ob= ED_object_active_context(C); + ob = ED_object_active_context(C); - CTX_DATA_BEGIN (C, Object*, obt, selected_editable_objects) { + CTX_DATA_BEGIN (C, Object *, obt, selected_editable_objects) { if (ob != obt) { if (allow_make_links_data(event, ob, obt)) { switch (event) { - case MAKE_LINKS_OBDATA: /* obdata */ - id= obt->data; - id->us--; - - id= ob->data; - id_us_plus(id); - obt->data= id; - - /* if amount of material indices changed: */ - test_object_materials(obt->data); - - obt->recalc |= OB_RECALC_DATA; - break; - case MAKE_LINKS_MATERIALS: - /* new approach, using functions from kernel */ - for (a=0; atotcol; a++) { - Material *ma= give_current_material(ob, a+1); - assign_material(obt, ma, a+1); /* also works with ma==NULL */ - } - break; - case MAKE_LINKS_ANIMDATA: - BKE_copy_animdata_id((ID *)obt, (ID *)ob, FALSE); - BKE_copy_animdata_id((ID *)obt->data, (ID *)ob->data, FALSE); - break; - case MAKE_LINKS_DUPLIGROUP: - obt->dup_group= ob->dup_group; - if (obt->dup_group) { - id_lib_extern(&obt->dup_group->id); - obt->transflag |= OB_DUPLIGROUP; - } - break; - case MAKE_LINKS_MODIFIERS: - object_link_modifiers(obt, ob); - obt->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; - break; + case MAKE_LINKS_OBDATA: /* obdata */ + id = obt->data; + id->us--; + + id = ob->data; + id_us_plus(id); + obt->data = id; + + /* if amount of material indices changed: */ + test_object_materials(obt->data); + + obt->recalc |= OB_RECALC_DATA; + break; + case MAKE_LINKS_MATERIALS: + /* new approach, using functions from kernel */ + 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 */ + } + break; + case MAKE_LINKS_ANIMDATA: + BKE_copy_animdata_id((ID *)obt, (ID *)ob, FALSE); + BKE_copy_animdata_id((ID *)obt->data, (ID *)ob->data, FALSE); + break; + case MAKE_LINKS_DUPLIGROUP: + obt->dup_group = ob->dup_group; + if (obt->dup_group) { + id_lib_extern(&obt->dup_group->id); + obt->transflag |= OB_DUPLIGROUP; + } + break; + case MAKE_LINKS_MODIFIERS: + object_link_modifiers(obt, ob); + obt->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME; + break; } } } @@ -1310,7 +1310,7 @@ static int make_links_data_exec(bContext *C, wmOperator *op) DAG_scene_sort(bmain, CTX_data_scene(C)); DAG_ids_flush_update(bmain, 0); - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, CTX_wm_view3d(C)); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, CTX_wm_view3d(C)); return OPERATOR_FINISHED; } @@ -1330,22 +1330,22 @@ void OBJECT_OT_make_links_scene(wmOperatorType *ot) /* better not run the poll check */ /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ - prop= RNA_def_enum(ot->srna, "scene", DummyRNA_NULL_items, 0, "Scene", ""); + prop = RNA_def_enum(ot->srna, "scene", DummyRNA_NULL_items, 0, "Scene", ""); RNA_def_enum_funcs(prop, RNA_scene_local_itemf); ot->prop = prop; } void OBJECT_OT_make_links_data(wmOperatorType *ot) { - static EnumPropertyItem make_links_items[]= { - {MAKE_LINKS_OBDATA, "OBDATA", 0, "Object Data", ""}, - {MAKE_LINKS_MATERIALS, "MATERIAL", 0, "Materials", ""}, - {MAKE_LINKS_ANIMDATA, "ANIMATION", 0, "Animation Data", ""}, - {MAKE_LINKS_DUPLIGROUP, "DUPLIGROUP", 0, "DupliGroup", ""}, - {MAKE_LINKS_MODIFIERS, "MODIFIERS", 0, "Modifiers", ""}, + static EnumPropertyItem make_links_items[] = { + {MAKE_LINKS_OBDATA, "OBDATA", 0, "Object Data", ""}, + {MAKE_LINKS_MATERIALS, "MATERIAL", 0, "Materials", ""}, + {MAKE_LINKS_ANIMDATA, "ANIMATION", 0, "Animation Data", ""}, + {MAKE_LINKS_DUPLIGROUP, "DUPLIGROUP", 0, "DupliGroup", ""}, + {MAKE_LINKS_MODIFIERS, "MODIFIERS", 0, "Modifiers", ""}, {0, NULL, 0, NULL, NULL}}; /* identifiers */ @@ -1358,7 +1358,7 @@ void OBJECT_OT_make_links_data(wmOperatorType *ot) ot->poll = ED_operator_object_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ ot->prop = RNA_def_enum(ot->srna, "type", make_links_items, 0, "Type", ""); @@ -1372,22 +1372,22 @@ static void single_object_users(Scene *scene, View3D *v3d, int flag) Base *base; Object *ob, *obn; - clear_sca_new_poins(); /* sensor/contr/act */ + clear_sca_new_poins(); /* sensor/contr/act */ /* duplicate (must set newid) */ - for (base= FIRSTBASE; base; base= base->next) { - ob= base->object; + for (base = FIRSTBASE; base; base = base->next) { + ob = base->object; /* newid may still have some trash from Outliner tree building, * so clear that first to avoid errors [#26002] */ 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; + obn = copy_object(ob); + base->object = obn; ob->id.us--; } } @@ -1397,7 +1397,7 @@ static void single_object_users(Scene *scene, View3D *v3d, int flag) 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); } @@ -1410,9 +1410,9 @@ 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; - else base->flag &= ~OB_DONE; + for (base = FIRSTBASE; base; base = base->next) { + if (base->object == ob) base->flag |= OB_DONE; + else base->flag &= ~OB_DONE; } single_object_users(scene, NULL, OB_DONE); @@ -1423,18 +1423,18 @@ static void new_id_matar(Material **matar, int totcol) ID *id; int a; - for (a=0; alib == NULL) { if (id->newid) { - matar[a]= (Material *)id->newid; + matar[a] = (Material *)id->newid; id_us_plus(id->newid); id->us--; } - else if (id->us>1) { - matar[a]= copy_material(matar[a]); + else if (id->us > 1) { + matar[a] = copy_material(matar[a]); id->us--; - id->newid= (ID *)matar[a]; + id->newid = (ID *)matar[a]; } } } @@ -1451,73 +1451,73 @@ static void single_obdata_users(Main *bmain, Scene *scene, int flag) ID *id; int a; - for (base= FIRSTBASE; base; base= base->next) { - ob= base->object; - if (ob->id.lib==NULL && (base->flag & flag)==flag ) { - id= ob->data; + for (base = FIRSTBASE; base; base = base->next) { + ob = base->object; + if (ob->id.lib == NULL && (base->flag & flag) == flag) { + id = ob->data; - if (id && id->us>1 && id->lib==NULL) { - ob->recalc= OB_RECALC_DATA; + if (id && id->us > 1 && id->lib == NULL) { + ob->recalc = OB_RECALC_DATA; BKE_copy_animdata_id_action(id); switch (ob->type) { - case OB_LAMP: - ob->data= la= copy_lamp(ob->data); - for (a=0; amtex[a]) { - ID_NEW(la->mtex[a]->object); + case OB_LAMP: + ob->data = la = copy_lamp(ob->data); + for (a = 0; a < MAX_MTEX; a++) { + if (la->mtex[a]) { + ID_NEW(la->mtex[a]->object); + } } - } - break; - case OB_CAMERA: - ob->data= copy_camera(ob->data); - break; - case OB_MESH: - ob->data= copy_mesh(ob->data); - //me= ob->data; - //if (me && me->key) - // ipo_idnew(me->key->ipo); /* drivers */ - break; - case OB_MBALL: - ob->data= copy_mball(ob->data); - break; - case OB_CURVE: - case OB_SURF: - case OB_FONT: - ob->data= cu= copy_curve(ob->data); - ID_NEW(cu->bevobj); - ID_NEW(cu->taperobj); - break; - case OB_LATTICE: - ob->data= copy_lattice(ob->data); - break; - case OB_ARMATURE: - ob->recalc |= OB_RECALC_DATA; - ob->data= copy_armature(ob->data); - armature_rebuild_pose(ob, ob->data); - break; - case OB_SPEAKER: - ob->data= copy_speaker(ob->data); - break; - default: - if (G.debug & G_DEBUG) - printf("ERROR %s: can't copy %s\n", __func__, id->name); - return; + break; + case OB_CAMERA: + ob->data = copy_camera(ob->data); + break; + case OB_MESH: + ob->data = copy_mesh(ob->data); + //me= ob->data; + //if (me && me->key) + // ipo_idnew(me->key->ipo); /* drivers */ + break; + case OB_MBALL: + ob->data = copy_mball(ob->data); + break; + case OB_CURVE: + case OB_SURF: + case OB_FONT: + ob->data = cu = copy_curve(ob->data); + ID_NEW(cu->bevobj); + ID_NEW(cu->taperobj); + break; + case OB_LATTICE: + ob->data = copy_lattice(ob->data); + break; + case OB_ARMATURE: + ob->recalc |= OB_RECALC_DATA; + ob->data = copy_armature(ob->data); + armature_rebuild_pose(ob, ob->data); + break; + case OB_SPEAKER: + ob->data = copy_speaker(ob->data); + break; + default: + if (G.debug & G_DEBUG) + printf("ERROR %s: can't copy %s\n", __func__, id->name); + return; } id->us--; - id->newid= ob->data; + id->newid = ob->data; } } } - me= bmain->mesh.first; + me = bmain->mesh.first; while (me) { ID_NEW(me->texcomesh); - me= me->id.next; + me = me->id.next; } } @@ -1526,10 +1526,10 @@ static void single_object_action_users(Scene *scene, int flag) Object *ob; Base *base; - for (base= FIRSTBASE; base; base= base->next) { - ob= base->object; - if (ob->id.lib==NULL && (flag==0 || (base->flag & SELECT)) ) { - ob->recalc= OB_RECALC_DATA; + for (base = FIRSTBASE; base; base = base->next) { + ob = base->object; + if (ob->id.lib == NULL && (flag == 0 || (base->flag & SELECT)) ) { + ob->recalc = OB_RECALC_DATA; BKE_copy_animdata_id_action(&ob->id); } } @@ -1543,30 +1543,30 @@ static void single_mat_users(Scene *scene, int flag, int do_textures) Tex *tex; int a, b; - for (base= FIRSTBASE; base; base= base->next) { - ob= base->object; - if (ob->id.lib==NULL && (flag==0 || (base->flag & SELECT)) ) { + for (base = FIRSTBASE; base; base = base->next) { + ob = base->object; + if (ob->id.lib == NULL && (flag == 0 || (base->flag & SELECT)) ) { - for (a=1; a<=ob->totcol; a++) { - ma= give_current_material(ob, a); + for (a = 1; a <= ob->totcol; a++) { + ma = give_current_material(ob, a); if (ma) { /* do not test for LIB_NEW: this functions guaranteed delivers single_users! */ - if (ma->id.us>1) { - man= copy_material(ma); + if (ma->id.us > 1) { + man = copy_material(ma); BKE_copy_animdata_id_action(&man->id); - man->id.us= 0; + man->id.us = 0; assign_material(ob, man, a); if (do_textures) { - for (b=0; bmtex[b] && (tex= ma->mtex[b]->tex)) { - if (tex->id.us>1) { + 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); + tex = copy_texture(tex); BKE_copy_animdata_id_action(&tex->id); - man->mtex[b]->tex= tex; + man->mtex[b]->tex = tex; } } } @@ -1582,20 +1582,20 @@ static void do_single_tex_user(Tex **from) { Tex *tex, *texn; - tex= *from; - if (tex==NULL) return; + tex = *from; + if (tex == NULL) return; if (tex->id.newid) { - *from= (Tex *)tex->id.newid; + *from = (Tex *)tex->id.newid; id_us_plus(tex->id.newid); tex->id.us--; } - else if (tex->id.us>1) { - texn= copy_texture(tex); + else if (tex->id.us > 1) { + texn = copy_texture(tex); BKE_copy_animdata_id_action(&texn->id); - tex->id.newid= (ID *)texn; + tex->id.newid = (ID *)texn; tex->id.us--; - *from= texn; + *from = texn; } } @@ -1607,31 +1607,31 @@ static void single_tex_users_expand(Main *bmain) World *wo; int b; - for (ma= bmain->mat.first; ma; ma=ma->id.next) { + for (ma = bmain->mat.first; ma; ma = ma->id.next) { if (ma->id.flag & LIB_NEW) { - for (b=0; bmtex[b] && ma->mtex[b]->tex) { - do_single_tex_user( &(ma->mtex[b]->tex) ); + do_single_tex_user(&(ma->mtex[b]->tex) ); } } } } - for (la= bmain->lamp.first; la; la=la->id.next) { + for (la = bmain->lamp.first; la; la = la->id.next) { if (la->id.flag & LIB_NEW) { - for (b=0; bmtex[b] && la->mtex[b]->tex) { - do_single_tex_user( &(la->mtex[b]->tex) ); + do_single_tex_user(&(la->mtex[b]->tex) ); } } } } - for (wo= bmain->world.first; wo; wo=wo->id.next) { + for (wo = bmain->world.first; wo; wo = wo->id.next) { if (wo->id.flag & LIB_NEW) { - for (b=0; bmtex[b] && wo->mtex[b]->tex) { - do_single_tex_user( &(wo->mtex[b]->tex) ); + do_single_tex_user(&(wo->mtex[b]->tex) ); } } } @@ -1648,26 +1648,26 @@ static void single_mat_users_expand(Main *bmain) Material *ma; int a; - for (ob=bmain->object.first; ob; ob=ob->id.next) + 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) + 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) + 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) + 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) + for (ma = bmain->mat.first; ma; ma = ma->id.next) if (ma->id.flag & LIB_NEW) - for (a=0; amtex[a]) ID_NEW(ma->mtex[a]->object); } @@ -1697,11 +1697,11 @@ static void make_local_makelocalmaterial(Material *ma) id_make_local(&ma->id, 0); - for (b=0; bmtex[b] && ma->mtex[b]->tex) id_make_local(&ma->mtex[b]->tex->id, 0); - adt= BKE_animdata_from_id(&ma->id); + adt = BKE_animdata_from_id(&ma->id); if (adt) BKE_animdata_make_local(adt); /* nodetree? XXX */ @@ -1709,83 +1709,83 @@ static void make_local_makelocalmaterial(Material *ma) static int make_local_exec(bContext *C, wmOperator *op) { - Main *bmain= CTX_data_main(C); + Main *bmain = CTX_data_main(C); AnimData *adt; ParticleSystem *psys; Material *ma, ***matarar; Lamp *la; ID *id; - int a, b, mode= RNA_enum_get(op->ptr, "type"); + int a, b, mode = RNA_enum_get(op->ptr, "type"); - if (mode==3) { - BKE_library_make_local(bmain, NULL, 0); /* NULL is all libs */ + 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; } clear_id_newpoins(); - CTX_DATA_BEGIN (C, Object*, ob, selected_objects) { + CTX_DATA_BEGIN (C, Object *, ob, selected_objects) { 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) { + CTX_DATA_BEGIN (C, Object *, ob, selected_objects) { + if (ob->id.lib == NULL) { ID_NEW(ob->parent); } } CTX_DATA_END; - CTX_DATA_BEGIN (C, Object*, ob, selected_objects) { - id= ob->data; + 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); + adt = BKE_animdata_from_id(id); if (adt) BKE_animdata_make_local(adt); /* tag indirect data direct */ - matarar= (Material ***)give_matarar(ob); + matarar = (Material ***)give_matarar(ob); if (matarar) { - for (a=0; atotcol; a++) { - ma= (*matarar)[a]; + for (a = 0; a < ob->totcol; a++) { + ma = (*matarar)[a]; 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); + adt = BKE_animdata_from_id(&ob->id); if (adt) BKE_animdata_make_local(adt); } CTX_DATA_END; - if (mode>1) { - CTX_DATA_BEGIN (C, Object*, ob, selected_objects) { - if (ob->type==OB_LAMP) { - la= ob->data; + if (mode > 1) { + CTX_DATA_BEGIN (C, Object *, ob, selected_objects) { + if (ob->type == OB_LAMP) { + la = ob->data; - for (b=0; bmtex[b] && la->mtex[b]->tex) id_make_local(&la->mtex[b]->tex->id, 0); } else { - for (a=0; atotcol; a++) { - ma= ob->mat[a]; + for (a = 0; a < ob->totcol; a++) { + ma = ob->mat[a]; if (ma) make_local_makelocalmaterial(ma); } - matarar= (Material ***)give_matarar(ob); + matarar = (Material ***)give_matarar(ob); if (matarar) { - for (a=0; atotcol; a++) { - ma= (*matarar)[a]; + for (a = 0; a < ob->totcol; a++) { + ma = (*matarar)[a]; if (ma) make_local_makelocalmaterial(ma); } @@ -1802,7 +1802,7 @@ static int make_local_exec(bContext *C, wmOperator *op) void OBJECT_OT_make_local(wmOperatorType *ot) { - static EnumPropertyItem type_items[]= { + static EnumPropertyItem type_items[] = { {1, "SELECTED_OBJECTS", 0, "Selected Objects", ""}, {2, "SELECTED_OBJECTS_DATA", 0, "Selected Objects and Data", ""}, {3, "ALL", 0, "All", ""}, @@ -1819,7 +1819,7 @@ void OBJECT_OT_make_local(wmOperatorType *ot) ot->poll = ED_operator_objectmode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ ot->prop = RNA_def_enum(ot->srna, "type", type_items, 0, "Type", ""); @@ -1827,10 +1827,10 @@ void OBJECT_OT_make_local(wmOperatorType *ot) static int make_single_user_exec(bContext *C, wmOperator *op) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); - View3D *v3d= CTX_wm_view3d(C); /* ok if this is NULL */ - int flag= RNA_enum_get(op->ptr, "type"); /* 0==ALL, SELECTED==selected objecs */ + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + 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")) single_object_users(scene, v3d, flag); @@ -1856,7 +1856,7 @@ static int make_single_user_exec(bContext *C, wmOperator *op) void OBJECT_OT_make_single_user(wmOperatorType *ot) { - static EnumPropertyItem type_items[]= { + static EnumPropertyItem type_items[] = { {SELECT, "SELECTED_OBJECTS", 0, "Selected Objects", ""}, {0, "ALL", 0, "All", ""}, {0, NULL, 0, NULL, NULL}}; @@ -1872,7 +1872,7 @@ void OBJECT_OT_make_single_user(wmOperatorType *ot) ot->poll = ED_operator_objectmode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ ot->prop = RNA_def_enum(ot->srna, "type", type_items, SELECT, "Type", ""); @@ -1886,20 +1886,20 @@ void OBJECT_OT_make_single_user(wmOperatorType *ot) static int drop_named_material_invoke(bContext *C, wmOperator *op, wmEvent *event) { - Main *bmain= CTX_data_main(C); - Base *base= ED_view3d_give_base_under_cursor(C, event->mval); + Main *bmain = CTX_data_main(C); + Base *base = ED_view3d_give_base_under_cursor(C, event->mval); Material *ma; - char name[MAX_ID_NAME-2]; + char name[MAX_ID_NAME - 2]; RNA_string_get(op->ptr, "name", name); - ma= (Material *)find_id("MA", name); - if (base==NULL || ma==NULL) + ma = (Material *)find_id("MA", name); + if (base == NULL || ma == NULL) return OPERATOR_CANCELLED; assign_material(base->object, ma, 1); DAG_ids_flush_update(bmain, 0); - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, CTX_wm_view3d(C)); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, CTX_wm_view3d(C)); return OPERATOR_FINISHED; } @@ -1922,5 +1922,5 @@ void OBJECT_OT_drop_named_material(wmOperatorType *ot) ot->flag = OPTYPE_UNDO; /* properties */ - RNA_def_string(ot->srna, "name", "Material", MAX_ID_NAME-2, "Name", "Material name to assign"); + RNA_def_string(ot->srna, "name", "Material", MAX_ID_NAME - 2, "Name", "Material name to assign"); } diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c index 386541c5262..7a4db175ee4 100644 --- a/source/blender/editors/object/object_select.c +++ b/source/blender/editors/object/object_select.c @@ -79,8 +79,8 @@ /************************ Exported **************************/ /* simple API for object selection, rather than just using the flag - * this takes into account the 'restrict selection in 3d view' flag. - * deselect works always, the restriction just prevents selection */ +* this takes into account the 'restrict selection in 3d view' flag. +* deselect works always, the restriction just prevents selection */ /* Note: send a NC_SCENE|ND_OB_SELECT notifier yourself! (or * or a NC_SCENE|ND_OB_VISIBLE in case of visibility toggling */ @@ -88,34 +88,34 @@ void ED_base_object_select(Base *base, short mode) { if (base) { - if (mode==BA_SELECT) { + if (mode == BA_SELECT) { if (!(base->object->restrictflag & OB_RESTRICT_SELECT)) base->flag |= SELECT; } - else if (mode==BA_DESELECT) { + else if (mode == BA_DESELECT) { base->flag &= ~SELECT; } - base->object->flag= base->flag; + base->object->flag = base->flag; } } /* also to set active NULL */ void ED_base_object_activate(bContext *C, Base *base) { - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); /* sets scene->basact */ - BASACT= base; + BASACT = base; if (base) { /* XXX old signals, remember to handle notifiers now! */ // select_actionchannel_by_name(base->object->action, "Object", 1); - WM_event_add_notifier(C, NC_SCENE|ND_OB_ACTIVE, scene); + WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene); } else - WM_event_add_notifier(C, NC_SCENE|ND_OB_ACTIVE, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, NULL); } /********************** Selection Operators **********************/ @@ -124,7 +124,7 @@ static int objects_selectable_poll(bContext *C) { /* we don't check for linked scenes here, selection is * still allowed then for inspection of scene */ - Object *obact= CTX_data_active_object(C); + Object *obact = CTX_data_active_object(C); if (CTX_data_edit_object(C)) return 0; @@ -141,23 +141,23 @@ static int object_select_by_type_exec(bContext *C, wmOperator *op) short obtype, extend; obtype = RNA_enum_get(op->ptr, "type"); - extend= RNA_boolean_get(op->ptr, "extend"); + extend = RNA_boolean_get(op->ptr, "extend"); if (extend == 0) { - CTX_DATA_BEGIN (C, Base*, base, visible_bases) { + CTX_DATA_BEGIN (C, Base *, base, visible_bases) { ED_base_object_select(base, BA_DESELECT); } CTX_DATA_END; } - CTX_DATA_BEGIN (C, Base*, base, visible_bases) { - if (base->object->type==obtype) { + CTX_DATA_BEGIN (C, Base *, base, visible_bases) { + if (base->object->type == obtype) { ED_base_object_select(base, BA_SELECT); } } CTX_DATA_END; - WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, CTX_data_scene(C)); + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, CTX_data_scene(C)); return OPERATOR_FINISHED; } @@ -175,7 +175,7 @@ void OBJECT_OT_select_by_type(wmOperatorType *ot) ot->poll = objects_selectable_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_boolean(ot->srna, "extend", FALSE, "Extend", "Extend selection instead of deselecting everything first"); @@ -198,11 +198,11 @@ static EnumPropertyItem prop_select_linked_types[] = { static int object_select_linked_exec(bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); Object *ob; void *obdata = NULL; Material *mat = NULL, *mat1; - Tex *tex= NULL; + Tex *tex = NULL; int a, b; int nr = RNA_enum_get(op->ptr, "type"); short changed = 0, extend; @@ -215,77 +215,77 @@ static int object_select_linked_exec(bContext *C, wmOperator *op) * PSys: 6 */ - extend= RNA_boolean_get(op->ptr, "extend"); + extend = RNA_boolean_get(op->ptr, "extend"); if (extend == 0) { - CTX_DATA_BEGIN (C, Base*, base, visible_bases) { + CTX_DATA_BEGIN (C, Base *, base, visible_bases) { ED_base_object_select(base, BA_DESELECT); } CTX_DATA_END; } - ob= OBACT; - if (ob==NULL) { + ob = OBACT; + if (ob == NULL) { BKE_report(op->reports, RPT_ERROR, "No Active Object"); return OPERATOR_CANCELLED; } - if (nr==1) { - // XXX old animation system + 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; - obdata= ob->data; + else if (nr == 2) { + if (ob->data == NULL) return OPERATOR_CANCELLED; + obdata = ob->data; } - 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; + 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; } } - 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) { - // XXX old animation system + CTX_DATA_BEGIN (C, Base *, base, visible_bases) { + 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) { - ob= base->object; + else if (nr == 3 || nr == 4) { + ob = base->object; - for (a=1; a<=ob->totcol; a++) { - mat1= give_current_material(ob, a); - if (nr==3) { - if (mat1==mat) base->flag |= SELECT; + for (a = 1; a <= ob->totcol; a++) { + mat1 = give_current_material(ob, a); + if (nr == 3) { + if (mat1 == mat) base->flag |= SELECT; changed = 1; } - else if (mat1 && nr==4) { - for (b=0; bmtex[b]) { - if (tex==mat1->mtex[b]->tex) { + 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,24 +320,24 @@ static int object_select_linked_exec(bContext *C, wmOperator *op) } } } - else if (nr==7) { + else if (nr == 7) { if (ob->id.lib == base->object->id.lib) { base->flag |= SELECT; - changed= 1; + changed = 1; } } - else if (nr==8) { + else if (nr == 8) { if (base->object->data && ((ID *)ob->data)->lib == ((ID *)base->object->data)->lib) { base->flag |= SELECT; - changed= 1; + changed = 1; } } - base->object->flag= base->flag; + base->object->flag = base->flag; } CTX_DATA_END; if (changed) { - WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, CTX_data_scene(C)); + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, CTX_data_scene(C)); return OPERATOR_FINISHED; } @@ -357,7 +357,7 @@ void OBJECT_OT_select_linked(wmOperatorType *ot) ot->poll = objects_selectable_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_boolean(ot->srna, "extend", FALSE, "Extend", "Extend selection instead of deselecting everything first"); @@ -386,7 +386,7 @@ static short select_grouped_children(bContext *C, Object *ob, int recursive) { short changed = 0; - CTX_DATA_BEGIN (C, Base*, base, selectable_bases) { + CTX_DATA_BEGIN (C, Base *, base, selectable_bases) { if (ob == base->object->parent) { if (!(base->flag & SELECT)) { ED_base_object_select(base, BA_SELECT); @@ -401,17 +401,17 @@ static short select_grouped_children(bContext *C, Object *ob, int recursive) return changed; } -static short select_grouped_parent(bContext *C) /* Makes parent active and de-selected OBACT */ +static short select_grouped_parent(bContext *C) /* Makes parent active and de-selected OBACT */ { - Scene *scene= CTX_data_scene(C); - View3D *v3d= CTX_wm_view3d(C); + Scene *scene = CTX_data_scene(C); + View3D *v3d = CTX_wm_view3d(C); short changed = 0; - Base *baspar, *basact= CTX_data_active_base(C); + Base *baspar, *basact = CTX_data_active_base(C); - if (!basact || !(basact->object->parent)) return 0; /* we know OBACT is valid */ + if (!basact || !(basact->object->parent)) return 0; /* we know OBACT is valid */ - baspar= object_in_scene(basact->object->parent, scene); + baspar = object_in_scene(basact->object->parent, scene); /* can be NULL if parent in other scene */ if (baspar && BASE_SELECTABLE(v3d, baspar)) { @@ -424,17 +424,17 @@ static short select_grouped_parent(bContext *C) /* Makes parent active and de-se } -#define GROUP_MENU_MAX 24 -static short select_grouped_group(bContext *C, Object *ob) /* Select objects in the same group as the active */ +#define GROUP_MENU_MAX 24 +static short select_grouped_group(bContext *C, Object *ob) /* Select objects in the same group as the active */ { short changed = 0; Group *group, *ob_groups[GROUP_MENU_MAX]; - int group_count=0, i; + int group_count = 0, i; uiPopupMenu *pup; uiLayout *layout; - for (group=CTX_data_main(C)->group.first; group && group_count < GROUP_MENU_MAX; group=group->id.next) { - if (object_in_group (ob, group)) { + for (group = CTX_data_main(C)->group.first; group && group_count < GROUP_MENU_MAX; group = group->id.next) { + if (object_in_group(ob, group)) { ob_groups[group_count] = group; group_count++; } @@ -444,7 +444,7 @@ static short select_grouped_group(bContext *C, Object *ob) /* Select objects in return 0; else if (group_count == 1) { group = ob_groups[0]; - CTX_DATA_BEGIN (C, Base*, base, visible_bases) { + CTX_DATA_BEGIN (C, Base *, base, visible_bases) { if (!(base->flag & SELECT) && object_in_group(base->object, group)) { ED_base_object_select(base, BA_SELECT); changed = 1; @@ -455,12 +455,12 @@ static short select_grouped_group(bContext *C, Object *ob) /* Select objects in } /* build the menu. */ - pup= uiPupMenuBegin(C, "Select Group", ICON_NONE); - layout= uiPupMenuLayout(pup); + pup = uiPupMenuBegin(C, "Select Group", ICON_NONE); + layout = uiPupMenuLayout(pup); - for (i=0; iid.name+2, 0, "OBJECT_OT_select_same_group", "group", group->id.name); + uiItemStringO(layout, group->id.name + 2, 0, "OBJECT_OT_select_same_group", "group", group->id.name); } uiPupMenuEnd(C, pup); @@ -469,19 +469,19 @@ static short select_grouped_group(bContext *C, Object *ob) /* Select objects in static short select_grouped_object_hooks(bContext *C, Object *ob) { - Scene *scene= CTX_data_scene(C); - View3D *v3d= CTX_wm_view3d(C); + Scene *scene = CTX_data_scene(C); + View3D *v3d = CTX_wm_view3d(C); short changed = 0; Base *base; ModifierData *md; HookModifierData *hmd; - for (md = ob->modifiers.first; md; md=md->next) { - if (md->type==eModifierType_Hook) { - hmd= (HookModifierData*) md; + for (md = ob->modifiers.first; md; md = md->next) { + if (md->type == eModifierType_Hook) { + hmd = (HookModifierData *) md; if (hmd->object && !(hmd->object->flag & SELECT)) { - base= object_in_scene(hmd->object, scene); + base = object_in_scene(hmd->object, scene); if (base && (BASE_SELECTABLE(v3d, base))) { ED_base_object_select(base, BA_SELECT); changed = 1; @@ -498,8 +498,8 @@ static short select_grouped_siblings(bContext *C, Object *ob) { short changed = 0; - CTX_DATA_BEGIN (C, Base*, base, selectable_bases) { - if ((base->object->parent==ob->parent) && !(base->flag & SELECT)) { + CTX_DATA_BEGIN (C, Base *, base, selectable_bases) { + if ((base->object->parent == ob->parent) && !(base->flag & SELECT)) { ED_base_object_select(base, BA_SELECT); changed = 1; } @@ -512,7 +512,7 @@ static short select_grouped_type(bContext *C, Object *ob) { short changed = 0; - CTX_DATA_BEGIN (C, Base*, base, selectable_bases) { + CTX_DATA_BEGIN (C, Base *, base, selectable_bases) { if ((base->object->type == ob->type) && !(base->flag & SELECT)) { ED_base_object_select(base, BA_SELECT); changed = 1; @@ -526,7 +526,7 @@ static short select_grouped_layer(bContext *C, Object *ob) { char changed = 0; - CTX_DATA_BEGIN (C, Base*, base, selectable_bases) { + CTX_DATA_BEGIN (C, Base *, base, selectable_bases) { if ((base->lay & ob->lay) && !(base->flag & SELECT)) { ED_base_object_select(base, BA_SELECT); changed = 1; @@ -540,7 +540,7 @@ static short select_grouped_index_object(bContext *C, Object *ob) { char changed = 0; - CTX_DATA_BEGIN (C, Base*, base, selectable_bases) { + CTX_DATA_BEGIN (C, Base *, base, selectable_bases) { if ((base->object->index == ob->index) && !(base->flag & SELECT)) { ED_base_object_select(base, BA_SELECT); changed = 1; @@ -554,7 +554,7 @@ static short select_grouped_color(bContext *C, Object *ob) { char changed = 0; - CTX_DATA_BEGIN (C, Base*, base, selectable_bases) { + CTX_DATA_BEGIN (C, Base *, base, selectable_bases) { if (!(base->flag & SELECT) && (compare_v3v3(base->object->col, ob->col, 0.005f))) { ED_base_object_select(base, BA_SELECT); changed = 1; @@ -569,8 +569,8 @@ 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 ) { - if ( get_ob_property(b, prop->name) ) + for (prop = a->prop.first; prop; prop = prop->next) { + if (get_ob_property(b, prop->name) ) return 1; } return 0; @@ -580,7 +580,7 @@ static short select_grouped_gameprops(bContext *C, Object *ob) { char changed = 0; - CTX_DATA_BEGIN (C, Base*, base, selectable_bases) { + CTX_DATA_BEGIN (C, Base *, base, selectable_bases) { if (!(base->flag & SELECT) && (objects_share_gameprop(base->object, ob))) { ED_base_object_select(base, BA_SELECT); changed = 1; @@ -602,7 +602,7 @@ static short select_grouped_keyingset(bContext *C, Object *UNUSED(ob)) /* select each object that Keying Set refers to */ // TODO: perhaps to be more in line with the rest of these, we should only take objects // if the passed in object is included in this too - CTX_DATA_BEGIN (C, Base*, base, selectable_bases) { + CTX_DATA_BEGIN (C, Base *, base, selectable_bases) { /* only check for this object if it isn't selected already, to limit time wasted */ if ((base->flag & SELECT) == 0) { KS_Path *ksp; @@ -627,42 +627,42 @@ static short select_grouped_keyingset(bContext *C, Object *UNUSED(ob)) static int object_select_grouped_exec(bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); Object *ob; int nr = RNA_enum_get(op->ptr, "type"); short changed = 0, extend; - extend= RNA_boolean_get(op->ptr, "extend"); + extend = RNA_boolean_get(op->ptr, "extend"); if (extend == 0) { - CTX_DATA_BEGIN (C, Base*, base, visible_bases) { + CTX_DATA_BEGIN (C, Base *, base, visible_bases) { ED_base_object_select(base, BA_DESELECT); changed = 1; } CTX_DATA_END; } - ob= OBACT; - if (ob==NULL) { + ob = OBACT; + 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)); + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, CTX_data_scene(C)); return OPERATOR_FINISHED; } @@ -682,7 +682,7 @@ void OBJECT_OT_select_grouped(wmOperatorType *ot) ot->poll = objects_selectable_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_boolean(ot->srna, "extend", FALSE, "Extend", "Extend selection instead of deselecting everything first"); @@ -696,24 +696,24 @@ static int object_select_by_layer_exec(bContext *C, wmOperator *op) unsigned int layernum; short extend; - extend= RNA_boolean_get(op->ptr, "extend"); + extend = RNA_boolean_get(op->ptr, "extend"); layernum = RNA_int_get(op->ptr, "layers"); if (extend == 0) { - CTX_DATA_BEGIN (C, Base*, base, visible_bases) { + CTX_DATA_BEGIN (C, Base *, base, visible_bases) { ED_base_object_select(base, BA_DESELECT); } CTX_DATA_END; } - CTX_DATA_BEGIN (C, Base*, base, visible_bases) { - if (base->lay == (1<< (layernum -1))) + CTX_DATA_BEGIN (C, Base *, base, visible_bases) { + if (base->lay == (1 << (layernum - 1))) ED_base_object_select(base, BA_SELECT); } CTX_DATA_END; /* undo? */ - WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, CTX_data_scene(C)); + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, CTX_data_scene(C)); return OPERATOR_FINISHED; } @@ -731,7 +731,7 @@ void OBJECT_OT_select_by_layer(wmOperatorType *ot) ot->poll = objects_selectable_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_boolean(ot->srna, "extend", FALSE, "Extend", "Extend selection instead of deselecting everything first"); @@ -749,7 +749,7 @@ static int object_select_all_exec(bContext *C, wmOperator *op) if (action == SEL_TOGGLE) { action = SEL_SELECT; - CTX_DATA_BEGIN (C, Base*, base, visible_bases) { + CTX_DATA_BEGIN (C, Base *, base, visible_bases) { if (base->flag & SELECT) { action = SEL_DESELECT; break; @@ -758,27 +758,27 @@ static int object_select_all_exec(bContext *C, wmOperator *op) CTX_DATA_END; } - CTX_DATA_BEGIN (C, Base*, base, visible_bases) { + CTX_DATA_BEGIN (C, Base *, base, visible_bases) { switch (action) { - case SEL_SELECT: - ED_base_object_select(base, BA_SELECT); - break; - case SEL_DESELECT: - ED_base_object_select(base, BA_DESELECT); - break; - case SEL_INVERT: - if (base->flag & SELECT) { - ED_base_object_select(base, BA_DESELECT); - } - else { + case SEL_SELECT: ED_base_object_select(base, BA_SELECT); - } - break; + break; + case SEL_DESELECT: + ED_base_object_select(base, BA_DESELECT); + break; + case SEL_INVERT: + if (base->flag & SELECT) { + ED_base_object_select(base, BA_DESELECT); + } + else { + ED_base_object_select(base, BA_SELECT); + } + break; } } CTX_DATA_END; - WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, CTX_data_scene(C)); + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, CTX_data_scene(C)); return OPERATOR_FINISHED; } @@ -796,7 +796,7 @@ void OBJECT_OT_select_all(wmOperatorType *ot) ot->poll = objects_selectable_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; WM_operator_properties_select_all(ot); } @@ -813,7 +813,7 @@ static int object_select_same_group_exec(bContext *C, wmOperator *op) RNA_string_get(op->ptr, "group", group_name); - for (group=CTX_data_main(C)->group.first; group; group=group->id.next) { + for (group = CTX_data_main(C)->group.first; group; group = group->id.next) { if (!strcmp(group->id.name, group_name)) break; } @@ -821,13 +821,13 @@ static int object_select_same_group_exec(bContext *C, wmOperator *op) if (!group) return OPERATOR_PASS_THROUGH; - CTX_DATA_BEGIN (C, Base*, base, visible_bases) { + CTX_DATA_BEGIN (C, Base *, base, visible_bases) { if (!(base->flag & SELECT) && object_in_group(base->object, group)) ED_base_object_select(base, BA_SELECT); } CTX_DATA_END; - WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, CTX_data_scene(C)); + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, CTX_data_scene(C)); return OPERATOR_FINISHED; } @@ -845,7 +845,7 @@ void OBJECT_OT_select_same_group(wmOperatorType *ot) ot->poll = objects_selectable_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_string(ot->srna, "group", "", MAX_ID_NAME, "Group", "Name of the group to select"); } @@ -853,20 +853,20 @@ void OBJECT_OT_select_same_group(wmOperatorType *ot) /**************************** Select Mirror ****************************/ static int object_select_mirror_exec(bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); short extend; - extend= RNA_boolean_get(op->ptr, "extend"); + extend = RNA_boolean_get(op->ptr, "extend"); - CTX_DATA_BEGIN (C, Base*, primbase, selected_bases) { + CTX_DATA_BEGIN (C, Base *, primbase, selected_bases) { char tmpname[MAXBONENAME]; - flip_side_name(tmpname, primbase->object->id.name+2, TRUE); + flip_side_name(tmpname, primbase->object->id.name + 2, TRUE); - if (strcmp(tmpname, primbase->object->id.name+2)!=0) { /* names differ */ - Object *ob= (Object *)find_id("OB", tmpname); + if (strcmp(tmpname, primbase->object->id.name + 2) != 0) { /* names differ */ + Object *ob = (Object *)find_id("OB", tmpname); if (ob) { - Base *secbase= object_in_scene(ob, scene); + Base *secbase = object_in_scene(ob, scene); if (secbase) { ED_base_object_select(secbase, BA_SELECT); @@ -880,7 +880,7 @@ static int object_select_mirror_exec(bContext *C, wmOperator *op) CTX_DATA_END; /* undo? */ - WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, CTX_data_scene(C)); + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, CTX_data_scene(C)); return OPERATOR_FINISHED; } @@ -898,7 +898,7 @@ void OBJECT_OT_select_mirror(wmOperatorType *ot) ot->poll = objects_selectable_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Extend selection instead of deselecting everything first"); } @@ -911,24 +911,24 @@ static int object_select_random_exec(bContext *C, wmOperator *op) float percent; short extend; - extend= RNA_boolean_get(op->ptr, "extend"); + extend = RNA_boolean_get(op->ptr, "extend"); if (extend == 0) { - CTX_DATA_BEGIN (C, Base*, base, visible_bases) { + CTX_DATA_BEGIN (C, Base *, base, visible_bases) { ED_base_object_select(base, BA_DESELECT); } CTX_DATA_END; } - percent = RNA_float_get(op->ptr, "percent")/100.0f; + percent = RNA_float_get(op->ptr, "percent") / 100.0f; - CTX_DATA_BEGIN (C, Base*, base, visible_bases) { + CTX_DATA_BEGIN (C, Base *, base, visible_bases) { if (BLI_frand() < percent) { ED_base_object_select(base, BA_SELECT); } } CTX_DATA_END; - WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, CTX_data_scene(C)); + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, CTX_data_scene(C)); return OPERATOR_FINISHED; } @@ -946,7 +946,7 @@ void OBJECT_OT_select_random(wmOperatorType *ot) ot->poll = objects_selectable_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_float_percentage(ot->srna, "percent", 50.f, 0.0f, 100.0f, "Percent", "Percentage of objects to select randomly", 0.f, 100.0f); diff --git a/source/blender/editors/object/object_shapekey.c b/source/blender/editors/object/object_shapekey.c index 9e31fc2d765..bd88bbda32c 100644 --- a/source/blender/editors/object/object_shapekey.c +++ b/source/blender/editors/object/object_shapekey.c @@ -78,11 +78,11 @@ static void ED_object_shape_key_add(bContext *C, Scene *scene, Object *ob, int f { KeyBlock *kb; if ((kb = object_insert_shape_key(scene, ob, NULL, from_mix))) { - Key *key= ob_get_key(ob); + Key *key = ob_get_key(ob); /* for absolute shape keys, new keys may not be added last */ ob->shapenr = BLI_findindex(&key->block, kb) + 1; - WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); } } @@ -90,26 +90,26 @@ static void ED_object_shape_key_add(bContext *C, Scene *scene, Object *ob, int f static int ED_object_shape_key_remove(bContext *C, Object *ob) { - Main *bmain= CTX_data_main(C); + Main *bmain = CTX_data_main(C); KeyBlock *kb, *rkb; Key *key; //IpoCurve *icu; - key= ob_get_key(ob); - if (key==NULL) + key = ob_get_key(ob); + if (key == NULL) return 0; - kb= BLI_findlink(&key->block, ob->shapenr-1); + 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) - rkb->relative= 0; + 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) { - key->refkey= key->block.first; + if (key->refkey == kb) { + key->refkey = key->block.first; if (key->refkey) { /* apply new basis key on original data */ @@ -136,16 +136,16 @@ static int ED_object_shape_key_remove(bContext *C, Object *ob) } } - 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); } DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); return 1; } @@ -155,53 +155,53 @@ static int object_shape_key_mirror(bContext *C, Object *ob) KeyBlock *kb; Key *key; - key= ob_get_key(ob); - if (key==NULL) + key = ob_get_key(ob); + if (key == NULL) return 0; - kb= BLI_findlink(&key->block, ob->shapenr-1); + kb = BLI_findlink(&key->block, ob->shapenr - 1); if (kb) { int i1, i2; float *fp1, *fp2; float tvec[3]; - char *tag_elem= MEM_callocN(sizeof(char) * kb->totelem, "shape_key_mirror"); + char *tag_elem = MEM_callocN(sizeof(char) * kb->totelem, "shape_key_mirror"); - if (ob->type==OB_MESH) { - Mesh *me= ob->data; + if (ob->type == OB_MESH) { + Mesh *me = ob->data; MVert *mv; mesh_octree_table(ob, NULL, NULL, 's'); - for (i1=0, mv=me->mvert; i1totvert; i1++, mv++) { - i2= mesh_get_x_mirror_vert(ob, i1); - if (i2==i1) { - fp1= ((float *)kb->data) + i1*3; + for (i1 = 0, mv = me->mvert; i1 < me->totvert; i1++, mv++) { + i2 = mesh_get_x_mirror_vert(ob, i1); + if (i2 == i1) { + fp1 = ((float *)kb->data) + i1 * 3; fp1[0] = -fp1[0]; - tag_elem[i1]= 1; + tag_elem[i1] = 1; } 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; + if (tag_elem[i1] == 0 && tag_elem[i2] == 0) { + fp1 = ((float *)kb->data) + i1 * 3; + fp2 = ((float *)kb->data) + i2 * 3; - copy_v3_v3(tvec, fp1); - copy_v3_v3(fp1, fp2); - copy_v3_v3(fp2, tvec); + copy_v3_v3(tvec, fp1); + copy_v3_v3(fp1, fp2); + copy_v3_v3(fp2, tvec); /* flip x axis */ fp1[0] = -fp1[0]; fp2[0] = -fp2[0]; } - tag_elem[i1]= tag_elem[i2]= 1; + tag_elem[i1] = tag_elem[i2] = 1; } } mesh_octree_table(ob, NULL, NULL, 'e'); } else if (ob->type == OB_LATTICE) { - Lattice *lt= ob->data; + Lattice *lt = ob->data; int i1, i2; float *fp1, *fp2; int u, v, w; @@ -213,28 +213,28 @@ static int object_shape_key_mirror(bContext *C, Object *ob) /* if (lt->editlatt) lt= lt->editlatt->latt; */ - for (w=0; wpntsw; w++) { - for (v=0; vpntsv; v++) { - for (u=0; upntsu - 1) - 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) { - i1= LT_INDEX(lt, u, v, w); - fp1= ((float *)kb->data) + i1*3; - fp1[0]= -fp1[0]; + i1 = LT_INDEX(lt, u, v, w); + fp1 = ((float *)kb->data) + i1 * 3; + fp1[0] = -fp1[0]; } else { - i1= LT_INDEX(lt, u, v, w); - i2= LT_INDEX(lt, u_inv, v, w); + i1 = LT_INDEX(lt, u, v, w); + i2 = LT_INDEX(lt, u_inv, v, w); - fp1= ((float *)kb->data) + i1*3; - fp2= ((float *)kb->data) + i2*3; + fp1 = ((float *)kb->data) + i1 * 3; + fp2 = ((float *)kb->data) + i2 * 3; copy_v3_v3(tvec, fp1); copy_v3_v3(fp1, fp2); copy_v3_v3(fp2, tvec); - fp1[0]= -fp1[0]; - fp2[0]= -fp2[0]; + fp1[0] = -fp1[0]; + fp2[0] = -fp2[0]; } } } @@ -245,7 +245,7 @@ static int object_shape_key_mirror(bContext *C, Object *ob) } DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); return 1; } @@ -254,22 +254,22 @@ static int object_shape_key_mirror(bContext *C, Object *ob) static int shape_key_mode_poll(bContext *C) { - Object *ob= ED_object_context(C); - ID *data= (ob)? ob->data: NULL; + Object *ob = ED_object_context(C); + ID *data = (ob) ? ob->data : NULL; return (ob && !ob->id.lib && data && !data->lib && ob->mode != OB_MODE_EDIT); } static int shape_key_poll(bContext *C) { - Object *ob= ED_object_context(C); - ID *data= (ob)? ob->data: NULL; + Object *ob = ED_object_context(C); + ID *data = (ob) ? ob->data : NULL; return (ob && !ob->id.lib && data && !data->lib); } static int shape_key_add_exec(bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); - Object *ob= ED_object_context(C); + Scene *scene = CTX_data_scene(C); + Object *ob = ED_object_context(C); int from_mix = RNA_boolean_get(op->ptr, "from_mix"); ED_object_shape_key_add(C, scene, ob, from_mix); @@ -289,7 +289,7 @@ void OBJECT_OT_shape_key_add(wmOperatorType *ot) ot->exec = shape_key_add_exec; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_boolean(ot->srna, "from_mix", 1, "From Mix", "Create the new shape key from the existing mix of keys"); @@ -297,7 +297,7 @@ void OBJECT_OT_shape_key_add(wmOperatorType *ot) static int shape_key_remove_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *ob= ED_object_context(C); + Object *ob = ED_object_context(C); if (!ED_object_shape_key_remove(C, ob)) return OPERATOR_CANCELLED; @@ -317,23 +317,23 @@ void OBJECT_OT_shape_key_remove(wmOperatorType *ot) ot->exec = shape_key_remove_exec; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } static int shape_key_clear_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *ob= ED_object_context(C); - Key *key= ob_get_key(ob); - KeyBlock *kb= ob_get_keyblock(ob); + Object *ob = ED_object_context(C); + Key *key = ob_get_key(ob); + KeyBlock *kb = ob_get_keyblock(ob); if (!key || !kb) return OPERATOR_CANCELLED; - for (kb=key->block.first; kb; kb=kb->next) - kb->curval= 0.0f; + for (kb = key->block.first; kb; kb = kb->next) + kb->curval = 0.0f; DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); return OPERATOR_FINISHED; } @@ -350,7 +350,7 @@ void OBJECT_OT_shape_key_clear(wmOperatorType *ot) ot->exec = shape_key_clear_exec; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* starting point and step size could be optional */ @@ -364,11 +364,11 @@ static int shape_key_retime_exec(bContext *C, wmOperator *UNUSED(op)) 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->pos = (cfra += 0.1f); DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); return OPERATOR_FINISHED; } @@ -385,12 +385,12 @@ void OBJECT_OT_shape_key_retime(wmOperatorType *ot) ot->exec = shape_key_retime_exec; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } static int shape_key_mirror_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *ob= ED_object_context(C); + Object *ob = ED_object_context(C); if (!object_shape_key_mirror(C, ob)) return OPERATOR_CANCELLED; @@ -409,28 +409,28 @@ void OBJECT_OT_shape_key_mirror(wmOperatorType *ot) ot->exec = shape_key_mirror_exec; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } static int shape_key_move_exec(bContext *C, wmOperator *op) { - Object *ob= ED_object_context(C); + Object *ob = ED_object_context(C); - int type= RNA_enum_get(op->ptr, "type"); - Key *key= ob_get_key(ob); + int type = RNA_enum_get(op->ptr, "type"); + Key *key = ob_get_key(ob); 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); + 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) { + for (kb_other = key->block.first; kb_other; kb_other = kb_other->next) { if (kb_other->relative == shapenr_act) { kb_other->relative += type; } @@ -439,16 +439,16 @@ static int shape_key_move_exec(bContext *C, wmOperator *op) } } - if (type==-1) { + if (type == -1) { /* move back */ - kb_other= kb->prev; + kb_other = kb->prev; BLI_remlink(&key->block, kb); BLI_insertlinkbefore(&key->block, kb_other, kb); ob->shapenr--; } else { /* move next */ - kb_other= kb->next; + kb_other = kb->next; BLI_remlink(&key->block, kb); BLI_insertlinkafter(&key->block, kb_other, kb); ob->shapenr++; @@ -458,7 +458,7 @@ static int shape_key_move_exec(bContext *C, wmOperator *op) } DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); return OPERATOR_FINISHED; } @@ -480,7 +480,7 @@ void OBJECT_OT_shape_key_move(wmOperatorType *ot) ot->exec = shape_key_move_exec; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_enum(ot->srna, "type", slot_move, 0, "Type", ""); } diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c index d0fc4f79817..1c0899ab551 100644 --- a/source/blender/editors/object/object_transform.c +++ b/source/blender/editors/object/object_transform.c @@ -78,57 +78,57 @@ static void object_clear_loc(Object *ob) { /* clear location if not locked */ - if ((ob->protectflag & OB_LOCK_LOCX)==0) - ob->loc[0]= ob->dloc[0]= 0.0f; - if ((ob->protectflag & OB_LOCK_LOCY)==0) - ob->loc[1]= ob->dloc[1]= 0.0f; - if ((ob->protectflag & OB_LOCK_LOCZ)==0) - ob->loc[2]= ob->dloc[2]= 0.0f; + if ((ob->protectflag & OB_LOCK_LOCX) == 0) + ob->loc[0] = ob->dloc[0] = 0.0f; + if ((ob->protectflag & OB_LOCK_LOCY) == 0) + ob->loc[1] = ob->dloc[1] = 0.0f; + if ((ob->protectflag & OB_LOCK_LOCZ) == 0) + ob->loc[2] = ob->dloc[2] = 0.0f; } /* clear rotation of object */ static void object_clear_rot(Object *ob) { /* clear rotations that aren't locked */ - if (ob->protectflag & (OB_LOCK_ROTX|OB_LOCK_ROTY|OB_LOCK_ROTZ|OB_LOCK_ROTW)) { + if (ob->protectflag & (OB_LOCK_ROTX | OB_LOCK_ROTY | OB_LOCK_ROTZ | OB_LOCK_ROTW)) { if (ob->protectflag & OB_LOCK_ROT4D) { /* perform clamping on a component by component basis */ if (ob->rotmode == ROT_MODE_AXISANGLE) { if ((ob->protectflag & OB_LOCK_ROTW) == 0) - ob->rotAngle= ob->drotAngle= 0.0f; + ob->rotAngle = ob->drotAngle = 0.0f; if ((ob->protectflag & OB_LOCK_ROTX) == 0) - ob->rotAxis[0]= ob->drotAxis[0]= 0.0f; + ob->rotAxis[0] = ob->drotAxis[0] = 0.0f; if ((ob->protectflag & OB_LOCK_ROTY) == 0) - ob->rotAxis[1]= ob->drotAxis[1]= 0.0f; + ob->rotAxis[1] = ob->drotAxis[1] = 0.0f; if ((ob->protectflag & OB_LOCK_ROTZ) == 0) - ob->rotAxis[2]= ob->drotAxis[2]= 0.0f; + ob->rotAxis[2] = ob->drotAxis[2] = 0.0f; /* check validity of axis - axis should never be 0,0,0 (if so, then we make it rotate about y) */ if (IS_EQF(ob->rotAxis[0], ob->rotAxis[1]) && IS_EQF(ob->rotAxis[1], ob->rotAxis[2])) ob->rotAxis[1] = 1.0f; if (IS_EQF(ob->drotAxis[0], ob->drotAxis[1]) && IS_EQF(ob->drotAxis[1], ob->drotAxis[2])) - ob->drotAxis[1]= 1.0f; + ob->drotAxis[1] = 1.0f; } else if (ob->rotmode == ROT_MODE_QUAT) { if ((ob->protectflag & OB_LOCK_ROTW) == 0) - ob->quat[0]= ob->dquat[0]= 1.0f; + ob->quat[0] = ob->dquat[0] = 1.0f; if ((ob->protectflag & OB_LOCK_ROTX) == 0) - ob->quat[1]= ob->dquat[1]= 0.0f; + ob->quat[1] = ob->dquat[1] = 0.0f; if ((ob->protectflag & OB_LOCK_ROTY) == 0) - ob->quat[2]= ob->dquat[2]= 0.0f; + ob->quat[2] = ob->dquat[2] = 0.0f; if ((ob->protectflag & OB_LOCK_ROTZ) == 0) - ob->quat[3]= ob->dquat[3]= 0.0f; + ob->quat[3] = ob->dquat[3] = 0.0f; // TODO: does this quat need normalizing now? } else { /* the flag may have been set for the other modes, so just ignore the extra flag... */ if ((ob->protectflag & OB_LOCK_ROTX) == 0) - ob->rot[0]= ob->drot[0]= 0.0f; + ob->rot[0] = ob->drot[0] = 0.0f; if ((ob->protectflag & OB_LOCK_ROTY) == 0) - ob->rot[1]= ob->drot[1]= 0.0f; + ob->rot[1] = ob->drot[1] = 0.0f; if ((ob->protectflag & OB_LOCK_ROTZ) == 0) - ob->rot[2]= ob->drot[2]= 0.0f; + ob->rot[2] = ob->drot[2] = 0.0f; } } else { @@ -147,30 +147,30 @@ static void object_clear_rot(Object *ob) copy_v3_v3(oldeul, ob->rot); } - eul[0]= eul[1]= eul[2]= 0.0f; + eul[0] = eul[1] = eul[2] = 0.0f; if (ob->protectflag & OB_LOCK_ROTX) - eul[0]= oldeul[0]; + eul[0] = oldeul[0]; if (ob->protectflag & OB_LOCK_ROTY) - eul[1]= oldeul[1]; + eul[1] = oldeul[1]; if (ob->protectflag & OB_LOCK_ROTZ) - eul[2]= oldeul[2]; + eul[2] = oldeul[2]; if (ob->rotmode == ROT_MODE_QUAT) { eul_to_quat(ob->quat, eul); /* quaternions flip w sign to accumulate rotations correctly */ - if ((quat1[0]<0.0f && ob->quat[0]>0.0f) || (quat1[0]>0.0f && ob->quat[0]<0.0f)) { + if ((quat1[0] < 0.0f && ob->quat[0] > 0.0f) || (quat1[0] > 0.0f && ob->quat[0] < 0.0f)) { mul_qt_fl(ob->quat, -1.0f); } } else if (ob->rotmode == ROT_MODE_AXISANGLE) { - eulO_to_axis_angle(ob->rotAxis, &ob->rotAngle,eul, EULER_ORDER_DEFAULT); + eulO_to_axis_angle(ob->rotAxis, &ob->rotAngle, eul, EULER_ORDER_DEFAULT); } else { copy_v3_v3(ob->rot, eul); } } - } // Duplicated in source/blender/editors/armature/editarmature.c + } // Duplicated in source/blender/editors/armature/editarmature.c else { if (ob->rotmode == ROT_MODE_QUAT) { unit_qt(ob->quat); @@ -191,17 +191,17 @@ static void object_clear_rot(Object *ob) static void object_clear_scale(Object *ob) { /* clear scale factors which are not locked */ - if ((ob->protectflag & OB_LOCK_SCALEX)==0) { - ob->dscale[0]= 1.0f; - ob->size[0]= 1.0f; + if ((ob->protectflag & OB_LOCK_SCALEX) == 0) { + ob->dscale[0] = 1.0f; + ob->size[0] = 1.0f; } - if ((ob->protectflag & OB_LOCK_SCALEY)==0) { - ob->dscale[1]= 1.0f; - ob->size[1]= 1.0f; + if ((ob->protectflag & OB_LOCK_SCALEY) == 0) { + ob->dscale[1] = 1.0f; + ob->size[1] = 1.0f; } - if ((ob->protectflag & OB_LOCK_SCALEZ)==0) { - ob->dscale[2]= 1.0f; - ob->size[2]= 1.0f; + if ((ob->protectflag & OB_LOCK_SCALEZ) == 0) { + ob->dscale[2] = 1.0f; + ob->size[2] = 1.0f; } } @@ -209,10 +209,10 @@ static void object_clear_scale(Object *ob) /* generic exec for clear-transform operators */ static int object_clear_transform_generic_exec(bContext *C, wmOperator *op, - void (*clear_func)(Object*), const char default_ksName[]) + void (*clear_func)(Object *), const char default_ksName[]) { Main *bmain = CTX_data_main(C); - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); KeyingSet *ks; /* sanity checks */ @@ -227,7 +227,7 @@ static int object_clear_transform_generic_exec(bContext *C, wmOperator *op, /* operate on selected objects only if they aren't in weight-paint mode * (so that object-transform clearing won't be applied at same time as bone-clearing) */ - CTX_DATA_BEGIN (C, Object*, ob, selected_editable_objects) { + CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) { if (!(ob->mode & OB_MODE_WEIGHT_PAINT)) { /* run provided clearing function */ clear_func(ob); @@ -243,7 +243,7 @@ static int object_clear_transform_generic_exec(bContext *C, wmOperator *op, /* this is needed so children are also updated */ DAG_ids_flush_update(bmain, 0); - WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); return OPERATOR_FINISHED; } @@ -268,7 +268,7 @@ void OBJECT_OT_location_clear(wmOperatorType *ot) ot->poll = ED_operator_scene_editable; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } static int object_rotation_clear_exec(bContext *C, wmOperator *op) @@ -288,7 +288,7 @@ void OBJECT_OT_rotation_clear(wmOperatorType *ot) ot->poll = ED_operator_scene_editable; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } static int object_scale_clear_exec(bContext *C, wmOperator *op) @@ -308,22 +308,22 @@ void OBJECT_OT_scale_clear(wmOperatorType *ot) ot->poll = ED_operator_scene_editable; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* --------------- */ static int object_origin_clear_exec(bContext *C, wmOperator *UNUSED(op)) { - Main *bmain= CTX_data_main(C); + Main *bmain = CTX_data_main(C); float *v1, *v3; float mat[3][3]; - CTX_DATA_BEGIN (C, Object*, ob, selected_editable_objects) { + CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) { if (ob->parent) { /* vectors pointed to by v1 and v3 will get modified */ - v1= ob->loc; - v3= ob->parentinv[3]; + v1 = ob->loc; + v3 = ob->parentinv[3]; copy_m3_m4(mat, ob->parentinv); negate_v3_v3(v3, v1); @@ -336,7 +336,7 @@ static int object_origin_clear_exec(bContext *C, wmOperator *UNUSED(op)) DAG_ids_flush_update(bmain, 0); - WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); return OPERATOR_FINISHED; } @@ -353,20 +353,20 @@ void OBJECT_OT_origin_clear(wmOperatorType *ot) ot->poll = ED_operator_scene_editable; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /*************************** Apply Transformation ****************************/ /* use this when the loc/size/rot of the parent has changed but the children - * should stay in the same place, e.g. for apply-size-rot or object center */ -static void ignore_parent_tx(Main *bmain, Scene *scene, Object *ob ) +* should stay in the same place, e.g. for apply-size-rot or object center */ +static void ignore_parent_tx(Main *bmain, Scene *scene, Object *ob) { Object workob; 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) { + 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); @@ -377,21 +377,21 @@ static void ignore_parent_tx(Main *bmain, Scene *scene, Object *ob ) static int apply_objects_internal(bContext *C, ReportList *reports, int apply_loc, int apply_rot, int apply_scale) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); float rsmat[3][3], tmat[3][3], obmat[3][3], iobmat[3][3], mat[4][4], scale; int a, change = 0; /* first check if we can execute */ - CTX_DATA_BEGIN (C, Object*, ob, selected_editable_objects) { + CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) { - if (ob->type==OB_MESH) { + 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) { + 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; @@ -411,7 +411,7 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo return OPERATOR_CANCELLED; } - cu= ob->data; + cu = ob->data; 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"); @@ -426,7 +426,7 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo CTX_DATA_END; /* now execute */ - CTX_DATA_BEGIN (C, Object*, ob, selected_editable_objects) { + CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) { /* calculate rotation/scale matrix */ if (apply_scale && apply_rot) @@ -464,24 +464,24 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo } /* apply to object data */ - if (ob->type==OB_MESH) { - Mesh *me= ob->data; + if (ob->type == OB_MESH) { + Mesh *me = ob->data; MVert *mvert; multiresModifier_scale_disp(scene, ob); /* adjust data */ - mvert= me->mvert; - for (a=0; atotvert; a++, mvert++) + mvert = me->mvert; + for (a = 0; a < me->totvert; a++, mvert++) mul_m4_v3(mat, mvert->co); if (me->key) { KeyBlock *kb; - for (kb=me->key->block.first; kb; kb=kb->next) { - float *fp= kb->data; + for (kb = me->key->block.first; kb; kb = kb->next) { + float *fp = kb->data; - for (a=0; atotelem; a++, fp+=3) + for (a = 0; a < kb->totelem; a++, fp += 3) mul_m4_v3(mat, fp); } } @@ -489,7 +489,7 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo /* update normals */ mesh_calc_normals_mapping(me->mvert, me->totvert, me->mloop, me->mpoly, me->totloop, me->totpoly, NULL, NULL, 0, NULL, NULL); } - else if (ob->type==OB_ARMATURE) { + else if (ob->type == OB_ARMATURE) { ED_armature_apply_transform(ob, mat); } else if (ob->type == OB_LATTICE) { @@ -503,7 +503,7 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo } } else if (ELEM(ob->type, OB_CURVE, OB_SURF)) { - Curve *cu= ob->data; + Curve *cu = ob->data; Nurb *nu; BPoint *bp; @@ -511,10 +511,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) { + for (nu = cu->nurb.first; nu; nu = nu->next) { if (nu->type == CU_BEZIER) { - a= nu->pntsu; - for (bezt= nu->bezt; a--; bezt++) { + a = nu->pntsu; + 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]); @@ -523,8 +523,8 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo calchandlesNurb(nu); } else { - a= nu->pntsu*nu->pntsv; - for (bp= nu->bp; a--; bp++) + a = nu->pntsu * nu->pntsv; + for (bp = nu->bp; a--; bp++) mul_m4_v3(mat, bp->vec); } } @@ -535,7 +535,7 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo if (apply_loc) zero_v3(ob->loc); if (apply_scale) - ob->size[0]= ob->size[1]= ob->size[2]= 1.0f; + ob->size[0] = ob->size[1] = ob->size[2] = 1.0f; if (apply_rot) { zero_v3(ob->rot); unit_qt(ob->quat); @@ -543,13 +543,13 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo } where_is_object(scene, ob); - if (ob->type==OB_ARMATURE) { + if (ob->type == OB_ARMATURE) { where_is_pose(scene, ob); /* needed for bone parents */ } ignore_parent_tx(bmain, scene, ob); - DAG_id_tag_update(&ob->id, OB_RECALC_OB|OB_RECALC_DATA); + DAG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA); change = 1; } @@ -558,16 +558,16 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo if (!change) return OPERATOR_CANCELLED; - WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); return OPERATOR_FINISHED; } static int visual_transform_apply_exec(bContext *C, wmOperator *UNUSED(op)) { - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); int change = 0; - CTX_DATA_BEGIN (C, Object*, ob, selected_editable_objects) { + CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) { where_is_object(scene, ob); object_apply_mat4(ob, ob->obmat, TRUE, TRUE); where_is_object(scene, ob); @@ -582,7 +582,7 @@ static int visual_transform_apply_exec(bContext *C, wmOperator *UNUSED(op)) if (!change) return OPERATOR_CANCELLED; - WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); return OPERATOR_FINISHED; } @@ -598,14 +598,14 @@ void OBJECT_OT_visual_transform_apply(wmOperatorType *ot) ot->poll = ED_operator_scene_editable; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } static int object_transform_apply_exec(bContext *C, wmOperator *op) { - const int loc= RNA_boolean_get(op->ptr, "location"); - const int rot= RNA_boolean_get(op->ptr, "rotation"); - const int sca= RNA_boolean_get(op->ptr, "scale"); + const int loc = RNA_boolean_get(op->ptr, "location"); + const int rot = RNA_boolean_get(op->ptr, "rotation"); + const int sca = RNA_boolean_get(op->ptr, "scale"); if (loc || rot || sca) { return apply_objects_internal(C, op->reports, loc, rot, sca); @@ -627,7 +627,7 @@ void OBJECT_OT_transform_apply(wmOperatorType *ot) ot->poll = ED_operator_objectmode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_boolean(ot->srna, "location", 0, "Location", ""); RNA_def_boolean(ot->srna, "rotation", 0, "Rotation", ""); @@ -637,23 +637,23 @@ void OBJECT_OT_transform_apply(wmOperatorType *ot) /********************* Set Object Center ************************/ enum { - GEOMETRY_TO_ORIGIN=0, + GEOMETRY_TO_ORIGIN = 0, ORIGIN_TO_GEOMETRY, ORIGIN_TO_CURSOR }; static int object_origin_set_exec(bContext *C, wmOperator *op) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); - Object *obedit= CTX_data_edit_object(C); + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + Object *obedit = CTX_data_edit_object(C); Object *tob; float cursor[3], cent[3], cent_neg[3], centn[3], min[3], max[3]; int centermode = RNA_enum_get(op->ptr, "type"); int around = RNA_enum_get(op->ptr, "center"); /* initialized from v3d->around */ /* keep track of what is changed */ - int tot_change=0, tot_lib_error=0, tot_multiuser_arm_error=0; + int tot_change = 0, tot_lib_error = 0, tot_multiuser_arm_error = 0; if (obedit && centermode != GEOMETRY_TO_ORIGIN) { BKE_report(op->reports, RPT_ERROR, "Operation cannot be performed in EditMode"); @@ -661,10 +661,10 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) } else { /* get the view settings if 'around' isn't set and the view is available */ - View3D *v3d= CTX_wm_view3d(C); + View3D *v3d = CTX_wm_view3d(C); copy_v3_v3(cursor, give_cursor(scene, v3d)); if (v3d && !RNA_struct_property_is_set(op->ptr, "center")) - around= v3d->around; + around = v3d->around; } zero_v3(cent); @@ -672,8 +672,8 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) if (obedit) { INIT_MINMAX(min, max); - if (obedit->type==OB_MESH) { - Mesh *me= obedit->data; + if (obedit->type == OB_MESH) { + Mesh *me = obedit->data; BMEditMesh *em = me->edit_btmesh; BMVert *eve; BMIter iter; @@ -686,10 +686,10 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) } else { BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) { - if (around==V3D_CENTROID) { + if (around == V3D_CENTROID) { total++; add_v3_v3(cent, eve->co); - mul_v3_fl(cent, 1.0f/(float)total); + mul_v3_fl(cent, 1.0f / (float)total); } else { DO_MINMAX(eve->co, min, max); @@ -705,24 +705,24 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) EDBM_mesh_normals_update(em); tot_change++; DAG_id_tag_update(&obedit->id, OB_RECALC_DATA); - } + } } /* reset flags */ - CTX_DATA_BEGIN (C, Object*, ob, selected_editable_objects) { - ob->flag &= ~OB_DONE; + CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) { + ob->flag &= ~OB_DONE; } CTX_DATA_END; - for (tob= bmain->object.first; tob; tob= tob->id.next) { + for (tob = bmain->object.first; tob; tob = tob->id.next) { if (tob->data) ((ID *)tob->data)->flag &= ~LIB_DOIT; 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) { + CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) { + if ((ob->flag & OB_DONE) == 0) { int do_inverse_offset = FALSE; ob->flag |= OB_DONE; @@ -734,7 +734,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) 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->transflag & OB_DUPLIGROUP) && ob->dup_group && (ob->dup_group->id.flag & LIB_DOIT) == 0) { if (ob->dup_group->id.lib) { tot_lib_error++; } @@ -753,7 +753,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) tot_change++; ob->dup_group->id.flag |= LIB_DOIT; - do_inverse_offset= TRUE; + do_inverse_offset = TRUE; } } } @@ -761,11 +761,11 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) tot_lib_error++; } - if (obedit==NULL && ob->type==OB_MESH) { - Mesh *me= ob->data; + 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); } + else if (around == V3D_CENTROID) { mesh_center_median(me, cent); } else { mesh_center_bounds(me, cent); } negate_v3_v3(cent_neg, cent); @@ -773,14 +773,14 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) tot_change++; me->id.flag |= LIB_DOIT; - do_inverse_offset= TRUE; + do_inverse_offset = TRUE; } else if (ELEM(ob->type, OB_CURVE, OB_SURF)) { - Curve *cu= ob->data; + Curve *cu = ob->data; if (centermode == ORIGIN_TO_CURSOR) { /* done */ } - else if (around==V3D_CENTROID) { curve_center_median(cu, cent); } - else { curve_center_bounds(cu, cent); } + 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)) @@ -791,7 +791,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) tot_change++; cu->id.flag |= LIB_DOIT; - do_inverse_offset= TRUE; + do_inverse_offset = TRUE; if (obedit) { if (centermode == GEOMETRY_TO_ORIGIN) { @@ -800,12 +800,12 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) break; } } - else if (ob->type==OB_FONT) { + else if (ob->type == OB_FONT) { /* get from bb */ - Curve *cu= ob->data; + Curve *cu = ob->data; - if (cu->bb==NULL && (centermode != ORIGIN_TO_CURSOR)) { + if (cu->bb == NULL && (centermode != ORIGIN_TO_CURSOR)) { /* do nothing*/ } else { @@ -813,21 +813,21 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) /* done */ } else { - cent[0]= 0.5f * ( cu->bb->vec[4][0] + cu->bb->vec[0][0]); - cent[1]= 0.5f * ( cu->bb->vec[0][1] + cu->bb->vec[2][1]) - 0.5f; /* extra 0.5 is the height o above line */ + cent[0] = 0.5f * (cu->bb->vec[4][0] + cu->bb->vec[0][0]); + cent[1] = 0.5f * (cu->bb->vec[0][1] + cu->bb->vec[2][1]) - 0.5f; /* extra 0.5 is the height o above line */ } - cent[2]= 0.0f; + cent[2] = 0.0f; - cu->xof= cu->xof - (cent[0] / cu->fsize); - cu->yof= cu->yof - (cent[1] / cu->fsize); + cu->xof = cu->xof - (cent[0] / cu->fsize); + cu->yof = cu->yof - (cent[1] / cu->fsize); tot_change++; cu->id.flag |= LIB_DOIT; - do_inverse_offset= TRUE; + 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) { @@ -860,15 +860,15 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) MetaBall *mb = ob->data; if (centermode == ORIGIN_TO_CURSOR) { /* done */ } - else if (around==V3D_CENTROID) { BKE_metaball_center_median(mb, cent); } - else { BKE_metaball_center_bounds(mb, cent); } + else if (around == V3D_CENTROID) { BKE_metaball_center_median(mb, cent); } + else { BKE_metaball_center_bounds(mb, cent); } negate_v3_v3(cent_neg, cent); BKE_metaball_translate(mb, cent_neg); tot_change++; mb->id.flag |= LIB_DOIT; - do_inverse_offset= TRUE; + do_inverse_offset = TRUE; if (obedit) { if (centermode == GEOMETRY_TO_ORIGIN) { @@ -887,28 +887,28 @@ 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 */ } ignore_parent_tx(bmain, scene, ob); /* other users? */ - CTX_DATA_BEGIN (C, Object*, ob_other, selected_editable_objects) { + CTX_DATA_BEGIN (C, Object *, ob_other, selected_editable_objects) { 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))) { ob_other->flag |= OB_DONE; - DAG_id_tag_update(&ob_other->id, OB_RECALC_OB|OB_RECALC_DATA); + DAG_id_tag_update(&ob_other->id, OB_RECALC_OB | OB_RECALC_DATA); copy_v3_v3(centn, cent); mul_mat3_m4_v3(ob_other->obmat, centn); /* ommit translation part */ 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); @@ -920,22 +920,22 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) } CTX_DATA_END; - for (tob= bmain->object.first; tob; tob= tob->id.next) + for (tob = bmain->object.first; tob; tob = tob->id.next) if (tob->data && (((ID *)tob->data)->flag & LIB_DOIT)) - DAG_id_tag_update(&tob->id, OB_RECALC_OB|OB_RECALC_DATA); + DAG_id_tag_update(&tob->id, OB_RECALC_OB | OB_RECALC_DATA); if (tot_change) { DAG_ids_flush_update(bmain, 0); - WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); } /* Warn if any errors occurred */ - if (tot_lib_error+tot_multiuser_arm_error) { - BKE_reportf(op->reports, RPT_WARNING, "%i Object(s) Not Centered, %i Changed:",tot_lib_error+tot_multiuser_arm_error, tot_change); + if (tot_lib_error + tot_multiuser_arm_error) { + BKE_reportf(op->reports, RPT_WARNING, "%i Object(s) Not Centered, %i Changed:", tot_lib_error + tot_multiuser_arm_error, tot_change); if (tot_lib_error) - BKE_reportf(op->reports, RPT_WARNING, "|%i linked library objects",tot_lib_error); + BKE_reportf(op->reports, RPT_WARNING, "|%i linked library objects", tot_lib_error); if (tot_multiuser_arm_error) - BKE_reportf(op->reports, RPT_WARNING, "|%i multiuser armature object(s)",tot_multiuser_arm_error); + BKE_reportf(op->reports, RPT_WARNING, "|%i multiuser armature object(s)", tot_multiuser_arm_error); } return OPERATOR_FINISHED; @@ -968,7 +968,7 @@ void OBJECT_OT_origin_set(wmOperatorType *ot) ot->poll = ED_operator_scene_editable; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; ot->prop = RNA_def_enum(ot->srna, "type", prop_set_center_types, 0, "Type", ""); RNA_def_enum(ot->srna, "center", prop_set_bounds_types, V3D_CENTROID, "Center", ""); diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index 1ddbc86a73f..6d5e098770a 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -84,9 +84,9 @@ static void vgroup_delete_all(Object *ob); static Lattice *vgroup_edit_lattice(Object *ob) { - Lattice *lt= ob->data; - BLI_assert(ob->type==OB_LATTICE); - return (lt->editlatt)? lt->editlatt->latt: lt; + Lattice *lt = ob->data; + BLI_assert(ob->type == OB_LATTICE); + return (lt->editlatt) ? lt->editlatt->latt : lt; } int ED_vgroup_object_is_edit_mode(Object *ob) @@ -94,7 +94,7 @@ int ED_vgroup_object_is_edit_mode(Object *ob) if (ob->type == OB_MESH) return (BMEdit_FromObject(ob) != NULL); else if (ob->type == OB_LATTICE) - return (((Lattice*)ob->data)->editlatt != NULL); + return (((Lattice *)ob->data)->editlatt != NULL); return 0; } @@ -144,18 +144,18 @@ void ED_vgroup_delete(Object *ob, bDeformGroup *defgroup) void ED_vgroup_clear(Object *ob) { - bDeformGroup *dg= (bDeformGroup *)ob->defbase.first; - int edit_mode= ED_vgroup_object_is_edit_mode(ob); + bDeformGroup *dg = (bDeformGroup *)ob->defbase.first; + int edit_mode = ED_vgroup_object_is_edit_mode(ob); while (dg) { - bDeformGroup *next_dg= dg->next; + bDeformGroup *next_dg = dg->next; if (edit_mode) vgroup_delete_edit_mode(ob, dg); else vgroup_delete_object_mode(ob, dg); - dg= next_dg; + dg = next_dg; } } @@ -163,14 +163,14 @@ int ED_vgroup_data_create(ID *id) { /* create deform verts */ - if (GS(id->name)==ID_ME) { - Mesh *me= (Mesh *)id; - me->dvert= CustomData_add_layer(&me->vdata, CD_MDEFORMVERT, CD_CALLOC, NULL, me->totvert); + 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) { - Lattice *lt= (Lattice *)id; - lt->dvert= MEM_callocN(sizeof(MDeformVert)*lt->pntsu*lt->pntsv*lt->pntsw, "lattice deformVert"); + 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; } else { @@ -201,7 +201,7 @@ static int ED_vgroup_give_parray(ID *id, MDeformVert ***dvert_arr, int *dvert_to i = em->bm->totvert; - *dvert_arr= MEM_mallocN(sizeof(void*)*i, "vgroup parray from me"); + *dvert_arr = MEM_mallocN(sizeof(void *) * i, "vgroup parray from me"); *dvert_tot = i; i = 0; @@ -222,21 +222,21 @@ static int ED_vgroup_give_parray(ID *id, MDeformVert ***dvert_arr, int *dvert_to return 1; } else if (me->dvert) { - MVert *mvert= me->mvert; - MDeformVert *dvert= me->dvert; + MVert *mvert = me->mvert; + MDeformVert *dvert = me->dvert; int i; - *dvert_tot= me->totvert; - *dvert_arr= MEM_mallocN(sizeof(void*)*me->totvert, "vgroup parray from me"); + *dvert_tot = me->totvert; + *dvert_arr = MEM_mallocN(sizeof(void *) * me->totvert, "vgroup parray from me"); if (use_vert_sel) { - for (i=0; itotvert; i++) { + for (i = 0; i < me->totvert; i++) { (*dvert_arr)[i] = (mvert[i].flag & SELECT) ? - &dvert[i] : NULL; + &dvert[i] : NULL; } } else { - for (i=0; itotvert; i++) { + for (i = 0; i < me->totvert; i++) { (*dvert_arr)[i] = me->dvert + i; } } @@ -249,24 +249,24 @@ static int ED_vgroup_give_parray(ID *id, MDeformVert ***dvert_arr, int *dvert_to } case ID_LT: { - int i=0; + int i = 0; - Lattice *lt= (Lattice *)id; - lt= (lt->editlatt)? lt->editlatt->latt: lt; + Lattice *lt = (Lattice *)id; + lt = (lt->editlatt) ? lt->editlatt->latt : lt; 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"); + BPoint *def = lt->def; + *dvert_tot = lt->pntsu * lt->pntsv * lt->pntsw; + *dvert_arr = MEM_mallocN(sizeof(void *) * (*dvert_tot), "vgroup parray from me"); if (use_vert_sel) { - for (i=0; i<*dvert_tot; i++) { + for (i = 0; i < *dvert_tot; i++) { (*dvert_arr)[i] = (def->f1 & SELECT) ? <->dvert[i] : NULL; } } else { - for (i=0; i<*dvert_tot; i++) { + for (i = 0; i < *dvert_tot; i++) { (*dvert_arr)[i] = lt->dvert + i; } } @@ -291,23 +291,23 @@ int ED_vgroup_give_array(ID *id, MDeformVert **dvert_arr, int *dvert_tot) case ID_ME: { Mesh *me = (Mesh *)id; - *dvert_arr= me->dvert; - *dvert_tot= me->totvert; + *dvert_arr = me->dvert; + *dvert_tot = me->totvert; return TRUE; } case ID_LT: { - Lattice *lt= (Lattice *)id; - lt= (lt->editlatt)? lt->editlatt->latt: lt; - *dvert_arr= lt->dvert; - *dvert_tot= lt->pntsu*lt->pntsv*lt->pntsw; + Lattice *lt = (Lattice *)id; + lt = (lt->editlatt) ? lt->editlatt->latt : lt; + *dvert_arr = lt->dvert; + *dvert_tot = lt->pntsu * lt->pntsv * lt->pntsw; return TRUE; } } } - *dvert_arr= NULL; - *dvert_tot= 0; + *dvert_arr = NULL; + *dvert_tot = 0; return FALSE; } @@ -319,19 +319,19 @@ int ED_vgroup_copy_array(Object *ob, Object *ob_from) int dvert_tot_from; int dvert_tot; int i; - int defbase_tot_from= BLI_countlist(&ob_from->defbase); - int defbase_tot= BLI_countlist(&ob->defbase); - short new_vgroup= FALSE; + int defbase_tot_from = BLI_countlist(&ob_from->defbase); + int defbase_tot = BLI_countlist(&ob->defbase); + short new_vgroup = FALSE; 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)) { ED_vgroup_give_parray(ob->data, &dvert_array, &dvert_tot, FALSE); - new_vgroup= TRUE; + 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); @@ -345,29 +345,29 @@ int ED_vgroup_copy_array(Object *ob, Object *ob_from) /* do the copy */ BLI_freelistN(&ob->defbase); BLI_duplicatelist(&ob->defbase, &ob_from->defbase); - ob->actdef= ob_from->actdef; + ob->actdef = ob_from->actdef; 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 */ + 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 */ vgroup_remap_update_users(ob, remap); MEM_freeN(remap); } - dvf= dvert_array_from; - dv= dvert_array; + dvf = dvert_array_from; + dv = dvert_array; - for (i=0; idw) MEM_freeN((*dv)->dw); - *(*dv)= *(*dvf); + *(*dv) = *(*dvf); if ((*dv)->dw) - (*dv)->dw= MEM_dupallocN((*dv)->dw); + (*dv)->dw = MEM_dupallocN((*dv)->dw); } MEM_freeN(dvert_array); @@ -386,13 +386,13 @@ static void ED_vgroup_nr_vert_add(Object *ob, /* add the vert to the deform group with the * specified number */ - MDeformVert *dvert= NULL; - int tot; + MDeformVert *dvert = NULL; + int tot; /* 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 */ @@ -401,7 +401,7 @@ static void ED_vgroup_nr_vert_add(Object *ob, if (dvert) { - MDeformVert *dv= &dvert[vertnum]; + MDeformVert *dv = &dvert[vertnum]; MDeformWeight *dw; /* Lets first check to see if this vert is @@ -409,27 +409,27 @@ static void ED_vgroup_nr_vert_add(Object *ob, * lets update it */ - dw= defvert_find_index(dv, def_nr); + dw = defvert_find_index(dv, def_nr); if (dw) { switch (assignmode) { - case WEIGHT_REPLACE: - dw->weight = weight; - break; - case WEIGHT_ADD: - dw->weight += weight; - if (dw->weight >= 1.0f) - dw->weight = 1.0f; - break; - case WEIGHT_SUBTRACT: - dw->weight -= weight; - /* if the weight is zero or less then - * remove the vert from the deform group - */ - if (dw->weight <= 0.0f) { - defvert_remove_group(dv, dw); - } - break; + case WEIGHT_REPLACE: + dw->weight = weight; + break; + case WEIGHT_ADD: + dw->weight += weight; + if (dw->weight >= 1.0f) + dw->weight = 1.0f; + break; + case WEIGHT_SUBTRACT: + dw->weight -= weight; + /* if the weight is zero or less then + * remove the vert from the deform group + */ + if (dw->weight <= 0.0f) { + defvert_remove_group(dv, dw); + } + break; } } else { @@ -438,20 +438,20 @@ static void ED_vgroup_nr_vert_add(Object *ob, */ switch (assignmode) { - case WEIGHT_SUBTRACT: - /* if we are subtracting then we don't - * need to do anything - */ - return; + case WEIGHT_SUBTRACT: + /* if we are subtracting then we don't + * need to do anything + */ + return; - case WEIGHT_REPLACE: - case WEIGHT_ADD: - /* if we are doing an additive assignment, then - * we need to create the deform weight - */ + case WEIGHT_REPLACE: + case WEIGHT_ADD: + /* if we are doing an additive assignment, then + * we need to create the deform weight + */ - /* we checked if the vertex was added before so no need to test again, simply add */ - defvert_add_index_notest(dv, def_nr, weight); + /* we checked if the vertex was added before so no need to test again, simply add */ + defvert_add_index_notest(dv, def_nr, weight); } } } @@ -463,9 +463,9 @@ void ED_vgroup_vert_add(Object *ob, bDeformGroup *dg, int vertnum, float weight, /* add the vert to the deform group with the * specified assign mode */ - const int def_nr= BLI_findindex(&ob->defbase, dg); + const int def_nr = BLI_findindex(&ob->defbase, dg); - MDeformVert *dv= NULL; + MDeformVert *dv = NULL; int tot; /* get the deform group number, exit if @@ -475,7 +475,7 @@ void ED_vgroup_vert_add(Object *ob, bDeformGroup *dg, int vertnum, float weight, /* 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 @@ -484,17 +484,17 @@ void ED_vgroup_vert_add(Object *ob, bDeformGroup *dg, int vertnum, float weight, } /* mesh object mode, lattice can be in editmode */ -void ED_vgroup_vert_remove(Object *ob, bDeformGroup *dg, int vertnum) +void ED_vgroup_vert_remove(Object *ob, bDeformGroup *dg, int vertnum) { /* This routine removes the vertex from the specified * deform group. */ /* 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); + const int def_nr = BLI_findindex(&ob->defbase, dg); if (def_nr != -1) { - MDeformVert *dvert= NULL; + MDeformVert *dvert = NULL; int tot; /* get the deform vertices corresponding to the @@ -503,10 +503,10 @@ void ED_vgroup_vert_remove(Object *ob, bDeformGroup *dg, int vertnum) ED_vgroup_give_array(ob->data, &dvert, &tot); if (dvert) { - MDeformVert *dv= &dvert[vertnum]; + MDeformVert *dv = &dvert[vertnum]; MDeformWeight *dw; - dw= defvert_find_index(dv, def_nr); + dw = defvert_find_index(dv, def_nr); defvert_remove_group(dv, dw); /* dw can be NULL */ } } @@ -514,20 +514,20 @@ void ED_vgroup_vert_remove(Object *ob, bDeformGroup *dg, int vertnum) static float get_vert_def_nr(Object *ob, const int def_nr, const int vertnum) { - MDeformVert *dv= NULL; + MDeformVert *dv = NULL; BMVert *eve; Mesh *me; /* get the deform vertices corresponding to the vertnum */ - if (ob->type==OB_MESH) { - me= ob->data; + if (ob->type == OB_MESH) { + me = ob->data; if (me->edit_btmesh) { - eve= BM_vert_at_index(me->edit_btmesh->bm, vertnum); + eve = BM_vert_at_index(me->edit_btmesh->bm, vertnum); if (!eve) { return 0.0f; } - dv= CustomData_bmesh_get(&me->edit_btmesh->bm->vdata, eve->head.data, CD_MDEFORMVERT); + dv = CustomData_bmesh_get(&me->edit_btmesh->bm->vdata, eve->head.data, CD_MDEFORMVERT); } else { if (vertnum >= me->totvert) { @@ -536,11 +536,11 @@ static float get_vert_def_nr(Object *ob, const int def_nr, const int vertnum) dv = &me->dvert[vertnum]; } } - else if (ob->type==OB_LATTICE) { - Lattice *lt= vgroup_edit_lattice(ob); + else if (ob->type == OB_LATTICE) { + Lattice *lt = vgroup_edit_lattice(ob); if (lt->dvert) { - if (vertnum >= lt->pntsu*lt->pntsv*lt->pntsw) { + if (vertnum >= lt->pntsu * lt->pntsv * lt->pntsw) { return 0.0f; } dv = <->dvert[vertnum]; @@ -548,7 +548,7 @@ static float get_vert_def_nr(Object *ob, const int def_nr, const int vertnum) } if (dv) { - MDeformWeight *dw= defvert_find_index(dv, def_nr); + MDeformWeight *dw = defvert_find_index(dv, def_nr); if (dw) { return dw->weight; } @@ -559,7 +559,7 @@ static float get_vert_def_nr(Object *ob, const int def_nr, const int vertnum) float ED_vgroup_vert_weight(Object *ob, bDeformGroup *dg, int vertnum) { - const int def_nr= BLI_findindex(&ob->defbase, dg); + const int def_nr = BLI_findindex(&ob->defbase, dg); if (def_nr == -1) { return -1; @@ -569,8 +569,8 @@ float ED_vgroup_vert_weight(Object *ob, bDeformGroup *dg, int vertnum) } void ED_vgroup_select_by_name(Object *ob, const char *name) -{ /* note: ob->actdef==0 signals on painting to create a new one, if a bone in posemode is selected */ - ob->actdef= defgroup_name_index(ob, name) + 1; +{ /* note: ob->actdef==0 signals on painting to create a new one, if a bone in posemode is selected */ + ob->actdef = defgroup_name_index(ob, name) + 1; } /********************** Operator Implementations *********************/ @@ -578,7 +578,7 @@ void ED_vgroup_select_by_name(Object *ob, const char *name) /* only in editmode */ static void vgroup_select_verts(Object *ob, int select) { - const int def_nr= ob->actdef-1; + const int def_nr = ob->actdef - 1; MDeformVert *dv; if (!BLI_findlink(&ob->defbase, def_nr)) { @@ -586,7 +586,7 @@ static void vgroup_select_verts(Object *ob, int select) } if (ob->type == OB_MESH) { - Mesh *me= ob->data; + Mesh *me = ob->data; if (me->edit_btmesh) { BMEditMesh *em = me->edit_btmesh; @@ -595,7 +595,7 @@ static void vgroup_select_verts(Object *ob, int select) BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) { if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) { - dv= CustomData_bmesh_get(&em->bm->vdata, eve->head.data, CD_MDEFORMVERT); + dv = CustomData_bmesh_get(&em->bm->vdata, eve->head.data, CD_MDEFORMVERT); if (defvert_find_index(dv, def_nr)) { BM_vert_select_set(em->bm, eve, select); } @@ -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 { @@ -615,11 +615,11 @@ static void vgroup_select_verts(Object *ob, int select) mv = me->mvert; dv = me->dvert; - for (i=0; itotvert; i++, mv++, dv++) { + for (i = 0; i < me->totvert; i++, mv++, dv++) { if (!(mv->flag & ME_HIDE)) { if (defvert_find_index(dv, def_nr)) { - if (select) mv->flag |= SELECT; - else mv->flag &= ~SELECT; + if (select) mv->flag |= SELECT; + else mv->flag &= ~SELECT; } } } @@ -629,19 +629,19 @@ static void vgroup_select_verts(Object *ob, int select) } } else if (ob->type == OB_LATTICE) { - Lattice *lt= vgroup_edit_lattice(ob); + Lattice *lt = vgroup_edit_lattice(ob); if (lt->dvert) { BPoint *bp; int a, tot; - dv= lt->dvert; + dv = lt->dvert; - tot= lt->pntsu*lt->pntsv*lt->pntsw; - for (a=0, bp= lt->def; apntsu * lt->pntsv * lt->pntsw; + 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; + if (select) bp->f1 |= SELECT; + else bp->f1 &= ~SELECT; } } } @@ -653,10 +653,10 @@ static void vgroup_duplicate(Object *ob) bDeformGroup *dg, *cdg; char name[sizeof(dg->name)]; MDeformWeight *dw_org, *dw_cpy; - MDeformVert **dvert_array=NULL; - int i, idg, icdg, dvert_tot=0; + MDeformVert **dvert_array = NULL; + int i, idg, icdg, dvert_tot = 0; - dg = BLI_findlink(&ob->defbase, (ob->actdef-1)); + dg = BLI_findlink(&ob->defbase, (ob->actdef - 1)); if (!dg) return; @@ -673,16 +673,16 @@ static void vgroup_duplicate(Object *ob) BLI_addtail(&ob->defbase, cdg); - idg = (ob->actdef-1); + idg = (ob->actdef - 1); ob->actdef = BLI_countlist(&ob->defbase); - icdg = (ob->actdef-1); + icdg = (ob->actdef - 1); /* TODO, we might want to allow only copy selected verts here? - campbell */ ED_vgroup_give_parray(ob->data, &dvert_array, &dvert_tot, FALSE); if (dvert_array) { for (i = 0; i < dvert_tot; i++) { - MDeformVert *dv= dvert_array[i]; + MDeformVert *dv = dvert_array[i]; dw_org = defvert_find_index(dv, idg); if (dw_org) { /* defvert_verify_index re-allocs org so need to store the weight first */ @@ -698,9 +698,9 @@ static void vgroup_duplicate(Object *ob) static void vgroup_normalize(Object *ob) { MDeformWeight *dw; - MDeformVert *dv, **dvert_array=NULL; - int i, dvert_tot=0; - const int def_nr= ob->actdef-1; + MDeformVert *dv, **dvert_array = NULL; + int i, dvert_tot = 0; + const int def_nr = ob->actdef - 1; const int use_vert_sel = (ob->type == OB_MESH && ((Mesh *)ob->data)->editflag & ME_EDIT_VERT_SEL) != 0; @@ -751,7 +751,7 @@ static void vgroup_normalize(Object *ob) /* This finds all of the vertices face-connected to vert by an edge and returns a * MEM_allocated array of indices of size count. * count is an int passed by reference so it can be assigned the value of the length here. */ -static int* getSurroundingVerts(Mesh *me, int vert, int *count) +static int *getSurroundingVerts(Mesh *me, int vert, int *count) { MPoly *mp = me->mpoly; int i = me->totpoly; @@ -778,12 +778,12 @@ static int* getSurroundingVerts(Mesh *me, int vert, int *count) } else if (!j) { /* We are on the last corner. */ - a = (ml-1)->v; + a = (ml - 1)->v; b = me->mloop[mp->loopstart].v; } else { - a = (ml-1)->v; - b = (ml+1)->v; + a = (ml - 1)->v; + b = (ml + 1)->v; } /* Append a and b verts to array, if not yet present. */ @@ -823,7 +823,7 @@ static void getSingleCoordinate(MVert *points, int count, float coord[3]) for (i = 0; i < count; i++) { add_v3_v3(coord, points[i].co); } - mul_v3_fl(coord, 1.0f/count); + mul_v3_fl(coord, 1.0f / count); } /* given a plane and a start and end position, @@ -853,7 +853,7 @@ 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; @@ -865,7 +865,7 @@ static void dm_deform_clear(DerivedMesh *dm, Object *ob) } /* recalculate the deformation */ -static DerivedMesh* dm_deform_recalc(Scene *scene, Object *ob) +static DerivedMesh *dm_deform_recalc(Scene *scene, Object *ob) { return mesh_get_derived_deform(scene, ob, CD_MASK_BAREMESH); } @@ -885,19 +885,19 @@ static void moveCloserToDistanceFromPlane(Scene *scene, Object *ob, Mesh *me, in DerivedMesh *dm; MDeformWeight *dw; MVert m; - MDeformVert *dvert = me->dvert+index; + MDeformVert *dvert = me->dvert + index; int totweight = dvert->totweight; float oldw = 0; float oldPos[3] = {0}; float vc, hc, dist = 0.0f; int i, k; - float (*changes)[2] = MEM_mallocN(sizeof(float *)*totweight*2, "vertHorzChange"); - float *dists = MEM_mallocN(sizeof(float)*totweight, "distance"); + float (*changes)[2] = MEM_mallocN(sizeof(float *) * totweight * 2, "vertHorzChange"); + float *dists = MEM_mallocN(sizeof(float) * totweight, "distance"); /* track if up or down moved it closer for each bone */ - int *upDown = MEM_callocN(sizeof(int)*totweight, "upDownTracker"); + int *upDown = MEM_callocN(sizeof(int) * totweight, "upDownTracker"); - int *dwIndices = MEM_callocN(sizeof(int)*totweight, "dwIndexTracker"); + int *dwIndices = MEM_callocN(sizeof(int) * totweight, "dwIndexTracker"); float distToStart; int bestIndex = 0; char wasChange; @@ -912,11 +912,11 @@ static void moveCloserToDistanceFromPlane(Scene *scene, Object *ob, Mesh *me, in distToStart = dot_v3v3(norm, oldPos) + d; if (distToBe == originalDistToBe) { - distToBe += distToStart - distToStart*strength; + distToBe += distToStart - distToStart * strength; } for (i = 0; i < totweight; i++) { dwIndices[i] = i; - dw = (dvert->dw+i); + dw = (dvert->dw + i); vc = hc = 0; if (!dw->weight) { changes[i][0] = 0; @@ -930,10 +930,10 @@ static void moveCloserToDistanceFromPlane(Scene *scene, Object *ob, Mesh *me, in } oldw = dw->weight; if (k) { - dw->weight *= 1+cp; + dw->weight *= 1 + cp; } else { - dw->weight /= 1+cp; + dw->weight /= 1 + cp; } if (dw->weight == oldw) { changes[i][0] = 0; @@ -976,7 +976,7 @@ static void moveCloserToDistanceFromPlane(Scene *scene, Object *ob, Mesh *me, in 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])) { @@ -1009,7 +1009,7 @@ 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)) { + if (fabs(changes[i][0]) > fabs(changes[i][1] * 2.0f)) { bestIndex = i; break; } @@ -1025,13 +1025,13 @@ static void moveCloserToDistanceFromPlane(Scene *scene, Object *ob, Mesh *me, in } lastIndex = bestIndex; wasUp = upDown[bestIndex]; - dw = (dvert->dw+dwIndices[bestIndex]); + dw = (dvert->dw + dwIndices[bestIndex]); oldw = dw->weight; if (upDown[bestIndex]) { - dw->weight *= 1+cp; + dw->weight *= 1 + cp; } else { - dw->weight /= 1+cp; + dw->weight /= 1 + cp; } if (dw->weight > 1) { dw->weight = 1; @@ -1065,10 +1065,10 @@ static void vgroup_fix(Scene *scene, Object *ob, float distToBe, float strength, return; for (i = 0; i < me->totvert && mvert; i++, mvert++) { if (mvert->flag & SELECT) { - int count=0; + int count = 0; if ((verts = getSurroundingVerts(me, i, &count))) { MVert m; - MVert *p = MEM_callocN(sizeof(MVert)*(count), "deformedPoints"); + MVert *p = MEM_callocN(sizeof(MVert) * (count), "deformedPoints"); int k; DerivedMesh *dm = mesh_get_derived_deform(scene, ob, CD_MASK_BAREMESH); @@ -1085,7 +1085,7 @@ static void vgroup_fix(Scene *scene, Object *ob, float distToBe, float strength, getSingleCoordinate(p, count, coord); dm->getVert(dm, i, &m); sub_v3_v3v3(norm, m.co, coord); - mag= normalize_v3(norm); + mag = normalize_v3(norm); if (mag) { /* zeros fix */ d = -dot_v3v3(norm, coord); /* dist = (dot_v3v3(norm, m.co) + d); */ /* UNUSED */ @@ -1103,9 +1103,9 @@ static void vgroup_fix(Scene *scene, Object *ob, float distToBe, float strength, static void vgroup_levels(Object *ob, float offset, float gain) { MDeformWeight *dw; - MDeformVert *dv, **dvert_array=NULL; - int i, dvert_tot=0; - const int def_nr= ob->actdef-1; + MDeformVert *dv, **dvert_array = NULL; + int i, dvert_tot = 0; + const int def_nr = ob->actdef - 1; const int use_vert_sel = (ob->type == OB_MESH && ((Mesh *)ob->data)->editflag & ME_EDIT_VERT_SEL) != 0; @@ -1138,9 +1138,9 @@ static void vgroup_levels(Object *ob, float offset, float gain) /* TODO - select between groups */ static void vgroup_normalize_all(Object *ob, int lock_active) { - MDeformVert *dv, **dvert_array=NULL; - int i, dvert_tot=0; - const int def_nr= ob->actdef-1; + MDeformVert *dv, **dvert_array = NULL; + int i, dvert_tot = 0; + const int def_nr = ob->actdef - 1; const int use_vert_sel = (ob->type == OB_MESH && ((Mesh *)ob->data)->editflag & ME_EDIT_VERT_SEL) != 0; @@ -1184,16 +1184,16 @@ static void vgroup_lock_all(Object *ob, int action) bDeformGroup *dg; if (action == SEL_TOGGLE) { - action= SEL_SELECT; - for (dg= ob->defbase.first; dg; dg= dg->next) { + action = SEL_SELECT; + for (dg = ob->defbase.first; dg; dg = dg->next) { if (dg->flag & DG_LOCK_WEIGHT) { - action= SEL_DESELECT; + 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; @@ -1211,9 +1211,9 @@ static void vgroup_lock_all(Object *ob, int action) static void vgroup_invert(Object *ob, const short auto_assign, const short auto_remove) { MDeformWeight *dw; - MDeformVert *dv, **dvert_array=NULL; - int i, dvert_tot=0; - const int def_nr= ob->actdef-1; + MDeformVert *dv, **dvert_array = NULL; + int i, dvert_tot = 0; + const int def_nr = ob->actdef - 1; const int use_vert_sel = (ob->type == OB_MESH && ((Mesh *)ob->data)->editflag & ME_EDIT_VERT_SEL) != 0; if (!BLI_findlink(&ob->defbase, def_nr)) { @@ -1231,10 +1231,10 @@ static void vgroup_invert(Object *ob, const short auto_assign, const short auto_ } if (auto_assign) { - dw= defvert_verify_index(dv, def_nr); + dw = defvert_verify_index(dv, def_nr); } else { - dw= defvert_find_index(dv, def_nr); + dw = defvert_find_index(dv, def_nr); } if (dw) { @@ -1254,8 +1254,8 @@ static void vgroup_blend(Object *ob, const float fac) { MDeformVert *dv; MDeformWeight *dw; - int i, dvert_tot=0; - const int def_nr= ob->actdef - 1; + int i, dvert_tot = 0; + const int def_nr = ob->actdef - 1; BLI_assert(fac >= 0.0 && fac <= 1.0f); @@ -1304,14 +1304,14 @@ static void vgroup_blend(Object *ob, const float fac) int i1 /* , i2 */; /* i1 is always the selected one */ if (sel1) { - i1= BM_elem_index_get(eed->v1); + i1 = BM_elem_index_get(eed->v1); /* i2= BM_elem_index_get(eed->v2); */ /* UNUSED */ - eve= eed->v2; + eve = eed->v2; } else { /* i2= BM_elem_index_get(eed->v1); */ /* UNUSED */ - i1= BM_elem_index_get(eed->v2); - eve= eed->v1; + i1 = BM_elem_index_get(eed->v2); + eve = eed->v1; } dv = CustomData_bmesh_get(&bm->vdata, eve->head.data, CD_MDEFORMVERT); @@ -1385,9 +1385,9 @@ static void vgroup_blend(Object *ob, const float fac) static void vgroup_clean(Object *ob, const float epsilon, int keep_single) { MDeformWeight *dw; - MDeformVert *dv, **dvert_array=NULL; - int i, dvert_tot=0; - const int def_nr= ob->actdef-1; + MDeformVert *dv, **dvert_array = NULL; + int i, dvert_tot = 0; + const int def_nr = ob->actdef - 1; const int use_vert_sel = (ob->type == OB_MESH && ((Mesh *)ob->data)->editflag & ME_EDIT_VERT_SEL) != 0; if (!BLI_findlink(&ob->defbase, def_nr)) { @@ -1405,11 +1405,11 @@ static void vgroup_clean(Object *ob, const float epsilon, int keep_single) continue; } - dw= defvert_find_index(dv, def_nr); + dw = defvert_find_index(dv, def_nr); 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 */ } } @@ -1422,7 +1422,7 @@ static void vgroup_clean(Object *ob, const float epsilon, int keep_single) static void vgroup_clean_all(Object *ob, const float epsilon, const int keep_single) { - MDeformVert **dvert_array=NULL; + MDeformVert **dvert_array = NULL; int i, dvert_tot = 0; const int use_vert_sel = (ob->type == OB_MESH && ((Mesh *)ob->data)->editflag & ME_EDIT_VERT_SEL) != 0; @@ -1440,14 +1440,14 @@ static void vgroup_clean_all(Object *ob, const float epsilon, const int keep_sin continue; } - j= dv->totweight; + j = dv->totweight; while (j--) { if (keep_single && dv->totweight == 1) break; - dw= dv->dw + j; + dw = dv->dw + j; if (dw->weight <= epsilon) { defvert_remove_group(dv, dw); @@ -1475,14 +1475,14 @@ static void dvert_mirror_op(MDeformVert *dvert, MDeformVert *dvert_mirr, SWAP(MDeformVert, *dvert, *dvert_mirr); } else { - MDeformWeight *dw= defvert_find_index(dvert, act_vgroup); - MDeformWeight *dw_mirr= defvert_find_index(dvert_mirr, act_vgroup); + MDeformWeight *dw = defvert_find_index(dvert, act_vgroup); + MDeformWeight *dw_mirr = defvert_find_index(dvert_mirr, act_vgroup); if (dw || dw_mirr) { if (dw_mirr == NULL) - dw_mirr= defvert_verify_index(dvert_mirr, act_vgroup); + dw_mirr = defvert_verify_index(dvert_mirr, act_vgroup); if (dw == NULL) - dw= defvert_verify_index(dvert, act_vgroup); + dw = defvert_verify_index(dvert, act_vgroup); SWAP(float, dw->weight, dw_mirr->weight); } @@ -1532,19 +1532,19 @@ void ED_vgroup_mirror(Object *ob, const short mirror_weights, const short flip_v BMVert *eve, *eve_mirr; MDeformVert *dvert, *dvert_mirr; short sel, sel_mirr; - int *flip_map, flip_map_len; - const int def_nr= ob->actdef-1; + int *flip_map, flip_map_len; + const int def_nr = ob->actdef - 1; - if ( (mirror_weights==0 && flip_vgroups==0) || + if ( (mirror_weights == 0 && flip_vgroups == 0) || (BLI_findlink(&ob->defbase, def_nr) == NULL) ) { return; } if (flip_vgroups) { - flip_map= all_vgroups ? - defgroup_flip_map(ob, &flip_map_len, FALSE) : - defgroup_flip_map_single(ob, &flip_map_len, FALSE, def_nr); + flip_map = all_vgroups ? + defgroup_flip_map(ob, &flip_map_len, FALSE) : + defgroup_flip_map_single(ob, &flip_map_len, FALSE, def_nr); BLI_assert(flip_map != NULL); @@ -1554,13 +1554,13 @@ void ED_vgroup_mirror(Object *ob, const short mirror_weights, const short flip_v } } else { - flip_map= NULL; - flip_map_len= 0; + flip_map = NULL; + flip_map_len = 0; } /* only the active group */ if (ob->type == OB_MESH) { - Mesh *me= ob->data; + Mesh *me = ob->data; BMEditMesh *em = me->edit_btmesh; if (em) { @@ -1574,13 +1574,13 @@ 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_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) { - if ((eve_mirr= EDBM_verts_mirror_get(em, eve))) { - sel= BM_elem_flag_test(eve, BM_ELEM_SELECT); - sel_mirr= BM_elem_flag_test(eve_mirr, BM_ELEM_SELECT); + if ((eve_mirr = EDBM_verts_mirror_get(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)) { - 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); + 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) { VGROUP_MIRR_OP; } @@ -1604,29 +1604,29 @@ void ED_vgroup_mirror(Object *ob, const short mirror_weights, const short flip_v } if (!use_vert_sel) { - sel= sel_mirr= TRUE; + sel = sel_mirr = TRUE; } /* 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_mirr = mesh_get_x_mirror_vert(ob, vidx)) != -1) && (vidx != vidx_mirr) && - ((((mv_mirr= me->mvert + vidx_mirr)->flag) & ME_VERT_TMP_TAG) == 0)) + ((((mv_mirr = me->mvert + vidx_mirr)->flag) & ME_VERT_TMP_TAG) == 0)) { if (use_vert_sel) { - sel= mv->flag & SELECT; - sel_mirr= mv_mirr->flag & SELECT; + sel = mv->flag & SELECT; + sel_mirr = mv_mirr->flag & SELECT; } if (sel || sel_mirr) { - dvert= &me->dvert[vidx]; - dvert_mirr= &me->dvert[vidx_mirr]; + dvert = &me->dvert[vidx]; + dvert_mirr = &me->dvert[vidx_mirr]; VGROUP_MIRR_OP; } @@ -1638,7 +1638,7 @@ void ED_vgroup_mirror(Object *ob, const short mirror_weights, const short flip_v } } else if (ob->type == OB_LATTICE) { - Lattice *lt= vgroup_edit_lattice(ob); + Lattice *lt = vgroup_edit_lattice(ob); int i1, i2; int u, v, w; int pntsu_half; @@ -1651,27 +1651,27 @@ void ED_vgroup_mirror(Object *ob, const short mirror_weights, const short flip_v /* unlike editmesh we know that by only looping over the first half of * the 'u' indices it will cover all points except the middle which is * ok in this case */ - pntsu_half= lt->pntsu / 2; + pntsu_half = lt->pntsu / 2; - for (w=0; wpntsw; w++) { - for (v=0; vpntsv; v++) { - for (u=0; upntsu - 1) - 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) { BPoint *bp, *bp_mirr; - i1= LT_INDEX(lt, u, v, w); - i2= LT_INDEX(lt, u_inv, v, w); + i1 = LT_INDEX(lt, u, v, w); + i2 = LT_INDEX(lt, u_inv, v, w); - bp= <->def[i1]; - bp_mirr= <->def[i2]; + bp = <->def[i1]; + bp_mirr = <->def[i2]; - sel= bp->f1 & SELECT; - sel_mirr= bp_mirr->f1 & SELECT; + sel = bp->f1 & SELECT; + sel_mirr = bp_mirr->f1 & SELECT; if (sel || sel_mirr) { - dvert= <->dvert[i1]; - dvert_mirr= <->dvert[i2]; + dvert = <->dvert[i1]; + dvert_mirr = <->dvert[i2]; VGROUP_MIRR_OP; } @@ -1701,40 +1701,40 @@ static void vgroup_remap_update_users(Object *ob, int *map) * they get deleted the numbers get out of sync, this corrects that */ if (ob->soft) - ob->soft->vertgroup= map[ob->soft->vertgroup]; + ob->soft->vertgroup = map[ob->soft->vertgroup]; - for (md=ob->modifiers.first; md; md=md->next) { + for (md = ob->modifiers.first; md; md = md->next) { if (md->type == eModifierType_Explode) { - emd= (ExplodeModifierData*)md; - emd->vgroup= map[emd->vgroup]; + emd = (ExplodeModifierData *)md; + emd->vgroup = map[emd->vgroup]; } else if (md->type == eModifierType_Cloth) { - clmd= (ClothModifierData*)md; - clsim= clmd->sim_parms; + clmd = (ClothModifierData *)md; + clsim = clmd->sim_parms; if (clsim) { - clsim->vgroup_mass= map[clsim->vgroup_mass]; - clsim->vgroup_bend= map[clsim->vgroup_bend]; - clsim->vgroup_struct= map[clsim->vgroup_struct]; + clsim->vgroup_mass = map[clsim->vgroup_mass]; + clsim->vgroup_bend = map[clsim->vgroup_bend]; + clsim->vgroup_struct = map[clsim->vgroup_struct]; } } } - for (psys=ob->particlesystem.first; psys; psys=psys->next) { - for (a=0; avgroup[a]= map[psys->vgroup[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]]; } } static void vgroup_delete_update_users(Object *ob, int id) { - int i, defbase_tot= BLI_countlist(&ob->defbase) + 1; - int *map= MEM_mallocN(sizeof(int) * defbase_tot, "vgroup del"); + int i, defbase_tot = BLI_countlist(&ob->defbase) + 1; + int *map = MEM_mallocN(sizeof(int) * defbase_tot, "vgroup del"); - map[id]= map[0]= 0; - for (i=1; idefbase, dg); + MDeformVert *dvert_array = NULL; + int dvert_tot = 0; + const int def_nr = BLI_findindex(&ob->defbase, dg); assert(def_nr > -1); @@ -1754,10 +1754,10 @@ static void vgroup_delete_object_mode(Object *ob, bDeformGroup *dg) 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); + 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 */ @@ -1779,7 +1779,7 @@ static void vgroup_delete_object_mode(Object *ob, bDeformGroup *dg) if (ob->actdef > def_nr) ob->actdef--; if (ob->actdef < 1 && ob->defbase.first) - ob->actdef= 1; + ob->actdef = 1; } @@ -1788,10 +1788,10 @@ static void vgroup_delete_object_mode(Object *ob, bDeformGroup *dg) static void vgroup_active_remove_verts(Object *ob, const int allverts, bDeformGroup *dg) { MDeformVert *dv; - const int def_nr= BLI_findindex(&ob->defbase, dg); + const int def_nr = BLI_findindex(&ob->defbase, dg); if (ob->type == OB_MESH) { - Mesh *me= ob->data; + Mesh *me = ob->data; if (me->edit_btmesh) { BMEditMesh *em = me->edit_btmesh; @@ -1799,7 +1799,7 @@ static void vgroup_active_remove_verts(Object *ob, const int allverts, bDeformGr BMIter iter; BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) { - dv= CustomData_bmesh_get(&em->bm->vdata, eve->head.data, CD_MDEFORMVERT); + 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))) { MDeformWeight *dw = defvert_find_index(dv, def_nr); @@ -1819,7 +1819,7 @@ static void vgroup_active_remove_verts(Object *ob, const int allverts, bDeformGr mv = me->mvert; dv = me->dvert; - for (i=0; itotvert; i++, mv++, dv++) { + for (i = 0; i < me->totvert; i++, mv++, dv++) { if (mv->flag & SELECT) { if (dv->dw && (allverts || (mv->flag & SELECT))) { MDeformWeight *dw = defvert_find_index(dv, def_nr); @@ -1830,17 +1830,17 @@ static void vgroup_active_remove_verts(Object *ob, const int allverts, bDeformGr } } else if (ob->type == OB_LATTICE) { - Lattice *lt= vgroup_edit_lattice(ob); + Lattice *lt = vgroup_edit_lattice(ob); if (lt->dvert) { BPoint *bp; - int i, tot= lt->pntsu*lt->pntsv*lt->pntsw; + int i, tot = lt->pntsu * lt->pntsv * lt->pntsw; - for (i=0, bp= lt->def; idef; i < tot; i++, bp++) { if (allverts || (bp->f1 & SELECT)) { MDeformWeight *dw; - dv= <->dvert[i]; + dv = <->dvert[i]; dw = defvert_find_index(dv, def_nr); defvert_remove_group(dv, dw); /* dw can be NULL */ @@ -1853,7 +1853,7 @@ static void vgroup_active_remove_verts(Object *ob, const int allverts, bDeformGr static void vgroup_delete_edit_mode(Object *ob, bDeformGroup *dg) { int i; - const int dg_index= BLI_findindex(&ob->defbase, dg); + const int dg_index = BLI_findindex(&ob->defbase, dg); assert(dg_index > -1); @@ -1861,32 +1861,32 @@ 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) { - Mesh *me= ob->data; + if (ob->type == OB_MESH) { + Mesh *me = ob->data; BMEditMesh *em = me->edit_btmesh; BMIter iter; BMVert *eve; MDeformVert *dvert; BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) { - dvert= CustomData_bmesh_get(&em->bm->vdata, eve->head.data, CD_MDEFORMVERT); + dvert = CustomData_bmesh_get(&em->bm->vdata, eve->head.data, CD_MDEFORMVERT); if (dvert) - for (i=0; itotweight; i++) + 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) { - Lattice *lt= vgroup_edit_lattice(ob); + else if (ob->type == OB_LATTICE) { + Lattice *lt = vgroup_edit_lattice(ob); BPoint *bp; - MDeformVert *dvert= lt->dvert; + MDeformVert *dvert = lt->dvert; int a, tot; if (dvert) { - tot= lt->pntsu*lt->pntsv*lt->pntsw; - for (a=0, bp= lt->def; atotweight; i++) { + 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) dvert->dw[i].def_nr--; } @@ -1897,26 +1897,26 @@ static void vgroup_delete_edit_mode(Object *ob, bDeformGroup *dg) vgroup_delete_update_users(ob, dg_index + 1); /* Remove the group */ - BLI_freelinkN (&ob->defbase, dg); + BLI_freelinkN(&ob->defbase, dg); /* Update the active deform index if necessary */ if (ob->actdef > dg_index) ob->actdef--; if (ob->actdef < 1 && ob->defbase.first) - ob->actdef= 1; + ob->actdef = 1; /* remove all dverts */ if (ob->defbase.first == NULL) { - if (ob->type==OB_MESH) { - Mesh *me= ob->data; + if (ob->type == OB_MESH) { + Mesh *me = ob->data; CustomData_free_layer_active(&me->vdata, CD_MDEFORMVERT, me->totvert); - me->dvert= NULL; + me->dvert = NULL; } - else if (ob->type==OB_LATTICE) { - Lattice *lt= vgroup_edit_lattice(ob); + else if (ob->type == OB_LATTICE) { + Lattice *lt = vgroup_edit_lattice(ob); if (lt->dvert) { MEM_freeN(lt->dvert); - lt->dvert= NULL; + lt->dvert = NULL; } } } @@ -1927,7 +1927,7 @@ static int vgroup_object_in_edit_mode(Object *ob) if (ob->type == OB_MESH) return (BMEdit_FromObject(ob) != NULL); else if (ob->type == OB_LATTICE) - return (((Lattice*)ob->data)->editlatt != NULL); + return (((Lattice *)ob->data)->editlatt != NULL); return 0; } @@ -1946,7 +1946,7 @@ 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); + bDeformGroup *dg = BLI_findlink(&ob->defbase, ob->actdef - 1); if (!dg) return; @@ -1959,16 +1959,16 @@ static void vgroup_delete(Object *ob) static void vgroup_delete_all(Object *ob) { /* Remove all DVerts */ - if (ob->type==OB_MESH) { - Mesh *me= ob->data; + if (ob->type == OB_MESH) { + Mesh *me = ob->data; CustomData_free_layer_active(&me->vdata, CD_MDEFORMVERT, me->totvert); - me->dvert= NULL; + me->dvert = NULL; } - else if (ob->type==OB_LATTICE) { - Lattice *lt= vgroup_edit_lattice(ob); + else if (ob->type == OB_LATTICE) { + Lattice *lt = vgroup_edit_lattice(ob); if (lt->dvert) { MEM_freeN(lt->dvert); - lt->dvert= NULL; + lt->dvert = NULL; } } @@ -1976,20 +1976,20 @@ static void vgroup_delete_all(Object *ob) BLI_freelistN(&ob->defbase); /* Fix counters/indices */ - ob->actdef= 0; + ob->actdef = 0; } /* only in editmode */ static void vgroup_assign_verts(Object *ob, const float weight) { MDeformVert *dv; - const int def_nr= ob->actdef-1; + const int def_nr = ob->actdef - 1; if (!BLI_findlink(&ob->defbase, def_nr)) return; if (ob->type == OB_MESH) { - Mesh *me= ob->data; + Mesh *me = ob->data; if (me->edit_btmesh) { BMEditMesh *em = me->edit_btmesh; @@ -2003,10 +2003,10 @@ static void vgroup_assign_verts(Object *ob, const float weight) BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) { if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) { MDeformWeight *dw; - dv= CustomData_bmesh_get(&em->bm->vdata, eve->head.data, CD_MDEFORMVERT); /* can be NULL */ - dw= defvert_verify_index(dv, def_nr); + dv = CustomData_bmesh_get(&em->bm->vdata, eve->head.data, CD_MDEFORMVERT); /* can be NULL */ + dw = defvert_verify_index(dv, def_nr); if (dw) { - dw->weight= weight; + dw->weight = weight; } } } @@ -2023,35 +2023,35 @@ static void vgroup_assign_verts(Object *ob, const float weight) mv = me->mvert; dv = me->dvert; - for (i=0; itotvert; i++, mv++, dv++) { + for (i = 0; i < me->totvert; i++, mv++, dv++) { if (mv->flag & SELECT) { MDeformWeight *dw; - dw= defvert_verify_index(dv, def_nr); + dw = defvert_verify_index(dv, def_nr); if (dw) { - dw->weight= weight; + dw->weight = weight; } } } } } else if (ob->type == OB_LATTICE) { - Lattice *lt= vgroup_edit_lattice(ob); + 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; + dv = lt->dvert; - tot= lt->pntsu*lt->pntsv*lt->pntsw; - for (a=0, bp= lt->def; apntsu * lt->pntsv * lt->pntsw; + for (a = 0, bp = lt->def; a < tot; a++, bp++, dv++) { if (bp->f1 & SELECT) { MDeformWeight *dw; - dw= defvert_verify_index(dv, def_nr); + dw = defvert_verify_index(dv, def_nr); if (dw) { - dw->weight= weight; + dw->weight = weight; } } } @@ -2067,7 +2067,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); } } @@ -2076,15 +2076,15 @@ static void vgroup_remove_verts(Object *ob, int allverts) static int vertex_group_poll(bContext *C) { - Object *ob= ED_object_context(C); - ID *data= (ob)? ob->data: NULL; + Object *ob = ED_object_context(C); + ID *data = (ob) ? ob->data : NULL; return (ob && !ob->id.lib && OB_TYPE_SUPPORT_VGROUP(ob->type) && data && !data->lib); } -static int UNUSED_FUNCTION(vertex_group_poll_edit)(bContext *C) +static int UNUSED_FUNCTION(vertex_group_poll_edit) (bContext * C) { - Object *ob= ED_object_context(C); - ID *data= (ob)? ob->data: NULL; + Object *ob = ED_object_context(C); + ID *data = (ob) ? ob->data : NULL; if (!(ob && !ob->id.lib && data && !data->lib)) return 0; @@ -2095,24 +2095,24 @@ static int UNUSED_FUNCTION(vertex_group_poll_edit)(bContext *C) /* editmode _or_ weight paint vertex sel */ static int vertex_group_poll_edit_or_wpaint_vert_select(bContext *C) { - Object *ob= ED_object_context(C); - ID *data= (ob)? ob->data: NULL; + Object *ob = ED_object_context(C); + ID *data = (ob) ? ob->data : NULL; if (!(ob && !ob->id.lib && data && !data->lib)) return 0; - return ( vgroup_object_in_edit_mode(ob) || - vgroup_object_in_wpaint_vert_select(ob) ); + return (vgroup_object_in_edit_mode(ob) || + vgroup_object_in_wpaint_vert_select(ob) ); } static int vertex_group_add_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *ob= ED_object_context(C); + Object *ob = ED_object_context(C); ED_vgroup_add(ob); DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_GEOM|ND_DATA, ob->data); - WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data); + WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); return OPERATOR_FINISHED; } @@ -2128,12 +2128,12 @@ void OBJECT_OT_vertex_group_add(wmOperatorType *ot) ot->exec = vertex_group_add_exec; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } static int vertex_group_remove_exec(bContext *C, wmOperator *op) { - Object *ob= ED_object_context(C); + Object *ob = ED_object_context(C); if (RNA_boolean_get(op->ptr, "all")) vgroup_delete_all(ob); @@ -2141,8 +2141,8 @@ static int vertex_group_remove_exec(bContext *C, wmOperator *op) vgroup_delete(ob); DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_GEOM|ND_DATA, ob->data); - WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data); + WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); return OPERATOR_FINISHED; } @@ -2161,7 +2161,7 @@ void OBJECT_OT_vertex_group_remove(wmOperatorType *ot) /* redo operator will fail in this case because vertex groups aren't stored * in local edit mode stack and toggling "all" property will lead to * all groups deleted without way to restore them (see [#29527], sergey) */ - ot->flag = /*OPTYPE_REGISTER|*/OPTYPE_UNDO; + ot->flag = /*OPTYPE_REGISTER|*/ OPTYPE_UNDO; /* properties */ RNA_def_boolean(ot->srna, "all", 0, "All", "Remove from all vertex groups"); @@ -2169,15 +2169,15 @@ void OBJECT_OT_vertex_group_remove(wmOperatorType *ot) static int vertex_group_assign_exec(bContext *C, wmOperator *op) { - ToolSettings *ts= CTX_data_tool_settings(C); - Object *ob= ED_object_context(C); + ToolSettings *ts = CTX_data_tool_settings(C); + Object *ob = ED_object_context(C); if (RNA_boolean_get(op->ptr, "new")) ED_vgroup_add(ob); vgroup_assign_verts(ob, ts->vgroup_weight); DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_GEOM|ND_DATA, ob->data); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data); return OPERATOR_FINISHED; } @@ -2196,7 +2196,7 @@ void OBJECT_OT_vertex_group_assign(wmOperatorType *ot) /* redo operator will fail in this case because vertex group assignment * isn't stored in local edit mode stack and toggling "new" property will * lead to creating plenty of new vertex groups (see [#29527], sergey) */ - ot->flag = /*OPTYPE_REGISTER|*/OPTYPE_UNDO; + ot->flag = /*OPTYPE_REGISTER|*/ OPTYPE_UNDO; /* properties */ RNA_def_boolean(ot->srna, "new", 0, "New", "Assign vertex to new vertex group"); @@ -2204,12 +2204,12 @@ void OBJECT_OT_vertex_group_assign(wmOperatorType *ot) static int vertex_group_remove_from_exec(bContext *C, wmOperator *op) { - Object *ob= ED_object_context(C); + Object *ob = ED_object_context(C); if (RNA_boolean_get(op->ptr, "all")) vgroup_remove_verts(ob, 0); else { - bDeformGroup *dg= BLI_findlink(&ob->defbase, ob->actdef - 1); + bDeformGroup *dg = BLI_findlink(&ob->defbase, ob->actdef - 1); if (dg == NULL) { return OPERATOR_CANCELLED; @@ -2219,7 +2219,7 @@ static int vertex_group_remove_from_exec(bContext *C, wmOperator *op) } DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_GEOM|ND_DATA, ob->data); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data); return OPERATOR_FINISHED; } @@ -2238,7 +2238,7 @@ void OBJECT_OT_vertex_group_remove_from(wmOperatorType *ot) /* redo operator will fail in this case because vertex groups assignment * isn't stored in local edit mode stack and toggling "all" property will lead to * removing vertices from all groups (see [#29527], sergey) */ - ot->flag = /*OPTYPE_REGISTER|*/OPTYPE_UNDO; + ot->flag = /*OPTYPE_REGISTER|*/ OPTYPE_UNDO; /* properties */ RNA_def_boolean(ot->srna, "all", 0, "All", "Remove from all vertex groups"); @@ -2246,13 +2246,13 @@ void OBJECT_OT_vertex_group_remove_from(wmOperatorType *ot) static int vertex_group_select_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *ob= ED_object_context(C); + Object *ob = ED_object_context(C); if (!ob || ob->id.lib) return OPERATOR_CANCELLED; vgroup_select_verts(ob, 1); - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, ob->data); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, ob->data); return OPERATOR_FINISHED; } @@ -2268,15 +2268,15 @@ void OBJECT_OT_vertex_group_select(wmOperatorType *ot) ot->exec = vertex_group_select_exec; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } static int vertex_group_deselect_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *ob= ED_object_context(C); + Object *ob = ED_object_context(C); vgroup_select_verts(ob, 0); - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, ob->data); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, ob->data); return OPERATOR_FINISHED; } @@ -2292,17 +2292,17 @@ void OBJECT_OT_vertex_group_deselect(wmOperatorType *ot) ot->exec = vertex_group_deselect_exec; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } static int vertex_group_copy_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *ob= ED_object_context(C); + Object *ob = ED_object_context(C); vgroup_duplicate(ob); DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); - WM_event_add_notifier(C, NC_GEOM|ND_DATA, ob->data); + WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data); return OPERATOR_FINISHED; } @@ -2318,21 +2318,21 @@ void OBJECT_OT_vertex_group_copy(wmOperatorType *ot) ot->exec = vertex_group_copy_exec; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } static int vertex_group_levels_exec(bContext *C, wmOperator *op) { - Object *ob= ED_object_context(C); + Object *ob = ED_object_context(C); - float offset= RNA_float_get(op->ptr,"offset"); - float gain= RNA_float_get(op->ptr,"gain"); + float offset = RNA_float_get(op->ptr, "offset"); + float gain = RNA_float_get(op->ptr, "gain"); vgroup_levels(ob, offset, gain); DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); - WM_event_add_notifier(C, NC_GEOM|ND_DATA, ob->data); + WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data); return OPERATOR_FINISHED; } @@ -2348,7 +2348,7 @@ void OBJECT_OT_vertex_group_levels(wmOperatorType *ot) ot->exec = vertex_group_levels_exec; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_float(ot->srna, "offset", 0.f, -1.0, 1.0, "Offset", "Value to add to weights", -1.0f, 1.f); RNA_def_float(ot->srna, "gain", 1.f, 0.f, FLT_MAX, "Gain", "Value to multiply weights by", 0.0f, 10.f); @@ -2356,13 +2356,13 @@ void OBJECT_OT_vertex_group_levels(wmOperatorType *ot) static int vertex_group_normalize_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *ob= ED_object_context(C); + Object *ob = ED_object_context(C); vgroup_normalize(ob); DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); - WM_event_add_notifier(C, NC_GEOM|ND_DATA, ob->data); + WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data); return OPERATOR_FINISHED; } @@ -2378,19 +2378,19 @@ void OBJECT_OT_vertex_group_normalize(wmOperatorType *ot) ot->exec = vertex_group_normalize_exec; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } static int vertex_group_normalize_all_exec(bContext *C, wmOperator *op) { - Object *ob= ED_object_context(C); - int lock_active= RNA_boolean_get(op->ptr,"lock_active"); + Object *ob = ED_object_context(C); + int lock_active = RNA_boolean_get(op->ptr, "lock_active"); vgroup_normalize_all(ob, lock_active); DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); - WM_event_add_notifier(C, NC_GEOM|ND_DATA, ob->data); + WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data); return OPERATOR_FINISHED; } @@ -2406,7 +2406,7 @@ void OBJECT_OT_vertex_group_normalize_all(wmOperatorType *ot) ot->exec = vertex_group_normalize_all_exec; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_boolean(ot->srna, "lock_active", TRUE, "Lock Active", "Keep the values of the active group while normalizing others"); @@ -2414,16 +2414,16 @@ void OBJECT_OT_vertex_group_normalize_all(wmOperatorType *ot) static int vertex_group_fix_exec(bContext *C, wmOperator *op) { - Object *ob= CTX_data_active_object(C); - Scene *scene= CTX_data_scene(C); + Object *ob = CTX_data_active_object(C); + Scene *scene = CTX_data_scene(C); - float distToBe= RNA_float_get(op->ptr, "dist"); - float strength= RNA_float_get(op->ptr, "strength"); - float cp= RNA_float_get(op->ptr, "accuracy"); - ModifierData *md= ob->modifiers.first; + float distToBe = RNA_float_get(op->ptr, "dist"); + float strength = RNA_float_get(op->ptr, "strength"); + float cp = RNA_float_get(op->ptr, "accuracy"); + ModifierData *md = ob->modifiers.first; while (md) { - if (md->type == eModifierType_Mirror && (md->mode&eModifierMode_Realtime)) { + if (md->type == eModifierType_Mirror && (md->mode & eModifierMode_Realtime)) { break; } md = md->next; @@ -2436,8 +2436,8 @@ static int vertex_group_fix_exec(bContext *C, wmOperator *op) vgroup_fix(scene, ob, distToBe, strength, cp); DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); - WM_event_add_notifier(C, NC_GEOM|ND_DATA, ob->data); + WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data); return OPERATOR_FINISHED; } @@ -2448,14 +2448,14 @@ void OBJECT_OT_vertex_group_fix(wmOperatorType *ot) ot->name = "Fix Vertex Group Deform"; ot->idname = "OBJECT_OT_vertex_group_fix"; ot->description = "Modify the position of selected vertices by changing only their respective " - "groups' weights (this tool may be slow for many vertices)"; + "groups' weights (this tool may be slow for many vertices)"; /* api callbacks */ ot->poll = vertex_group_poll; ot->exec = vertex_group_fix_exec; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_float(ot->srna, "dist", 0.0f, -FLT_MAX, FLT_MAX, "Distance", "The distance to move to", -10.0f, 10.0f); RNA_def_float(ot->srna, "strength", 1.f, -2.0f, FLT_MAX, "Strength", "The distance moved can be changed by this multiplier", -2.0f, 2.0f); @@ -2466,7 +2466,7 @@ void OBJECT_OT_vertex_group_fix(wmOperatorType *ot) static int vertex_group_lock_exec(bContext *C, wmOperator *op) { - Object *ob= CTX_data_active_object(C); + Object *ob = CTX_data_active_object(C); int action = RNA_enum_get(op->ptr, "action"); @@ -2486,21 +2486,21 @@ void OBJECT_OT_vertex_group_lock(wmOperatorType *ot) ot->exec = vertex_group_lock_exec; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; WM_operator_properties_select_all(ot); } static int vertex_group_invert_exec(bContext *C, wmOperator *op) { - Object *ob= ED_object_context(C); - int auto_assign= RNA_boolean_get(op->ptr,"auto_assign"); - int auto_remove= RNA_boolean_get(op->ptr,"auto_remove"); + Object *ob = ED_object_context(C); + int auto_assign = RNA_boolean_get(op->ptr, "auto_assign"); + int auto_remove = RNA_boolean_get(op->ptr, "auto_remove"); vgroup_invert(ob, auto_assign, auto_remove); DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); - WM_event_add_notifier(C, NC_GEOM|ND_DATA, ob->data); + WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data); return OPERATOR_FINISHED; } @@ -2516,7 +2516,7 @@ void OBJECT_OT_vertex_group_invert(wmOperatorType *ot) ot->exec = vertex_group_invert_exec; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_boolean(ot->srna, "auto_assign", TRUE, "Add Weights", "Add verts from groups that have zero weight before inverting"); @@ -2533,8 +2533,8 @@ static int vertex_group_blend_exec(bContext *C, wmOperator *op) vgroup_blend(ob, fac); DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); - WM_event_add_notifier(C, NC_GEOM|ND_DATA, ob->data); + WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data); return OPERATOR_FINISHED; } @@ -2543,7 +2543,7 @@ static int vertex_group_blend_exec(bContext *C, wmOperator *op) static int vertex_group_blend_poll(bContext *C) { Object *ob = ED_object_context(C); - ID *data = (ob) ? ob->data: NULL; + ID *data = (ob) ? ob->data : NULL; if (!(ob && !ob->id.lib && data && !data->lib)) return FALSE; @@ -2580,7 +2580,7 @@ void OBJECT_OT_vertex_group_blend(wmOperatorType *ot) ot->exec = vertex_group_blend_exec; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; prop = RNA_def_property(ot->srna, "factor", PROP_FLOAT, PROP_FACTOR); RNA_def_property_ui_text(prop, "Factor", ""); @@ -2591,18 +2591,18 @@ void OBJECT_OT_vertex_group_blend(wmOperatorType *ot) static int vertex_group_clean_exec(bContext *C, wmOperator *op) { - Object *ob= ED_object_context(C); + Object *ob = ED_object_context(C); - float limit= RNA_float_get(op->ptr,"limit"); - int all_groups= RNA_boolean_get(op->ptr,"all_groups"); - int keep_single= RNA_boolean_get(op->ptr,"keep_single"); + float limit = RNA_float_get(op->ptr, "limit"); + 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); - else vgroup_clean(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); - WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); - WM_event_add_notifier(C, NC_GEOM|ND_DATA, ob->data); + WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data); return OPERATOR_FINISHED; } @@ -2619,7 +2619,7 @@ void OBJECT_OT_vertex_group_clean(wmOperatorType *ot) ot->exec = vertex_group_clean_exec; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_float(ot->srna, "limit", 0.01f, 0.0f, 1.0, "Limit", "Remove weights under this limit", 0.001f, 0.99f); RNA_def_boolean(ot->srna, "all_groups", FALSE, "All Groups", "Clean all vertex groups"); @@ -2630,16 +2630,16 @@ void OBJECT_OT_vertex_group_clean(wmOperatorType *ot) static int vertex_group_mirror_exec(bContext *C, wmOperator *op) { - Object *ob= ED_object_context(C); + Object *ob = ED_object_context(C); ED_vgroup_mirror(ob, - RNA_boolean_get(op->ptr,"mirror_weights"), - RNA_boolean_get(op->ptr,"flip_group_names"), - RNA_boolean_get(op->ptr,"all_groups")); + RNA_boolean_get(op->ptr, "mirror_weights"), + RNA_boolean_get(op->ptr, "flip_group_names"), + RNA_boolean_get(op->ptr, "all_groups")); DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); - WM_event_add_notifier(C, NC_GEOM|ND_DATA, ob->data); + WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data); return OPERATOR_FINISHED; } @@ -2650,14 +2650,14 @@ void OBJECT_OT_vertex_group_mirror(wmOperatorType *ot) ot->name = "Mirror Vertex Group"; ot->idname = "OBJECT_OT_vertex_group_mirror"; ot->description = "Mirror all vertex groups, flip weights and/or names, editing only selected vertices, " - "flipping when both sides are selected otherwise copy from unselected"; + "flipping when both sides are selected otherwise copy from unselected"; /* api callbacks */ ot->poll = vertex_group_poll; ot->exec = vertex_group_mirror_exec; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_boolean(ot->srna, "mirror_weights", TRUE, "Mirror Weights", "Mirror weights"); @@ -2668,21 +2668,21 @@ void OBJECT_OT_vertex_group_mirror(wmOperatorType *ot) static int vertex_group_copy_to_linked_exec(bContext *C, wmOperator *UNUSED(op)) { - Scene *scene= CTX_data_scene(C); - Object *ob= ED_object_context(C); + Scene *scene = CTX_data_scene(C); + Object *ob = ED_object_context(C); Base *base; - int retval= OPERATOR_CANCELLED; + 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; + base->object->actdef = ob->actdef; DAG_id_tag_update(&base->object->id, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, base->object); - WM_event_add_notifier(C, NC_GEOM|ND_DATA, base->object->data); + WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, base->object); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, base->object->data); retval = OPERATOR_FINISHED; } @@ -2704,19 +2704,19 @@ void OBJECT_OT_vertex_group_copy_to_linked(wmOperatorType *ot) ot->exec = vertex_group_copy_to_linked_exec; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } static int vertex_group_copy_to_selected_exec(bContext *C, wmOperator *op) { - Object *obact= ED_object_context(C); - int change= 0; - int fail= 0; + Object *obact = ED_object_context(C); + int change = 0; + int fail = 0; - CTX_DATA_BEGIN (C, Object*, ob, selected_editable_objects) { + CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) { if (obact != ob) { if (ED_vgroup_copy_array(ob, obact)) change++; - else fail++; + else fail++; } } CTX_DATA_END; @@ -2743,47 +2743,48 @@ void OBJECT_OT_vertex_group_copy_to_selected(wmOperatorType *ot) ot->exec = vertex_group_copy_to_selected_exec; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } -static EnumPropertyItem vgroup_items[]= { - {0, NULL, 0, NULL, NULL}}; +static EnumPropertyItem vgroup_items[] = { + {0, NULL, 0, NULL, NULL} +}; static int set_active_group_exec(bContext *C, wmOperator *op) { - Object *ob= ED_object_context(C); - int nr= RNA_enum_get(op->ptr, "group"); + Object *ob = ED_object_context(C); + int nr = RNA_enum_get(op->ptr, "group"); - BLI_assert(nr+1 >= 0); - ob->actdef= nr+1; + BLI_assert(nr + 1 >= 0); + ob->actdef = nr + 1; DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_GEOM|ND_DATA, ob); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob); return OPERATOR_FINISHED; } static EnumPropertyItem *vgroup_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), int *free) { - Object *ob= ED_object_context(C); + Object *ob = ED_object_context(C); EnumPropertyItem tmp = {0, "", 0, "", ""}; - EnumPropertyItem *item= NULL; + EnumPropertyItem *item = NULL; bDeformGroup *def; - int a, totitem= 0; + int a, totitem = 0; if (!ob) return vgroup_items; - for (a=0, def=ob->defbase.first; def; def=def->next, a++) { - tmp.value= a; - tmp.icon= ICON_GROUP_VERTEX; - tmp.identifier= def->name; - tmp.name= def->name; + for (a = 0, def = ob->defbase.first; def; def = def->next, a++) { + tmp.value = a; + tmp.icon = ICON_GROUP_VERTEX; + tmp.identifier = def->name; + tmp.name = def->name; RNA_enum_item_add(&item, &totitem, &tmp); } RNA_enum_item_end(&item, &totitem); - *free= 1; + *free = 1; return item; } @@ -2803,10 +2804,10 @@ void OBJECT_OT_vertex_group_set_active(wmOperatorType *ot) ot->invoke = WM_menu_invoke; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ - prop= RNA_def_enum(ot->srna, "group", vgroup_items, 0, "Group", "Vertex group to set as active"); + prop = RNA_def_enum(ot->srna, "group", vgroup_items, 0, "Group", "Vertex group to set as active"); RNA_def_enum_funcs(prop, vgroup_itemf); ot->prop = prop; } @@ -2817,11 +2818,11 @@ static char *vgroup_init_remap(Object *ob) { bDeformGroup *def; int defbase_tot = BLI_countlist(&ob->defbase); - char *name_array= MEM_mallocN(MAX_VGROUP_NAME * sizeof(char) * defbase_tot, "sort vgroups"); + char *name_array = MEM_mallocN(MAX_VGROUP_NAME * sizeof(char) * defbase_tot, "sort vgroups"); char *name; - name= name_array; - for (def = ob->defbase.first; def; def=def->next) { + name = name_array; + for (def = ob->defbase.first; def; def = def->next) { BLI_strncpy(name, def->name, MAX_VGROUP_NAME); name += MAX_VGROUP_NAME; } @@ -2831,33 +2832,33 @@ static char *vgroup_init_remap(Object *ob) static int vgroup_do_remap(Object *ob, char *name_array, wmOperator *op) { - MDeformVert *dvert= NULL; + MDeformVert *dvert = NULL; bDeformGroup *def; int defbase_tot = BLI_countlist(&ob->defbase); /* needs a dummy index at the start*/ - int *sort_map_update= MEM_mallocN(sizeof(int) * (defbase_tot + 1), "sort vgroups"); - int *sort_map= sort_map_update + 1; + int *sort_map_update = MEM_mallocN(sizeof(int) * (defbase_tot + 1), "sort vgroups"); + int *sort_map = sort_map_update + 1; char *name; int i; - name= name_array; - for (def= ob->defbase.first, i=0; def; def=def->next, i++) { - sort_map[i]= BLI_findstringindex(&ob->defbase, name, offsetof(bDeformGroup, name)); + name = name_array; + 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->type == OB_MESH) { BMEditMesh *em = BMEdit_FromObject(ob); BMIter iter; BMVert *eve; BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) { - dvert= CustomData_bmesh_get(&em->bm->vdata, eve->head.data, CD_MDEFORMVERT); + dvert = CustomData_bmesh_get(&em->bm->vdata, eve->head.data, CD_MDEFORMVERT); if (dvert && dvert->totweight) { defvert_remap(dvert, sort_map, defbase_tot); } @@ -2870,7 +2871,7 @@ static int vgroup_do_remap(Object *ob, char *name_array, wmOperator *op) } } else { - int dvert_tot=0; + int dvert_tot = 0; ED_vgroup_give_array(ob->data, &dvert, &dvert_tot); @@ -2883,14 +2884,14 @@ static int vgroup_do_remap(Object *ob, char *name_array, wmOperator *op) } /* update users */ - for (i=0; iactdef] >= 0); - ob->actdef= sort_map_update[ob->actdef]; + ob->actdef = sort_map_update[ob->actdef]; MEM_freeN(sort_map_update); @@ -2899,15 +2900,15 @@ static int vgroup_do_remap(Object *ob, char *name_array, wmOperator *op) static int vgroup_sort(void *def_a_ptr, void *def_b_ptr) { - bDeformGroup *def_a= (bDeformGroup *)def_a_ptr; - bDeformGroup *def_b= (bDeformGroup *)def_b_ptr; + bDeformGroup *def_a = (bDeformGroup *)def_a_ptr; + bDeformGroup *def_b = (bDeformGroup *)def_b_ptr; return BLI_natstrcmp(def_a->name, def_b->name); } static int vertex_group_sort_exec(bContext *C, wmOperator *op) { - Object *ob= ED_object_context(C); + Object *ob = ED_object_context(C); char *name_array; int ret; @@ -2922,7 +2923,7 @@ static int vertex_group_sort_exec(bContext *C, wmOperator *op) if (ret != OPERATOR_CANCELLED) { DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_GEOM|ND_DATA, ob); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob); } if (name_array) MEM_freeN(name_array); @@ -2941,15 +2942,15 @@ void OBJECT_OT_vertex_group_sort(wmOperatorType *ot) ot->exec = vertex_group_sort_exec; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } static int vgroup_move_exec(bContext *C, wmOperator *op) { - Object *ob= ED_object_context(C); + Object *ob = ED_object_context(C); bDeformGroup *def; char *name_array; - int dir= RNA_enum_get(op->ptr, "direction"), ret; + int dir = RNA_enum_get(op->ptr, "direction"), ret; def = BLI_findlink(&ob->defbase, ob->actdef - 1); if (!def) { @@ -2977,7 +2978,7 @@ static int vgroup_move_exec(bContext *C, wmOperator *op) if (ret != OPERATOR_CANCELLED) { DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_GEOM|ND_DATA, ob); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob); } return ret; @@ -3000,7 +3001,7 @@ void OBJECT_OT_vertex_group_move(wmOperatorType *ot) ot->exec = vgroup_move_exec; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_enum(ot->srna, "direction", vgroup_slot_move, 0, "Direction", "Direction to move, UP or DOWN"); } -- cgit v1.2.3