Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2019-04-22 02:19:45 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-04-22 12:48:16 +0300
commit620b960d3d8cfd90b9f0df6ba3671c33eccb8309 (patch)
tree64f69db4bf9d44f0a32d1c92b0714bf2dc98ff2d /source/blender/editors/object
parentbba60bb564cf5a16cfcac744d4ba82cf8eba3da9 (diff)
Cleanup: style, use braces for editors
Diffstat (limited to 'source/blender/editors/object')
-rw-r--r--source/blender/editors/object/object_add.c99
-rw-r--r--source/blender/editors/object/object_bake.c36
-rw-r--r--source/blender/editors/object/object_bake_api.c93
-rw-r--r--source/blender/editors/object/object_collection.c57
-rw-r--r--source/blender/editors/object/object_constraint.c216
-rw-r--r--source/blender/editors/object/object_edit.c42
-rw-r--r--source/blender/editors/object/object_facemap_ops.c39
-rw-r--r--source/blender/editors/object/object_gpencil_modifier.c72
-rw-r--r--source/blender/editors/object/object_hook.c78
-rw-r--r--source/blender/editors/object/object_modes.c45
-rw-r--r--source/blender/editors/object/object_modifier.c250
-rw-r--r--source/blender/editors/object/object_relations.c153
-rw-r--r--source/blender/editors/object/object_select.c33
-rw-r--r--source/blender/editors/object/object_shader_fx.c54
-rw-r--r--source/blender/editors/object/object_shapekey.c15
-rw-r--r--source/blender/editors/object/object_transform.c126
-rw-r--r--source/blender/editors/object/object_vgroup.c156
17 files changed, 1043 insertions, 521 deletions
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c
index 7b6f920e59f..87782e895b5 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -216,14 +216,17 @@ void ED_object_base_init_transform(bContext *C, Base *base, const float loc[3],
Scene *scene = CTX_data_scene(C);
Depsgraph *depsgraph = CTX_data_depsgraph(C);
- if (!scene)
+ if (!scene) {
return;
+ }
- if (loc)
+ if (loc) {
copy_v3_v3(ob->loc, loc);
+ }
- if (rot)
+ if (rot) {
copy_v3_v3(ob->rot, rot);
+ }
BKE_object_where_is_calc(depsgraph, scene, ob);
}
@@ -342,11 +345,13 @@ bool ED_object_add_generic_get_opts(bContext *C,
/* Switch to Edit mode? optional prop */
if ((prop = RNA_struct_find_property(op->ptr, "enter_editmode"))) {
bool _enter_editmode;
- if (!enter_editmode)
+ if (!enter_editmode) {
enter_editmode = &_enter_editmode;
+ }
- if (RNA_property_is_set(op->ptr, prop) && enter_editmode)
+ if (RNA_property_is_set(op->ptr, prop) && enter_editmode) {
*enter_editmode = RNA_property_boolean_get(op->ptr, prop);
+ }
else {
*enter_editmode = (U.flag & USER_ADD_EDITMODE) != 0;
RNA_property_boolean_set(op->ptr, prop, *enter_editmode);
@@ -363,8 +368,9 @@ bool ED_object_add_generic_get_opts(bContext *C,
/* Location! */
{
float _loc[3];
- if (!loc)
+ if (!loc) {
loc = _loc;
+ }
if (RNA_struct_property_is_set(op->ptr, "location")) {
RNA_float_get_array(op->ptr, "location", loc);
@@ -379,15 +385,19 @@ bool ED_object_add_generic_get_opts(bContext *C,
{
bool _is_view_aligned;
float _rot[3];
- if (!is_view_aligned)
+ if (!is_view_aligned) {
is_view_aligned = &_is_view_aligned;
- if (!rot)
+ }
+ if (!rot) {
rot = _rot;
+ }
- if (RNA_struct_property_is_set(op->ptr, "rotation"))
+ if (RNA_struct_property_is_set(op->ptr, "rotation")) {
*is_view_aligned = false;
- else if (RNA_struct_property_is_set(op->ptr, "view_align"))
+ }
+ else if (RNA_struct_property_is_set(op->ptr, "view_align")) {
*is_view_aligned = RNA_boolean_get(op->ptr, "view_align");
+ }
else {
*is_view_aligned = (U.flag & USER_ADD_VIEWALIGNED) != 0;
RNA_boolean_set(op->ptr, "view_align", *is_view_aligned);
@@ -397,8 +407,9 @@ bool ED_object_add_generic_get_opts(bContext *C,
ED_object_rotation_from_view(C, rot, view_align_axis);
RNA_float_set_array(op->ptr, "rotation", rot);
}
- else
+ else {
RNA_float_get_array(op->ptr, "rotation", rot);
+ }
}
return true;
@@ -625,15 +636,17 @@ static int effector_add_exec(bContext *C, wmOperator *op)
ED_object_new_primitive_matrix(C, ob, loc, rot, mat);
BLI_addtail(&cu->editnurb->nurbs,
ED_curve_add_nurbs_primitive(C, ob, mat, CU_NURBS | CU_PRIM_PATH, dia));
- if (!enter_editmode)
+ if (!enter_editmode) {
ED_object_editmode_exit(C, EM_FREEDATA);
+ }
}
else {
const char *name = CTX_DATA_(BLT_I18NCONTEXT_ID_OBJECT, "Field");
ob = ED_object_add_type(C, OB_EMPTY, name, loc, rot, false, local_view_bits);
BKE_object_obdata_size_init(ob, dia);
- if (ELEM(type, PFIELD_WIND, PFIELD_VORTEX))
+ if (ELEM(type, PFIELD_WIND, PFIELD_VORTEX)) {
ob->empty_drawtype = OB_SINGLE_ARROW;
+ }
}
ob->pd = BKE_partdeflect_new(type);
@@ -686,8 +699,9 @@ static int object_camera_add_exec(bContext *C, wmOperator *op)
ob = ED_object_add_type(C, OB_CAMERA, NULL, loc, rot, false, local_view_bits);
if (v3d) {
- if (v3d->camera == NULL)
+ if (v3d->camera == NULL) {
v3d->camera = ob;
+ }
if (v3d->scenelock && scene->camera == NULL) {
scene->camera = ob;
}
@@ -797,8 +811,9 @@ static int object_add_text_exec(bContext *C, wmOperator *op)
C, op, 'Z', loc, rot, &enter_editmode, &local_view_bits, 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, NULL, loc, rot, enter_editmode, local_view_bits);
BKE_object_obdata_size_init(obedit, RNA_float_get(op->ptr, "radius"));
@@ -862,8 +877,9 @@ static int object_armature_add_exec(bContext *C, wmOperator *op)
ED_armature_ebone_add_primitive(obedit, dia, view_aligned);
/* userdef */
- if (newob && !enter_editmode)
+ if (newob && !enter_editmode) {
ED_object_editmode_exit(C, EM_FREEDATA);
+ }
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, obedit);
@@ -1246,8 +1262,9 @@ static int collection_instance_add_exec(bContext *C, wmOperator *op)
RNA_float_set_array(op->ptr, "location", loc);
}
}
- else
+ else {
collection = BLI_findlink(&CTX_data_main(C)->collections, RNA_enum_get(op->ptr, "collection"));
+ }
if (!ED_object_add_generic_get_opts(C, op, 'Z', loc, rot, NULL, &local_view_bits, NULL)) {
return OPERATOR_CANCELLED;
@@ -1392,8 +1409,9 @@ static int object_delete_exec(bContext *C, wmOperator *op)
const bool use_global = RNA_boolean_get(op->ptr, "use_global");
uint changed_count = 0;
- if (CTX_data_edit_object(C))
+ if (CTX_data_edit_object(C)) {
return OPERATOR_CANCELLED;
+ }
CTX_DATA_BEGIN (C, Object *, ob, selected_objects) {
const bool is_indirectly_used = BKE_library_ID_is_indirectly_used(bmain, ob);
@@ -2100,8 +2118,9 @@ static int convert_exec(bContext *C, wmOperator *op)
}
}
- for (nu = cu->nurb.first; nu; nu = nu->next)
+ for (nu = cu->nurb.first; nu; nu = nu->next) {
nu->charidx = 0;
+ }
cu->flag &= ~CU_3D;
BKE_curve_curve_dimension_update(cu);
@@ -2166,8 +2185,9 @@ static int convert_exec(bContext *C, wmOperator *op)
me->totcol = mb->totcol;
if (newob->totcol) {
me->mat = MEM_dupallocN(mb->mat);
- for (a = 0; a < newob->totcol; a++)
+ for (a = 0; a < newob->totcol; a++) {
id_us_plus((ID *)me->mat[a]);
+ }
}
convert_ensure_curve_cache(depsgraph, scene, baseob);
@@ -2318,8 +2338,9 @@ static Base *object_add_duplicate_internal(
if (ob->rigidbody_object || ob->rigidbody_constraint) {
Collection *collection;
for (collection = bmain->collections.first; collection; collection = collection->id.next) {
- if (BKE_collection_has_object(collection, ob))
+ if (BKE_collection_has_object(collection, ob)) {
BKE_collection_object_add(bmain, collection, obn);
+ }
}
}
}
@@ -2380,8 +2401,9 @@ static int duplicate_exec(bContext *C, wmOperator *op)
}
/* new object becomes active */
- if (BASACT(view_layer) == base)
+ if (BASACT(view_layer) == base) {
ED_object_base_activate(C, basen);
+ }
if (basen->object->data) {
DEG_id_tag_update(basen->object->data, 0);
@@ -2511,13 +2533,16 @@ static bool join_poll(bContext *C)
{
Object *ob = CTX_data_active_object(C);
- if (!ob || ID_IS_LINKED(ob))
+ if (!ob || ID_IS_LINKED(ob)) {
return 0;
+ }
- if (ELEM(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_ARMATURE, OB_GPENCIL))
+ if (ELEM(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_ARMATURE, OB_GPENCIL)) {
return ED_operator_screenactive(C);
- else
+ }
+ else {
return 0;
+ }
}
static int join_exec(bContext *C, wmOperator *op)
@@ -2540,14 +2565,18 @@ static int join_exec(bContext *C, wmOperator *op)
}
}
- if (ob->type == OB_MESH)
+ if (ob->type == OB_MESH) {
return join_mesh_exec(C, op);
- else if (ELEM(ob->type, OB_CURVE, OB_SURF))
+ }
+ else if (ELEM(ob->type, OB_CURVE, OB_SURF)) {
return join_curve_exec(C, op);
- else if (ob->type == OB_ARMATURE)
+ }
+ else if (ob->type == OB_ARMATURE) {
return join_armature_exec(C, op);
- else if (ob->type == OB_GPENCIL)
+ }
+ else if (ob->type == OB_GPENCIL) {
return ED_gpencil_join_objects_exec(C, op);
+ }
return OPERATOR_CANCELLED;
}
@@ -2573,14 +2602,17 @@ static bool join_shapes_poll(bContext *C)
{
Object *ob = CTX_data_active_object(C);
- if (!ob || ID_IS_LINKED(ob))
+ if (!ob || ID_IS_LINKED(ob)) {
return 0;
+ }
/* only meshes supported at the moment */
- if (ob->type == OB_MESH)
+ if (ob->type == OB_MESH) {
return ED_operator_screenactive(C);
- else
+ }
+ else {
return 0;
+ }
}
static int join_shapes_exec(bContext *C, wmOperator *op)
@@ -2596,8 +2628,9 @@ static int join_shapes_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- if (ob->type == OB_MESH)
+ if (ob->type == OB_MESH) {
return join_mesh_shapes_exec(C, op);
+ }
return OPERATOR_CANCELLED;
}
diff --git a/source/blender/editors/object/object_bake.c b/source/blender/editors/object/object_bake.c
index f3138c5afec..6e2f0dba969 100644
--- a/source/blender/editors/object/object_bake.c
+++ b/source/blender/editors/object/object_bake.c
@@ -196,14 +196,17 @@ static bool multiresbake_check(bContext *C, wmOperator *op)
ok = false;
}
else {
- if (ibuf->rect == NULL && ibuf->rect_float == NULL)
+ if (ibuf->rect == NULL && ibuf->rect_float == NULL) {
ok = false;
+ }
- if (ibuf->rect_float && !(ibuf->channels == 0 || ibuf->channels == 4))
+ if (ibuf->rect_float && !(ibuf->channels == 0 || ibuf->channels == 4)) {
ok = false;
+ }
- if (!ok)
+ if (!ok) {
BKE_report(op->reports, RPT_ERROR, "Baking to unsupported image type");
+ }
}
BKE_image_release_ibuf(ima, ibuf, NULL);
@@ -211,8 +214,9 @@ static bool multiresbake_check(bContext *C, wmOperator *op)
}
}
- if (!ok)
+ if (!ok) {
break;
+ }
}
CTX_DATA_END;
@@ -289,12 +293,15 @@ static void clear_single_image(Image *image, ClearFlag flag)
if ((image->id.tag & LIB_TAG_DOIT) == 0) {
ImBuf *ibuf = BKE_image_acquire_ibuf(image, NULL, NULL);
- if (flag == CLEAR_TANGENT_NORMAL)
+ if (flag == CLEAR_TANGENT_NORMAL) {
IMB_rectfill(ibuf, (ibuf->planes == R_IMF_PLANES_RGBA) ? nor_alpha : nor_solid);
- else if (flag == CLEAR_DISPLACEMENT)
+ }
+ else if (flag == CLEAR_DISPLACEMENT) {
IMB_rectfill(ibuf, (ibuf->planes == R_IMF_PLANES_RGBA) ? disp_alpha : disp_solid);
- else
+ }
+ else {
IMB_rectfill(ibuf, (ibuf->planes == R_IMF_PLANES_RGBA) ? vec_alpha : vec_solid);
+ }
image->id.tag |= LIB_TAG_DOIT;
@@ -332,8 +339,9 @@ static int multiresbake_image_exec_locked(bContext *C, wmOperator *op)
Scene *scene = CTX_data_scene(C);
int objects_baked = 0;
- if (!multiresbake_check(C, op))
+ if (!multiresbake_check(C, op)) {
return OPERATOR_CANCELLED;
+ }
if (scene->r.bake_flag & R_BAKE_CLEAR) { /* clear images */
CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases) {
@@ -396,8 +404,9 @@ static int multiresbake_image_exec_locked(bContext *C, wmOperator *op)
}
CTX_DATA_END;
- if (!objects_baked)
+ if (!objects_baked) {
BKE_report(op->reports, RPT_ERROR, "No objects found to bake from");
+ }
return OPERATOR_FINISHED;
}
@@ -541,8 +550,9 @@ static int multiresbake_image_exec(bContext *C, wmOperator *op)
MultiresBakeJob *bkr;
wmJob *wm_job;
- if (!multiresbake_check(C, op))
+ if (!multiresbake_check(C, op)) {
return OPERATOR_CANCELLED;
+ }
bkr = MEM_callocN(sizeof(MultiresBakeJob), "MultiresBakeJob data");
init_multiresbake_job(C, bkr);
@@ -580,8 +590,9 @@ static int multiresbake_image_exec(bContext *C, wmOperator *op)
static int objects_bake_render_modal(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
{
/* no running blender, remove handler and pass through */
- if (0 == WM_jobs_test(CTX_wm_manager(C), CTX_data_scene(C), WM_JOB_TYPE_OBJECT_BAKE_TEXTURE))
+ if (0 == WM_jobs_test(CTX_wm_manager(C), CTX_data_scene(C), WM_JOB_TYPE_OBJECT_BAKE_TEXTURE)) {
return OPERATOR_FINISHED | OPERATOR_PASS_THROUGH;
+ }
/* running render */
switch (event->type) {
@@ -593,8 +604,9 @@ static int objects_bake_render_modal(bContext *C, wmOperator *UNUSED(op), const
static bool is_multires_bake(Scene *scene)
{
- if (ELEM(scene->r.bake_mode, RE_BAKE_NORMALS, RE_BAKE_DISPLACEMENT, RE_BAKE_AO))
+ if (ELEM(scene->r.bake_mode, RE_BAKE_NORMALS, RE_BAKE_DISPLACEMENT, RE_BAKE_AO)) {
return scene->r.bake_flag & R_BAKE_MULTIRES;
+ }
return 0;
}
diff --git a/source/blender/editors/object/object_bake_api.c b/source/blender/editors/object/object_bake_api.c
index fba5a4e281e..85801dbdd0a 100644
--- a/source/blender/editors/object/object_bake_api.c
+++ b/source/blender/editors/object/object_bake_api.c
@@ -137,8 +137,9 @@ static void bake_progress_update(void *bjv, float progress)
static int bake_modal(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
{
/* no running blender, remove handler and pass through */
- if (0 == WM_jobs_test(CTX_wm_manager(C), CTX_data_scene(C), WM_JOB_TYPE_OBJECT_BAKE))
+ if (0 == WM_jobs_test(CTX_wm_manager(C), CTX_data_scene(C), WM_JOB_TYPE_OBJECT_BAKE)) {
return OPERATOR_FINISHED | OPERATOR_PASS_THROUGH;
+ }
/* running render */
switch (event->type) {
@@ -154,8 +155,9 @@ static int bake_modal(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
* note: this wont check for the escape key being pressed, but doing so isnt threadsafe */
static int bake_break(void *UNUSED(rjv))
{
- if (G.is_break)
+ if (G.is_break) {
return 1;
+ }
return 0;
}
@@ -163,8 +165,9 @@ static void bake_update_image(ScrArea *sa, Image *image)
{
if (sa && sa->spacetype == SPACE_IMAGE) { /* in case the user changed while baking */
SpaceImage *sima = sa->spacedata.first;
- if (sima)
+ if (sima) {
sima->image = image;
+ }
}
}
@@ -185,8 +188,9 @@ static bool write_internal_bake_pixels(Image *image,
ibuf = BKE_image_acquire_ibuf(image, NULL, &lock);
- if (!ibuf)
+ if (!ibuf) {
return false;
+ }
if (margin > 0 || !is_clear) {
mask_buffer = MEM_callocN(sizeof(char) * num_pixels, "Bake Mask");
@@ -202,14 +206,17 @@ static bool write_internal_bake_pixels(Image *image,
from_colorspace = IMB_colormanagement_role_colorspace_name_get(COLOR_ROLE_SCENE_LINEAR);
- if (is_float)
+ if (is_float) {
to_colorspace = IMB_colormanagement_get_float_colorspace(ibuf);
- else
+ }
+ else {
to_colorspace = IMB_colormanagement_get_rect_colorspace(ibuf);
+ }
- if (from_colorspace != to_colorspace)
+ if (from_colorspace != to_colorspace) {
IMB_colormanagement_transform(
buffer, ibuf->x, ibuf->y, ibuf->channels, from_colorspace, to_colorspace, false);
+ }
}
/* populates the ImBuf */
@@ -266,13 +273,15 @@ static bool write_internal_bake_pixels(Image *image,
}
/* margins */
- if (margin > 0)
+ if (margin > 0) {
RE_bake_margin(ibuf, mask_buffer, margin);
+ }
ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID | IB_BITMAPDIRTY;
- if (ibuf->rect_float)
+ if (ibuf->rect_float) {
ibuf->userflags |= IB_RECT_INVALID;
+ }
/* force mipmap recalc */
if (ibuf->mipmap[0]) {
@@ -282,8 +291,9 @@ static bool write_internal_bake_pixels(Image *image,
BKE_image_release_ibuf(image, ibuf, NULL);
- if (mask_buffer)
+ if (mask_buffer) {
MEM_freeN(mask_buffer);
+ }
return true;
}
@@ -319,8 +329,9 @@ static bool write_external_bake_pixels(const char *filepath,
/* create a new ImBuf */
ibuf = IMB_allocImBuf(width, height, im_format->planes, (is_float ? IB_rectfloat : IB_rect));
- if (!ibuf)
+ if (!ibuf) {
return false;
+ }
/* populates the ImBuf */
if (is_float) {
@@ -366,8 +377,9 @@ static bool write_external_bake_pixels(const char *filepath,
RE_bake_mask_fill(pixel_array, num_pixels, mask_buffer);
RE_bake_margin(ibuf, mask_buffer, margin);
- if (mask_buffer)
+ if (mask_buffer) {
MEM_freeN(mask_buffer);
+ }
}
if ((ok = BKE_imbuf_write(ibuf, filepath, im_format))) {
@@ -570,14 +582,16 @@ static bool bake_objects_check(Main *bmain,
if (is_selected_to_active) {
int tot_objects = 0;
- if (!bake_object_check(view_layer, ob, reports))
+ if (!bake_object_check(view_layer, ob, reports)) {
return false;
+ }
for (link = selected_objects->first; link; link = link->next) {
Object *ob_iter = (Object *)link->ptr.data;
- if (ob_iter == ob)
+ if (ob_iter == ob) {
continue;
+ }
if (ELEM(ob_iter->type, OB_MESH, OB_FONT, OB_CURVE, OB_SURF, OB_MBALL) == false) {
BKE_reportf(reports,
@@ -602,8 +616,9 @@ static bool bake_objects_check(Main *bmain,
}
for (link = selected_objects->first; link; link = link->next) {
- if (!bake_object_check(view_layer, link->ptr.data, reports))
+ if (!bake_object_check(view_layer, link->ptr.data, reports)) {
return false;
+ }
}
}
return true;
@@ -847,8 +862,9 @@ static int bake(Render *re,
for (link = selected_objects->first; link; link = link->next) {
Object *ob_iter = link->ptr.data;
- if (ob_iter == ob_low)
+ if (ob_iter == ob_low) {
continue;
+ }
tot_highpoly++;
}
@@ -890,8 +906,9 @@ static int bake(Render *re,
me_low = bake_mesh_new_from_object(depsgraph, bmain, scene, ob_low_eval);
/* populate the pixel array with the face data */
- if ((is_selected_to_active && (ob_cage == NULL) && is_cage) == false)
+ if ((is_selected_to_active && (ob_cage == NULL) && is_cage) == false) {
RE_bake_pixels_populate(me_low, pixel_array_low, num_pixels, &bake_images, uv_layer);
+ }
/* else populate the pixel array with the 'cage' mesh (the smooth version of the mesh) */
if (is_selected_to_active) {
@@ -939,8 +956,9 @@ static int bake(Render *re,
for (link = selected_objects->first; link; link = link->next) {
Object *ob_iter = link->ptr.data;
- if (ob_iter == ob_low)
+ if (ob_iter == ob_low) {
continue;
+ }
/* initialize highpoly_data */
highpoly[i].ob = ob_iter;
@@ -1082,8 +1100,9 @@ static int bake(Render *re,
ob_low_eval->obmat);
BKE_id_free(bmain, me_nores);
- if (md)
+ if (md) {
md->mode = mode;
+ }
}
break;
}
@@ -1193,43 +1212,53 @@ static int bake(Render *re,
}
}
- if (is_save_internal)
+ if (is_save_internal) {
refresh_images(&bake_images);
+ }
cleanup:
if (highpoly) {
int i;
for (i = 0; i < tot_highpoly; i++) {
- if (highpoly[i].me)
+ if (highpoly[i].me) {
BKE_id_free(bmain, highpoly[i].me);
+ }
}
MEM_freeN(highpoly);
}
- if (mmd_low)
+ if (mmd_low) {
mmd_low->flags = mmd_flags_low;
+ }
- if (pixel_array_low)
+ if (pixel_array_low) {
MEM_freeN(pixel_array_low);
+ }
- if (pixel_array_high)
+ if (pixel_array_high) {
MEM_freeN(pixel_array_high);
+ }
- if (bake_images.data)
+ if (bake_images.data) {
MEM_freeN(bake_images.data);
+ }
- if (bake_images.lookup)
+ if (bake_images.lookup) {
MEM_freeN(bake_images.lookup);
+ }
- if (result)
+ if (result) {
MEM_freeN(result);
+ }
- if (me_low)
+ if (me_low) {
BKE_id_free(bmain, me_low);
+ }
- if (me_cage)
+ if (me_cage) {
BKE_id_free(bmain, me_cage);
+ }
DEG_graph_free(depsgraph);
@@ -1492,8 +1521,9 @@ static void bake_startjob(void *bkv, short *UNUSED(stop), short *do_update, floa
bkr->sa,
bkr->uv_layer);
- if (bkr->result == OPERATOR_CANCELLED)
+ if (bkr->result == OPERATOR_CANCELLED) {
return;
+ }
}
}
@@ -1613,8 +1643,9 @@ static int bake_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)
bake_set_props(op, scene);
/* only one render job at a time */
- if (WM_jobs_test(CTX_wm_manager(C), scene, WM_JOB_TYPE_OBJECT_BAKE))
+ if (WM_jobs_test(CTX_wm_manager(C), scene, WM_JOB_TYPE_OBJECT_BAKE)) {
return OPERATOR_CANCELLED;
+ }
bkr = MEM_mallocN(sizeof(BakeAPIRender), "render bake");
diff --git a/source/blender/editors/object/object_collection.c b/source/blender/editors/object/object_collection.c
index e0de4b8faef..54c50db99a5 100644
--- a/source/blender/editors/object/object_collection.c
+++ b/source/blender/editors/object/object_collection.c
@@ -79,8 +79,9 @@ static const EnumPropertyItem *collection_object_active_itemf(bContext *C,
/* if 2 or more collections, add option to add to all collections */
collection = NULL;
- while ((collection = BKE_collection_object_find(bmain, scene, collection, ob)))
+ while ((collection = BKE_collection_object_find(bmain, scene, collection, ob))) {
count++;
+ }
if (count >= 2) {
item_tmp.identifier = item_tmp.name = "All Collections";
@@ -135,19 +136,23 @@ static int objects_add_active_exec(bContext *C, wmOperator *op)
bool is_cycle = false;
bool updated = false;
- if (ob == NULL)
+ if (ob == NULL) {
return OPERATOR_CANCELLED;
+ }
/* now add all selected objects to the collection(s) */
FOREACH_COLLECTION_BEGIN (bmain, scene, Collection *, collection) {
- if (single_collection && collection != single_collection)
+ if (single_collection && collection != single_collection) {
continue;
- if (!BKE_collection_has_object(collection, ob))
+ }
+ if (!BKE_collection_has_object(collection, ob)) {
continue;
+ }
CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases) {
- if (BKE_collection_has_object(collection, base->object))
+ if (BKE_collection_has_object(collection, base->object)) {
continue;
+ }
if (!BKE_collection_object_cyclic_check(bmain, base->object, collection)) {
BKE_collection_object_add(bmain, collection, base->object);
@@ -162,11 +167,13 @@ static int objects_add_active_exec(bContext *C, wmOperator *op)
}
FOREACH_COLLECTION_END;
- if (is_cycle)
+ if (is_cycle) {
BKE_report(op->reports, RPT_WARNING, "Skipped some collections because of cycle detected");
+ }
- if (!updated)
+ if (!updated) {
return OPERATOR_CANCELLED;
+ }
DEG_relations_tag_update(bmain);
WM_event_add_notifier(C, NC_GROUP | NA_EDITED, NULL);
@@ -214,14 +221,16 @@ static int objects_remove_active_exec(bContext *C, wmOperator *op)
bmain, scene, ob, single_collection_index);
bool ok = false;
- if (ob == NULL)
+ if (ob == NULL) {
return OPERATOR_CANCELLED;
+ }
/* Linking to same collection requires its own loop so we can avoid
* looking up the active objects collections each time. */
FOREACH_COLLECTION_BEGIN (bmain, scene, Collection *, collection) {
- if (single_collection && collection != single_collection)
+ if (single_collection && collection != single_collection) {
continue;
+ }
if (BKE_collection_has_object(collection, ob)) {
/* Remove collections from selected objects */
@@ -235,8 +244,9 @@ static int objects_remove_active_exec(bContext *C, wmOperator *op)
}
FOREACH_COLLECTION_END;
- if (!ok)
+ if (!ok) {
BKE_report(op->reports, RPT_ERROR, "Active object contains no collections");
+ }
DEG_relations_tag_update(bmain);
WM_event_add_notifier(C, NC_GROUP | NA_EDITED, NULL);
@@ -314,14 +324,17 @@ static int collection_objects_remove_exec(bContext *C, wmOperator *op)
bmain, scene, ob, single_collection_index);
bool updated = false;
- if (ob == NULL)
+ if (ob == NULL) {
return OPERATOR_CANCELLED;
+ }
FOREACH_COLLECTION_BEGIN (bmain, scene, Collection *, collection) {
- if (single_collection && collection != single_collection)
+ if (single_collection && collection != single_collection) {
continue;
- if (!BKE_collection_has_object(collection, ob))
+ }
+ if (!BKE_collection_has_object(collection, ob)) {
continue;
+ }
/* now remove all selected objects from the collection */
CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases) {
@@ -333,8 +346,9 @@ static int collection_objects_remove_exec(bContext *C, wmOperator *op)
}
FOREACH_COLLECTION_END;
- if (!updated)
+ if (!updated) {
return OPERATOR_CANCELLED;
+ }
DEG_relations_tag_update(bmain);
WM_event_add_notifier(C, NC_GROUP | NA_EDITED, NULL);
@@ -418,8 +432,9 @@ static int collection_add_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob = ED_object_context(C);
Main *bmain = CTX_data_main(C);
- if (ob == NULL)
+ if (ob == NULL) {
return OPERATOR_CANCELLED;
+ }
Collection *collection = BKE_collection_add(bmain, NULL, "Collection");
id_fake_user_set(&collection->id);
@@ -454,8 +469,9 @@ static int collection_link_exec(bContext *C, wmOperator *op)
Object *ob = ED_object_context(C);
Collection *collection = BLI_findlink(&bmain->collections, RNA_enum_get(op->ptr, "collection"));
- if (ELEM(NULL, ob, collection))
+ if (ELEM(NULL, ob, collection)) {
return OPERATOR_CANCELLED;
+ }
/* Early return check, if the object is already in collection
* we could skip all the dependency check and just consider
@@ -517,8 +533,9 @@ static int collection_remove_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob = ED_object_context(C);
Collection *collection = CTX_data_pointer_get_type(C, "collection", &RNA_Collection).data;
- if (!ob || !collection)
+ if (!ob || !collection) {
return OPERATOR_CANCELLED;
+ }
BKE_collection_object_remove(bmain, collection, ob, false);
@@ -550,8 +567,9 @@ static int collection_unlink_exec(bContext *C, wmOperator *UNUSED(op))
Main *bmain = CTX_data_main(C);
Collection *collection = CTX_data_pointer_get_type(C, "collection", &RNA_Collection).data;
- if (!collection)
+ if (!collection) {
return OPERATOR_CANCELLED;
+ }
BKE_id_delete(bmain, collection);
@@ -583,8 +601,9 @@ static int select_grouped_exec(bContext *C, wmOperator *UNUSED(op))
Scene *scene = CTX_data_scene(C);
Collection *collection = CTX_data_pointer_get_type(C, "collection", &RNA_Collection).data;
- if (!collection)
+ if (!collection) {
return OPERATOR_CANCELLED;
+ }
CTX_DATA_BEGIN (C, Base *, base, visible_bases) {
if (((base->flag & BASE_SELECTED) == 0) && ((base->flag & BASE_SELECTABLE) != 0)) {
diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c
index 7a1cf44c0aa..8ae736d42c0 100644
--- a/source/blender/editors/object/object_constraint.c
+++ b/source/blender/editors/object/object_constraint.c
@@ -79,18 +79,21 @@
/* if object in posemode, active bone constraints, else object constraints */
ListBase *get_active_constraints(Object *ob)
{
- if (ob == NULL)
+ if (ob == NULL) {
return NULL;
+ }
if (ob->mode & OB_MODE_POSE) {
bPoseChannel *pchan;
pchan = BKE_pose_channel_active(ob);
- if (pchan)
+ if (pchan) {
return &pchan->constraints;
+ }
}
- else
+ else {
return &ob->constraints;
+ }
return NULL;
}
@@ -99,11 +102,13 @@ ListBase *get_active_constraints(Object *ob)
* and/or also get the posechannel this is from (if applicable) */
ListBase *get_constraint_lb(Object *ob, bConstraint *con, bPoseChannel **r_pchan)
{
- if (r_pchan)
+ if (r_pchan) {
*r_pchan = NULL;
+ }
- if (ELEM(NULL, ob, con))
+ if (ELEM(NULL, ob, con)) {
return NULL;
+ }
/* try object constraints first */
if ((BLI_findindex(&ob->constraints, con) != -1)) {
@@ -120,8 +125,9 @@ ListBase *get_constraint_lb(Object *ob, bConstraint *con, bPoseChannel **r_pchan
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
if ((BLI_findindex(&pchan->constraints, con) != -1)) {
- if (r_pchan)
+ if (r_pchan) {
*r_pchan = pchan;
+ }
return &pchan->constraints;
}
@@ -153,8 +159,9 @@ static void validate_pyconstraint_cb(Main *bmain, void *arg1, void *arg2)
/* exception for no script */
if (index) {
/* innovative use of a for...loop to search */
- for (text = bmain->texts.first, i = 1; text && index != i; i++, text = text->id.next)
+ for (text = bmain->texts.first, i = 1; text && index != i; i++, text = text->id.next) {
;
+ }
}
data->text = text;
}
@@ -173,14 +180,16 @@ static char *buildmenu_pyconstraints(Main *bmain, Text *con_text, int *pyconinde
BLI_dynstr_append(pupds, buf);
/* init active-index first */
- if (con_text == NULL)
+ if (con_text == NULL) {
*pyconindex = 0;
+ }
/* loop through markers, adding them */
for (text = bmain->texts.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)
+ if (text == con_text) {
*pyconindex = i;
+ }
/* only include valid pyconstraint scripts */
if (BPY_is_pyconstraint(text)) {
@@ -189,8 +198,9 @@ static char *buildmenu_pyconstraints(Main *bmain, Text *con_text, int *pyconinde
sprintf(buf, "%%x%d", i);
BLI_dynstr_append(pupds, buf);
- if (text->id.next)
+ if (text->id.next) {
BLI_dynstr_append(pupds, "|");
+ }
}
}
@@ -234,10 +244,12 @@ static void set_constraint_nth_target(bConstraint *con,
num_targets = BLI_listbase_count(&targets);
if (index < 0) {
- if (abs(index) < num_targets)
+ if (abs(index) < num_targets) {
index = num_targets - abs(index);
- else
+ }
+ else {
index = num_targets - 1;
+ }
}
else if (index >= num_targets) {
index = num_targets - 1;
@@ -251,8 +263,9 @@ static void set_constraint_nth_target(bConstraint *con,
}
}
- if (cti->flush_constraint_targets)
+ if (cti->flush_constraint_targets) {
cti->flush_constraint_targets(con, &targets, 0);
+ }
}
}
@@ -338,27 +351,33 @@ static void test_constraint(
bFollowPathConstraint *data = con->data;
/* don't allow track/up axes to be the same */
- if (data->upflag == data->trackflag)
+ if (data->upflag == data->trackflag) {
con->flag |= CONSTRAINT_DISABLE;
- if (data->upflag + 3 == data->trackflag)
+ }
+ if (data->upflag + 3 == data->trackflag) {
con->flag |= CONSTRAINT_DISABLE;
+ }
}
else if (con->type == CONSTRAINT_TYPE_TRACKTO) {
bTrackToConstraint *data = con->data;
/* don't allow track/up axes to be the same */
- if (data->reserved2 == data->reserved1)
+ if (data->reserved2 == data->reserved1) {
con->flag |= CONSTRAINT_DISABLE;
- if (data->reserved2 + 3 == data->reserved1)
+ }
+ if (data->reserved2 + 3 == data->reserved1) {
con->flag |= CONSTRAINT_DISABLE;
+ }
}
else if (con->type == CONSTRAINT_TYPE_LOCKTRACK) {
bLockTrackConstraint *data = con->data;
- if (data->lockflag == data->trackflag)
+ if (data->lockflag == data->trackflag) {
con->flag |= CONSTRAINT_DISABLE;
- if (data->lockflag + 3 == data->trackflag)
+ }
+ if (data->lockflag + 3 == data->trackflag) {
con->flag |= CONSTRAINT_DISABLE;
+ }
}
else if (con->type == CONSTRAINT_TYPE_SPLINEIK) {
bSplineIKConstraint *data = con->data;
@@ -385,17 +404,20 @@ static void test_constraint(
MovieTracking *tracking = &data->clip->tracking;
MovieTrackingObject *tracking_object;
- if (data->object[0])
+ if (data->object[0]) {
tracking_object = BKE_tracking_object_get_named(tracking, data->object);
- else
+ }
+ else {
tracking_object = BKE_tracking_object_get_camera(tracking);
+ }
if (!tracking_object) {
con->flag |= CONSTRAINT_DISABLE;
}
else {
- if (!BKE_tracking_track_get_named(tracking, tracking_object, data->track))
+ if (!BKE_tracking_track_get_named(tracking, tracking_object, data->track)) {
con->flag |= CONSTRAINT_DISABLE;
+ }
}
}
else {
@@ -406,14 +428,16 @@ static void test_constraint(
else if (con->type == CONSTRAINT_TYPE_CAMERASOLVER) {
bCameraSolverConstraint *data = con->data;
- if ((data->flag & CAMERASOLVER_ACTIVECLIP) == 0 && (data->clip == NULL))
+ if ((data->flag & CAMERASOLVER_ACTIVECLIP) == 0 && (data->clip == NULL)) {
con->flag |= CONSTRAINT_DISABLE;
+ }
}
else if (con->type == CONSTRAINT_TYPE_OBJECTSOLVER) {
bObjectSolverConstraint *data = con->data;
- if ((data->flag & CAMERASOLVER_ACTIVECLIP) == 0 && (data->clip == NULL))
+ if ((data->flag & CAMERASOLVER_ACTIVECLIP) == 0 && (data->clip == NULL)) {
con->flag |= CONSTRAINT_DISABLE;
+ }
}
else if (con->type == CONSTRAINT_TYPE_TRANSFORM_CACHE) {
bTransformCacheConstraint *data = con->data;
@@ -494,8 +518,9 @@ static void test_constraint(
}
/* free any temporary targets */
- if (cti->flush_constraint_targets)
+ if (cti->flush_constraint_targets) {
cti->flush_constraint_targets(con, &targets, 0);
+ }
}
}
@@ -513,8 +538,9 @@ static int constraint_type_get(Object *owner, bPoseChannel *pchan)
break;
}
}
- else
+ else {
type = CONSTRAINT_OBTYPE_OBJECT;
+ }
return type;
}
@@ -527,8 +553,9 @@ static void test_constraints(Main *bmain, Object *owner, bPoseChannel *pchan)
ListBase *conlist = NULL;
int type;
- if (owner == NULL)
+ if (owner == NULL) {
return;
+ }
type = constraint_type_get(owner, pchan);
@@ -552,15 +579,17 @@ static void test_constraints(Main *bmain, Object *owner, bPoseChannel *pchan)
void object_test_constraints(Main *bmain, Object *owner)
{
- if (owner->constraints.first)
+ if (owner->constraints.first) {
test_constraints(bmain, owner, NULL);
+ }
if (owner->type == OB_ARMATURE && owner->pose) {
bPoseChannel *pchan;
for (pchan = owner->pose->chanbase.first; pchan; pchan = pchan->next) {
- if (pchan->constraints.first)
+ if (pchan->constraints.first) {
test_constraints(bmain, owner, pchan);
+ }
}
}
}
@@ -653,8 +682,9 @@ static int edit_constraint_invoke_properties(bContext *C, wmOperator *op)
ListBase *list;
if (RNA_struct_property_is_set(op->ptr, "constraint") &&
- RNA_struct_property_is_set(op->ptr, "owner"))
+ RNA_struct_property_is_set(op->ptr, "owner")) {
return 1;
+ }
if (ptr.data) {
con = ptr.data;
@@ -662,10 +692,12 @@ static int edit_constraint_invoke_properties(bContext *C, wmOperator *op)
list = get_constraint_lb(ob, con, NULL);
- if (&ob->constraints == list)
+ if (&ob->constraints == list) {
RNA_enum_set(op->ptr, "owner", EDIT_CONSTRAINT_OWNER_OBJECT);
- else
+ }
+ else {
RNA_enum_set(op->ptr, "owner", EDIT_CONSTRAINT_OWNER_BONE);
+ }
return 1;
}
@@ -687,8 +719,9 @@ static bConstraint *edit_constraint_property_get(wmOperator *op, Object *ob, int
}
else if (owner == EDIT_CONSTRAINT_OWNER_BONE) {
bPoseChannel *pchan = BKE_pose_channel_active(ob);
- if (pchan)
+ if (pchan) {
list = &pchan->constraints;
+ }
else {
#if 0
if (G.debug & G_DEBUG) {
@@ -715,8 +748,9 @@ static bConstraint *edit_constraint_property_get(wmOperator *op, Object *ob, int
}
#endif
- if (con && (type != 0) && (con->type != type))
+ if (con && (type != 0) && (con->type != type)) {
con = NULL;
+ }
return con;
}
@@ -734,8 +768,9 @@ static int stretchto_reset_exec(bContext *C, wmOperator *op)
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)
+ if (data == NULL) {
return OPERATOR_CANCELLED;
+ }
/* just set original length to 0.0, which will cause a reset on next recalc */
data->orglength = 0.0f;
@@ -747,10 +782,12 @@ static int stretchto_reset_exec(bContext *C, wmOperator *op)
static int stretchto_reset_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
- if (edit_constraint_invoke_properties(C, op))
+ if (edit_constraint_invoke_properties(C, op)) {
return stretchto_reset_exec(C, op);
- else
+ }
+ else {
return OPERATOR_CANCELLED;
+ }
}
void CONSTRAINT_OT_stretchto_reset(wmOperatorType *ot)
@@ -780,8 +817,9 @@ static int limitdistance_reset_exec(bContext *C, wmOperator *op)
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)
+ if (data == NULL) {
return OPERATOR_CANCELLED;
+ }
/* just set original length to 0.0, which will cause a reset on next recalc */
data->dist = 0.0f;
@@ -793,10 +831,12 @@ static int limitdistance_reset_exec(bContext *C, wmOperator *op)
static int limitdistance_reset_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
- if (edit_constraint_invoke_properties(C, op))
+ if (edit_constraint_invoke_properties(C, op)) {
return limitdistance_reset_exec(C, op);
- else
+ }
+ else {
return OPERATOR_CANCELLED;
+ }
}
void CONSTRAINT_OT_limitdistance_reset(wmOperatorType *ot)
@@ -938,10 +978,12 @@ static int childof_set_inverse_exec(bContext *C, wmOperator *op)
static int childof_set_inverse_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
- if (edit_constraint_invoke_properties(C, op))
+ if (edit_constraint_invoke_properties(C, op)) {
return childof_set_inverse_exec(C, op);
- else
+ }
+ else {
return OPERATOR_CANCELLED;
+ }
}
void CONSTRAINT_OT_childof_set_inverse(wmOperatorType *ot)
@@ -987,10 +1029,12 @@ static int childof_clear_inverse_exec(bContext *C, wmOperator *op)
static int childof_clear_inverse_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
- if (edit_constraint_invoke_properties(C, op))
+ if (edit_constraint_invoke_properties(C, op)) {
return childof_clear_inverse_exec(C, op);
- else
+ }
+ else {
return OPERATOR_CANCELLED;
+ }
}
void CONSTRAINT_OT_childof_clear_inverse(wmOperatorType *ot)
@@ -1075,8 +1119,9 @@ static int followpath_path_animate_exec(bContext *C, wmOperator *op)
data->followflag |= FOLLOWPATH_STATIC;
/* path needs to be freed */
- if (path)
+ if (path) {
MEM_freeN(path);
+ }
}
/* setup dummy 'generator' modifier here to get 1-1 correspondence still working
@@ -1181,10 +1226,12 @@ static int objectsolver_set_inverse_invoke(bContext *C,
wmOperator *op,
const wmEvent *UNUSED(event))
{
- if (edit_constraint_invoke_properties(C, op))
+ if (edit_constraint_invoke_properties(C, op)) {
return objectsolver_set_inverse_exec(C, op);
- else
+ }
+ else {
return OPERATOR_CANCELLED;
+ }
}
void CONSTRAINT_OT_objectsolver_set_inverse(wmOperatorType *ot)
@@ -1229,10 +1276,12 @@ static int objectsolver_clear_inverse_invoke(bContext *C,
wmOperator *op,
const wmEvent *UNUSED(event))
{
- if (edit_constraint_invoke_properties(C, op))
+ if (edit_constraint_invoke_properties(C, op)) {
return objectsolver_clear_inverse_exec(C, op);
- else
+ }
+ else {
return OPERATOR_CANCELLED;
+ }
}
void CONSTRAINT_OT_objectsolver_clear_inverse(wmOperatorType *ot)
@@ -1262,23 +1311,27 @@ void ED_object_constraint_set_active(Object *ob, bConstraint *con)
/* lets be nice and escape if its active already */
/* NOTE: this assumes that the stack doesn't have other active ones set... */
- if ((lb && con) && (con->flag & CONSTRAINT_ACTIVE))
+ if ((lb && con) && (con->flag & CONSTRAINT_ACTIVE)) {
return;
+ }
BKE_constraints_active_set(lb, con);
}
void ED_object_constraint_update(Main *bmain, Object *ob)
{
- if (ob->pose)
+ if (ob->pose) {
BKE_pose_update_constraint_flags(ob->pose);
+ }
object_test_constraints(bmain, ob);
- if (ob->type == OB_ARMATURE)
+ if (ob->type == OB_ARMATURE) {
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY | ID_RECALC_TRANSFORM);
- else
+ }
+ else {
DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM);
+ }
}
static void object_pose_tag_update(Main *bmain, Object *ob)
@@ -1315,10 +1368,12 @@ void ED_object_constraint_tag_update(Main *bmain, Object *ob, bConstraint *con)
object_test_constraint(bmain, ob, con);
}
- if (ob->type == OB_ARMATURE)
+ if (ob->type == OB_ARMATURE) {
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY | ID_RECALC_TRANSFORM);
- else
+ }
+ else {
DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM);
+ }
/* Do Copy-on-Write tag here too, otherwise constraint
* influence/mute buttons in UI have no effect
@@ -1409,10 +1464,12 @@ static int constraint_move_down_exec(bContext *C, wmOperator *op)
static int constraint_move_down_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
- if (edit_constraint_invoke_properties(C, op))
+ if (edit_constraint_invoke_properties(C, op)) {
return constraint_move_down_exec(C, op);
- else
+ }
+ else {
return OPERATOR_CANCELLED;
+ }
}
void CONSTRAINT_OT_move_down(wmOperatorType *ot)
@@ -1457,10 +1514,12 @@ static int constraint_move_up_exec(bContext *C, wmOperator *op)
static int constraint_move_up_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
- if (edit_constraint_invoke_properties(C, op))
+ if (edit_constraint_invoke_properties(C, op)) {
return constraint_move_up_exec(C, op);
- else
+ }
+ else {
return OPERATOR_CANCELLED;
+ }
}
void CONSTRAINT_OT_move_up(wmOperatorType *ot)
@@ -1772,10 +1831,12 @@ static bool get_new_constraint_target(
/* since by default, IK targets the tip of the last bone, use the tip of the active PoseChannel
* if adding a target for an IK Constraint
*/
- if (con_type == CONSTRAINT_TYPE_KINEMATIC)
+ if (con_type == CONSTRAINT_TYPE_KINEMATIC) {
mul_v3_m4v3(obt->loc, obact->obmat, pchanact->pose_tail);
- else
+ }
+ else {
mul_v3_m4v3(obt->loc, obact->obmat, pchanact->pose_head);
+ }
}
else {
copy_v3_v3(obt->loc, obact->obmat[3]);
@@ -1829,10 +1890,12 @@ static int constraint_add_exec(
/* Create a new constraint of the type required,
* and add it to the active/given constraints list. */
- if (pchan)
+ if (pchan) {
con = BKE_constraint_add_for_pose(ob, pchan, NULL, type);
- else
+ }
+ else {
con = BKE_constraint_add_for_object(ob, NULL, type);
+ }
/* get the first selected object/bone, and make that the target
* - apart from the buttons-window add buttons, we shouldn't add in this way
@@ -1846,10 +1909,12 @@ static int constraint_add_exec(
/* Method of setting target depends on the type of target we've got - by default,
* just set the first target (distinction here is only for multiple-targeted constraints).
*/
- if (tar_pchan)
+ if (tar_pchan) {
set_constraint_nth_target(con, tar_ob, tar_pchan->name, 0);
- else
+ }
+ else {
set_constraint_nth_target(con, tar_ob, "", 0);
+ }
}
}
@@ -1884,8 +1949,9 @@ static int constraint_add_exec(
/* make sure all settings are valid - similar to above checks, but sometimes can be wrong */
object_test_constraints(bmain, ob);
- if (pchan)
+ if (pchan) {
BKE_pose_update_constraint_flags(ob->pose);
+ }
/* force depsgraph to get recalculated since new relationships added */
DEG_relations_tag_update(bmain);
@@ -1900,8 +1966,9 @@ static int constraint_add_exec(
}
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY | ID_RECALC_TRANSFORM);
}
- else
+ else {
DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM);
+ }
/* notifiers for updates */
WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT | NA_ADDED, ob);
@@ -1926,8 +1993,9 @@ static int object_constraint_add_exec(bContext *C, wmOperator *op)
/* hack: set constraint targets from selected objects in context is allowed when
* operator name included 'with_targets', since the menu doesn't allow multiple properties
*/
- if (strstr(op->idname, "with_targets"))
+ if (strstr(op->idname, "with_targets")) {
with_targets = 1;
+ }
return constraint_add_exec(C, op, ob, &ob->constraints, type, with_targets);
}
@@ -1947,8 +2015,9 @@ static int pose_constraint_add_exec(bContext *C, wmOperator *op)
/* hack: set constraint targets from selected objects in context is allowed when
* operator name included 'with_targets', since the menu doesn't allow multiple properties
*/
- if (strstr(op->idname, "with_targets"))
+ if (strstr(op->idname, "with_targets")) {
with_targets = 1;
+ }
return constraint_add_exec(C, op, ob, get_active_constraints(ob), type, with_targets);
}
@@ -2059,8 +2128,9 @@ static int pose_ik_add_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED
/* bone must not have any constraints already */
for (con = pchan->constraints.first; con; con = con->next) {
- if (con->type == CONSTRAINT_TYPE_KINEMATIC)
+ if (con->type == CONSTRAINT_TYPE_KINEMATIC) {
break;
+ }
}
if (con) {
BKE_report(op->reports, RPT_ERROR, "Bone already has an IK constraint");
@@ -2076,12 +2146,14 @@ static int pose_ik_add_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED
/* bone target, or object target?
* - the only thing that matters is that we want a target...
*/
- if (tar_pchan)
+ if (tar_pchan) {
uiItemBooleanO(
layout, IFACE_("To Active Bone"), ICON_NONE, "POSE_OT_ik_add", "with_targets", 1);
- else
+ }
+ else {
uiItemBooleanO(
layout, IFACE_("To Active Object"), ICON_NONE, "POSE_OT_ik_add", "with_targets", 1);
+ }
}
else {
/* we have a choice of adding to a new empty, or not setting any target (targetless IK) */
diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c
index 4e532b0ab41..95737453777 100644
--- a/source/blender/editors/object/object_edit.c
+++ b/source/blender/editors/object/object_edit.c
@@ -139,8 +139,9 @@ Object *ED_object_active_context(bContext *C)
Object *ob = NULL;
if (C) {
ob = ED_object_context(C);
- if (!ob)
+ if (!ob) {
ob = CTX_data_active_object(C);
+ }
}
return ob;
}
@@ -718,8 +719,9 @@ static bool editmode_toggle_poll(bContext *C)
Object *ob = CTX_data_active_object(C);
/* covers proxies too */
- if (ELEM(NULL, ob, ob->data) || ID_IS_LINKED(ob->data))
+ if (ELEM(NULL, ob, ob->data) || ID_IS_LINKED(ob->data)) {
return 0;
+ }
/* if hidden but in edit mode, we still display */
if ((ob->restrictflag & OB_RESTRICT_VIEW) && !(ob->mode & OB_MODE_EDIT)) {
@@ -857,12 +859,15 @@ static int forcefield_toggle_exec(bContext *C, wmOperator *UNUSED(op))
{
Object *ob = CTX_data_active_object(C);
- if (ob->pd == NULL)
+ if (ob->pd == NULL) {
ob->pd = BKE_partdeflect_new(PFIELD_FORCE);
- else if (ob->pd->forcefield == 0)
+ }
+ else if (ob->pd->forcefield == 0) {
ob->pd->forcefield = PFIELD_FORCE;
- else
+ }
+ else {
ob->pd->forcefield = 0;
+ }
ED_object_check_force_modifiers(CTX_data_main(C), CTX_data_scene(C), ob);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
@@ -935,8 +940,9 @@ static int object_calculate_paths_invoke(bContext *C, wmOperator *op, const wmEv
{
Object *ob = CTX_data_active_object(C);
- if (ob == NULL)
+ if (ob == NULL) {
return OPERATOR_CANCELLED;
+ }
/* set default settings from existing/stored settings */
{
@@ -1032,8 +1038,9 @@ static int object_update_paths_exec(bContext *C, wmOperator *UNUSED(op))
{
Scene *scene = CTX_data_scene(C);
- if (scene == NULL)
+ if (scene == NULL) {
return OPERATOR_CANCELLED;
+ }
/* calculate the paths for objects that have them (and are tagged to get refreshed) */
ED_objects_recalculate_paths(C, scene, false);
@@ -1204,10 +1211,12 @@ static int shade_smooth_exec(bContext *C, wmOperator *op)
cu = ob->data;
for (nu = cu->nurb.first; nu; nu = nu->next) {
- if (!clear)
+ if (!clear) {
nu->flag |= ME_SMOOTH;
- else
+ }
+ else {
nu->flag &= ~ME_SMOOTH;
+ }
}
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
@@ -1218,8 +1227,9 @@ static int shade_smooth_exec(bContext *C, wmOperator *op)
}
CTX_DATA_END;
- if (linked_data)
+ if (linked_data) {
BKE_report(op->reports, RPT_WARNING, "Can't edit linked mesh or curve data");
+ }
return (done) ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
}
@@ -1271,8 +1281,9 @@ static const EnumPropertyItem *object_mode_set_itemsf(bContext *C,
Object *ob;
int totitem = 0;
- if (!C) /* needed for docs */
+ if (!C) { /* needed for docs */
return rna_enum_object_mode_items;
+ }
ob = CTX_data_active_object(C);
if (ob) {
@@ -1320,10 +1331,12 @@ static bool object_mode_set_poll(bContext *C)
* to still work in that case when there's no active object
* so that users can exit editmode this way as per normal.
*/
- if (ED_operator_object_active_editable(C))
+ if (ED_operator_object_active_editable(C)) {
return true;
- else
+ }
+ else {
return (CTX_data_gpencil_data(C) != NULL);
+ }
}
static int object_mode_set_exec(bContext *C, wmOperator *op)
@@ -1354,8 +1367,9 @@ static int object_mode_set_exec(bContext *C, wmOperator *op)
mode = OB_MODE_EDIT_GPENCIL;
}
- if (!ob || !ED_object_mode_compat_test(ob, mode))
+ if (!ob || !ED_object_mode_compat_test(ob, mode)) {
return OPERATOR_PASS_THROUGH;
+ }
if (ob->mode != mode) {
/* we should be able to remove this call, each operator calls */
diff --git a/source/blender/editors/object/object_facemap_ops.c b/source/blender/editors/object/object_facemap_ops.c
index a77cfab031d..0081e18f33c 100644
--- a/source/blender/editors/object/object_facemap_ops.c
+++ b/source/blender/editors/object/object_facemap_ops.c
@@ -56,8 +56,9 @@
void ED_object_facemap_face_add(Object *ob, bFaceMap *fmap, int facenum)
{
int fmap_nr;
- if (GS(((ID *)ob->data)->name) != ID_ME)
+ if (GS(((ID *)ob->data)->name) != ID_ME) {
return;
+ }
/* get the face map number, exit if it can't be found */
fmap_nr = BLI_findindex(&ob->fmaps, fmap);
@@ -67,8 +68,9 @@ void ED_object_facemap_face_add(Object *ob, bFaceMap *fmap, int facenum)
Mesh *me = ob->data;
/* if there's is no facemap layer then create one */
- if ((facemap = CustomData_get_layer(&me->pdata, CD_FACEMAP)) == NULL)
+ if ((facemap = CustomData_get_layer(&me->pdata, CD_FACEMAP)) == NULL) {
facemap = CustomData_add_layer(&me->pdata, CD_FACEMAP, CD_DEFAULT, NULL, me->totpoly);
+ }
facemap[facenum] = fmap_nr;
}
@@ -78,8 +80,9 @@ void ED_object_facemap_face_add(Object *ob, bFaceMap *fmap, int facenum)
void ED_object_facemap_face_remove(Object *ob, bFaceMap *fmap, int facenum)
{
int fmap_nr;
- if (GS(((ID *)ob->data)->name) != ID_ME)
+ if (GS(((ID *)ob->data)->name) != ID_ME) {
return;
+ }
/* get the face map number, exit if it can't be found */
fmap_nr = BLI_findindex(&ob->fmaps, fmap);
@@ -88,8 +91,9 @@ void ED_object_facemap_face_remove(Object *ob, bFaceMap *fmap, int facenum)
int *facemap;
Mesh *me = ob->data;
- if ((facemap = CustomData_get_layer(&me->pdata, CD_FACEMAP)) == NULL)
+ if ((facemap = CustomData_get_layer(&me->pdata, CD_FACEMAP)) == NULL) {
return;
+ }
facemap[facenum] = -1;
}
@@ -114,10 +118,12 @@ static void object_fmap_swap_edit_mode(Object *ob, int num1, int num2)
if (map) {
if (num1 != -1) {
- if (*map == num1)
+ if (*map == num1) {
*map = num2;
- else if (*map == num2)
+ }
+ else if (*map == num2) {
*map = num1;
+ }
}
}
}
@@ -138,10 +144,12 @@ static void object_fmap_swap_object_mode(Object *ob, int num1, int num2)
if (map) {
for (i = 0; i < me->totpoly; i++) {
if (num1 != -1) {
- if (map[i] == num1)
+ if (map[i] == num1) {
map[i] = num2;
- else if (map[i] == num2)
+ }
+ else if (map[i] == num2) {
map[i] = num1;
+ }
}
}
}
@@ -151,10 +159,12 @@ static void object_fmap_swap_object_mode(Object *ob, int num1, int num2)
static void object_facemap_swap(Object *ob, int num1, int num2)
{
- if (BKE_object_is_in_editmode(ob))
+ if (BKE_object_is_in_editmode(ob)) {
object_fmap_swap_edit_mode(ob, num1, num2);
- else
+ }
+ else {
object_fmap_swap_object_mode(ob, num1, num2);
+ }
}
static bool face_map_supported_poll(bContext *C)
@@ -245,8 +255,9 @@ static int face_map_assign_exec(bContext *C, wmOperator *UNUSED(op))
int *map;
int cd_fmap_offset;
- if (!CustomData_has_layer(&em->bm->pdata, CD_FACEMAP))
+ if (!CustomData_has_layer(&em->bm->pdata, CD_FACEMAP)) {
BM_data_layer_add(em->bm, &em->bm->pdata, CD_FACEMAP);
+ }
cd_fmap_offset = CustomData_get_offset(&em->bm->pdata, CD_FACEMAP);
@@ -294,8 +305,9 @@ static int face_map_remove_from_exec(bContext *C, wmOperator *UNUSED(op))
int cd_fmap_offset;
int mapindex = ob->actfmap - 1;
- if (!CustomData_has_layer(&em->bm->pdata, CD_FACEMAP))
+ if (!CustomData_has_layer(&em->bm->pdata, CD_FACEMAP)) {
return OPERATOR_CANCELLED;
+ }
cd_fmap_offset = CustomData_get_offset(&em->bm->pdata, CD_FACEMAP);
@@ -339,8 +351,9 @@ static void fmap_select(Object *ob, bool select)
int cd_fmap_offset;
int mapindex = ob->actfmap - 1;
- if (!CustomData_has_layer(&em->bm->pdata, CD_FACEMAP))
+ if (!CustomData_has_layer(&em->bm->pdata, CD_FACEMAP)) {
BM_data_layer_add(em->bm, &em->bm->pdata, CD_FACEMAP);
+ }
cd_fmap_offset = CustomData_get_offset(&em->bm->pdata, CD_FACEMAP);
diff --git a/source/blender/editors/object/object_gpencil_modifier.c b/source/blender/editors/object/object_gpencil_modifier.c
index 70e942690d5..383974270f4 100644
--- a/source/blender/editors/object/object_gpencil_modifier.c
+++ b/source/blender/editors/object/object_gpencil_modifier.c
@@ -109,8 +109,9 @@ static bool UNUSED_FUNCTION(gpencil_object_has_modifier)(const Object *ob,
GpencilModifierData *md;
for (md = ob->greasepencil_modifiers.first; md; md = md->next) {
- if ((md != exclude) && (md->type == type))
+ if ((md != exclude) && (md->type == type)) {
return true;
+ }
}
return false;
@@ -163,8 +164,9 @@ void ED_object_gpencil_modifier_clear(Main *bmain, Object *ob)
GpencilModifierData *md = ob->greasepencil_modifiers.first;
bool sort_depsgraph = false;
- if (!md)
+ if (!md) {
return;
+ }
while (md) {
GpencilModifierData *next_md;
@@ -257,8 +259,9 @@ int ED_object_gpencil_modifier_apply(Main *bmain,
return 0;
}
- if (md != ob->greasepencil_modifiers.first)
+ if (md != ob->greasepencil_modifiers.first) {
BKE_report(reports, RPT_INFO, "Applied modifier was not first, result may not be as expected");
+ }
if (!gpencil_modifier_apply_obdata(reports, bmain, depsgraph, ob, md)) {
return 0;
@@ -300,8 +303,9 @@ static int gpencil_modifier_add_exec(bContext *C, wmOperator *op)
Object *ob = ED_object_active_context(C);
int type = RNA_enum_get(op->ptr, "type");
- if (!ED_object_gpencil_modifier_add(op->reports, bmain, scene, ob, NULL, type))
+ if (!ED_object_gpencil_modifier_add(op->reports, bmain, scene, ob, NULL, type)) {
return OPERATOR_CANCELLED;
+ }
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
@@ -319,16 +323,18 @@ static const EnumPropertyItem *gpencil_modifier_add_itemf(bContext *C,
const GpencilModifierTypeInfo *mti;
int totitem = 0, a;
- if (!ob)
+ if (!ob) {
return rna_enum_object_greasepencil_modifier_type_items;
+ }
for (a = 0; rna_enum_object_greasepencil_modifier_type_items[a].identifier; a++) {
md_item = &rna_enum_object_greasepencil_modifier_type_items[a];
if (md_item->identifier[0]) {
mti = BKE_gpencil_modifierType_getInfo(md_item->value);
- if (mti->flags & eGpencilModifierTypeFlag_NoUserAdd)
+ if (mti->flags & eGpencilModifierTypeFlag_NoUserAdd) {
continue;
+ }
}
else {
group_item = md_item;
@@ -386,12 +392,15 @@ static int gpencil_edit_modifier_poll_generic(bContext *C, StructRNA *rna_type,
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 || ID_IS_LINKED(ob))
+ if (!ob || ID_IS_LINKED(ob)) {
return 0;
- if (obtype_flag && ((1 << ob->type) & obtype_flag) == 0)
+ }
+ if (obtype_flag && ((1 << ob->type) & obtype_flag) == 0) {
return 0;
- if (ptr.id.data && ID_IS_LINKED(ptr.id.data))
+ }
+ if (ptr.id.data && ID_IS_LINKED(ptr.id.data)) {
return 0;
+ }
if (ID_IS_STATIC_OVERRIDE(ob)) {
CTX_wm_operator_poll_msg_set(C, "Cannot edit modifiers coming from static override");
@@ -443,8 +452,9 @@ static GpencilModifierData *gpencil_edit_modifier_property_get(wmOperator *op,
md = BKE_gpencil_modifiers_findByName(ob, modifier_name);
- if (md && type != 0 && md->type != type)
+ if (md && type != 0 && md->type != type) {
md = NULL;
+ }
return md;
}
@@ -457,8 +467,9 @@ static int gpencil_modifier_remove_exec(bContext *C, wmOperator *op)
Object *ob = ED_object_active_context(C);
GpencilModifierData *md = gpencil_edit_modifier_property_get(op, ob, 0);
- if (!md || !ED_object_gpencil_modifier_remove(op->reports, bmain, ob, md))
+ if (!md || !ED_object_gpencil_modifier_remove(op->reports, bmain, ob, md)) {
return OPERATOR_CANCELLED;
+ }
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
@@ -469,10 +480,12 @@ static int gpencil_modifier_remove_invoke(bContext *C,
wmOperator *op,
const wmEvent *UNUSED(event))
{
- if (gpencil_edit_modifier_invoke_properties(C, op))
+ if (gpencil_edit_modifier_invoke_properties(C, op)) {
return gpencil_modifier_remove_exec(C, op);
- else
+ }
+ else {
return OPERATOR_CANCELLED;
+ }
}
void OBJECT_OT_gpencil_modifier_remove(wmOperatorType *ot)
@@ -497,8 +510,9 @@ static int gpencil_modifier_move_up_exec(bContext *C, wmOperator *op)
Object *ob = ED_object_active_context(C);
GpencilModifierData *md = gpencil_edit_modifier_property_get(op, ob, 0);
- if (!md || !ED_object_gpencil_modifier_move_up(op->reports, ob, md))
+ if (!md || !ED_object_gpencil_modifier_move_up(op->reports, ob, md)) {
return OPERATOR_CANCELLED;
+ }
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
@@ -510,10 +524,12 @@ static int gpencil_modifier_move_up_invoke(bContext *C,
wmOperator *op,
const wmEvent *UNUSED(event))
{
- if (gpencil_edit_modifier_invoke_properties(C, op))
+ if (gpencil_edit_modifier_invoke_properties(C, op)) {
return gpencil_modifier_move_up_exec(C, op);
- else
+ }
+ else {
return OPERATOR_CANCELLED;
+ }
}
void OBJECT_OT_gpencil_modifier_move_up(wmOperatorType *ot)
@@ -538,8 +554,9 @@ static int gpencil_modifier_move_down_exec(bContext *C, wmOperator *op)
Object *ob = ED_object_active_context(C);
GpencilModifierData *md = gpencil_edit_modifier_property_get(op, ob, 0);
- if (!md || !ED_object_gpencil_modifier_move_down(op->reports, ob, md))
+ if (!md || !ED_object_gpencil_modifier_move_down(op->reports, ob, md)) {
return OPERATOR_CANCELLED;
+ }
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
@@ -551,10 +568,12 @@ static int gpencil_modifier_move_down_invoke(bContext *C,
wmOperator *op,
const wmEvent *UNUSED(event))
{
- if (gpencil_edit_modifier_invoke_properties(C, op))
+ if (gpencil_edit_modifier_invoke_properties(C, op)) {
return gpencil_modifier_move_down_exec(C, op);
- else
+ }
+ else {
return OPERATOR_CANCELLED;
+ }
}
void OBJECT_OT_gpencil_modifier_move_down(wmOperatorType *ot)
@@ -594,10 +613,12 @@ static int gpencil_modifier_apply_exec(bContext *C, wmOperator *op)
static int gpencil_modifier_apply_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
- if (gpencil_edit_modifier_invoke_properties(C, op))
+ if (gpencil_edit_modifier_invoke_properties(C, op)) {
return gpencil_modifier_apply_exec(C, op);
- else
+ }
+ else {
return OPERATOR_CANCELLED;
+ }
}
static const EnumPropertyItem gpencil_modifier_apply_as_items[] = {
@@ -639,8 +660,9 @@ static int gpencil_modifier_copy_exec(bContext *C, wmOperator *op)
Object *ob = ED_object_active_context(C);
GpencilModifierData *md = gpencil_edit_modifier_property_get(op, ob, 0);
- if (!md || !ED_object_gpencil_modifier_copy(op->reports, ob, md))
+ if (!md || !ED_object_gpencil_modifier_copy(op->reports, ob, md)) {
return OPERATOR_CANCELLED;
+ }
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
@@ -650,10 +672,12 @@ static int gpencil_modifier_copy_exec(bContext *C, wmOperator *op)
static int gpencil_modifier_copy_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
- if (gpencil_edit_modifier_invoke_properties(C, op))
+ if (gpencil_edit_modifier_invoke_properties(C, op)) {
return gpencil_modifier_copy_exec(C, op);
- else
+ }
+ else {
return OPERATOR_CANCELLED;
+ }
}
void OBJECT_OT_gpencil_modifier_copy(wmOperatorType *ot)
diff --git a/source/blender/editors/object/object_hook.c b/source/blender/editors/object/object_hook.c
index d4e5ba42be2..c1205635a96 100644
--- a/source/blender/editors/object/object_hook.c
+++ b/source/blender/editors/object/object_hook.c
@@ -75,11 +75,13 @@ static int return_editmesh_indexar(BMEditMesh *em, int *r_tot, int **r_indexar,
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))
+ if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) {
totvert++;
+ }
}
- if (totvert == 0)
+ if (totvert == 0) {
return 0;
+ }
*r_indexar = index = MEM_mallocN(4 * totvert, "hook indexar");
*r_tot = totvert;
@@ -144,14 +146,16 @@ static void select_editbmesh_hook(Object *ob, HookModifierData *hmd)
BMIter iter;
int index = 0, nr = 0;
- if (hmd->indexar == NULL)
+ if (hmd->indexar == NULL) {
return;
+ }
BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) {
if (nr == hmd->indexar[index]) {
BM_vert_select_set(em->bm, eve, true);
- if (index < hmd->totindex - 1)
+ if (index < hmd->totindex - 1) {
index++;
+ }
}
nr++;
@@ -173,14 +177,16 @@ static int return_editlattice_indexar(Lattice *editlatt,
bp = editlatt->def;
while (a--) {
if (bp->f1 & SELECT) {
- if (bp->hide == 0)
+ if (bp->hide == 0) {
totvert++;
+ }
}
bp++;
}
- if (totvert == 0)
+ if (totvert == 0) {
return 0;
+ }
*r_indexar = index = MEM_mallocN(4 * totvert, "hook indexar");
*r_tot = totvert;
@@ -219,8 +225,9 @@ static void select_editlattice_hook(Object *obedit, HookModifierData *hmd)
while (a--) {
if (hmd->indexar[index] == nr) {
bp->f1 |= SELECT;
- if (index < hmd->totindex - 1)
+ if (index < hmd->totindex - 1) {
index++;
+ }
}
nr++;
bp++;
@@ -240,12 +247,15 @@ static int return_editcurve_indexar(Object *obedit, int *r_tot, int **r_indexar,
bezt = nu->bezt;
a = nu->pntsu;
while (a--) {
- if (bezt->f1 & SELECT)
+ if (bezt->f1 & SELECT) {
totvert++;
- if (bezt->f2 & SELECT)
+ }
+ if (bezt->f2 & SELECT) {
totvert++;
- if (bezt->f3 & SELECT)
+ }
+ if (bezt->f3 & SELECT) {
totvert++;
+ }
bezt++;
}
}
@@ -253,14 +263,16 @@ static int return_editcurve_indexar(Object *obedit, int *r_tot, int **r_indexar,
bp = nu->bp;
a = nu->pntsu * nu->pntsv;
while (a--) {
- if (bp->f1 & SELECT)
+ if (bp->f1 & SELECT) {
totvert++;
+ }
bp++;
}
}
}
- if (totvert == 0)
+ if (totvert == 0) {
return 0;
+ }
*r_indexar = index = MEM_mallocN(sizeof(*index) * totvert, "hook indexar");
*r_tot = totvert;
@@ -376,20 +388,23 @@ static void select_editcurve_hook(Object *obedit, HookModifierData *hmd)
while (a--) {
if (nr == hmd->indexar[index]) {
bezt->f1 |= SELECT;
- if (index < hmd->totindex - 1)
+ if (index < hmd->totindex - 1) {
index++;
+ }
}
nr++;
if (nr == hmd->indexar[index]) {
bezt->f2 |= SELECT;
- if (index < hmd->totindex - 1)
+ if (index < hmd->totindex - 1) {
index++;
+ }
}
nr++;
if (nr == hmd->indexar[index]) {
bezt->f3 |= SELECT;
- if (index < hmd->totindex - 1)
+ if (index < hmd->totindex - 1) {
index++;
+ }
}
nr++;
@@ -402,8 +417,9 @@ static void select_editcurve_hook(Object *obedit, HookModifierData *hmd)
while (a--) {
if (nr == hmd->indexar[index]) {
bp->f1 |= SELECT;
- if (index < hmd->totindex - 1)
+ if (index < hmd->totindex - 1) {
index++;
+ }
}
nr++;
bp++;
@@ -439,17 +455,22 @@ static void object_hook_from_context(
static void object_hook_select(Object *ob, HookModifierData *hmd)
{
- if (hmd->indexar == NULL)
+ if (hmd->indexar == NULL) {
return;
+ }
- if (ob->type == OB_MESH)
+ if (ob->type == OB_MESH) {
select_editbmesh_hook(ob, hmd);
- else if (ob->type == OB_LATTICE)
+ }
+ else if (ob->type == OB_LATTICE) {
select_editlattice_hook(ob, hmd);
- else if (ob->type == OB_CURVE)
+ }
+ else if (ob->type == OB_CURVE) {
select_editcurve_hook(ob, hmd);
- else if (ob->type == OB_SURF)
+ }
+ else if (ob->type == OB_SURF) {
select_editcurve_hook(ob, hmd);
+ }
}
/* special poll operators for hook operators */
@@ -459,12 +480,15 @@ static bool hook_op_edit_poll(bContext *C)
Object *obedit = CTX_data_edit_object(C);
if (obedit) {
- if (ED_operator_editmesh(C))
+ if (ED_operator_editmesh(C)) {
return 1;
- if (ED_operator_editsurfcurve(C))
+ }
+ if (ED_operator_editsurfcurve(C)) {
return 1;
- if (ED_operator_editlattice(C))
+ }
+ if (ED_operator_editlattice(C)) {
return 1;
+ }
//if (ED_operator_editmball(C)) return 1;
}
@@ -715,8 +739,9 @@ static const EnumPropertyItem *hook_mod_itemf(bContext *C,
ModifierData *md = NULL;
int a, totitem = 0;
- if (!ob)
+ if (!ob) {
return DummyRNA_NULL_items;
+ }
for (a = 0, md = ob->modifiers.first; md; md = md->next, a++) {
if (md->type == eModifierType_Hook) {
@@ -880,8 +905,9 @@ static int object_hook_assign_exec(bContext *C, wmOperator *op)
BKE_report(op->reports, RPT_WARNING, "Requires selected vertices or active vertex group");
return OPERATOR_CANCELLED;
}
- if (hmd->indexar)
+ if (hmd->indexar) {
MEM_freeN(hmd->indexar);
+ }
copy_v3_v3(hmd->cent, cent);
hmd->indexar = indexar;
diff --git a/source/blender/editors/object/object_modes.c b/source/blender/editors/object/object_modes.c
index 7c881aa7cab..cc28ceaf95b 100644
--- a/source/blender/editors/object/object_modes.c
+++ b/source/blender/editors/object/object_modes.c
@@ -54,28 +54,39 @@
static const char *object_mode_op_string(eObjectMode mode)
{
- if (mode & OB_MODE_EDIT)
+ if (mode & OB_MODE_EDIT) {
return "OBJECT_OT_editmode_toggle";
- if (mode == OB_MODE_SCULPT)
+ }
+ if (mode == OB_MODE_SCULPT) {
return "SCULPT_OT_sculptmode_toggle";
- if (mode == OB_MODE_VERTEX_PAINT)
+ }
+ if (mode == OB_MODE_VERTEX_PAINT) {
return "PAINT_OT_vertex_paint_toggle";
- if (mode == OB_MODE_WEIGHT_PAINT)
+ }
+ if (mode == OB_MODE_WEIGHT_PAINT) {
return "PAINT_OT_weight_paint_toggle";
- if (mode == OB_MODE_TEXTURE_PAINT)
+ }
+ if (mode == OB_MODE_TEXTURE_PAINT) {
return "PAINT_OT_texture_paint_toggle";
- if (mode == OB_MODE_PARTICLE_EDIT)
+ }
+ if (mode == OB_MODE_PARTICLE_EDIT) {
return "PARTICLE_OT_particle_edit_toggle";
- if (mode == OB_MODE_POSE)
+ }
+ if (mode == OB_MODE_POSE) {
return "OBJECT_OT_posemode_toggle";
- if (mode == OB_MODE_EDIT_GPENCIL)
+ }
+ if (mode == OB_MODE_EDIT_GPENCIL) {
return "GPENCIL_OT_editmode_toggle";
- if (mode == OB_MODE_PAINT_GPENCIL)
+ }
+ if (mode == OB_MODE_PAINT_GPENCIL) {
return "GPENCIL_OT_paintmode_toggle";
- if (mode == OB_MODE_SCULPT_GPENCIL)
+ }
+ if (mode == OB_MODE_SCULPT_GPENCIL) {
return "GPENCIL_OT_sculptmode_toggle";
- if (mode == OB_MODE_WEIGHT_GPENCIL)
+ }
+ if (mode == OB_MODE_WEIGHT_GPENCIL) {
return "GPENCIL_OT_weightmode_toggle";
+ }
return NULL;
}
@@ -86,8 +97,9 @@ static const char *object_mode_op_string(eObjectMode mode)
bool ED_object_mode_compat_test(const Object *ob, eObjectMode mode)
{
if (ob) {
- if (mode == OB_MODE_OBJECT)
+ if (mode == OB_MODE_OBJECT) {
return true;
+ }
switch (ob->type) {
case OB_MESH:
@@ -100,16 +112,19 @@ bool ED_object_mode_compat_test(const Object *ob, eObjectMode mode)
case OB_SURF:
case OB_FONT:
case OB_MBALL:
- if (mode & (OB_MODE_EDIT))
+ if (mode & (OB_MODE_EDIT)) {
return true;
+ }
break;
case OB_LATTICE:
- if (mode & (OB_MODE_EDIT | OB_MODE_WEIGHT_PAINT))
+ if (mode & (OB_MODE_EDIT | OB_MODE_WEIGHT_PAINT)) {
return true;
+ }
break;
case OB_ARMATURE:
- if (mode & (OB_MODE_EDIT | OB_MODE_POSE))
+ if (mode & (OB_MODE_EDIT | OB_MODE_POSE)) {
return true;
+ }
break;
case OB_GPENCIL:
if (mode & (OB_MODE_EDIT | OB_MODE_EDIT_GPENCIL | OB_MODE_PAINT_GPENCIL |
diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c
index ef55f6a8f4b..bc95360eab9 100644
--- a/source/blender/editors/object/object_modifier.c
+++ b/source/blender/editors/object/object_modifier.c
@@ -155,13 +155,15 @@ ModifierData *ED_object_modifier_add(
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);
}
- else
+ else {
BLI_addtail(&ob->modifiers, new_md);
+ }
if (name) {
BLI_strncpy_utf8(new_md->name, name, sizeof(new_md->name));
@@ -179,8 +181,9 @@ ModifierData *ED_object_modifier_add(
}
}
else if (type == eModifierType_Collision) {
- if (!ob->pd)
+ if (!ob->pd) {
ob->pd = BKE_partdeflect_new(0);
+ }
ob->pd->deflect = 1;
}
@@ -215,8 +218,9 @@ static bool object_has_modifier(const Object *ob, const ModifierData *exclude, M
ModifierData *md;
for (md = ob->modifiers.first; md; md = md->next) {
- if ((md != exclude) && (md->type == type))
+ if ((md != exclude) && (md->type == type)) {
return true;
+ }
}
return false;
@@ -239,8 +243,9 @@ bool ED_object_iter_other(Main *bmain,
ID *ob_data_id = orig_ob->data;
int users = ob_data_id->us;
- if (ob_data_id->flag & LIB_FAKEUSER)
+ if (ob_data_id->flag & LIB_FAKEUSER) {
users--;
+ }
/* First check that the object's data has multiple users */
if (users > 1) {
@@ -249,8 +254,9 @@ bool ED_object_iter_other(Main *bmain,
for (ob = bmain->objects.first; ob && totfound < users; ob = ob->id.next) {
if (((ob != orig_ob) || include_orig) && (ob->data == orig_ob->data)) {
- if (callback(ob, callback_data))
+ if (callback(ob, callback_data)) {
return true;
+ }
totfound++;
}
@@ -324,8 +330,9 @@ static bool object_modifier_remove(Main *bmain,
}
}
else if (md->type == eModifierType_Collision) {
- if (ob->pd)
+ if (ob->pd) {
ob->pd->deflect = 0;
+ }
*r_sort_depsgraph = true;
}
@@ -334,13 +341,15 @@ static bool object_modifier_remove(Main *bmain,
}
else if (md->type == eModifierType_Multires) {
/* Delete MDisps layer if not used by another multires modifier */
- if (object_modifier_safe_to_delete(bmain, ob, md, eModifierType_Multires))
+ if (object_modifier_safe_to_delete(bmain, ob, md, eModifierType_Multires)) {
multires_customdata_delete(ob->data);
+ }
}
else if (md->type == eModifierType_Skin) {
/* Delete MVertSkin layer if not used by another skin modifier */
- if (object_modifier_safe_to_delete(bmain, ob, md, eModifierType_Skin))
+ if (object_modifier_safe_to_delete(bmain, ob, md, eModifierType_Skin)) {
modifier_skin_customdata_delete(ob);
+ }
}
if (ELEM(md->type, eModifierType_Softbody, eModifierType_Cloth) &&
@@ -378,8 +387,9 @@ void ED_object_modifier_clear(Main *bmain, Object *ob)
ModifierData *md = ob->modifiers.first;
bool sort_depsgraph = false;
- if (!md)
+ if (!md) {
return;
+ }
while (md) {
ModifierData *next_md;
@@ -456,10 +466,12 @@ int ED_object_modifier_convert(ReportList *UNUSED(reports),
int totvert = 0, totedge = 0, cvert = 0;
int totpart = 0, totchild = 0;
- if (md->type != eModifierType_ParticleSystem)
+ if (md->type != eModifierType_ParticleSystem) {
return 0;
- if (ob && ob->mode & OB_MODE_PARTICLE_EDIT)
+ }
+ if (ob && ob->mode & OB_MODE_PARTICLE_EDIT) {
return 0;
+ }
psys_orig = ((ParticleSystemModifierData *)md)->psys;
part = psys_orig->part;
@@ -475,8 +487,9 @@ int ED_object_modifier_convert(ReportList *UNUSED(reports),
totpart = psys_eval->totcached;
totchild = psys_eval->totchildcache;
- if (totchild && (part->draw & PART_DRAW_PARENT) == 0)
+ if (totchild && (part->draw & PART_DRAW_PARENT) == 0) {
totpart = 0;
+ }
/* count */
cache = psys_eval->pathcache;
@@ -499,8 +512,9 @@ int ED_object_modifier_convert(ReportList *UNUSED(reports),
}
}
- if (totvert == 0)
+ if (totvert == 0) {
return 0;
+ }
/* add new mesh */
obn = BKE_object_add(bmain, scene, view_layer, OB_MESH, NULL);
@@ -659,8 +673,9 @@ static int modifier_apply_obdata(
}
/* Multires: ensure that recent sculpting is applied */
- if (md->type == eModifierType_Multires)
+ if (md->type == eModifierType_Multires) {
multires_force_update(ob);
+ }
if (mmd && mmd->totlvl && mti->type == eModifierTypeType_OnlyDeform) {
if (!multiresModifier_reshapeFromDeformModifier(depsgraph, mmd, ob, md)) {
@@ -677,8 +692,9 @@ static int modifier_apply_obdata(
BKE_mesh_nomain_to_mesh(mesh_applied, me, ob, &CD_MASK_MESH, true);
- if (md->type == eModifierType_Multires)
+ if (md->type == eModifierType_Multires) {
multires_customdata_delete(me);
+ }
}
}
else if (ELEM(ob->type, OB_CURVE, OB_SURF)) {
@@ -719,8 +735,9 @@ static int modifier_apply_obdata(
for (; psys; psys = psys->next) {
- if (psys->part->type != PART_HAIR)
+ if (psys->part->type != PART_HAIR) {
continue;
+ }
psys_apply_hair_lattice(depsgraph, scene, ob, psys);
}
@@ -755,8 +772,9 @@ int ED_object_modifier_apply(Main *bmain,
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");
+ }
/* Get evaluated modifier, so object links pointer to evaluated data,
* but still use original object it is applied to the original mesh. */
@@ -810,8 +828,9 @@ static int modifier_add_exec(bContext *C, wmOperator *op)
Object *ob = ED_object_active_context(C);
int type = RNA_enum_get(op->ptr, "type");
- if (!ED_object_modifier_add(op->reports, bmain, scene, ob, NULL, type))
+ if (!ED_object_modifier_add(op->reports, bmain, scene, ob, NULL, type)) {
return OPERATOR_CANCELLED;
+ }
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
@@ -829,8 +848,9 @@ static const EnumPropertyItem *modifier_add_itemf(bContext *C,
const ModifierTypeInfo *mti;
int totitem = 0, a;
- if (!ob)
+ if (!ob) {
return rna_enum_object_modifier_type_items;
+ }
for (a = 0; rna_enum_object_modifier_type_items[a].identifier; a++) {
md_item = &rna_enum_object_modifier_type_items[a];
@@ -838,11 +858,13 @@ static const EnumPropertyItem *modifier_add_itemf(bContext *C,
if (md_item->identifier[0]) {
mti = modifierType_getInfo(md_item->value);
- if (mti->flags & eModifierTypeFlag_NoUserAdd)
+ if (mti->flags & eModifierTypeFlag_NoUserAdd) {
continue;
+ }
- if (!BKE_object_support_modifier_type_check(ob, md_item->value))
+ if (!BKE_object_support_modifier_type_check(ob, md_item->value)) {
continue;
+ }
}
else {
group_item = md_item;
@@ -896,12 +918,15 @@ bool edit_modifier_poll_generic(bContext *C, StructRNA *rna_type, int obtype_fla
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 || ID_IS_LINKED(ob))
+ if (!ob || ID_IS_LINKED(ob)) {
return 0;
- if (obtype_flag && ((1 << ob->type) & obtype_flag) == 0)
+ }
+ if (obtype_flag && ((1 << ob->type) & obtype_flag) == 0) {
return 0;
- if (ptr.id.data && ID_IS_LINKED(ptr.id.data))
+ }
+ if (ptr.id.data && ID_IS_LINKED(ptr.id.data)) {
return 0;
+ }
if (ID_IS_STATIC_OVERRIDE(ob)) {
CTX_wm_operator_poll_msg_set(C, "Cannot edit modifiers coming from static override");
@@ -950,8 +975,9 @@ ModifierData *edit_modifier_property_get(wmOperator *op, Object *ob, int type)
md = modifiers_findByName(ob, modifier_name);
- if (md && type != 0 && md->type != type)
+ if (md && type != 0 && md->type != type) {
md = NULL;
+ }
return md;
}
@@ -966,8 +992,9 @@ static int modifier_remove_exec(bContext *C, wmOperator *op)
ModifierData *md = edit_modifier_property_get(op, ob, 0);
int mode_orig = ob->mode;
- if (!md || !ED_object_modifier_remove(op->reports, bmain, ob, md))
+ if (!md || !ED_object_modifier_remove(op->reports, bmain, ob, md)) {
return OPERATOR_CANCELLED;
+ }
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
@@ -984,10 +1011,12 @@ static int modifier_remove_exec(bContext *C, wmOperator *op)
static int modifier_remove_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
- if (edit_modifier_invoke_properties(C, op))
+ if (edit_modifier_invoke_properties(C, op)) {
return modifier_remove_exec(C, op);
- else
+ }
+ else {
return OPERATOR_CANCELLED;
+ }
}
void OBJECT_OT_modifier_remove(wmOperatorType *ot)
@@ -1012,8 +1041,9 @@ static int modifier_move_up_exec(bContext *C, wmOperator *op)
Object *ob = ED_object_active_context(C);
ModifierData *md = edit_modifier_property_get(op, ob, 0);
- if (!md || !ED_object_modifier_move_up(op->reports, ob, md))
+ if (!md || !ED_object_modifier_move_up(op->reports, ob, md)) {
return OPERATOR_CANCELLED;
+ }
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
@@ -1023,10 +1053,12 @@ static int modifier_move_up_exec(bContext *C, wmOperator *op)
static int modifier_move_up_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
- if (edit_modifier_invoke_properties(C, op))
+ if (edit_modifier_invoke_properties(C, op)) {
return modifier_move_up_exec(C, op);
- else
+ }
+ else {
return OPERATOR_CANCELLED;
+ }
}
void OBJECT_OT_modifier_move_up(wmOperatorType *ot)
@@ -1051,8 +1083,9 @@ static int modifier_move_down_exec(bContext *C, wmOperator *op)
Object *ob = ED_object_active_context(C);
ModifierData *md = edit_modifier_property_get(op, ob, 0);
- if (!md || !ED_object_modifier_move_down(op->reports, ob, md))
+ if (!md || !ED_object_modifier_move_down(op->reports, ob, md)) {
return OPERATOR_CANCELLED;
+ }
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
@@ -1062,10 +1095,12 @@ static int modifier_move_down_exec(bContext *C, wmOperator *op)
static int modifier_move_down_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
- if (edit_modifier_invoke_properties(C, op))
+ if (edit_modifier_invoke_properties(C, op)) {
return modifier_move_down_exec(C, op);
- else
+ }
+ else {
return OPERATOR_CANCELLED;
+ }
}
void OBJECT_OT_modifier_move_down(wmOperatorType *ot)
@@ -1106,10 +1141,12 @@ static int modifier_apply_exec(bContext *C, wmOperator *op)
static int modifier_apply_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
- if (edit_modifier_invoke_properties(C, op))
+ if (edit_modifier_invoke_properties(C, op)) {
return modifier_apply_exec(C, op);
- else
+ }
+ else {
return OPERATOR_CANCELLED;
+ }
}
static const EnumPropertyItem modifier_apply_as_items[] = {
@@ -1155,8 +1192,10 @@ static int modifier_convert_exec(bContext *C, wmOperator *op)
Object *ob = ED_object_active_context(C);
ModifierData *md = edit_modifier_property_get(op, ob, 0);
- if (!md || !ED_object_modifier_convert(op->reports, bmain, depsgraph, scene, view_layer, ob, md))
+ if (!md ||
+ !ED_object_modifier_convert(op->reports, bmain, depsgraph, scene, view_layer, ob, md)) {
return OPERATOR_CANCELLED;
+ }
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
@@ -1166,10 +1205,12 @@ static int modifier_convert_exec(bContext *C, wmOperator *op)
static int modifier_convert_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
- if (edit_modifier_invoke_properties(C, op))
+ if (edit_modifier_invoke_properties(C, op)) {
return modifier_convert_exec(C, op);
- else
+ }
+ else {
return OPERATOR_CANCELLED;
+ }
}
void OBJECT_OT_modifier_convert(wmOperatorType *ot)
@@ -1194,8 +1235,9 @@ static int modifier_copy_exec(bContext *C, wmOperator *op)
Object *ob = ED_object_active_context(C);
ModifierData *md = edit_modifier_property_get(op, ob, 0);
- if (!md || !ED_object_modifier_copy(op->reports, ob, md))
+ if (!md || !ED_object_modifier_copy(op->reports, ob, md)) {
return OPERATOR_CANCELLED;
+ }
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
@@ -1205,10 +1247,12 @@ static int modifier_copy_exec(bContext *C, wmOperator *op)
static int modifier_copy_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
- if (edit_modifier_invoke_properties(C, op))
+ if (edit_modifier_invoke_properties(C, op)) {
return modifier_copy_exec(C, op);
- else
+ }
+ else {
return OPERATOR_CANCELLED;
+ }
}
void OBJECT_OT_modifier_copy(wmOperatorType *ot)
@@ -1240,8 +1284,9 @@ static int multires_higher_levels_delete_exec(bContext *C, wmOperator *op)
MultiresModifierData *mmd = (MultiresModifierData *)edit_modifier_property_get(
op, ob, eModifierType_Multires);
- if (!mmd)
+ if (!mmd) {
return OPERATOR_CANCELLED;
+ }
multiresModifier_del_levels(mmd, scene, ob, 1);
@@ -1257,10 +1302,12 @@ static int multires_higher_levels_delete_invoke(bContext *C,
wmOperator *op,
const wmEvent *UNUSED(event))
{
- if (edit_modifier_invoke_properties(C, op))
+ if (edit_modifier_invoke_properties(C, op)) {
return multires_higher_levels_delete_exec(C, op);
- else
+ }
+ else {
return OPERATOR_CANCELLED;
+ }
}
void OBJECT_OT_multires_higher_levels_delete(wmOperatorType *ot)
@@ -1287,8 +1334,9 @@ static int multires_subdivide_exec(bContext *C, wmOperator *op)
MultiresModifierData *mmd = (MultiresModifierData *)edit_modifier_property_get(
op, ob, eModifierType_Multires);
- if (!mmd)
+ if (!mmd) {
return OPERATOR_CANCELLED;
+ }
multiresModifier_subdivide(mmd, scene, ob, 0, mmd->simple);
@@ -1308,10 +1356,12 @@ static int multires_subdivide_exec(bContext *C, wmOperator *op)
static int multires_subdivide_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
- if (edit_modifier_invoke_properties(C, op))
+ if (edit_modifier_invoke_properties(C, op)) {
return multires_subdivide_exec(C, op);
- else
+ }
+ else {
return OPERATOR_CANCELLED;
+ }
}
void OBJECT_OT_multires_subdivide(wmOperatorType *ot)
@@ -1338,8 +1388,9 @@ static int multires_reshape_exec(bContext *C, wmOperator *op)
MultiresModifierData *mmd = (MultiresModifierData *)edit_modifier_property_get(
op, ob, eModifierType_Multires);
- if (!mmd)
+ if (!mmd) {
return OPERATOR_CANCELLED;
+ }
if (mmd->lvl == 0) {
BKE_report(op->reports, RPT_ERROR, "Reshape can work only with higher levels of subdivisions");
@@ -1372,10 +1423,12 @@ static int multires_reshape_exec(bContext *C, wmOperator *op)
static int multires_reshape_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
- if (edit_modifier_invoke_properties(C, op))
+ if (edit_modifier_invoke_properties(C, op)) {
return multires_reshape_exec(C, op);
- else
+ }
+ else {
return OPERATOR_CANCELLED;
+ }
}
void OBJECT_OT_multires_reshape(wmOperatorType *ot)
@@ -1403,16 +1456,19 @@ static int multires_external_save_exec(bContext *C, wmOperator *op)
char path[FILE_MAX];
const bool relative = RNA_boolean_get(op->ptr, "relative_path");
- if (!me)
+ if (!me) {
return OPERATOR_CANCELLED;
+ }
- if (CustomData_external_test(&me->ldata, CD_MDISPS))
+ if (CustomData_external_test(&me->ldata, CD_MDISPS)) {
return OPERATOR_CANCELLED;
+ }
RNA_string_get(op->ptr, "filepath", path);
- if (relative)
+ if (relative) {
BLI_path_rel(path, BKE_main_blendfile_path(bmain));
+ }
CustomData_external_add(&me->ldata, &me->id, CD_MDISPS, me->totloop, path);
CustomData_external_write(&me->ldata, &me->id, CD_MASK_MESH.lmask, me->totloop, 0);
@@ -1427,19 +1483,23 @@ static int multires_external_save_invoke(bContext *C, wmOperator *op, const wmEv
Mesh *me = ob->data;
char path[FILE_MAX];
- if (!edit_modifier_invoke_properties(C, op))
+ if (!edit_modifier_invoke_properties(C, op)) {
return OPERATOR_CANCELLED;
+ }
mmd = (MultiresModifierData *)edit_modifier_property_get(op, ob, eModifierType_Multires);
- if (!mmd)
+ if (!mmd) {
return OPERATOR_CANCELLED;
+ }
- if (CustomData_external_test(&me->ldata, CD_MDISPS))
+ if (CustomData_external_test(&me->ldata, CD_MDISPS)) {
return OPERATOR_CANCELLED;
+ }
- if (RNA_struct_property_is_set(op->ptr, "filepath"))
+ if (RNA_struct_property_is_set(op->ptr, "filepath")) {
return multires_external_save_exec(C, op);
+ }
op->customdata = me;
@@ -1482,8 +1542,9 @@ static int multires_external_pack_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob = ED_object_active_context(C);
Mesh *me = ob->data;
- if (!CustomData_external_test(&me->ldata, CD_MDISPS))
+ if (!CustomData_external_test(&me->ldata, CD_MDISPS)) {
return OPERATOR_CANCELLED;
+ }
/* XXX don't remove.. */
CustomData_external_remove(&me->ldata, &me->id, CD_MDISPS, me->totloop);
@@ -1512,8 +1573,9 @@ static int multires_base_apply_exec(bContext *C, wmOperator *op)
MultiresModifierData *mmd = (MultiresModifierData *)edit_modifier_property_get(
op, ob, eModifierType_Multires);
- if (!mmd)
+ if (!mmd) {
return OPERATOR_CANCELLED;
+ }
multiresModifier_base_apply(mmd, scene, ob);
@@ -1525,10 +1587,12 @@ static int multires_base_apply_exec(bContext *C, wmOperator *op)
static int multires_base_apply_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
- if (edit_modifier_invoke_properties(C, op))
+ if (edit_modifier_invoke_properties(C, op)) {
return multires_base_apply_exec(C, op);
- else
+ }
+ else {
return OPERATOR_CANCELLED;
+ }
}
void OBJECT_OT_multires_base_apply(wmOperatorType *ot)
@@ -1553,10 +1617,12 @@ static void modifier_skin_customdata_delete(Object *ob)
Mesh *me = ob->data;
BMEditMesh *em = me->edit_mesh;
- if (em)
+ if (em) {
BM_data_layer_free(em->bm, &em->bm->vdata, CD_MVERT_SKIN);
- else
+ }
+ else {
CustomData_free_layer_active(&me->vdata, CD_MVERT_SKIN, me->totvert);
+ }
}
static bool skin_poll(bContext *C)
@@ -1757,8 +1823,9 @@ static void skin_armature_bone_create(Object *skin_ob,
int v;
/* ignore edge if already visited */
- if (BLI_BITMAP_TEST(edges_visited, endx))
+ if (BLI_BITMAP_TEST(edges_visited, endx)) {
continue;
+ }
BLI_BITMAP_ENABLE(edges_visited, endx);
v = (e->v1 == parent_v ? e->v2 : e->v1);
@@ -1894,10 +1961,12 @@ static int skin_armature_create_exec(bContext *C, wmOperator *op)
static int skin_armature_create_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
- if (edit_modifier_invoke_properties(C, op))
+ if (edit_modifier_invoke_properties(C, op)) {
return skin_armature_create_exec(C, op);
- else
+ }
+ else {
return OPERATOR_CANCELLED;
+ }
}
void OBJECT_OT_skin_armature_create(wmOperatorType *ot)
@@ -1967,10 +2036,12 @@ static int correctivesmooth_bind_exec(bContext *C, wmOperator *op)
static int correctivesmooth_bind_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
- if (edit_modifier_invoke_properties(C, op))
+ if (edit_modifier_invoke_properties(C, op)) {
return correctivesmooth_bind_exec(C, op);
- else
+ }
+ else {
return OPERATOR_CANCELLED;
+ }
}
void OBJECT_OT_correctivesmooth_bind(wmOperatorType *ot)
@@ -2038,10 +2109,12 @@ static int meshdeform_bind_exec(bContext *C, wmOperator *op)
static int meshdeform_bind_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
- if (edit_modifier_invoke_properties(C, op))
+ if (edit_modifier_invoke_properties(C, op)) {
return meshdeform_bind_exec(C, op);
- else
+ }
+ else {
return OPERATOR_CANCELLED;
+ }
}
void OBJECT_OT_meshdeform_bind(wmOperatorType *ot)
@@ -2074,8 +2147,9 @@ static int explode_refresh_exec(bContext *C, wmOperator *op)
ExplodeModifierData *emd = (ExplodeModifierData *)edit_modifier_property_get(
op, ob, eModifierType_Explode);
- if (!emd)
+ if (!emd) {
return OPERATOR_CANCELLED;
+ }
emd->flag |= eExplodeFlag_CalcFaces;
@@ -2087,10 +2161,12 @@ static int explode_refresh_exec(bContext *C, wmOperator *op)
static int explode_refresh_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
- if (edit_modifier_invoke_properties(C, op))
+ if (edit_modifier_invoke_properties(C, op)) {
return explode_refresh_exec(C, op);
- else
+ }
+ else {
return OPERATOR_CANCELLED;
+ }
}
void OBJECT_OT_explode_refresh(wmOperatorType *ot)
@@ -2149,8 +2225,9 @@ static void oceanbake_update(void *customdata, float progress, int *cancel)
{
OceanBakeJob *oj = customdata;
- if (oceanbake_breakjob(oj))
+ if (oceanbake_breakjob(oj)) {
*cancel = 1;
+ }
*(oj->do_update) = true;
*(oj->progress) = progress;
@@ -2203,8 +2280,9 @@ static int ocean_bake_exec(bContext *C, wmOperator *op)
wmJob *wm_job;
OceanBakeJob *oj;
- if (!omd)
+ if (!omd) {
return OPERATOR_CANCELLED;
+ }
if (free) {
BKE_ocean_free_modifier_cache(omd);
@@ -2282,10 +2360,12 @@ static int ocean_bake_exec(bContext *C, wmOperator *op)
static int ocean_bake_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
- if (edit_modifier_invoke_properties(C, op))
+ if (edit_modifier_invoke_properties(C, op)) {
return ocean_bake_exec(C, op);
- else
+ }
+ else {
return OPERATOR_CANCELLED;
+ }
}
void OBJECT_OT_ocean_bake(wmOperatorType *ot)
@@ -2355,10 +2435,12 @@ static int laplaciandeform_bind_exec(bContext *C, wmOperator *op)
static int laplaciandeform_bind_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
- if (edit_modifier_invoke_properties(C, op))
+ if (edit_modifier_invoke_properties(C, op)) {
return laplaciandeform_bind_exec(C, op);
- else
+ }
+ else {
return OPERATOR_CANCELLED;
+ }
}
void OBJECT_OT_laplaciandeform_bind(wmOperatorType *ot)
@@ -2418,10 +2500,12 @@ static int surfacedeform_bind_exec(bContext *C, wmOperator *op)
static int surfacedeform_bind_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
- if (edit_modifier_invoke_properties(C, op))
+ if (edit_modifier_invoke_properties(C, op)) {
return surfacedeform_bind_exec(C, op);
- else
+ }
+ else {
return OPERATOR_CANCELLED;
+ }
}
void OBJECT_OT_surfacedeform_bind(wmOperatorType *ot)
diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c
index d47b1fc6533..bf74c17c361 100644
--- a/source/blender/editors/object/object_relations.c
+++ b/source/blender/editors/object/object_relations.c
@@ -159,16 +159,21 @@ 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)
+ if (v1 == 0) {
v1 = nr;
- else if (v2 == 0)
+ }
+ else if (v2 == 0) {
v2 = nr;
- else if (v3 == 0)
+ }
+ else if (v3 == 0) {
v3 = nr;
- else if (v4 == 0)
+ }
+ else if (v4 == 0) {
v4 = nr;
- else
+ }
+ else {
break;
+ }
}
nr++;
}
@@ -183,16 +188,21 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op)
a = nu->pntsu;
while (a--) {
if (BEZT_ISSEL_ANY_HIDDENHANDLES(v3d, bezt)) {
- if (v1 == 0)
+ if (v1 == 0) {
v1 = nr;
- else if (v2 == 0)
+ }
+ else if (v2 == 0) {
v2 = nr;
- else if (v3 == 0)
+ }
+ else if (v3 == 0) {
v3 = nr;
- else if (v4 == 0)
+ }
+ else if (v4 == 0) {
v4 = nr;
- else
+ }
+ else {
break;
+ }
}
nr++;
bezt++;
@@ -203,16 +213,21 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op)
a = nu->pntsu * nu->pntsv;
while (a--) {
if (bp->f1 & SELECT) {
- if (v1 == 0)
+ if (v1 == 0) {
v1 = nr;
- else if (v2 == 0)
+ }
+ else if (v2 == 0) {
v2 = nr;
- else if (v3 == 0)
+ }
+ else if (v3 == 0) {
v3 = nr;
- else if (v4 == 0)
+ }
+ else if (v4 == 0) {
v4 = nr;
- else
+ }
+ else {
break;
+ }
}
nr++;
bp++;
@@ -228,16 +243,21 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op)
bp = lt->editlatt->latt->def;
while (a--) {
if (bp->f1 & SELECT) {
- if (v1 == 0)
+ if (v1 == 0) {
v1 = nr;
- else if (v2 == 0)
+ }
+ else if (v2 == 0) {
v2 = nr;
- else if (v3 == 0)
+ }
+ else if (v3 == 0) {
v3 = nr;
- else if (v4 == 0)
+ }
+ else if (v4 == 0) {
v4 = nr;
- else
+ }
+ else {
break;
+ }
}
nr++;
bp++;
@@ -316,8 +336,9 @@ static int make_proxy_invoke(bContext *C, wmOperator *op, const wmEvent *event)
Object *ob = ED_object_active_context(C);
/* sanity checks */
- if (!scene || ID_IS_LINKED(scene) || !ob)
+ if (!scene || ID_IS_LINKED(scene) || !ob) {
return OPERATOR_CANCELLED;
+ }
/* Get object to work on - use a menu if we need to... */
if (ob->instance_collection && ID_IS_LINKED(ob->instance_collection)) {
@@ -411,8 +432,9 @@ static const EnumPropertyItem *proxy_collection_object_itemf(bContext *C,
int i = 0;
Object *ob = ED_object_active_context(C);
- if (!ob || !ob->instance_collection)
+ if (!ob || !ob->instance_collection) {
return DummyRNA_DEFAULT_items;
+ }
/* find the object to affect */
FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN (ob->instance_collection, object) {
@@ -529,8 +551,9 @@ static void object_remove_parent_deform_modifiers(Object *ob, const Object *par)
void ED_object_parent_clear(Object *ob, const int type)
{
- if (ob->parent == NULL)
+ if (ob->parent == NULL) {
return;
+ }
switch (type) {
case CLEAR_PARENT_ALL: {
@@ -664,8 +687,9 @@ bool ED_object_parent_set(ReportList *reports,
/* preconditions */
if (partype == PAR_FOLLOW || partype == PAR_PATH_CONST) {
- if (par->type != OB_CURVE)
+ if (par->type != OB_CURVE) {
return 0;
+ }
else {
Curve *cu = par->data;
Curve *cu_eval = parent_eval->data;
@@ -687,13 +711,15 @@ bool ED_object_parent_set(ReportList *reports,
FCurve *fcu = verify_fcurve(bmain, act, NULL, NULL, "eval_time", 0, 1);
/* setup dummy 'generator' modifier here to get 1-1 correspondence still working */
- if (!fcu->bezt && !fcu->fpt && !fcu->modifiers.first)
+ if (!fcu->bezt && !fcu->fpt && !fcu->modifiers.first) {
add_fmodifier(&fcu->modifiers, FMODIFIER_TYPE_GENERATOR, fcu);
+ }
}
/* fall back on regular parenting now (for follow only) */
- if (partype == PAR_FOLLOW)
+ if (partype == PAR_FOLLOW) {
partype = PAR_OBJECT;
+ }
}
}
else if (ELEM(partype, PAR_BONE, PAR_BONE_RELATIVE)) {
@@ -730,10 +756,12 @@ bool ED_object_parent_set(ReportList *reports,
}
/* handle types */
- if (pchan)
+ if (pchan) {
BLI_strncpy(ob->parsubstr, pchan->name, sizeof(ob->parsubstr));
- else
+ }
+ else {
ob->parsubstr[0] = 0;
+ }
if (partype == PAR_PATH_CONST) {
/* don't do anything here, since this is not technically "parenting" */
@@ -955,8 +983,9 @@ static int parent_set_exec(bContext *C, wmOperator *op)
BLI_kdtree_3d_free(tree);
}
- if (!ok)
+ if (!ok) {
return OPERATOR_CANCELLED;
+ }
DEG_relations_tag_update(bmain);
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
@@ -1052,10 +1081,12 @@ static bool parent_set_poll_property(const bContext *UNUSED(C),
/* Only show XMirror for PAR_ARMATURE_ENVELOPE and PAR_ARMATURE_AUTO! */
if (STREQ(prop_id, "xmirror")) {
const int type = RNA_enum_get(op->ptr, "type");
- if (ELEM(type, PAR_ARMATURE_ENVELOPE, PAR_ARMATURE_AUTO))
+ if (ELEM(type, PAR_ARMATURE_ENVELOPE, PAR_ARMATURE_AUTO)) {
return true;
- else
+ }
+ else {
return false;
+ }
}
return true;
@@ -1184,12 +1215,14 @@ static int object_track_clear_exec(bContext *C, wmOperator *op)
if (ELEM(con->type,
CONSTRAINT_TYPE_TRACKTO,
CONSTRAINT_TYPE_LOCKTRACK,
- CONSTRAINT_TYPE_DAMPTRACK))
+ CONSTRAINT_TYPE_DAMPTRACK)) {
BKE_constraint_remove(&ob->constraints, con);
+ }
}
- if (type == CLEAR_TRACK_KEEP_TRANSFORM)
+ if (type == CLEAR_TRACK_KEEP_TRANSFORM) {
BKE_object_apply_mat4(ob, ob->obmat, true, true);
+ }
}
CTX_DATA_END;
@@ -1544,20 +1577,24 @@ static int make_links_data_exec(bContext *C, wmOperator *op)
break;
}
- if (cu_dst->vfont)
+ if (cu_dst->vfont) {
id_us_min(&cu_dst->vfont->id);
+ }
cu_dst->vfont = cu_src->vfont;
id_us_plus((ID *)cu_dst->vfont);
- if (cu_dst->vfontb)
+ if (cu_dst->vfontb) {
id_us_min(&cu_dst->vfontb->id);
+ }
cu_dst->vfontb = cu_src->vfontb;
id_us_plus((ID *)cu_dst->vfontb);
- if (cu_dst->vfonti)
+ if (cu_dst->vfonti) {
id_us_min(&cu_dst->vfonti->id);
+ }
cu_dst->vfonti = cu_src->vfonti;
id_us_plus((ID *)cu_dst->vfonti);
- if (cu_dst->vfontbi)
+ if (cu_dst->vfontbi) {
id_us_min(&cu_dst->vfontbi->id);
+ }
cu_dst->vfontbi = cu_src->vfontbi;
id_us_plus((ID *)cu_dst->vfontbi);
@@ -1829,8 +1866,9 @@ static void single_obdata_users(
case OB_MESH:
/* Needed to remap texcomesh below. */
me = ob->data = ID_NEW_SET(ob->data, BKE_mesh_copy(bmain, ob->data));
- if (me->key) /* We do not need to set me->key->id.newid here... */
+ if (me->key) { /* We do not need to set me->key->id.newid here... */
BKE_animdata_copy_id_action(bmain, (ID *)me->key, false);
+ }
break;
case OB_MBALL:
ob->data = ID_NEW_SET(ob->data, BKE_mball_copy(bmain, ob->data));
@@ -1841,13 +1879,15 @@ static void single_obdata_users(
ob->data = cu = ID_NEW_SET(ob->data, BKE_curve_copy(bmain, ob->data));
ID_NEW_REMAP(cu->bevobj);
ID_NEW_REMAP(cu->taperobj);
- if (cu->key) /* We do not need to set cu->key->id.newid here... */
+ if (cu->key) { /* We do not need to set cu->key->id.newid here... */
BKE_animdata_copy_id_action(bmain, (ID *)cu->key, false);
+ }
break;
case OB_LATTICE:
ob->data = lat = ID_NEW_SET(ob->data, BKE_lattice_copy(bmain, ob->data));
- if (lat->key) /* We do not need to set lat->key->id.newid here... */
+ if (lat->key) { /* We do not need to set lat->key->id.newid here... */
BKE_animdata_copy_id_action(bmain, (ID *)lat->key, false);
+ }
break;
case OB_ARMATURE:
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
@@ -1944,25 +1984,35 @@ static void single_mat_users_expand(Main *bmain)
MetaBall *mb;
bGPdata *gpd;
- for (ob = bmain->objects.first; ob; ob = ob->id.next)
- if (ob->id.tag & LIB_TAG_NEW)
+ for (ob = bmain->objects.first; ob; ob = ob->id.next) {
+ if (ob->id.tag & LIB_TAG_NEW) {
new_id_matar(bmain, ob->mat, ob->totcol);
+ }
+ }
- for (me = bmain->meshes.first; me; me = me->id.next)
- if (me->id.tag & LIB_TAG_NEW)
+ for (me = bmain->meshes.first; me; me = me->id.next) {
+ if (me->id.tag & LIB_TAG_NEW) {
new_id_matar(bmain, me->mat, me->totcol);
+ }
+ }
- for (cu = bmain->curves.first; cu; cu = cu->id.next)
- if (cu->id.tag & LIB_TAG_NEW)
+ for (cu = bmain->curves.first; cu; cu = cu->id.next) {
+ if (cu->id.tag & LIB_TAG_NEW) {
new_id_matar(bmain, cu->mat, cu->totcol);
+ }
+ }
- for (mb = bmain->metaballs.first; mb; mb = mb->id.next)
- if (mb->id.tag & LIB_TAG_NEW)
+ for (mb = bmain->metaballs.first; mb; mb = mb->id.next) {
+ if (mb->id.tag & LIB_TAG_NEW) {
new_id_matar(bmain, mb->mat, mb->totcol);
+ }
+ }
- for (gpd = bmain->gpencils.first; gpd; gpd = gpd->id.next)
- if (gpd->id.tag & LIB_TAG_NEW)
+ for (gpd = bmain->gpencils.first; gpd; gpd = gpd->id.next) {
+ if (gpd->id.tag & LIB_TAG_NEW) {
new_id_matar(bmain, gpd->mat, gpd->totcol);
+ }
+ }
}
/* used for copying scenes */
@@ -2592,8 +2642,9 @@ static int drop_named_material_invoke(bContext *C, wmOperator *op, const wmEvent
RNA_string_get(op->ptr, "name", name);
ma = (Material *)BKE_libblock_find_name(bmain, ID_MA, name);
- if (base == NULL || ma == NULL)
+ if (base == NULL || ma == NULL) {
return OPERATOR_CANCELLED;
+ }
assign_material(CTX_data_main(C), base->object, ma, 1, BKE_MAT_ASSIGN_USERPREF);
diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c
index 94d4e77c279..f0508b5f35c 100644
--- a/source/blender/editors/object/object_select.c
+++ b/source/blender/editors/object/object_select.c
@@ -387,10 +387,12 @@ static bool objects_selectable_poll(bContext *C)
* still allowed then for inspection of scene */
Object *obact = CTX_data_active_object(C);
- if (CTX_data_edit_object(C))
+ if (CTX_data_edit_object(C)) {
return 0;
- if (obact && obact->mode)
+ }
+ if (obact && obact->mode) {
return 0;
+ }
return 1;
}
@@ -658,8 +660,9 @@ static int object_select_linked_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
else if (nr == OBJECT_SELECT_LINKED_OBDATA) {
- if (ob->data == NULL)
+ if (ob->data == NULL) {
return OPERATOR_CANCELLED;
+ }
changed = object_select_all_by_obdata(C, ob->data);
}
@@ -667,20 +670,23 @@ static int object_select_linked_exec(bContext *C, wmOperator *op)
Material *mat = NULL;
mat = give_current_material(ob, ob->actcol);
- if (mat == NULL)
+ if (mat == NULL) {
return OPERATOR_CANCELLED;
+ }
changed = object_select_all_by_material(C, mat);
}
else if (nr == OBJECT_SELECT_LINKED_DUPGROUP) {
- if (ob->instance_collection == NULL)
+ if (ob->instance_collection == NULL) {
return OPERATOR_CANCELLED;
+ }
changed = object_select_all_by_instance_collection(C, ob);
}
else if (nr == OBJECT_SELECT_LINKED_PARTICLE) {
- if (BLI_listbase_is_empty(&ob->particlesystem))
+ if (BLI_listbase_is_empty(&ob->particlesystem)) {
return OPERATOR_CANCELLED;
+ }
changed = object_select_all_by_particle(C, ob);
}
@@ -689,13 +695,15 @@ static int object_select_linked_exec(bContext *C, wmOperator *op)
changed = object_select_all_by_library(C, ob->id.lib);
}
else if (nr == OBJECT_SELECT_LINKED_LIBRARY_OBDATA) {
- if (ob->data == NULL)
+ if (ob->data == NULL) {
return OPERATOR_CANCELLED;
+ }
changed = object_select_all_by_library_obdata(C, ((ID *)ob->data)->lib);
}
- else
+ else {
return OPERATOR_CANCELLED;
+ }
if (changed) {
DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
@@ -830,8 +838,9 @@ static bool select_grouped_collection(bContext *C, Object *ob)
}
}
- if (!collection_count)
+ if (!collection_count) {
return 0;
+ }
else if (collection_count == 1) {
collection = ob_collections[0];
CTX_DATA_BEGIN (C, Base *, base, visible_bases) {
@@ -1175,8 +1184,9 @@ static int object_select_same_collection_exec(bContext *C, wmOperator *op)
char collection_name[MAX_ID_NAME];
/* passthrough if no objects are visible */
- if (CTX_DATA_COUNT(C, visible_bases) == 0)
+ if (CTX_DATA_COUNT(C, visible_bases) == 0) {
return OPERATOR_PASS_THROUGH;
+ }
RNA_string_get(op->ptr, "collection", collection_name);
@@ -1252,8 +1262,9 @@ static int object_select_mirror_exec(bContext *C, wmOperator *op)
}
}
- if (extend == false)
+ if (extend == false) {
ED_object_base_select(primbase, BA_DESELECT);
+ }
}
CTX_DATA_END;
diff --git a/source/blender/editors/object/object_shader_fx.c b/source/blender/editors/object/object_shader_fx.c
index 98c548d76e0..f4f944459f7 100644
--- a/source/blender/editors/object/object_shader_fx.c
+++ b/source/blender/editors/object/object_shader_fx.c
@@ -110,8 +110,9 @@ static bool UNUSED_FUNCTION(object_has_shaderfx)(const Object *ob,
ShaderFxData *fx;
for (fx = ob->shader_fx.first; fx; fx = fx->next) {
- if ((fx != exclude) && (fx->type == type))
+ if ((fx != exclude) && (fx->type == type)) {
return true;
+ }
}
return false;
@@ -161,8 +162,9 @@ void ED_object_shaderfx_clear(Main *bmain, Object *ob)
ShaderFxData *fx = ob->shader_fx.first;
bool sort_depsgraph = false;
- if (!fx)
+ if (!fx) {
return;
+ }
while (fx) {
ShaderFxData *next_fx;
@@ -207,8 +209,9 @@ static int shaderfx_add_exec(bContext *C, wmOperator *op)
Object *ob = ED_object_active_context(C);
int type = RNA_enum_get(op->ptr, "type");
- if (!ED_object_shaderfx_add(op->reports, bmain, scene, ob, NULL, type))
+ if (!ED_object_shaderfx_add(op->reports, bmain, scene, ob, NULL, type)) {
return OPERATOR_CANCELLED;
+ }
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
@@ -226,16 +229,18 @@ static const EnumPropertyItem *shaderfx_add_itemf(bContext *C,
const ShaderFxTypeInfo *mti;
int totitem = 0, a;
- if (!ob)
+ if (!ob) {
return rna_enum_object_shaderfx_type_items;
+ }
for (a = 0; rna_enum_object_shaderfx_type_items[a].identifier; a++) {
fx_item = &rna_enum_object_shaderfx_type_items[a];
if (fx_item->identifier[0]) {
mti = BKE_shaderfxType_getInfo(fx_item->value);
- if (mti->flags & eShaderFxTypeFlag_NoUserAdd)
+ if (mti->flags & eShaderFxTypeFlag_NoUserAdd) {
continue;
+ }
}
else {
group_item = fx_item;
@@ -295,12 +300,15 @@ static bool edit_shaderfx_poll_generic(bContext *C, StructRNA *rna_type, int obt
return 0;
}
- if (!ob || ID_IS_LINKED(ob))
+ if (!ob || ID_IS_LINKED(ob)) {
return 0;
- if (obtype_flag && ((1 << ob->type) & obtype_flag) == 0)
+ }
+ if (obtype_flag && ((1 << ob->type) & obtype_flag) == 0) {
return 0;
- if (ptr.id.data && ID_IS_LINKED(ptr.id.data))
+ }
+ if (ptr.id.data && ID_IS_LINKED(ptr.id.data)) {
return 0;
+ }
if (ID_IS_STATIC_OVERRIDE(ob)) {
CTX_wm_operator_poll_msg_set(C, "Cannot edit shaderfxs coming from static override");
@@ -349,8 +357,9 @@ static ShaderFxData *edit_shaderfx_property_get(wmOperator *op, Object *ob, int
fx = BKE_shaderfx_findByName(ob, shaderfx_name);
- if (fx && type != 0 && fx->type != type)
+ if (fx && type != 0 && fx->type != type) {
fx = NULL;
+ }
return fx;
}
@@ -365,8 +374,9 @@ static int shaderfx_remove_exec(bContext *C, wmOperator *op)
Object *ob = ED_object_active_context(C);
ShaderFxData *fx = edit_shaderfx_property_get(op, ob, 0);
- if (!fx || !ED_object_shaderfx_remove(op->reports, bmain, ob, fx))
+ if (!fx || !ED_object_shaderfx_remove(op->reports, bmain, ob, fx)) {
return OPERATOR_CANCELLED;
+ }
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
@@ -375,10 +385,12 @@ static int shaderfx_remove_exec(bContext *C, wmOperator *op)
static int shaderfx_remove_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
- if (edit_shaderfx_invoke_properties(C, op))
+ if (edit_shaderfx_invoke_properties(C, op)) {
return shaderfx_remove_exec(C, op);
- else
+ }
+ else {
return OPERATOR_CANCELLED;
+ }
}
void OBJECT_OT_shaderfx_remove(wmOperatorType *ot)
@@ -403,8 +415,9 @@ static int shaderfx_move_up_exec(bContext *C, wmOperator *op)
Object *ob = ED_object_active_context(C);
ShaderFxData *fx = edit_shaderfx_property_get(op, ob, 0);
- if (!fx || !ED_object_shaderfx_move_up(op->reports, ob, fx))
+ if (!fx || !ED_object_shaderfx_move_up(op->reports, ob, fx)) {
return OPERATOR_CANCELLED;
+ }
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
@@ -414,10 +427,12 @@ static int shaderfx_move_up_exec(bContext *C, wmOperator *op)
static int shaderfx_move_up_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
- if (edit_shaderfx_invoke_properties(C, op))
+ if (edit_shaderfx_invoke_properties(C, op)) {
return shaderfx_move_up_exec(C, op);
- else
+ }
+ else {
return OPERATOR_CANCELLED;
+ }
}
void OBJECT_OT_shaderfx_move_up(wmOperatorType *ot)
@@ -442,8 +457,9 @@ static int shaderfx_move_down_exec(bContext *C, wmOperator *op)
Object *ob = ED_object_active_context(C);
ShaderFxData *fx = edit_shaderfx_property_get(op, ob, 0);
- if (!fx || !ED_object_shaderfx_move_down(op->reports, ob, fx))
+ if (!fx || !ED_object_shaderfx_move_down(op->reports, ob, fx)) {
return OPERATOR_CANCELLED;
+ }
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
@@ -453,10 +469,12 @@ static int shaderfx_move_down_exec(bContext *C, wmOperator *op)
static int shaderfx_move_down_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
- if (edit_shaderfx_invoke_properties(C, op))
+ if (edit_shaderfx_invoke_properties(C, op)) {
return shaderfx_move_down_exec(C, op);
- else
+ }
+ else {
return OPERATOR_CANCELLED;
+ }
}
void OBJECT_OT_shaderfx_move_down(wmOperatorType *ot)
diff --git a/source/blender/editors/object/object_shapekey.c b/source/blender/editors/object/object_shapekey.c
index aa0c6cbeef4..fb76ba6099d 100644
--- a/source/blender/editors/object/object_shapekey.c
+++ b/source/blender/editors/object/object_shapekey.c
@@ -110,8 +110,9 @@ static bool object_shape_key_mirror(
*r_totmirr = *r_totfail = 0;
key = BKE_key_from_object(ob);
- if (key == NULL)
+ if (key == NULL) {
return 0;
+ }
kb = BLI_findlink(&key->block, ob->shapenr - 1);
@@ -335,11 +336,13 @@ static int shape_key_clear_exec(bContext *C, wmOperator *UNUSED(op))
Key *key = BKE_key_from_object(ob);
KeyBlock *kb = BKE_keyblock_from_object(ob);
- if (!key || !kb)
+ if (!key || !kb) {
return OPERATOR_CANCELLED;
+ }
- for (kb = key->block.first; kb; kb = kb->next)
+ for (kb = key->block.first; kb; kb = kb->next) {
kb->curval = 0.0f;
+ }
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
@@ -370,8 +373,9 @@ static int shape_key_retime_exec(bContext *C, wmOperator *UNUSED(op))
KeyBlock *kb = BKE_keyblock_from_object(ob);
float cfra = 0.0f;
- if (!key || !kb)
+ if (!key || !kb) {
return OPERATOR_CANCELLED;
+ }
for (kb = key->block.first; kb; kb = kb->next) {
kb->pos = cfra;
@@ -405,8 +409,9 @@ static int shape_key_mirror_exec(bContext *C, wmOperator *op)
int totmirr = 0, totfail = 0;
bool use_topology = RNA_boolean_get(op->ptr, "use_topology");
- if (!object_shape_key_mirror(C, ob, &totmirr, &totfail, use_topology))
+ if (!object_shape_key_mirror(C, ob, &totmirr, &totfail, use_topology)) {
return OPERATOR_CANCELLED;
+ }
ED_mesh_report_mirror(op, totmirr, totfail);
diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c
index b7efb22a628..9e1ef96ab93 100644
--- a/source/blender/editors/object/object_transform.c
+++ b/source/blender/editors/object/object_transform.c
@@ -82,18 +82,21 @@ static void object_clear_loc(Object *ob, const bool clear_delta)
/* clear location if not locked */
if ((ob->protectflag & OB_LOCK_LOCX) == 0) {
ob->loc[0] = 0.0f;
- if (clear_delta)
+ if (clear_delta) {
ob->dloc[0] = 0.0f;
+ }
}
if ((ob->protectflag & OB_LOCK_LOCY) == 0) {
ob->loc[1] = 0.0f;
- if (clear_delta)
+ if (clear_delta) {
ob->dloc[1] = 0.0f;
+ }
}
if ((ob->protectflag & OB_LOCK_LOCZ) == 0) {
ob->loc[2] = 0.0f;
- if (clear_delta)
+ if (clear_delta) {
ob->dloc[2] = 0.0f;
+ }
}
}
@@ -107,53 +110,63 @@ static void object_clear_rot(Object *ob, const bool clear_delta)
if (ob->rotmode == ROT_MODE_AXISANGLE) {
if ((ob->protectflag & OB_LOCK_ROTW) == 0) {
ob->rotAngle = 0.0f;
- if (clear_delta)
+ if (clear_delta) {
ob->drotAngle = 0.0f;
+ }
}
if ((ob->protectflag & OB_LOCK_ROTX) == 0) {
ob->rotAxis[0] = 0.0f;
- if (clear_delta)
+ if (clear_delta) {
ob->drotAxis[0] = 0.0f;
+ }
}
if ((ob->protectflag & OB_LOCK_ROTY) == 0) {
ob->rotAxis[1] = 0.0f;
- if (clear_delta)
+ if (clear_delta) {
ob->drotAxis[1] = 0.0f;
+ }
}
if ((ob->protectflag & OB_LOCK_ROTZ) == 0) {
ob->rotAxis[2] = 0.0f;
- if (clear_delta)
+ if (clear_delta) {
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]))
+ 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]) &&
- clear_delta)
+ clear_delta) {
ob->drotAxis[1] = 1.0f;
+ }
}
else if (ob->rotmode == ROT_MODE_QUAT) {
if ((ob->protectflag & OB_LOCK_ROTW) == 0) {
ob->quat[0] = 1.0f;
- if (clear_delta)
+ if (clear_delta) {
ob->dquat[0] = 1.0f;
+ }
}
if ((ob->protectflag & OB_LOCK_ROTX) == 0) {
ob->quat[1] = 0.0f;
- if (clear_delta)
+ if (clear_delta) {
ob->dquat[1] = 0.0f;
+ }
}
if ((ob->protectflag & OB_LOCK_ROTY) == 0) {
ob->quat[2] = 0.0f;
- if (clear_delta)
+ if (clear_delta) {
ob->dquat[2] = 0.0f;
+ }
}
if ((ob->protectflag & OB_LOCK_ROTZ) == 0) {
ob->quat[3] = 0.0f;
- if (clear_delta)
+ if (clear_delta) {
ob->dquat[3] = 0.0f;
+ }
}
/* TODO: does this quat need normalizing now? */
}
@@ -161,18 +174,21 @@ static void object_clear_rot(Object *ob, const bool clear_delta)
/* 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] = 0.0f;
- if (clear_delta)
+ if (clear_delta) {
ob->drot[0] = 0.0f;
+ }
}
if ((ob->protectflag & OB_LOCK_ROTY) == 0) {
ob->rot[1] = 0.0f;
- if (clear_delta)
+ if (clear_delta) {
ob->drot[1] = 0.0f;
+ }
}
if ((ob->protectflag & OB_LOCK_ROTZ) == 0) {
ob->rot[2] = 0.0f;
- if (clear_delta)
+ if (clear_delta) {
ob->drot[2] = 0.0f;
+ }
}
}
}
@@ -194,12 +210,15 @@ static void object_clear_rot(Object *ob, const bool clear_delta)
eul[0] = eul[1] = eul[2] = 0.0f;
- if (ob->protectflag & OB_LOCK_ROTX)
+ if (ob->protectflag & OB_LOCK_ROTX) {
eul[0] = oldeul[0];
- if (ob->protectflag & OB_LOCK_ROTY)
+ }
+ if (ob->protectflag & OB_LOCK_ROTY) {
eul[1] = oldeul[1];
- if (ob->protectflag & OB_LOCK_ROTZ)
+ }
+ if (ob->protectflag & OB_LOCK_ROTZ) {
eul[2] = oldeul[2];
+ }
if (ob->rotmode == ROT_MODE_QUAT) {
eul_to_quat(ob->quat, eul);
@@ -219,18 +238,21 @@ static void object_clear_rot(Object *ob, const bool clear_delta)
else {
if (ob->rotmode == ROT_MODE_QUAT) {
unit_qt(ob->quat);
- if (clear_delta)
+ if (clear_delta) {
unit_qt(ob->dquat);
+ }
}
else if (ob->rotmode == ROT_MODE_AXISANGLE) {
unit_axis_angle(ob->rotAxis, &ob->rotAngle);
- if (clear_delta)
+ if (clear_delta) {
unit_axis_angle(ob->drotAxis, &ob->drotAngle);
+ }
}
else {
zero_v3(ob->rot);
- if (clear_delta)
+ if (clear_delta) {
zero_v3(ob->drot);
+ }
}
}
}
@@ -241,18 +263,21 @@ static void object_clear_scale(Object *ob, const bool clear_delta)
/* clear scale factors which are not locked */
if ((ob->protectflag & OB_LOCK_SCALEX) == 0) {
ob->scale[0] = 1.0f;
- if (clear_delta)
+ if (clear_delta) {
ob->dscale[0] = 1.0f;
+ }
}
if ((ob->protectflag & OB_LOCK_SCALEY) == 0) {
ob->scale[1] = 1.0f;
- if (clear_delta)
+ if (clear_delta) {
ob->dscale[1] = 1.0f;
+ }
}
if ((ob->protectflag & OB_LOCK_SCALEZ) == 0) {
ob->scale[2] = 1.0f;
- if (clear_delta)
+ if (clear_delta) {
ob->dscale[2] = 1.0f;
+ }
}
}
@@ -585,8 +610,9 @@ static int apply_objects_internal(bContext *C,
}
CTX_DATA_END;
- if (!changed)
+ if (!changed) {
return OPERATOR_CANCELLED;
+ }
changed = false;
@@ -594,10 +620,12 @@ static int apply_objects_internal(bContext *C,
CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) {
/* calculate rotation/scale matrix */
- if (apply_scale && apply_rot)
+ if (apply_scale && apply_rot) {
BKE_object_to_mat3(ob, rsmat);
- else if (apply_scale)
+ }
+ else if (apply_scale) {
BKE_object_scale_to_mat3(ob, rsmat);
+ }
else if (apply_rot) {
float tmat[3][3], timat[3][3];
@@ -610,8 +638,9 @@ static int apply_objects_internal(bContext *C,
mul_m3_m3m3(rsmat, timat, rsmat);
mul_m3_m3m3(rsmat, rsmat, tmat);
}
- else
+ else {
unit_m3(rsmat);
+ }
copy_m4_m3(mat, rsmat);
@@ -633,8 +662,9 @@ static int apply_objects_internal(bContext *C,
if (ob->type == OB_MESH) {
Mesh *me = ob->data;
- if (apply_scale)
+ if (apply_scale) {
multiresModifier_scale_disp(depsgraph, scene, ob);
+ }
/* adjust data */
BKE_mesh_transform(me, mat, true);
@@ -687,11 +717,13 @@ static int apply_objects_internal(bContext *C,
/* applying scale on camera actually scales clip's reconstruction.
* of there's clip assigned to camera nothing to do actually.
*/
- if (!clip)
+ if (!clip) {
continue;
+ }
- if (apply_scale)
+ if (apply_scale) {
BKE_tracking_reconstruction_scale(&clip->tracking, ob->scale);
+ }
}
else if (ob->type == OB_EMPTY) {
/* It's possible for empties too, even though they don't
@@ -735,10 +767,12 @@ static int apply_objects_internal(bContext *C,
continue;
}
- if (apply_loc)
+ if (apply_loc) {
zero_v3(ob->loc);
- if (apply_scale)
+ }
+ if (apply_scale) {
ob->scale[0] = ob->scale[1] = ob->scale[2] = 1.0f;
+ }
if (apply_rot) {
zero_v3(ob->rot);
unit_qt(ob->quat);
@@ -785,8 +819,9 @@ static int visual_transform_apply_exec(bContext *C, wmOperator *UNUSED(op))
}
CTX_DATA_END;
- if (!changed)
+ if (!changed) {
return OPERATOR_CANCELLED;
+ }
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
return OPERATOR_FINISHED;
@@ -959,10 +994,12 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
}
for (tob = bmain->objects.first; tob; tob = tob->id.next) {
- if (tob->data)
+ if (tob->data) {
((ID *)tob->data)->tag &= ~LIB_TAG_DOIT;
- if (tob->instance_collection)
+ }
+ if (tob->instance_collection) {
((ID *)tob->instance_collection)->tag &= ~LIB_TAG_DOIT;
+ }
}
for (ctx_ob = ctx_data_list.first; ctx_ob; ctx_ob = ctx_ob->next) {
@@ -1050,8 +1087,9 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
}
/* don't allow Z change if curve is 2D */
- if ((ob->type == OB_CURVE) && !(cu->flag & CU_3D))
+ if ((ob->type == OB_CURVE) && !(cu->flag & CU_3D)) {
cent[2] = 0.0;
+ }
negate_v3_v3(cent_neg, cent);
BKE_curve_translate(cu, cent_neg, 1);
@@ -1120,8 +1158,9 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
ignore_parent_tx(C, bmain, scene, ob);
- if (obedit)
+ if (obedit) {
break;
+ }
}
}
else if (ob->type == OB_MBALL) {
@@ -1207,8 +1246,9 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
for (bGPDframe *gpf = gpl->frames.first; gpf; gpf = gpf->next) {
for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
/* skip strokes that are invalid for current view */
- if (ED_gpencil_stroke_can_use(C, gps) == false)
+ if (ED_gpencil_stroke_can_use(C, gps) == false) {
continue;
+ }
for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
float mpt[3];
@@ -1308,11 +1348,13 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
"%i object(s) not centered, %i changed:",
tot_lib_error + tot_multiuser_arm_error,
tot_change);
- if (tot_lib_error)
+ if (tot_lib_error) {
BKE_reportf(op->reports, RPT_WARNING, "|%i linked library object(s)", tot_lib_error);
- if (tot_multiuser_arm_error)
+ }
+ if (tot_multiuser_arm_error) {
BKE_reportf(
op->reports, RPT_WARNING, "|%i multiuser armature object(s)", tot_multiuser_arm_error);
+ }
}
return OPERATOR_FINISHED;
diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c
index d03f1974fd6..d422ee565a3 100644
--- a/source/blender/editors/object/object_vgroup.c
+++ b/source/blender/editors/object/object_vgroup.c
@@ -349,8 +349,9 @@ void ED_vgroup_parray_remove_zero(MDeformVert **dvert_array,
while (j--) {
MDeformWeight *dw;
- if (keep_single && dv->totweight == 1)
+ if (keep_single && dv->totweight == 1) {
break;
+ }
dw = dv->dw + j;
if ((dw->def_nr < vgroup_tot) && vgroup_validmap[dw->def_nr]) {
@@ -374,8 +375,9 @@ bool ED_vgroup_array_copy(Object *ob, Object *ob_from)
int defbase_tot = BLI_listbase_count(&ob->defbase);
bool new_vgroup = false;
- if (ob == ob_from)
+ if (ob == ob_from) {
return true;
+ }
/* In case we copy vgroup between two objects using same data,
* we only have to care about object side of things. */
@@ -391,10 +393,12 @@ bool ED_vgroup_array_copy(Object *ob, Object *ob_from)
if (dvert_tot == 0 || (dvert_tot != dvert_tot_from) || dvert_array_from == NULL ||
dvert_array == NULL) {
- if (dvert_array)
+ if (dvert_array) {
MEM_freeN(dvert_array);
- if (dvert_array_from)
+ }
+ if (dvert_array_from) {
MEM_freeN(dvert_array_from);
+ }
if (new_vgroup == true) {
/* free the newly added vgroup since it wasn't compatible */
@@ -414,10 +418,12 @@ bool ED_vgroup_array_copy(Object *ob, Object *ob_from)
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++)
+ for (i = 0; i <= defbase_tot_from; i++) {
remap[i] = i;
- for (; i <= defbase_tot; i++)
+ }
+ for (; i <= defbase_tot; i++) {
remap[i] = 0; /* can't use these, so disable */
+ }
BKE_object_defgroup_remap_update_users(ob, remap);
MEM_freeN(remap);
@@ -532,8 +538,9 @@ static void ED_mesh_defvert_mirror_update_ob(Object *ob, int def_nr, int vidx)
Mesh *me = ob->data;
bool use_topology = (me->editflag & ME_EDIT_MIRROR_TOPO) != 0;
- if (vidx == -1)
+ if (vidx == -1) {
return;
+ }
vidx_mirr = mesh_get_x_mirror_vert(ob, NULL, vidx, use_topology);
@@ -704,20 +711,24 @@ const EnumPropertyItem *ED_object_vgroup_selection_itemf_helper(const bContext *
}
ob = CTX_data_active_object(C);
- if (selection_mask & (1 << WT_VGROUP_ACTIVE))
+ if (selection_mask & (1 << WT_VGROUP_ACTIVE)) {
RNA_enum_items_add_value(&item, &totitem, WT_vertex_group_select_item, WT_VGROUP_ACTIVE);
+ }
if (BKE_object_pose_armature_get(ob)) {
- if (selection_mask & (1 << WT_VGROUP_BONE_SELECT))
+ if (selection_mask & (1 << WT_VGROUP_BONE_SELECT)) {
RNA_enum_items_add_value(
&item, &totitem, WT_vertex_group_select_item, WT_VGROUP_BONE_SELECT);
- if (selection_mask & (1 << WT_VGROUP_BONE_DEFORM))
+ }
+ if (selection_mask & (1 << WT_VGROUP_BONE_DEFORM)) {
RNA_enum_items_add_value(
&item, &totitem, WT_vertex_group_select_item, WT_VGROUP_BONE_DEFORM);
+ }
}
- if (selection_mask & (1 << WT_VGROUP_ALL))
+ if (selection_mask & (1 << WT_VGROUP_ALL)) {
RNA_enum_items_add_value(&item, &totitem, WT_vertex_group_select_item, WT_VGROUP_ALL);
+ }
RNA_enum_item_end(&item, &totitem);
*r_free = true;
@@ -779,12 +790,14 @@ static void ED_vgroup_nr_vert_add(
/* get the vert */
BKE_object_defgroup_array_get(ob->data, &dvert, &tot);
- if (dvert == NULL)
+ if (dvert == NULL) {
return;
+ }
/* check that vertnum is valid before trying to get the relevant dvert */
- if ((vertnum < 0) || (vertnum >= tot))
+ if ((vertnum < 0) || (vertnum >= tot)) {
return;
+ }
if (dvert) {
MDeformVert *dv = &dvert[vertnum];
@@ -804,8 +817,9 @@ static void ED_vgroup_nr_vert_add(
break;
case WEIGHT_ADD:
dw->weight += weight;
- if (dw->weight >= 1.0f)
+ if (dw->weight >= 1.0f) {
dw->weight = 1.0f;
+ }
break;
case WEIGHT_SUBTRACT:
dw->weight -= weight;
@@ -862,8 +876,9 @@ void ED_vgroup_vert_add(Object *ob, bDeformGroup *dg, int vertnum, float weight,
/* if there's no deform verts then create some,
*/
- if (BKE_object_defgroup_array_get(ob->data, &dv, &tot) && dv == NULL)
+ if (BKE_object_defgroup_array_get(ob->data, &dv, &tot) && dv == NULL) {
BKE_object_defgroup_data_create(ob->data);
+ }
/* call another function to do the work
*/
@@ -1003,10 +1018,12 @@ static void vgroup_select_verts(Object *ob, int select)
}
/* this has to be called, because this function operates on vertices only */
- if (select)
+ if (select) {
EDBM_select_flush(em); /* vertices to edges/faces */
- else
+ }
+ else {
EDBM_deselect_flush(em);
+ }
}
}
else {
@@ -1021,10 +1038,12 @@ static void vgroup_select_verts(Object *ob, int select)
for (i = 0; i < me->totvert; i++, mv++, dv++) {
if (!(mv->flag & ME_HIDE)) {
if (defvert_find_index(dv, def_nr)) {
- if (select)
+ if (select) {
mv->flag |= SELECT;
- else
+ }
+ else {
mv->flag &= ~SELECT;
+ }
}
}
}
@@ -1046,12 +1065,14 @@ static void vgroup_select_verts(Object *ob, int select)
tot = lt->pntsu * lt->pntsv * lt->pntsw;
for (a = 0, bp = lt->def; a < tot; a++, bp++, dv++) {
if (defvert_find_index(dv, def_nr)) {
- if (select)
+ if (select) {
bp->f1 |= SELECT;
+ }
else {
bp->f1 &= ~SELECT;
- if (actbp && bp == actbp)
+ if (actbp && bp == actbp) {
lt->actbp = LT_ACTBP_NONE;
+ }
}
}
}
@@ -1068,8 +1089,9 @@ static void vgroup_duplicate(Object *ob)
int i, idg, icdg, dvert_tot = 0;
dg = BLI_findlink(&ob->defbase, (ob->actdef - 1));
- if (!dg)
+ if (!dg) {
return;
+ }
if (!strstr(dg->name, "_copy")) {
BLI_snprintf(name, sizeof(name), "%s_copy", dg->name);
@@ -1206,15 +1228,19 @@ static int *getSurroundingVerts(Mesh *me, int vert, int *count)
k = BLI_array_len(verts);
/* XXX Maybe a == b is enough? */
while (k-- && !(a == b && a == -1)) {
- if (verts[k] == a)
+ if (verts[k] == a) {
a = -1;
- else if (verts[k] == b)
+ }
+ else if (verts[k] == b) {
b = -1;
+ }
}
- if (a != -1)
+ if (a != -1) {
BLI_array_append(verts, a);
- if (b != -1)
+ }
+ if (b != -1) {
BLI_array_append(verts, b);
+ }
/* Vert found in this poly, we can go to next one! */
break;
@@ -1483,8 +1509,9 @@ static void vgroup_fix(
Mesh *me = ob->data;
MVert *mvert = me->mvert;
int *verts = NULL;
- if (!(me->editflag & ME_EDIT_PAINT_VERT_SEL))
+ if (!(me->editflag & ME_EDIT_PAINT_VERT_SEL)) {
return;
+ }
for (i = 0; i < me->totvert && mvert; i++, mvert++) {
if (mvert->flag & SELECT) {
int count = 0;
@@ -1956,15 +1983,17 @@ static void vgroup_smooth_subset(Object *ob,
MEM_freeN(emap_mem);
}
- if (dvert_array)
+ if (dvert_array) {
MEM_freeN(dvert_array);
+ }
/* not so efficient to get 'dvert_array' again just so unselected verts are NULL'd */
if (use_mirror) {
ED_vgroup_parray_alloc(ob->data, &dvert_array, &dvert_tot, true);
ED_vgroup_parray_mirror_sync(ob, dvert_array, dvert_tot, vgroup_validmap, vgroup_tot);
- if (dvert_array)
+ if (dvert_array) {
MEM_freeN(dvert_array);
+ }
}
}
@@ -1978,14 +2007,18 @@ static int inv_cmp_mdef_vert_weights(const void *a1, const void *a2)
* This does the opposite. */
const struct MDeformWeight *dw1 = a1, *dw2 = a2;
- if (dw1->weight < dw2->weight)
+ if (dw1->weight < dw2->weight) {
return 1;
- else if (dw1->weight > dw2->weight)
+ }
+ else if (dw1->weight > dw2->weight) {
return -1;
- else if (&dw1 < &dw2)
+ }
+ else if (&dw1 < &dw2) {
return 1; /* compare address for stable sort algorithm */
- else
+ }
+ else {
return -1;
+ }
}
/* Used for limiting the number of influencing bones per vertex when exporting
@@ -2410,8 +2443,9 @@ cleanup:
*r_totmirr = totmirr;
*r_totfail = totfail;
- if (flip_map)
+ if (flip_map) {
MEM_freeN(flip_map);
+ }
#undef VGROUP_MIRR_OP
}
@@ -2419,8 +2453,9 @@ cleanup:
static void vgroup_delete_active(Object *ob)
{
bDeformGroup *dg = BLI_findlink(&ob->defbase, ob->actdef - 1);
- if (!dg)
+ if (!dg) {
return;
+ }
BKE_object_defgroup_remove(ob, dg);
}
@@ -2430,8 +2465,9 @@ static void vgroup_assign_verts(Object *ob, const float weight)
{
const int def_nr = ob->actdef - 1;
- if (!BLI_findlink(&ob->defbase, def_nr))
+ if (!BLI_findlink(&ob->defbase, def_nr)) {
return;
+ }
if (ob->type == OB_MESH) {
Mesh *me = ob->data;
@@ -2443,8 +2479,9 @@ static void vgroup_assign_verts(Object *ob, const float weight)
BMIter iter;
BMVert *eve;
- if (!CustomData_has_layer(&em->bm->vdata, CD_MDEFORMVERT))
+ if (!CustomData_has_layer(&em->bm->vdata, CD_MDEFORMVERT)) {
BM_data_layer_add(em->bm, &em->bm->vdata, CD_MDEFORMVERT);
+ }
cd_dvert_offset = CustomData_get_offset(&em->bm->vdata, CD_MDEFORMVERT);
@@ -2490,8 +2527,9 @@ static void vgroup_assign_verts(Object *ob, const float weight)
BPoint *bp;
int a, tot;
- if (lt->dvert == NULL)
+ if (lt->dvert == NULL) {
BKE_object_defgroup_data_create(&lt->id);
+ }
dv = lt->dvert;
@@ -2549,8 +2587,9 @@ static bool UNUSED_FUNCTION(vertex_group_poll_edit)(bContext *C)
Object *ob = ED_object_context(C);
ID *data = (ob) ? ob->data : NULL;
- if (!(ob && !ID_IS_LINKED(ob) && data && !ID_IS_LINKED(data)))
+ if (!(ob && !ID_IS_LINKED(ob) && data && !ID_IS_LINKED(data))) {
return 0;
+ }
return BKE_object_is_in_editmode_vgroup(ob);
}
@@ -2563,8 +2602,9 @@ static bool vertex_group_vert_poll_ex(bContext *C,
Object *ob = ED_object_context(C);
ID *data = (ob) ? ob->data : NULL;
- if (!(ob && !ID_IS_LINKED(ob) && data && !ID_IS_LINKED(data)))
+ if (!(ob && !ID_IS_LINKED(ob) && data && !ID_IS_LINKED(data))) {
return false;
+ }
if (ob_type_flag && (((1 << ob->type) & ob_type_flag)) == 0) {
return false;
@@ -2622,8 +2662,9 @@ static bool vertex_group_vert_select_unlocked_poll(bContext *C)
Object *ob = ED_object_context(C);
ID *data = (ob) ? ob->data : NULL;
- if (!(ob && !ID_IS_LINKED(ob) && data && !ID_IS_LINKED(data)))
+ if (!(ob && !ID_IS_LINKED(ob) && data && !ID_IS_LINKED(data))) {
return 0;
+ }
if (!(BKE_object_is_in_editmode_vgroup(ob) || BKE_object_is_in_wpaint_select_vert(ob))) {
return 0;
@@ -2643,12 +2684,14 @@ static bool vertex_group_vert_select_mesh_poll(bContext *C)
Object *ob = ED_object_context(C);
ID *data = (ob) ? ob->data : NULL;
- if (!(ob && !ID_IS_LINKED(ob) && data && !ID_IS_LINKED(data)))
+ if (!(ob && !ID_IS_LINKED(ob) && data && !ID_IS_LINKED(data))) {
return 0;
+ }
/* only difference to #vertex_group_vert_select_poll */
- if (ob->type != OB_MESH)
+ if (ob->type != OB_MESH) {
return 0;
+ }
return (BKE_object_is_in_editmode_vgroup(ob) || BKE_object_is_in_wpaint_select_vert(ob));
}
@@ -2684,12 +2727,15 @@ static int vertex_group_remove_exec(bContext *C, wmOperator *op)
{
Object *ob = ED_object_context(C);
- if (RNA_boolean_get(op->ptr, "all"))
+ if (RNA_boolean_get(op->ptr, "all")) {
BKE_object_defgroup_remove_all(ob);
- else if (RNA_boolean_get(op->ptr, "all_unlocked"))
+ }
+ else if (RNA_boolean_get(op->ptr, "all_unlocked")) {
BKE_object_defgroup_remove_all_ex(ob, true);
- else
+ }
+ else {
vgroup_delete_active(ob);
+ }
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_GEOM | ND_VERTEX_GROUP, ob->data);
@@ -2837,8 +2883,9 @@ static int vertex_group_select_exec(bContext *C, wmOperator *UNUSED(op))
{
Object *ob = ED_object_context(C);
- if (!ob || ID_IS_LINKED(ob))
+ if (!ob || ID_IS_LINKED(ob)) {
return OPERATOR_CANCELLED;
+ }
vgroup_select_verts(ob, 1);
DEG_id_tag_update(ob->data, ID_RECALC_COPY_ON_WRITE | ID_RECALC_SELECT);
@@ -3574,8 +3621,9 @@ static const EnumPropertyItem *vgroup_itemf(bContext *C,
bDeformGroup *def;
int a, totitem = 0;
- if (!ob)
+ if (!ob) {
return DummyRNA_NULL_items;
+ }
for (a = 0, def = ob->defbase.first; def; def = def->next, a++) {
tmp.value = a;
@@ -3686,16 +3734,18 @@ static int vgroup_do_remap(Object *ob, const char *name_array, wmOperator *op)
/*create as necessary*/
if (dvert) {
while (dvert_tot--) {
- if (dvert->totweight)
+ if (dvert->totweight) {
defvert_remap(dvert, sort_map, defbase_tot);
+ }
dvert++;
}
}
}
/* update users */
- for (i = 0; i < defbase_tot; i++)
+ for (i = 0; i < defbase_tot; i++) {
sort_map[i]++;
+ }
sort_map_update[0] = 0;
BKE_object_defgroup_remap_update_users(ob, sort_map_update);
@@ -3779,8 +3829,9 @@ static int vertex_group_sort_exec(bContext *C, wmOperator *op)
WM_event_add_notifier(C, NC_GEOM | ND_VERTEX_GROUP, ob);
}
- if (name_array)
+ if (name_array) {
MEM_freeN(name_array);
+ }
return ret;
}
@@ -3831,8 +3882,9 @@ static int vgroup_move_exec(bContext *C, wmOperator *op)
}
}
- if (name_array)
+ if (name_array) {
MEM_freeN(name_array);
+ }
return ret;
}