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
path: root/source
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
parentbba60bb564cf5a16cfcac744d4ba82cf8eba3da9 (diff)
Cleanup: style, use braces for editors
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/animation/anim_channels_defines.c263
-rw-r--r--source/blender/editors/animation/anim_channels_edit.c295
-rw-r--r--source/blender/editors/animation/anim_deps.c45
-rw-r--r--source/blender/editors/animation/anim_draw.c51
-rw-r--r--source/blender/editors/animation/anim_filter.c213
-rw-r--r--source/blender/editors/animation/anim_ipo_utils.c39
-rw-r--r--source/blender/editors/animation/anim_markers.c87
-rw-r--r--source/blender/editors/animation/anim_motion_paths.c15
-rw-r--r--source/blender/editors/animation/anim_ops.c48
-rw-r--r--source/blender/editors/animation/drivers.c69
-rw-r--r--source/blender/editors/animation/fmodifier_ui.c57
-rw-r--r--source/blender/editors/animation/keyframes_draw.c69
-rw-r--r--source/blender/editors/animation/keyframes_edit.c225
-rw-r--r--source/blender/editors/animation/keyframes_general.c96
-rw-r--r--source/blender/editors/animation/keyframing.c234
-rw-r--r--source/blender/editors/animation/keyingsets.c129
-rw-r--r--source/blender/editors/armature/armature_add.c72
-rw-r--r--source/blender/editors/armature/armature_edit.c84
-rw-r--r--source/blender/editors/armature/armature_naming.c24
-rw-r--r--source/blender/editors/armature/armature_relations.c33
-rw-r--r--source/blender/editors/armature/armature_select.c84
-rw-r--r--source/blender/editors/armature/armature_skinning.c42
-rw-r--r--source/blender/editors/armature/armature_utils.c45
-rw-r--r--source/blender/editors/armature/meshlaplacian.c312
-rw-r--r--source/blender/editors/armature/pose_edit.c27
-rw-r--r--source/blender/editors/armature/pose_group.c60
-rw-r--r--source/blender/editors/armature/pose_lib.c174
-rw-r--r--source/blender/editors/armature/pose_select.c66
-rw-r--r--source/blender/editors/armature/pose_slide.c54
-rw-r--r--source/blender/editors/armature/pose_transform.c105
-rw-r--r--source/blender/editors/armature/pose_utils.c27
-rw-r--r--source/blender/editors/gizmo_library/gizmo_library_utils.c3
-rw-r--r--source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c3
-rw-r--r--source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c3
-rw-r--r--source/blender/editors/gpencil/annotate_draw.c72
-rw-r--r--source/blender/editors/gpencil/annotate_paint.c150
-rw-r--r--source/blender/editors/gpencil/drawgpencil.c27
-rw-r--r--source/blender/editors/gpencil/editaction_gpencil.c72
-rw-r--r--source/blender/editors/gpencil/gpencil_armature.c12
-rw-r--r--source/blender/editors/gpencil/gpencil_brush.c21
-rw-r--r--source/blender/editors/gpencil/gpencil_convert.c39
-rw-r--r--source/blender/editors/gpencil/gpencil_data.c132
-rw-r--r--source/blender/editors/gpencil/gpencil_edit.c159
-rw-r--r--source/blender/editors/gpencil/gpencil_fill.c12
-rw-r--r--source/blender/editors/gpencil/gpencil_interpolate.c6
-rw-r--r--source/blender/editors/gpencil/gpencil_merge.c6
-rw-r--r--source/blender/editors/gpencil/gpencil_paint.c130
-rw-r--r--source/blender/editors/gpencil/gpencil_primitive.c48
-rw-r--r--source/blender/editors/gpencil/gpencil_select.c18
-rw-r--r--source/blender/editors/gpencil/gpencil_utils.c93
-rw-r--r--source/blender/editors/io/io_alembic.c6
-rw-r--r--source/blender/editors/io/io_collada.c12
-rw-r--r--source/blender/editors/lattice/editlattice_select.c3
-rw-r--r--source/blender/editors/lattice/editlattice_tools.c3
-rw-r--r--source/blender/editors/mask/mask_add.c27
-rw-r--r--source/blender/editors/mask/mask_draw.c33
-rw-r--r--source/blender/editors/mask/mask_edit.c3
-rw-r--r--source/blender/editors/mask/mask_editaction.c60
-rw-r--r--source/blender/editors/mask/mask_ops.c102
-rw-r--r--source/blender/editors/mask/mask_select.c24
-rw-r--r--source/blender/editors/mesh/editface.c33
-rw-r--r--source/blender/editors/mesh/editmesh_bevel.c39
-rw-r--r--source/blender/editors/mesh/editmesh_extrude.c27
-rw-r--r--source/blender/editors/mesh/editmesh_extrude_screw.c3
-rw-r--r--source/blender/editors/mesh/editmesh_inset.c24
-rw-r--r--source/blender/editors/mesh/editmesh_intersect.c9
-rw-r--r--source/blender/editors/mesh/editmesh_knife.c138
-rw-r--r--source/blender/editors/mesh/editmesh_loopcut.c12
-rw-r--r--source/blender/editors/mesh/editmesh_path.c42
-rw-r--r--source/blender/editors/mesh/editmesh_preselect_edgering.c3
-rw-r--r--source/blender/editors/mesh/editmesh_rip.c9
-rw-r--r--source/blender/editors/mesh/editmesh_rip_edge.c3
-rw-r--r--source/blender/editors/mesh/editmesh_select.c66
-rw-r--r--source/blender/editors/mesh/editmesh_select_similar.c12
-rw-r--r--source/blender/editors/mesh/editmesh_tools.c136
-rw-r--r--source/blender/editors/mesh/editmesh_utils.c51
-rw-r--r--source/blender/editors/mesh/mesh_data.c87
-rw-r--r--source/blender/editors/mesh/mesh_mirror.c18
-rw-r--r--source/blender/editors/mesh/meshtools.c87
-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
-rw-r--r--source/blender/editors/physics/dynamicpaint_ops.c33
-rw-r--r--source/blender/editors/physics/particle_boids.c36
-rw-r--r--source/blender/editors/physics/particle_edit.c506
-rw-r--r--source/blender/editors/physics/particle_object.c138
-rw-r--r--source/blender/editors/physics/physics_fluid.c72
-rw-r--r--source/blender/editors/physics/rigidbody_constraint.c3
-rw-r--r--source/blender/editors/physics/rigidbody_object.c9
-rw-r--r--source/blender/editors/physics/rigidbody_world.c6
-rw-r--r--source/blender/editors/render/render_internal.c144
-rw-r--r--source/blender/editors/render/render_opengl.c54
-rw-r--r--source/blender/editors/render/render_preview.c123
-rw-r--r--source/blender/editors/render/render_shading.c60
-rw-r--r--source/blender/editors/render/render_update.c24
-rw-r--r--source/blender/editors/render/render_view.c30
-rw-r--r--source/blender/editors/scene/scene_edit.c12
-rw-r--r--source/blender/editors/screen/area.c129
-rw-r--r--source/blender/editors/screen/glutil.c42
-rw-r--r--source/blender/editors/screen/screen_context.c48
-rw-r--r--source/blender/editors/screen/screen_edit.c123
-rw-r--r--source/blender/editors/screen/screen_geometry.c12
-rw-r--r--source/blender/editors/screen/screen_ops.c459
-rw-r--r--source/blender/editors/screen/screendump.c18
-rw-r--r--source/blender/editors/sculpt_paint/paint_cursor.c102
-rw-r--r--source/blender/editors/sculpt_paint/paint_curve.c60
-rw-r--r--source/blender/editors/sculpt_paint/paint_hide.c42
-rw-r--r--source/blender/editors/sculpt_paint/paint_image.c90
-rw-r--r--source/blender/editors/sculpt_paint/paint_image_2d.c225
-rw-r--r--source/blender/editors/sculpt_paint/paint_image_proj.c276
-rw-r--r--source/blender/editors/sculpt_paint/paint_mask.c45
-rw-r--r--source/blender/editors/sculpt_paint/paint_ops.c51
-rw-r--r--source/blender/editors/sculpt_paint/paint_stroke.c102
-rw-r--r--source/blender/editors/sculpt_paint/paint_utils.c42
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex.c87
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex_color_ops.c9
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c303
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_undo.c105
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_uv.c24
-rw-r--r--source/blender/editors/sound/sound_ops.c81
-rw-r--r--source/blender/editors/space_action/action_data.c21
-rw-r--r--source/blender/editors/space_action/action_draw.c27
-rw-r--r--source/blender/editors/space_action/action_edit.c114
-rw-r--r--source/blender/editors/space_action/action_select.c111
-rw-r--r--source/blender/editors/space_action/space_action.c36
-rw-r--r--source/blender/editors/space_api/spacetypes.c9
-rw-r--r--source/blender/editors/space_clip/clip_buttons.c57
-rw-r--r--source/blender/editors/space_clip/clip_dopesheet_draw.c9
-rw-r--r--source/blender/editors/space_clip/clip_dopesheet_ops.c12
-rw-r--r--source/blender/editors/space_clip/clip_draw.c117
-rw-r--r--source/blender/editors/space_clip/clip_editor.c66
-rw-r--r--source/blender/editors/space_clip/clip_graph_draw.c6
-rw-r--r--source/blender/editors/space_clip/clip_graph_ops.c51
-rw-r--r--source/blender/editors/space_clip/clip_ops.c93
-rw-r--r--source/blender/editors/space_clip/clip_toolbar.c6
-rw-r--r--source/blender/editors/space_clip/clip_utils.c24
-rw-r--r--source/blender/editors/space_clip/space_clip.c90
-rw-r--r--source/blender/editors/space_clip/tracking_ops.c6
-rw-r--r--source/blender/editors/space_clip/tracking_ops_orient.c6
-rw-r--r--source/blender/editors/space_clip/tracking_ops_solve.c3
-rw-r--r--source/blender/editors/space_clip/tracking_select.c45
-rw-r--r--source/blender/editors/space_file/file_draw.c6
-rw-r--r--source/blender/editors/space_file/file_ops.c84
-rw-r--r--source/blender/editors/space_file/filelist.c111
-rw-r--r--source/blender/editors/space_file/filesel.c84
-rw-r--r--source/blender/editors/space_file/fsmenu.c21
-rw-r--r--source/blender/editors/space_file/space_file.c12
-rw-r--r--source/blender/editors/space_graph/graph_buttons.c54
-rw-r--r--source/blender/editors/space_graph/graph_draw.c45
-rw-r--r--source/blender/editors/space_graph/graph_edit.c258
-rw-r--r--source/blender/editors/space_graph/graph_ops.c36
-rw-r--r--source/blender/editors/space_graph/graph_select.c162
-rw-r--r--source/blender/editors/space_graph/graph_utils.c42
-rw-r--r--source/blender/editors/space_graph/space_graph.c27
-rw-r--r--source/blender/editors/space_info/textview.c3
-rw-r--r--source/blender/editors/space_nla/nla_buttons.c42
-rw-r--r--source/blender/editors/space_nla/nla_channels.c72
-rw-r--r--source/blender/editors/space_nla/nla_draw.c30
-rw-r--r--source/blender/editors/space_nla/nla_edit.c171
-rw-r--r--source/blender/editors/space_nla/nla_ops.c15
-rw-r--r--source/blender/editors/space_nla/nla_select.c60
-rw-r--r--source/blender/editors/space_nla/space_nla.c24
-rw-r--r--source/blender/editors/space_outliner/outliner_select.c3
-rw-r--r--source/blender/editors/space_outliner/outliner_tree.c2
-rw-r--r--source/blender/editors/space_text/space_text.c12
-rw-r--r--source/blender/editors/space_text/text_autocomplete.c66
-rw-r--r--source/blender/editors/space_text/text_draw.c186
-rw-r--r--source/blender/editors/space_text/text_format.c15
-rw-r--r--source/blender/editors/space_text/text_format_lua.c137
-rw-r--r--source/blender/editors/space_text/text_format_osl.c172
-rw-r--r--source/blender/editors/space_text/text_format_pov.c1245
-rw-r--r--source/blender/editors/space_text/text_format_pov_ini.c523
-rw-r--r--source/blender/editors/space_text/text_format_py.c110
-rw-r--r--source/blender/editors/space_text/text_header.c9
-rw-r--r--source/blender/editors/space_text/text_ops.c307
-rw-r--r--source/blender/editors/transform/transform.c564
-rw-r--r--source/blender/editors/transform/transform_constraints.c66
-rw-r--r--source/blender/editors/transform/transform_conversions.c818
-rw-r--r--source/blender/editors/transform/transform_generics.c138
-rw-r--r--source/blender/editors/transform/transform_gizmo_2d.c6
-rw-r--r--source/blender/editors/transform/transform_gizmo_3d.c36
-rw-r--r--source/blender/editors/transform/transform_input.c6
-rw-r--r--source/blender/editors/transform/transform_ops.c6
-rw-r--r--source/blender/editors/transform/transform_orientations.c24
-rw-r--r--source/blender/editors/transform/transform_snap.c75
-rw-r--r--source/blender/editors/transform/transform_snap_object.c3
-rw-r--r--source/blender/editors/undo/ed_undo.c6
-rw-r--r--source/blender/editors/util/ed_transverts.c27
-rw-r--r--source/blender/editors/util/ed_util.c12
-rw-r--r--source/blender/editors/uvedit/uvedit_buttons.c9
-rw-r--r--source/blender/editors/uvedit/uvedit_draw.c18
-rw-r--r--source/blender/editors/uvedit/uvedit_ops.c261
-rw-r--r--source/blender/editors/uvedit/uvedit_parametrizer.c450
-rw-r--r--source/blender/editors/uvedit/uvedit_smart_stitch.c70
-rw-r--r--source/blender/editors/uvedit/uvedit_unwrap_ops.c213
209 files changed, 11909 insertions, 6465 deletions
diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c
index a17ee820595..bab76911449 100644
--- a/source/blender/editors/animation/anim_channels_defines.c
+++ b/source/blender/editors/animation/anim_channels_defines.c
@@ -298,8 +298,9 @@ static short acf_generic_indention_flexible(bAnimContext *UNUSED(ac), bAnimListE
FCurve *fcu = (FCurve *)ale->data;
// TODO: we need some way of specifying that the indention color should be one less...
- if (fcu->grp)
+ if (fcu->grp) {
indent++;
+ }
}
/* no indention */
@@ -311,10 +312,12 @@ static short acf_generic_basic_offset(bAnimContext *ac, bAnimListElem *ale)
{
const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale);
- if (acf && acf->get_indent_level)
+ if (acf && acf->get_indent_level) {
return acf->get_indent_level(ac, ale) * INDENT_STEP_SIZE;
- else
+ }
+ else {
return 0;
+ }
}
/* offset based on nodetree type */
@@ -353,13 +356,15 @@ static short acf_generic_group_offset(bAnimContext *ac, bAnimListElem *ale)
offset += U.widget_unit;
}
/* materials and particles animdata */
- else if (ELEM(GS(ale->id->name), ID_MA, ID_PA))
+ else if (ELEM(GS(ale->id->name), ID_MA, ID_PA)) {
offset += (short)(0.7f * U.widget_unit);
- /* If not in Action Editor mode, action-groups (and their children)
+ /* If not in Action Editor mode, action-groups (and their children)
* must carry some offset too. */
- else if (ac->datatype != ANIMCONT_ACTION)
+ }
+ else if (ac->datatype != ANIMCONT_ACTION) {
offset += (short)(0.7f * U.widget_unit);
+ }
/* nodetree animdata */
if (GS(ale->id->name) == ID_NT) {
@@ -379,8 +384,9 @@ static void acf_generic_idblock_name(bAnimListElem *ale, char *name)
ID *id = (ID *)ale->data; /* data pointed to should be an ID block */
/* just copy the name... */
- if (id && name)
+ if (id && name) {
BLI_strncpy(name, id->name + 2, ANIM_CHAN_NAME_SIZE);
+ }
}
/* name property for ID block entries */
@@ -477,8 +483,9 @@ static void acf_summary_backdrop(bAnimContext *ac, bAnimListElem *ale, float ymi
/* name for summary entries */
static void acf_summary_name(bAnimListElem *UNUSED(ale), char *name)
{
- if (name)
+ if (name) {
BLI_strncpy(name, IFACE_("Dope Sheet Summary"), ANIM_CHAN_NAME_SIZE);
+ }
}
// FIXME: this is really a temp icon I think
@@ -636,8 +643,9 @@ static void *acf_scene_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings set
case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
- if (scene->adt)
+ if (scene->adt) {
return GET_ACF_FLAG_PTR(scene->adt->flag, type);
+ }
return NULL;
default: /* unsupported */
@@ -711,8 +719,9 @@ static void acf_object_name(bAnimListElem *ale, char *name)
Object *ob = base->object;
/* just copy the name... */
- if (ob && name)
+ if (ob && name) {
BLI_strncpy(name, ob->id.name + 2, ANIM_CHAN_NAME_SIZE);
+ }
}
/* name property for object */
@@ -804,8 +813,9 @@ static void *acf_object_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings se
case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
case ACHANNEL_SETTING_ALWAYS_VISIBLE:
- if (ob->adt)
+ if (ob->adt) {
return GET_ACF_FLAG_PTR(ob->adt->flag, type);
+ }
return NULL;
default: /* unsupported */
@@ -844,20 +854,24 @@ static void acf_group_color(bAnimContext *ac, bAnimListElem *ale, float r_color[
unsigned char cp[3];
/* highlight only for active */
- if (ale->flag & AGRP_ACTIVE)
+ if (ale->flag & AGRP_ACTIVE) {
copy_v3_v3_char((char *)cp, agrp->cs.select);
- else
+ }
+ else {
copy_v3_v3_char((char *)cp, agrp->cs.solid);
+ }
/* copy the colors over, transforming from bytes to floats */
rgb_uchar_to_float(r_color, cp);
}
else {
/* highlight only for active */
- if (ale->flag & AGRP_ACTIVE)
+ if (ale->flag & AGRP_ACTIVE) {
UI_GetThemeColor3fv(TH_GROUP_ACTIVE, r_color);
- else
+ }
+ else {
UI_GetThemeColor3fv(TH_GROUP, r_color);
+ }
}
}
@@ -885,8 +899,9 @@ static void acf_group_name(bAnimListElem *ale, char *name)
bActionGroup *agrp = (bActionGroup *)ale->data;
/* just copy the name... */
- if (agrp && name)
+ if (agrp && name) {
BLI_strncpy(name, agrp->name, ANIM_CHAN_NAME_SIZE);
+ }
}
/* name property for group entries */
@@ -1039,10 +1054,12 @@ static bool acf_fcurve_setting_valid(bAnimContext *ac,
/* conditionally available */
case ACHANNEL_SETTING_PROTECT: /* Protection is only valid when there's keyframes */
- if (fcu->bezt)
+ if (fcu->bezt) {
return true;
- else
+ }
+ else {
return false; // NOTE: in this special case, we need to draw ICON_ZOOMOUT
+ }
case ACHANNEL_SETTING_VISIBLE: /* Only available in Graph Editor */
return (ac->spacetype == SPACE_GRAPH);
@@ -1492,8 +1509,9 @@ static void *acf_dsmat_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings set
case ACHANNEL_SETTING_SELECT: /* selected */
case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
- if (ma->adt)
+ if (ma->adt) {
return GET_ACF_FLAG_PTR(ma->adt->flag, type);
+ }
return NULL;
default: /* unsupported */
@@ -1572,8 +1590,9 @@ static void *acf_dslight_setting_ptr(bAnimListElem *ale,
case ACHANNEL_SETTING_SELECT: /* selected */
case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
- if (la->adt)
+ if (la->adt) {
return GET_ACF_FLAG_PTR(la->adt->flag, type);
+ }
return NULL;
default: /* unsupported */
@@ -1657,8 +1676,9 @@ static void *acf_dstex_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings set
case ACHANNEL_SETTING_SELECT: /* selected */
case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
- if (tex->adt)
+ if (tex->adt) {
return GET_ACF_FLAG_PTR(tex->adt->flag, type);
+ }
return NULL;
default: /* unsupported */
@@ -1822,8 +1842,9 @@ static void *acf_dscam_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings set
case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
case ACHANNEL_SETTING_ALWAYS_VISIBLE:
- if (ca->adt)
+ if (ca->adt) {
return GET_ACF_FLAG_PTR(ca->adt->flag, type);
+ }
return NULL;
default: /* unsupported */
@@ -1910,8 +1931,9 @@ static void *acf_dscur_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings set
case ACHANNEL_SETTING_SELECT: /* selected */
case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
- if (cu->adt)
+ if (cu->adt) {
return GET_ACF_FLAG_PTR(cu->adt->flag, type);
+ }
return NULL;
default: /* unsupported */
@@ -1988,8 +2010,9 @@ static void *acf_dsskey_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings se
case ACHANNEL_SETTING_SELECT: /* selected */
case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
- if (key->adt)
+ if (key->adt) {
return GET_ACF_FLAG_PTR(key->adt->flag, type);
+ }
return NULL;
default: /* unsupported */
@@ -2066,8 +2089,9 @@ static void *acf_dswor_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings set
case ACHANNEL_SETTING_SELECT: /* selected */
case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
- if (wo->adt)
+ if (wo->adt) {
return GET_ACF_FLAG_PTR(wo->adt->flag, type);
+ }
return NULL;
default: /* unsupported */
@@ -2144,8 +2168,9 @@ static void *acf_dspart_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings se
case ACHANNEL_SETTING_SELECT: /* selected */
case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
- if (part->adt)
+ if (part->adt) {
return GET_ACF_FLAG_PTR(part->adt->flag, type);
+ }
return NULL;
default: /* unsupported */
@@ -2224,8 +2249,9 @@ static void *acf_dsmball_setting_ptr(bAnimListElem *ale,
case ACHANNEL_SETTING_SELECT: /* selected */
case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
- if (mb->adt)
+ if (mb->adt) {
return GET_ACF_FLAG_PTR(mb->adt->flag, type);
+ }
return NULL;
default: /* unsupported */
@@ -2302,8 +2328,9 @@ static void *acf_dsarm_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings set
case ACHANNEL_SETTING_SELECT: /* selected */
case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
- if (arm->adt)
+ if (arm->adt) {
return GET_ACF_FLAG_PTR(arm->adt->flag, type);
+ }
return NULL;
default: /* unsupported */
@@ -2393,8 +2420,9 @@ static void *acf_dsntree_setting_ptr(bAnimListElem *ale,
case ACHANNEL_SETTING_SELECT: /* selected */
case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
- if (ntree->adt)
+ if (ntree->adt) {
return GET_ACF_FLAG_PTR(ntree->adt->flag, type);
+ }
return NULL;
default: /* unsupported */
@@ -2473,8 +2501,9 @@ static void *acf_dslinestyle_setting_ptr(bAnimListElem *ale,
case ACHANNEL_SETTING_SELECT: /* selected */
case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
- if (linestyle->adt)
+ if (linestyle->adt) {
return GET_ACF_FLAG_PTR(linestyle->adt->flag, type);
+ }
return NULL;
default: /* unsupported */
@@ -2551,8 +2580,9 @@ static void *acf_dsmesh_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings se
case ACHANNEL_SETTING_SELECT: /* selected */
case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
- if (me->adt)
+ if (me->adt) {
return GET_ACF_FLAG_PTR(me->adt->flag, type);
+ }
return NULL;
default: /* unsupported */
@@ -2630,8 +2660,9 @@ static void *acf_dslat_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings set
case ACHANNEL_SETTING_SELECT: /* selected */
case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
- if (lt->adt)
+ if (lt->adt) {
return GET_ACF_FLAG_PTR(lt->adt->flag, type);
+ }
return NULL;
default: /* unsupported */
@@ -2709,8 +2740,9 @@ static void *acf_dsspk_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings set
case ACHANNEL_SETTING_SELECT: /* selected */
case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
- if (spk->adt)
+ if (spk->adt) {
return GET_ACF_FLAG_PTR(spk->adt->flag, type);
+ }
return NULL;
default: /* unsupported */
@@ -2789,8 +2821,9 @@ static void *acf_dsgpencil_setting_ptr(bAnimListElem *ale,
case ACHANNEL_SETTING_SELECT: /* selected */
case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
- if (gpd->adt)
+ if (gpd->adt) {
return GET_ACF_FLAG_PTR(gpd->adt->flag, type);
+ }
return NULL;
default: /* unsupported */
@@ -2908,10 +2941,12 @@ static void acf_shapekey_name(bAnimListElem *ale, char *name)
/* just copy the name... */
if (kb && name) {
/* if the KeyBlock had a name, use it, otherwise use the index */
- if (kb->name[0])
+ if (kb->name[0]) {
BLI_strncpy(name, kb->name, ANIM_CHAN_NAME_SIZE);
- else
+ }
+ else {
BLI_snprintf(name, ANIM_CHAN_NAME_SIZE, IFACE_("Key %d"), ale->index);
+ }
}
}
@@ -3098,8 +3133,9 @@ static void acf_gpl_name(bAnimListElem *ale, char *name)
{
bGPDlayer *gpl = (bGPDlayer *)ale->data;
- if (gpl && name)
+ if (gpl && name) {
BLI_strncpy(name, gpl->info, ANIM_CHAN_NAME_SIZE);
+ }
}
/* name property for grease pencil layer entries */
@@ -3276,8 +3312,9 @@ static void acf_masklay_name(bAnimListElem *ale, char *name)
{
MaskLayer *masklay = (MaskLayer *)ale->data;
- if (masklay && name)
+ if (masklay && name) {
BLI_strncpy(name, masklay->name, ANIM_CHAN_NAME_SIZE);
+ }
}
/* name property for grease pencil layer entries */
@@ -3387,8 +3424,9 @@ static void acf_nlatrack_name(bAnimListElem *ale, char *name)
{
NlaTrack *nlt = (NlaTrack *)ale->data;
- if (nlt && name)
+ if (nlt && name) {
BLI_strncpy(name, nlt->name, ANIM_CHAN_NAME_SIZE);
+ }
}
/* name property for nla track entries */
@@ -3559,10 +3597,12 @@ static void acf_nlaaction_backdrop(bAnimContext *ac, bAnimListElem *ale, float y
*/
nla_action_get_color(adt, (bAction *)ale->data, color);
- if (adt && (adt->flag & ADT_NLA_EDIT_ON))
+ if (adt && (adt->flag & ADT_NLA_EDIT_ON)) {
color[3] = 1.0f;
- else
+ }
+ else {
color[3] = (adt && (adt->flag & ADT_NLA_SOLO_TRACK)) ? 0.3f : 1.0f;
+ }
/* only on top left corner, to show that this channel sits on top of the preceding ones
* while still linking into the action line strip to the right
@@ -3755,17 +3795,20 @@ static void ANIM_init_channel_typeinfo_data(void)
const bAnimChannelType *ANIM_channel_get_typeinfo(bAnimListElem *ale)
{
/* santiy checks */
- if (ale == NULL)
+ if (ale == NULL) {
return NULL;
+ }
/* init the typeinfo if not available yet... */
ANIM_init_channel_typeinfo_data();
/* check if type is in bounds... */
- if ((ale->type >= 0) && (ale->type < ANIMTYPE_NUM_TYPES))
+ if ((ale->type >= 0) && (ale->type < ANIMTYPE_NUM_TYPES)) {
return animchannelTypeInfo[ale->type];
- else
+ }
+ else {
return NULL;
+ }
}
/* --------------------------- */
@@ -3776,26 +3819,31 @@ void ANIM_channel_debug_print_info(bAnimListElem *ale, short indent_level)
const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale);
/* print indents */
- for (; indent_level > 0; indent_level--)
+ for (; indent_level > 0; indent_level--) {
printf(" ");
+ }
/* print info */
if (acf) {
char name[ANIM_CHAN_NAME_SIZE]; /* hopefully this will be enough! */
/* get UI name */
- if (acf->name)
+ if (acf->name) {
acf->name(ale, name);
- else
+ }
+ else {
BLI_strncpy(name, "<No name>", sizeof(name));
+ }
/* print type name + ui name */
printf("ChanType: <%s> Name: \"%s\"\n", acf->channel_type_name, name);
}
- else if (ale)
+ else if (ale) {
printf("ChanType: <Unknown - %d>\n", ale->type);
- else
+ }
+ else {
printf("<Invalid channel - NULL>\n");
+ }
}
/* --------------------------- */
@@ -3825,28 +3873,34 @@ short ANIM_channel_setting_get(bAnimContext *ac, bAnimListElem *ale, eAnimChanne
{
const int *val = (int *)ptr;
- if (negflag)
+ if (negflag) {
return ((*val) & flag) == 0;
- else
+ }
+ else {
return ((*val) & flag) != 0;
+ }
}
case sizeof(short): /* short pointer for setting */
{
const short *val = (short *)ptr;
- if (negflag)
+ if (negflag) {
return ((*val) & flag) == 0;
- else
+ }
+ else {
return ((*val) & flag) != 0;
+ }
}
case sizeof(char): /* char pointer for setting */
{
const char *val = (char *)ptr;
- if (negflag)
+ if (negflag) {
return ((*val) & flag) == 0;
- else
+ }
+ else {
return ((*val) & flag) != 0;
+ }
}
}
}
@@ -3962,14 +4016,17 @@ void ANIM_channel_draw(
float y, ymid, ytext;
/* sanity checks - don't draw anything */
- if (ELEM(NULL, acf, ale))
+ if (ELEM(NULL, acf, ale)) {
return;
+ }
/* get initial offset */
- if (acf->get_offset)
+ if (acf->get_offset) {
offset = acf->get_offset(ac, ale);
- else
+ }
+ else {
offset = 0;
+ }
/* calculate appropriate y-coordinates for icon buttons */
y = (ymaxc - yminc) / 2 + yminc;
@@ -3978,10 +4035,12 @@ void ANIM_channel_draw(
ytext = y - 0.2f * U.widget_unit;
/* check if channel is selected */
- if (acf->has_setting(ac, ale, ACHANNEL_SETTING_SELECT))
+ if (acf->has_setting(ac, ale, ACHANNEL_SETTING_SELECT)) {
selected = ANIM_channel_setting_get(ac, ale, ACHANNEL_SETTING_SELECT);
- else
+ }
+ else {
selected = 0;
+ }
/* set blending again, as may not be set in previous step */
GPU_blend_set_func_separate(
@@ -3989,8 +4048,9 @@ void ANIM_channel_draw(
GPU_blend(true);
/* step 1) draw backdrop ........................................... */
- if (acf->draw_backdrop)
+ if (acf->draw_backdrop) {
acf->draw_backdrop(ac, ale, yminc, ymaxc);
+ }
/* step 2) draw expand widget ....................................... */
if (acf->has_setting(ac, ale, ACHANNEL_SETTING_EXPAND)) {
@@ -4063,10 +4123,12 @@ void ANIM_channel_draw(
/* set text color */
/* XXX: if active, highlight differently? */
- if (selected)
+ if (selected) {
UI_GetThemeColor4ubv(TH_TEXT_HI, col);
- else
+ }
+ else {
UI_GetThemeColor4ubv(TH_TEXT, col);
+ }
/* get name */
acf->name(ale, name);
@@ -4132,25 +4194,30 @@ void ANIM_channel_draw(
/* check if there's enough space for the toggles if the sliders are drawn too */
if (!(draw_sliders) || (BLI_rcti_size_x(&v2d->mask) > ACHANNEL_BUTTON_WIDTH / 2)) {
/* protect... */
- if (acf->has_setting(ac, ale, ACHANNEL_SETTING_PROTECT))
+ if (acf->has_setting(ac, ale, ACHANNEL_SETTING_PROTECT)) {
offset += ICON_WIDTH;
+ }
/* mute... */
- if (acf->has_setting(ac, ale, ACHANNEL_SETTING_MUTE))
+ if (acf->has_setting(ac, ale, ACHANNEL_SETTING_MUTE)) {
offset += ICON_WIDTH;
- if (ale->type == ANIMTYPE_GPLAYER)
+ }
+ if (ale->type == ANIMTYPE_GPLAYER) {
offset += ICON_WIDTH;
+ }
/* pinned... */
- if (acf->has_setting(ac, ale, ACHANNEL_SETTING_PINNED))
+ if (acf->has_setting(ac, ale, ACHANNEL_SETTING_PINNED)) {
offset += ICON_WIDTH;
+ }
/* NOTE: technically, NLA Action "pushdown" should be here too,
* but there are no sliders there. */
/* NLA action channels have slightly different spacing requirements... */
- if (ale->type == ANIMTYPE_NLAACTION)
+ if (ale->type == ANIMTYPE_NLAACTION) {
ymin_ofs = NLACHANNEL_SKIP;
+ }
}
/* Draw slider:
@@ -4226,8 +4293,9 @@ static void achannel_setting_flush_widget_cb(bContext *C, void *ale_npoin, void
}
/* verify animation context */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return;
+ }
/* check if the setting is on... */
on = ANIM_channel_setting_get(&ac, ale_setting, setting);
@@ -4304,8 +4372,9 @@ static void achannel_setting_slider_cb(bContext *C, void *id_poin, void *fcu_poi
/* try to resolve the path stored in the F-Curve */
if (RNA_path_resolve_property(&id_ptr, fcu->rna_path, &ptr, &prop)) {
/* set the special 'replace' flag if on a keyframe */
- if (fcurve_frame_has_keyframe(fcu, cfra, 0))
+ if (fcurve_frame_has_keyframe(fcu, cfra, 0)) {
flag |= INSERTKEY_REPLACE;
+ }
/* insert a keyframe for this F-Curve */
done = insert_keyframe_direct(
@@ -4363,20 +4432,23 @@ static void achannel_setting_slider_shapekey_cb(bContext *C, void *key_poin, voi
FCurve *fcu = verify_fcurve(bmain, act, NULL, &ptr, rna_path, 0, 1);
/* set the special 'replace' flag if on a keyframe */
- if (fcurve_frame_has_keyframe(fcu, cfra, 0))
+ if (fcurve_frame_has_keyframe(fcu, cfra, 0)) {
flag |= INSERTKEY_REPLACE;
+ }
/* insert a keyframe for this F-Curve */
done = insert_keyframe_direct(
depsgraph, reports, ptr, prop, fcu, cfra, ts->keyframe_type, nla_context, flag);
- if (done)
+ if (done) {
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
+ }
}
/* free the path */
- if (rna_path)
+ if (rna_path) {
MEM_freeN(rna_path);
+ }
BKE_animsys_free_nla_keyframing_context_cache(&nla_cache);
}
@@ -4413,15 +4485,17 @@ static void achannel_setting_slider_nla_curve_cb(bContext *C,
if (fcu && prop) {
/* set the special 'replace' flag if on a keyframe */
- if (fcurve_frame_has_keyframe(fcu, cfra, 0))
+ if (fcurve_frame_has_keyframe(fcu, cfra, 0)) {
flag |= INSERTKEY_REPLACE;
+ }
/* insert a keyframe for this F-Curve */
done = insert_keyframe_direct(
depsgraph, reports, ptr, prop, fcu, cfra, ts->keyframe_type, NULL, flag);
- if (done)
+ if (done) {
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
+ }
}
}
@@ -4454,12 +4528,15 @@ static void draw_setting_widget(bAnimContext *ac,
//icon = ((enabled) ? ICON_VISIBLE_IPO_ON : ICON_VISIBLE_IPO_OFF);
icon = ICON_VISIBLE_IPO_OFF;
- if (ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE))
+ if (ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE)) {
tooltip = TIP_("F-Curve is visible in Graph Editor for editing");
- else if (ale->type == ANIMTYPE_GPLAYER)
+ }
+ else if (ale->type == ANIMTYPE_GPLAYER) {
tooltip = TIP_("Grease Pencil layer is visible in the viewport");
- else
+ }
+ else {
tooltip = TIP_("Channels are visible in Graph Editor for editing");
+ }
break;
case ACHANNEL_SETTING_ALWAYS_VISIBLE:
@@ -4493,10 +4570,12 @@ static void draw_setting_widget(bAnimContext *ac,
//icon = ((enabled) ? ICON_LOCKED : ICON_UNLOCKED);
icon = ICON_UNLOCKED;
- if (ale->datatype != ALE_NLASTRIP)
+ if (ale->datatype != ALE_NLASTRIP) {
tooltip = TIP_("Editability of keyframes for this channel");
- else
+ }
+ else {
tooltip = TIP_("Editability of NLA Strips in this track");
+ }
break;
case ACHANNEL_SETTING_MUTE: /* muted speaker */
@@ -4539,16 +4618,20 @@ static void draw_setting_widget(bAnimContext *ac,
/* type of button */
if (usetoggle) {
- if (negflag)
+ if (negflag) {
butType = UI_BTYPE_ICON_TOGGLE_N;
- else
+ }
+ else {
butType = UI_BTYPE_ICON_TOGGLE;
+ }
}
else {
- if (negflag)
+ if (negflag) {
butType = UI_BTYPE_TOGGLE_N;
- else
+ }
+ else {
butType = UI_BTYPE_TOGGLE;
+ }
}
/* draw button for setting */
if (ptr && flag) {
@@ -4662,8 +4745,9 @@ void ANIM_channel_draw_widgets(const bContext *C,
const bool is_being_renamed = achannel_is_being_renamed(ac, acf, channel_index);
/* sanity checks - don't draw anything */
- if (ELEM(NULL, acf, ale, block))
+ if (ELEM(NULL, acf, ale, block)) {
return;
+ }
/* get initial offset */
short offset = rect->xmin;
@@ -5002,15 +5086,18 @@ void ANIM_channel_draw_widgets(const bContext *C,
channel_height);
/* assign keyframing function according to slider type */
- if (ale->type == ANIMTYPE_SHAPEKEY)
+ if (ale->type == ANIMTYPE_SHAPEKEY) {
UI_but_func_set(but, achannel_setting_slider_shapekey_cb, ale->id, ale->data);
- else
+ }
+ else {
UI_but_func_set(but, achannel_setting_slider_cb, ale->id, ale->data);
+ }
}
/* free the path if necessary */
- if (free_path)
+ if (free_path) {
MEM_freeN(rna_path);
+ }
}
}
else { /* Special Slider for stuff without RNA Access ---------- */
diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c
index d85457bbc4f..d0eb2d187fd 100644
--- a/source/blender/editors/animation/anim_channels_edit.c
+++ b/source/blender/editors/animation/anim_channels_edit.c
@@ -85,14 +85,16 @@ void ANIM_set_active_channel(bAnimContext *ac,
/* try to build list of filtered items */
ANIM_animdata_filter(ac, &anim_data, filter, data, datatype);
- if (BLI_listbase_is_empty(&anim_data))
+ if (BLI_listbase_is_empty(&anim_data)) {
return;
+ }
/* only clear the 'active' flag for the channels of the same type */
for (ale = anim_data.first; ale; ale = ale->next) {
/* skip if types don't match */
- if (channel_type != ale->type)
+ if (channel_type != ale->type) {
continue;
+ }
/* flag to set depends on type */
switch (ale->type) {
@@ -263,13 +265,15 @@ void ANIM_deselect_anim_channels(
/* See if we should be selecting or deselecting */
if (test) {
for (ale = anim_data.first; ale; ale = ale->next) {
- if (sel == 0)
+ if (sel == 0) {
break;
+ }
switch (ale->type) {
case ANIMTYPE_SCENE:
- if (ale->flag & SCE_DS_SELECTED)
+ if (ale->flag & SCE_DS_SELECTED) {
sel = ACHANNEL_SETFLAG_CLEAR;
+ }
break;
case ANIMTYPE_OBJECT:
#if 0 /* for now, do not take object selection into account, since it gets too annoying */
@@ -278,21 +282,25 @@ void ANIM_deselect_anim_channels(
#endif
break;
case ANIMTYPE_GROUP:
- if (ale->flag & AGRP_SELECTED)
+ if (ale->flag & AGRP_SELECTED) {
sel = ACHANNEL_SETFLAG_CLEAR;
+ }
break;
case ANIMTYPE_FCURVE:
case ANIMTYPE_NLACURVE:
- if (ale->flag & FCURVE_SELECTED)
+ if (ale->flag & FCURVE_SELECTED) {
sel = ACHANNEL_SETFLAG_CLEAR;
+ }
break;
case ANIMTYPE_SHAPEKEY:
- if (ale->flag & KEYBLOCK_SEL)
+ if (ale->flag & KEYBLOCK_SEL) {
sel = ACHANNEL_SETFLAG_CLEAR;
+ }
break;
case ANIMTYPE_NLATRACK:
- if (ale->flag & NLATRACK_SELECTED)
+ if (ale->flag & NLATRACK_SELECTED) {
sel = ACHANNEL_SETFLAG_CLEAR;
+ }
break;
case ANIMTYPE_FILLACTD: /* Action Expander */
@@ -314,17 +322,20 @@ void ANIM_deselect_anim_channels(
case ANIMTYPE_DSSPK:
case ANIMTYPE_DSGPENCIL:
case ANIMTYPE_DSMCLIP: {
- if ((ale->adt) && (ale->adt->flag & ADT_UI_SELECTED))
+ if ((ale->adt) && (ale->adt->flag & ADT_UI_SELECTED)) {
sel = ACHANNEL_SETFLAG_CLEAR;
+ }
break;
}
case ANIMTYPE_GPLAYER:
- if (ale->flag & GP_LAYER_SELECT)
+ if (ale->flag & GP_LAYER_SELECT) {
sel = ACHANNEL_SETFLAG_CLEAR;
+ }
break;
case ANIMTYPE_MASKLAYER:
- if (ale->flag & MASK_LAYERFLAG_SELECT)
+ if (ale->flag & MASK_LAYERFLAG_SELECT) {
sel = ACHANNEL_SETFLAG_CLEAR;
+ }
break;
}
}
@@ -451,8 +462,9 @@ void ANIM_flush_setting_anim_channels(bAnimContext *ac,
int prevLevel = 0, matchLevel = 0;
/* sanity check */
- if (ELEM(NULL, anim_data, anim_data->first))
+ if (ELEM(NULL, anim_data, anim_data->first)) {
return;
+ }
if (setting == ACHANNEL_SETTING_ALWAYS_VISIBLE) {
return;
@@ -508,8 +520,9 @@ void ANIM_flush_setting_anim_channels(bAnimContext *ac,
int level;
/* if no channel info was found, skip, since this type might not have any useful info */
- if (acf == NULL)
+ if (acf == NULL) {
continue;
+ }
/* get the level of the current channel traversed
* - we define the level as simply being the offset for the start of the channel
@@ -533,13 +546,15 @@ void ANIM_flush_setting_anim_channels(bAnimContext *ac,
/* if previous level was a base-level (i.e. 0 offset / root of one hierarchy),
* stop here
*/
- if (prevLevel == 0)
+ if (prevLevel == 0) {
break;
- /* otherwise, this level weaves into another sibling hierarchy to the previous one just
+ /* otherwise, this level weaves into another sibling hierarchy to the previous one just
* finished, so skip until we get to the parent of this level
*/
- else
+ }
+ else {
continue;
+ }
}
}
}
@@ -552,8 +567,9 @@ void ANIM_flush_setting_anim_channels(bAnimContext *ac,
int level;
/* if no channel info was found, skip, since this type might not have any useful info */
- if (acf == NULL)
+ if (acf == NULL) {
continue;
+ }
/* get the level of the current channel traversed
* - we define the level as simply being the offset for the start of the channel
@@ -563,14 +579,16 @@ void ANIM_flush_setting_anim_channels(bAnimContext *ac,
/* if the level is 'greater than' (i.e. less important) the channel that was changed,
* flush the new status...
*/
- if (level > matchLevel)
+ if (level > matchLevel) {
ANIM_channel_setting_set(ac, ale, setting, mode);
- /* however, if the level is 'less than or equal to' the channel that was changed,
+ /* however, if the level is 'less than or equal to' the channel that was changed,
* (i.e. the current channel is as important if not more important than the changed channel)
* then we should stop, since we've found the last one of the children we should flush
*/
- else
+ }
+ else {
break;
+ }
/* store this level as the 'old' level now */
// prevLevel = level; // XXX: prevLevel is unused
@@ -587,8 +605,9 @@ void ANIM_fcurve_delete_from_animdata(bAnimContext *ac, AnimData *adt, FCurve *f
* (this doesn't guarantee that the F-Curve is in there, but at least we tried
* - if no F-Curve, there is nothing to remove
*/
- if (ELEM(NULL, adt, fcu))
+ if (ELEM(NULL, adt, fcu)) {
return;
+ }
/* remove from whatever list it came from
* - Action Group
@@ -650,11 +669,13 @@ static bool animedit_poll_channels_active(bContext *C)
/* channels region test */
/* TODO: could enhance with actually testing if channels region? */
- if (ELEM(NULL, sa, CTX_wm_region(C)))
+ if (ELEM(NULL, sa, CTX_wm_region(C))) {
return 0;
+ }
/* animation editor test */
- if (ELEM(sa->spacetype, SPACE_ACTION, SPACE_GRAPH, SPACE_NLA) == 0)
+ if (ELEM(sa->spacetype, SPACE_ACTION, SPACE_GRAPH, SPACE_NLA) == 0) {
return 0;
+ }
return 1;
}
@@ -667,16 +688,19 @@ static bool animedit_poll_channels_nla_tweakmode_off(bContext *C)
/* channels region test */
/* TODO: could enhance with actually testing if channels region? */
- if (ELEM(NULL, sa, CTX_wm_region(C)))
+ if (ELEM(NULL, sa, CTX_wm_region(C))) {
return 0;
+ }
/* animation editor test */
- if (ELEM(sa->spacetype, SPACE_ACTION, SPACE_GRAPH, SPACE_NLA) == 0)
+ if (ELEM(sa->spacetype, SPACE_ACTION, SPACE_GRAPH, SPACE_NLA) == 0) {
return 0;
+ }
/* NLA TweakMode test */
if (sa->spacetype == SPACE_NLA) {
- if ((scene == NULL) || (scene->flag & SCE_NLA_EDIT_ON))
+ if ((scene == NULL) || (scene->flag & SCE_NLA_EDIT_ON)) {
return 0;
+ }
}
return 1;
@@ -725,8 +749,9 @@ typedef enum eReorderIslandFlag {
static bool rearrange_island_ok(tReorderChannelIsland *island)
{
/* island must not be untouchable */
- if (island->flag & REORDER_ISLAND_UNTOUCHABLE)
+ if (island->flag & REORDER_ISLAND_UNTOUCHABLE) {
return 0;
+ }
/* island should be selected to be moved */
return (island->flag & REORDER_ISLAND_SELECTED) && !(island->flag & REORDER_ISLAND_MOVED);
@@ -917,12 +942,15 @@ static void rearrange_animchannel_add_to_islands(ListBase *islands,
island = MEM_callocN(sizeof(tReorderChannelIsland), "tReorderChannelIsland");
BLI_addtail(islands, island);
- if (is_sel)
+ if (is_sel) {
island->flag |= REORDER_ISLAND_SELECTED;
- if (is_untouchable)
+ }
+ if (is_untouchable) {
island->flag |= REORDER_ISLAND_UNTOUCHABLE;
- if (is_hidden)
+ }
+ if (is_hidden) {
island->flag |= REORDER_ISLAND_HIDDEN;
+ }
}
/* add channel to island - need to remove it from its existing list first though */
@@ -987,8 +1015,9 @@ static bool rearrange_animchannel_islands(ListBase *list,
bool done = false;
/* don't waste effort on an empty list */
- if (BLI_listbase_is_empty(list))
+ if (BLI_listbase_is_empty(list)) {
return 0;
+ }
/* group channels into islands */
for (channel = list->first; channel; channel = chanNext) {
@@ -1044,8 +1073,9 @@ static void rearrange_nla_channels(bAnimContext *ac, AnimData *adt, eRearrangeAn
/* get rearranging function */
rearrange_func = rearrange_get_mode_func(mode);
- if (rearrange_func == NULL)
+ if (rearrange_func == NULL) {
return;
+ }
/* Filter visible data. */
rearrange_animchannels_filter_visible(&anim_data_visible, ac, ANIMTYPE_NLATRACK);
@@ -1071,12 +1101,14 @@ static void rearrange_driver_channels(bAnimContext *ac,
AnimChanRearrangeFp rearrange_func = rearrange_get_mode_func(mode);
ListBase anim_data_visible = {NULL, NULL};
- if (rearrange_func == NULL)
+ if (rearrange_func == NULL) {
return;
+ }
/* only consider drivers if they're accessible */
- if (EXPANDED_DRVD(adt) == 0)
+ if (EXPANDED_DRVD(adt) == 0) {
return;
+ }
/* Filter visible data. */
rearrange_animchannels_filter_visible(&anim_data_visible, ac, ANIMTYPE_FCURVE);
@@ -1097,8 +1129,9 @@ static void split_groups_action_temp(bAction *act, bActionGroup *tgrp)
bActionGroup *agrp;
FCurve *fcu;
- if (act == NULL)
+ if (act == NULL) {
return;
+ }
/* Separate F-Curves into lists per group */
for (agrp = act->groups.first; agrp; agrp = agrp->next) {
@@ -1190,8 +1223,9 @@ static void rearrange_action_channels(bAnimContext *ac, bAction *act, eRearrange
/* get rearranging function */
AnimChanRearrangeFp rearrange_func = rearrange_get_mode_func(mode);
- if (rearrange_func == NULL)
+ if (rearrange_func == NULL) {
return;
+ }
/* make sure we're only operating with groups (vs a mixture of groups+curves) */
split_groups_action_temp(act, &tgrp);
@@ -1245,12 +1279,14 @@ static void rearrange_nla_control_channels(bAnimContext *ac,
/* get rearranging function */
AnimChanRearrangeFp rearrange_func = rearrange_get_mode_func(mode);
- if (rearrange_func == NULL)
+ if (rearrange_func == NULL) {
return;
+ }
/* skip if these curves aren't being shown */
- if (adt->flag & ADT_NLA_SKEYS_COLLAPSED)
+ if (adt->flag & ADT_NLA_SKEYS_COLLAPSED) {
return;
+ }
/* Filter visible data. */
rearrange_animchannels_filter_visible(&anim_data_visible, ac, ANIMTYPE_NLACURVE);
@@ -1278,8 +1314,9 @@ static void rearrange_gpencil_channels(bAnimContext *ac, eRearrangeAnimChan_Mode
/* get rearranging function */
AnimChanRearrangeFp rearrange_func = rearrange_get_mode_func(mode);
- if (rearrange_func == NULL)
+ if (rearrange_func == NULL) {
return;
+ }
/* get Grease Pencil datablocks */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_ANIMDATA);
@@ -1291,8 +1328,9 @@ static void rearrange_gpencil_channels(bAnimContext *ac, eRearrangeAnimChan_Mode
/* only consider layers if this datablock is open */
BLI_assert(ale->type == ANIMTYPE_GPDATABLOCK);
- if ((gpd->flag & GP_DATA_EXPAND) == 0)
+ if ((gpd->flag & GP_DATA_EXPAND) == 0) {
continue;
+ }
/* Filter visible data. */
rearrange_animchannels_filter_visible(&anim_data_visible, ac, ANIMTYPE_GPLAYER);
@@ -1317,8 +1355,9 @@ static int animchannels_rearrange_exec(bContext *C, wmOperator *op)
eRearrangeAnimChan_Mode mode;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get mode */
mode = RNA_enum_get(op->ptr, "direction");
@@ -1361,24 +1400,29 @@ static int animchannels_rearrange_exec(bContext *C, wmOperator *op)
case ANIMCONT_ACTION: /* Single Action only... */
case ANIMCONT_SHAPEKEY: // DOUBLE CHECK ME...
{
- if (adt->action)
+ if (adt->action) {
rearrange_action_channels(&ac, adt->action, mode);
- else if (G.debug & G_DEBUG)
+ }
+ else if (G.debug & G_DEBUG) {
printf("Animdata has no action\n");
+ }
break;
}
default: /* DopeSheet/Graph Editor - Some Actions + NLA Control Curves */
{
/* NLA Control Curves */
- if (adt->nla_tracks.first)
+ if (adt->nla_tracks.first) {
rearrange_nla_control_channels(&ac, adt, mode);
+ }
/* Action */
- if (adt->action)
+ if (adt->action) {
rearrange_action_channels(&ac, adt->action, mode);
- else if (G.debug & G_DEBUG)
+ }
+ else if (G.debug & G_DEBUG) {
printf("Animdata has no action\n");
+ }
break;
}
}
@@ -1426,8 +1470,9 @@ static bool animchannels_grouping_poll(bContext *C)
/* channels region test */
/* TODO: could enhance with actually testing if channels region? */
- if (ELEM(NULL, sa, CTX_wm_region(C)))
+ if (ELEM(NULL, sa, CTX_wm_region(C))) {
return 0;
+ }
/* animation editor test - must be suitable modes only */
sl = CTX_wm_space_data(C);
@@ -1438,8 +1483,9 @@ static bool animchannels_grouping_poll(bContext *C)
SpaceAction *saction = (SpaceAction *)sl;
/* dopesheet and action only - all others are for other datatypes or have no groups */
- if (ELEM(saction->mode, SACTCONT_ACTION, SACTCONT_DOPESHEET) == 0)
+ if (ELEM(saction->mode, SACTCONT_ACTION, SACTCONT_DOPESHEET) == 0) {
return 0;
+ }
break;
}
@@ -1447,8 +1493,9 @@ static bool animchannels_grouping_poll(bContext *C)
SpaceGraph *sipo = (SpaceGraph *)sl;
/* drivers can't have groups... */
- if (sipo->mode != SIPO_MODE_ANIMATION)
+ if (sipo->mode != SIPO_MODE_ANIMATION) {
return 0;
+ }
break;
}
@@ -1513,8 +1560,9 @@ static int animchannels_group_exec(bContext *C, wmOperator *op)
char name[MAX_NAME];
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get name for new group */
RNA_string_get(op->ptr, "name", name);
@@ -1581,8 +1629,9 @@ static int animchannels_ungroup_exec(bContext *C, wmOperator *UNUSED(op))
int filter;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* just selected F-Curves... */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL |
@@ -1666,12 +1715,14 @@ static int animchannels_delete_exec(bContext *C, wmOperator *UNUSED(op))
int filter;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* cannot delete in shapekey */
- if (ac.datatype == ANIMCONT_SHAPEKEY)
+ if (ac.datatype == ANIMCONT_SHAPEKEY) {
return OPERATOR_CANCELLED;
+ }
/* do groups only first (unless in Drivers mode, where there are none) */
if (ac.datatype != ANIMCONT_DRIVERS) {
@@ -1689,8 +1740,9 @@ static int animchannels_delete_exec(bContext *C, wmOperator *UNUSED(op))
FCurve *fcu, *fcn;
/* skip this group if no AnimData available, as we can't safely remove the F-Curves */
- if (adt == NULL)
+ if (adt == NULL) {
continue;
+ }
/* delete all of the Group's F-Curves, but no others */
for (fcu = agrp->channels.first; fcu && fcu->grp == agrp; fcu = fcn) {
@@ -1706,8 +1758,9 @@ static int animchannels_delete_exec(bContext *C, wmOperator *UNUSED(op))
BLI_freelinkN(&adt->action->groups, agrp);
DEG_id_tag_update_ex(CTX_data_main(C), &adt->action->id, ID_RECALC_ANIMATION);
}
- else
+ else {
MEM_freeN(agrp);
+ }
}
}
@@ -1867,8 +1920,9 @@ static void setflag_anim_channels(bAnimContext *ac,
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS |
ANIMFILTER_NODUPLIS);
}
- if (onlysel)
+ if (onlysel) {
filter |= ANIMFILTER_SEL;
+ }
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
/* if toggling, check if disable or enable */
@@ -1889,15 +1943,17 @@ static void setflag_anim_channels(bAnimContext *ac,
/* apply the setting */
for (ale = anim_data.first; ale; ale = ale->next) {
/* skip channel if setting is not available */
- if (ANIM_channel_setting_get(ac, ale, setting) == -1)
+ if (ANIM_channel_setting_get(ac, ale, setting) == -1) {
continue;
+ }
/* set the setting in the appropriate way */
ANIM_channel_setting_set(ac, ale, setting, mode);
/* if flush status... */
- if (flush)
+ if (flush) {
ANIM_flush_setting_anim_channels(ac, &all_data, ale, setting, mode);
+ }
}
ANIM_animdata_freelist(&anim_data);
@@ -1914,16 +1970,18 @@ static int animchannels_setflag_exec(bContext *C, wmOperator *op)
bool flush = true;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* mode (eAnimChannels_SetFlag), setting (eAnimChannel_Settings) */
mode = RNA_enum_get(op->ptr, "mode");
setting = RNA_enum_get(op->ptr, "type");
/* check if setting is flushable */
- if (setting == ACHANNEL_SETTING_EXPAND)
+ if (setting == ACHANNEL_SETTING_EXPAND) {
flush = false;
+ }
/* modify setting
* - only selected channels are affected
@@ -2049,12 +2107,14 @@ static int animchannels_expand_exec(bContext *C, wmOperator *op)
bool onlysel = true;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* only affect selected channels? */
- if (RNA_boolean_get(op->ptr, "all"))
+ if (RNA_boolean_get(op->ptr, "all")) {
onlysel = false;
+ }
/* modify setting */
setflag_anim_channels(&ac, ACHANNEL_SETTING_EXPAND, ACHANNEL_SETFLAG_ADD, onlysel, false);
@@ -2092,12 +2152,14 @@ static int animchannels_collapse_exec(bContext *C, wmOperator *op)
bool onlysel = true;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* only affect selected channels? */
- if (RNA_boolean_get(op->ptr, "all"))
+ if (RNA_boolean_get(op->ptr, "all")) {
onlysel = false;
+ }
/* modify setting */
setflag_anim_channels(&ac, ACHANNEL_SETTING_EXPAND, ACHANNEL_SETFLAG_CLEAR, onlysel, false);
@@ -2148,8 +2210,9 @@ static int animchannels_clean_empty_exec(bContext *C, wmOperator *UNUSED(op))
int filter;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get animdata blocks */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_ANIMDATA);
@@ -2241,12 +2304,14 @@ static bool animchannels_enable_poll(bContext *C)
/* channels region test */
/* TODO: could enhance with actually testing if channels region? */
- if (ELEM(NULL, sa, CTX_wm_region(C)))
+ if (ELEM(NULL, sa, CTX_wm_region(C))) {
return 0;
+ }
/* animation editor test - Action/Dopesheet/etc. and Graph only */
- if (ELEM(sa->spacetype, SPACE_ACTION, SPACE_GRAPH) == 0)
+ if (ELEM(sa->spacetype, SPACE_ACTION, SPACE_GRAPH) == 0) {
return 0;
+ }
return 1;
}
@@ -2260,8 +2325,9 @@ static int animchannels_enable_exec(bContext *C, wmOperator *UNUSED(op))
int filter;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_NODUPLIS);
@@ -2275,8 +2341,9 @@ static int animchannels_enable_exec(bContext *C, wmOperator *UNUSED(op))
fcu->flag &= ~FCURVE_DISABLED;
/* for drivers, let's do the same too */
- if (fcu->driver)
+ if (fcu->driver) {
fcu->driver->flag &= ~DRIVER_FLAG_INVALID;
+ }
/* tag everything for updates - in particular, this is needed to get drivers working again */
ale->update |= ANIM_UPDATE_DEPS;
@@ -2313,8 +2380,9 @@ static bool animchannels_find_poll(bContext *C)
{
ScrArea *sa = CTX_wm_area(C);
- if (sa == NULL)
+ if (sa == NULL) {
return 0;
+ }
/* animation editor with dopesheet */
return ELEM(sa->spacetype, SPACE_ACTION, SPACE_GRAPH, SPACE_NLA);
@@ -2326,8 +2394,9 @@ static int animchannels_find_invoke(bContext *C, wmOperator *op, const wmEvent *
bAnimContext ac;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* set initial filter text, and enable filter */
RNA_string_set(op->ptr, "query", ac.ads->searchstr);
@@ -2342,8 +2411,9 @@ static int animchannels_find_exec(bContext *C, wmOperator *op)
bAnimContext ac;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* update filter text */
RNA_string_get(op->ptr, "query", ac.ads->searchstr);
@@ -2385,8 +2455,9 @@ static int animchannels_deselectall_exec(bContext *C, wmOperator *op)
bAnimContext ac;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* 'standard' behavior - check if selected, then apply relevant selection */
const int action = RNA_enum_get(op->ptr, "action");
@@ -2465,10 +2536,12 @@ static void box_select_anim_channels(bAnimContext *ac, rcti *rect, short selectm
/* loop over data, doing box select */
for (ale = anim_data.first; ale; ale = ale->next) {
- if (ac->datatype == ANIMCONT_NLA)
+ if (ac->datatype == ANIMCONT_NLA) {
ymin = ymax - NLACHANNEL_STEP(snla);
- else
+ }
+ else {
ymin = ymax - ACHANNEL_STEP(ac);
+ }
/* if channel is within border-select region, alter it */
if (!((ymax < rectf.ymin) || (ymin > rectf.ymax))) {
@@ -2515,8 +2588,9 @@ static int animchannels_box_select_exec(bContext *C, wmOperator *op)
const bool extend = RNA_boolean_get(op->ptr, "extend");
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get settings from operator */
WM_operator_properties_border_to_rcti(op, &rect);
@@ -2583,9 +2657,10 @@ static bool rename_anim_channels(bAnimContext *ac, int channel_index)
ale = BLI_findlink(&anim_data, channel_index);
if (ale == NULL) {
/* channel not found */
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("Error: animation channel (index = %d) not found in rename_anim_channels()\n",
channel_index);
+ }
ANIM_animdata_freelist(&anim_data);
return false;
@@ -2678,17 +2753,20 @@ static int animchannels_rename_invoke(bContext *C, wmOperator *UNUSED(op), const
int channel_index;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
channel_index = animchannels_channel_get(&ac, event->mval);
/* handle click */
- if (rename_anim_channels(&ac, channel_index))
+ if (rename_anim_channels(&ac, channel_index)) {
return OPERATOR_FINISHED;
- else
+ }
+ else {
/* allow event to be handled by selectall operator */
return OPERATOR_PASS_THROUGH;
+ }
}
static void ANIM_OT_channels_rename(wmOperatorType *ot)
@@ -2722,9 +2800,10 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index,
ale = BLI_findlink(&anim_data, channel_index);
if (ale == NULL) {
/* channel not found */
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("Error: animation channel (index = %d) not found in mouse_anim_channels()\n",
channel_index);
+ }
ANIM_animdata_freelist(&anim_data);
return 0;
@@ -2750,13 +2829,15 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index,
if (selectmode == SELECT_INVERT) {
/* swap select */
sce->flag ^= SCE_DS_SELECTED;
- if (adt)
+ if (adt) {
adt->flag ^= ADT_UI_SELECTED;
+ }
}
else {
sce->flag |= SCE_DS_SELECTED;
- if (adt)
+ if (adt) {
adt->flag |= ADT_UI_SELECTED;
+ }
}
notifierFlags |= (ND_ANIMCHAN | NA_SELECTED);
@@ -2779,8 +2860,9 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index,
ED_object_base_select(base, BA_INVERT);
BKE_scene_object_base_flag_sync_from_base(base);
- if (adt)
+ if (adt) {
adt->flag ^= ADT_UI_SELECTED;
+ }
}
else {
Base *b;
@@ -2790,22 +2872,25 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index,
for (b = view_layer->object_bases.first; b; b = b->next) {
ED_object_base_select(b, BA_DESELECT);
BKE_scene_object_base_flag_sync_from_base(b);
- if (b->object->adt)
+ if (b->object->adt) {
b->object->adt->flag &= ~(ADT_UI_SELECTED | ADT_UI_ACTIVE);
+ }
}
/* select object now */
ED_object_base_select(base, BA_SELECT);
BKE_scene_object_base_flag_sync_from_base(base);
- if (adt)
+ if (adt) {
adt->flag |= ADT_UI_SELECTED;
+ }
}
/* change active object - regardless of whether it is now selected [T37883] */
ED_object_base_activate(C, base); /* adds notifier */
- if ((adt) && (adt->flag & ADT_UI_SELECTED))
+ if ((adt) && (adt->flag & ADT_UI_SELECTED)) {
adt->flag |= ADT_UI_ACTIVE;
+ }
/* Ensure we exit editmode on whatever object was active before
* to avoid getting stuck there - T48747. */
@@ -2850,8 +2935,9 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index,
}
/* set active? */
- if ((ale->adt) && (ale->adt->flag & ADT_UI_SELECTED))
+ if ((ale->adt) && (ale->adt->flag & ADT_UI_SELECTED)) {
ale->adt->flag |= ADT_UI_ACTIVE;
+ }
}
notifierFlags |= (ND_ANIMCHAN | NA_SELECTED);
@@ -2899,19 +2985,22 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index,
/* deselect all other channels */
ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, false, ACHANNEL_SETFLAG_CLEAR);
- if (pchan)
+ if (pchan) {
ED_pose_deselect_all(ob, SEL_DESELECT, false);
+ }
/* only select channels in group and group itself */
- for (fcu = agrp->channels.first; fcu && fcu->grp == agrp; fcu = fcu->next)
+ for (fcu = agrp->channels.first; fcu && fcu->grp == agrp; fcu = fcu->next) {
fcu->flag |= FCURVE_SELECTED;
+ }
agrp->flag |= AGRP_SELECTED;
}
else {
/* select group by itself */
ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, false, ACHANNEL_SETFLAG_CLEAR);
- if (pchan)
+ if (pchan) {
ED_pose_deselect_all(ob, SEL_DESELECT, false);
+ }
agrp->flag |= AGRP_SELECTED;
}
@@ -2919,13 +3008,15 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index,
/* if group is selected now, make group the 'active' one in the visible list */
if (agrp->flag & AGRP_SELECTED) {
ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, agrp, ANIMTYPE_GROUP);
- if (pchan)
+ if (pchan) {
ED_pose_bone_select(ob, pchan, true);
+ }
}
else {
ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, NULL, ANIMTYPE_GROUP);
- if (pchan)
+ if (pchan) {
ED_pose_bone_select(ob, pchan, false);
+ }
}
notifierFlags |= (ND_ANIMCHAN | NA_SELECTED);
@@ -2947,8 +3038,9 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index,
}
/* if F-Curve is selected now, make F-Curve the 'active' one in the visible list */
- if (fcu->flag & FCURVE_SELECTED)
+ if (fcu->flag & FCURVE_SELECTED) {
ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, fcu, ale->type);
+ }
notifierFlags |= (ND_ANIMCHAN | NA_SELECTED);
break;
@@ -3052,8 +3144,9 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index,
break;
}
default:
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("Error: Invalid channel type in mouse_anim_channels()\n");
+ }
break;
}
@@ -3078,8 +3171,9 @@ static int animchannels_mouseclick_invoke(bContext *C, wmOperator *op, const wmE
float x, y;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get useful pointers from animation context data */
ar = ac.ar;
@@ -3169,9 +3263,10 @@ static bool select_anim_channel_keys(bAnimContext *ac, int channel_index, bool e
ale = BLI_findlink(&anim_data, channel_index);
if (ale == NULL) {
/* channel not found */
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("Error: animation channel (index = %d) not found in rename_anim_channels()\n",
channel_index);
+ }
ANIM_animdata_freelist(&anim_data);
return false;
@@ -3221,8 +3316,9 @@ static int animchannels_channel_select_keys_invoke(bContext *C,
bool extend = RNA_boolean_get(op->ptr, "extend");
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
channel_index = animchannels_channel_get(&ac, event->mval);
@@ -3231,9 +3327,10 @@ static int animchannels_channel_select_keys_invoke(bContext *C,
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL);
return OPERATOR_FINISHED;
}
- else
+ else {
/* allow event to be handled by selectall operator */
return OPERATOR_PASS_THROUGH;
+ }
}
static void ANIM_OT_channel_select_keys(wmOperatorType *ot)
diff --git a/source/blender/editors/animation/anim_deps.c b/source/blender/editors/animation/anim_deps.c
index 5d25d732fe8..d7fe326f2ee 100644
--- a/source/blender/editors/animation/anim_deps.c
+++ b/source/blender/editors/animation/anim_deps.c
@@ -63,8 +63,9 @@ void ANIM_list_elem_update(Main *bmain, Scene *scene, bAnimListElem *ale)
AnimData *adt;
id = ale->id;
- if (!id)
+ if (!id) {
return;
+ }
/* tag AnimData for refresh so that other views will update in realtime with these changes */
adt = BKE_animdata_from_id(id);
@@ -97,8 +98,9 @@ void ANIM_list_elem_update(Main *bmain, Scene *scene, bAnimListElem *ale)
RNA_id_pointer_create(id, &id_ptr);
- if (RNA_path_resolve_property(&id_ptr, fcu->rna_path, &ptr, &prop))
+ if (RNA_path_resolve_property(&id_ptr, fcu->rna_path, &ptr, &prop)) {
RNA_property_update_main(bmain, scene, &ptr, prop);
+ }
}
else {
/* in other case we do standard depsgraph update, ideally
@@ -141,8 +143,9 @@ static void animchan_sync_group(bAnimContext *ac, bAnimListElem *ale, bActionGro
/* major priority is selection status
* so we need both a group and an owner
*/
- if (ELEM(NULL, agrp, owner_id))
+ if (ELEM(NULL, agrp, owner_id)) {
return;
+ }
/* for standard Objects, check if group is the name of some bone */
if (GS(owner_id->name) == ID_OB) {
@@ -160,10 +163,12 @@ static void animchan_sync_group(bAnimContext *ac, bAnimListElem *ale, bActionGro
bActionGroup *bgrp;
/* if one matches, sync the selection status */
- if ((pchan->bone) && (pchan->bone->flag & BONE_SELECTED))
+ if ((pchan->bone) && (pchan->bone->flag & BONE_SELECTED)) {
agrp->flag |= AGRP_SELECTED;
- else
+ }
+ else {
agrp->flag &= ~AGRP_SELECTED;
+ }
/* also sync active group status */
if ((ob == ac->obact) && (pchan->bone == arm->act_bone)) {
@@ -204,8 +209,9 @@ static void animchan_sync_fcurve(bAnimContext *UNUSED(ac),
/* major priority is selection status, so refer to the checks done in anim_filter.c
* skip_fcurve_selected_data() for reference about what's going on here...
*/
- if (ELEM(NULL, fcu, fcu->rna_path, owner_id))
+ if (ELEM(NULL, fcu, fcu->rna_path, owner_id)) {
return;
+ }
if (GS(owner_id->name) == ID_SCE) {
Scene *scene = (Scene *)owner_id;
@@ -219,15 +225,18 @@ static void animchan_sync_fcurve(bAnimContext *UNUSED(ac),
/* get strip name, and check if this strip is selected */
seq_name = BLI_str_quoted_substrN(fcu->rna_path, "sequences_all[");
seq = BKE_sequence_get_by_name(ed->seqbasep, seq_name, false);
- if (seq_name)
+ if (seq_name) {
MEM_freeN(seq_name);
+ }
/* update selection status */
if (seq) {
- if (seq->flag & SELECT)
+ if (seq->flag & SELECT) {
fcu->flag |= FCURVE_SELECTED;
- else
+ }
+ else {
fcu->flag &= ~FCURVE_SELECTED;
+ }
}
}
}
@@ -242,16 +251,19 @@ static void animchan_sync_fcurve(bAnimContext *UNUSED(ac),
/* get strip name, and check if this strip is selected */
node_name = BLI_str_quoted_substrN(fcu->rna_path, "nodes[");
node = nodeFindNodebyName(ntree, node_name);
- if (node_name)
+ if (node_name) {
MEM_freeN(node_name);
+ }
/* update selection/active status */
if (node) {
/* update selection status */
- if (node->flag & NODE_SELECT)
+ if (node->flag & NODE_SELECT) {
fcu->flag |= FCURVE_SELECTED;
- else
+ }
+ else {
fcu->flag &= ~FCURVE_SELECTED;
+ }
/* update active status */
/* XXX: this may interfere with setting bones as active if both exist at once;
@@ -311,8 +323,9 @@ void ANIM_sync_animchannels_to_data(const bContext *C)
FCurve *active_fcurve = NULL;
/* get animation context info for filtering the channels */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return;
+ }
/* filter data */
@@ -382,14 +395,16 @@ void ANIM_animdata_update(bAnimContext *ac, ListBase *anim_data)
if (ale->update & ANIM_UPDATE_ORDER) {
ale->update &= ~ANIM_UPDATE_ORDER;
- if (fcu)
+ if (fcu) {
sort_time_fcurve(fcu);
+ }
}
if (ale->update & ANIM_UPDATE_HANDLES) {
ale->update &= ~ANIM_UPDATE_HANDLES;
- if (fcu)
+ if (fcu) {
calchandles_fcurve(fcu);
+ }
}
if (ale->update & ANIM_UPDATE_DEPS) {
diff --git a/source/blender/editors/animation/anim_draw.c b/source/blender/editors/animation/anim_draw.c
index bf6dfe3938b..d5116858970 100644
--- a/source/blender/editors/animation/anim_draw.c
+++ b/source/blender/editors/animation/anim_draw.c
@@ -237,12 +237,14 @@ void ANIM_draw_framerange(Scene *scene, View2D *v2d)
AnimData *ANIM_nla_mapping_get(bAnimContext *ac, bAnimListElem *ale)
{
/* sanity checks */
- if (ac == NULL)
+ if (ac == NULL) {
return NULL;
+ }
/* abort if rendering - we may get some race condition issues... */
- if (G.is_rendering)
+ if (G.is_rendering) {
return NULL;
+ }
/* apart from strictly keyframe-related contexts, this shouldn't even happen */
// XXX: nla and channel here may not be necessary...
@@ -257,8 +259,9 @@ AnimData *ANIM_nla_mapping_get(bAnimContext *ac, bAnimListElem *ale)
if (ale) {
/* NLA Control Curves occur on NLA strips,
* and shouldn't be subjected to this kind of mapping. */
- if (ale->type != ANIMTYPE_NLACURVE)
+ if (ale->type != ANIMTYPE_NLACURVE) {
return ale->adt;
+ }
}
}
@@ -323,10 +326,12 @@ void ANIM_nla_mapping_apply_fcurve(AnimData *adt, FCurve *fcu, bool restore, boo
ked.i1 = (int)only_keys;
/* get editing callback */
- if (restore)
+ if (restore) {
map_cb = bezt_nlamapping_restore;
- else
+ }
+ else {
map_cb = bezt_nlamapping_apply;
+ }
/* apply to F-Curve */
ANIM_fcurve_keyframes_loop(&ked, fcu, NULL, map_cb, NULL);
@@ -355,15 +360,17 @@ static float normalization_factor_get(Scene *scene, FCurve *fcu, short flag, flo
float factor = 1.0f, offset = 0.0f;
if (flag & ANIM_UNITCONV_RESTORE) {
- if (r_offset)
+ if (r_offset) {
*r_offset = fcu->prev_offset;
+ }
return 1.0f / fcu->prev_norm_factor;
}
if (flag & ANIM_UNITCONV_NORMALIZE_FREEZE) {
- if (r_offset)
+ if (r_offset) {
*r_offset = fcu->prev_offset;
+ }
if (fcu->prev_norm_factor == 0.0f) {
/* Happens when Auto Normalize was disabled before
* any curves were displayed.
@@ -374,8 +381,9 @@ static float normalization_factor_get(Scene *scene, FCurve *fcu, short flag, flo
}
if (G.moving & G_TRANSFORM_FCURVES) {
- if (r_offset)
+ if (r_offset) {
*r_offset = fcu->prev_offset;
+ }
if (fcu->prev_norm_factor == 0.0f) {
/* Same as above. */
return 1.0f;
@@ -499,8 +507,9 @@ float ANIM_unit_mapping_get_factor(Scene *scene, ID *id, FCurve *fcu, short flag
return normalization_factor_get(scene, fcu, flag, r_offset);
}
- if (r_offset)
+ if (r_offset) {
*r_offset = 0.0f;
+ }
/* sanity checks */
if (id && fcu && fcu->rna_path) {
@@ -514,10 +523,12 @@ float ANIM_unit_mapping_get_factor(Scene *scene, ID *id, FCurve *fcu, short flag
if (RNA_SUBTYPE_UNIT(RNA_property_subtype(prop)) == PROP_UNIT_ROTATION) {
/* if the radians flag is not set, default to using degrees which need conversions */
if ((scene) && (scene->unit.system_rotation == USER_UNIT_ROT_RADIANS) == 0) {
- if (flag & ANIM_UNITCONV_RESTORE)
+ if (flag & ANIM_UNITCONV_RESTORE) {
return DEG2RADF(1.0f); /* degrees to radians */
- else
+ }
+ else {
return RAD2DEGF(1.0f); /* radians to degrees */
+ }
}
}
@@ -577,8 +588,9 @@ static bool find_prev_next_keyframes(struct bContext *C, int *nextfra, int *prev
}
else {
/* this changes the frame, so set the frame and we're done */
- if (++nextcount == U.view_frame_keyframes)
+ if (++nextcount == U.view_frame_keyframes) {
donenext = true;
+ }
}
cfranext = aknext->cfra;
}
@@ -593,8 +605,9 @@ static bool find_prev_next_keyframes(struct bContext *C, int *nextfra, int *prev
}
else {
/* this changes the frame, so set the frame and we're done */
- if (++prevcount == U.view_frame_keyframes)
+ if (++prevcount == U.view_frame_keyframes) {
doneprev = true;
+ }
}
cfraprev = akprev->cfra;
}
@@ -605,15 +618,19 @@ static bool find_prev_next_keyframes(struct bContext *C, int *nextfra, int *prev
/* any success? */
if (doneprev || donenext) {
- if (doneprev)
+ if (doneprev) {
*prevfra = cfraprev;
- else
+ }
+ else {
*prevfra = CFRA - (cfranext - CFRA);
+ }
- if (donenext)
+ if (donenext) {
*nextfra = cfranext;
- else
+ }
+ else {
*nextfra = CFRA + (CFRA - cfraprev);
+ }
return true;
}
diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c
index 41d23eb31ba..674f530894d 100644
--- a/source/blender/editors/animation/anim_filter.c
+++ b/source/blender/editors/animation/anim_filter.c
@@ -114,8 +114,9 @@ static void animedit_get_yscale_factor(bAnimContext *ac)
ac->yscale_fac = btheme->space_action.keyframe_scale_fac;
/* clamp to avoid problems with uninitialised values... */
- if (ac->yscale_fac < 0.1f)
+ if (ac->yscale_fac < 0.1f) {
ac->yscale_fac = 1.0f;
+ }
//printf("yscale_fac = %f\n", ac->yscale_fac);
}
@@ -130,8 +131,9 @@ static Key *actedit_get_shapekeys(bAnimContext *ac)
Key *key;
ob = OBACT(view_layer);
- if (ob == NULL)
+ if (ob == NULL) {
return NULL;
+ }
/* XXX pinning is not available in 'ShapeKey' mode... */
//if (saction->pin) return NULL;
@@ -140,8 +142,9 @@ static Key *actedit_get_shapekeys(bAnimContext *ac)
key = BKE_key_from_object(ob);
if (key) {
- if (key->type == KEY_RELATIVE)
+ if (key->type == KEY_RELATIVE) {
return key;
+ }
}
return NULL;
@@ -158,10 +161,12 @@ static bool actedit_get_context(bAnimContext *ac, SpaceAction *saction)
case SACTCONT_ACTION: /* 'Action Editor' */
/* if not pinned, sync with active object */
if (/*saction->pin == 0*/ true) {
- if (ac->obact && ac->obact->adt)
+ if (ac->obact && ac->obact->adt) {
saction->action = ac->obact->adt->action;
- else
+ }
+ else {
saction->action = NULL;
+ }
}
ac->datatype = ANIMCONT_ACTION;
@@ -178,10 +183,12 @@ static bool actedit_get_context(bAnimContext *ac, SpaceAction *saction)
if (/*saction->pin == 0*/ true) {
Key *key = (Key *)ac->data;
- if (key && key->adt)
+ if (key && key->adt) {
saction->action = key->adt->action;
- else
+ }
+ else {
saction->action = NULL;
+ }
}
ac->mode = saction->mode;
@@ -246,10 +253,12 @@ static bool actedit_get_context(bAnimContext *ac, SpaceAction *saction)
* dopesheet filters (i.e. we'd have to figure out where to host those settings,
* to be on a scene level like this flag currently is, along with several other unknowns).
*/
- if (ac->scene->flag & SCE_KEYS_NO_SELONLY)
+ if (ac->scene->flag & SCE_KEYS_NO_SELONLY) {
saction->ads.filterflag &= ~ADS_FILTER_ONLYSEL;
- else
+ }
+ else {
saction->ads.filterflag |= ADS_FILTER_ONLYSEL;
+ }
ac->datatype = ANIMCONT_TIMELINE;
ac->data = &saction->ads;
@@ -279,10 +288,12 @@ static bool graphedit_get_context(bAnimContext *ac, SpaceGraph *sipo)
ac->ads = sipo->ads;
/* set settings for Graph Editor - "Selected = Editable" */
- if (sipo->flag & SIPO_SELCUVERTSONLY)
+ if (sipo->flag & SIPO_SELCUVERTSONLY) {
sipo->ads->filterflag |= ADS_FILTER_SELEDIT;
- else
+ }
+ else {
sipo->ads->filterflag &= ~ADS_FILTER_SELEDIT;
+ }
/* sync settings with current view status, then return appropriate data */
switch (sipo->mode) {
@@ -323,8 +334,9 @@ static bool graphedit_get_context(bAnimContext *ac, SpaceGraph *sipo)
static bool nlaedit_get_context(bAnimContext *ac, SpaceNla *snla)
{
/* init dopesheet data if non-existent (i.e. for old files) */
- if (snla->ads == NULL)
+ if (snla->ads == NULL) {
snla->ads = MEM_callocN(sizeof(bDopeSheet), "NlaEdit DopeSheet");
+ }
ac->ads = snla->ads;
/* sync settings with current view status, then return appropriate data */
@@ -389,8 +401,9 @@ bool ANIM_animdata_get_context(const bContext *C, bAnimContext *ac)
Scene *scene = CTX_data_scene(C);
/* clear old context info */
- if (ac == NULL)
+ if (ac == NULL) {
return false;
+ }
memset(ac, 0, sizeof(bAnimContext));
/* get useful default context settings from context */
@@ -992,8 +1005,9 @@ static bool skip_fcurve_selected_data(bDopeSheet *ads, FCurve *fcu, ID *owner_id
/* get bone-name, and check if this bone is selected */
bone_name = BLI_str_quoted_substrN(fcu->rna_path, "pose.bones[");
pchan = BKE_pose_channel_find_name(ob->pose, bone_name);
- if (bone_name)
+ if (bone_name) {
MEM_freeN(bone_name);
+ }
/* check whether to continue or skip */
if ((pchan) && (pchan->bone)) {
@@ -1003,17 +1017,20 @@ static bool skip_fcurve_selected_data(bDopeSheet *ads, FCurve *fcu, ID *owner_id
bArmature *arm = (bArmature *)ob->data;
/* skipping - not visible on currently visible layers */
- if ((arm->layer & pchan->bone->layer) == 0)
+ if ((arm->layer & pchan->bone->layer) == 0) {
return true;
+ }
/* skipping - is currently hidden */
- if (pchan->bone->flag & BONE_HIDDEN_P)
+ if (pchan->bone->flag & BONE_HIDDEN_P) {
return true;
+ }
}
/* can only add this F-Curve if it is selected */
if (ads->filterflag & ADS_FILTER_ONLYSEL) {
- if ((pchan->bone->flag & BONE_SELECTED) == 0)
+ if ((pchan->bone->flag & BONE_SELECTED) == 0) {
return true;
+ }
}
}
}
@@ -1031,14 +1048,16 @@ static bool skip_fcurve_selected_data(bDopeSheet *ads, FCurve *fcu, ID *owner_id
/* get strip name, and check if this strip is selected */
seq_name = BLI_str_quoted_substrN(fcu->rna_path, "sequences_all[");
seq = BKE_sequence_get_by_name(ed->seqbasep, seq_name, false);
- if (seq_name)
+ if (seq_name) {
MEM_freeN(seq_name);
+ }
}
/* can only add this F-Curve if it is selected */
if (ads->filterflag & ADS_FILTER_ONLYSEL) {
- if ((seq == NULL) || (seq->flag & SELECT) == 0)
+ if ((seq == NULL) || (seq->flag & SELECT) == 0) {
return true;
+ }
}
}
}
@@ -1053,13 +1072,15 @@ static bool skip_fcurve_selected_data(bDopeSheet *ads, FCurve *fcu, ID *owner_id
/* get strip name, and check if this strip is selected */
node_name = BLI_str_quoted_substrN(fcu->rna_path, "nodes[");
node = nodeFindNodebyName(ntree, node_name);
- if (node_name)
+ if (node_name) {
MEM_freeN(node_name);
+ }
/* can only add this F-Curve if it is selected */
if (ads->filterflag & ADS_FILTER_ONLYSEL) {
- if ((node) && (node->flag & NODE_SELECT) == 0)
+ if ((node) && (node->flag & NODE_SELECT) == 0) {
return true;
+ }
}
}
}
@@ -1151,15 +1172,17 @@ static bool fcurve_has_errors(FCurve *fcu)
* BUT this may not hold with PyDrivers as this flag gets cleared
* if no critical errors prevent the driver from working...
*/
- if (driver->flag & DRIVER_FLAG_INVALID)
+ if (driver->flag & DRIVER_FLAG_INVALID) {
return true;
+ }
/* check variables for other things that need linting... */
// TODO: maybe it would be more efficient just to have a quick flag for this?
for (dvar = driver->variables.first; dvar; dvar = dvar->next) {
DRIVER_TARGETS_USED_LOOPER_BEGIN (dvar) {
- if (dtar->flag & DTAR_FLAG_INVALID)
+ if (dtar->flag & DTAR_FLAG_INVALID) {
return true;
+ }
}
DRIVER_TARGETS_LOOPER_END;
}
@@ -1198,8 +1221,9 @@ static FCurve *animfilter_fcurve_next(bDopeSheet *ads,
if ((filter_mode & ANIMFILTER_TMP_IGNORE_ONLYSEL) == 0) {
if ((ads->filterflag & ADS_FILTER_ONLYSEL) ||
(ads->filterflag & ADS_FILTER_INCL_HIDDEN) == 0) {
- if (skip_fcurve_selected_data(ads, fcu, owner_id, filter_mode))
+ if (skip_fcurve_selected_data(ads, fcu, owner_id, filter_mode)) {
continue;
+ }
}
}
}
@@ -1215,15 +1239,17 @@ static FCurve *animfilter_fcurve_next(bDopeSheet *ads,
if (!(filter_mode & ANIMFILTER_ACTIVE) || (fcu->flag & FCURVE_ACTIVE)) {
/* name based filtering... */
if (((ads) && (ads->searchstr[0] != '\0')) && (owner_id)) {
- if (skip_fcurve_with_name(ads, fcu, channel_type, owner, owner_id))
+ if (skip_fcurve_with_name(ads, fcu, channel_type, owner, owner_id)) {
continue;
+ }
}
/* error-based filtering... */
if ((ads) && (ads->filterflag & ADS_FILTER_ONLY_ERRORS)) {
/* skip if no errors... */
- if (fcurve_has_errors(fcu) == false)
+ if (fcurve_has_errors(fcu) == false) {
continue;
+ }
}
/* this F-Curve can be used, so return it */
@@ -1309,8 +1335,9 @@ static size_t animfilter_act_group(bAnimContext *ac,
(filter_mode & (ANIMFILTER_SEL | ANIMFILTER_UNSEL))) {
/* If the group itself isn't selected appropriately,
* we shouldn't consider it's children either. */
- if (ANIMCHANNEL_SELOK(SEL_AGRP(agrp)) == 0)
+ if (ANIMCHANNEL_SELOK(SEL_AGRP(agrp)) == 0) {
return 0;
+ }
/* if we're still here,
* then the selection status of the curves within this group should not matter,
@@ -1386,15 +1413,17 @@ static size_t animfilter_action(bAnimContext *ac,
/* don't include anything from this action if it is linked in from another file,
* and we're getting stuff for editing...
*/
- if ((filter_mode & ANIMFILTER_FOREDIT) && ID_IS_LINKED(act))
+ if ((filter_mode & ANIMFILTER_FOREDIT) && ID_IS_LINKED(act)) {
return 0;
+ }
/* do groups */
// TODO: do nested groups?
for (agrp = act->groups.first; agrp; agrp = agrp->next) {
/* store reference to last channel of group */
- if (agrp->channels.last)
+ if (agrp->channels.last) {
lastchan = agrp->channels.last;
+ }
/* action group's channels */
items += animfilter_act_group(ac, anim_data, ads, act, agrp, filter_mode, owner_id);
@@ -1462,10 +1491,12 @@ static size_t animfilter_nla(bAnimContext *UNUSED(ac),
* assume that the caller of this has already checked that these should be included */
for (nlt = first; nlt; nlt = next) {
/* 'next' NLA-Track to use depends on whether we're filtering for drawing or not */
- if (filter_mode & ANIMFILTER_LIST_CHANNELS)
+ if (filter_mode & ANIMFILTER_LIST_CHANNELS) {
next = nlt->prev;
- else
+ }
+ else {
next = nlt->next;
+ }
/* if we're in NLA-tweakmode, don't show this track if it was disabled (due to tweaking) for now
* - active track should still get shown though (even though it has disabled flag set)
@@ -1473,8 +1504,9 @@ static size_t animfilter_nla(bAnimContext *UNUSED(ac),
// FIXME: the channels after should still get drawn, just 'differently',
// and after an active-action channel.
if ((adt->flag & ADT_NLA_EDIT_ON) && (nlt->flag & NLATRACK_DISABLED) &&
- (adt->act_track != nlt))
+ (adt->act_track != nlt)) {
continue;
+ }
/* only work with this channel and its subchannels if it is editable */
if (!(filter_mode & ANIMFILTER_FOREDIT) || EDITABLE_NLT(nlt)) {
@@ -1629,8 +1661,9 @@ static size_t animdata_filter_shapekey(bAnimContext *ac,
/* loop through the channels adding ShapeKeys as appropriate */
for (kb = key->block.first; kb; kb = kb->next) {
/* skip the first one, since that's the non-animatable basis */
- if (kb == key->block.first)
+ if (kb == key->block.first) {
continue;
+ }
/* only work with this channel and its subchannels if it is editable */
if (!(filter_mode & ANIMFILTER_FOREDIT) || EDITABLE_SHAPEKEY(kb)) {
@@ -1683,8 +1716,9 @@ static size_t animdata_filter_gpencil_layers_data(ListBase *anim_data,
if (!(filter_mode & ANIMFILTER_ACTIVE) || (gpl->flag & GP_LAYER_ACTIVE)) {
/* skip layer if the name doesn't match the filter string */
if ((ads) && (ads->searchstr[0] != '\0')) {
- if (name_matches_dopesheet_filter(ads, gpl->info) == false)
+ if (name_matches_dopesheet_filter(ads, gpl->info) == false) {
continue;
+ }
}
/* add to list */
ANIMCHANNEL_NEW_CHANNEL(gpl, ANIMTYPE_GPLAYER, gpd, NULL);
@@ -1778,12 +1812,14 @@ static size_t animdata_filter_gpencil(bAnimContext *ac,
if ((filter_mode & ANIMFILTER_DATA_VISIBLE) &&
!(ads->filterflag & ADS_FILTER_INCL_HIDDEN)) {
/* layer visibility - we check both object and base, since these may not be in sync yet */
- if ((base->flag & BASE_VISIBLE) == 0)
+ if ((base->flag & BASE_VISIBLE) == 0) {
continue;
+ }
/* outliner restrict-flag */
- if (ob->restrictflag & OB_RESTRICT_VIEW)
+ if (ob->restrictflag & OB_RESTRICT_VIEW) {
continue;
+ }
}
/* check selection and object type filters */
@@ -1798,8 +1834,9 @@ static size_t animdata_filter_gpencil(bAnimContext *ac,
* - used to ease the process of doing multiple-character choreographies
*/
if (ads->filter_grp != NULL) {
- if (BKE_collection_has_object_recursive(ads->filter_grp, ob) == 0)
+ if (BKE_collection_has_object_recursive(ads->filter_grp, ob) == 0) {
continue;
+ }
}
/* finally, include this object's grease pencil datablock */
@@ -1815,8 +1852,9 @@ static size_t animdata_filter_gpencil(bAnimContext *ac,
* but only those that seem to be useful somewhere */
for (gpd = ac->bmain->gpencils.first; gpd; gpd = gpd->id.next) {
/* only show if gpd is used by something... */
- if (ID_REAL_USERS(gpd) < 1)
+ if (ID_REAL_USERS(gpd) < 1) {
continue;
+ }
/* add GP frames from this datablock */
items += animdata_filter_gpencil_data(anim_data, ads, gpd, filter_mode);
@@ -1944,8 +1982,9 @@ static size_t animdata_filter_mask(Main *bmain,
size_t tmp_items = 0;
/* only show if mask is used by something... */
- if (ID_REAL_USERS(mask) < 1)
+ if (ID_REAL_USERS(mask) < 1) {
continue;
+ }
/* add mask animation channels */
BEGIN_ANIMFILTER_SUBCHANNELS (EXPANDED_MASK(mask)) {
@@ -2164,8 +2203,9 @@ static size_t animdata_filter_ds_textures(
int a = 0;
/* get datatype specific data first */
- if (owner_id == NULL)
+ if (owner_id == NULL) {
return 0;
+ }
switch (GS(owner_id->name)) {
case ID_PA: {
@@ -2175,9 +2215,10 @@ static size_t animdata_filter_ds_textures(
}
default: {
/* invalid/unsupported option */
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("ERROR: Unsupported owner_id (i.e. texture stack) for filter textures - %s\n",
owner_id->name);
+ }
return 0;
}
}
@@ -2187,8 +2228,9 @@ static size_t animdata_filter_ds_textures(
Tex *tex = (mtex[a]) ? mtex[a]->tex : NULL;
/* for now, if no texture returned, skip (this shouldn't confuse the user I hope) */
- if (tex == NULL)
+ if (tex == NULL) {
continue;
+ }
/* add texture's anim channels */
items += animdata_filter_ds_texture(ac, anim_data, ads, tex, owner_id, filter_mode);
@@ -2211,9 +2253,10 @@ static size_t animdata_filter_ds_material(
tmp_items += animfilter_block_data(ac, &tmp_data, ads, (ID *)ma, filter_mode);
/* nodes */
- if ((ma->nodetree) && !(ads->filterflag & ADS_FILTER_NONTREE))
+ if ((ma->nodetree) && !(ads->filterflag & ADS_FILTER_NONTREE)) {
tmp_items += animdata_filter_ds_nodetree(
ac, &tmp_data, ads, (ID *)ma, ma->nodetree, filter_mode);
+ }
}
END_ANIMFILTER_SUBCHANNELS;
@@ -2312,8 +2355,9 @@ static void animfilter_modifier_idpoin_cb(void *afm_ptr,
/* NOTE: the walker only guarantees to give us all the ID-ptr *slots*,
* not just the ones which are actually used, so be careful!
*/
- if (id == NULL)
+ if (id == NULL) {
return;
+ }
/* check if this is something we're interested in... */
switch (GS(id->name)) {
@@ -2382,8 +2426,9 @@ static size_t animdata_filter_ds_particles(
size_t tmp_items = 0;
/* if no material returned, skip - so that we don't get weird blank entries... */
- if (ELEM(NULL, psys->part, psys->part->adt))
+ if (ELEM(NULL, psys->part, psys->part->adt)) {
continue;
+ }
/* add particle-system's animation data to temp collection */
BEGIN_ANIMFILTER_SUBCHANNELS (FILTER_PART_OBJD(psys->part)) {
@@ -2391,9 +2436,10 @@ static size_t animdata_filter_ds_particles(
tmp_items += animfilter_block_data(ac, &tmp_data, ads, (ID *)psys->part, filter_mode);
/* textures */
- if (!(ads->filterflag & ADS_FILTER_NOTEX))
+ if (!(ads->filterflag & ADS_FILTER_NOTEX)) {
tmp_items += animdata_filter_ds_textures(
ac, &tmp_data, ads, (ID *)psys->part, filter_mode);
+ }
}
END_ANIMFILTER_SUBCHANNELS;
@@ -2434,8 +2480,9 @@ static size_t animdata_filter_ds_obdata(
{
Camera *ca = (Camera *)ob->data;
- if (ads->filterflag & ADS_FILTER_NOCAM)
+ if (ads->filterflag & ADS_FILTER_NOCAM) {
return 0;
+ }
type = ANIMTYPE_DSCAM;
expanded = FILTER_CAM_OBJD(ca);
@@ -2445,8 +2492,9 @@ static size_t animdata_filter_ds_obdata(
{
Light *la = (Light *)ob->data;
- if (ads->filterflag & ADS_FILTER_NOLAM)
+ if (ads->filterflag & ADS_FILTER_NOLAM) {
return 0;
+ }
type = ANIMTYPE_DSLAM;
expanded = FILTER_LAM_OBJD(la);
@@ -2458,8 +2506,9 @@ static size_t animdata_filter_ds_obdata(
{
Curve *cu = (Curve *)ob->data;
- if (ads->filterflag & ADS_FILTER_NOCUR)
+ if (ads->filterflag & ADS_FILTER_NOCUR) {
return 0;
+ }
type = ANIMTYPE_DSCUR;
expanded = FILTER_CUR_OBJD(cu);
@@ -2469,8 +2518,9 @@ static size_t animdata_filter_ds_obdata(
{
MetaBall *mb = (MetaBall *)ob->data;
- if (ads->filterflag & ADS_FILTER_NOMBA)
+ if (ads->filterflag & ADS_FILTER_NOMBA) {
return 0;
+ }
type = ANIMTYPE_DSMBALL;
expanded = FILTER_MBALL_OBJD(mb);
@@ -2480,8 +2530,9 @@ static size_t animdata_filter_ds_obdata(
{
bArmature *arm = (bArmature *)ob->data;
- if (ads->filterflag & ADS_FILTER_NOARM)
+ if (ads->filterflag & ADS_FILTER_NOARM) {
return 0;
+ }
type = ANIMTYPE_DSARM;
expanded = FILTER_ARM_OBJD(arm);
@@ -2491,8 +2542,9 @@ static size_t animdata_filter_ds_obdata(
{
Mesh *me = (Mesh *)ob->data;
- if (ads->filterflag & ADS_FILTER_NOMESH)
+ if (ads->filterflag & ADS_FILTER_NOMESH) {
return 0;
+ }
type = ANIMTYPE_DSMESH;
expanded = FILTER_MESH_OBJD(me);
@@ -2502,8 +2554,9 @@ static size_t animdata_filter_ds_obdata(
{
Lattice *lt = (Lattice *)ob->data;
- if (ads->filterflag & ADS_FILTER_NOLAT)
+ if (ads->filterflag & ADS_FILTER_NOLAT) {
return 0;
+ }
type = ANIMTYPE_DSLAT;
expanded = FILTER_LATTICE_OBJD(lt);
@@ -2532,9 +2585,10 @@ static size_t animdata_filter_ds_obdata(
bNodeTree *ntree = la->nodetree;
/* nodetree */
- if ((ntree) && !(ads->filterflag & ADS_FILTER_NONTREE))
+ if ((ntree) && !(ads->filterflag & ADS_FILTER_NONTREE)) {
tmp_items += animdata_filter_ds_nodetree(
ac, &tmp_data, ads, &la->id, ntree, filter_mode);
+ }
break;
}
}
@@ -2740,9 +2794,10 @@ static size_t animdata_filter_ds_world(
tmp_items += animfilter_block_data(ac, &tmp_data, ads, (ID *)wo, filter_mode);
/* nodes */
- if ((wo->nodetree) && !(ads->filterflag & ADS_FILTER_NONTREE))
+ if ((wo->nodetree) && !(ads->filterflag & ADS_FILTER_NONTREE)) {
tmp_items += animdata_filter_ds_nodetree(
ac, &tmp_data, ads, (ID *)wo, wo->nodetree, filter_mode);
+ }
}
END_ANIMFILTER_SUBCHANNELS;
@@ -2938,8 +2993,9 @@ static bool animdata_filter_base_is_ok(bDopeSheet *ads, Base *base, int filter_m
{
Object *ob = base->object;
- if (base->object == NULL)
+ if (base->object == NULL) {
return false;
+ }
/* firstly, check if object can be included, by the following factors:
* - if only visible, must check for layer and also viewport visibility
@@ -2952,20 +3008,23 @@ static bool animdata_filter_base_is_ok(bDopeSheet *ads, Base *base, int filter_m
*/
if ((filter_mode & ANIMFILTER_DATA_VISIBLE) && !(ads->filterflag & ADS_FILTER_INCL_HIDDEN)) {
/* layer visibility - we check both object and base, since these may not be in sync yet */
- if ((base->flag & BASE_VISIBLE) == 0)
+ if ((base->flag & BASE_VISIBLE) == 0) {
return false;
+ }
/* outliner restrict-flag */
- if (ob->restrictflag & OB_RESTRICT_VIEW)
+ if (ob->restrictflag & OB_RESTRICT_VIEW) {
return false;
+ }
}
/* if only F-Curves with visible flags set can be shown, check that
* datablock hasn't been set to invisible
*/
if (filter_mode & ANIMFILTER_CURVE_VISIBLE) {
- if ((ob->adt) && (ob->adt->flag & ADT_CURVES_NOT_VISIBLE))
+ if ((ob->adt) && (ob->adt->flag & ADT_CURVES_NOT_VISIBLE)) {
return false;
+ }
}
/* Pinned curves are visible regardless of selection flags. */
@@ -2998,8 +3057,9 @@ static bool animdata_filter_base_is_ok(bDopeSheet *ads, Base *base, int filter_m
* - used to ease the process of doing multiple-character choreographies
*/
if (ads->filter_grp != NULL) {
- if (BKE_collection_has_object_recursive(ads->filter_grp, ob) == 0)
+ if (BKE_collection_has_object_recursive(ads->filter_grp, ob) == 0) {
return false;
+ }
}
/* no reason to exclude this object... */
@@ -3055,10 +3115,11 @@ static size_t animdata_filter_dopesheet(bAnimContext *ac,
/* check that we do indeed have a scene */
if ((ads->source == NULL) || (GS(ads->source->name) != ID_SCE)) {
printf("Dope Sheet Error: No scene!\n");
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("\tPointer = %p, Name = '%s'\n",
(void *)ads->source,
(ads->source) ? ads->source->name : NULL);
+ }
return 0;
}
@@ -3166,8 +3227,9 @@ static short animdata_filter_dopesheet_summary(bAnimContext *ac,
/* If summary is collapsed, don't show other channels beneath this - this check is put inside
* the summary check so that it doesn't interfere with normal operation.
*/
- if (ads->flag & ADS_FLAG_SUMMARY_COLLAPSED)
+ if (ads->flag & ADS_FLAG_SUMMARY_COLLAPSED) {
return 0;
+ }
}
/* the other channels beneath this can be shown */
@@ -3229,10 +3291,12 @@ static size_t animdata_filter_remove_invalid(ListBase *anim_data)
for (ale = anim_data->first; ale; ale = next) {
next = ale->next;
- if (ale->type == ANIMTYPE_NONE)
+ if (ale->type == ANIMTYPE_NONE) {
BLI_freelinkN(anim_data, ale);
- else
+ }
+ else {
items++;
+ }
}
return items;
@@ -3313,8 +3377,9 @@ size_t ANIM_animdata_filter(bAnimContext *ac,
else {
/* The check for the DopeSheet summary is included here
* since the summary works here too. */
- if (animdata_filter_dopesheet_summary(ac, anim_data, filter_mode, &items))
+ if (animdata_filter_dopesheet_summary(ac, anim_data, filter_mode, &items)) {
items += animfilter_action(ac, anim_data, ads, data, filter_mode, (ID *)obact);
+ }
}
break;
@@ -3333,8 +3398,9 @@ size_t ANIM_animdata_filter(bAnimContext *ac,
else {
/* The check for the DopeSheet summary is included here
* since the summary works here too. */
- if (animdata_filter_dopesheet_summary(ac, anim_data, filter_mode, &items))
+ if (animdata_filter_dopesheet_summary(ac, anim_data, filter_mode, &items)) {
items = animdata_filter_shapekey(ac, anim_data, key, filter_mode);
+ }
}
break;
@@ -3342,13 +3408,15 @@ size_t ANIM_animdata_filter(bAnimContext *ac,
/* Modes for Specialty Data Types (i.e. not keyframes) */
case ANIMCONT_GPENCIL: {
- if (animdata_filter_dopesheet_summary(ac, anim_data, filter_mode, &items))
+ if (animdata_filter_dopesheet_summary(ac, anim_data, filter_mode, &items)) {
items = animdata_filter_gpencil(ac, anim_data, data, filter_mode);
+ }
break;
}
case ANIMCONT_MASK: {
- if (animdata_filter_dopesheet_summary(ac, anim_data, filter_mode, &items))
+ if (animdata_filter_dopesheet_summary(ac, anim_data, filter_mode, &items)) {
items = animdata_filter_mask(ac->bmain, anim_data, data, filter_mode);
+ }
break;
}
@@ -3356,8 +3424,9 @@ size_t ANIM_animdata_filter(bAnimContext *ac,
case ANIMCONT_DOPESHEET: /* 'DopeSheet Editor' */
{
/* the DopeSheet editor is the primary place where the DopeSheet summaries are useful */
- if (animdata_filter_dopesheet_summary(ac, anim_data, filter_mode, &items))
+ if (animdata_filter_dopesheet_summary(ac, anim_data, filter_mode, &items)) {
items += animdata_filter_dopesheet(ac, anim_data, data, filter_mode);
+ }
break;
}
case ANIMCONT_FCURVES: /* Graph Editor -> F-Curves/Animation Editing */
@@ -3373,8 +3442,9 @@ size_t ANIM_animdata_filter(bAnimContext *ac,
/* Timeline Mode - Basically the same as dopesheet, except we only have the summary for now */
case ANIMCONT_TIMELINE: {
/* the DopeSheet editor is the primary place where the DopeSheet summaries are useful */
- if (animdata_filter_dopesheet_summary(ac, anim_data, filter_mode, &items))
+ if (animdata_filter_dopesheet_summary(ac, anim_data, filter_mode, &items)) {
items += animdata_filter_dopesheet(ac, anim_data, data, filter_mode);
+ }
break;
}
@@ -3399,8 +3469,9 @@ size_t ANIM_animdata_filter(bAnimContext *ac,
items = animdata_filter_remove_invalid(anim_data);
/* remove duplicates (if required) */
- if (filter_mode & ANIMFILTER_NODUPLIS)
+ if (filter_mode & ANIMFILTER_NODUPLIS) {
items = animdata_filter_remove_duplis(anim_data);
+ }
}
/* return the number of items in the list */
diff --git a/source/blender/editors/animation/anim_ipo_utils.c b/source/blender/editors/animation/anim_ipo_utils.c
index e34d12bc8fa..19fd521d7d9 100644
--- a/source/blender/editors/animation/anim_ipo_utils.c
+++ b/source/blender/editors/animation/anim_ipo_utils.c
@@ -56,15 +56,19 @@ int getname_anim_fcurve(char *name, ID *id, FCurve *fcu)
int icon = 0;
/* sanity checks */
- if (name == NULL)
+ if (name == NULL) {
return icon;
+ }
else if (ELEM(NULL, id, fcu, fcu->rna_path)) {
- if (fcu == NULL)
+ if (fcu == NULL) {
strcpy(name, IFACE_("<invalid>"));
- else if (fcu->rna_path == NULL)
+ }
+ else if (fcu->rna_path == NULL) {
strcpy(name, IFACE_("<no path>"));
- else /* id == NULL */
+ }
+ else { /* id == NULL */
BLI_snprintf(name, 256, "%s[%d]", fcu->rna_path, fcu->array_index);
+ }
}
else {
PointerRNA id_ptr, ptr;
@@ -111,10 +115,12 @@ int getname_anim_fcurve(char *name, ID *id, FCurve *fcu)
free_structname = 1;
/* free the temp names */
- if (pchanName)
+ if (pchanName) {
MEM_freeN(pchanName);
- if (constName)
+ }
+ if (constName) {
MEM_freeN(constName);
+ }
}
else if (ptr.data != ptr.id.data) {
PropertyRNA *nameprop = RNA_struct_name_property(ptr.type);
@@ -123,8 +129,9 @@ int getname_anim_fcurve(char *name, ID *id, FCurve *fcu)
structname = RNA_property_string_get_alloc(&ptr, nameprop, NULL, 0, NULL);
free_structname = 1;
}
- else
+ else {
structname = RNA_struct_ui_name(ptr.type);
+ }
}
/* Property Name is straightforward */
@@ -135,10 +142,12 @@ int getname_anim_fcurve(char *name, ID *id, FCurve *fcu)
char c = RNA_property_array_item_char(prop, fcu->array_index);
/* we need to write the index to a temp buffer (in py syntax) */
- if (c)
+ if (c) {
BLI_snprintf(arrayindbuf, sizeof(arrayindbuf), "%c ", c);
- else
+ }
+ else {
BLI_snprintf(arrayindbuf, sizeof(arrayindbuf), "[%d]", fcu->array_index);
+ }
arrayname = &arrayindbuf[0];
}
@@ -150,14 +159,17 @@ int getname_anim_fcurve(char *name, ID *id, FCurve *fcu)
/* putting this all together into the buffer */
/* XXX we need to check for invalid names...
* XXX the name length limit needs to be passed in or as some define */
- if (structname)
+ if (structname) {
BLI_snprintf(name, 256, "%s%s (%s)", arrayname, propname, structname);
- else
+ }
+ else {
BLI_snprintf(name, 256, "%s%s", arrayname, propname);
+ }
/* free temp name if nameprop is set */
- if (free_structname)
+ if (free_structname) {
MEM_freeN((void *)structname);
+ }
/* Icon for this property's owner:
* use the struct's icon if it is set
@@ -216,8 +228,9 @@ void getcolor_fcurve_rainbow(int cur, int tot, float out[3])
/* the base color can get offset a bit so that the colors aren't so identical */
hsv[0] += fac * HSV_BANDWIDTH;
- if (hsv[0] > 1.0f)
+ if (hsv[0] > 1.0f) {
hsv[0] = fmod(hsv[0], 1.0f);
+ }
/* saturation adjustments for more visible range */
hsv[1] = ((hsv[0] > 0.5f) && (hsv[0] < 0.8f)) ? 0.5f : 0.6f;
diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c
index 8bffb943824..e90599b05c8 100644
--- a/source/blender/editors/animation/anim_markers.c
+++ b/source/blender/editors/animation/anim_markers.c
@@ -107,10 +107,12 @@ ListBase *ED_context_get_markers(const bContext *C)
/* public API for getting markers from "animation" context */
ListBase *ED_animcontext_get_markers(const bAnimContext *ac)
{
- if (ac)
+ if (ac) {
return context_get_markers(ac->scene, ac->sa);
- else
+ }
+ else {
return NULL;
+ }
}
/* --------------------------------- */
@@ -212,10 +214,12 @@ void ED_markers_get_minmax(ListBase *markers, short sel, float *first, float *la
max = -FLT_MAX;
for (marker = markers->first; marker; marker = marker->next) {
if (!sel || (marker->flag & SELECT)) {
- if (marker->frame < min)
+ if (marker->frame < min) {
min = (float)marker->frame;
- if (marker->frame > max)
+ }
+ if (marker->frame > max) {
max = (float)marker->frame;
+ }
}
}
@@ -232,15 +236,17 @@ static void add_marker_to_cfra_elem(ListBase *lb, TimeMarker *marker, short only
CfraElem *ce, *cen;
/* should this one only be considered if it is selected? */
- if ((only_sel) && ((marker->flag & SELECT) == 0))
+ if ((only_sel) && ((marker->flag & SELECT) == 0)) {
return;
+ }
/* insertion sort - try to find a previous cfra elem */
for (ce = lb->first; ce; ce = ce->next) {
if (ce->cfra == marker->frame) {
/* do because of double keys */
- if (marker->flag & SELECT)
+ if (marker->flag & SELECT) {
ce->sel = marker->flag;
+ }
return;
}
else if (ce->cfra > marker->frame) {
@@ -249,10 +255,12 @@ static void add_marker_to_cfra_elem(ListBase *lb, TimeMarker *marker, short only
}
cen = MEM_callocN(sizeof(CfraElem), "add_to_cfra_elem");
- if (ce)
+ if (ce) {
BLI_insertlinkbefore(lb, ce, cen);
- else
+ }
+ else {
BLI_addtail(lb, cen);
+ }
cen->cfra = marker->frame;
cen->sel = marker->flag;
@@ -281,8 +289,9 @@ void ED_markers_make_cfra_list(ListBase *markers, ListBase *lb, short only_sel)
return;
}
- for (marker = markers->first; marker; marker = marker->next)
+ for (marker = markers->first; marker; marker = marker->next) {
add_marker_to_cfra_elem(lb, marker, only_sel);
+ }
}
void ED_markers_deselect_all(ListBase *markers, int action)
@@ -316,8 +325,9 @@ TimeMarker *ED_markers_get_first_selected(ListBase *markers)
if (markers) {
for (marker = markers->first; marker; marker = marker->next) {
- if (marker->flag & SELECT)
+ if (marker->flag & SELECT) {
return marker;
+ }
}
}
@@ -571,8 +581,9 @@ static bool ed_markers_poll_selected_markers(bContext *C)
ListBase *markers = ED_context_get_markers(C);
/* first things first: markers can only exist in timeline views */
- if (ED_operator_animview_active(C) == 0)
+ if (ED_operator_animview_active(C) == 0) {
return 0;
+ }
/* check if some marker is selected */
return ED_markers_get_first_selected(markers) != NULL;
@@ -583,12 +594,14 @@ static bool ed_markers_poll_selected_no_locked_markers(bContext *C)
ListBase *markers = ED_context_get_markers(C);
ToolSettings *ts = CTX_data_tool_settings(C);
- if (ts->lock_markers)
+ if (ts->lock_markers) {
return 0;
+ }
/* first things first: markers can only exist in timeline views */
- if (ED_operator_animview_active(C) == 0)
+ if (ED_operator_animview_active(C) == 0) {
return 0;
+ }
/* check if some marker is selected */
return ED_markers_get_first_selected(markers) != NULL;
@@ -600,12 +613,14 @@ static bool ed_markers_poll_markers_exist(bContext *C)
ListBase *markers = ED_context_get_markers(C);
ToolSettings *ts = CTX_data_tool_settings(C);
- if (ts->lock_markers)
+ if (ts->lock_markers) {
return 0;
+ }
/* first things first: markers can only exist in timeline views */
- if (ED_operator_animview_active(C) == 0)
+ if (ED_operator_animview_active(C) == 0) {
return 0;
+ }
/* list of markers must exist, as well as some markers in it! */
return (markers && markers->first);
@@ -634,14 +649,17 @@ static int ed_markers_opwrap_invoke_custom(bContext *C,
/* removed check for Y coord of event, keymap has bounbox now */
/* allow operator to run now */
- if (invoke_func)
+ if (invoke_func) {
retval = invoke_func(C, op, event);
- else if (op->type->exec)
+ }
+ else if (op->type->exec) {
retval = op->type->exec(C, op);
- else
+ }
+ else {
BKE_report(op->reports,
RPT_ERROR,
"Programming error: operator does not actually have code to do anything!");
+ }
/* unless successful, must add "pass-through"
* to let normal operator's have a chance at tackling this event */
@@ -671,19 +689,22 @@ static int ed_marker_add_exec(bContext *C, wmOperator *UNUSED(op))
TimeMarker *marker;
int frame = CTX_data_scene(C)->r.cfra;
- if (markers == NULL)
+ if (markers == NULL) {
return OPERATOR_CANCELLED;
+ }
/* prefer not having 2 markers at the same place,
* though the user can move them to overlap once added */
for (marker = markers->first; marker; marker = marker->next) {
- if (marker->frame == frame)
+ if (marker->frame == frame) {
return OPERATOR_CANCELLED;
+ }
}
/* deselect all */
- for (marker = markers->first; marker; marker = marker->next)
+ for (marker = markers->first; marker; marker = marker->next) {
marker->flag &= ~SELECT;
+ }
marker = MEM_callocN(sizeof(TimeMarker), "TimeMarker");
marker->flag = SELECT;
@@ -1081,8 +1102,9 @@ static void ed_marker_duplicate_apply(bContext *C)
ListBase *markers = ED_context_get_markers(C);
TimeMarker *marker, *newmarker;
- if (markers == NULL)
+ if (markers == NULL) {
return;
+ }
/* go through the list of markers, duplicate selected markers and add duplicated copies
* to the beginning of the list (unselect original markers)
@@ -1191,8 +1213,9 @@ static int ed_marker_select(bContext *C, const wmEvent *event, bool extend, bool
float viewx;
int x, cfra;
- if (markers == NULL)
+ if (markers == NULL) {
return OPERATOR_PASS_THROUGH;
+ }
x = event->x - ar->winrct.xmin;
@@ -1211,8 +1234,9 @@ static int ed_marker_select(bContext *C, const wmEvent *event, bool extend, bool
TimeMarker *marker;
int sel = 0;
- if (!extend)
+ if (!extend) {
BKE_view_layer_base_deselect_all(view_layer);
+ }
for (marker = markers->first; marker; marker = marker->next) {
if (marker->frame == cfra) {
@@ -1227,8 +1251,9 @@ static int ed_marker_select(bContext *C, const wmEvent *event, bool extend, bool
base = BKE_view_layer_base_find(view_layer, marker->camera);
if (base) {
ED_object_base_select(base, sel);
- if (sel)
+ if (sel) {
ED_object_base_activate(C, base);
+ }
}
}
}
@@ -1317,8 +1342,9 @@ static int ed_marker_box_select_exec(bContext *C, wmOperator *op)
WM_operator_properties_border_to_rctf(op, &rect);
UI_view2d_region_to_view_rctf(v2d, &rect, &rect);
- if (markers == NULL)
+ if (markers == NULL) {
return 0;
+ }
const eSelectOp sel_op = RNA_enum_get(op->ptr, "mode");
const bool select = (sel_op != SEL_OP_SUB);
@@ -1412,8 +1438,9 @@ static int ed_marker_delete_exec(bContext *C, wmOperator *UNUSED(op))
TimeMarker *marker, *nmarker;
bool changed = false;
- if (markers == NULL)
+ if (markers == NULL) {
return OPERATOR_CANCELLED;
+ }
for (marker = markers->first; marker; marker = nmarker) {
nmarker = marker->next;
@@ -1477,8 +1504,9 @@ static int ed_marker_rename_invoke_wrapper(bContext *C, wmOperator *op, const wm
{
/* must initialize the marker name first if there is a marker selected */
TimeMarker *marker = ED_markers_get_first_selected(ED_context_get_markers(C));
- if (marker)
+ if (marker) {
RNA_string_set(op->ptr, "name", marker->name);
+ }
/* now see if the operator is usable */
return ed_markers_opwrap_invoke_custom(C, op, event, WM_operator_props_popup_confirm);
@@ -1600,8 +1628,9 @@ static int ed_marker_camera_bind_exec(bContext *C, wmOperator *op)
}
/* add new marker, unless we already have one on this frame, in which case, replace it */
- if (markers == NULL)
+ if (markers == NULL) {
return OPERATOR_CANCELLED;
+ }
marker = ED_markers_find_nearest_marker(markers, CFRA);
if ((marker == NULL) || (marker->frame != CFRA)) {
diff --git a/source/blender/editors/animation/anim_motion_paths.c b/source/blender/editors/animation/anim_motion_paths.c
index 5ea36627e7a..e3c4e2a8cfb 100644
--- a/source/blender/editors/animation/anim_motion_paths.c
+++ b/source/blender/editors/animation/anim_motion_paths.c
@@ -216,8 +216,9 @@ void animviz_calc_motionpaths(Depsgraph *depsgraph,
bool current_frame_only)
{
/* sanity check */
- if (ELEM(NULL, targets, targets->first))
+ if (ELEM(NULL, targets, targets->first)) {
return;
+ }
/* Compute frame range to bake within.
* TODO: this method could be improved...
@@ -263,10 +264,12 @@ void animviz_calc_motionpaths(Depsgraph *depsgraph,
bAnimVizSettings *avs;
/* get pointer to animviz settings for each target */
- if (mpt->pchan)
+ if (mpt->pchan) {
avs = &mpt->ob->pose->avs;
- else
+ }
+ else {
avs = &mpt->ob->avs;
+ }
/* it is assumed that keyframes for bones are all grouped in a single group
* unless an option is set to always use the whole action
@@ -320,10 +323,12 @@ void animviz_calc_motionpaths(Depsgraph *depsgraph,
bMotionPath *mpath = mpt->mpath;
/* get pointer to animviz settings for each target */
- if (mpt->pchan)
+ if (mpt->pchan) {
avs = &mpt->ob->pose->avs;
- else
+ }
+ else {
avs = &mpt->ob->avs;
+ }
/* clear the flag requesting recalculation of targets */
avs->recalc &= ~ANIMVIZ_RECALC_PATHS;
diff --git a/source/blender/editors/animation/anim_ops.c b/source/blender/editors/animation/anim_ops.c
index 91cbc2ff3e0..45bb8f3b11e 100644
--- a/source/blender/editors/animation/anim_ops.c
+++ b/source/blender/editors/animation/anim_ops.c
@@ -62,8 +62,9 @@ static bool change_frame_poll(bContext *C)
ScrArea *sa = CTX_wm_area(C);
/* XXX temp? prevent changes during render */
- if (G.is_rendering)
+ if (G.is_rendering) {
return false;
+ }
/* although it's only included in keymaps for regions using ED_KEYMAP_ANIMATION,
* this shouldn't show up in 3D editor (or others without 2D timeline view) via search
@@ -157,8 +158,9 @@ static void change_frame_seq_preview_begin(bContext *C, const wmEvent *event)
ED_sequencer_special_preview_set(C, event->mval);
}
}
- if (screen)
+ if (screen) {
screen->scrubbing = true;
+ }
}
static void change_frame_seq_preview_end(bContext *C)
@@ -225,8 +227,9 @@ static int change_frame_modal(bContext *C, wmOperator *op, const wmEvent *event)
case RIGHTMOUSE:
case MIDDLEMOUSE:
/* We check for either mouse-button to end, to work with all user keymaps. */
- if (event->val == KM_RELEASE)
+ if (event->val == KM_RELEASE) {
ret = OPERATOR_FINISHED;
+ }
break;
case LEFTCTRLKEY:
@@ -281,8 +284,9 @@ static bool anim_set_end_frames_poll(bContext *C)
ScrArea *sa = CTX_wm_area(C);
/* XXX temp? prevent changes during render */
- if (G.is_rendering)
+ if (G.is_rendering) {
return false;
+ }
/* although it's only included in keymaps for regions using ED_KEYMAP_ANIMATION,
* this shouldn't show up in 3D editor (or others without 2D timeline view) via search
@@ -302,22 +306,27 @@ static int anim_set_sfra_exec(bContext *C, wmOperator *UNUSED(op))
Scene *scene = CTX_data_scene(C);
int frame;
- if (scene == NULL)
+ if (scene == NULL) {
return OPERATOR_CANCELLED;
+ }
frame = CFRA;
/* if Preview Range is defined, set the 'start' frame for that */
- if (PRVRANGEON)
+ if (PRVRANGEON) {
scene->r.psfra = frame;
- else
+ }
+ else {
scene->r.sfra = frame;
+ }
if (PEFRA < frame) {
- if (PRVRANGEON)
+ if (PRVRANGEON) {
scene->r.pefra = frame;
- else
+ }
+ else {
scene->r.efra = frame;
+ }
}
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
@@ -345,22 +354,27 @@ static int anim_set_efra_exec(bContext *C, wmOperator *UNUSED(op))
Scene *scene = CTX_data_scene(C);
int frame;
- if (scene == NULL)
+ if (scene == NULL) {
return OPERATOR_CANCELLED;
+ }
frame = CFRA;
/* if Preview Range is defined, set the 'end' frame for that */
- if (PRVRANGEON)
+ if (PRVRANGEON) {
scene->r.pefra = frame;
- else
+ }
+ else {
scene->r.efra = frame;
+ }
if (PSFRA > frame) {
- if (PRVRANGEON)
+ if (PRVRANGEON) {
scene->r.psfra = frame;
- else
+ }
+ else {
scene->r.sfra = frame;
+ }
}
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
@@ -405,8 +419,9 @@ static int previewrange_define_exec(bContext *C, wmOperator *op)
*/
FRAMENUMBER_MIN_CLAMP(sfra);
FRAMENUMBER_MIN_CLAMP(efra);
- if (efra < sfra)
+ if (efra < sfra) {
efra = sfra;
+ }
scene->r.flag |= SCER_PRV_RANGE;
scene->r.psfra = round_fl_to_int(sfra);
@@ -452,8 +467,9 @@ static int previewrange_clear_exec(bContext *C, wmOperator *UNUSED(op))
ScrArea *curarea = CTX_wm_area(C);
/* sanity checks */
- if (ELEM(NULL, scene, curarea))
+ if (ELEM(NULL, scene, curarea)) {
return OPERATOR_CANCELLED;
+ }
/* simply clear values */
scene->r.flag &= ~SCER_PRV_RANGE;
diff --git a/source/blender/editors/animation/drivers.c b/source/blender/editors/animation/drivers.c
index 3f930aae47f..34d7fac041f 100644
--- a/source/blender/editors/animation/drivers.c
+++ b/source/blender/editors/animation/drivers.c
@@ -73,13 +73,15 @@ FCurve *verify_driver_fcurve(ID *id, const char rna_path[], const int array_inde
FCurve *fcu;
/* sanity checks */
- if (ELEM(NULL, id, rna_path))
+ if (ELEM(NULL, id, rna_path)) {
return NULL;
+ }
/* init animdata if none available yet */
adt = BKE_animdata_from_id(id);
- if ((adt == NULL) && (add))
+ if ((adt == NULL) && (add)) {
adt = BKE_animdata_add_id(id);
+ }
if (adt == NULL) {
/* if still none (as not allowed to add, or ID doesn't have animdata for some reason) */
return NULL;
@@ -233,31 +235,40 @@ static int add_driver_with_target(ReportList *UNUSED(reports),
/* Transform channel depends on type */
if (STREQ(prop_name, "location")) {
- if (src_index == 2)
+ if (src_index == 2) {
dtar->transChan = DTAR_TRANSCHAN_LOCZ;
- else if (src_index == 1)
+ }
+ else if (src_index == 1) {
dtar->transChan = DTAR_TRANSCHAN_LOCY;
- else
+ }
+ else {
dtar->transChan = DTAR_TRANSCHAN_LOCX;
+ }
}
else if (STREQ(prop_name, "scale")) {
- if (src_index == 2)
+ if (src_index == 2) {
dtar->transChan = DTAR_TRANSCHAN_SCALEZ;
- else if (src_index == 1)
+ }
+ else if (src_index == 1) {
dtar->transChan = DTAR_TRANSCHAN_SCALEY;
- else
+ }
+ else {
dtar->transChan = DTAR_TRANSCHAN_SCALEX;
+ }
}
else {
/* XXX: With quaternions and axis-angle, this mapping might not be correct...
* But since those have 4 elements instead, there's not much we can do
*/
- if (src_index == 2)
+ if (src_index == 2) {
dtar->transChan = DTAR_TRANSCHAN_ROTZ;
- else if (src_index == 1)
+ }
+ else if (src_index == 1) {
dtar->transChan = DTAR_TRANSCHAN_ROTY;
- else
+ }
+ else {
dtar->transChan = DTAR_TRANSCHAN_ROTX;
+ }
}
}
else {
@@ -438,12 +449,14 @@ int ANIM_add_driver(
array_index_max = RNA_property_array_length(&ptr, prop);
array_index = 0;
}
- else
+ else {
array_index_max = array_index;
+ }
/* maximum index should be greater than the start index */
- if (array_index == array_index_max)
+ if (array_index == array_index_max) {
array_index_max += 1;
+ }
/* will only loop once unless the array index was -1 */
for (; array_index < array_index_max; array_index++) {
@@ -477,26 +490,32 @@ int ANIM_add_driver(
float fval;
if (proptype == PROP_BOOLEAN) {
- if (!array)
+ if (!array) {
val = RNA_property_boolean_get(&ptr, prop);
- else
+ }
+ else {
val = RNA_property_boolean_get_index(&ptr, prop, array_index);
+ }
BLI_snprintf(expression, maxlen, "%s%s", dvar_prefix, (val) ? "True" : "False");
}
else if (proptype == PROP_INT) {
- if (!array)
+ if (!array) {
val = RNA_property_int_get(&ptr, prop);
- else
+ }
+ else {
val = RNA_property_int_get_index(&ptr, prop, array_index);
+ }
BLI_snprintf(expression, maxlen, "%s%d", dvar_prefix, val);
}
else if (proptype == PROP_FLOAT) {
- if (!array)
+ if (!array) {
fval = RNA_property_float_get(&ptr, prop);
- else
+ }
+ else {
fval = RNA_property_float_get_index(&ptr, prop, array_index);
+ }
BLI_snprintf(expression, maxlen, "%s%.3f", dvar_prefix, fval);
BLI_str_rstrip_float_zero(expression, '\0');
@@ -587,8 +606,9 @@ static FCurve *channeldriver_copypaste_buf = NULL;
void ANIM_drivers_copybuf_free(void)
{
/* free the buffer F-Curve if it exists, as if it were just another F-Curve */
- if (channeldriver_copypaste_buf)
+ if (channeldriver_copypaste_buf) {
free_fcurve(channeldriver_copypaste_buf);
+ }
channeldriver_copypaste_buf = NULL;
}
@@ -868,8 +888,9 @@ static const EnumPropertyItem *driver_mapping_type_itemsf(bContext *C,
int totitem = 0;
- if (!C) /* needed for docs */
+ if (!C) { /* needed for docs */
return prop_driver_create_mapping_types;
+ }
UI_context_active_but_prop_get(C, &ptr, &prop, &index);
@@ -929,8 +950,9 @@ static int add_driver_button_none(bContext *C, wmOperator *op, short mapping_typ
UI_context_active_but_prop_get(C, &ptr, &prop, &index);
- if (mapping_type == CREATEDRIVER_MAPPING_NONE_ALL)
+ if (mapping_type == CREATEDRIVER_MAPPING_NONE_ALL) {
index = -1;
+ }
if (ptr.id.data && ptr.data && prop && RNA_property_animateable(&ptr, prop)) {
char *path = BKE_animdata_driver_path_hack(C, &ptr, prop, NULL);
@@ -1084,8 +1106,9 @@ static int remove_driver_button_exec(bContext *C, wmOperator *op)
/* try to find driver using property retrieved from UI */
UI_context_active_but_prop_get(C, &ptr, &prop, &index);
- if (all)
+ if (all) {
index = -1;
+ }
if (ptr.id.data && ptr.data && prop) {
char *path = BKE_animdata_driver_path_hack(C, &ptr, prop, NULL);
diff --git a/source/blender/editors/animation/fmodifier_ui.c b/source/blender/editors/animation/fmodifier_ui.c
index 9e96023b272..f4e1268ab77 100644
--- a/source/blender/editors/animation/fmodifier_ui.c
+++ b/source/blender/editors/animation/fmodifier_ui.c
@@ -77,8 +77,9 @@ static void validate_fmodifier_cb(bContext *UNUSED(C), void *fcm_v, void *UNUSED
const FModifierTypeInfo *fmi = fmodifier_get_typeinfo(fcm);
/* call the verify callback on the modifier if applicable */
- if (fmi && fmi->verify_data)
+ if (fmi && fmi->verify_data) {
fmi->verify_data(fcm);
+ }
}
/* callback to remove the given modifier */
@@ -210,7 +211,7 @@ static void draw_modifier__generator(uiLayout *layout,
cp = data->coefficients;
for (i = 0; (i < data->arraysize) && (cp); i++, cp++) {
/* To align with first line... */
- if (i)
+ if (i) {
uiDefBut(block,
UI_BTYPE_LABEL,
1,
@@ -225,7 +226,8 @@ static void draw_modifier__generator(uiLayout *layout,
0,
0,
"");
- else
+ }
+ else {
uiDefBut(block,
UI_BTYPE_LABEL,
1,
@@ -240,6 +242,7 @@ static void draw_modifier__generator(uiLayout *layout,
0,
0,
"");
+ }
/* coefficient */
uiDefButF(block,
@@ -258,12 +261,15 @@ static void draw_modifier__generator(uiLayout *layout,
TIP_("Coefficient for polynomial"));
/* 'x' param (and '+' if necessary) */
- if (i == 0)
+ if (i == 0) {
BLI_strncpy(xval, "", sizeof(xval));
- else if (i == 1)
+ }
+ else if (i == 1) {
BLI_strncpy(xval, "x", sizeof(xval));
- else
+ }
+ else {
BLI_snprintf(xval, sizeof(xval), "x^%u", i);
+ }
uiDefBut(block,
UI_BTYPE_LABEL,
1,
@@ -328,7 +334,7 @@ static void draw_modifier__generator(uiLayout *layout,
cp = data->coefficients;
for (i = 0; (i < data->poly_order) && (cp); i++, cp += 2) {
/* To align with first line */
- if (i)
+ if (i) {
uiDefBut(block,
UI_BTYPE_LABEL,
1,
@@ -343,7 +349,8 @@ static void draw_modifier__generator(uiLayout *layout,
0,
0,
"");
- else
+ }
+ else {
uiDefBut(block,
UI_BTYPE_LABEL,
1,
@@ -358,6 +365,7 @@ static void draw_modifier__generator(uiLayout *layout,
0,
0,
"");
+ }
/* opening bracket */
uiDefBut(
block, UI_BTYPE_LABEL, 1, "(", 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
@@ -429,7 +437,7 @@ static void draw_modifier__generator(uiLayout *layout,
row = uiLayoutRow(layout, true);
block = uiLayoutGetBlock(row);
}
- else
+ else {
uiDefBut(block,
UI_BTYPE_LABEL,
1,
@@ -444,6 +452,7 @@ static void draw_modifier__generator(uiLayout *layout,
0,
0,
"");
+ }
}
break;
}
@@ -569,15 +578,17 @@ static void fmod_envelope_addpoint_cb(bContext *C, void *fcm_dv, void *UNUSED(ar
fedn = MEM_callocN((env->totvert + 1) * sizeof(FCM_EnvelopeData), "FCM_EnvelopeData");
/* add the points that should occur before the point to be pasted */
- if (i > 0)
+ if (i > 0) {
memcpy(fedn, env->data, i * sizeof(FCM_EnvelopeData));
+ }
/* add point to paste at index i */
*(fedn + i) = fed;
/* add the points that occur after the point to be pasted */
- if (i < env->totvert)
+ if (i < env->totvert) {
memcpy(fedn + i + 1, env->data + i, (env->totvert - i) * sizeof(FCM_EnvelopeData));
+ }
/* replace (+ free) old with new */
MEM_freeN(env->data);
@@ -885,10 +896,12 @@ void ANIM_uiTemplate_fmodifier_draw(uiLayout *layout,
uiItemR(sub, &ptr, "active", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
/* name */
- if (fmi)
+ if (fmi) {
uiItemL(sub, IFACE_(fmi->name), ICON_NONE);
- else
+ }
+ else {
uiItemL(sub, IFACE_("<Unknown Modifier>"), ICON_NONE);
+ }
/* right-align ------------------------------------------- */
sub = uiLayoutRow(row, true);
@@ -1025,8 +1038,9 @@ bool ANIM_fmodifiers_copy_to_buf(ListBase *modifiers, bool active)
bool ok = true;
/* sanity checks */
- if (ELEM(NULL, modifiers, modifiers->first))
+ if (ELEM(NULL, modifiers, modifiers->first)) {
return 0;
+ }
/* copy the whole list, or just the active one? */
if (active) {
@@ -1036,11 +1050,13 @@ bool ANIM_fmodifiers_copy_to_buf(ListBase *modifiers, bool active)
FModifier *fcmN = copy_fmodifier(fcm);
BLI_addtail(&fmodifier_copypaste_buf, fcmN);
}
- else
+ else {
ok = 0;
+ }
}
- else
+ else {
copy_fmodifiers(&fmodifier_copypaste_buf, modifiers);
+ }
/* did we succeed? */
return ok;
@@ -1055,14 +1071,16 @@ bool ANIM_fmodifiers_paste_from_buf(ListBase *modifiers, bool replace, FCurve *c
bool ok = false;
/* sanity checks */
- if (modifiers == NULL)
+ if (modifiers == NULL) {
return 0;
+ }
bool was_cyclic = curve && BKE_fcurve_is_cyclic(curve);
/* if replacing the list, free the existing modifiers */
- if (replace)
+ if (replace) {
free_fmodifiers(modifiers);
+ }
/* now copy over all the modifiers in the buffer to the end of the list */
for (fcm = fmodifier_copypaste_buf.first; fcm; fcm = fcm->next) {
@@ -1080,8 +1098,9 @@ bool ANIM_fmodifiers_paste_from_buf(ListBase *modifiers, bool replace, FCurve *c
}
/* adding or removing the Cycles modifier requires an update to handles */
- if (curve && BKE_fcurve_is_cyclic(curve) != was_cyclic)
+ if (curve && BKE_fcurve_is_cyclic(curve) != was_cyclic) {
calchandles_fcurve(curve);
+ }
/* did we succeed? */
return ok;
diff --git a/source/blender/editors/animation/keyframes_draw.c b/source/blender/editors/animation/keyframes_draw.c
index 86b438846c9..22350f997f3 100644
--- a/source/blender/editors/animation/keyframes_draw.c
+++ b/source/blender/editors/animation/keyframes_draw.c
@@ -77,13 +77,16 @@ short compare_ak_cfraPtr(void *node, void *data)
const float *cframe = data;
float val = *cframe;
- if (is_cfra_eq(val, ak->cfra))
+ if (is_cfra_eq(val, ak->cfra)) {
return 0;
+ }
- if (val < ak->cfra)
+ if (val < ak->cfra) {
return -1;
- else
+ }
+ else {
return 1;
+ }
}
/* --------------- */
@@ -205,16 +208,18 @@ static void nupdate_ak_bezt(void *node, void *data)
BezTriple *bezt = chain->cur;
/* set selection status and 'touched' status */
- if (BEZT_ISSEL_ANY(bezt))
+ if (BEZT_ISSEL_ANY(bezt)) {
ak->sel = SELECT;
+ }
/* count keyframes in this column */
ak->totkey++;
/* For keyframe type, 'proper' keyframes have priority over breakdowns
* (and other types for now). */
- if (BEZKEYTYPE(bezt) == BEZT_KEYTYPE_KEYFRAME)
+ if (BEZKEYTYPE(bezt) == BEZT_KEYTYPE_KEYFRAME) {
ak->key_type = BEZT_KEYTYPE_KEYFRAME;
+ }
/* For interpolation type, select the highest value (enum is sorted). */
ak->handle_type = MAX2(ak->handle_type, bezt_handle_type(bezt));
@@ -268,16 +273,18 @@ static void nupdate_ak_gpframe(void *node, void *data)
bGPDframe *gpf = (bGPDframe *)data;
/* set selection status and 'touched' status */
- if (gpf->flag & GP_FRAME_SELECT)
+ if (gpf->flag & GP_FRAME_SELECT) {
ak->sel = SELECT;
+ }
/* count keyframes in this column */
ak->totkey++;
/* for keyframe type, 'proper' keyframes have priority over breakdowns
* (and other types for now). */
- if (gpf->key_type == BEZT_KEYTYPE_KEYFRAME)
+ if (gpf->key_type == BEZT_KEYTYPE_KEYFRAME) {
ak->key_type = BEZT_KEYTYPE_KEYFRAME;
+ }
}
/* ......... */
@@ -314,8 +321,9 @@ static void nupdate_ak_masklayshape(void *node, void *data)
MaskLayerShape *masklay_shape = (MaskLayerShape *)data;
/* set selection status and 'touched' status */
- if (masklay_shape->flag & MASK_SHAPE_SELECT)
+ if (masklay_shape->flag & MASK_SHAPE_SELECT) {
ak->sel = SELECT;
+ }
/* count keyframes in this column */
ak->totkey++;
@@ -326,32 +334,38 @@ static void nupdate_ak_masklayshape(void *node, void *data)
/* Add the given BezTriple to the given 'list' of Keyframes */
static void add_bezt_to_keycolumns_list(DLRBT_Tree *keys, BezTripleChain *bezt)
{
- if (ELEM(NULL, keys, bezt))
+ if (ELEM(NULL, keys, bezt)) {
return;
- else
+ }
+ else {
BLI_dlrbTree_add(keys, compare_ak_bezt, nalloc_ak_bezt, nupdate_ak_bezt, bezt);
+ }
}
/* Add the given GPencil Frame to the given 'list' of Keyframes */
static void add_gpframe_to_keycolumns_list(DLRBT_Tree *keys, bGPDframe *gpf)
{
- if (ELEM(NULL, keys, gpf))
+ if (ELEM(NULL, keys, gpf)) {
return;
- else
+ }
+ else {
BLI_dlrbTree_add(keys, compare_ak_gpframe, nalloc_ak_gpframe, nupdate_ak_gpframe, gpf);
+ }
}
/* Add the given MaskLayerShape Frame to the given 'list' of Keyframes */
static void add_masklay_to_keycolumns_list(DLRBT_Tree *keys, MaskLayerShape *masklay_shape)
{
- if (ELEM(NULL, keys, masklay_shape))
+ if (ELEM(NULL, keys, masklay_shape)) {
return;
- else
+ }
+ else {
BLI_dlrbTree_add(keys,
compare_ak_masklayshape,
nalloc_ak_masklayshape,
nupdate_ak_masklayshape,
masklay_shape);
+ }
}
/* ActKeyBlocks (Long Keyframes) ------------------------------------------ */
@@ -528,8 +542,9 @@ bool actkeyblock_is_valid(ActKeyColumn *ac)
int actkeyblock_get_valid_hold(ActKeyColumn *ac)
{
/* check that block is valid */
- if (!actkeyblock_is_valid(ac))
+ if (!actkeyblock_is_valid(ac)) {
return 0;
+ }
const int hold_mask = (ACTKEYBLOCK_FLAG_ANY_HOLD | ACTKEYBLOCK_FLAG_STATIC_HOLD |
ACTKEYBLOCK_FLAG_ANY_HOLD);
@@ -784,8 +799,9 @@ static void draw_keylist(View2D *v2d,
* This might give some improvements,
* since we current have to flip between view/region matrices.
*/
- if (IN_RANGE_INCL(ak->cfra, v2d->cur.xmin, v2d->cur.xmax))
+ if (IN_RANGE_INCL(ak->cfra, v2d->cur.xmin, v2d->cur.xmax)) {
key_len++;
+ }
}
if (key_len > 0) {
@@ -1046,8 +1062,9 @@ void scene_to_keylist(bDopeSheet *ads, Scene *sce, DLRBT_Tree *keys, int saction
bAnimListElem dummychan = {NULL};
- if (sce == NULL)
+ if (sce == NULL) {
return;
+ }
/* create a dummy wrapper data to work with */
dummychan.type = ANIMTYPE_SCENE;
@@ -1064,8 +1081,9 @@ void scene_to_keylist(bDopeSheet *ads, Scene *sce, DLRBT_Tree *keys, int saction
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
/* loop through each F-Curve, grabbing the keyframes */
- for (ale = anim_data.first; ale; ale = ale->next)
+ for (ale = anim_data.first; ale; ale = ale->next) {
fcurve_to_keylist(ale->adt, ale->data, keys, saction_flag);
+ }
ANIM_animdata_freelist(&anim_data);
}
@@ -1080,8 +1098,9 @@ void ob_to_keylist(bDopeSheet *ads, Object *ob, DLRBT_Tree *keys, int saction_fl
bAnimListElem dummychan = {NULL};
Base dummybase = {NULL};
- if (ob == NULL)
+ if (ob == NULL) {
return;
+ }
/* create a dummy wrapper data to work with */
dummybase.object = ob;
@@ -1100,8 +1119,9 @@ void ob_to_keylist(bDopeSheet *ads, Object *ob, DLRBT_Tree *keys, int saction_fl
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
/* loop through each F-Curve, grabbing the keyframes */
- for (ale = anim_data.first; ale; ale = ale->next)
+ for (ale = anim_data.first; ale; ale = ale->next) {
fcurve_to_keylist(ale->adt, ale->data, keys, saction_flag);
+ }
ANIM_animdata_freelist(&anim_data);
}
@@ -1144,8 +1164,9 @@ void fcurve_to_keylist(AnimData *adt, FCurve *fcu, DLRBT_Tree *keys, int saction
{
if (fcu && fcu->totvert && fcu->bezt) {
/* apply NLA-mapping (if applicable) */
- if (adt)
+ if (adt) {
ANIM_nla_mapping_apply_fcurve(adt, fcu, 0, 0);
+ }
/* Check if the curve is cyclic. */
bool is_cyclic = BKE_fcurve_is_cyclic(fcu) && (fcu->totvert >= 2);
@@ -1170,8 +1191,9 @@ void fcurve_to_keylist(AnimData *adt, FCurve *fcu, DLRBT_Tree *keys, int saction
update_keyblocks(keys, fcu->bezt, fcu->totvert);
/* unapply NLA-mapping if applicable */
- if (adt)
+ if (adt) {
ANIM_nla_mapping_apply_fcurve(adt, fcu, 1, 0);
+ }
}
}
@@ -1222,8 +1244,9 @@ void gpl_to_keylist(bDopeSheet *UNUSED(ads), bGPDlayer *gpl, DLRBT_Tree *keys)
if (gpl && keys) {
/* Although the frames should already be in an ordered list,
* they are not suitable for displaying yet. */
- for (gpf = gpl->frames.first; gpf; gpf = gpf->next)
+ for (gpf = gpl->frames.first; gpf; gpf = gpf->next) {
add_gpframe_to_keycolumns_list(keys, gpf);
+ }
update_keyblocks(keys, NULL, 0);
}
diff --git a/source/blender/editors/animation/keyframes_edit.c b/source/blender/editors/animation/keyframes_edit.c
index e0df1942495..815d4c5f3af 100644
--- a/source/blender/editors/animation/keyframes_edit.c
+++ b/source/blender/editors/animation/keyframes_edit.c
@@ -82,8 +82,9 @@ short ANIM_fcurve_keyframes_loop(KeyframeEditData *ked,
unsigned int i;
/* sanity check */
- if (ELEM(NULL, fcu, fcu->bezt))
+ if (ELEM(NULL, fcu, fcu->bezt)) {
return 0;
+ }
/* set the F-Curve into the editdata so that it can be accessed */
if (ked) {
@@ -107,27 +108,31 @@ short ANIM_fcurve_keyframes_loop(KeyframeEditData *ked,
/* Only operate on this BezTriple if it fulfills the criteria of the validation func */
if ((ok = key_ok(ked, bezt))) {
- if (ked)
+ if (ked) {
ked->curflags = ok;
+ }
/* Exit with return-code '1' if function returns positive
* This is useful if finding if some BezTriple satisfies a condition.
*/
- if (key_cb(ked, bezt))
+ if (key_cb(ked, bezt)) {
return 1;
+ }
}
}
}
else {
for (bezt = fcu->bezt, i = 0; i < fcu->totvert; bezt++, i++) {
- if (ked)
+ if (ked) {
ked->curIndex = i;
+ }
/* Exit with return-code '1' if function returns positive
* This is useful if finding if some BezTriple satisfies a condition.
*/
- if (key_cb(ked, bezt))
+ if (key_cb(ked, bezt)) {
return 1;
+ }
}
}
}
@@ -140,8 +145,9 @@ short ANIM_fcurve_keyframes_loop(KeyframeEditData *ked,
}
/* if fcu_cb (F-Curve post-editing callback) has been specified then execute it */
- if (fcu_cb)
+ if (fcu_cb) {
fcu_cb(fcu);
+ }
/* done */
return 0;
@@ -159,13 +165,15 @@ static short agrp_keyframes_loop(KeyframeEditData *ked,
FCurve *fcu;
/* sanity check */
- if (agrp == NULL)
+ if (agrp == NULL) {
return 0;
+ }
/* only iterate over the F-Curves that are in this group */
for (fcu = agrp->channels.first; fcu && fcu->grp == agrp; fcu = fcu->next) {
- if (ANIM_fcurve_keyframes_loop(ked, fcu, key_ok, key_cb, fcu_cb))
+ if (ANIM_fcurve_keyframes_loop(ked, fcu, key_ok, key_cb, fcu_cb)) {
return 1;
+ }
}
return 0;
@@ -181,13 +189,15 @@ static short act_keyframes_loop(KeyframeEditData *ked,
FCurve *fcu;
/* sanity check */
- if (act == NULL)
+ if (act == NULL) {
return 0;
+ }
/* just loop through all F-Curves */
for (fcu = act->curves.first; fcu; fcu = fcu->next) {
- if (ANIM_fcurve_keyframes_loop(ked, fcu, key_ok, key_cb, fcu_cb))
+ if (ANIM_fcurve_keyframes_loop(ked, fcu, key_ok, key_cb, fcu_cb)) {
return 1;
+ }
}
return 0;
@@ -210,8 +220,9 @@ static short ob_keyframes_loop(KeyframeEditData *ked,
bAnimListElem dummychan = {NULL};
Base dummybase = {NULL};
- if (ob == NULL)
+ if (ob == NULL) {
return 0;
+ }
/* create a dummy wrapper data to work with */
dummybase.object = ob;
@@ -259,8 +270,9 @@ static short scene_keyframes_loop(KeyframeEditData *ked,
bAnimListElem dummychan = {NULL};
- if (sce == NULL)
+ if (sce == NULL) {
return 0;
+ }
/* create a dummy wrapper data to work with */
dummychan.type = ANIMTYPE_SCENE;
@@ -302,8 +314,9 @@ static short summary_keyframes_loop(KeyframeEditData *ked,
int filter, ret_code = 0;
/* sanity check */
- if (ac == NULL)
+ if (ac == NULL) {
return 0;
+ }
/* get F-Curves to take keyframes from */
filter = ANIMFILTER_DATA_VISIBLE;
@@ -328,10 +341,12 @@ static short summary_keyframes_loop(KeyframeEditData *ked,
if (ked->iterflags & (KED_F1_NLA_UNMAP | KED_F2_NLA_UNMAP)) {
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
- if (ked->iterflags & KED_F1_NLA_UNMAP)
+ if (ked->iterflags & KED_F1_NLA_UNMAP) {
ked->f1 = BKE_nla_tweakedit_remap(adt, f1, NLATIME_CONVERT_UNMAP);
- if (ked->iterflags & KED_F2_NLA_UNMAP)
+ }
+ if (ked->iterflags & KED_F2_NLA_UNMAP) {
ked->f2 = BKE_nla_tweakedit_remap(adt, f2, NLATIME_CONVERT_UNMAP);
+ }
}
/* now operate on the channel as per normal */
@@ -349,8 +364,9 @@ static short summary_keyframes_loop(KeyframeEditData *ked,
}
}
- if (ret_code)
+ if (ret_code) {
break;
+ }
}
ANIM_animdata_freelist(&anim_data);
@@ -369,8 +385,9 @@ short ANIM_animchannel_keyframes_loop(KeyframeEditData *ked,
FcuEditFunc fcu_cb)
{
/* sanity checks */
- if (ale == NULL)
+ if (ale == NULL) {
return 0;
+ }
/* method to use depends on the type of keyframe data */
switch (ale->datatype) {
@@ -408,8 +425,9 @@ short ANIM_animchanneldata_keyframes_loop(KeyframeEditData *ked,
FcuEditFunc fcu_cb)
{
/* sanity checks */
- if (data == NULL)
+ if (data == NULL) {
return 0;
+ }
/* method to use depends on the type of keyframe data */
switch (keytype) {
@@ -522,10 +540,12 @@ static short ok_bezier_selected(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
/* this macro checks all beztriple handles for selection...
* only one of the verts has to be selected for this to be ok...
*/
- if (BEZT_ISSEL_ANY(bezt))
+ if (BEZT_ISSEL_ANY(bezt)) {
return KEYFRAME_OK_ALL;
- else
+ }
+ else {
return 0;
+ }
}
static short ok_bezier_value(KeyframeEditData *ked, BezTriple *bezt)
@@ -571,8 +591,9 @@ static short ok_bezier_region(KeyframeEditData *ked, BezTriple *bezt)
/* return ok flags */
return ok;
}
- else
+ else {
return 0;
+ }
}
/**
@@ -607,8 +628,9 @@ static short ok_bezier_region_lasso(KeyframeEditData *ked, BezTriple *bezt)
/* return ok flags */
return ok;
}
- else
+ else {
return 0;
+ }
}
static short ok_bezier_channel_lasso(KeyframeEditData *ked, BezTriple *bezt)
@@ -632,8 +654,9 @@ static short ok_bezier_channel_lasso(KeyframeEditData *ked, BezTriple *bezt)
pt[0] = bezt->vec[1][0];
pt[1] = ked->channel_y;
- if (keyframe_region_lasso_test(data, pt))
+ if (keyframe_region_lasso_test(data, pt)) {
return KEYFRAME_OK_KEY;
+ }
}
return 0;
}
@@ -669,8 +692,9 @@ static short ok_bezier_region_circle(KeyframeEditData *ked, BezTriple *bezt)
/* return ok flags */
return ok;
}
- else
+ else {
return 0;
+ }
}
static short ok_bezier_channel_circle(KeyframeEditData *ked, BezTriple *bezt)
@@ -694,8 +718,9 @@ static short ok_bezier_channel_circle(KeyframeEditData *ked, BezTriple *bezt)
pt[0] = bezt->vec[1][0];
pt[1] = ked->channel_y;
- if (keyframe_region_circle_test(data, pt))
+ if (keyframe_region_circle_test(data, pt)) {
return KEYFRAME_OK_KEY;
+ }
}
return 0;
}
@@ -802,8 +827,9 @@ void bezt_remap_times(KeyframeEditData *ked, BezTriple *bezt)
/* snaps the keyframe to the nearest frame */
static short snap_bezier_nearest(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
bezt->vec[1][0] = (float)(floorf(bezt->vec[1][0] + 0.5f));
+ }
return 0;
}
@@ -813,8 +839,9 @@ static short snap_bezier_nearestsec(KeyframeEditData *ked, BezTriple *bezt)
const Scene *scene = ked->scene;
const float secf = (float)FPS;
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
bezt->vec[1][0] = (floorf(bezt->vec[1][0] / secf + 0.5f) * secf);
+ }
return 0;
}
@@ -822,16 +849,18 @@ static short snap_bezier_nearestsec(KeyframeEditData *ked, BezTriple *bezt)
static short snap_bezier_cframe(KeyframeEditData *ked, BezTriple *bezt)
{
const Scene *scene = ked->scene;
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
bezt->vec[1][0] = (float)CFRA;
+ }
return 0;
}
/* snaps the keyframe time to the nearest marker's frame */
static short snap_bezier_nearmarker(KeyframeEditData *ked, BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
bezt->vec[1][0] = (float)ED_markers_find_nearest_marker_time(&ked->list, bezt->vec[1][0]);
+ }
return 0;
}
@@ -841,10 +870,12 @@ static short snap_bezier_horizontal(KeyframeEditData *UNUSED(ked), BezTriple *be
if (bezt->f2 & SELECT) {
bezt->vec[0][1] = bezt->vec[2][1] = bezt->vec[1][1];
- if (ELEM(bezt->h1, HD_AUTO, HD_AUTO_ANIM, HD_VECT))
+ if (ELEM(bezt->h1, HD_AUTO, HD_AUTO_ANIM, HD_VECT)) {
bezt->h1 = HD_ALIGN;
- if (ELEM(bezt->h2, HD_AUTO, HD_AUTO_ANIM, HD_VECT))
+ }
+ if (ELEM(bezt->h2, HD_AUTO, HD_AUTO_ANIM, HD_VECT)) {
bezt->h2 = HD_ALIGN;
+ }
}
return 0;
}
@@ -852,16 +883,18 @@ static short snap_bezier_horizontal(KeyframeEditData *UNUSED(ked), BezTriple *be
/* frame to snap to is stored in the custom data -> first float value slot */
static short snap_bezier_time(KeyframeEditData *ked, BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
bezt->vec[1][0] = ked->f1;
+ }
return 0;
}
/* value to snap to is stored in the custom data -> first float value slot */
static short snap_bezier_value(KeyframeEditData *ked, BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
bezt->vec[1][1] = ked->f1;
+ }
return 0;
}
@@ -1020,10 +1053,12 @@ KeyframeEditFunc ANIM_editkeyframes_mirror(short type)
static short set_bezier_auto(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
if ((bezt->f1 & SELECT) || (bezt->f3 & SELECT)) {
- if (bezt->f1 & SELECT)
+ if (bezt->f1 & SELECT) {
bezt->h1 = HD_AUTO;
- if (bezt->f3 & SELECT)
+ }
+ if (bezt->f3 & SELECT) {
bezt->h2 = HD_AUTO;
+ }
ENSURE_HANDLES_MATCH(bezt);
}
@@ -1036,10 +1071,12 @@ static short set_bezier_auto(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
static short set_bezier_auto_clamped(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
if ((bezt->f1 & SELECT) || (bezt->f3 & SELECT)) {
- if (bezt->f1 & SELECT)
+ if (bezt->f1 & SELECT) {
bezt->h1 = HD_AUTO_ANIM;
- if (bezt->f3 & SELECT)
+ }
+ if (bezt->f3 & SELECT) {
bezt->h2 = HD_AUTO_ANIM;
+ }
ENSURE_HANDLES_MATCH(bezt);
}
@@ -1049,10 +1086,12 @@ static short set_bezier_auto_clamped(KeyframeEditData *UNUSED(ked), BezTriple *b
/* Sets the selected bezier handles to type 'vector' */
static short set_bezier_vector(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f1 & SELECT)
+ if (bezt->f1 & SELECT) {
bezt->h1 = HD_VECT;
- if (bezt->f3 & SELECT)
+ }
+ if (bezt->f3 & SELECT) {
bezt->h2 = HD_VECT;
+ }
return 0;
}
@@ -1061,30 +1100,36 @@ static short set_bezier_vector(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
// currently this isn't used, but may be restored later
static short bezier_isfree(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if ((bezt->f1 & SELECT) && (bezt->h1))
+ if ((bezt->f1 & SELECT) && (bezt->h1)) {
return 1;
- if ((bezt->f3 & SELECT) && (bezt->h2))
+ }
+ if ((bezt->f3 & SELECT) && (bezt->h2)) {
return 1;
+ }
return 0;
}
/* Sets selected bezier handles to type 'align' */
static short set_bezier_align(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f1 & SELECT)
+ if (bezt->f1 & SELECT) {
bezt->h1 = HD_ALIGN;
- if (bezt->f3 & SELECT)
+ }
+ if (bezt->f3 & SELECT) {
bezt->h2 = HD_ALIGN;
+ }
return 0;
}
/* Sets selected bezier handles to type 'free' */
static short set_bezier_free(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f1 & SELECT)
+ if (bezt->f1 & SELECT) {
bezt->h1 = HD_FREE;
- if (bezt->f3 & SELECT)
+ }
+ if (bezt->f3 & SELECT) {
bezt->h2 = HD_FREE;
+ }
return 0;
}
@@ -1114,92 +1159,105 @@ KeyframeEditFunc ANIM_editkeyframes_handles(short code)
static short set_bezt_constant(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
bezt->ipo = BEZT_IPO_CONST;
+ }
return 0;
}
static short set_bezt_linear(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
bezt->ipo = BEZT_IPO_LIN;
+ }
return 0;
}
static short set_bezt_bezier(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
bezt->ipo = BEZT_IPO_BEZ;
+ }
return 0;
}
static short set_bezt_back(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
bezt->ipo = BEZT_IPO_BACK;
+ }
return 0;
}
static short set_bezt_bounce(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
bezt->ipo = BEZT_IPO_BOUNCE;
+ }
return 0;
}
static short set_bezt_circle(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
bezt->ipo = BEZT_IPO_CIRC;
+ }
return 0;
}
static short set_bezt_cubic(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
bezt->ipo = BEZT_IPO_CUBIC;
+ }
return 0;
}
static short set_bezt_elastic(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
bezt->ipo = BEZT_IPO_ELASTIC;
+ }
return 0;
}
static short set_bezt_expo(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
bezt->ipo = BEZT_IPO_EXPO;
+ }
return 0;
}
static short set_bezt_quad(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
bezt->ipo = BEZT_IPO_QUAD;
+ }
return 0;
}
static short set_bezt_quart(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
bezt->ipo = BEZT_IPO_QUART;
+ }
return 0;
}
static short set_bezt_quint(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
bezt->ipo = BEZT_IPO_QUINT;
+ }
return 0;
}
static short set_bezt_sine(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
bezt->ipo = BEZT_IPO_SINE;
+ }
return 0;
}
@@ -1245,36 +1303,41 @@ KeyframeEditFunc ANIM_editkeyframes_ipo(short code)
static short set_keytype_keyframe(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
BEZKEYTYPE(bezt) = BEZT_KEYTYPE_KEYFRAME;
+ }
return 0;
}
static short set_keytype_breakdown(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
BEZKEYTYPE(bezt) = BEZT_KEYTYPE_BREAKDOWN;
+ }
return 0;
}
static short set_keytype_extreme(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
BEZKEYTYPE(bezt) = BEZT_KEYTYPE_EXTREME;
+ }
return 0;
}
static short set_keytype_jitter(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
BEZKEYTYPE(bezt) = BEZT_KEYTYPE_JITTER;
+ }
return 0;
}
static short set_keytype_moving_hold(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
BEZKEYTYPE(bezt) = BEZT_KEYTYPE_MOVEHOLD;
+ }
return 0;
}
@@ -1304,29 +1367,33 @@ KeyframeEditFunc ANIM_editkeyframes_keytype(short code)
static short set_easingtype_easein(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
bezt->easing = BEZT_IPO_EASE_IN;
+ }
return 0;
}
static short set_easingtype_easeout(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
bezt->easing = BEZT_IPO_EASE_OUT;
+ }
return 0;
}
static short set_easingtype_easeinout(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
bezt->easing = BEZT_IPO_EASE_IN_OUT;
+ }
return 0;
}
static short set_easingtype_easeauto(KeyframeEditData *UNUSED(ked), BezTriple *bezt)
{
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
bezt->easing = BEZT_IPO_EASE_AUTO;
+ }
return 0;
}
@@ -1355,12 +1422,15 @@ static short select_bezier_add(KeyframeEditData *ked, BezTriple *bezt)
{
/* if we've got info on what to select, use it, otherwise select all */
if ((ked) && (ked->iterflags & KEYFRAME_ITER_INCL_HANDLES)) {
- if (ked->curflags & KEYFRAME_OK_KEY)
+ if (ked->curflags & KEYFRAME_OK_KEY) {
bezt->f2 |= SELECT;
- if (ked->curflags & KEYFRAME_OK_H1)
+ }
+ if (ked->curflags & KEYFRAME_OK_H1) {
bezt->f1 |= SELECT;
- if (ked->curflags & KEYFRAME_OK_H2)
+ }
+ if (ked->curflags & KEYFRAME_OK_H2) {
bezt->f3 |= SELECT;
+ }
}
else {
BEZT_SEL_ALL(bezt);
@@ -1373,12 +1443,15 @@ static short select_bezier_subtract(KeyframeEditData *ked, BezTriple *bezt)
{
/* if we've got info on what to deselect, use it, otherwise deselect all */
if ((ked) && (ked->iterflags & KEYFRAME_ITER_INCL_HANDLES)) {
- if (ked->curflags & KEYFRAME_OK_KEY)
+ if (ked->curflags & KEYFRAME_OK_KEY) {
bezt->f2 &= ~SELECT;
- if (ked->curflags & KEYFRAME_OK_H1)
+ }
+ if (ked->curflags & KEYFRAME_OK_H1) {
bezt->f1 &= ~SELECT;
- if (ked->curflags & KEYFRAME_OK_H2)
+ }
+ if (ked->curflags & KEYFRAME_OK_H2) {
bezt->f3 &= ~SELECT;
+ }
}
else {
BEZT_DESEL_ALL(bezt);
@@ -1476,8 +1549,9 @@ static short selmap_build_bezier_less(KeyframeEditData *ked, BezTriple *bezt)
if (i > 0) {
BezTriple *prev = bezt - 1;
- if (BEZT_ISSEL_ANY(prev) == 0)
+ if (BEZT_ISSEL_ANY(prev) == 0) {
return 0;
+ }
}
else if (i == 0) {
/* current keyframe is selected at an endpoint, so should get deselected */
@@ -1488,8 +1562,9 @@ static short selmap_build_bezier_less(KeyframeEditData *ked, BezTriple *bezt)
if (i < (fcu->totvert - 1)) {
BezTriple *next = bezt + 1;
- if (BEZT_ISSEL_ANY(next) == 0)
+ if (BEZT_ISSEL_ANY(next) == 0) {
return 0;
+ }
}
else if (i == (fcu->totvert - 1)) {
/* current keyframe is selected at an endpoint, so should get deselected */
diff --git a/source/blender/editors/animation/keyframes_general.c b/source/blender/editors/animation/keyframes_general.c
index 3109ae6c553..5214c5f78fa 100644
--- a/source/blender/editors/animation/keyframes_general.c
+++ b/source/blender/editors/animation/keyframes_general.c
@@ -70,17 +70,20 @@
void delete_fcurve_key(FCurve *fcu, int index, bool do_recalc)
{
/* sanity check */
- if (fcu == NULL)
+ if (fcu == NULL) {
return;
+ }
/* verify the index:
* 1) cannot be greater than the number of available keyframes
* 2) negative indices are for specifying a value from the end of the array
*/
- if (abs(index) >= fcu->totvert)
+ if (abs(index) >= fcu->totvert) {
return;
- else if (index < 0)
+ }
+ else if (index < 0) {
index += fcu->totvert;
+ }
/* Delete this keyframe */
memmove(
@@ -88,14 +91,16 @@ void delete_fcurve_key(FCurve *fcu, int index, bool do_recalc)
fcu->totvert--;
if (fcu->totvert == 0) {
- if (fcu->bezt)
+ if (fcu->bezt) {
MEM_freeN(fcu->bezt);
+ }
fcu->bezt = NULL;
}
/* recalc handles - only if it won't cause problems */
- if (do_recalc)
+ if (do_recalc) {
calchandles_fcurve(fcu);
+ }
}
/* Delete selected keyframes in given F-Curve */
@@ -104,8 +109,9 @@ bool delete_fcurve_keys(FCurve *fcu)
int i;
bool changed = false;
- if (fcu->bezt == NULL) /* ignore baked curves */
+ if (fcu->bezt == NULL) { /* ignore baked curves */
return false;
+ }
/* Delete selected BezTriples */
for (i = 0; i < fcu->totvert; i++) {
@@ -118,16 +124,18 @@ bool delete_fcurve_keys(FCurve *fcu)
}
/* Free the array of BezTriples if there are not keyframes */
- if (fcu->totvert == 0)
+ if (fcu->totvert == 0) {
clear_fcurve_keys(fcu);
+ }
return changed;
}
void clear_fcurve_keys(FCurve *fcu)
{
- if (fcu->bezt)
+ if (fcu->bezt) {
MEM_freeN(fcu->bezt);
+ }
fcu->bezt = NULL;
fcu->totvert = 0;
@@ -142,8 +150,9 @@ void duplicate_fcurve_keys(FCurve *fcu)
int i;
/* this can only work when there is an F-Curve, and also when there are some BezTriples */
- if (ELEM(NULL, fcu, fcu->bezt))
+ if (ELEM(NULL, fcu, fcu->bezt)) {
return;
+ }
for (i = 0; i < fcu->totvert; i++) {
/* If a key is selected */
@@ -283,8 +292,9 @@ void clean_fcurve(struct bAnimContext *ac, bAnimListElem *ale, float thresh, boo
}
/* now free the memory used by the old BezTriples */
- if (old_bezts)
+ if (old_bezts) {
MEM_freeN(old_bezts);
+ }
/* final step, if there is just one key in fcurve, check if it's
* the default value and if is, remove fcurve completely. */
@@ -296,8 +306,9 @@ void clean_fcurve(struct bAnimContext *ac, bAnimListElem *ale, float thresh, boo
/* get property to read from, and get value as appropriate */
if (RNA_path_resolve_property(&id_ptr, fcu->rna_path, &ptr, &prop)) {
- if (RNA_property_type(prop) == PROP_FLOAT)
+ if (RNA_property_type(prop) == PROP_FLOAT) {
default_value = RNA_property_float_get_default_index(&ptr, prop, fcu->array_index);
+ }
}
if (fcu->bezt->vec[1][1] == default_value) {
@@ -336,8 +347,9 @@ void smooth_fcurve(FCurve *fcu)
/* first loop through - count how many verts are selected */
bezt = fcu->bezt;
for (i = 0; i < fcu->totvert; i++, bezt++) {
- if (BEZT_ISSEL_ANY(bezt))
+ if (BEZT_ISSEL_ANY(bezt)) {
totSel++;
+ }
}
/* if any points were selected, allocate tSmooth_Bezt points to work on */
@@ -357,10 +369,12 @@ void smooth_fcurve(FCurve *fcu)
tsb->h3 = &bezt->vec[2][1];
/* advance to the next tsb to populate */
- if (x < totSel - 1)
+ if (x < totSel - 1) {
tsb++;
- else
+ }
+ else {
break;
+ }
}
}
@@ -433,8 +447,9 @@ void sample_fcurve(FCurve *fcu)
int sfra, range;
int i, n;
- if (fcu->bezt == NULL) /* ignore baked */
+ if (fcu->bezt == NULL) { /* ignore baked */
return;
+ }
/* find selected keyframes... once pair has been found, add keyframes */
for (i = 0, bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) {
@@ -543,12 +558,14 @@ void ANIM_fcurves_copybuf_free(void)
acn = aci->next;
/* free keyframes */
- if (aci->bezt)
+ if (aci->bezt) {
MEM_freeN(aci->bezt);
+ }
/* free RNA-path */
- if (aci->rna_path)
+ if (aci->rna_path) {
MEM_freeN(aci->rna_path);
+ }
/* free ourself */
BLI_freelinkN(&animcopybuf, aci);
@@ -583,8 +600,9 @@ short copy_animedit_keys(bAnimContext *ac, ListBase *anim_data)
* - this check should also eliminate any problems associated with using sample-data
*/
if (ANIM_fcurve_keyframes_loop(
- NULL, fcu, NULL, ANIM_editkeyframes_ok(BEZT_OK_SELECTED), NULL) == 0)
+ NULL, fcu, NULL, ANIM_editkeyframes_ok(BEZT_OK_SELECTED), NULL) == 0) {
continue;
+ }
/* init copybuf item info */
aci = MEM_callocN(sizeof(tAnimCopybufItem), "AnimCopybufItem");
@@ -607,8 +625,9 @@ short copy_animedit_keys(bAnimContext *ac, ListBase *anim_data)
if (pchan) {
aci->is_bone = true;
}
- if (bone_name)
+ if (bone_name) {
MEM_freeN(bone_name);
+ }
}
BLI_addtail(&animcopybuf, aci);
@@ -622,8 +641,9 @@ short copy_animedit_keys(bAnimContext *ac, ListBase *anim_data)
newbuf = MEM_callocN(sizeof(BezTriple) * (aci->totvert + 1), "copybuf beztriple");
/* assume that since we are just re-sizing the array, just copy all existing data across */
- if (aci->bezt)
+ if (aci->bezt) {
memcpy(newbuf, aci->bezt, sizeof(BezTriple) * (aci->totvert));
+ }
/* copy current beztriple across too */
nbezt = &newbuf[aci->totvert];
@@ -633,23 +653,27 @@ short copy_animedit_keys(bAnimContext *ac, ListBase *anim_data)
BEZT_SEL_ALL(nbezt);
/* free old array and set the new */
- if (aci->bezt)
+ if (aci->bezt) {
MEM_freeN(aci->bezt);
+ }
aci->bezt = newbuf;
aci->totvert++;
/* check if this is the earliest frame encountered so far */
- if (bezt->vec[1][0] < animcopy_firstframe)
+ if (bezt->vec[1][0] < animcopy_firstframe) {
animcopy_firstframe = bezt->vec[1][0];
- if (bezt->vec[1][0] > animcopy_lastframe)
+ }
+ if (bezt->vec[1][0] > animcopy_lastframe) {
animcopy_lastframe = bezt->vec[1][0];
+ }
}
}
}
/* check if anything ended up in the buffer */
- if (ELEM(NULL, animcopybuf.first, animcopybuf.last))
+ if (ELEM(NULL, animcopybuf.first, animcopybuf.last)) {
return -1;
+ }
/* in case 'relative' paste method is used */
animcopy_cfra = CFRA;
@@ -762,8 +786,9 @@ static tAnimCopybufItem *pastebuf_match_path_property(Main *bmain,
if (len_id <= len_path) {
/* note, paths which end with "] will fail with this test - Animated ID Props */
if (STREQ(identifier, fcu->rna_path + (len_path - len_id))) {
- if ((from_single) || (aci->array_index == fcu->array_index))
+ if ((from_single) || (aci->array_index == fcu->array_index)) {
break;
+ }
}
}
}
@@ -803,17 +828,21 @@ static void do_curve_mirror_flippping(tAnimCopybufItem *aci, BezTriple *bezt)
if (aci->is_bone) {
const size_t slength = strlen(aci->rna_path);
bool flip = false;
- if (BLI_strn_endswith(aci->rna_path, "location", slength) && aci->array_index == 0)
+ if (BLI_strn_endswith(aci->rna_path, "location", slength) && aci->array_index == 0) {
flip = true;
+ }
else if (BLI_strn_endswith(aci->rna_path, "rotation_quaternion", slength) &&
- ELEM(aci->array_index, 2, 3))
+ ELEM(aci->array_index, 2, 3)) {
flip = true;
+ }
else if (BLI_strn_endswith(aci->rna_path, "rotation_euler", slength) &&
- ELEM(aci->array_index, 1, 2))
+ ELEM(aci->array_index, 1, 2)) {
flip = true;
+ }
else if (BLI_strn_endswith(aci->rna_path, "rotation_axis_angle", slength) &&
- ELEM(aci->array_index, 2, 3))
+ ELEM(aci->array_index, 2, 3)) {
flip = true;
+ }
if (flip) {
bezt->vec[0][1] = -bezt->vec[0][1];
@@ -879,8 +908,9 @@ static void paste_animedit_keys_fcurve(
/* just start pasting, with the first keyframe on the current frame, and so on */
for (i = 0, bezt = aci->bezt; i < aci->totvert; i++, bezt++) {
/* temporarily apply offset to src beztriple while copying */
- if (flip)
+ if (flip) {
do_curve_mirror_flippping(aci, bezt);
+ }
bezt->vec[0][0] += offset;
bezt->vec[1][0] += offset;
@@ -897,8 +927,9 @@ static void paste_animedit_keys_fcurve(
bezt->vec[1][0] -= offset;
bezt->vec[2][0] -= offset;
- if (flip)
+ if (flip) {
do_curve_mirror_flippping(aci, bezt);
+ }
}
/* recalculate F-Curve's handles? */
@@ -1054,8 +1085,9 @@ short paste_animedit_keys(bAnimContext *ac,
}
/* don't continue if some fcurves were pasted */
- if (totmatch)
+ if (totmatch) {
break;
+ }
}
}
diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c
index 56c52665613..4851665c9f3 100644
--- a/source/blender/editors/animation/keyframing.c
+++ b/source/blender/editors/animation/keyframing.c
@@ -94,27 +94,32 @@ short ANIM_get_keyframing_flags(Scene *scene, short incl_mode)
/* standard flags */
{
/* visual keying */
- if (IS_AUTOKEY_FLAG(scene, AUTOMATKEY))
+ if (IS_AUTOKEY_FLAG(scene, AUTOMATKEY)) {
flag |= INSERTKEY_MATRIX;
+ }
/* only needed */
- if (IS_AUTOKEY_FLAG(scene, INSERTNEEDED))
+ if (IS_AUTOKEY_FLAG(scene, INSERTNEEDED)) {
flag |= INSERTKEY_NEEDED;
+ }
/* default F-Curve color mode - RGB from XYZ indices */
- if (IS_AUTOKEY_FLAG(scene, XYZ2RGB))
+ if (IS_AUTOKEY_FLAG(scene, XYZ2RGB)) {
flag |= INSERTKEY_XYZ2RGB;
+ }
}
/* only if including settings from the autokeying mode... */
if (incl_mode) {
/* keyframing mode - only replace existing keyframes */
- if (IS_AUTOKEY_MODE(scene, EDITKEYS))
+ if (IS_AUTOKEY_MODE(scene, EDITKEYS)) {
flag |= INSERTKEY_REPLACE;
+ }
/* cycle-aware keyframe insertion - preserve cycle period and flow */
- if (IS_AUTOKEY_FLAG(scene, CYCLEAWARE))
+ if (IS_AUTOKEY_FLAG(scene, CYCLEAWARE)) {
flag |= INSERTKEY_CYCLE_AWARE;
+ }
}
return flag;
@@ -132,8 +137,9 @@ bAction *verify_adt_action(Main *bmain, ID *id, short add)
/* init animdata if none available yet */
adt = BKE_animdata_from_id(id);
- if ((adt == NULL) && (add))
+ if ((adt == NULL) && (add)) {
adt = BKE_animdata_add_id(id);
+ }
if (adt == NULL) {
/* if still none (as not allowed to add, or ID doesn't have animdata for some reason) */
printf("ERROR: Couldn't add AnimData (ID = %s)\n", (id) ? (id->name) : "<None>");
@@ -181,8 +187,9 @@ FCurve *verify_fcurve(Main *bmain,
FCurve *fcu;
/* sanity checks */
- if (ELEM(NULL, act, rna_path))
+ if (ELEM(NULL, act, rna_path)) {
return NULL;
+ }
/* try to find f-curve matching for this setting
* - add if not found and allowed to add one
@@ -196,8 +203,9 @@ FCurve *verify_fcurve(Main *bmain,
fcu->flag = (FCURVE_VISIBLE | FCURVE_SELECTED);
fcu->auto_smoothing = FCURVE_SMOOTH_CONT_ACCEL;
- if (BLI_listbase_is_empty(&act->curves))
+ if (BLI_listbase_is_empty(&act->curves)) {
fcu->flag |= FCURVE_ACTIVE; /* first one added active */
+ }
/* store path - make copy, and store that */
fcu->rna_path = BLI_strdup(rna_path);
@@ -414,15 +422,17 @@ int insert_bezt_fcurve(FCurve *fcu, const BezTriple *bezt, eInsertKeyFlags flag)
/* Add the beztriples that should occur before the beztriple to be pasted
* (originally in fcu). */
- if (i > 0)
+ if (i > 0) {
memcpy(newb, fcu->bezt, i * sizeof(BezTriple));
+ }
/* add beztriple to paste at index i */
*(newb + i) = *bezt;
/* add the beztriples that occur after the beztriple to be pasted (originally in fcu) */
- if (i < fcu->totvert)
+ if (i < fcu->totvert) {
memcpy(newb + i + 1, fcu->bezt + i, (fcu->totvert - i) * sizeof(BezTriple));
+ }
/* replace (+ free) old with new, only if necessary to do so */
MEM_freeN(fcu->bezt);
@@ -533,15 +543,17 @@ int insert_vert_fcurve(
/* what if 'a' is a negative index?
* for now, just exit to prevent any segfaults
*/
- if (a < 0)
+ if (a < 0) {
return -1;
+ }
/* don't recalculate handles if fast is set
* - this is a hack to make importers faster
* - we may calculate twice (due to autohandle needing to be calculated twice)
*/
- if ((flag & INSERTKEY_FAST) == 0)
+ if ((flag & INSERTKEY_FAST) == 0) {
calchandles_fcurve(fcu);
+ }
/* set handletype and interpolation */
if ((fcu->totvert > 2) && (flag & INSERTKEY_REPLACE) == 0) {
@@ -553,18 +565,21 @@ int insert_vert_fcurve(
* - When replacing, the user may have specified some interpolation that should be kept.
*/
if (fcu->totvert > oldTot) {
- if (a > 0)
+ if (a > 0) {
bezt->ipo = (bezt - 1)->ipo;
- else if (a < fcu->totvert - 1)
+ }
+ else if (a < fcu->totvert - 1) {
bezt->ipo = (bezt + 1)->ipo;
+ }
}
/* don't recalculate handles if fast is set
* - this is a hack to make importers faster
* - we may calculate twice (due to autohandle needing to be calculated twice)
*/
- if ((flag & INSERTKEY_FAST) == 0)
+ if ((flag & INSERTKEY_FAST) == 0) {
calchandles_fcurve(fcu);
+ }
}
/* return the index at which the keyframe was added */
@@ -593,11 +608,13 @@ static short new_key_needed(FCurve *fcu, float cFrame, float nValue)
float valA = 0.0f, valB = 0.0f;
/* safety checking */
- if (fcu == NULL)
+ if (fcu == NULL) {
return KEYNEEDED_JUSTADD;
+ }
totCount = fcu->totvert;
- if (totCount == 0)
+ if (totCount == 0) {
return KEYNEEDED_JUSTADD;
+ }
/* loop through checking if any are the same */
bezt = fcu->bezt;
@@ -634,10 +651,12 @@ static short new_key_needed(FCurve *fcu, float cFrame, float nValue)
realVal = evaluate_fcurve(fcu, cFrame);
/* compare whether it's the same as proposed */
- if (IS_EQF(realVal, nValue))
+ if (IS_EQF(realVal, nValue)) {
return KEYNEEDED_DONTADD;
- else
+ }
+ else {
return KEYNEEDED_JUSTADD;
+ }
}
}
@@ -647,18 +666,21 @@ static short new_key_needed(FCurve *fcu, float cFrame, float nValue)
* stays around or not depends on whether the values of previous/current
* beztriples and new keyframe are the same.
*/
- if (IS_EQF(prevVal, nValue) && IS_EQF(beztVal, nValue) && IS_EQF(prevVal, beztVal))
+ if (IS_EQF(prevVal, nValue) && IS_EQF(beztVal, nValue) && IS_EQF(prevVal, beztVal)) {
return KEYNEEDED_DELNEXT;
- else
+ }
+ else {
return KEYNEEDED_JUSTADD;
+ }
}
}
else {
/* just add a keyframe if there's only one keyframe
* and the new one occurs before the existing one does.
*/
- if ((cFrame < beztPosi) && (totCount == 1))
+ if ((cFrame < beztPosi) && (totCount == 1)) {
return KEYNEEDED_JUSTADD;
+ }
}
/* continue. frame to do not yet passed (or other conditions not met) */
@@ -666,8 +688,9 @@ static short new_key_needed(FCurve *fcu, float cFrame, float nValue)
prev = bezt;
bezt++;
}
- else
+ else {
break;
+ }
}
/* Frame in which to add a new-keyframe occurs after all other keys
@@ -680,15 +703,19 @@ static short new_key_needed(FCurve *fcu, float cFrame, float nValue)
bezt = (fcu->bezt + (fcu->totvert - 1));
valA = bezt->vec[1][1];
- if (prev)
+ if (prev) {
valB = prev->vec[1][1];
- else
+ }
+ else {
valB = bezt->vec[1][1] + 1.0f;
+ }
- if (IS_EQF(valA, nValue) && IS_EQF(valA, valB))
+ if (IS_EQF(valA, nValue) && IS_EQF(valA, valB)) {
return KEYNEEDED_DELPREV;
- else
+ }
+ else {
return KEYNEEDED_JUSTADD;
+ }
}
/* ------------------ RNA Data-Access Functions ------------------ */
@@ -794,8 +821,9 @@ static bool visualkey_can_use(PointerRNA *ptr, PropertyRNA *prop)
const char *identifier = NULL;
/* validate data */
- if (ELEM(NULL, ptr, ptr->data, prop))
+ if (ELEM(NULL, ptr, ptr->data, prop)) {
return false;
+ }
/* get first constraint and determine type of keyframe constraints to check for
* - constraints can be on either Objects or PoseChannels, so we only check if the
@@ -824,8 +852,9 @@ static bool visualkey_can_use(PointerRNA *ptr, PropertyRNA *prop)
}
/* check if any data to search using */
- if (ELEM(NULL, con, identifier) && (has_parent == false) && (has_rigidbody == false))
+ if (ELEM(NULL, con, identifier) && (has_parent == false) && (has_rigidbody == false)) {
return false;
+ }
/* location or rotation identifiers only... */
if (identifier == NULL) {
@@ -849,16 +878,19 @@ static bool visualkey_can_use(PointerRNA *ptr, PropertyRNA *prop)
/* only search if a searchtype and initial constraint are available */
if (searchtype) {
/* parent or rigidbody are always matching */
- if (has_parent || has_rigidbody)
+ if (has_parent || has_rigidbody) {
return true;
+ }
/* constraints */
for (; con; con = con->next) {
/* only consider constraint if it is not disabled, and has influence */
- if (con->flag & CONSTRAINT_DISABLE)
+ if (con->flag & CONSTRAINT_DISABLE) {
continue;
- if (con->enforce == 0.0f)
+ }
+ if (con->enforce == 0.0f) {
continue;
+ }
/* some constraints may alter these transforms */
switch (con->type) {
@@ -876,48 +908,59 @@ static bool visualkey_can_use(PointerRNA *ptr, PropertyRNA *prop)
/* single-transform constraints */
case CONSTRAINT_TYPE_TRACKTO:
- if (searchtype == VISUALKEY_ROT)
+ if (searchtype == VISUALKEY_ROT) {
return true;
+ }
break;
case CONSTRAINT_TYPE_DAMPTRACK:
- if (searchtype == VISUALKEY_ROT)
+ if (searchtype == VISUALKEY_ROT) {
return true;
+ }
break;
case CONSTRAINT_TYPE_ROTLIMIT:
- if (searchtype == VISUALKEY_ROT)
+ if (searchtype == VISUALKEY_ROT) {
return true;
+ }
break;
case CONSTRAINT_TYPE_LOCLIMIT:
- if (searchtype == VISUALKEY_LOC)
+ if (searchtype == VISUALKEY_LOC) {
return true;
+ }
break;
case CONSTRAINT_TYPE_SIZELIMIT:
- if (searchtype == VISUALKEY_SCA)
+ if (searchtype == VISUALKEY_SCA) {
return true;
+ }
break;
case CONSTRAINT_TYPE_DISTLIMIT:
- if (searchtype == VISUALKEY_LOC)
+ if (searchtype == VISUALKEY_LOC) {
return true;
+ }
break;
case CONSTRAINT_TYPE_ROTLIKE:
- if (searchtype == VISUALKEY_ROT)
+ if (searchtype == VISUALKEY_ROT) {
return true;
+ }
break;
case CONSTRAINT_TYPE_LOCLIKE:
- if (searchtype == VISUALKEY_LOC)
+ if (searchtype == VISUALKEY_LOC) {
return true;
+ }
break;
case CONSTRAINT_TYPE_SIZELIKE:
- if (searchtype == VISUALKEY_SCA)
+ if (searchtype == VISUALKEY_SCA) {
return true;
+ }
break;
case CONSTRAINT_TYPE_LOCKTRACK:
- if (searchtype == VISUALKEY_ROT)
+ if (searchtype == VISUALKEY_ROT) {
return true;
+ }
break;
case CONSTRAINT_TYPE_MINMAX:
- if (searchtype == VISUALKEY_LOC)
+ if (searchtype == VISUALKEY_LOC) {
return true;
+ }
break;
default:
@@ -1512,8 +1555,9 @@ static bool delete_keyframe_fcurve(AnimData *adt, FCurve *fcu, float cfra)
/* Only delete curve too if it won't be doing anything anymore */
if ((fcu->totvert == 0) &&
- (list_has_suitable_fmodifier(&fcu->modifiers, 0, FMI_TYPE_GENERATE_CURVE) == 0))
+ (list_has_suitable_fmodifier(&fcu->modifiers, 0, FMI_TYPE_GENERATE_CURVE) == 0)) {
ANIM_fcurve_delete_from_animdata(NULL, adt, fcu);
+ }
/* return success */
return true;
@@ -1598,8 +1642,9 @@ short delete_keyframe(Main *bmain,
* but don't do this for standard arrays since that can cause corruption issues
* (extra unused curves)
*/
- if (array_index_max == array_index)
+ if (array_index_max == array_index) {
array_index_max++;
+ }
}
/* will only loop once unless the array index was -1 */
@@ -1607,8 +1652,9 @@ short delete_keyframe(Main *bmain,
FCurve *fcu = verify_fcurve(bmain, act, group, &ptr, rna_path, array_index, 0);
/* check if F-Curve exists and/or whether it can be edited */
- if (fcu == NULL)
+ if (fcu == NULL) {
continue;
+ }
if (BKE_fcurve_is_protected(fcu)) {
BKE_reportf(reports,
@@ -1698,8 +1744,9 @@ static short clear_keyframe(Main *bmain,
* but don't do this for standard arrays since that can cause corruption issues
* (extra unused curves)
*/
- if (array_index_max == array_index)
+ if (array_index_max == array_index) {
array_index_max++;
+ }
}
/* will only loop once unless the array index was -1 */
@@ -1707,8 +1754,9 @@ static short clear_keyframe(Main *bmain,
FCurve *fcu = verify_fcurve(bmain, act, group, &ptr, rna_path, array_index, 0);
/* check if F-Curve exists and/or whether it can be edited */
- if (fcu == NULL)
+ if (fcu == NULL) {
continue;
+ }
if (BKE_fcurve_is_protected(fcu)) {
BKE_reportf(reports,
@@ -1751,8 +1799,9 @@ static bool modify_key_op_poll(bContext *C)
Scene *scene = CTX_data_scene(C);
/* if no area or active scene */
- if (ELEM(NULL, sa, scene))
+ if (ELEM(NULL, sa, scene)) {
return false;
+ }
/* should be fine */
return true;
@@ -1784,12 +1833,13 @@ static int insert_key_exec(bContext *C, wmOperator *op)
/* try to insert keyframes for the channels specified by KeyingSet */
success = ANIM_apply_keyingset(C, NULL, NULL, ks, MODIFYKEY_MODE_INSERT, cfra);
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
BKE_reportf(op->reports,
RPT_INFO,
"Keying set '%s' - successfully added %d keyframes",
ks->name,
success);
+ }
/* restore the edit mode if necessary */
if (ob_edit_mode) {
@@ -1803,18 +1853,20 @@ static int insert_key_exec(bContext *C, wmOperator *op)
}
else if (success) {
/* if the appropriate properties have been set, make a note that we've inserted something */
- if (RNA_boolean_get(op->ptr, "confirm_success"))
+ if (RNA_boolean_get(op->ptr, "confirm_success")) {
BKE_reportf(op->reports,
RPT_INFO,
"Successfully added %d keyframes for keying set '%s'",
success,
ks->name);
+ }
/* send notifiers that keyframes have been changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_ADDED, NULL);
}
- else
+ else {
BKE_report(op->reports, RPT_WARNING, "Keying set failed to insert any keyframes");
+ }
return OPERATOR_FINISHED;
}
@@ -2006,8 +2058,9 @@ static int delete_key_exec(bContext *C, wmOperator *op)
/* try to delete keyframes for the channels specified by KeyingSet */
success = ANIM_apply_keyingset(C, NULL, NULL, ks, MODIFYKEY_MODE_DELETE, cfra);
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("KeyingSet '%s' - Successfully removed %d Keyframes\n", ks->name, success);
+ }
/* report failure or do updates? */
if (success == MODIFYKEY_INVALID_CONTEXT) {
@@ -2016,18 +2069,20 @@ static int delete_key_exec(bContext *C, wmOperator *op)
}
else if (success) {
/* if the appropriate properties have been set, make a note that we've inserted something */
- if (RNA_boolean_get(op->ptr, "confirm_success"))
+ if (RNA_boolean_get(op->ptr, "confirm_success")) {
BKE_reportf(op->reports,
RPT_INFO,
"Successfully removed %d keyframes for keying set '%s'",
success,
ks->name);
+ }
/* send notifiers that keyframes have been changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_REMOVED, NULL);
}
- else
+ else {
BKE_report(op->reports, RPT_WARNING, "Keying set failed to remove any keyframes");
+ }
return OPERATOR_FINISHED;
}
@@ -2127,13 +2182,15 @@ static int clear_anim_v3d_exec(bContext *C, wmOperator *UNUSED(op))
/* get bone-name, and check if this bone is selected */
bone_name = BLI_str_quoted_substrN(fcu->rna_path, "pose.bones[");
pchan = BKE_pose_channel_find_name(ob->pose, bone_name);
- if (bone_name)
+ if (bone_name) {
MEM_freeN(bone_name);
+ }
/* delete if bone is selected*/
if ((pchan) && (pchan->bone)) {
- if (pchan->bone->flag & BONE_SELECTED)
+ if (pchan->bone->flag & BONE_SELECTED) {
can_delete = true;
+ }
}
}
}
@@ -2220,8 +2277,9 @@ static int delete_key_v3d_exec(bContext *C, wmOperator *op)
/* get bone-name, and check if this bone is selected */
bone_name = BLI_str_quoted_substrN(fcu->rna_path, "pose.bones[");
pchan = BKE_pose_channel_find_name(ob->pose, bone_name);
- if (bone_name)
+ if (bone_name) {
MEM_freeN(bone_name);
+ }
/* skip if bone is not selected */
if ((pchan) && (pchan->bone)) {
@@ -2229,15 +2287,18 @@ static int delete_key_v3d_exec(bContext *C, wmOperator *op)
bArmature *arm = (bArmature *)ob->data;
/* skipping - not visible on currently visible layers */
- if ((arm->layer & pchan->bone->layer) == 0)
+ if ((arm->layer & pchan->bone->layer) == 0) {
continue;
+ }
/* skipping - is currently hidden */
- if (pchan->bone->flag & BONE_HIDDEN_P)
+ if (pchan->bone->flag & BONE_HIDDEN_P) {
continue;
+ }
/* selection flag... */
- if ((pchan->bone->flag & BONE_SELECTED) == 0)
+ if ((pchan->bone->flag & BONE_SELECTED) == 0) {
continue;
+ }
}
}
@@ -2250,14 +2311,16 @@ static int delete_key_v3d_exec(bContext *C, wmOperator *op)
}
/* report success (or failure) */
- if (success)
+ if (success) {
BKE_reportf(op->reports,
RPT_INFO,
"Object '%s' successfully had %d keyframes removed",
id->name + 2,
success);
- else
+ }
+ else {
BKE_reportf(op->reports, RPT_ERROR, "No keyframes removed from Object '%s'", id->name + 2);
+ }
DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM);
}
@@ -2532,8 +2595,9 @@ static int delete_key_button_exec(bContext *C, wmOperator *op)
bmain, op->reports, ptr.id.data, NULL, NULL, path, index, cfra, 0);
MEM_freeN(path);
}
- else if (G.debug & G_DEBUG)
+ else if (G.debug & G_DEBUG) {
printf("Button Delete-Key: no path to property\n");
+ }
}
}
else if (G.debug & G_DEBUG) {
@@ -2599,8 +2663,9 @@ static int clear_key_button_exec(bContext *C, wmOperator *op)
success += clear_keyframe(bmain, op->reports, ptr.id.data, NULL, NULL, path, index, 0);
MEM_freeN(path);
}
- else if (G.debug & G_DEBUG)
+ else if (G.debug & G_DEBUG) {
printf("Button Clear-Key: no path to property\n");
+ }
}
else if (G.debug & G_DEBUG) {
printf("ptr.data = %p, prop = %p\n", (void *)ptr.data, (void *)prop);
@@ -2643,8 +2708,9 @@ bool autokeyframe_cfra_can_key(Scene *scene, ID *id)
float cfra = (float)CFRA; // XXX for now, this will do
/* only filter if auto-key mode requires this */
- if (IS_AUTOKEY_ON(scene) == 0)
+ if (IS_AUTOKEY_ON(scene) == 0) {
return false;
+ }
if (IS_AUTOKEY_MODE(scene, EDITKEYS)) {
/* Replace Mode:
@@ -2675,8 +2741,9 @@ bool autokeyframe_cfra_can_key(Scene *scene, ID *id)
bool fcurve_frame_has_keyframe(FCurve *fcu, float frame, short filter)
{
/* quick sanity check */
- if (ELEM(NULL, fcu, fcu->bezt))
+ if (ELEM(NULL, fcu, fcu->bezt)) {
return false;
+ }
/* we either include all regardless of muting, or only non-muted */
if ((filter & ANIMFILTER_KEYS_MUTED) || (fcu->flag & FCURVE_MUTED) == 0) {
@@ -2688,8 +2755,9 @@ bool fcurve_frame_has_keyframe(FCurve *fcu, float frame, short filter)
*/
if (replace) {
/* sanity check: 'i' may in rare cases exceed arraylen */
- if ((i >= 0) && (i < fcu->totvert))
+ if ((i >= 0) && (i < fcu->totvert)) {
return true;
+ }
}
}
@@ -2727,12 +2795,14 @@ static bool action_frame_has_keyframe(bAction *act, float frame, short filter)
FCurve *fcu;
/* can only find if there is data */
- if (act == NULL)
+ if (act == NULL) {
return false;
+ }
/* if only check non-muted, check if muted */
- if ((filter & ANIMFILTER_KEYS_MUTED) || (act->flag & ACT_MUTED))
+ if ((filter & ANIMFILTER_KEYS_MUTED) || (act->flag & ACT_MUTED)) {
return false;
+ }
/* loop over F-Curves, using binary-search to try to find matches
* - this assumes that keyframes are only beztriples
@@ -2740,8 +2810,9 @@ static bool action_frame_has_keyframe(bAction *act, float frame, short filter)
for (fcu = act->curves.first; fcu; fcu = fcu->next) {
/* only check if there are keyframes (currently only of type BezTriple) */
if (fcu->bezt && fcu->totvert) {
- if (fcurve_frame_has_keyframe(fcu, frame, filter))
+ if (fcurve_frame_has_keyframe(fcu, frame, filter)) {
return true;
+ }
}
}
@@ -2753,8 +2824,9 @@ static bool action_frame_has_keyframe(bAction *act, float frame, short filter)
static bool object_frame_has_keyframe(Object *ob, float frame, short filter)
{
/* error checking */
- if (ob == NULL)
+ if (ob == NULL) {
return false;
+ }
/* check own animation data - specifically, the action it contains */
if ((ob->adt) && (ob->adt->action)) {
@@ -2764,8 +2836,9 @@ static bool object_frame_has_keyframe(Object *ob, float frame, short filter)
*/
float ob_frame = BKE_nla_tweakedit_remap(ob->adt, frame, NLATIME_CONVERT_UNMAP);
- if (action_frame_has_keyframe(ob->adt->action, ob_frame, filter))
+ if (action_frame_has_keyframe(ob->adt->action, ob_frame, filter)) {
return true;
+ }
}
/* try shapekey keyframes (if available, and allowed by filter) */
@@ -2777,8 +2850,9 @@ static bool object_frame_has_keyframe(Object *ob, float frame, short filter)
*/
/* 1. test for relative (with keyframes) */
- if (id_frame_has_keyframe((ID *)key, frame, filter))
+ if (id_frame_has_keyframe((ID *)key, frame, filter)) {
return true;
+ }
/* 2. test for time */
/* TODO... yet to be implemented (this feature may evolve before then anyway) */
@@ -2791,8 +2865,9 @@ static bool object_frame_has_keyframe(Object *ob, float frame, short filter)
Material *ma = give_current_material(ob, (ob->actcol + 1));
/* we only retrieve the active material... */
- if (id_frame_has_keyframe((ID *)ma, frame, filter))
+ if (id_frame_has_keyframe((ID *)ma, frame, filter)) {
return true;
+ }
}
else {
int a;
@@ -2801,8 +2876,9 @@ static bool object_frame_has_keyframe(Object *ob, float frame, short filter)
for (a = 0; a < ob->totcol; a++) {
Material *ma = give_current_material(ob, a + 1);
- if (id_frame_has_keyframe((ID *)ma, frame, filter))
+ if (id_frame_has_keyframe((ID *)ma, frame, filter)) {
return true;
+ }
}
}
}
@@ -2817,8 +2893,9 @@ static bool object_frame_has_keyframe(Object *ob, float frame, short filter)
bool id_frame_has_keyframe(ID *id, float frame, short filter)
{
/* sanity checks */
- if (id == NULL)
+ if (id == NULL) {
return false;
+ }
/* perform special checks for 'macro' types */
switch (GS(id->name)) {
@@ -2834,8 +2911,9 @@ bool id_frame_has_keyframe(ID *id, float frame, short filter)
AnimData *adt = BKE_animdata_from_id(id);
/* only check keyframes in active action */
- if (adt)
+ if (adt) {
return action_frame_has_keyframe(adt->action, frame, filter);
+ }
break;
}
}
diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c
index 90651a55a42..7362a7e04a1 100644
--- a/source/blender/editors/animation/keyingsets.c
+++ b/source/blender/editors/animation/keyingsets.c
@@ -76,8 +76,9 @@ static bool keyingset_poll_active_edit(bContext *C)
{
Scene *scene = CTX_data_scene(C);
- if (scene == NULL)
+ if (scene == NULL) {
return 0;
+ }
/* there must be an active KeyingSet (and KeyingSets) */
return ((scene->active_keyingset > 0) && (scene->keyingsets.first));
@@ -89,12 +90,15 @@ static bool keyingset_poll_activePath_edit(bContext *C)
Scene *scene = CTX_data_scene(C);
KeyingSet *ks;
- if (scene == NULL)
+ if (scene == NULL) {
return 0;
- if (scene->active_keyingset <= 0)
+ }
+ if (scene->active_keyingset <= 0) {
return 0;
- else
+ }
+ else {
ks = BLI_findlink(&scene->keyingsets, scene->active_keyingset - 1);
+ }
/* there must be an active KeyingSet and an active path */
return ((ks) && (ks->paths.first) && (ks->active_path > 0));
@@ -157,8 +161,9 @@ static int remove_active_keyingset_exec(bContext *C, wmOperator *op)
BKE_report(op->reports, RPT_ERROR, "Cannot remove built in keying set");
return OPERATOR_CANCELLED;
}
- else
+ else {
ks = BLI_findlink(&scene->keyingsets, scene->active_keyingset - 1);
+ }
/* free KeyingSet's data, then remove it from the scene */
BKE_keyingset_free(ks);
@@ -201,8 +206,9 @@ static int add_empty_ks_path_exec(bContext *C, wmOperator *op)
BKE_report(op->reports, RPT_ERROR, "No active keying set to add empty path to");
return OPERATOR_CANCELLED;
}
- else
+ else {
ks = BLI_findlink(&scene->keyingsets, scene->active_keyingset - 1);
+ }
/* don't use the API method for this, since that checks on values... */
ksp = MEM_callocN(sizeof(KS_Path), "KeyingSetPath Empty");
@@ -307,8 +313,9 @@ static int add_keyingset_button_exec(bContext *C, wmOperator *op)
keyingflag |= ANIM_get_keyframing_flags(scene, 0);
- if (IS_AUTOKEY_FLAG(scene, XYZ2RGB))
+ if (IS_AUTOKEY_FLAG(scene, XYZ2RGB)) {
keyingflag |= INSERTKEY_XYZ2RGB;
+ }
/* call the API func, and set the active keyingset index */
ks = BKE_keyingset_add(
@@ -531,8 +538,9 @@ ListBase builtin_keyingsets = {NULL, NULL};
KeyingSetInfo *ANIM_keyingset_info_find_name(const char name[])
{
/* sanity checks */
- if ((name == NULL) || (name[0] == 0))
+ if ((name == NULL) || (name[0] == 0)) {
return NULL;
+ }
/* search by comparing names */
return BLI_findstring(&keyingset_type_infos, name, offsetof(KeyingSetInfo, idname));
@@ -544,19 +552,23 @@ KeyingSet *ANIM_builtin_keyingset_get_named(KeyingSet *prevKS, const char name[]
KeyingSet *ks, *first = NULL;
/* sanity checks any name to check? */
- if (name[0] == 0)
+ if (name[0] == 0) {
return NULL;
+ }
/* get first KeyingSet to use */
- if (prevKS && prevKS->next)
+ if (prevKS && prevKS->next) {
first = prevKS->next;
- else
+ }
+ else {
first = builtin_keyingsets.first;
+ }
/* loop over KeyingSets checking names */
for (ks = first; ks; ks = ks->next) {
- if (STREQ(name, ks->idname))
+ if (STREQ(name, ks->idname)) {
return ks;
+ }
}
/* complain about missing keying sets on debug builds */
@@ -609,8 +621,9 @@ void ANIM_keyingset_info_unregister(Main *bmain, KeyingSetInfo *ksi)
BKE_keyingset_free(ks);
BLI_remlink(&builtin_keyingsets, ks);
- for (scene = bmain->scenes.first; scene; scene = scene->id.next)
+ for (scene = bmain->scenes.first; scene; scene = scene->id.next) {
BLI_remlink_safe(&scene->keyingsets, ks);
+ }
MEM_freeN(ks);
}
@@ -631,8 +644,9 @@ void ANIM_keyingset_infos_exit(void)
next = ksi->next;
/* free extra RNA data, and remove from list */
- if (ksi->ext.free)
+ if (ksi->ext.free) {
ksi->ext.free(ksi->ext.data);
+ }
BLI_freelinkN(&keyingset_type_infos, ksi);
}
@@ -644,8 +658,9 @@ void ANIM_keyingset_infos_exit(void)
bool ANIM_keyingset_find_id(KeyingSet *ks, ID *id)
{
/* sanity checks */
- if (ELEM(NULL, ks, id))
+ if (ELEM(NULL, ks, id)) {
return false;
+ }
return BLI_findptr(&ks->paths, id, offsetof(KS_Path, id)) != NULL;
}
@@ -659,18 +674,21 @@ bool ANIM_keyingset_find_id(KeyingSet *ks, ID *id)
KeyingSet *ANIM_scene_get_active_keyingset(Scene *scene)
{
/* if no scene, we've got no hope of finding the Keying Set */
- if (scene == NULL)
+ if (scene == NULL) {
return NULL;
+ }
/* currently, there are several possibilities here:
* - 0: no active keying set
* - > 0: one of the user-defined Keying Sets, but indices start from 0 (hence the -1)
* - < 0: a builtin keying set
*/
- if (scene->active_keyingset > 0)
+ if (scene->active_keyingset > 0) {
return BLI_findlink(&scene->keyingsets, scene->active_keyingset - 1);
- else
+ }
+ else {
return BLI_findlink(&builtin_keyingsets, (-scene->active_keyingset) - 1);
+ }
}
/* Get the index of the Keying Set provided, for the given Scene */
@@ -679,8 +697,9 @@ int ANIM_scene_get_keyingset_index(Scene *scene, KeyingSet *ks)
int index;
/* if no KeyingSet provided, have none */
- if (ks == NULL)
+ if (ks == NULL) {
return 0;
+ }
/* check if the KeyingSet exists in scene list */
if (scene) {
@@ -688,8 +707,9 @@ int ANIM_scene_get_keyingset_index(Scene *scene, KeyingSet *ks)
* - (absolute) Scene KeyingSets are from (>= 1)
*/
index = BLI_findindex(&scene->keyingsets, ks);
- if (index != -1)
+ if (index != -1) {
return (index + 1);
+ }
}
/* still here, so try builtins list too
@@ -697,10 +717,12 @@ int ANIM_scene_get_keyingset_index(Scene *scene, KeyingSet *ks)
* - none/invalid is (= 0)
*/
index = BLI_findindex(&builtin_keyingsets, ks);
- if (index != -1)
+ if (index != -1) {
return -(index + 1);
- else
+ }
+ else {
return 0;
+ }
}
/* Get Keying Set to use for Auto-Keyframing some transforms */
@@ -710,12 +732,15 @@ KeyingSet *ANIM_get_keyingset_for_autokeying(Scene *scene, const char *transform
* - use the active KeyingSet if defined (and user wants to use it for all autokeying),
* or otherwise key transforms only
*/
- if (IS_AUTOKEY_FLAG(scene, ONLYKEYINGSET) && (scene->active_keyingset))
+ if (IS_AUTOKEY_FLAG(scene, ONLYKEYINGSET) && (scene->active_keyingset)) {
return ANIM_scene_get_active_keyingset(scene);
- else if (IS_AUTOKEY_FLAG(scene, INSERTAVAIL))
+ }
+ else if (IS_AUTOKEY_FLAG(scene, INSERTAVAIL)) {
return ANIM_builtin_keyingset_get_named(NULL, ANIM_KS_AVAILABLE_ID);
- else
+ }
+ else {
return ANIM_builtin_keyingset_get_named(NULL, transformKSName);
+ }
}
/* Menu of All Keying Sets ----------------------------- */
@@ -835,8 +860,9 @@ bool ANIM_keyingset_context_ok_poll(bContext *C, KeyingSet *ks)
KeyingSetInfo *ksi = ANIM_keyingset_info_find_name(ks->typeinfo);
/* get the associated 'type info' for this KeyingSet */
- if (ksi == NULL)
+ if (ksi == NULL) {
return 0;
+ }
/* TODO: check for missing callbacks! */
/* check if it can be used in the current context */
@@ -883,20 +909,24 @@ void ANIM_relative_keyingset_add_source(ListBase *dsources, ID *id, StructRNA *s
* - we must have somewhere to output the data
* - we must have both srna+data (and with id too optionally), or id by itself only
*/
- if (dsources == NULL)
+ if (dsources == NULL) {
return;
- if (ELEM(NULL, srna, data) && (id == NULL))
+ }
+ if (ELEM(NULL, srna, data) && (id == NULL)) {
return;
+ }
/* allocate new elem, and add to the list */
ds = MEM_callocN(sizeof(tRKS_DSource), "tRKS_DSource");
BLI_addtail(dsources, ds);
/* depending on what data we have, create using ID or full pointer call */
- if (srna && data)
+ if (srna && data) {
RNA_pointer_create(id, srna, data, &ds->ptr);
- else
+ }
+ else {
RNA_id_pointer_create(id, &ds->ptr);
+ }
}
/* KeyingSet Operations (Insert/Delete Keyframes) ------------ */
@@ -911,8 +941,9 @@ void ANIM_relative_keyingset_add_source(ListBase *dsources, ID *id, StructRNA *s
short ANIM_validate_keyingset(bContext *C, ListBase *dsources, KeyingSet *ks)
{
/* sanity check */
- if (ks == NULL)
+ if (ks == NULL) {
return 0;
+ }
/* if relative Keying Sets, poll and build up the paths */
if ((ks->flag & KEYINGSET_ABSOLUTE) == 0) {
@@ -924,8 +955,9 @@ short ANIM_validate_keyingset(bContext *C, ListBase *dsources, KeyingSet *ks)
BKE_keyingset_free(ks);
/* get the associated 'type info' for this KeyingSet */
- if (ksi == NULL)
+ if (ksi == NULL) {
return MODIFYKEY_MISSING_TYPEINFO;
+ }
/* TODO: check for missing callbacks! */
/* check if it can be used in the current context */
@@ -933,15 +965,18 @@ short ANIM_validate_keyingset(bContext *C, ListBase *dsources, KeyingSet *ks)
/* if a list of data sources are provided, run a special iterator over them,
* otherwise, just continue per normal
*/
- if (dsources)
+ if (dsources) {
RKS_ITER_overrides_list(ksi, C, ks, dsources);
- else
+ }
+ else {
ksi->iter(ksi, C, ks);
+ }
/* if we don't have any paths now, then this still qualifies as invalid context */
// FIXME: we need some error conditions (to be retrieved from the iterator why this failed!)
- if (BLI_listbase_is_empty(&ks->paths))
+ if (BLI_listbase_is_empty(&ks->paths)) {
return MODIFYKEY_INVALID_CONTEXT;
+ }
}
else {
/* poll callback tells us that KeyingSet is useless in current context */
@@ -1005,16 +1040,18 @@ int ANIM_apply_keyingset(
char keytype = scene->toolsettings->keyframe_type;
/* sanity checks */
- if (ks == NULL)
+ if (ks == NULL) {
return 0;
+ }
/* get flags to use */
if (mode == MODIFYKEY_MODE_INSERT) {
/* use context settings as base */
kflag = keyingset_apply_keying_flags(base_kflags, ks->keyingoverride, ks->keyingflag);
}
- else if (mode == MODIFYKEY_MODE_DELETE)
+ else if (mode == MODIFYKEY_MODE_DELETE) {
kflag = 0;
+ }
/* if relative Keying Sets, poll and build up the paths */
success = ANIM_validate_keyingset(C, dsources, ks);
@@ -1045,12 +1082,15 @@ int ANIM_apply_keyingset(
kflag2 = keyingset_apply_keying_flags(kflag, ksp->keyingoverride, ksp->keyingflag);
/* get pointer to name of group to add channels to */
- if (ksp->groupmode == KSP_GROUP_NONE)
+ if (ksp->groupmode == KSP_GROUP_NONE) {
groupname = NULL;
- else if (ksp->groupmode == KSP_GROUP_KSNAME)
+ }
+ else if (ksp->groupmode == KSP_GROUP_KSNAME) {
groupname = ks->name;
- else
+ }
+ else {
groupname = ksp->group;
+ }
/* init arraylen and i - arraylen should be greater than i so that
* normal non-array entries get keyframed correctly
@@ -1072,15 +1112,16 @@ int ANIM_apply_keyingset(
}
/* we should do at least one step */
- if (arraylen == i)
+ if (arraylen == i) {
arraylen++;
+ }
/* for each possible index, perform operation
* - assume that arraylen is greater than index
*/
for (; i < arraylen; i++) {
/* action to take depends on mode */
- if (mode == MODIFYKEY_MODE_INSERT)
+ if (mode == MODIFYKEY_MODE_INSERT) {
success += insert_keyframe(bmain,
depsgraph,
reports,
@@ -1093,9 +1134,11 @@ int ANIM_apply_keyingset(
keytype,
&nla_cache,
kflag2);
- else if (mode == MODIFYKEY_MODE_DELETE)
+ }
+ else if (mode == MODIFYKEY_MODE_DELETE) {
success += delete_keyframe(
bmain, reports, ksp->id, act, groupname, ksp->rna_path, i, cfra, kflag2);
+ }
}
/* set recalc-flags */
diff --git a/source/blender/editors/armature/armature_add.c b/source/blender/editors/armature/armature_add.c
index 40526eb82fe..3b65f3a71ed 100644
--- a/source/blender/editors/armature/armature_add.c
+++ b/source/blender/editors/armature/armature_add.c
@@ -137,20 +137,23 @@ static int armature_click_extrude_exec(bContext *C, wmOperator *UNUSED(op))
/* find the active or selected bone */
for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
if (EBONE_VISIBLE(arm, ebone)) {
- if (ebone->flag & BONE_TIPSEL || arm->act_edbone == ebone)
+ if (ebone->flag & BONE_TIPSEL || arm->act_edbone == ebone) {
break;
+ }
}
}
if (ebone == NULL) {
for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
if (EBONE_VISIBLE(arm, ebone)) {
- if (ebone->flag & BONE_ROOTSEL || arm->act_edbone == ebone)
+ if (ebone->flag & BONE_ROOTSEL || arm->act_edbone == ebone) {
break;
+ }
}
}
- if (ebone == NULL)
+ if (ebone == NULL) {
return OPERATOR_CANCELLED;
+ }
to_root = 1;
}
@@ -159,13 +162,15 @@ static int armature_click_extrude_exec(bContext *C, wmOperator *UNUSED(op))
/* we re-use code for mirror editing... */
flipbone = NULL;
- if (arm->flag & ARM_MIRROR_EDIT)
+ if (arm->flag & ARM_MIRROR_EDIT) {
flipbone = ED_armature_ebone_get_mirrored(arm->edbo, ebone);
+ }
for (a = 0; a < 2; a++) {
if (a == 1) {
- if (flipbone == NULL)
+ if (flipbone == NULL) {
break;
+ }
else {
SWAP(EditBone *, flipbone, ebone);
}
@@ -190,8 +195,9 @@ static int armature_click_extrude_exec(bContext *C, wmOperator *UNUSED(op))
copy_v3_v3(newbone->tail, curs->location);
sub_v3_v3v3(newbone->tail, newbone->tail, obedit->obmat[3]);
- if (a == 1)
+ if (a == 1) {
newbone->tail[0] = -newbone->tail[0];
+ }
copy_m3_m4(mat, obedit->obmat);
invert_m3_m3(imat, mat);
@@ -279,8 +285,9 @@ static EditBone *get_named_editbone(ListBase *edbo, const char *name)
if (name) {
for (eBone = edbo->first; eBone; eBone = eBone->next) {
- if (STREQ(name, eBone->name))
+ if (STREQ(name, eBone->name)) {
return eBone;
+ }
}
}
@@ -410,8 +417,9 @@ void updateDuplicateSubtargetObjects(EditBone *dupBone,
}
}
- if (cti->flush_constraint_targets)
+ if (cti->flush_constraint_targets) {
cti->flush_constraint_targets(curcon, &targets, 0);
+ }
}
}
}
@@ -442,8 +450,9 @@ EditBone *duplicateEditBoneObjects(
BLI_addtail(editbones, eBone);
/* copy the ID property */
- if (curBone->prop)
+ if (curBone->prop) {
eBone->prop = IDP_CopyProperty(curBone->prop);
+ }
/* Lets duplicate the list of constraints that the
* current bone has.
@@ -478,8 +487,9 @@ static int armature_duplicate_selected_exec(bContext *C, wmOperator *op)
const bool do_flip_names = RNA_boolean_get(op->ptr, "do_flip_names");
/* cancel if nothing selected */
- if (CTX_DATA_COUNT(C, selected_bones) == 0)
+ if (CTX_DATA_COUNT(C, selected_bones) == 0) {
return OPERATOR_CANCELLED;
+ }
uint objects_len = 0;
Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(
@@ -888,8 +898,9 @@ static int armature_extrude_exec(bContext *C, wmOperator *op)
if (EBONE_VISIBLE(arm, ebone)) {
if (ebone->flag & BONE_ROOTSEL) {
if (ebone->parent && (ebone->flag & BONE_CONNECTED)) {
- if (ebone->parent->flag & BONE_TIPSEL)
+ if (ebone->parent->flag & BONE_TIPSEL) {
ebone->flag &= ~BONE_ROOTSEL;
+ }
}
}
}
@@ -920,18 +931,21 @@ static int armature_extrude_exec(bContext *C, wmOperator *op)
flipbone = ED_armature_ebone_get_mirrored(arm->edbo, ebone);
if (flipbone) {
forked_iter = 0; // we extrude 2 different bones
- if (flipbone->flag & (BONE_TIPSEL | BONE_ROOTSEL | BONE_SELECTED))
+ if (flipbone->flag & (BONE_TIPSEL | BONE_ROOTSEL | BONE_SELECTED)) {
/* don't want this bone to be selected... */
flipbone->flag &= ~(BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL);
+ }
}
- if ((flipbone == NULL) && (forked_iter))
+ if ((flipbone == NULL) && (forked_iter)) {
flipbone = ebone;
+ }
}
for (a = 0; a < 2; a++) {
if (a == 1) {
- if (flipbone == NULL)
+ if (flipbone == NULL) {
break;
+ }
else {
SWAP(EditBone *, flipbone, ebone);
}
@@ -948,8 +962,9 @@ static int armature_extrude_exec(bContext *C, wmOperator *op)
/* copies it, in case mirrored bone */
newbone->flag = ebone->flag & (BONE_TIPSEL | BONE_RELATIVE_PARENTING);
- if (newbone->parent)
+ if (newbone->parent) {
newbone->flag |= BONE_CONNECTED;
+ }
}
else {
copy_v3_v3(newbone->head, ebone->head);
@@ -988,22 +1003,26 @@ static int armature_extrude_exec(bContext *C, wmOperator *op)
if (flipbone && forked_iter) { // only set if mirror edit
if (strlen(newbone->name) < (MAXBONENAME - 2)) {
- if (a == 0)
+ if (a == 0) {
strcat(newbone->name, "_L");
- else
+ }
+ else {
strcat(newbone->name, "_R");
+ }
}
}
ED_armature_ebone_unique_name(arm->edbo, newbone->name, NULL);
/* Add the new bone to the list */
BLI_addtail(arm->edbo, newbone);
- if (!first)
+ if (!first) {
first = newbone;
+ }
/* restore ebone if we were flipping */
- if (a == 1 && flipbone)
+ if (a == 1 && flipbone) {
SWAP(EditBone *, flipbone, ebone);
+ }
}
}
@@ -1073,10 +1092,12 @@ static int armature_bone_primitive_add_exec(bContext *C, wmOperator *op)
invert_m4_m4(obedit->imat, obedit->obmat);
mul_m4_v3(obedit->imat, curs);
- if (rv3d && (U.flag & USER_ADD_VIEWALIGNED))
+ if (rv3d && (U.flag & USER_ADD_VIEWALIGNED)) {
copy_m3_m4(obmat, rv3d->viewmat);
- else
+ }
+ else {
unit_m3(obmat);
+ }
copy_m3_m4(viewmat, obedit->obmat);
mul_m3_m3m3(totmat, obmat, viewmat);
@@ -1089,10 +1110,12 @@ static int armature_bone_primitive_add_exec(bContext *C, wmOperator *op)
copy_v3_v3(bone->head, curs);
- if (rv3d && (U.flag & USER_ADD_VIEWALIGNED))
+ if (rv3d && (U.flag & USER_ADD_VIEWALIGNED)) {
add_v3_v3v3(bone->tail, bone->head, imat[1]); // bone with unit length 1
- else
+ }
+ else {
add_v3_v3v3(bone->tail, bone->head, imat[2]); // bone with unit length 1, pointing up Z
+ }
/* note, notifier might evolve */
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit);
@@ -1174,8 +1197,9 @@ static int armature_subdivide_exec(bContext *C, wmOperator *op)
/* correct parent bones */
for (tbone = arm->edbo->first; tbone; tbone = tbone->next) {
- if (tbone->parent == ebone)
+ if (tbone->parent == ebone) {
tbone->parent = newbone;
+ }
}
newbone->parent = ebone;
}
diff --git a/source/blender/editors/armature/armature_edit.c b/source/blender/editors/armature/armature_edit.c
index ad563e569c3..c5430e06b6e 100644
--- a/source/blender/editors/armature/armature_edit.c
+++ b/source/blender/editors/armature/armature_edit.c
@@ -334,8 +334,9 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op)
if (EBONE_VISIBLE(arm, ebone) && EBONE_EDITABLE(ebone)) {
float cursor_rel[3];
sub_v3_v3v3(cursor_rel, cursor_local, ebone->head);
- if (axis_flip)
+ if (axis_flip) {
negate_v3(cursor_rel);
+ }
if (normalize_v3(cursor_rel) != 0.0f) {
ebone->roll = ED_armature_ebone_roll_to_vector(ebone, cursor_rel, axis_only);
changed = true;
@@ -375,8 +376,9 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op)
(ebone_other = ebone_other->parent));
if (!is_vec_zero) {
- if (axis_flip)
+ if (axis_flip) {
negate_v3(vec);
+ }
if (is_edit) {
ebone->roll = ED_armature_ebone_roll_to_vector(ebone, vec, axis_only);
@@ -424,16 +426,19 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op)
}
else { /* Axis */
assert(type <= 5);
- if (type < 3)
+ if (type < 3) {
vec[type] = 1.0f;
- else
+ }
+ else {
vec[type - 2] = -1.0f;
+ }
mul_m3_v3(imat, vec);
normalize_v3(vec);
}
- if (axis_flip)
+ if (axis_flip) {
negate_v3(vec);
+ }
for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
if (EBONE_VISIBLE(arm, ebone) && EBONE_EDITABLE(ebone)) {
@@ -591,12 +596,14 @@ static void chains_find_tips(ListBase *edbo, ListBase *list)
}
}
- if (stop)
+ if (stop) {
break;
+ }
}
/* skip current bone if it is part of an existing chain */
- if (stop)
+ if (stop) {
continue;
+ }
/* is any existing chain part of the chain formed by this bone? */
stop = 0;
@@ -609,12 +616,14 @@ static void chains_find_tips(ListBase *edbo, ListBase *list)
}
}
- if (stop)
+ if (stop) {
break;
+ }
}
/* current bone has already been added to a chain? */
- if (stop)
+ if (stop) {
continue;
+ }
/* add current bone to a new chain */
ld = MEM_callocN(sizeof(LinkData), "BoneChain");
@@ -817,17 +826,21 @@ static int armature_fill_bones_exec(bContext *C, wmOperator *op)
/* do parenting (will need to set connected flag too) */
if (headtail == 2) {
/* ebp tail or head - tail gets priority */
- if (ebp_a->tail_owner)
+ if (ebp_a->tail_owner) {
newbone->parent = ebp_a->tail_owner;
- else
+ }
+ else {
newbone->parent = ebp_a->head_owner;
+ }
}
else {
/* ebp_b tail or head - tail gets priority */
- if (ebp_b->tail_owner)
+ if (ebp_b->tail_owner) {
newbone->parent = ebp_b->tail_owner;
- else
+ }
+ else {
newbone->parent = ebp_b->head_owner;
+ }
}
/* don't set for bone connecting two head points of bones */
@@ -940,14 +953,16 @@ static void bones_merge(
}
/* carry on to the next tip now */
- if (found)
+ if (found) {
break;
+ }
}
}
/* step 2b: parent child of end to newbone (child from this chain) */
- if (endchild)
+ if (endchild) {
endchild->parent = newbone;
+ }
/* step 3: delete all bones between and including start and end */
for (ebo = end; ebo; ebo = ebone) {
@@ -1006,13 +1021,15 @@ static int armature_merge_exec(bContext *C, wmOperator *op)
bend = ebo;
bchild = child;
}
- else
+ else {
bstart = ebo;
+ }
}
else {
/* chain is broken... merge any continuous segments then clear */
- if (bstart && bend)
+ if (bstart && bend) {
bones_merge(obedit, bstart, bend, bchild, &chains);
+ }
bstart = NULL;
bend = NULL;
@@ -1021,8 +1038,9 @@ static int armature_merge_exec(bContext *C, wmOperator *op)
}
/* merge from bstart to bend if something not merged */
- if (bstart && bend)
+ if (bstart && bend) {
bones_merge(obedit, bstart, bend, bchild, &chains);
+ }
/* put back link */
BLI_insertlinkbefore(&chains, nchain, chain);
@@ -1137,10 +1155,12 @@ static int armature_switch_direction_exec(bContext *C, wmOperator *UNUSED(op))
* - connected flag is only set if points are coincidental
*/
ebo->parent = child;
- if ((child) && equals_v3v3(ebo->head, child->tail))
+ if ((child) && equals_v3v3(ebo->head, child->tail)) {
ebo->flag |= BONE_CONNECTED;
- else
+ }
+ else {
ebo->flag &= ~BONE_CONNECTED;
+ }
/* get next bones
* - child will become the new parent of next bone
@@ -1207,8 +1227,9 @@ static void fix_connected_bone(EditBone *ebone)
float diff[3];
if (!(ebone->parent) || !(ebone->flag & BONE_CONNECTED) ||
- equals_v3v3(ebone->parent->tail, ebone->head))
+ equals_v3v3(ebone->parent->tail, ebone->head)) {
return;
+ }
/* if the parent has moved we translate child's head and tail accordingly */
sub_v3_v3v3(diff, ebone->parent->tail, ebone->head);
@@ -1271,8 +1292,9 @@ static int armature_align_bones_exec(bContext *C, wmOperator *op)
* then just use actbone. Useful when doing upper arm to spine.
*/
actmirb = ED_armature_ebone_get_mirrored(arm->edbo, actbone);
- if (actmirb == NULL)
+ if (actmirb == NULL) {
actmirb = actbone;
+ }
}
/* if there is only 1 selected bone, we assume that that is the active bone,
@@ -1286,8 +1308,9 @@ static int armature_align_bones_exec(bContext *C, wmOperator *op)
if (actbone->parent) {
bone_align_to_bone(arm->edbo, actbone, actbone->parent);
- if ((arm->flag & ARM_MIRROR_EDIT) && (actmirb->parent))
+ if ((arm->flag & ARM_MIRROR_EDIT) && (actmirb->parent)) {
bone_align_to_bone(arm->edbo, actmirb, actmirb->parent);
+ }
BKE_reportf(op->reports, RPT_INFO, "Aligned bone '%s' to parent", actbone->name);
}
@@ -1304,10 +1327,12 @@ static int armature_align_bones_exec(bContext *C, wmOperator *op)
/* align selected bones to the active one */
CTX_DATA_BEGIN (C, EditBone *, ebone, selected_editable_bones) {
if (ELEM(ebone, actbone, actmirb) == 0) {
- if (ebone->flag & BONE_SELECTED)
+ if (ebone->flag & BONE_SELECTED) {
bone_align_to_bone(arm->edbo, ebone, actbone);
- else
+ }
+ else {
bone_align_to_bone(arm->edbo, ebone, actmirb);
+ }
}
}
CTX_DATA_END;
@@ -1401,8 +1426,9 @@ static int armature_delete_selected_exec(bContext *C, wmOperator *UNUSED(op))
bool changed_multi = false;
/* cancel if nothing selected */
- if (CTX_DATA_COUNT(C, selected_bones) == 0)
+ if (CTX_DATA_COUNT(C, selected_bones) == 0) {
return OPERATOR_CANCELLED;
+ }
ViewLayer *view_layer = CTX_data_view_layer(C);
uint objects_len = 0;
@@ -1421,8 +1447,9 @@ static int armature_delete_selected_exec(bContext *C, wmOperator *UNUSED(op))
ebone_next = curBone->next;
if (arm->layer & curBone->layer) {
if (curBone->flag & BONE_SELECTED) {
- if (curBone == arm->act_edbone)
+ if (curBone == arm->act_edbone) {
arm->act_edbone = NULL;
+ }
ED_armature_ebone_remove(arm, curBone);
changed = true;
}
@@ -1643,8 +1670,9 @@ static int armature_hide_exec(bContext *C, wmOperator *op)
const int invert = RNA_boolean_get(op->ptr, "unselected") ? BONE_SELECTED : 0;
/* cancel if nothing selected */
- if (CTX_DATA_COUNT(C, selected_bones) == 0)
+ if (CTX_DATA_COUNT(C, selected_bones) == 0) {
return OPERATOR_CANCELLED;
+ }
uint objects_len = 0;
Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(
diff --git a/source/blender/editors/armature/armature_naming.c b/source/blender/editors/armature/armature_naming.c
index 6bf289c1b95..6d25fac79f6 100644
--- a/source/blender/editors/armature/armature_naming.c
+++ b/source/blender/editors/armature/armature_naming.c
@@ -130,8 +130,9 @@ static void constraint_bone_name_fix(Object *ob,
}
}
- if (cti->flush_constraint_targets)
+ if (cti->flush_constraint_targets) {
cti->flush_constraint_targets(curcon, &targets, 0);
+ }
}
/* action constraints */
@@ -221,8 +222,9 @@ void ED_armature_bone_rename(Main *bmain,
/* Update any object constraints to use the new bone name */
for (cob = bmain->objects.first; cob; cob = cob->id.next) {
- if (cob->constraints.first)
+ if (cob->constraints.first) {
constraint_bone_name_fix(ob, &cob->constraints, oldname, newname);
+ }
if (cob->pose) {
bPoseChannel *pchan;
for (pchan = cob->pose->chanbase.first; pchan; pchan = pchan->next) {
@@ -236,8 +238,9 @@ void ED_armature_bone_rename(Main *bmain,
if (ob->parent && (ob->parent->data == arm)) {
if (ob->partype == PARBONE) {
/* bone name in object */
- if (STREQ(ob->parsubstr, oldname))
+ if (STREQ(ob->parsubstr, oldname)) {
BLI_strncpy(ob->parsubstr, newname, MAXBONENAME);
+ }
}
}
@@ -255,8 +258,9 @@ void ED_armature_bone_rename(Main *bmain,
HookModifierData *hmd = (HookModifierData *)md;
if (hmd->object && (hmd->object->data == arm)) {
- if (STREQ(hmd->subtarget, oldname))
+ if (STREQ(hmd->subtarget, oldname)) {
BLI_strncpy(hmd->subtarget, newname, MAXBONENAME);
+ }
}
break;
}
@@ -264,12 +268,14 @@ void ED_armature_bone_rename(Main *bmain,
UVWarpModifierData *umd = (UVWarpModifierData *)md;
if (umd->object_src && (umd->object_src->data == arm)) {
- if (STREQ(umd->bone_src, oldname))
+ if (STREQ(umd->bone_src, oldname)) {
BLI_strncpy(umd->bone_src, newname, MAXBONENAME);
+ }
}
if (umd->object_dst && (umd->object_dst->data == arm)) {
- if (STREQ(umd->bone_dst, oldname))
+ if (STREQ(umd->bone_dst, oldname)) {
BLI_strncpy(umd->bone_dst, newname, MAXBONENAME);
+ }
}
break;
}
@@ -284,8 +290,9 @@ void ED_armature_bone_rename(Main *bmain,
bGPdata *gpd = (bGPdata *)ob->data;
for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
if ((gpl->parent != NULL) && (gpl->parent->data == arm)) {
- if (STREQ(gpl->parsubstr, oldname))
+ if (STREQ(gpl->parsubstr, oldname)) {
BLI_strncpy(gpl->parsubstr, newname, MAXBONENAME);
+ }
}
}
@@ -305,8 +312,9 @@ void ED_armature_bone_rename(Main *bmain,
case eGpencilModifierType_Hook: {
HookGpencilModifierData *hgp_md = (HookGpencilModifierData *)gp_md;
if (hgp_md->object && (hgp_md->object->data == arm)) {
- if (STREQ(hgp_md->subtarget, oldname))
+ if (STREQ(hgp_md->subtarget, oldname)) {
BLI_strncpy(hgp_md->subtarget, newname, MAXBONENAME);
+ }
}
break;
}
diff --git a/source/blender/editors/armature/armature_relations.c b/source/blender/editors/armature/armature_relations.c
index 5d193c56c06..037703c50bf 100644
--- a/source/blender/editors/armature/armature_relations.c
+++ b/source/blender/editors/armature/armature_relations.c
@@ -92,8 +92,9 @@ static void joined_armature_fix_links_constraints(
}
}
- if (cti->flush_constraint_targets)
+ if (cti->flush_constraint_targets) {
cti->flush_constraint_targets(con, &targets, 0);
+ }
}
/* action constraint? (pose constraints only) */
@@ -248,10 +249,12 @@ int join_armature_exec(bContext *C, wmOperator *op)
bool ok = false;
/* Ensure we're not in editmode and that the active object is an armature*/
- if (!ob_active || ob_active->type != OB_ARMATURE)
+ if (!ob_active || ob_active->type != OB_ARMATURE) {
return OPERATOR_CANCELLED;
- if (!arm || arm->edbo)
+ }
+ if (!arm || arm->edbo) {
return OPERATOR_CANCELLED;
+ }
CTX_DATA_BEGIN (C, Object *, ob_iter, selected_editable_objects) {
if (ob_iter == ob_active) {
@@ -696,8 +699,9 @@ static void bone_connect_to_new_parent(ListBase *edbo,
EditBone *ebone;
float offset[3];
- if ((selbone->parent) && (selbone->flag & BONE_CONNECTED))
+ if ((selbone->parent) && (selbone->flag & BONE_CONNECTED)) {
selbone->parent->flag &= ~(BONE_TIPSEL);
+ }
/* make actbone the parent of selbone */
selbone->parent = actbone;
@@ -767,8 +771,9 @@ static int armature_parent_set_exec(bContext *C, wmOperator *op)
* then just use actbone. Useful when doing upper arm to spine.
*/
actmirb = ED_armature_ebone_get_mirrored(arm->edbo, actbone);
- if (actmirb == NULL)
+ if (actmirb == NULL) {
actmirb = actbone;
+ }
}
/* if there is only 1 selected bone, we assume that that is the active bone,
@@ -781,8 +786,9 @@ static int armature_parent_set_exec(bContext *C, wmOperator *op)
if (actbone->parent) {
bone_connect_to_existing_parent(actbone);
- if ((arm->flag & ARM_MIRROR_EDIT) && (actmirb->parent))
+ if ((arm->flag & ARM_MIRROR_EDIT) && (actmirb->parent)) {
bone_connect_to_existing_parent(actmirb);
+ }
}
}
else {
@@ -797,10 +803,12 @@ static int armature_parent_set_exec(bContext *C, wmOperator *op)
/* parent selected bones to the active one */
CTX_DATA_BEGIN (C, EditBone *, ebone, selected_editable_bones) {
if (ELEM(ebone, actbone, actmirb) == 0) {
- if (ebone->flag & BONE_SELECTED)
+ if (ebone->flag & BONE_SELECTED) {
bone_connect_to_new_parent(arm->edbo, ebone, actbone, val);
- else
+ }
+ else {
bone_connect_to_new_parent(arm->edbo, ebone, actmirb, val);
+ }
}
}
CTX_DATA_END;
@@ -824,8 +832,9 @@ static int armature_parent_set_invoke(bContext *C,
CTX_DATA_BEGIN (C, EditBone *, ebone, selected_editable_bones) {
if (ebone != actbone) {
- if (ebone->parent != actbone)
+ if (ebone->parent != actbone) {
allchildbones = 1;
+ }
}
}
CTX_DATA_END;
@@ -833,8 +842,9 @@ static int armature_parent_set_invoke(bContext *C,
uiItemEnumO(layout, "ARMATURE_OT_parent_set", NULL, 0, "type", ARM_PAR_CONNECT);
/* ob becomes parent, make the associated menus */
- if (allchildbones)
+ if (allchildbones) {
uiItemEnumO(layout, "ARMATURE_OT_parent_set", NULL, 0, "type", ARM_PAR_OFFSET);
+ }
UI_popup_menu_end(C, pup);
@@ -873,8 +883,9 @@ static void editbone_clear_parent(EditBone *ebone, int mode)
ebone->parent->flag &= ~(BONE_TIPSEL);
}
- if (mode == 1)
+ if (mode == 1) {
ebone->parent = NULL;
+ }
ebone->flag &= ~BONE_CONNECTED;
}
diff --git a/source/blender/editors/armature/armature_select.c b/source/blender/editors/armature/armature_select.c
index 0c493672d9e..95c10b79678 100644
--- a/source/blender/editors/armature/armature_select.c
+++ b/source/blender/editors/armature/armature_select.c
@@ -167,10 +167,12 @@ void *get_bone_from_selectbuffer(Base **bases,
if (is_editmode == false) {
base = ED_armature_base_and_bone_from_select_buffer(bases, bases_len, hitresult, &bone);
if (bone != NULL) {
- if (findunsel)
+ if (findunsel) {
sel = (bone->flag & BONE_SELECTED);
- else
+ }
+ else {
sel = !(bone->flag & BONE_SELECTED);
+ }
data = bone;
}
@@ -182,10 +184,12 @@ void *get_bone_from_selectbuffer(Base **bases,
else {
base = ED_armature_base_and_ebone_from_select_buffer(
bases, bases_len, hitresult, &ebone);
- if (findunsel)
+ if (findunsel) {
sel = (ebone->flag & BONE_SELECTED);
- else
+ }
+ else {
sel = !(ebone->flag & BONE_SELECTED);
+ }
data = ebone;
}
@@ -300,8 +304,9 @@ static int armature_select_linked_invoke(bContext *C, wmOperator *op, const wmEv
Base *base = NULL;
bone = get_nearest_bone(C, event->mval, true, &base);
- if (!bone)
+ if (!bone) {
return OPERATOR_CANCELLED;
+ }
arm = base->object->data;
@@ -316,10 +321,12 @@ static int armature_select_linked_invoke(bContext *C, wmOperator *op, const wmEv
}
}
- if (curBone->flag & BONE_CONNECTED)
+ if (curBone->flag & BONE_CONNECTED) {
next = curBone->parent;
- else
+ }
+ else {
next = NULL;
+ }
}
/* Select children */
@@ -343,8 +350,9 @@ static int armature_select_linked_invoke(bContext *C, wmOperator *op, const wmEv
}
}
}
- if (!curBone)
+ if (!curBone) {
bone = NULL;
+ }
}
ED_armature_edit_sync_selection(arm->edbo);
@@ -515,12 +523,15 @@ cache_end:
if (hitresult & (BONESEL_ROOT | BONESEL_TIP)) {
/* but also the unselected one */
if (findunsel) {
- if ((hitresult & BONESEL_ROOT) && (ebone->flag & BONE_ROOTSEL) == 0)
+ if ((hitresult & BONESEL_ROOT) && (ebone->flag & BONE_ROOTSEL) == 0) {
dep = 1;
- else if ((hitresult & BONESEL_TIP) && (ebone->flag & BONE_TIPSEL) == 0)
+ }
+ else if ((hitresult & BONESEL_TIP) && (ebone->flag & BONE_TIPSEL) == 0) {
dep = 1;
- else
+ }
+ else {
dep = 2;
+ }
}
else {
dep = 1;
@@ -529,10 +540,12 @@ cache_end:
else {
/* bone found */
if (findunsel) {
- if ((ebone->flag & BONE_SELECTED) == 0)
+ if ((ebone->flag & BONE_SELECTED) == 0) {
dep = 3;
- else
+ }
+ else {
dep = 4;
+ }
}
else {
dep = 3;
@@ -698,8 +711,9 @@ bool ED_armature_edit_select_pick(
/* deselect this bone */
nearBone->flag &= ~(BONE_TIPSEL | BONE_SELECTED);
/* only deselect parent tip if it is not selected */
- if (!(nearBone->parent->flag & BONE_SELECTED))
+ if (!(nearBone->parent->flag & BONE_SELECTED)) {
nearBone->parent->flag &= ~BONE_TIPSEL;
+ }
}
else if (toggle) {
/* hold shift inverts this bone's selection */
@@ -707,8 +721,9 @@ bool ED_armature_edit_select_pick(
/* deselect this bone */
nearBone->flag &= ~(BONE_TIPSEL | BONE_SELECTED);
/* only deselect parent tip if it is not selected */
- if (!(nearBone->parent->flag & BONE_SELECTED))
+ if (!(nearBone->parent->flag & BONE_SELECTED)) {
nearBone->parent->flag &= ~BONE_TIPSEL;
+ }
}
else {
/* select this bone */
@@ -731,24 +746,31 @@ bool ED_armature_edit_select_pick(
}
else if (toggle) {
/* hold shift inverts this bone's selection */
- if (nearBone->flag & BONE_SELECTED)
+ if (nearBone->flag & BONE_SELECTED) {
nearBone->flag &= ~(BONE_TIPSEL | BONE_ROOTSEL);
- else
+ }
+ else {
nearBone->flag |= (BONE_TIPSEL | BONE_ROOTSEL);
+ }
}
- else
+ else {
nearBone->flag |= (BONE_TIPSEL | BONE_ROOTSEL);
+ }
}
}
else {
- if (extend)
+ if (extend) {
nearBone->flag |= selmask;
- else if (deselect)
+ }
+ else if (deselect) {
nearBone->flag &= ~selmask;
- else if (toggle && (nearBone->flag & selmask))
+ }
+ else if (toggle && (nearBone->flag & selmask)) {
nearBone->flag &= ~selmask;
- else
+ }
+ else {
nearBone->flag |= selmask;
+ }
}
ED_armature_edit_sync_selection(arm->edbo);
@@ -1373,8 +1395,9 @@ static void select_similar_suffix(bContext *C)
BLI_string_split_suffix(ebone_act->name, body_tmp, suffix_act, sizeof(ebone_act->name));
- if (suffix_act[0] == '\0')
+ if (suffix_act[0] == '\0') {
return;
+ }
uint objects_len = 0;
Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(
@@ -1429,11 +1452,13 @@ static void select_similar_data_pchan(bContext *C, const size_t bytes_size, cons
static void is_ancestor(EditBone *bone, EditBone *ancestor)
{
- if (bone->temp.ebone == ancestor || bone->temp.ebone == NULL)
+ if (bone->temp.ebone == ancestor || bone->temp.ebone == NULL) {
return;
+ }
- if (bone->temp.ebone->temp.ebone != NULL && bone->temp.ebone->temp.ebone != ancestor)
+ if (bone->temp.ebone->temp.ebone != NULL && bone->temp.ebone->temp.ebone != ancestor) {
is_ancestor(bone->temp.ebone, ancestor);
+ }
bone->temp.ebone = bone->temp.ebone->temp.ebone;
}
@@ -1451,8 +1476,9 @@ static void select_similar_children(bContext *C)
for (EditBone *ebone_iter = arm->edbo->first; ebone_iter; ebone_iter = ebone_iter->next) {
is_ancestor(ebone_iter, ebone_act);
- if (ebone_iter->temp.ebone == ebone_act && EBONE_SELECTABLE(arm, ebone_iter))
+ if (ebone_iter->temp.ebone == ebone_act && EBONE_SELECTABLE(arm, ebone_iter)) {
ED_armature_ebone_select_set(ebone_iter, true);
+ }
}
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit);
@@ -1757,8 +1783,9 @@ static bool armature_shortest_path_select(
{
do {
- if (!use_parent && (ebone_child == ebone_parent))
+ if (!use_parent && (ebone_child == ebone_parent)) {
break;
+ }
if (is_test) {
if (!EBONE_SELECTABLE(arm, ebone_child)) {
@@ -1769,8 +1796,9 @@ static bool armature_shortest_path_select(
ED_armature_ebone_selectflag_set(ebone_child, (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL));
}
- if (ebone_child == ebone_parent)
+ if (ebone_child == ebone_parent) {
break;
+ }
ebone_child = ebone_child->parent;
} while (true);
diff --git a/source/blender/editors/armature/armature_skinning.c b/source/blender/editors/armature/armature_skinning.c
index c267485d553..08de699a70b 100644
--- a/source/blender/editors/armature/armature_skinning.c
+++ b/source/blender/editors/armature/armature_skinning.c
@@ -93,10 +93,12 @@ static int bone_skinnable_cb(Object *UNUSED(ob), Bone *bone, void *datap)
if (!(data->is_weight_paint) || !(bone->flag & BONE_HIDDEN_P)) {
if (!(bone->flag & BONE_NO_DEFORM)) {
if (data->heat && data->armob->pose &&
- BKE_pose_channel_find_name(data->armob->pose, bone->name))
+ BKE_pose_channel_find_name(data->armob->pose, bone->name)) {
segments = bone->segments;
- else
+ }
+ else {
segments = 1;
+ }
if (data->list != NULL) {
hbone = (Bone ***)&data->list;
@@ -165,10 +167,12 @@ static int dgroup_skinnable_cb(Object *ob, Bone *bone, void *datap)
if (!data->is_weight_paint || !(bone->flag & BONE_HIDDEN_P)) {
if (!(bone->flag & BONE_NO_DEFORM)) {
if (data->heat && data->armob->pose &&
- BKE_pose_channel_find_name(data->armob->pose, bone->name))
+ BKE_pose_channel_find_name(data->armob->pose, bone->name)) {
segments = bone->segments;
- else
+ }
+ else {
segments = 1;
+ }
if (!data->is_weight_paint || ((arm->layer & bone->layer) && (bone->flag & BONE_SELECTED))) {
if (!(defgroup = defgroup_find_name(ob, bone->name))) {
@@ -231,8 +235,9 @@ static void envelope_bone_weighting(Object *ob,
/* for each skinnable bone */
for (j = 0; j < numbones; ++j) {
- if (!selected[j])
+ if (!selected[j]) {
continue;
+ }
bone = bonelist[j];
dgroup = dgrouplist[j];
@@ -246,17 +251,21 @@ static void envelope_bone_weighting(Object *ob,
bone->dist * scale);
/* add the vert to the deform group if (weight != 0.0) */
- if (distance != 0.0f)
+ if (distance != 0.0f) {
ED_vgroup_vert_add(ob, dgroup, i, distance, WEIGHT_REPLACE);
- else
+ }
+ else {
ED_vgroup_vert_remove(ob, dgroup, i);
+ }
/* do same for mirror */
if (dgroupflip && dgroupflip[j] && iflip != -1) {
- if (distance != 0.0f)
+ if (distance != 0.0f) {
ED_vgroup_vert_add(ob, dgroupflip[j], iflip, distance, WEIGHT_REPLACE);
- else
+ }
+ else {
ED_vgroup_vert_remove(ob, dgroupflip[j], iflip);
+ }
}
}
}
@@ -308,11 +317,13 @@ static void add_verts_to_dgroups(ReportList *reports,
/* count the number of skinnable bones */
numbones = bone_looper(ob, arm->bonebase.first, &looper_data, bone_skinnable_cb);
- if (numbones == 0)
+ if (numbones == 0) {
return;
+ }
- if (BKE_object_defgroup_data_create(ob->data) == NULL)
+ if (BKE_object_defgroup_data_create(ob->data) == NULL) {
return;
+ }
/* create an array of pointer to bones that are skinnable
* and fill it with all of the skinnable bones */
@@ -377,11 +388,13 @@ static void add_verts_to_dgroups(ReportList *reports,
/* set selected */
if (wpmode) {
- if ((arm->layer & bone->layer) && (bone->flag & BONE_SELECTED))
+ if ((arm->layer & bone->layer) && (bone->flag & BONE_SELECTED)) {
selected[j] = 1;
+ }
}
- else
+ else {
selected[j] = 1;
+ }
/* find flipped group */
if (dgroup && mirror) {
@@ -415,8 +428,9 @@ static void add_verts_to_dgroups(ReportList *reports,
/* transform verts to global space */
for (i = 0; i < mesh->totvert; i++) {
- if (!vertsfilled)
+ if (!vertsfilled) {
copy_v3_v3(verts[i], mesh->mvert[i].co);
+ }
mul_m4_v3(ob->obmat, verts[i]);
}
diff --git a/source/blender/editors/armature/armature_utils.c b/source/blender/editors/armature/armature_utils.c
index ebb0b6b4c22..b4e4396ce89 100644
--- a/source/blender/editors/armature/armature_utils.c
+++ b/source/blender/editors/armature/armature_utils.c
@@ -56,16 +56,20 @@ void ED_armature_edit_sync_selection(ListBase *edbo)
/* if bone is not selectable, we shouldn't alter this setting... */
if ((ebo->flag & BONE_UNSELECTABLE) == 0) {
if ((ebo->flag & BONE_CONNECTED) && (ebo->parent)) {
- if (ebo->parent->flag & BONE_TIPSEL)
+ if (ebo->parent->flag & BONE_TIPSEL) {
ebo->flag |= BONE_ROOTSEL;
- else
+ }
+ else {
ebo->flag &= ~BONE_ROOTSEL;
+ }
}
- if ((ebo->flag & BONE_TIPSEL) && (ebo->flag & BONE_ROOTSEL))
+ if ((ebo->flag & BONE_TIPSEL) && (ebo->flag & BONE_ROOTSEL)) {
ebo->flag |= BONE_SELECTED;
- else
+ }
+ else {
ebo->flag &= ~BONE_SELECTED;
+ }
}
}
}
@@ -75,8 +79,9 @@ void ED_armature_edit_validate_active(struct bArmature *arm)
EditBone *ebone = arm->act_edbone;
if (ebone) {
- if (ebone->flag & BONE_HIDDEN_A)
+ if (ebone->flag & BONE_HIDDEN_A) {
arm->act_edbone = NULL;
+ }
}
}
@@ -116,8 +121,9 @@ int bone_looper(Object *ob, Bone *bone, void *data, int (*bone_func)(Object *, B
void bone_free(bArmature *arm, EditBone *bone)
{
- if (arm->act_edbone == bone)
+ if (arm->act_edbone == bone) {
arm->act_edbone = NULL;
+ }
if (bone->prop) {
IDP_FreeProperty(bone->prop);
@@ -165,8 +171,9 @@ void ED_armature_ebone_remove(bArmature *arm, EditBone *exBone)
bool ED_armature_ebone_is_child_recursive(EditBone *ebone_parent, EditBone *ebone_child)
{
for (ebone_child = ebone_child->parent; ebone_child; ebone_child = ebone_child->parent) {
- if (ebone_child == ebone_parent)
+ if (ebone_child == ebone_parent) {
return true;
+ }
}
return false;
}
@@ -274,8 +281,9 @@ EditBone *ED_armature_ebone_get_mirrored(const ListBase *edbo, EditBone *ebo)
{
char name_flip[MAXBONENAME];
- if (ebo == NULL)
+ if (ebo == NULL) {
return NULL;
+ }
BLI_string_flip_side_name(name_flip, ebo->name, false, sizeof(name_flip));
@@ -301,8 +309,9 @@ void armature_select_mirrored_ex(bArmature *arm, const int flag)
if (arm->layer & curBone->layer) {
if (curBone->flag & flag) {
ebone_mirr = ED_armature_ebone_get_mirrored(arm->edbo, curBone);
- if (ebone_mirr)
+ if (ebone_mirr) {
ebone_mirr->flag |= (curBone->flag & flag);
+ }
}
}
}
@@ -499,20 +508,23 @@ static EditBone *make_boneList_rec(ListBase *edbo,
eBone->bbone_prev_type = curBone->bbone_prev_type;
eBone->bbone_next_type = curBone->bbone_next_type;
- if (curBone->prop)
+ if (curBone->prop) {
eBone->prop = IDP_CopyProperty(curBone->prop);
+ }
BLI_addtail(edbo, eBone);
/* Add children if necessary */
if (curBone->childbase.first) {
eBoneTest = make_boneList_rec(edbo, &curBone->childbase, eBone, actBone);
- if (eBoneTest)
+ if (eBoneTest) {
eBoneAct = eBoneTest;
+ }
}
- if (curBone == actBone)
+ if (curBone == actBone) {
eBoneAct = eBone;
+ }
}
return eBoneAct;
@@ -648,11 +660,13 @@ void ED_armature_from_edit(Main *bmain, bArmature *arm)
/* Find any bones that refer to this bone */
for (fBone = arm->edbo->first; fBone; fBone = fBone->next) {
- if (fBone->parent == eBone)
+ if (fBone->parent == eBone) {
fBone->parent = eBone->parent;
+ }
}
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("Warning: removed zero sized bone: %s\n", eBone->name);
+ }
bone_free(arm, eBone);
}
}
@@ -704,8 +718,9 @@ void ED_armature_from_edit(Main *bmain, bArmature *arm)
newBone->bbone_prev_type = eBone->bbone_prev_type;
newBone->bbone_next_type = eBone->bbone_next_type;
- if (eBone->prop)
+ if (eBone->prop) {
newBone->prop = IDP_CopyProperty(eBone->prop);
+ }
}
/* Fix parenting in a separate pass to ensure ebone->bone connections are valid at this point.
diff --git a/source/blender/editors/armature/meshlaplacian.c b/source/blender/editors/armature/meshlaplacian.c
index a9f8925febc..b194650060a 100644
--- a/source/blender/editors/armature/meshlaplacian.c
+++ b/source/blender/editors/armature/meshlaplacian.c
@@ -122,10 +122,12 @@ static void laplacian_increase_edge_count(EdgeHash *edgehash, int v1, int v2)
{
void **p;
- if (BLI_edgehash_ensure_p(edgehash, v1, v2, &p))
+ if (BLI_edgehash_ensure_p(edgehash, v1, v2, &p)) {
*p = (void *)((intptr_t)*p + (intptr_t)1);
- else
+ }
+ else {
*p = (void *)((intptr_t)1);
+ }
}
static int laplacian_edge_count(EdgeHash *edgehash, int v1, int v2)
@@ -147,12 +149,15 @@ static void laplacian_triangle_area(LaplacianSystem *sys, int i1, int i2, int i3
t2 = cotangent_tri_weight_v3(v2, v3, v1);
t3 = cotangent_tri_weight_v3(v3, v1, v2);
- if (angle_v3v3v3(v2, v1, v3) > DEG2RADF(90.0f))
+ if (angle_v3v3v3(v2, v1, v3) > DEG2RADF(90.0f)) {
obtuse = 1;
- else if (angle_v3v3v3(v1, v2, v3) > DEG2RADF(90.0f))
+ }
+ else if (angle_v3v3v3(v1, v2, v3) > DEG2RADF(90.0f)) {
obtuse = 2;
- else if (angle_v3v3v3(v1, v3, v2) > DEG2RADF(90.0f))
+ }
+ else if (angle_v3v3v3(v1, v3, v2) > DEG2RADF(90.0f)) {
obtuse = 3;
+ }
if (obtuse > 0) {
area = area_tri_v3(v1, v2, v3);
@@ -228,10 +233,12 @@ static LaplacianSystem *laplacian_system_construct_begin(int totvert, int totfac
sys->storeweights = 0;
/* create linear solver */
- if (lsq)
+ if (lsq) {
sys->context = EIG_linear_least_squares_solver_new(0, totvert, 1);
- else
+ }
+ else {
sys->context = EIG_linear_solver_new(0, totvert, 1);
+ }
return sys;
}
@@ -267,28 +274,35 @@ static void laplacian_system_construct_end(LaplacianSystem *sys)
laplacian_increase_edge_count(sys->edgehash, (*face)[2], (*face)[0]);
}
- if (sys->areaweights)
- for (a = 0, face = sys->faces; a < sys->totface; a++, face++)
+ if (sys->areaweights) {
+ for (a = 0, face = sys->faces; a < sys->totface; a++, face++) {
laplacian_triangle_area(sys, (*face)[0], (*face)[1], (*face)[2]);
+ }
+ }
for (a = 0; a < totvert; a++) {
if (sys->areaweights) {
- if (sys->varea[a] != 0.0f)
+ if (sys->varea[a] != 0.0f) {
sys->varea[a] = 0.5f / sys->varea[a];
+ }
}
- else
+ else {
sys->varea[a] = 1.0f;
+ }
/* for heat weighting */
- if (sys->heat.H)
+ if (sys->heat.H) {
EIG_linear_solver_matrix_add(sys->context, a, a, sys->heat.H[a]);
+ }
}
- if (sys->storeweights)
+ if (sys->storeweights) {
sys->fweights = MEM_callocN(sizeof(float) * 3 * totface, "LaplacianFWeight");
+ }
- for (a = 0, face = sys->faces; a < totface; a++, face++)
+ for (a = 0, face = sys->faces; a < totface; a++, face++) {
laplacian_triangle_weights(sys, a, (*face)[0], (*face)[1], (*face)[2]);
+ }
MEM_freeN(sys->faces);
sys->faces = NULL;
@@ -304,16 +318,21 @@ static void laplacian_system_construct_end(LaplacianSystem *sys)
static void laplacian_system_delete(LaplacianSystem *sys)
{
- if (sys->verts)
+ if (sys->verts) {
MEM_freeN(sys->verts);
- if (sys->varea)
+ }
+ if (sys->varea) {
MEM_freeN(sys->varea);
- if (sys->vpinned)
+ }
+ if (sys->vpinned) {
MEM_freeN(sys->vpinned);
- if (sys->faces)
+ }
+ if (sys->faces) {
MEM_freeN(sys->faces);
- if (sys->fweights)
+ }
+ if (sys->fweights) {
MEM_freeN(sys->fweights);
+ }
EIG_linear_solver_delete(sys->context);
MEM_freeN(sys);
@@ -450,8 +469,9 @@ static int heat_ray_source_visible(LaplacianSystem *sys, int vertex, int source)
int visible;
lt = sys->heat.vltree[vertex];
- if (lt == NULL)
+ if (lt == NULL) {
return 1;
+ }
data.sys = sys;
copy_v3_v3(data.start, sys->heat.verts[vertex]);
@@ -496,9 +516,11 @@ static int heat_source_closest(LaplacianSystem *sys, int vertex, int source)
dist = heat_source_distance(sys, vertex, source);
- if (dist <= sys->heat.mindist[vertex] * (1.0f + DISTANCE_EPSILON))
- if (heat_ray_source_visible(sys, vertex, source))
+ if (dist <= sys->heat.mindist[vertex] * (1.0f + DISTANCE_EPSILON)) {
+ if (heat_ray_source_visible(sys, vertex, source)) {
return 1;
+ }
+ }
return 0;
}
@@ -514,16 +536,19 @@ static void heat_set_H(LaplacianSystem *sys, int vertex)
for (j = 0; j < sys->heat.numsource; j++) {
dist = heat_source_distance(sys, vertex, j);
- if (dist < mindist)
+ if (dist < mindist) {
mindist = dist;
+ }
}
sys->heat.mindist[vertex] = mindist;
/* count number of sources with approximately this minimum distance */
- for (j = 0; j < sys->heat.numsource; j++)
- if (heat_source_closest(sys, vertex, j))
+ for (j = 0; j < sys->heat.numsource; j++) {
+ if (heat_source_closest(sys, vertex, j)) {
numclosest++;
+ }
+ }
sys->heat.p[vertex] = (numclosest > 0) ? 1.0f / numclosest : 0.0f;
@@ -532,8 +557,9 @@ static void heat_set_H(LaplacianSystem *sys, int vertex)
mindist = max_ff(mindist, 1e-4f);
h = numclosest * C_WEIGHT / (mindist * mindist);
}
- else
+ else {
h = 0.0f;
+ }
sys->heat.H[vertex] = h;
}
@@ -557,8 +583,9 @@ static void heat_calc_vnormals(LaplacianSystem *sys)
add_v3_v3(sys->heat.vnors[v3], fnor);
}
- for (a = 0; a < sys->totvert; a++)
+ for (a = 0; a < sys->totvert; a++) {
normalize_v3(sys->heat.vnors[a]);
+ }
}
static void heat_laplacian_create(LaplacianSystem *sys)
@@ -575,8 +602,9 @@ static void heat_laplacian_create(LaplacianSystem *sys)
sys->heat.p = MEM_callocN(sizeof(float) * totvert, "HeatP");
/* add verts and faces to laplacian */
- for (a = 0; a < totvert; a++)
+ for (a = 0; a < totvert; a++) {
laplacian_add_vertex(sys, sys->heat.verts[a], 0);
+ }
for (a = 0, lt = mlooptri; a < tottri; a++, lt++) {
int vtri[3];
@@ -589,8 +617,9 @@ static void heat_laplacian_create(LaplacianSystem *sys)
/* for distance computation in set_H */
heat_calc_vnormals(sys);
- for (a = 0; a < totvert; a++)
+ for (a = 0; a < totvert; a++) {
heat_set_H(sys, a);
+ }
}
static void heat_system_free(LaplacianSystem *sys)
@@ -616,8 +645,9 @@ static float heat_limit_weight(float weight)
t = (weight - WEIGHT_LIMIT_END) / (WEIGHT_LIMIT_START - WEIGHT_LIMIT_END);
return t * WEIGHT_LIMIT_START;
}
- else
+ else {
return weight;
+ }
}
void heat_bone_weighting(Object *ob,
@@ -695,14 +725,16 @@ void heat_bone_weighting(Object *ob,
if (dgroupflip) {
vertsflipped = MEM_callocN(sizeof(int) * me->totvert, "vertsflipped");
- for (a = 0; a < me->totvert; a++)
+ for (a = 0; a < me->totvert; a++) {
vertsflipped[a] = mesh_get_x_mirror_vert(ob, NULL, a, use_topology);
+ }
}
/* compute weights per bone */
for (j = 0; j < numsource; j++) {
- if (!selected[j])
+ if (!selected[j]) {
continue;
+ }
firstsegment = (j == 0 || dgrouplist[j - 1] != dgrouplist[j]);
lastsegment = (j == numsource - 1 || dgrouplist[j] != dgrouplist[j + 1]);
@@ -711,55 +743,66 @@ void heat_bone_weighting(Object *ob,
/* clear weights */
if (bbone && firstsegment) {
for (a = 0; a < me->totvert; a++) {
- if (mask && !mask[a])
+ if (mask && !mask[a]) {
continue;
+ }
ED_vgroup_vert_remove(ob, dgrouplist[j], a);
- if (vertsflipped && dgroupflip[j] && vertsflipped[a] >= 0)
+ if (vertsflipped && dgroupflip[j] && vertsflipped[a] >= 0) {
ED_vgroup_vert_remove(ob, dgroupflip[j], vertsflipped[a]);
+ }
}
}
/* fill right hand side */
laplacian_begin_solve(sys, -1);
- for (a = 0; a < me->totvert; a++)
- if (heat_source_closest(sys, a, j))
+ for (a = 0; a < me->totvert; a++) {
+ if (heat_source_closest(sys, a, j)) {
laplacian_add_right_hand_side(sys, a, sys->heat.H[a] * sys->heat.p[a]);
+ }
+ }
/* solve */
if (laplacian_system_solve(sys)) {
/* load solution into vertex groups */
for (a = 0; a < me->totvert; a++) {
- if (mask && !mask[a])
+ if (mask && !mask[a]) {
continue;
+ }
solution = laplacian_system_get_solution(sys, a);
if (bbone) {
- if (solution > 0.0f)
+ if (solution > 0.0f) {
ED_vgroup_vert_add(ob, dgrouplist[j], a, solution, WEIGHT_ADD);
+ }
}
else {
weight = heat_limit_weight(solution);
- if (weight > 0.0f)
+ if (weight > 0.0f) {
ED_vgroup_vert_add(ob, dgrouplist[j], a, weight, WEIGHT_REPLACE);
- else
+ }
+ else {
ED_vgroup_vert_remove(ob, dgrouplist[j], a);
+ }
}
/* do same for mirror */
if (vertsflipped && dgroupflip[j] && vertsflipped[a] >= 0) {
if (bbone) {
- if (solution > 0.0f)
+ if (solution > 0.0f) {
ED_vgroup_vert_add(ob, dgroupflip[j], vertsflipped[a], solution, WEIGHT_ADD);
+ }
}
else {
weight = heat_limit_weight(solution);
- if (weight > 0.0f)
+ if (weight > 0.0f) {
ED_vgroup_vert_add(ob, dgroupflip[j], vertsflipped[a], weight, WEIGHT_REPLACE);
- else
+ }
+ else {
ED_vgroup_vert_remove(ob, dgroupflip[j], vertsflipped[a]);
+ }
}
}
}
@@ -772,29 +815,34 @@ void heat_bone_weighting(Object *ob,
/* remove too small vertex weights */
if (bbone && lastsegment) {
for (a = 0; a < me->totvert; a++) {
- if (mask && !mask[a])
+ if (mask && !mask[a]) {
continue;
+ }
weight = ED_vgroup_vert_weight(ob, dgrouplist[j], a);
weight = heat_limit_weight(weight);
- if (weight <= 0.0f)
+ if (weight <= 0.0f) {
ED_vgroup_vert_remove(ob, dgrouplist[j], a);
+ }
if (vertsflipped && dgroupflip[j] && vertsflipped[a] >= 0) {
weight = ED_vgroup_vert_weight(ob, dgroupflip[j], vertsflipped[a]);
weight = heat_limit_weight(weight);
- if (weight <= 0.0f)
+ if (weight <= 0.0f) {
ED_vgroup_vert_remove(ob, dgroupflip[j], vertsflipped[a]);
+ }
}
}
}
}
/* free */
- if (vertsflipped)
+ if (vertsflipped) {
MEM_freeN(vertsflipped);
- if (mask)
+ }
+ if (mask) {
MEM_freeN(mask);
+ }
heat_system_free(sys);
@@ -964,8 +1012,9 @@ static MDefBoundIsect *meshdeform_ray_tree_intersect(MeshDeformBind *mdb,
float end[3], vec_normal[3];
/* happens binding when a cage has no faces */
- if (UNLIKELY(mdb->bvhtree == NULL))
+ if (UNLIKELY(mdb->bvhtree == NULL)) {
return NULL;
+ }
/* setup isec */
memset(&isect_mdef, 0, sizeof(isect_mdef));
@@ -1037,8 +1086,9 @@ static int meshdeform_inside_cage(MeshDeformBind *mdb, float *co)
normalize_v3(dir);
isect = meshdeform_ray_tree_intersect(mdb, start, outside);
- if (isect && !isect->facing)
+ if (isect && !isect->facing) {
return 1;
+ }
}
return 0;
@@ -1054,12 +1104,15 @@ BLI_INLINE int meshdeform_index(MeshDeformBind *mdb, int x, int y, int z, int n)
y += MESHDEFORM_OFFSET[n][1];
z += MESHDEFORM_OFFSET[n][2];
- if (x < 0 || x >= mdb->size)
+ if (x < 0 || x >= mdb->size) {
return -1;
- if (y < 0 || y >= mdb->size)
+ }
+ if (y < 0 || y >= mdb->size) {
return -1;
- if (z < 0 || z >= mdb->size)
+ }
+ if (z < 0 || z >= mdb->size) {
return -1;
+ }
return x + y * size + z * size * size;
}
@@ -1087,8 +1140,9 @@ static void meshdeform_add_intersections(MeshDeformBind *mdb, int x, int y, int
/* check each outgoing edge for intersection */
for (i = 1; i <= 6; i++) {
- if (meshdeform_index(mdb, x, y, z, i) == -1)
+ if (meshdeform_index(mdb, x, y, z, i) == -1) {
continue;
+ }
meshdeform_cell_center(mdb, x, y, z, i, ncenter);
@@ -1134,9 +1188,11 @@ static void meshdeform_bind_floodfill(MeshDeformBind *mdb)
}
/* other cells are interior */
- for (a = 0; a < size * size * size; a++)
- if (tag[a] == MESHDEFORM_TAG_UNTYPED)
+ for (a = 0; a < size * size * size; a++) {
+ if (tag[a] == MESHDEFORM_TAG_UNTYPED) {
tag[a] = MESHDEFORM_TAG_INTERIOR;
+ }
+ }
#if 0
{
@@ -1230,8 +1286,9 @@ static float meshdeform_interp_w(MeshDeformBind *mdb,
totweight += weight;
}
- if (totweight > 0.0f)
+ if (totweight > 0.0f) {
result /= totweight;
+ }
return result;
}
@@ -1241,12 +1298,15 @@ static void meshdeform_check_semibound(MeshDeformBind *mdb, int x, int y, int z)
int i, a;
a = meshdeform_index(mdb, x, y, z, 0);
- if (mdb->tag[a] != MESHDEFORM_TAG_EXTERIOR)
+ if (mdb->tag[a] != MESHDEFORM_TAG_EXTERIOR) {
return;
+ }
- for (i = 1; i <= 6; i++)
- if (mdb->boundisect[a][i - 1])
+ for (i = 1; i <= 6; i++) {
+ if (mdb->boundisect[a][i - 1]) {
mdb->semibound[a] = 1;
+ }
+ }
}
static float meshdeform_boundary_total_weight(MeshDeformBind *mdb, int x, int y, int z)
@@ -1258,15 +1318,19 @@ static float meshdeform_boundary_total_weight(MeshDeformBind *mdb, int x, int y,
/* count weight for neighbor cells */
for (i = 1; i <= 6; i++) {
- if (meshdeform_index(mdb, x, y, z, i) == -1)
+ if (meshdeform_index(mdb, x, y, z, i) == -1) {
continue;
+ }
- if (mdb->boundisect[a][i - 1])
+ if (mdb->boundisect[a][i - 1]) {
weight = 1.0f / mdb->boundisect[a][i - 1]->len;
- else if (!mdb->semibound[a])
+ }
+ else if (!mdb->semibound[a]) {
weight = 1.0f / mdb->width[0];
- else
+ }
+ else {
weight = 0.0f;
+ }
totweight += weight;
}
@@ -1282,16 +1346,18 @@ static void meshdeform_matrix_add_cell(
int i, a, acenter;
acenter = meshdeform_index(mdb, x, y, z, 0);
- if (mdb->tag[acenter] == MESHDEFORM_TAG_EXTERIOR)
+ if (mdb->tag[acenter] == MESHDEFORM_TAG_EXTERIOR) {
return;
+ }
EIG_linear_solver_matrix_add(context, mdb->varidx[acenter], mdb->varidx[acenter], 1.0f);
totweight = meshdeform_boundary_total_weight(mdb, x, y, z);
for (i = 1; i <= 6; i++) {
a = meshdeform_index(mdb, x, y, z, i);
- if (a == -1 || mdb->tag[a] == MESHDEFORM_TAG_EXTERIOR)
+ if (a == -1 || mdb->tag[a] == MESHDEFORM_TAG_EXTERIOR) {
continue;
+ }
isect = mdb->boundisect[acenter][i - 1];
if (!isect) {
@@ -1309,14 +1375,16 @@ static void meshdeform_matrix_add_rhs(
int i, a, acenter;
acenter = meshdeform_index(mdb, x, y, z, 0);
- if (mdb->tag[acenter] == MESHDEFORM_TAG_EXTERIOR)
+ if (mdb->tag[acenter] == MESHDEFORM_TAG_EXTERIOR) {
return;
+ }
totweight = meshdeform_boundary_total_weight(mdb, x, y, z);
for (i = 1; i <= 6; i++) {
a = meshdeform_index(mdb, x, y, z, i);
- if (a == -1)
+ if (a == -1) {
continue;
+ }
isect = mdb->boundisect[acenter][i - 1];
@@ -1336,8 +1404,9 @@ static void meshdeform_matrix_add_semibound_phi(
int i, a;
a = meshdeform_index(mdb, x, y, z, 0);
- if (!mdb->semibound[a])
+ if (!mdb->semibound[a]) {
return;
+ }
mdb->phi[a] = 0.0f;
@@ -1360,8 +1429,9 @@ static void meshdeform_matrix_add_exterior_phi(
int i, a, acenter;
acenter = meshdeform_index(mdb, x, y, z, 0);
- if (mdb->tag[acenter] != MESHDEFORM_TAG_EXTERIOR || mdb->semibound[acenter])
+ if (mdb->tag[acenter] != MESHDEFORM_TAG_EXTERIOR || mdb->semibound[acenter]) {
return;
+ }
phi = 0.0f;
totweight = 0.0f;
@@ -1374,8 +1444,9 @@ static void meshdeform_matrix_add_exterior_phi(
}
}
- if (totweight != 0.0f)
+ if (totweight != 0.0f) {
mdb->phi[acenter] = phi / totweight;
+ }
}
static void meshdeform_matrix_solve(MeshDeformModifierData *mmd, MeshDeformBind *mdb)
@@ -1387,8 +1458,9 @@ static void meshdeform_matrix_solve(MeshDeformModifierData *mmd, MeshDeformBind
/* setup variable indices */
mdb->varidx = MEM_callocN(sizeof(int) * mdb->size3, "MeshDeformDSvaridx");
- for (a = 0, totvar = 0; a < mdb->size3; a++)
+ for (a = 0, totvar = 0; a < mdb->size3; a++) {
mdb->varidx[a] = (mdb->tag[a] == MESHDEFORM_TAG_EXTERIOR) ? -1 : totvar++;
+ }
if (totvar == 0) {
MEM_freeN(mdb->varidx);
@@ -1401,33 +1473,46 @@ static void meshdeform_matrix_solve(MeshDeformModifierData *mmd, MeshDeformBind
context = EIG_linear_solver_new(totvar, totvar, 1);
/* build matrix */
- for (z = 0; z < mdb->size; z++)
- for (y = 0; y < mdb->size; y++)
- for (x = 0; x < mdb->size; x++)
+ for (z = 0; z < mdb->size; z++) {
+ for (y = 0; y < mdb->size; y++) {
+ for (x = 0; x < mdb->size; x++) {
meshdeform_matrix_add_cell(mdb, context, x, y, z);
+ }
+ }
+ }
/* solve for each cage vert */
for (a = 0; a < mdb->totcagevert; a++) {
/* fill in right hand side and solve */
- for (z = 0; z < mdb->size; z++)
- for (y = 0; y < mdb->size; y++)
- for (x = 0; x < mdb->size; x++)
+ for (z = 0; z < mdb->size; z++) {
+ for (y = 0; y < mdb->size; y++) {
+ for (x = 0; x < mdb->size; x++) {
meshdeform_matrix_add_rhs(mdb, context, x, y, z, a);
+ }
+ }
+ }
if (EIG_linear_solver_solve(context)) {
- for (z = 0; z < mdb->size; z++)
- for (y = 0; y < mdb->size; y++)
- for (x = 0; x < mdb->size; x++)
+ for (z = 0; z < mdb->size; z++) {
+ for (y = 0; y < mdb->size; y++) {
+ for (x = 0; x < mdb->size; x++) {
meshdeform_matrix_add_semibound_phi(mdb, x, y, z, a);
+ }
+ }
+ }
- for (z = 0; z < mdb->size; z++)
- for (y = 0; y < mdb->size; y++)
- for (x = 0; x < mdb->size; x++)
+ for (z = 0; z < mdb->size; z++) {
+ for (y = 0; y < mdb->size; y++) {
+ for (x = 0; x < mdb->size; x++) {
meshdeform_matrix_add_exterior_phi(mdb, x, y, z, a);
+ }
+ }
+ }
for (b = 0; b < mdb->size3; b++) {
- if (mdb->tag[b] != MESHDEFORM_TAG_EXTERIOR)
+ if (mdb->tag[b] != MESHDEFORM_TAG_EXTERIOR) {
mdb->phi[b] = EIG_linear_solver_variable_get(context, 0, mdb->varidx[b]);
+ }
mdb->totalphi[b] += mdb->phi[b];
}
@@ -1499,8 +1584,9 @@ static void harmonic_coordinates_bind(MeshDeformModifierData *mmd, MeshDeformBin
/* compute bounding box of the cage mesh */
INIT_MINMAX(mdb->min, mdb->max);
- for (a = 0; a < mdb->totcagevert; a++)
+ for (a = 0; a < mdb->totcagevert; a++) {
minmax_v3v3_v3(mdb->min, mdb->max, mdb->cagecos[a]);
+ }
/* allocate memory */
mdb->size = (2 << (mmd->gridsize - 1)) + 2;
@@ -1513,10 +1599,12 @@ static void harmonic_coordinates_bind(MeshDeformModifierData *mmd, MeshDeformBin
mdb->bvhtree = BKE_bvhtree_from_mesh_get(&mdb->bvhdata, mdb->cagemesh, BVHTREE_FROM_LOOPTRI, 4);
mdb->inside = MEM_callocN(sizeof(int) * mdb->totvert, "MDefInside");
- if (mmd->flag & MOD_MDEF_DYNAMIC_BIND)
+ if (mmd->flag & MOD_MDEF_DYNAMIC_BIND) {
mdb->dyngrid = MEM_callocN(sizeof(MDefBindInfluence *) * mdb->size3, "MDefDynGrid");
- else
+ }
+ else {
mdb->weights = MEM_callocN(sizeof(float) * mdb->totvert * mdb->totcagevert, "MDefWeights");
+ }
mdb->memarena = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, "harmonic coords arena");
BLI_memarena_use_calloc(mdb->memarena);
@@ -1534,9 +1622,11 @@ static void harmonic_coordinates_bind(MeshDeformModifierData *mmd, MeshDeformBin
/* make bounding box equal size in all directions, add padding, and compute
* width of the cells */
maxwidth = -1.0f;
- for (a = 0; a < 3; a++)
- if (mdb->max[a] - mdb->min[a] > maxwidth)
+ for (a = 0; a < 3; a++) {
+ if (mdb->max[a] - mdb->min[a] > maxwidth) {
maxwidth = mdb->max[a] - mdb->min[a];
+ }
+ }
for (a = 0; a < 3; a++) {
center[a] = (mdb->min[a] + mdb->max[a]) * 0.5f;
@@ -1557,8 +1647,9 @@ static void harmonic_coordinates_bind(MeshDeformModifierData *mmd, MeshDeformBin
for (a = 0; a < mdb->totvert; a++) {
copy_v3_v3(vec, mdb->vertexcos[a]);
mdb->inside[a] = meshdeform_inside_cage(mdb, vec);
- if (mdb->inside[a])
+ if (mdb->inside[a]) {
totinside++;
+ }
}
/* free temporary MDefBoundIsects */
@@ -1566,22 +1657,29 @@ static void harmonic_coordinates_bind(MeshDeformModifierData *mmd, MeshDeformBin
mdb->memarena = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, "harmonic coords arena");
/* start with all cells untyped */
- for (a = 0; a < mdb->size3; a++)
+ for (a = 0; a < mdb->size3; a++) {
mdb->tag[a] = MESHDEFORM_TAG_UNTYPED;
+ }
/* detect intersections and tag boundary cells */
- for (z = 0; z < mdb->size; z++)
- for (y = 0; y < mdb->size; y++)
- for (x = 0; x < mdb->size; x++)
+ for (z = 0; z < mdb->size; z++) {
+ for (y = 0; y < mdb->size; y++) {
+ for (x = 0; x < mdb->size; x++) {
meshdeform_add_intersections(mdb, x, y, z);
+ }
+ }
+ }
/* compute exterior and interior tags */
meshdeform_bind_floodfill(mdb);
- for (z = 0; z < mdb->size; z++)
- for (y = 0; y < mdb->size; y++)
- for (x = 0; x < mdb->size; x++)
+ for (z = 0; z < mdb->size; z++) {
+ for (y = 0; y < mdb->size; y++) {
+ for (x = 0; x < mdb->size; x++) {
meshdeform_check_semibound(mdb, x, y, z);
+ }
+ }
+ }
/* solve */
meshdeform_matrix_solve(mmd, mdb);
@@ -1589,9 +1687,11 @@ static void harmonic_coordinates_bind(MeshDeformModifierData *mmd, MeshDeformBin
/* assign results */
if (mmd->flag & MOD_MDEF_DYNAMIC_BIND) {
mmd->totinfluence = 0;
- for (a = 0; a < mdb->size3; a++)
- for (inf = mdb->dyngrid[a]; inf; inf = inf->next)
+ for (a = 0; a < mdb->size3; a++) {
+ for (inf = mdb->dyngrid[a]; inf; inf = inf->next) {
mmd->totinfluence++;
+ }
+ }
/* convert MDefBindInfluences to smaller MDefInfluences */
mmd->dyngrid = MEM_callocN(sizeof(MDefCell) * mdb->size3, "MDefDynGrid");
@@ -1612,8 +1712,9 @@ static void harmonic_coordinates_bind(MeshDeformModifierData *mmd, MeshDeformBin
if (totweight > 0.0f) {
mdinf = mmd->dyninfluences + cell->offset;
- for (b = 0; b < cell->totinfluence; b++, mdinf++)
+ for (b = 0; b < cell->totinfluence; b++, mdinf++) {
mdinf->weight /= totweight;
+ }
}
offset += cell->totinfluence;
@@ -1666,10 +1767,12 @@ void ED_mesh_deform_bind_callback(MeshDeformModifierData *mmd,
copy_m4_m4(mdb.cagemat, cagemat);
mvert = mdb.cagemesh->mvert;
- for (a = 0; a < mdb.totcagevert; a++)
+ for (a = 0; a < mdb.totcagevert; a++) {
copy_v3_v3(mdb.cagecos[a], mvert[a].co);
- for (a = 0; a < mdb.totvert; a++)
+ }
+ for (a = 0; a < mdb.totvert; a++) {
mul_v3_m4v3(mdb.vertexcos[a], mdb.cagemat, vertexcos + a * 3);
+ }
/* solve */
harmonic_coordinates_bind(mmd_orig, &mdb);
@@ -1681,8 +1784,9 @@ void ED_mesh_deform_bind_callback(MeshDeformModifierData *mmd,
copy_m4_m4(mmd_orig->bindmat, mmd_orig->object->obmat);
/* transform bindcagecos to world space */
- for (a = 0; a < mdb.totcagevert; a++)
+ for (a = 0; a < mdb.totcagevert; a++) {
mul_m4_v3(mmd_orig->object->obmat, mmd_orig->bindcagecos + a * 3);
+ }
/* free */
MEM_freeN(mdb.vertexcos);
diff --git a/source/blender/editors/armature/pose_edit.c b/source/blender/editors/armature/pose_edit.c
index 0a886074f42..cf64210ebdb 100644
--- a/source/blender/editors/armature/pose_edit.c
+++ b/source/blender/editors/armature/pose_edit.c
@@ -263,8 +263,9 @@ static int pose_calculate_paths_invoke(bContext *C, wmOperator *op, const wmEven
{
Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
- if (ELEM(NULL, ob, ob->pose))
+ if (ELEM(NULL, ob, ob->pose)) {
return OPERATOR_CANCELLED;
+ }
/* set default settings from existing/stored settings */
{
@@ -291,8 +292,9 @@ static int pose_calculate_paths_exec(bContext *C, wmOperator *op)
Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
Scene *scene = CTX_data_scene(C);
- if (ELEM(NULL, ob, ob->pose))
+ if (ELEM(NULL, ob, ob->pose)) {
return OPERATOR_CANCELLED;
+ }
/* grab baking settings from operator settings */
{
@@ -391,8 +393,9 @@ static int pose_update_paths_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
Scene *scene = CTX_data_scene(C);
- if (ELEM(NULL, ob, scene))
+ if (ELEM(NULL, ob, scene)) {
return OPERATOR_CANCELLED;
+ }
/* calculate the bones that now have motionpaths... */
/* TODO: only make for the selected bones? */
@@ -427,8 +430,9 @@ static void ED_pose_clear_paths(Object *ob, bool only_selected)
bPoseChannel *pchan;
bool skipped = false;
- if (ELEM(NULL, ob, ob->pose))
+ if (ELEM(NULL, ob, ob->pose)) {
return;
+ }
/* free the motionpath blocks for all bones - This is easier for users to quickly clear all */
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
@@ -444,8 +448,9 @@ static void ED_pose_clear_paths(Object *ob, bool only_selected)
}
/* if nothing was skipped, there should be no paths left! */
- if (skipped == false)
+ if (skipped == false) {
ob->pose->avs.path_bakeflag &= ~MOTIONPATH_BAKE_HAS_PATHS;
+ }
/* tag armature object for copy on write - so removed paths don't still show */
DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE);
@@ -458,8 +463,9 @@ static int pose_clear_paths_exec(bContext *C, wmOperator *op)
bool only_selected = RNA_boolean_get(op->ptr, "only_selected");
/* only continue if there's an object */
- if (ELEM(NULL, ob, ob->pose))
+ if (ELEM(NULL, ob, ob->pose)) {
return OPERATOR_CANCELLED;
+ }
/* use the backend function for this */
ED_pose_clear_paths(ob, only_selected);
@@ -735,8 +741,9 @@ static int pose_armature_layers_showall_exec(bContext *C, wmOperator *op)
int i;
/* sanity checking */
- if (arm == NULL)
+ if (arm == NULL) {
return OPERATOR_CANCELLED;
+ }
/* use RNA to set the layers
* although it would be faster to just set directly using bitflags, we still
@@ -744,8 +751,9 @@ static int pose_armature_layers_showall_exec(bContext *C, wmOperator *op)
*/
RNA_id_pointer_create(&arm->id, &ptr);
- for (i = 0; i < maxLayers; i++)
+ for (i = 0; i < maxLayers; i++) {
layers[i] = 1;
+ }
RNA_boolean_set_array(&ptr, "layers", layers);
@@ -788,8 +796,9 @@ static int armature_layers_invoke(bContext *C, wmOperator *op, const wmEvent *ev
bool layers[32];
/* sanity checking */
- if (arm == NULL)
+ if (arm == NULL) {
return OPERATOR_CANCELLED;
+ }
/* Get RNA pointer to armature data to use that to retrieve the layers as ints
* to init the operator. */
diff --git a/source/blender/editors/armature/pose_group.c b/source/blender/editors/armature/pose_group.c
index 0d100a09dfd..3ae9976c948 100644
--- a/source/blender/editors/armature/pose_group.c
+++ b/source/blender/editors/armature/pose_group.c
@@ -59,8 +59,9 @@ static int pose_group_add_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob = ED_pose_object_from_context(C);
/* only continue if there's an object and pose */
- if (ELEM(NULL, ob, ob->pose))
+ if (ELEM(NULL, ob, ob->pose)) {
return OPERATOR_CANCELLED;
+ }
/* for now, just call the API function for this */
BKE_pose_add_group(ob->pose, NULL);
@@ -91,8 +92,9 @@ static int pose_group_remove_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob = ED_pose_object_from_context(C);
/* only continue if there's an object and pose */
- if (ELEM(NULL, ob, ob->pose))
+ if (ELEM(NULL, ob, ob->pose)) {
return OPERATOR_CANCELLED;
+ }
/* for now, just call the API function for this */
BKE_pose_remove_group_index(ob->pose, ob->pose->active_group);
@@ -134,8 +136,9 @@ static int pose_groups_menu_invoke(bContext *C, wmOperator *op, const wmEvent *U
int i;
/* only continue if there's an object, and a pose there too */
- if (ELEM(NULL, ob, ob->pose))
+ if (ELEM(NULL, ob, ob->pose)) {
return OPERATOR_CANCELLED;
+ }
pose = ob->pose;
/* If group index is set, try to use it! */
@@ -164,8 +167,9 @@ static int pose_groups_menu_invoke(bContext *C, wmOperator *op, const wmEvent *U
}
/* add entries for each group */
- for (grp = pose->agroups.first, i = 1; grp; grp = grp->next, i++)
+ for (grp = pose->agroups.first, i = 1; grp; grp = grp->next, i++) {
uiItemIntO(layout, grp->name, ICON_NONE, op->idname, "type", i);
+ }
/* finish building the menu, and process it (should result in calling self again) */
UI_popup_menu_end(C, pup);
@@ -187,8 +191,9 @@ static int pose_group_assign_exec(bContext *C, wmOperator *op)
bool done = false;
/* only continue if there's an object, and a pose there too */
- if (ELEM(NULL, ob, ob->pose))
+ if (ELEM(NULL, ob, ob->pose)) {
return OPERATOR_CANCELLED;
+ }
pose = ob->pose;
@@ -196,8 +201,9 @@ static int pose_group_assign_exec(bContext *C, wmOperator *op)
* - if 0 after this, make a new group...
*/
pose->active_group = RNA_int_get(op->ptr, "type");
- if (pose->active_group == 0)
+ if (pose->active_group == 0) {
BKE_pose_add_group(ob->pose, NULL);
+ }
/* add selected bones to group then */
FOREACH_PCHAN_SELECTED_IN_OBJECT_BEGIN (ob, pchan) {
@@ -211,10 +217,12 @@ static int pose_group_assign_exec(bContext *C, wmOperator *op)
DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE);
/* report done status */
- if (done)
+ if (done) {
return OPERATOR_FINISHED;
- else
+ }
+ else {
return OPERATOR_CANCELLED;
+ }
}
void POSE_OT_group_assign(wmOperatorType *ot)
@@ -242,8 +250,9 @@ static int pose_group_unassign_exec(bContext *C, wmOperator *UNUSED(op))
bool done = false;
/* only continue if there's an object, and a pose there too */
- if (ELEM(NULL, ob, ob->pose))
+ if (ELEM(NULL, ob, ob->pose)) {
return OPERATOR_CANCELLED;
+ }
/* find selected bones to remove from all bone groups */
FOREACH_PCHAN_SELECTED_IN_OBJECT_BEGIN (ob, pchan) {
@@ -259,10 +268,12 @@ static int pose_group_unassign_exec(bContext *C, wmOperator *UNUSED(op))
DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE);
/* report done status */
- if (done)
+ if (done) {
return OPERATOR_FINISHED;
- else
+ }
+ else {
return OPERATOR_CANCELLED;
+ }
}
void POSE_OT_group_unassign(wmOperatorType *ot)
@@ -288,15 +299,18 @@ static int group_move_exec(bContext *C, wmOperator *op)
bActionGroup *grp;
int dir = RNA_enum_get(op->ptr, "direction");
- if (ELEM(NULL, ob, pose))
+ if (ELEM(NULL, ob, pose)) {
return OPERATOR_CANCELLED;
- if (pose->active_group <= 0)
+ }
+ if (pose->active_group <= 0) {
return OPERATOR_CANCELLED;
+ }
/* get group to move */
grp = BLI_findlink(&pose->agroups, pose->active_group - 1);
- if (grp == NULL)
+ if (grp == NULL) {
return OPERATOR_CANCELLED;
+ }
/* move bone group */
if (BLI_listbase_link_move(&pose->agroups, grp, dir)) {
@@ -374,10 +388,12 @@ static int group_sort_exec(bContext *C, wmOperator *UNUSED(op))
int agrp_count;
int i;
- if (ELEM(NULL, ob, pose))
+ if (ELEM(NULL, ob, pose)) {
return OPERATOR_CANCELLED;
- if (pose->active_group <= 0)
+ }
+ if (pose->active_group <= 0) {
return OPERATOR_CANCELLED;
+ }
/* create temporary array with bone groups and indices */
agrp_count = BLI_listbase_count(&pose->agroups);
@@ -439,12 +455,14 @@ static void pose_group_select(Object *ob, bool select)
FOREACH_PCHAN_VISIBLE_IN_OBJECT_BEGIN (ob, pchan) {
if ((pchan->bone->flag & BONE_UNSELECTABLE) == 0) {
if (select) {
- if (pchan->agrp_index == pose->active_group)
+ if (pchan->agrp_index == pose->active_group) {
pchan->bone->flag |= BONE_SELECTED;
+ }
}
else {
- if (pchan->agrp_index == pose->active_group)
+ if (pchan->agrp_index == pose->active_group) {
pchan->bone->flag &= ~BONE_SELECTED;
+ }
}
}
}
@@ -456,8 +474,9 @@ static int pose_group_select_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob = ED_pose_object_from_context(C);
/* only continue if there's an object, and a pose there too */
- if (ELEM(NULL, ob, ob->pose))
+ if (ELEM(NULL, ob, ob->pose)) {
return OPERATOR_CANCELLED;
+ }
pose_group_select(ob, 1);
@@ -489,8 +508,9 @@ static int pose_group_deselect_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob = ED_pose_object_from_context(C);
/* only continue if there's an object, and a pose there too */
- if (ELEM(NULL, ob, ob->pose))
+ if (ELEM(NULL, ob, ob->pose)) {
return OPERATOR_CANCELLED;
+ }
pose_group_select(ob, 0);
diff --git a/source/blender/editors/armature/pose_lib.c b/source/blender/editors/armature/pose_lib.c
index f373f775079..010f1c0e654 100644
--- a/source/blender/editors/armature/pose_lib.c
+++ b/source/blender/editors/armature/pose_lib.c
@@ -105,8 +105,9 @@ static int poselib_get_free_index(bAction *act)
bool changed = false;
/* sanity checks */
- if (ELEM(NULL, act, act->markers.first))
+ if (ELEM(NULL, act, act->markers.first)) {
return 1;
+ }
/* As poses are not stored in chronological order, we must iterate over this list
* a few times until we don't make any new discoveries (mostly about the lower bound).
@@ -135,19 +136,23 @@ static int poselib_get_free_index(bAction *act)
/* - if low is not equal to high, then low+1 is a gap
* - if low is equal to high, then high+1 is the next index (add at end)
*/
- if (low < high)
+ if (low < high) {
return (low + 1);
- else
+ }
+ else {
return (high + 1);
+ }
}
/* returns the active pose for a poselib */
static TimeMarker *poselib_get_active_pose(bAction *act)
{
- if ((act) && (act->active_marker))
+ if ((act) && (act->active_marker)) {
return BLI_findlink(&act->markers, act->active_marker - 1);
- else
+ }
+ else {
return NULL;
+ }
}
/* Get object that Pose Lib should be found on */
@@ -157,15 +162,18 @@ static Object *get_poselib_object(bContext *C)
ScrArea *sa;
/* sanity check */
- if (C == NULL)
+ if (C == NULL) {
return NULL;
+ }
sa = CTX_wm_area(C);
- if (sa && (sa->spacetype == SPACE_PROPERTIES))
+ if (sa && (sa->spacetype == SPACE_PROPERTIES)) {
return ED_object_context(C);
- else
+ }
+ else {
return BKE_object_pose_armature_get(CTX_data_active_object(C));
+ }
}
/* Poll callback for operators that require existing PoseLib data (with poses) to work */
@@ -190,12 +198,14 @@ static bool has_poselib_pose_data_for_editing_poll(bContext *C)
static bAction *poselib_init_new(Main *bmain, Object *ob)
{
/* sanity checks - only for armatures */
- if (ELEM(NULL, ob, ob->pose))
+ if (ELEM(NULL, ob, ob->pose)) {
return NULL;
+ }
/* init object's poselib action (unlink old one if there) */
- if (ob->poselib)
+ if (ob->poselib) {
id_us_min(&ob->poselib->id);
+ }
ob->poselib = BKE_action_add(bmain, "PoseLib");
ob->poselib->idroot = ID_OB;
@@ -206,12 +216,15 @@ static bAction *poselib_init_new(Main *bmain, Object *ob)
/* Initialize a new poselib (checks if that needs to happen) */
static bAction *poselib_validate(Main *bmain, Object *ob)
{
- if (ELEM(NULL, ob, ob->pose))
+ if (ELEM(NULL, ob, ob->pose)) {
return NULL;
- else if (ob->poselib == NULL)
+ }
+ else if (ob->poselib == NULL) {
return poselib_init_new(bmain, ob);
- else
+ }
+ else {
return ob->poselib;
+ }
}
/* ************************************************************* */
@@ -223,8 +236,9 @@ static int poselib_new_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob = get_poselib_object(C);
/* sanity checks */
- if (ob == NULL)
+ if (ob == NULL) {
return OPERATOR_CANCELLED;
+ }
/* new method here deals with the rest... */
poselib_init_new(bmain, ob);
@@ -257,8 +271,9 @@ static int poselib_unlink_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob = get_poselib_object(C);
/* sanity checks */
- if (ELEM(NULL, ob, ob->poselib))
+ if (ELEM(NULL, ob, ob->poselib)) {
return OPERATOR_CANCELLED;
+ }
/* there should be a poselib (we just checked above!), so just lower its user count and remove */
id_us_min(&ob->poselib->id);
@@ -338,10 +353,12 @@ static int poselib_sanitize_exec(bContext *C, wmOperator *op)
for (marker = act->markers.first; marker; marker = markern) {
markern = marker->next;
- if (marker->flag != -1)
+ if (marker->flag != -1) {
BLI_freelinkN(&act->markers, marker);
- else
+ }
+ else {
marker->flag = 0;
+ }
}
/* free temp memory */
@@ -423,8 +440,9 @@ static int poselib_add_menu_invoke(bContext *C, wmOperator *op, const wmEvent *U
uiLayout *layout;
/* sanity check */
- if (ELEM(NULL, ob, pose))
+ if (ELEM(NULL, ob, pose)) {
return OPERATOR_CANCELLED;
+ }
/* start building */
pup = UI_popup_menu_begin(C, op->type->name, ICON_NONE);
@@ -472,8 +490,9 @@ static int poselib_add_exec(bContext *C, wmOperator *op)
char name[64];
/* sanity check (invoke should have checked this anyway) */
- if (ELEM(NULL, ob, pose))
+ if (ELEM(NULL, ob, pose)) {
return OPERATOR_CANCELLED;
+ }
/* get name to give to pose */
RNA_string_get(op->ptr, "name", name);
@@ -955,8 +974,9 @@ static void poselib_backup_posecopy(tPoseLib_PreviewData *pld)
plb->pchan = pchan;
memcpy(&plb->olddata, plb->pchan, sizeof(bPoseChannel));
- if (pchan->prop)
+ if (pchan->prop) {
plb->oldprops = IDP_CopyProperty(pchan->prop);
+ }
BLI_addtail(&pld->backups, plb);
@@ -976,8 +996,9 @@ static void poselib_backup_restore(tPoseLib_PreviewData *pld)
memcpy(plb->pchan, &plb->olddata, sizeof(bPoseChannel));
/* just overwrite values of properties from the stored copies (there should be some) */
- if (plb->oldprops)
+ if (plb->oldprops) {
IDP_SyncGroupValues(plb->pchan->prop, plb->oldprops);
+ }
/* TODO: constraints settings aren't restored yet,
* even though these could change (though not that likely) */
@@ -1025,10 +1046,12 @@ static void poselib_apply_pose(tPoseLib_PreviewData *pld)
const bool any_bone_selected = pld->flag & PL_PREVIEW_ANY_BONE_SELECTED;
/* get the frame */
- if (pld->marker)
+ if (pld->marker) {
frame = pld->marker->frame;
- else
+ }
+ else {
return;
+ }
/* init settings for testing groups for keyframes */
group_ok_cb = ANIM_editkeyframes_ok(BEZT_OK_FRAMERANGE);
@@ -1059,8 +1082,9 @@ static void poselib_apply_pose(tPoseLib_PreviewData *pld)
}
}
- if (ok)
+ if (ok) {
animsys_evaluate_action_group(ptr, act, agrp, (float)frame);
+ }
}
}
}
@@ -1091,13 +1115,15 @@ static void poselib_keytag_pose(bContext *C, Scene *scene, tPoseLib_PreviewData
ANIM_relative_keyingset_add_source(&dsources, &pld->ob->id, &RNA_PoseBone, pchan);
/* clear any unkeyed tags */
- if (pchan->bone)
+ if (pchan->bone) {
pchan->bone->flag &= ~BONE_UNKEYED;
+ }
}
else {
/* add unkeyed tags */
- if (pchan->bone)
+ if (pchan->bone) {
pchan->bone->flag |= BONE_UNKEYED;
+ }
}
}
}
@@ -1122,27 +1148,32 @@ static void poselib_preview_apply(bContext *C, wmOperator *op)
/* only recalc pose (and its dependencies) if pose has changed */
if (pld->redraw == PL_PREVIEW_REDRAWALL) {
/* don't clear pose if firsttime */
- if ((pld->flag & PL_PREVIEW_FIRSTTIME) == 0)
+ if ((pld->flag & PL_PREVIEW_FIRSTTIME) == 0) {
poselib_backup_restore(pld);
- else
+ }
+ else {
pld->flag &= ~PL_PREVIEW_FIRSTTIME;
+ }
/* pose should be the right one to draw (unless we're temporarily not showing it) */
if ((pld->flag & PL_PREVIEW_SHOWORIGINAL) == 0) {
RNA_int_set(op->ptr, "pose_index", BLI_findindex(&pld->act->markers, pld->marker));
poselib_apply_pose(pld);
}
- else
+ else {
RNA_int_set(op->ptr, "pose_index", -2); /* -2 means don't apply any pose */
+ }
/* old optimize trick... this enforces to bypass the depsgraph
* - note: code copied from transform_generics.c -> recalcData()
*/
// FIXME: shouldn't this use the builtin stuff?
- if ((pld->arm->flag & ARM_DELAYDEFORM) == 0)
+ if ((pld->arm->flag & ARM_DELAYDEFORM) == 0) {
DEG_id_tag_update(&pld->ob->id, ID_RECALC_GEOMETRY); /* sets recalc flags */
- else
+ }
+ else {
BKE_pose_where_is(CTX_data_depsgraph(C), pld->scene, pld->ob);
+ }
}
/* do header print - if interactively previewing */
@@ -1203,8 +1234,9 @@ static void poselib_preview_apply(bContext *C, wmOperator *op)
static void poselib_preview_get_next(tPoseLib_PreviewData *pld, int step)
{
/* stop if not going anywhere, as we assume that there is a direction to move in */
- if (step == 0)
+ if (step == 0) {
return;
+ }
/* search-string dictates a special approach */
if (pld->searchstr[0]) {
@@ -1242,50 +1274,59 @@ static void poselib_preview_get_next(tPoseLib_PreviewData *pld, int step)
/* find first match */
for (ldc = pld->searchp.first; ldc; ldc = ldc->next) {
- if (ldc->data == pld->marker)
+ if (ldc->data == pld->marker) {
break;
+ }
}
- if (ldc == NULL)
+ if (ldc == NULL) {
ldc = pld->searchp.first;
+ }
/* Loop through the matches in a cyclic fashion, incrementing/decrementing step as appropriate
* until step == 0. At this point, marker should be the correct marker.
*/
if (step > 0) {
- for (ld = ldc; ld && step; ld = ldn, step--)
+ for (ld = ldc; ld && step; ld = ldn, step--) {
ldn = (ld->next) ? ld->next : pld->searchp.first;
+ }
}
else {
- for (ld = ldc; ld && step; ld = ldn, step++)
+ for (ld = ldc; ld && step; ld = ldn, step++) {
ldn = (ld->prev) ? ld->prev : pld->searchp.last;
+ }
}
/* set marker */
- if (ld)
+ if (ld) {
pld->marker = ld->data;
+ }
}
else {
TimeMarker *marker, *next;
/* if no marker, because we just ended searching, then set that to the start of the list */
- if (pld->marker == NULL)
+ if (pld->marker == NULL) {
pld->marker = pld->act->markers.first;
+ }
/* Loop through the markers in a cyclic fashion, incrementing/decrementing step as appropriate
* until step == 0. At this point, marker should be the correct marker.
*/
if (step > 0) {
- for (marker = pld->marker; marker && step; marker = next, step--)
+ for (marker = pld->marker; marker && step; marker = next, step--) {
next = (marker->next) ? marker->next : pld->act->markers.first;
+ }
}
else {
- for (marker = pld->marker; marker && step; marker = next, step++)
+ for (marker = pld->marker; marker && step; marker = next, step++) {
next = (marker->prev) ? marker->prev : pld->act->markers.last;
+ }
}
/* it should be fairly impossible for marker to be NULL */
- if (marker)
+ if (marker) {
pld->marker = marker;
+ }
}
}
@@ -1302,8 +1343,9 @@ static void poselib_preview_handle_search(tPoseLib_PreviewData *pld,
short index = pld->search_cursor;
short i;
- for (i = index; i <= len; i++)
+ for (i = index; i <= len; i++) {
pld->searchstr[i - 1] = pld->searchstr[i];
+ }
pld->search_cursor--;
@@ -1320,8 +1362,9 @@ static void poselib_preview_handle_search(tPoseLib_PreviewData *pld,
int i;
if (index < len) {
- for (i = index; i < len; i++)
+ for (i = index; i < len; i++) {
pld->searchstr[i] = pld->searchstr[i + 1];
+ }
poselib_preview_get_next(pld, 1);
pld->redraw = PL_PREVIEW_REDRAWALL;
@@ -1338,11 +1381,13 @@ static void poselib_preview_handle_search(tPoseLib_PreviewData *pld,
short i;
if (len) {
- for (i = len; i > index; i--)
+ for (i = len; i > index; i--) {
pld->searchstr[i] = pld->searchstr[i - 1];
+ }
}
- else
+ else {
pld->searchstr[1] = 0;
+ }
pld->searchstr[index] = ascii;
pld->search_cursor++;
@@ -1476,8 +1521,9 @@ static int poselib_preview_handle_event(bContext *UNUSED(C), wmOperator *op, con
case RIGHTARROWKEY:
if (pld->searchstr[0]) {
/* move text-cursor to the right */
- if (pld->search_cursor < strlen(pld->searchstr))
+ if (pld->search_cursor < strlen(pld->searchstr)) {
pld->search_cursor++;
+ }
pld->redraw = PL_PREVIEW_REDRAWHEADER;
}
else {
@@ -1491,8 +1537,9 @@ static int poselib_preview_handle_event(bContext *UNUSED(C), wmOperator *op, con
case LEFTARROWKEY:
if (pld->searchstr[0]) {
/* move text-cursor to the left */
- if (pld->search_cursor)
+ if (pld->search_cursor) {
pld->search_cursor--;
+ }
pld->redraw = PL_PREVIEW_REDRAWHEADER;
}
else {
@@ -1597,12 +1644,15 @@ static void poselib_preview_init_data(bContext *C, wmOperator *op)
pld->sa = CTX_wm_area(C);
/* get starting pose based on RNA-props for this operator */
- if (pose_index == -1)
+ if (pose_index == -1) {
pld->marker = poselib_get_active_pose(pld->act);
- else if (pose_index == -2)
+ }
+ else if (pose_index == -2) {
pld->flag |= PL_PREVIEW_SHOWORIGINAL;
- else
+ }
+ else {
pld->marker = (pld->act) ? BLI_findlink(&pld->act->markers, pose_index) : NULL;
+ }
/* check if valid poselib */
if (ELEM(NULL, pld->ob, pld->pose, pld->arm)) {
@@ -1619,8 +1669,9 @@ static void poselib_preview_init_data(bContext *C, wmOperator *op)
if (pld->act->markers.first) {
/* just use first one then... */
pld->marker = pld->act->markers.first;
- if (pose_index > -2)
+ if (pose_index > -2) {
BKE_report(op->reports, RPT_WARNING, "Pose lib had no active pose");
+ }
}
else {
BKE_report(op->reports, RPT_ERROR, "Pose lib has no poses to preview/apply");
@@ -1675,10 +1726,12 @@ static void poselib_preview_cleanup(bContext *C, wmOperator *op)
/* old optimize trick... this enforces to bypass the depgraph
* - note: code copied from transform_generics.c -> recalcData()
*/
- if ((arm->flag & ARM_DELAYDEFORM) == 0)
+ if ((arm->flag & ARM_DELAYDEFORM) == 0) {
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); /* sets recalc flags */
- else
+ }
+ else {
BKE_pose_where_is(CTX_data_depsgraph(C), scene, ob);
+ }
}
else if (pld->state == PL_PREVIEW_CONFIRM) {
/* tag poses as appropriate */
@@ -1695,8 +1748,9 @@ static void poselib_preview_cleanup(bContext *C, wmOperator *op)
if (IS_AUTOKEY_MODE(scene, NORMAL)) {
//remake_action_ipos(ob->action);
}
- else
+ else {
BKE_pose_where_is(CTX_data_depsgraph(C), scene, ob);
+ }
}
/* Request final redraw of the view. */
@@ -1720,10 +1774,12 @@ static int poselib_preview_exit(bContext *C, wmOperator *op)
/* finish up */
poselib_preview_cleanup(C, op);
- if (ELEM(exit_state, PL_PREVIEW_CANCEL, PL_PREVIEW_ERROR))
+ if (ELEM(exit_state, PL_PREVIEW_CANCEL, PL_PREVIEW_ERROR)) {
return OPERATOR_CANCELLED;
- else
+ }
+ else {
return OPERATOR_FINISHED;
+ }
}
/* Cancel previewing operation (called when exiting Blender) */
@@ -1739,15 +1795,17 @@ static int poselib_preview_modal(bContext *C, wmOperator *op, const wmEvent *eve
int ret;
/* 1) check state to see if we're still running */
- if (pld->state != PL_PREVIEW_RUNNING)
+ if (pld->state != PL_PREVIEW_RUNNING) {
return poselib_preview_exit(C, op);
+ }
/* 2) handle events */
ret = poselib_preview_handle_event(C, op, event);
/* 3) apply changes and redraw, otherwise, confirming goes wrong */
- if (pld->redraw)
+ if (pld->redraw) {
poselib_preview_apply(C, op);
+ }
return ret;
}
diff --git a/source/blender/editors/armature/pose_select.c b/source/blender/editors/armature/pose_select.c
index d26eb7e904d..e9ea49aaf03 100644
--- a/source/blender/editors/armature/pose_select.c
+++ b/source/blender/editors/armature/pose_select.c
@@ -71,8 +71,9 @@ static void pose_do_bone_select(bPoseChannel *pchan, const int select_mode)
/* select pchan only if selectable, but deselect works always */
switch (select_mode) {
case SEL_SELECT:
- if (!(pchan->bone->flag & BONE_UNSELECTABLE))
+ if (!(pchan->bone->flag & BONE_UNSELECTABLE)) {
pchan->bone->flag |= BONE_SELECTED;
+ }
break;
case SEL_DESELECT:
pchan->bone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
@@ -110,8 +111,9 @@ void ED_pose_bone_select(Object *ob, bPoseChannel *pchan, bool select)
/* sanity checks */
// XXX: actually, we can probably still get away with no object - at most we have no updates
- if (ELEM(NULL, ob, ob->pose, pchan, pchan->bone))
+ if (ELEM(NULL, ob, ob->pose, pchan, pchan->bone)) {
return;
+ }
arm = ob->data;
@@ -147,8 +149,9 @@ bool ED_armature_pose_select_pick_with_buffer(ViewLayer *view_layer,
Object *ob = base->object;
Bone *nearBone;
- if (!ob || !ob->pose)
+ if (!ob || !ob->pose) {
return 0;
+ }
Object *ob_act = OBACT(view_layer);
Object *obedit = OBEDIT_FROM_VIEW_LAYER(view_layer);
@@ -346,16 +349,20 @@ static void selectconnected_posebonechildren(Object *ob, Bone *bone, int extend)
Bone *curBone;
/* stop when unconnected child is encountered, or when unselectable bone is encountered */
- if (!(bone->flag & BONE_CONNECTED) || (bone->flag & BONE_UNSELECTABLE))
+ if (!(bone->flag & BONE_CONNECTED) || (bone->flag & BONE_UNSELECTABLE)) {
return;
+ }
- if (extend)
+ if (extend) {
bone->flag &= ~BONE_SELECTED;
- else
+ }
+ else {
bone->flag |= BONE_SELECTED;
+ }
- for (curBone = bone->childbase.first; curBone; curBone = curBone->next)
+ for (curBone = bone->childbase.first; curBone; curBone = curBone->next) {
selectconnected_posebonechildren(ob, curBone, extend);
+ }
}
/* within active object context */
@@ -370,30 +377,37 @@ static int pose_select_connected_invoke(bContext *C, wmOperator *op, const wmEve
Base *base = NULL;
bone = get_nearest_bone(C, event->mval, !extend, &base);
- if (!bone)
+ if (!bone) {
return OPERATOR_CANCELLED;
+ }
/* Select parents */
for (curBone = bone; curBone; curBone = next) {
/* ignore bone if cannot be selected */
if ((curBone->flag & BONE_UNSELECTABLE) == 0) {
- if (extend)
+ if (extend) {
curBone->flag &= ~BONE_SELECTED;
- else
+ }
+ else {
curBone->flag |= BONE_SELECTED;
+ }
- if (curBone->flag & BONE_CONNECTED)
+ if (curBone->flag & BONE_CONNECTED) {
next = curBone->parent;
- else
+ }
+ else {
next = NULL;
+ }
}
- else
+ else {
next = NULL;
+ }
}
/* Select children */
- for (curBone = bone->childbase.first; curBone; curBone = next)
+ for (curBone = bone->childbase.first; curBone; curBone = next) {
selectconnected_posebonechildren(base->object, curBone, extend);
+ }
ED_pose_bone_select_tag_update(base->object);
@@ -557,16 +571,18 @@ static int pose_select_constraint_target_exec(bContext *C, wmOperator *UNUSED(op
}
}
- if (cti->flush_constraint_targets)
+ if (cti->flush_constraint_targets) {
cti->flush_constraint_targets(con, &targets, 1);
+ }
}
}
}
}
CTX_DATA_END;
- if (!found)
+ if (!found) {
return OPERATOR_CANCELLED;
+ }
return OPERATOR_FINISHED;
}
@@ -828,12 +844,14 @@ static bool pose_select_same_layer(bContext *C, bool extend)
}
/* Keep track of layers to use later? */
- if (pchan->bone->flag & BONE_SELECTED)
+ if (pchan->bone->flag & BONE_SELECTED) {
*layers |= pchan->bone->layer;
+ }
/* Deselect all bones before selecting new ones? */
- if ((extend == false) && (pchan->bone->flag & BONE_UNSELECTABLE) == 0)
+ if ((extend == false) && (pchan->bone->flag & BONE_UNSELECTABLE) == 0) {
pchan->bone->flag &= ~BONE_SELECTED;
+ }
}
CTX_DATA_END;
@@ -912,8 +930,9 @@ static bool pose_select_same_keyingset(bContext *C, ReportList *reports, bool ex
/* if not extending selection, deselect all selected first */
if (extend == false) {
CTX_DATA_BEGIN (C, bPoseChannel *, pchan, visible_pose_bones) {
- if ((pchan->bone->flag & BONE_UNSELECTABLE) == 0)
+ if ((pchan->bone->flag & BONE_UNSELECTABLE) == 0) {
pchan->bone->flag &= ~BONE_SELECTED;
+ }
}
CTX_DATA_END;
}
@@ -977,8 +996,9 @@ static int pose_select_grouped_exec(bContext *C, wmOperator *op)
bool changed = false;
/* sanity check */
- if (ob->pose == NULL)
+ if (ob->pose == NULL) {
return OPERATOR_CANCELLED;
+ }
/* selection types */
switch (type) {
@@ -1000,10 +1020,12 @@ static int pose_select_grouped_exec(bContext *C, wmOperator *op)
}
/* report done status */
- if (changed)
+ if (changed) {
return OPERATOR_FINISHED;
- else
+ }
+ else {
return OPERATOR_CANCELLED;
+ }
}
void POSE_OT_select_grouped(wmOperatorType *ot)
diff --git a/source/blender/editors/armature/pose_slide.c b/source/blender/editors/armature/pose_slide.c
index 7bc934e07a2..79182a89096 100644
--- a/source/blender/editors/armature/pose_slide.c
+++ b/source/blender/editors/armature/pose_slide.c
@@ -459,8 +459,9 @@ static void pose_slide_apply_props(tPoseSlideOp *pso,
FCurve *fcu = (FCurve *)ld->data;
const char *bPtr, *pPtr;
- if (fcu->rna_path == NULL)
+ if (fcu->rna_path == NULL) {
continue;
+ }
/* do we have a match?
* - bPtr is the RNA Path with the standard part chopped off
@@ -1209,8 +1210,9 @@ static int pose_slide_push_invoke(bContext *C, wmOperator *op, const wmEvent *ev
pose_slide_exit(op);
return OPERATOR_CANCELLED;
}
- else
+ else {
pso = op->customdata;
+ }
/* initialise percentage so that it won't pop on first mouse move */
pose_slide_mouse_update_percentage(pso, op, event);
@@ -1229,8 +1231,9 @@ static int pose_slide_push_exec(bContext *C, wmOperator *op)
pose_slide_exit(op);
return OPERATOR_CANCELLED;
}
- else
+ else {
pso = op->customdata;
+ }
/* do common exec work */
return pose_slide_exec_common(C, op, pso);
@@ -1269,8 +1272,9 @@ static int pose_slide_relax_invoke(bContext *C, wmOperator *op, const wmEvent *e
pose_slide_exit(op);
return OPERATOR_CANCELLED;
}
- else
+ else {
pso = op->customdata;
+ }
/* initialise percentage so that it won't pop on first mouse move */
pose_slide_mouse_update_percentage(pso, op, event);
@@ -1289,8 +1293,9 @@ static int pose_slide_relax_exec(bContext *C, wmOperator *op)
pose_slide_exit(op);
return OPERATOR_CANCELLED;
}
- else
+ else {
pso = op->customdata;
+ }
/* do common exec work */
return pose_slide_exec_common(C, op, pso);
@@ -1329,8 +1334,9 @@ static int pose_slide_breakdown_invoke(bContext *C, wmOperator *op, const wmEven
pose_slide_exit(op);
return OPERATOR_CANCELLED;
}
- else
+ else {
pso = op->customdata;
+ }
/* initialise percentage so that it won't pop on first mouse move */
pose_slide_mouse_update_percentage(pso, op, event);
@@ -1349,8 +1355,9 @@ static int pose_slide_breakdown_exec(bContext *C, wmOperator *op)
pose_slide_exit(op);
return OPERATOR_CANCELLED;
}
- else
+ else {
pso = op->customdata;
+ }
/* do common exec work */
return pose_slide_exec_common(C, op, pso);
@@ -1565,15 +1572,17 @@ static void pose_propagate_fcurve(
short first = 1;
/* skip if no keyframes to edit */
- if ((fcu->bezt == NULL) || (fcu->totvert < 2))
+ if ((fcu->bezt == NULL) || (fcu->totvert < 2)) {
return;
+ }
/* find the reference value from bones directly, which means that the user
* doesn't need to firstly keyframe the pose (though this doesn't mean that
* they can't either)
*/
- if (!pose_propagate_get_refVal(ob, fcu, &refVal))
+ if (!pose_propagate_get_refVal(ob, fcu, &refVal)) {
return;
+ }
/* find the first keyframe to start propagating from
* - if there's a keyframe on the current frame, we probably want to save this value there too
@@ -1585,10 +1594,12 @@ static void pose_propagate_fcurve(
if (mode != POSE_PROPAGATE_SELECTED_KEYS) {
match = binarysearch_bezt_index(fcu->bezt, startFrame, fcu->totvert, &keyExists);
- if (fcu->bezt[match].vec[1][0] < startFrame)
+ if (fcu->bezt[match].vec[1][0] < startFrame) {
i = match + 1;
- else
+ }
+ else {
i = match;
+ }
}
else {
/* selected - start from first keyframe */
@@ -1599,18 +1610,21 @@ static void pose_propagate_fcurve(
/* additional termination conditions based on the operator 'mode' property go here... */
if (ELEM(mode, POSE_PROPAGATE_BEFORE_FRAME, POSE_PROPAGATE_SMART_HOLDS)) {
/* stop if keyframe is outside the accepted range */
- if (bezt->vec[1][0] > modeData.end_frame)
+ if (bezt->vec[1][0] > modeData.end_frame) {
break;
+ }
}
else if (mode == POSE_PROPAGATE_NEXT_KEY) {
/* stop after the first keyframe has been processed */
- if (first == 0)
+ if (first == 0) {
break;
+ }
}
else if (mode == POSE_PROPAGATE_LAST_KEY) {
/* only affect this frame if it will be the last one */
- if (i != (fcu->totvert - 1))
+ if (i != (fcu->totvert - 1)) {
continue;
+ }
}
else if (mode == POSE_PROPAGATE_SELECTED_MARKERS) {
/* only allow if there's a marker on this frame */
@@ -1618,18 +1632,21 @@ static void pose_propagate_fcurve(
/* stop on matching marker if there is one */
for (ce = modeData.sel_markers.first; ce; ce = ce->next) {
- if (ce->cfra == round_fl_to_int(bezt->vec[1][0]))
+ if (ce->cfra == round_fl_to_int(bezt->vec[1][0])) {
break;
+ }
}
/* skip this keyframe if no marker */
- if (ce == NULL)
+ if (ce == NULL) {
continue;
+ }
}
else if (mode == POSE_PROPAGATE_SELECTED_KEYS) {
/* only allow if this keyframe is already selected - skip otherwise */
- if (BEZT_ISSEL_ANY(bezt) == 0)
+ if (BEZT_ISSEL_ANY(bezt) == 0) {
continue;
+ }
}
/* just flatten handles, since values will now be the same either side... */
@@ -1698,8 +1715,9 @@ static int pose_propagate_exec(bContext *C, wmOperator *op)
/* free temp data */
poseAnim_mapping_free(&pflinks);
- if (mode == POSE_PROPAGATE_SELECTED_MARKERS)
+ if (mode == POSE_PROPAGATE_SELECTED_MARKERS) {
BLI_freelistN(&modeData.sel_markers);
+ }
/* updates + notifiers */
FOREACH_OBJECT_IN_MODE_BEGIN (view_layer, v3d, OB_ARMATURE, OB_MODE_POSE, ob) {
diff --git a/source/blender/editors/armature/pose_transform.c b/source/blender/editors/armature/pose_transform.c
index 824e8b1a327..91f0bdc51ad 100644
--- a/source/blender/editors/armature/pose_transform.c
+++ b/source/blender/editors/armature/pose_transform.c
@@ -102,8 +102,9 @@ static int apply_armature_pose2bones_exec(bContext *C, wmOperator *op)
EditBone *curbone;
/* don't check if editmode (should be done by caller) */
- if (ob->type != OB_ARMATURE)
+ if (ob->type != OB_ARMATURE) {
return OPERATOR_CANCELLED;
+ }
if (BKE_object_obdata_is_libdata(ob)) {
BKE_report(op->reports, RPT_ERROR, "Cannot apply pose to lib-linked armature");
return OPERATOR_CANCELLED;
@@ -111,11 +112,12 @@ static int apply_armature_pose2bones_exec(bContext *C, wmOperator *op)
/* helpful warnings... */
/* TODO: add warnings to be careful about actions, applying deforms first, etc. */
- if (ob->adt && ob->adt->action)
+ if (ob->adt && ob->adt->action) {
BKE_report(op->reports,
RPT_WARNING,
"Actions on this armature will be destroyed by this new rest pose as the "
"transforms stored are relative to the old rest pose");
+ }
/* Get editbones of active armature to alter */
ED_armature_to_edit(arm);
@@ -293,10 +295,12 @@ static void set_pose_keys(Object *ob)
if (ob->pose) {
for (chan = ob->pose->chanbase.first; chan; chan = chan->next) {
Bone *bone = chan->bone;
- if ((bone) && (bone->flag & BONE_SELECTED) && (arm->layer & bone->layer))
+ if ((bone) && (bone->flag & BONE_SELECTED) && (arm->layer & bone->layer)) {
chan->flag |= POSE_KEY;
- else
+ }
+ else {
chan->flag &= ~POSE_KEY;
+ }
}
}
}
@@ -320,10 +324,12 @@ static bPoseChannel *pose_bone_do_paste(Object *ob,
short paste_ok;
/* get the name - if flipping, we must flip this first */
- if (flip)
+ if (flip) {
BLI_string_flip_side_name(name, chan->name, false, sizeof(name));
- else
+ }
+ else {
BLI_strncpy(name, chan->name, sizeof(name));
+ }
/* only copy when:
* 1) channel exists - poses are not meant to add random channels to anymore
@@ -332,10 +338,12 @@ static bPoseChannel *pose_bone_do_paste(Object *ob,
*/
pchan = BKE_pose_channel_find_name(ob->pose, name);
- if (selOnly)
+ if (selOnly) {
paste_ok = ((pchan) && (pchan->bone->flag & BONE_SELECTED));
- else
+ }
+ else {
paste_ok = (pchan != NULL);
+ }
/* continue? */
if (paste_ok) {
@@ -362,24 +370,30 @@ static bPoseChannel *pose_bone_do_paste(Object *ob,
}
else if (pchan->rotmode > 0) {
/* quat/axis-angle to euler */
- if (chan->rotmode == ROT_MODE_AXISANGLE)
+ if (chan->rotmode == ROT_MODE_AXISANGLE) {
axis_angle_to_eulO(pchan->eul, pchan->rotmode, chan->rotAxis, chan->rotAngle);
- else
+ }
+ else {
quat_to_eulO(pchan->eul, pchan->rotmode, chan->quat);
+ }
}
else if (pchan->rotmode == ROT_MODE_AXISANGLE) {
/* quat/euler to axis angle */
- if (chan->rotmode > 0)
+ if (chan->rotmode > 0) {
eulO_to_axis_angle(pchan->rotAxis, &pchan->rotAngle, chan->eul, chan->rotmode);
- else
+ }
+ else {
quat_to_axis_angle(pchan->rotAxis, &pchan->rotAngle, chan->quat);
+ }
}
else {
/* euler/axis-angle to quat */
- if (chan->rotmode > 0)
+ if (chan->rotmode > 0) {
eulO_to_quat(pchan->quat, chan->eul, chan->rotmode);
- else
+ }
+ else {
axis_angle_to_quat(pchan->quat, chan->rotAxis, pchan->rotAngle);
+ }
}
/* B-Bone posing options should also be included... */
@@ -628,12 +642,15 @@ void POSE_OT_paste(wmOperatorType *ot)
/* clear scale of pose-channel */
static void pchan_clear_scale(bPoseChannel *pchan)
{
- if ((pchan->protectflag & OB_LOCK_SCALEX) == 0)
+ if ((pchan->protectflag & OB_LOCK_SCALEX) == 0) {
pchan->size[0] = 1.0f;
- if ((pchan->protectflag & OB_LOCK_SCALEY) == 0)
+ }
+ if ((pchan->protectflag & OB_LOCK_SCALEY) == 0) {
pchan->size[1] = 1.0f;
- if ((pchan->protectflag & OB_LOCK_SCALEZ) == 0)
+ }
+ if ((pchan->protectflag & OB_LOCK_SCALEZ) == 0) {
pchan->size[2] = 1.0f;
+ }
pchan->ease1 = 0.0f;
pchan->ease2 = 0.0f;
@@ -644,12 +661,15 @@ static void pchan_clear_scale(bPoseChannel *pchan)
/* clear location of pose-channel */
static void pchan_clear_loc(bPoseChannel *pchan)
{
- if ((pchan->protectflag & OB_LOCK_LOCX) == 0)
+ if ((pchan->protectflag & OB_LOCK_LOCX) == 0) {
pchan->loc[0] = 0.0f;
- if ((pchan->protectflag & OB_LOCK_LOCY) == 0)
+ }
+ if ((pchan->protectflag & OB_LOCK_LOCY) == 0) {
pchan->loc[1] = 0.0f;
- if ((pchan->protectflag & OB_LOCK_LOCZ) == 0)
+ }
+ if ((pchan->protectflag & OB_LOCK_LOCZ) == 0) {
pchan->loc[2] = 0.0f;
+ }
}
/* clear rotation of pose-channel */
@@ -660,39 +680,51 @@ static void pchan_clear_rot(bPoseChannel *pchan)
if (pchan->protectflag & OB_LOCK_ROT4D) {
/* perform clamping on a component by component basis */
if (pchan->rotmode == ROT_MODE_AXISANGLE) {
- if ((pchan->protectflag & OB_LOCK_ROTW) == 0)
+ if ((pchan->protectflag & OB_LOCK_ROTW) == 0) {
pchan->rotAngle = 0.0f;
- if ((pchan->protectflag & OB_LOCK_ROTX) == 0)
+ }
+ if ((pchan->protectflag & OB_LOCK_ROTX) == 0) {
pchan->rotAxis[0] = 0.0f;
- if ((pchan->protectflag & OB_LOCK_ROTY) == 0)
+ }
+ if ((pchan->protectflag & OB_LOCK_ROTY) == 0) {
pchan->rotAxis[1] = 0.0f;
- if ((pchan->protectflag & OB_LOCK_ROTZ) == 0)
+ }
+ if ((pchan->protectflag & OB_LOCK_ROTZ) == 0) {
pchan->rotAxis[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(pchan->rotAxis[0], pchan->rotAxis[1]) &&
- IS_EQF(pchan->rotAxis[1], pchan->rotAxis[2]))
+ IS_EQF(pchan->rotAxis[1], pchan->rotAxis[2])) {
pchan->rotAxis[1] = 1.0f;
+ }
}
else if (pchan->rotmode == ROT_MODE_QUAT) {
- if ((pchan->protectflag & OB_LOCK_ROTW) == 0)
+ if ((pchan->protectflag & OB_LOCK_ROTW) == 0) {
pchan->quat[0] = 1.0f;
- if ((pchan->protectflag & OB_LOCK_ROTX) == 0)
+ }
+ if ((pchan->protectflag & OB_LOCK_ROTX) == 0) {
pchan->quat[1] = 0.0f;
- if ((pchan->protectflag & OB_LOCK_ROTY) == 0)
+ }
+ if ((pchan->protectflag & OB_LOCK_ROTY) == 0) {
pchan->quat[2] = 0.0f;
- if ((pchan->protectflag & OB_LOCK_ROTZ) == 0)
+ }
+ if ((pchan->protectflag & OB_LOCK_ROTZ) == 0) {
pchan->quat[3] = 0.0f;
+ }
}
else {
/* the flag may have been set for the other modes, so just ignore the extra flag... */
- if ((pchan->protectflag & OB_LOCK_ROTX) == 0)
+ if ((pchan->protectflag & OB_LOCK_ROTX) == 0) {
pchan->eul[0] = 0.0f;
- if ((pchan->protectflag & OB_LOCK_ROTY) == 0)
+ }
+ if ((pchan->protectflag & OB_LOCK_ROTY) == 0) {
pchan->eul[1] = 0.0f;
- if ((pchan->protectflag & OB_LOCK_ROTZ) == 0)
+ }
+ if ((pchan->protectflag & OB_LOCK_ROTZ) == 0) {
pchan->eul[2] = 0.0f;
+ }
}
}
else {
@@ -713,12 +745,15 @@ static void pchan_clear_rot(bPoseChannel *pchan)
eul[0] = eul[1] = eul[2] = 0.0f;
- if (pchan->protectflag & OB_LOCK_ROTX)
+ if (pchan->protectflag & OB_LOCK_ROTX) {
eul[0] = oldeul[0];
- if (pchan->protectflag & OB_LOCK_ROTY)
+ }
+ if (pchan->protectflag & OB_LOCK_ROTY) {
eul[1] = oldeul[1];
- if (pchan->protectflag & OB_LOCK_ROTZ)
+ }
+ if (pchan->protectflag & OB_LOCK_ROTZ) {
eul[2] = oldeul[2];
+ }
if (pchan->rotmode == ROT_MODE_QUAT) {
eul_to_quat(pchan->quat, eul);
diff --git a/source/blender/editors/armature/pose_utils.c b/source/blender/editors/armature/pose_utils.c
index 844fce49d28..2b7bd9ea05a 100644
--- a/source/blender/editors/armature/pose_utils.c
+++ b/source/blender/editors/armature/pose_utils.c
@@ -91,14 +91,18 @@ static void fcurves_to_pchan_links_get(ListBase *pfLinks,
BLI_addtail(pfLinks, pfl);
/* set pchan's transform flags */
- if (transFlags & ACT_TRANS_LOC)
+ if (transFlags & ACT_TRANS_LOC) {
pchan->flag |= POSE_LOC;
- if (transFlags & ACT_TRANS_ROT)
+ }
+ if (transFlags & ACT_TRANS_ROT) {
pchan->flag |= POSE_ROT;
- if (transFlags & ACT_TRANS_SCALE)
+ }
+ if (transFlags & ACT_TRANS_SCALE) {
pchan->flag |= POSE_SIZE;
- if (transFlags & ACT_TRANS_BBONE)
+ }
+ if (transFlags & ACT_TRANS_BBONE) {
pchan->flag |= POSE_BBONE_SHAPE;
+ }
/* store current transforms */
copy_v3_v3(pfl->oldloc, pchan->loc);
@@ -121,8 +125,9 @@ static void fcurves_to_pchan_links_get(ListBase *pfLinks,
pfl->scaleOut = pchan->scaleOut;
/* make copy of custom properties */
- if (pchan->prop && (transFlags & ACT_TRANS_PROP))
+ if (pchan->prop && (transFlags & ACT_TRANS_PROP)) {
pfl->oldprops = IDP_CopyProperty(pchan->prop);
+ }
}
}
@@ -222,10 +227,12 @@ void poseAnim_mapping_refresh(bContext *C, Scene *scene, Object *ob)
* - note: code copied from transform_generics.c -> recalcData()
*/
/* FIXME: shouldn't this use the builtin stuff? */
- if ((arm->flag & ARM_DELAYDEFORM) == 0)
+ if ((arm->flag & ARM_DELAYDEFORM) == 0) {
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); /* sets recalc flags */
- else
+ }
+ else {
BKE_pose_where_is(depsgraph, scene, ob);
+ }
/* otherwise animation doesn't get updated */
DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE);
@@ -262,8 +269,9 @@ void poseAnim_mapping_reset(ListBase *pfLinks)
pchan->scaleOut = pfl->scaleOut;
/* just overwrite values of properties from the stored copies (there should be some) */
- if (pfl->oldprops)
+ if (pfl->oldprops) {
IDP_SyncGroupValues(pfl->pchan->prop, pfl->oldprops);
+ }
}
}
@@ -353,8 +361,9 @@ LinkData *poseAnim_mapping_getNextFCurve(ListBase *fcuLinks, LinkData *prev, con
FCurve *fcu = (FCurve *)ld->data;
/* check if paths match */
- if (STREQ(path, fcu->rna_path))
+ if (STREQ(path, fcu->rna_path)) {
return ld;
+ }
}
/* none found */
diff --git a/source/blender/editors/gizmo_library/gizmo_library_utils.c b/source/blender/editors/gizmo_library/gizmo_library_utils.c
index 2e5c3b37542..1f61c45eb80 100644
--- a/source/blender/editors/gizmo_library/gizmo_library_utils.c
+++ b/source/blender/editors/gizmo_library/gizmo_library_utils.c
@@ -68,9 +68,10 @@ float gizmo_offset_from_value(GizmoCommonData *data,
const bool constrained,
const bool inverted)
{
- if (constrained)
+ if (constrained) {
return gizmo_offset_from_value_constr(
data->range_fac, data->min, data->range, value, inverted);
+ }
return value;
}
diff --git a/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c
index 3e382cf97a6..780cca66fb9 100644
--- a/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c
+++ b/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c
@@ -1118,8 +1118,9 @@ static void gizmo_cage2d_exit(bContext *C, wmGizmo *gz, const bool cancel)
MEM_SAFE_FREE(data->dial);
- if (!cancel)
+ if (!cancel) {
return;
+ }
wmGizmoProperty *gz_prop;
diff --git a/source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c
index 323ae38c27c..e2a86469da1 100644
--- a/source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c
+++ b/source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c
@@ -616,8 +616,9 @@ static void gizmo_cage3d_exit(bContext *C, wmGizmo *gz, const bool cancel)
{
RectTransformInteraction *data = gz->interaction_data;
- if (!cancel)
+ if (!cancel) {
return;
+ }
wmGizmoProperty *gz_prop;
diff --git a/source/blender/editors/gpencil/annotate_draw.c b/source/blender/editors/gpencil/annotate_draw.c
index b4f0bc03700..84dc29afab3 100644
--- a/source/blender/editors/gpencil/annotate_draw.c
+++ b/source/blender/editors/gpencil/annotate_draw.c
@@ -101,12 +101,14 @@ static void gp_draw_stroke_buffer(const tGPspoint *points,
int draw_points = 0;
/* error checking */
- if ((points == NULL) || (totpoints <= 0))
+ if ((points == NULL) || (totpoints <= 0)) {
return;
+ }
/* check if buffer can be drawn */
- if (dflag & (GP_DRAWDATA_ONLY3D | GP_DRAWDATA_ONLYV2D))
+ if (dflag & (GP_DRAWDATA_ONLY3D | GP_DRAWDATA_ONLYV2D)) {
return;
+ }
if (sflag & GP_STROKE_ERASER) {
/* don't draw stroke at all! */
@@ -515,26 +517,33 @@ static bool gp_can_draw_stroke(const bGPDstroke *gps, const int dflag)
{
/* skip stroke if it isn't in the right display space for this drawing context */
/* 1) 3D Strokes */
- if ((dflag & GP_DRAWDATA_ONLY3D) && !(gps->flag & GP_STROKE_3DSPACE))
+ if ((dflag & GP_DRAWDATA_ONLY3D) && !(gps->flag & GP_STROKE_3DSPACE)) {
return false;
- if (!(dflag & GP_DRAWDATA_ONLY3D) && (gps->flag & GP_STROKE_3DSPACE))
+ }
+ if (!(dflag & GP_DRAWDATA_ONLY3D) && (gps->flag & GP_STROKE_3DSPACE)) {
return false;
+ }
/* 2) Screen Space 2D Strokes */
- if ((dflag & GP_DRAWDATA_ONLYV2D) && !(gps->flag & GP_STROKE_2DSPACE))
+ if ((dflag & GP_DRAWDATA_ONLYV2D) && !(gps->flag & GP_STROKE_2DSPACE)) {
return false;
- if (!(dflag & GP_DRAWDATA_ONLYV2D) && (gps->flag & GP_STROKE_2DSPACE))
+ }
+ if (!(dflag & GP_DRAWDATA_ONLYV2D) && (gps->flag & GP_STROKE_2DSPACE)) {
return false;
+ }
/* 3) Image Space (2D) */
- if ((dflag & GP_DRAWDATA_ONLYI2D) && !(gps->flag & GP_STROKE_2DIMAGE))
+ if ((dflag & GP_DRAWDATA_ONLYI2D) && !(gps->flag & GP_STROKE_2DIMAGE)) {
return false;
- if (!(dflag & GP_DRAWDATA_ONLYI2D) && (gps->flag & GP_STROKE_2DIMAGE))
+ }
+ if (!(dflag & GP_DRAWDATA_ONLYI2D) && (gps->flag & GP_STROKE_2DIMAGE)) {
return false;
+ }
/* skip stroke if it doesn't have any valid data */
- if ((gps->points == NULL) || (gps->totpoints < 1))
+ if ((gps->points == NULL) || (gps->totpoints < 1)) {
return false;
+ }
/* stroke can be drawn */
return true;
@@ -629,8 +638,9 @@ static void gp_draw_strokes_edit(bGPdata *gpd,
float alpha)
{
/* if alpha 0 do not draw */
- if (alpha == 0.0f)
+ if (alpha == 0.0f) {
return;
+ }
const bool no_xray = (dflag & GP_DRAWDATA_NO_XRAY) != 0;
int mask_orig = 0;
@@ -653,15 +663,17 @@ static void gp_draw_strokes_edit(bGPdata *gpd,
/* draw stroke verts */
for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
/* check if stroke can be drawn */
- if (gp_can_draw_stroke(gps, dflag) == false)
+ if (gp_can_draw_stroke(gps, dflag) == false) {
continue;
+ }
/* Optimisation: only draw points for selected strokes
* We assume that selected points can only occur in
* strokes that are selected too.
*/
- if ((gps->flag & GP_STROKE_SELECT) == 0)
+ if ((gps->flag & GP_STROKE_SELECT) == 0) {
continue;
+ }
/* Get size of verts:
* - The selected state needs to be larger than the unselected state so that
@@ -787,8 +799,9 @@ static void gp_draw_onionskins(bGPdata *gpd,
color[3] = alpha * fac * 0.66f;
gp_draw_strokes(gpd, gpl, gf, offsx, offsy, winx, winy, dflag, gpl->thickness, color);
}
- else
+ else {
break;
+ }
}
}
else if (gpl->gstep == 0) {
@@ -818,8 +831,9 @@ static void gp_draw_onionskins(bGPdata *gpd,
color[3] = alpha * fac * 0.66f;
gp_draw_strokes(gpd, gpl, gf, offsx, offsy, winx, winy, dflag, gpl->thickness, color);
}
- else
+ else {
break;
+ }
}
}
else if (gpl->gstep_next == 0) {
@@ -850,13 +864,15 @@ static void gp_draw_data_layers(
ink[3] = gpl->opacity;
/* don't draw layer if hidden */
- if (gpl->flag & GP_LAYER_HIDE)
+ if (gpl->flag & GP_LAYER_HIDE) {
continue;
+ }
/* get frame to draw */
bGPDframe *gpf = BKE_gpencil_layer_getframe(gpl, cfra, GP_GETFRAME_USE_PREV);
- if (gpf == NULL)
+ if (gpf == NULL) {
continue;
+ }
/* set basic stroke thickness */
GPU_line_width(lthick);
@@ -917,8 +933,9 @@ static void gp_draw_status_text(const bGPdata *gpd, ARegion *ar)
rcti rect;
/* Cannot draw any status text when drawing OpenGL Renders */
- if (G.f & G_FLAG_RENDER_VIEWPORT)
+ if (G.f & G_FLAG_RENDER_VIEWPORT) {
return;
+ }
/* Get bounds of region - Necessary to avoid problems with region overlap */
ED_region_visible_rect(ar, &rect);
@@ -1036,8 +1053,9 @@ void ED_annotation_draw_2dimage(const bContext *C)
int dflag = GP_DRAWDATA_NOSTATUS;
bGPdata *gpd = ED_gpencil_data_get_active(C); // XXX
- if (gpd == NULL)
+ if (gpd == NULL) {
return;
+ }
/* calculate rect */
switch (sa->spacetype) {
@@ -1103,22 +1121,27 @@ void ED_annotation_draw_view2d(const bContext *C, bool onlyv2d)
int dflag = 0;
/* check that we have grease-pencil stuff to draw */
- if (sa == NULL)
+ if (sa == NULL) {
return;
+ }
bGPdata *gpd = ED_gpencil_data_get_active(C); // XXX
- if (gpd == NULL)
+ if (gpd == NULL) {
return;
+ }
/* special hack for Image Editor */
/* FIXME: the opengl poly-strokes don't draw at right thickness when done this way, so disabled */
- if (ELEM(sa->spacetype, SPACE_IMAGE, SPACE_CLIP))
+ if (ELEM(sa->spacetype, SPACE_IMAGE, SPACE_CLIP)) {
dflag |= GP_DRAWDATA_IEDITHACK;
+ }
/* draw it! */
- if (onlyv2d)
+ if (onlyv2d) {
dflag |= (GP_DRAWDATA_ONLYV2D | GP_DRAWDATA_NOSTATUS);
- if (ED_screen_animation_playing(wm))
+ }
+ if (ED_screen_animation_playing(wm)) {
dflag |= GP_DRAWDATA_NO_ONIONS;
+ }
gp_draw_data_all(scene, gpd, 0, 0, ar->winx, ar->winy, CFRA, dflag, sa->spacetype);
@@ -1141,8 +1164,9 @@ void ED_annotation_draw_view3d(
/* check that we have grease-pencil stuff to draw */
/* XXX: Hardcoded reference here may get out of sync if we change how we fetch annotation data */
bGPdata *gpd = scene->gpd;
- if (gpd == NULL)
+ if (gpd == NULL) {
return;
+ }
/* when rendering to the offscreen buffer we don't want to
* deal with the camera border, otherwise map the coords to the camera border. */
diff --git a/source/blender/editors/gpencil/annotate_paint.c b/source/blender/editors/gpencil/annotate_paint.c
index 899b76e252f..0363fd6c754 100644
--- a/source/blender/editors/gpencil/annotate_paint.c
+++ b/source/blender/editors/gpencil/annotate_paint.c
@@ -232,10 +232,12 @@ static bool gpencil_draw_poll(bContext *C)
/* check if current context can support GPencil data */
if (ED_gpencil_data_get_pointers(C, NULL) != NULL) {
/* check if Grease Pencil isn't already running */
- if (ED_gpencil_session_active() == 0)
+ if (ED_gpencil_session_active() == 0) {
return true;
- else
+ }
+ else {
CTX_wm_operator_poll_msg_set(C, "Annotation operator is already active");
+ }
}
else {
CTX_wm_operator_poll_msg_set(C, "Failed to find Grease Pencil data to draw into");
@@ -279,26 +281,30 @@ static bool gp_stroke_filtermval(tGPsdata *p, const float mval[2], float pmval[2
int dy = (int)fabsf(mval[1] - pmval[1]);
/* if buffer is empty, just let this go through (i.e. so that dots will work) */
- if (p->gpd->runtime.sbuffer_size == 0)
+ if (p->gpd->runtime.sbuffer_size == 0) {
return true;
- /* check if mouse moved at least certain distance on both axes (best case)
+ /* check if mouse moved at least certain distance on both axes (best case)
* - aims to eliminate some jitter-noise from input when trying to draw straight lines freehand
*/
- else if ((dx > MIN_MANHATTEN_PX) && (dy > MIN_MANHATTEN_PX))
+ }
+ else if ((dx > MIN_MANHATTEN_PX) && (dy > MIN_MANHATTEN_PX)) {
return true;
- /* Check if the distance since the last point is significant enough:
+ /* Check if the distance since the last point is significant enough:
* - Prevents points being added too densely
* - Distance here doesn't use sqrt to prevent slowness.
* We should still be safe from overflows though.
*/
- else if ((dx * dx + dy * dy) > MIN_EUCLIDEAN_PX * MIN_EUCLIDEAN_PX)
+ }
+ else if ((dx * dx + dy * dy) > MIN_EUCLIDEAN_PX * MIN_EUCLIDEAN_PX) {
return true;
- /* mouse 'didn't move' */
- else
+ /* mouse 'didn't move' */
+ }
+ else {
return false;
+ }
}
/* convert screen-coordinates to buffer-coordinates */
@@ -467,8 +473,9 @@ static short gp_stroke_addpoint(tGPsdata *p, const float mval[2], float pressure
}
else if (p->paintmode == GP_PAINTMODE_DRAW) { /* normal drawing */
/* check if still room in buffer */
- if (gpd->runtime.sbuffer_size >= GP_STROKE_BUFFER_MAX)
+ if (gpd->runtime.sbuffer_size >= GP_STROKE_BUFFER_MAX) {
return GP_STROKEADD_OVERFLOW;
+ }
/* get pointer to destination point */
pt = ((tGPspoint *)(gpd->runtime.sbuffer) + gpd->runtime.sbuffer_size);
@@ -490,10 +497,12 @@ static short gp_stroke_addpoint(tGPsdata *p, const float mval[2], float pressure
}
/* check if another operation can still occur */
- if (gpd->runtime.sbuffer_size == GP_STROKE_BUFFER_MAX)
+ if (gpd->runtime.sbuffer_size == GP_STROKE_BUFFER_MAX) {
return GP_STROKEADD_FULL;
- else
+ }
+ else {
return GP_STROKEADD_NORMAL;
+ }
}
else if (p->paintmode == GP_PAINTMODE_DRAW_POLY) {
/* get pointer to destination point */
@@ -548,8 +557,9 @@ static short gp_stroke_addpoint(tGPsdata *p, const float mval[2], float pressure
}
/* increment counters */
- if (gpd->runtime.sbuffer_size == 0)
+ if (gpd->runtime.sbuffer_size == 0) {
gpd->runtime.sbuffer_size++;
+ }
return GP_STROKEADD_NORMAL;
}
@@ -571,12 +581,14 @@ static void gp_stroke_simplify(tGPsdata *p)
short i, j;
/* only simplify if simplification is enabled, and we're not doing a straight line */
- if (!(U.gp_settings & GP_PAINT_DOSIMPLIFY) || (p->paintmode == GP_PAINTMODE_DRAW_STRAIGHT))
+ if (!(U.gp_settings & GP_PAINT_DOSIMPLIFY) || (p->paintmode == GP_PAINTMODE_DRAW_STRAIGHT)) {
return;
+ }
/* don't simplify if less than 4 points in buffer */
- if ((num_points <= 4) || (old_points == NULL))
+ if ((num_points <= 4) || (old_points == NULL)) {
return;
+ }
/* clear buffer (but don't free mem yet) so that we can write to it
* - firstly set sbuffer to NULL, so a new one is allocated
@@ -655,16 +667,19 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
/* get total number of points to allocate space for
* - drawing straight-lines only requires the endpoints
*/
- if (p->paintmode == GP_PAINTMODE_DRAW_STRAIGHT)
+ if (p->paintmode == GP_PAINTMODE_DRAW_STRAIGHT) {
totelem = (gpd->runtime.sbuffer_size >= 2) ? 2 : gpd->runtime.sbuffer_size;
- else
+ }
+ else {
totelem = gpd->runtime.sbuffer_size;
+ }
/* exit with error if no valid points from this stroke */
if (totelem == 0) {
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("Error: No valid points in stroke buffer to convert (tot=%d)\n",
gpd->runtime.sbuffer_size);
+ }
return;
}
@@ -773,8 +788,9 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
if (found_depth == false) {
/* eeh... not much we can do.. :/, ignore depth in this case, use the 3D cursor */
- for (i = gpd->runtime.sbuffer_size - 1; i >= 0; i--)
+ for (i = gpd->runtime.sbuffer_size - 1; i >= 0; i--) {
depth_arr[i] = 0.9999f;
+ }
}
else {
if (ts->annotate_v3d_align & GP_PROJECT_DEPTH_STROKE_ENDPOINTS) {
@@ -783,20 +799,23 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
int last_valid = 0;
for (i = 0; i < gpd->runtime.sbuffer_size; i++) {
- if (depth_arr[i] != FLT_MAX)
+ if (depth_arr[i] != FLT_MAX) {
break;
+ }
}
first_valid = i;
for (i = gpd->runtime.sbuffer_size - 1; i >= 0; i--) {
- if (depth_arr[i] != FLT_MAX)
+ if (depth_arr[i] != FLT_MAX) {
break;
+ }
}
last_valid = i;
/* invalidate non-endpoints, so only blend between first and last */
- for (i = first_valid + 1; i < last_valid; i++)
+ for (i = first_valid + 1; i < last_valid; i++) {
depth_arr[i] = FLT_MAX;
+ }
interp_depth = true;
}
@@ -822,8 +841,9 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
pt->time = ptc->time;
}
- if (depth_arr)
+ if (depth_arr) {
MEM_freeN(depth_arr);
+ }
}
/* add stroke to frame */
@@ -949,8 +969,9 @@ static void gp_stroke_eraser_dostroke(tGPsdata *p,
pt2 = gps->points + i + 1;
/* only process if it hasn't been masked out... */
- if ((p->flags & GP_PAINTFLAG_SELECTMASK) && !(gps->points->flag & GP_SPOINT_SELECT))
+ if ((p->flags & GP_PAINTFLAG_SELECTMASK) && !(gps->points->flag & GP_SPOINT_SELECT)) {
continue;
+ }
gp_point_to_xy(&p->gsc, gps, pt1, &pc1[0], &pc1[1]);
gp_point_to_xy(&p->gsc, gps, pt2, &pc2[0], &pc2[1]);
@@ -1061,8 +1082,9 @@ static bool gp_session_initdata(bContext *C, tGPsdata *p)
/* make sure the active view (at the starting time) is a 3d-view */
if (curarea == NULL) {
p->status = GP_STATUS_ERROR;
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("Error: No active view for painting\n");
+ }
return 0;
}
@@ -1091,10 +1113,11 @@ static bool gp_session_initdata(bContext *C, tGPsdata *p)
if (ar->regiondata == NULL) {
p->status = GP_STATUS_ERROR;
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf(
"Error: 3D-View active region doesn't have any region data, so cannot be "
"drawable\n");
+ }
return 0;
}
break;
@@ -1121,8 +1144,9 @@ static bool gp_session_initdata(bContext *C, tGPsdata *p)
/* check that gpencil data is allowed to be drawn */
if (sseq->mainb == SEQ_DRAW_SEQUENCE) {
p->status = GP_STATUS_ERROR;
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("Error: In active view (sequencer), active mode doesn't support Grease Pencil\n");
+ }
return 0;
}
break;
@@ -1182,8 +1206,9 @@ static bool gp_session_initdata(bContext *C, tGPsdata *p)
/* unsupported views */
default: {
p->status = GP_STATUS_ERROR;
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("Error: Annotations are not supported in this editor\n");
+ }
return 0;
}
}
@@ -1192,8 +1217,9 @@ static bool gp_session_initdata(bContext *C, tGPsdata *p)
gpd_ptr = ED_gpencil_data_get_pointers(C, &p->ownerPtr);
if ((gpd_ptr == NULL) || !ED_gpencil_data_owner_is_annotation(&p->ownerPtr)) {
p->status = GP_STATUS_ERROR;
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("Error: Current context doesn't allow for any Annotation data\n");
+ }
return 0;
}
else {
@@ -1257,8 +1283,9 @@ static void gp_session_cleanup(tGPsdata *p)
bGPdata *gpd = (p) ? p->gpd : NULL;
/* error checking */
- if (gpd == NULL)
+ if (gpd == NULL) {
return;
+ }
/* free stroke buffer */
if (gpd->runtime.sbuffer) {
@@ -1291,13 +1318,15 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode, Deps
p->gpd->flag |= GP_DATA_ANNOTATIONS;
p->gpl = BKE_gpencil_layer_addnew(p->gpd, DATA_("Note"), true);
- if (p->custom_color[3])
+ if (p->custom_color[3]) {
copy_v3_v3(p->gpl->color, p->custom_color);
+ }
}
if (p->gpl->flag & GP_LAYER_LOCKED) {
p->status = GP_STATUS_ERROR;
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("Error: Cannot paint on locked layer\n");
+ }
return;
}
@@ -1341,17 +1370,20 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode, Deps
/* Drawing Modes - Add a new frame if needed on the active layer */
short add_frame_mode = GP_GETFRAME_ADD_NEW;
- if (ts->gpencil_flags & GP_TOOL_FLAG_RETAIN_LAST)
+ if (ts->gpencil_flags & GP_TOOL_FLAG_RETAIN_LAST) {
add_frame_mode = GP_GETFRAME_ADD_COPY;
- else
+ }
+ else {
add_frame_mode = GP_GETFRAME_ADD_NEW;
+ }
p->gpf = BKE_gpencil_layer_getframe(p->gpl, CFRA, add_frame_mode);
if (p->gpf == NULL) {
p->status = GP_STATUS_ERROR;
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("Error: No frame created (gpencil_paint_init)\n");
+ }
return;
}
else {
@@ -1474,8 +1506,9 @@ static void gp_paint_cleanup(tGPsdata *p)
}
/* "unlock" frame */
- if (p->gpf)
+ if (p->gpf) {
p->gpf->flag &= ~GP_FRAME_PAINT;
+ }
}
/* ------------------------------- */
@@ -1637,10 +1670,12 @@ static int gpencil_draw_init(bContext *C, wmOperator *op, const wmEvent *event)
/* ensure that the correct cursor icon is set */
static void gpencil_draw_cursor_set(tGPsdata *p)
{
- if (p->paintmode == GP_PAINTMODE_ERASER)
+ if (p->paintmode == GP_PAINTMODE_ERASER) {
WM_cursor_modal_set(p->win, BC_CROSSCURSOR); /* XXX need a better cursor */
- else
+ }
+ else {
WM_cursor_modal_set(p->win, BC_PAINTBRUSHCURSOR);
+ }
}
/* update UI indicators of status, including cursor and header prints */
@@ -1751,8 +1786,9 @@ static void gpencil_draw_apply(wmOperator *op, tGPsdata *p, Depsgraph *depsgraph
BKE_report(op->reports, RPT_ERROR, "Cannot paint stroke");
p->status = GP_STATUS_ERROR;
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("Error: Grease-Pencil Paint - Add Point Invalid\n");
+ }
return;
}
@@ -1843,8 +1879,9 @@ static void annotation_draw_apply_event(
/* special exception here for too high pressure values on first touch in
* windows for some tablets, then we just skip first touch...
*/
- if (tablet && (p->pressure >= 0.99f))
+ if (tablet && (p->pressure >= 0.99f)) {
return;
+ }
}
/* check if alt key is pressed and limit to straight lines */
@@ -1890,13 +1927,15 @@ static int gpencil_draw_exec(bContext *C, wmOperator *op)
/* try to initialize context data needed while drawing */
if (!gpencil_draw_init(C, op, NULL)) {
- if (op->customdata)
+ if (op->customdata) {
MEM_freeN(op->customdata);
+ }
/* printf("\tGP - no valid data\n"); */
return OPERATOR_CANCELLED;
}
- else
+ else {
p = op->customdata;
+ }
/* printf("\tGP - Start redrawing stroke\n"); */
@@ -1988,19 +2027,23 @@ static int gpencil_draw_invoke(bContext *C, wmOperator *op, const wmEvent *event
}
}
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("GPencil - Starting Drawing\n");
+ }
/* try to initialize context data needed while drawing */
if (!gpencil_draw_init(C, op, event)) {
- if (op->customdata)
+ if (op->customdata) {
MEM_freeN(op->customdata);
- if (G.debug & G_DEBUG)
+ }
+ if (G.debug & G_DEBUG) {
printf("\tGP - no valid data\n");
+ }
return OPERATOR_CANCELLED;
}
- else
+ else {
p = op->customdata;
+ }
/* if empty erase capture and finish */
if (p->status == GP_STATUS_CAPTURE) {
@@ -2072,8 +2115,9 @@ static tGPsdata *gpencil_stroke_begin(bContext *C, wmOperator *op)
/* XXX: watch it with the paintmode! in future,
* it'd be nice to allow changing paint-mode when in sketching-sessions */
- if (gp_session_initdata(C, p))
+ if (gp_session_initdata(C, p)) {
gp_paint_initstroke(p, p->paintmode, CTX_data_depsgraph(C));
+ }
if (p->status != GP_STATUS_ERROR) {
p->status = GP_STATUS_PAINTING;
@@ -2290,8 +2334,9 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event)
p->status = GP_STATUS_ERROR;
estate = OPERATOR_CANCELLED;
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("%s: Region under cursor is out of bounds, so cannot be drawn on\n", __func__);
+ }
}
}
else if (p->ar) {
@@ -2306,8 +2351,9 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event)
p->status = GP_STATUS_ERROR;
estate = OPERATOR_CANCELLED;
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("%s: No active region found in GP Paint session data\n", __func__);
+ }
}
if (in_bounds) {
@@ -2386,8 +2432,9 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event)
case PADMINUS:
p->radius -= 5;
- if (p->radius <= 0)
+ if (p->radius <= 0) {
p->radius = 1;
+ }
break;
}
@@ -2408,8 +2455,9 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
/* gpencil modal operator stores area, which can be removed while using it (like fullscreen) */
- if (0 == gpencil_area_exists(C, p->sa))
+ if (0 == gpencil_area_exists(C, p->sa)) {
estate = OPERATOR_CANCELLED;
+ }
else {
/* update status indicators - cursor, header, etc. */
gpencil_draw_status_indicators(C, p);
diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c
index 47f6e2e5a6e..c54598fd549 100644
--- a/source/blender/editors/gpencil/drawgpencil.c
+++ b/source/blender/editors/gpencil/drawgpencil.c
@@ -325,8 +325,9 @@ static void gp_triangulate_stroke_fill(bGPDstroke *gps)
}
else {
/* No triangles needed - Free anything allocated previously */
- if (gps->triangles)
+ if (gps->triangles) {
MEM_freeN(gps->triangles);
+ }
gps->triangles = NULL;
}
@@ -818,26 +819,33 @@ static bool gp_can_draw_stroke(const bGPDstroke *gps, const int dflag)
{
/* skip stroke if it isn't in the right display space for this drawing context */
/* 1) 3D Strokes */
- if ((dflag & GP_DRAWDATA_ONLY3D) && !(gps->flag & GP_STROKE_3DSPACE))
+ if ((dflag & GP_DRAWDATA_ONLY3D) && !(gps->flag & GP_STROKE_3DSPACE)) {
return false;
- if (!(dflag & GP_DRAWDATA_ONLY3D) && (gps->flag & GP_STROKE_3DSPACE))
+ }
+ if (!(dflag & GP_DRAWDATA_ONLY3D) && (gps->flag & GP_STROKE_3DSPACE)) {
return false;
+ }
/* 2) Screen Space 2D Strokes */
- if ((dflag & GP_DRAWDATA_ONLYV2D) && !(gps->flag & GP_STROKE_2DSPACE))
+ if ((dflag & GP_DRAWDATA_ONLYV2D) && !(gps->flag & GP_STROKE_2DSPACE)) {
return false;
- if (!(dflag & GP_DRAWDATA_ONLYV2D) && (gps->flag & GP_STROKE_2DSPACE))
+ }
+ if (!(dflag & GP_DRAWDATA_ONLYV2D) && (gps->flag & GP_STROKE_2DSPACE)) {
return false;
+ }
/* 3) Image Space (2D) */
- if ((dflag & GP_DRAWDATA_ONLYI2D) && !(gps->flag & GP_STROKE_2DIMAGE))
+ if ((dflag & GP_DRAWDATA_ONLYI2D) && !(gps->flag & GP_STROKE_2DIMAGE)) {
return false;
- if (!(dflag & GP_DRAWDATA_ONLYI2D) && (gps->flag & GP_STROKE_2DIMAGE))
+ }
+ if (!(dflag & GP_DRAWDATA_ONLYI2D) && (gps->flag & GP_STROKE_2DIMAGE)) {
return false;
+ }
/* skip stroke if it doesn't have any valid data */
- if ((gps->points == NULL) || (gps->totpoints < 1))
+ if ((gps->points == NULL) || (gps->totpoints < 1)) {
return false;
+ }
/* stroke can be drawn */
return true;
@@ -1143,8 +1151,9 @@ static void UNUSED_FUNCTION(gp_draw_status_text)(const bGPdata *gpd, ARegion *ar
rcti rect;
/* Cannot draw any status text when drawing OpenGL Renders */
- if (G.f & G_FLAG_RENDER_VIEWPORT)
+ if (G.f & G_FLAG_RENDER_VIEWPORT) {
return;
+ }
/* Get bounds of region - Necessary to avoid problems with region overlap */
ED_region_visible_rect(ar, &rect);
diff --git a/source/blender/editors/gpencil/editaction_gpencil.c b/source/blender/editors/gpencil/editaction_gpencil.c
index 44e7341b6f7..d0f44314c95 100644
--- a/source/blender/editors/gpencil/editaction_gpencil.c
+++ b/source/blender/editors/gpencil/editaction_gpencil.c
@@ -61,14 +61,16 @@ bool ED_gplayer_frames_looper(bGPDlayer *gpl, Scene *scene, short (*gpf_cb)(bGPD
bGPDframe *gpf;
/* error checker */
- if (gpl == NULL)
+ if (gpl == NULL) {
return false;
+ }
/* do loop */
for (gpf = gpl->frames.first; gpf; gpf = gpf->next) {
/* execute callback */
- if (gpf_cb(gpf, scene))
+ if (gpf_cb(gpf, scene)) {
return true;
+ }
}
/* nothing to return */
@@ -85,8 +87,9 @@ void ED_gplayer_make_cfra_list(bGPDlayer *gpl, ListBase *elems, bool onlysel)
CfraElem *ce;
/* error checking */
- if (ELEM(NULL, gpl, elems))
+ if (ELEM(NULL, gpl, elems)) {
return;
+ }
/* loop through gp-frames, adding */
for (gpf = gpl->frames.first; gpf; gpf = gpf->next) {
@@ -110,13 +113,15 @@ bool ED_gplayer_frame_select_check(bGPDlayer *gpl)
bGPDframe *gpf;
/* error checking */
- if (gpl == NULL)
+ if (gpl == NULL) {
return false;
+ }
/* stop at the first one found */
for (gpf = gpl->frames.first; gpf; gpf = gpf->next) {
- if (gpf->flag & GP_FRAME_SELECT)
+ if (gpf->flag & GP_FRAME_SELECT) {
return true;
+ }
}
/* not found */
@@ -126,8 +131,9 @@ bool ED_gplayer_frame_select_check(bGPDlayer *gpl)
/* helper function - select gp-frame based on SELECT_* mode */
static void gpframe_select(bGPDframe *gpf, short select_mode)
{
- if (gpf == NULL)
+ if (gpf == NULL) {
return;
+ }
switch (select_mode) {
case SELECT_ADD:
@@ -148,8 +154,9 @@ void ED_gpencil_select_frames(bGPDlayer *gpl, short select_mode)
bGPDframe *gpf;
/* error checking */
- if (gpl == NULL)
+ if (gpl == NULL) {
return;
+ }
/* handle according to mode */
for (gpf = gpl->frames.first; gpf; gpf = gpf->next) {
@@ -161,8 +168,9 @@ void ED_gpencil_select_frames(bGPDlayer *gpl, short select_mode)
void ED_gplayer_frame_select_set(bGPDlayer *gpl, short mode)
{
/* error checking */
- if (gpl == NULL)
+ if (gpl == NULL) {
return;
+ }
/* now call the standard function */
ED_gpencil_select_frames(gpl, mode);
@@ -173,8 +181,9 @@ void ED_gpencil_select_frame(bGPDlayer *gpl, int selx, short select_mode)
{
bGPDframe *gpf;
- if (gpl == NULL)
+ if (gpl == NULL) {
return;
+ }
gpf = BKE_gpencil_layer_find_frame(gpl, selx);
@@ -188,13 +197,15 @@ void ED_gplayer_frames_select_box(bGPDlayer *gpl, float min, float max, short se
{
bGPDframe *gpf;
- if (gpl == NULL)
+ if (gpl == NULL) {
return;
+ }
/* only select those frames which are in bounds */
for (gpf = gpl->frames.first; gpf; gpf = gpf->next) {
- if (IN_RANGE(gpf->framenum, min, max))
+ if (IN_RANGE(gpf->framenum, min, max)) {
gpframe_select(gpf, select_mode);
+ }
}
}
@@ -206,8 +217,9 @@ void ED_gplayer_frames_select_region(KeyframeEditData *ked,
{
bGPDframe *gpf;
- if (gpl == NULL)
+ if (gpl == NULL) {
return;
+ }
/* only select frames which are within the region */
for (gpf = gpl->frames.first; gpf; gpf = gpf->next) {
@@ -220,13 +232,15 @@ void ED_gplayer_frames_select_region(KeyframeEditData *ked,
/* check the necessary regions */
if (tool == BEZT_OK_CHANNEL_LASSO) {
/* Lasso */
- if (keyframe_region_lasso_test(ked->data, pt))
+ if (keyframe_region_lasso_test(ked->data, pt)) {
gpframe_select(gpf, select_mode);
+ }
}
else if (tool == BEZT_OK_CHANNEL_CIRCLE) {
/* Circle */
- if (keyframe_region_circle_test(ked->data, pt))
+ if (keyframe_region_circle_test(ked->data, pt)) {
gpframe_select(gpf, select_mode);
+ }
}
}
}
@@ -241,8 +255,9 @@ bool ED_gplayer_frames_delete(bGPDlayer *gpl)
bool changed = false;
/* error checking */
- if (gpl == NULL)
+ if (gpl == NULL) {
return false;
+ }
/* check for frames to delete */
for (gpf = gpl->frames.first; gpf; gpf = gpfn) {
@@ -263,8 +278,9 @@ void ED_gplayer_frames_duplicate(bGPDlayer *gpl)
bGPDframe *gpf, *gpfn;
/* error checking */
- if (gpl == NULL)
+ if (gpl == NULL) {
return;
+ }
/* duplicate selected frames */
for (gpf = gpl->frames.first; gpf; gpf = gpfn) {
@@ -290,8 +306,9 @@ void ED_gplayer_frames_keytype_set(bGPDlayer *gpl, short type)
{
bGPDframe *gpf;
- if (gpl == NULL)
+ if (gpl == NULL) {
return;
+ }
for (gpf = gpl->frames.first; gpf; gpf = gpf->next) {
if (gpf->flag & GP_FRAME_SELECT) {
@@ -364,10 +381,12 @@ bool ED_gpencil_anim_copybuf_copy(bAnimContext *ac)
BLI_addtail(&copied_frames, new_frame);
/* extend extents for keyframes encountered */
- if (gpf->framenum < gp_anim_copy_firstframe)
+ if (gpf->framenum < gp_anim_copy_firstframe) {
gp_anim_copy_firstframe = gpf->framenum;
- if (gpf->framenum > gp_anim_copy_lastframe)
+ }
+ if (gpf->framenum > gp_anim_copy_lastframe) {
gp_anim_copy_lastframe = gpf->framenum;
+ }
}
}
@@ -460,8 +479,9 @@ bool ED_gpencil_anim_copybuf_paste(bAnimContext *ac, const short offset_mode)
}
/* this situation might occur! */
- if (gpls == NULL)
+ if (gpls == NULL) {
continue;
+ }
/* add frames from buffer */
for (gpfs = gpls->frames.first; gpfs; gpfs = gpfs->next) {
@@ -495,8 +515,9 @@ bool ED_gpencil_anim_copybuf_paste(bAnimContext *ac, const short offset_mode)
}
/* if no strokes (i.e. new frame) added, free gpf */
- if (BLI_listbase_is_empty(&gpf->strokes))
+ if (BLI_listbase_is_empty(&gpf->strokes)) {
BKE_gpencil_layer_delframe(gpld, gpf);
+ }
}
/* unapply offset from buffer-frame */
@@ -524,23 +545,26 @@ static short snap_gpf_nearest(bGPDframe *UNUSED(gpf), Scene *UNUSED(scene))
static short snap_gpf_nearestsec(bGPDframe *gpf, Scene *scene)
{
float secf = (float)FPS;
- if (gpf->flag & GP_FRAME_SELECT)
+ if (gpf->flag & GP_FRAME_SELECT) {
gpf->framenum = (int)(floorf(gpf->framenum / secf + 0.5f) * secf);
+ }
return 0;
}
static short snap_gpf_cframe(bGPDframe *gpf, Scene *scene)
{
- if (gpf->flag & GP_FRAME_SELECT)
+ if (gpf->flag & GP_FRAME_SELECT) {
gpf->framenum = (int)CFRA;
+ }
return 0;
}
static short snap_gpf_nearmarker(bGPDframe *gpf, Scene *scene)
{
- if (gpf->flag & GP_FRAME_SELECT)
+ if (gpf->flag & GP_FRAME_SELECT) {
gpf->framenum = (int)ED_markers_find_nearest_marker_time(&scene->markers,
(float)gpf->framenum);
+ }
return 0;
}
diff --git a/source/blender/editors/gpencil/gpencil_armature.c b/source/blender/editors/gpencil/gpencil_armature.c
index d99a630a45c..c433b374d4c 100644
--- a/source/blender/editors/gpencil/gpencil_armature.c
+++ b/source/blender/editors/gpencil/gpencil_armature.c
@@ -287,8 +287,9 @@ static void gpencil_add_verts_to_dgroups(
/* count the number of skinnable bones */
numbones = gpencil_bone_looper(ob, arm->bonebase.first, &looper_data, gpencil_bone_skinnable_cb);
- if (numbones == 0)
+ if (numbones == 0) {
return;
+ }
/* create an array of pointer to bones that are skinnable
* and fill it with all of the skinnable bones */
@@ -366,13 +367,15 @@ static void gpencil_add_verts_to_dgroups(
for (bGPDframe *gpf = init_gpf; gpf; gpf = gpf->next) {
if ((gpf == gpl->actframe) || ((gpf->flag & GP_FRAME_SELECT) && (is_multiedit))) {
- if (gpf == NULL)
+ if (gpf == NULL) {
continue;
+ }
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;
+ }
BKE_gpencil_dvert_ensure(gps);
@@ -564,8 +567,9 @@ static int gpencil_generate_weights_exec(bContext *C, wmOperator *op)
const float decay = RNA_float_get(op->ptr, "decay");
/* sanity checks */
- if (ELEM(NULL, ob, gpd))
+ if (ELEM(NULL, ob, gpd)) {
return OPERATOR_CANCELLED;
+ }
/* get armature */
const int arm_idx = RNA_enum_get(op->ptr, "armature");
diff --git a/source/blender/editors/gpencil/gpencil_brush.c b/source/blender/editors/gpencil/gpencil_brush.c
index c1503bb57b2..f9a5ff3a0cf 100644
--- a/source/blender/editors/gpencil/gpencil_brush.c
+++ b/source/blender/editors/gpencil/gpencil_brush.c
@@ -368,8 +368,9 @@ static bool gp_brush_thickness_apply(
* the upper end of this range. Therefore, we don't actually clamp
* down on the upper end.
*/
- if (pt->pressure < 0.0f)
+ if (pt->pressure < 0.0f) {
pt->pressure = 0.0f;
+ }
return true;
}
@@ -937,8 +938,9 @@ static bool gp_brush_weight_apply(
}
/* weight should stay within [0.0, 1.0] */
- if (pt->pressure < 0.0f)
+ if (pt->pressure < 0.0f) {
pt->pressure = 0.0f;
+ }
return true;
}
@@ -1394,8 +1396,9 @@ static void gpsculpt_brush_init_stroke(tGP_BrushEditData *gso)
int cfra_eval = (int)DEG_get_ctime(gso->depsgraph);
/* only try to add a new frame if this is the first stroke, or the frame has changed */
- if ((gpd == NULL) || (cfra_eval == gso->cfra))
+ if ((gpd == NULL) || (cfra_eval == gso->cfra)) {
return;
+ }
/* go through each layer, and ensure that we've got a valid frame to use */
for (gpl = gpd->layers.first; gpl; gpl = gpl->next) {
@@ -1735,10 +1738,12 @@ static void gpsculpt_brush_apply(bContext *C, wmOperator *op, PointerRNA *itempt
gso->pressure = RNA_float_get(itemptr, "pressure");
- if (RNA_boolean_get(itemptr, "pen_flip"))
+ if (RNA_boolean_get(itemptr, "pen_flip")) {
gso->flag |= GP_SCULPT_FLAG_INVERT;
- else
+ }
+ else {
gso->flag &= ~GP_SCULPT_FLAG_INVERT;
+ }
/* Store coordinates as reference, if operator just started running */
if (gso->first) {
@@ -1838,8 +1843,9 @@ static void gpsculpt_brush_apply_event(bContext *C, wmOperator *op, const wmEven
/* reapply */
static int gpsculpt_brush_exec(bContext *C, wmOperator *op)
{
- if (!gpsculpt_brush_init(C, op))
+ if (!gpsculpt_brush_init(C, op)) {
return OPERATOR_CANCELLED;
+ }
RNA_BEGIN (op->ptr, itemptr, "stroke") {
gpsculpt_brush_apply(C, op, &itemptr);
@@ -1868,8 +1874,9 @@ static int gpsculpt_brush_invoke(bContext *C, wmOperator *op, const wmEvent *eve
}
/* init painting data */
- if (!gpsculpt_brush_init(C, op))
+ if (!gpsculpt_brush_init(C, op)) {
return OPERATOR_CANCELLED;
+ }
gso = op->customdata;
diff --git a/source/blender/editors/gpencil/gpencil_convert.c b/source/blender/editors/gpencil/gpencil_convert.c
index 28d57939e0e..ded663276a4 100644
--- a/source/blender/editors/gpencil/gpencil_convert.c
+++ b/source/blender/editors/gpencil/gpencil_convert.c
@@ -501,8 +501,9 @@ static void gp_stroke_path_animation(bContext *C,
PropertyRNA *prop = NULL;
int nbr_gaps = 0, i;
- if (gtd->mode == GP_STROKECONVERT_TIMING_NONE)
+ if (gtd->mode == GP_STROKECONVERT_TIMING_NONE) {
return;
+ }
/* gap_duration and gap_randomness are in frames, but we need seconds!!! */
gtd->gap_duration = FRA2TIME(gtd->gap_duration);
@@ -1214,10 +1215,12 @@ static void gp_stroke_norm_curve_weights(Curve *cu, const float minmax_weights[2
int i;
/* when delta == minmax_weights[0] == minmax_weights[1], we get div by zero [#35686] */
- if (IS_EQF(delta, minmax_weights[1]))
+ if (IS_EQF(delta, minmax_weights[1])) {
fac = 1.0f;
- else
+ }
+ else {
fac = 1.0f / (minmax_weights[1] - delta);
+ }
for (nu = cu->nurb.first; nu; nu = nu->next) {
if (nu->bezt) {
@@ -1285,12 +1288,14 @@ static void gp_layer_to_curve(bContext *C,
rctf subrect, *subrect_ptr = NULL;
/* error checking */
- if (ELEM(NULL, gpd, gpl, gpf))
+ if (ELEM(NULL, gpd, gpl, gpf)) {
return;
+ }
/* only convert if there are any strokes on this layer's frame to convert */
- if (BLI_listbase_is_empty(&gpf->strokes))
+ if (BLI_listbase_is_empty(&gpf->strokes)) {
return;
+ }
/* initialize camera framing */
if (gp_camera_view_subrect(C, &subrect)) {
@@ -1413,8 +1418,9 @@ static bool gp_convert_check_has_valid_timing(bContext *C, bGPDlayer *gpl, wmOpe
bool valid = true;
if (!gpl || !(gpf = BKE_gpencil_layer_getframe(gpl, cfra_eval, GP_GETFRAME_USE_PREV)) ||
- !(gps = gpf->strokes.first))
+ !(gps = gpf->strokes.first)) {
return false;
+ }
do {
base_time = cur_time = gps->inittime;
@@ -1580,13 +1586,15 @@ static bool gp_convert_poll_property(const bContext *UNUSED(C),
}
/* Never show this prop */
- if (STREQ(prop_id, "use_timing_data"))
+ if (STREQ(prop_id, "use_timing_data")) {
return false;
+ }
if (link_strokes) {
/* Only show when link_stroke is true */
- if (STREQ(prop_id, "timing_mode"))
+ if (STREQ(prop_id, "timing_mode")) {
return true;
+ }
if (timing_mode != GP_STROKECONVERT_TIMING_NONE) {
/* Only show when link_stroke is true and stroke timing is enabled */
@@ -1595,25 +1603,30 @@ static bool gp_convert_poll_property(const bContext *UNUSED(C),
}
/* Only show if we have valid timing data! */
- if (valid_timing && STREQ(prop_id, "use_realtime"))
+ if (valid_timing && STREQ(prop_id, "use_realtime")) {
return true;
+ }
/* Only show if realtime or valid_timing is false! */
- if ((!realtime || !valid_timing) && STREQ(prop_id, "end_frame"))
+ if ((!realtime || !valid_timing) && STREQ(prop_id, "end_frame")) {
return true;
+ }
if (valid_timing && timing_mode == GP_STROKECONVERT_TIMING_CUSTOMGAP) {
/* Only show for custom gaps! */
- if (STREQ(prop_id, "gap_duration"))
+ if (STREQ(prop_id, "gap_duration")) {
return true;
+ }
/* Only show randomness for non-null custom gaps! */
- if (STREQ(prop_id, "gap_randomness") && (gap_duration > 0.0f))
+ if (STREQ(prop_id, "gap_randomness") && (gap_duration > 0.0f)) {
return true;
+ }
/* Only show seed for randomize action! */
- if (STREQ(prop_id, "seed") && (gap_duration > 0.0f) && (gap_randomness > 0.0f))
+ if (STREQ(prop_id, "seed") && (gap_duration > 0.0f) && (gap_randomness > 0.0f)) {
return true;
+ }
}
}
}
diff --git a/source/blender/editors/gpencil/gpencil_data.c b/source/blender/editors/gpencil/gpencil_data.c
index 7cab9def553..f44c90001e1 100644
--- a/source/blender/editors/gpencil/gpencil_data.c
+++ b/source/blender/editors/gpencil/gpencil_data.c
@@ -298,8 +298,9 @@ static int gp_layer_remove_exec(bContext *C, wmOperator *op)
bGPDlayer *gpl = BKE_gpencil_layer_getactive(gpd);
/* sanity checks */
- if (ELEM(NULL, gpd, gpl))
+ if (ELEM(NULL, gpd, gpl)) {
return OPERATOR_CANCELLED;
+ }
if (gpl->flag & GP_LAYER_LOCKED) {
BKE_report(op->reports, RPT_ERROR, "Cannot delete locked layers");
@@ -310,10 +311,12 @@ static int gp_layer_remove_exec(bContext *C, wmOperator *op)
* - use the one after if this is the first
* - if this is the only layer, this naturally becomes NULL
*/
- if (gpl->prev)
+ if (gpl->prev) {
BKE_gpencil_layer_setactive(gpd, gpl->prev);
- else
+ }
+ else {
BKE_gpencil_layer_setactive(gpd, gpl->next);
+ }
/* delete the layer now... */
BKE_gpencil_layer_delete(gpd, gpl);
@@ -354,8 +357,9 @@ static int gp_layer_move_exec(bContext *C, wmOperator *op)
const int direction = RNA_enum_get(op->ptr, "type") * -1;
/* sanity checks */
- if (ELEM(NULL, gpd, gpl))
+ if (ELEM(NULL, gpd, gpl)) {
return OPERATOR_CANCELLED;
+ }
BLI_assert(ELEM(direction, -1, 0, 1)); /* we use value below */
if (BLI_listbase_link_move(&gpd->layers, gpl, direction)) {
@@ -398,8 +402,9 @@ static int gp_layer_copy_exec(bContext *C, wmOperator *UNUSED(op))
bGPDlayer *new_layer;
/* sanity checks */
- if (ELEM(NULL, gpd, gpl))
+ if (ELEM(NULL, gpd, gpl)) {
return OPERATOR_CANCELLED;
+ }
/* make copy of layer, and add it immediately after the existing layer */
new_layer = BKE_gpencil_layer_duplicate(gpl);
@@ -446,19 +451,22 @@ static bool gp_layer_duplicate_object_poll(bContext *C)
{
ViewLayer *view_layer = CTX_data_view_layer(C);
Object *ob = CTX_data_active_object(C);
- if ((ob == NULL) || (ob->type != OB_GPENCIL))
+ if ((ob == NULL) || (ob->type != OB_GPENCIL)) {
return false;
+ }
bGPdata *gpd = (bGPdata *)ob->data;
bGPDlayer *gpl = BKE_gpencil_layer_getactive(gpd);
- if (gpl == NULL)
+ if (gpl == NULL) {
return false;
+ }
/* check there are more grease pencil objects */
for (Base *base = view_layer->object_bases.first; base; base = base->next) {
- if ((base->object != ob) && (base->object->type == OB_GPENCIL))
+ if ((base->object != ob) && (base->object->type == OB_GPENCIL)) {
return true;
+ }
}
return false;
@@ -591,8 +599,9 @@ static int gp_frame_duplicate_exec(bContext *C, wmOperator *op)
int mode = RNA_enum_get(op->ptr, "mode");
/* sanity checks */
- if (ELEM(NULL, gpd, gpl))
+ if (ELEM(NULL, gpd, gpl)) {
return OPERATOR_CANCELLED;
+ }
if (mode == 0) {
BKE_gpencil_frame_addcopy(gpl, cfra_eval);
@@ -656,16 +665,18 @@ static int gp_frame_clean_fill_exec(bContext *C, wmOperator *op)
if ((gpf == gpl->actframe) || (mode == GP_FRAME_CLEAN_FILL_ALL)) {
bGPDstroke *gps, *gpsn;
- if (gpf == NULL)
+ if (gpf == NULL) {
continue;
+ }
/* simply delete strokes which are no fill */
for (gps = gpf->strokes.first; gps; gps = gpsn) {
gpsn = 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;
+ }
/* free stroke */
if (gps->flag & GP_STROKE_NOFILL) {
@@ -738,16 +749,18 @@ static int gp_frame_clean_loose_exec(bContext *C, wmOperator *op)
for (bGPDframe *gpf = init_gpf; gpf; gpf = gpf->next) {
if ((gpf == gpl->actframe) || ((gpf->flag & GP_FRAME_SELECT) && (is_multiedit))) {
- if (gpf == NULL)
+ if (gpf == NULL) {
continue;
+ }
/* simply delete strokes which are no loose */
for (gps = gpf->strokes.first; gps; gps = gpsn) {
gpsn = 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;
+ }
/* free stroke */
if (gps->totpoints <= limit) {
@@ -818,8 +831,9 @@ static int gp_hide_exec(bContext *C, wmOperator *op)
bool unselected = RNA_boolean_get(op->ptr, "unselected");
/* sanity checks */
- if (ELEM(NULL, gpd, layer))
+ if (ELEM(NULL, gpd, layer)) {
return OPERATOR_CANCELLED;
+ }
if (unselected) {
bGPDlayer *gpl;
@@ -898,8 +912,9 @@ static int gp_reveal_exec(bContext *C, wmOperator *op)
const bool select = RNA_boolean_get(op->ptr, "select");
/* sanity checks */
- if (gpd == NULL)
+ if (gpd == NULL) {
return OPERATOR_CANCELLED;
+ }
for (gpl = gpd->layers.first; gpl; gpl = gpl->next) {
@@ -958,8 +973,9 @@ static int gp_lock_all_exec(bContext *C, wmOperator *UNUSED(op))
bGPDlayer *gpl;
/* sanity checks */
- if (gpd == NULL)
+ if (gpd == NULL) {
return OPERATOR_CANCELLED;
+ }
/* make all layers non-editable */
for (gpl = gpd->layers.first; gpl; gpl = gpl->next) {
@@ -997,8 +1013,9 @@ static int gp_unlock_all_exec(bContext *C, wmOperator *UNUSED(op))
bGPDlayer *gpl;
/* sanity checks */
- if (gpd == NULL)
+ if (gpd == NULL) {
return OPERATOR_CANCELLED;
+ }
/* make all layers editable again */
for (gpl = gpd->layers.first; gpl; gpl = gpl->next) {
@@ -1037,8 +1054,9 @@ static int gp_isolate_layer_exec(bContext *C, wmOperator *op)
int flags = GP_LAYER_LOCKED;
bool isolate = false;
- if (RNA_boolean_get(op->ptr, "affect_visibility"))
+ if (RNA_boolean_get(op->ptr, "affect_visibility")) {
flags |= GP_LAYER_HIDE;
+ }
if (ELEM(NULL, gpd, layer)) {
BKE_report(op->reports, RPT_ERROR, "No active layer to isolate");
@@ -1048,8 +1066,9 @@ static int gp_isolate_layer_exec(bContext *C, wmOperator *op)
/* Test whether to isolate or clear all flags */
for (gpl = gpd->layers.first; gpl; gpl = gpl->next) {
/* Skip if this is the active layer */
- if (gpl == layer)
+ if (gpl == layer) {
continue;
+ }
/* If the flags aren't set, that means that the layer is
* not alone, so we have some layers to isolate still
@@ -1065,10 +1084,12 @@ static int gp_isolate_layer_exec(bContext *C, wmOperator *op)
if (isolate) {
/* Set flags on all "other" layers */
for (gpl = gpd->layers.first; gpl; gpl = gpl->next) {
- if (gpl == layer)
+ if (gpl == layer) {
continue;
- else
+ }
+ else {
gpl->flag |= flags;
+ }
}
}
else {
@@ -1425,18 +1446,21 @@ static int gp_stroke_change_color_exec(bContext *C, wmOperator *op)
for (bGPDframe *gpf = init_gpf; gpf; gpf = gpf->next) {
if ((gpf == gpl->actframe) || ((gpf->flag & GP_FRAME_SELECT) && (is_multiedit))) {
- if (gpf == NULL)
+ if (gpf == NULL) {
continue;
+ }
for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
/* only if selected */
if (gps->flag & GP_STROKE_SELECT) {
/* 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;
+ }
/* check if the color is editable */
- if (ED_gpencil_stroke_color_use(ob, gpl, gps) == false)
+ if (ED_gpencil_stroke_color_use(ob, gpl, gps) == false) {
continue;
+ }
/* assign new color */
gps->mat_nr = idx;
@@ -1486,8 +1510,9 @@ static int gp_stroke_lock_color_exec(bContext *C, wmOperator *UNUSED(op))
short *totcol = give_totcolp(ob);
/* sanity checks */
- if (ELEM(NULL, gpd))
+ if (ELEM(NULL, gpd)) {
return OPERATOR_CANCELLED;
+ }
/* first lock all colors */
for (short i = 0; i < *totcol; i++) {
@@ -1610,8 +1635,9 @@ static int gpencil_vertex_group_assign_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob = CTX_data_active_object(C);
/* sanity checks */
- if (ELEM(NULL, ts, ob, ob->data))
+ if (ELEM(NULL, ts, ob, ob->data)) {
return OPERATOR_CANCELLED;
+ }
ED_gpencil_vgroup_assign(C, ob, ts->vgroup_weight);
@@ -1644,8 +1670,9 @@ static int gpencil_vertex_group_remove_from_exec(bContext *C, wmOperator *UNUSED
Object *ob = CTX_data_active_object(C);
/* sanity checks */
- if (ELEM(NULL, ob, ob->data))
+ if (ELEM(NULL, ob, ob->data)) {
return OPERATOR_CANCELLED;
+ }
ED_gpencil_vgroup_remove(C, ob);
@@ -1677,8 +1704,9 @@ static int gpencil_vertex_group_select_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob = CTX_data_active_object(C);
/* sanity checks */
- if (ELEM(NULL, ob, ob->data))
+ if (ELEM(NULL, ob, ob->data)) {
return OPERATOR_CANCELLED;
+ }
ED_gpencil_vgroup_select(C, ob);
@@ -1710,8 +1738,9 @@ static int gpencil_vertex_group_deselect_exec(bContext *C, wmOperator *UNUSED(op
Object *ob = CTX_data_active_object(C);
/* sanity checks */
- if (ELEM(NULL, ob, ob->data))
+ if (ELEM(NULL, ob, ob->data)) {
return OPERATOR_CANCELLED;
+ }
ED_gpencil_vgroup_deselect(C, ob);
@@ -2172,8 +2201,9 @@ int ED_gpencil_join_objects_exec(bContext *C, wmOperator *op)
bool ok = false;
/* Ensure we're in right mode and that the active object is correct */
- if (!ob_active || ob_active->type != OB_GPENCIL)
+ if (!ob_active || ob_active->type != OB_GPENCIL) {
return OPERATOR_CANCELLED;
+ }
bGPdata *gpd = (bGPdata *)ob_active->data;
if ((!gpd) || GPENCIL_ANY_MODE(gpd)) {
@@ -2386,14 +2416,16 @@ static int gpencil_lock_layer_exec(bContext *C, wmOperator *UNUSED(op))
MaterialGPencilStyle *gp_style = NULL;
/* sanity checks */
- if (ELEM(NULL, gpd))
+ if (ELEM(NULL, gpd)) {
return OPERATOR_CANCELLED;
+ }
/* first lock and hide all colors */
Material *ma = NULL;
short *totcol = give_totcolp(ob);
- if (totcol == 0)
+ if (totcol == 0) {
return OPERATOR_CANCELLED;
+ }
for (short i = 0; i < *totcol; i++) {
ma = give_current_material(ob, i + 1);
@@ -2410,8 +2442,9 @@ static int gpencil_lock_layer_exec(bContext *C, wmOperator *UNUSED(op))
(gpl->flag & GP_LAYER_ACTIVE)) {
for (bGPDstroke *gps = gpl->actframe->strokes.last; gps; gps = gps->prev) {
/* 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;
+ }
ma = give_current_material(ob, gps->mat_nr + 1);
DEG_id_tag_update(&ma->id, ID_RECALC_COPY_ON_WRITE);
@@ -2463,8 +2496,9 @@ static int gpencil_color_isolate_exec(bContext *C, wmOperator *op)
int flags = GP_STYLE_COLOR_LOCKED;
bool isolate = false;
- if (RNA_boolean_get(op->ptr, "affect_visibility"))
+ if (RNA_boolean_get(op->ptr, "affect_visibility")) {
flags |= GP_STYLE_COLOR_HIDE;
+ }
if (ELEM(NULL, gpd, active_color)) {
BKE_report(op->reports, RPT_ERROR, "No active color to isolate");
@@ -2477,8 +2511,9 @@ static int gpencil_color_isolate_exec(bContext *C, wmOperator *op)
for (short i = 0; i < *totcol; i++) {
ma = give_current_material(ob, i + 1);
/* Skip if this is the active one */
- if (ma == active_ma)
+ if (ma == active_ma) {
continue;
+ }
/* If the flags aren't set, that means that the color is
* not alone, so we have some colors to isolate still
@@ -2496,10 +2531,12 @@ static int gpencil_color_isolate_exec(bContext *C, wmOperator *op)
for (short i = 0; i < *totcol; i++) {
ma = give_current_material(ob, i + 1);
gp_style = ma->gp_style;
- if (gp_style == active_color)
+ if (gp_style == active_color) {
continue;
- else
+ }
+ else {
gp_style->flag |= flags;
+ }
DEG_id_tag_update(&ma->id, ID_RECALC_COPY_ON_WRITE);
}
}
@@ -2560,8 +2597,9 @@ static int gpencil_color_hide_exec(bContext *C, wmOperator *op)
Material *ma = NULL;
short *totcol = give_totcolp(ob);
- if (totcol == 0)
+ if (totcol == 0) {
return OPERATOR_CANCELLED;
+ }
if (unselected) {
/* hide unselected */
@@ -2620,8 +2658,9 @@ static int gpencil_color_reveal_exec(bContext *C, wmOperator *UNUSED(op))
Material *ma = NULL;
short *totcol = give_totcolp(ob);
- if (totcol == 0)
+ if (totcol == 0) {
return OPERATOR_CANCELLED;
+ }
/* make all colors visible */
MaterialGPencilStyle *gp_style = NULL;
@@ -2670,8 +2709,9 @@ static int gpencil_color_lock_all_exec(bContext *C, wmOperator *UNUSED(op))
Material *ma = NULL;
short *totcol = give_totcolp(ob);
- if (totcol == 0)
+ if (totcol == 0) {
return OPERATOR_CANCELLED;
+ }
/* make all layers non-editable */
MaterialGPencilStyle *gp_style = NULL;
@@ -2720,8 +2760,9 @@ static int gpencil_color_unlock_all_exec(bContext *C, wmOperator *UNUSED(op))
Material *ma = NULL;
short *totcol = give_totcolp(ob);
- if (totcol == 0)
+ if (totcol == 0) {
return OPERATOR_CANCELLED;
+ }
/* make all layers editable again*/
MaterialGPencilStyle *gp_style = NULL;
@@ -2771,8 +2812,9 @@ static int gpencil_color_select_exec(bContext *C, wmOperator *op)
const bool deselected = RNA_boolean_get(op->ptr, "deselect");
/* sanity checks */
- if (ELEM(NULL, gpd, gp_style))
+ if (ELEM(NULL, gpd, gp_style)) {
return OPERATOR_CANCELLED;
+ }
/* read all strokes and select*/
CTX_DATA_BEGIN (C, bGPDlayer *, gpl, editable_gpencil_layers) {
@@ -2786,11 +2828,13 @@ static int gpencil_color_select_exec(bContext *C, wmOperator *op)
/* verify something to do */
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;
+ }
/* check if the color is editable */
- if (ED_gpencil_stroke_color_use(ob, gpl, gps) == false)
+ if (ED_gpencil_stroke_color_use(ob, gpl, gps) == false) {
continue;
+ }
/* select */
if (ob->actcol == gps->mat_nr + 1) {
diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c
index 0116747ab82..5ac8cc1761f 100644
--- a/source/blender/editors/gpencil/gpencil_edit.c
+++ b/source/blender/editors/gpencil/gpencil_edit.c
@@ -286,8 +286,9 @@ static int gpencil_paintmode_toggle_exec(bContext *C, wmOperator *op)
is_object = true;
}
- if (gpd == NULL)
+ if (gpd == NULL) {
return OPERATOR_CANCELLED;
+ }
/* Just toggle paintmode flag... */
gpd->flag ^= GP_DATA_STROKE_PAINTMODE;
@@ -386,8 +387,9 @@ static int gpencil_sculptmode_toggle_exec(bContext *C, wmOperator *op)
is_object = true;
}
- if (gpd == NULL)
+ if (gpd == NULL) {
return OPERATOR_CANCELLED;
+ }
/* Just toggle sculptmode flag... */
gpd->flag ^= GP_DATA_STROKE_SCULPTMODE;
@@ -475,8 +477,9 @@ static int gpencil_weightmode_toggle_exec(bContext *C, wmOperator *op)
is_object = true;
}
- if (gpd == NULL)
+ if (gpd == NULL) {
return OPERATOR_CANCELLED;
+ }
/* Just toggle weightmode flag... */
gpd->flag ^= GP_DATA_STROKE_WEIGHTMODE;
@@ -545,8 +548,9 @@ void GPENCIL_OT_weightmode_toggle(wmOperatorType *ot)
static int gpencil_hideselect_toggle_exec(bContext *C, wmOperator *UNUSED(op))
{
View3D *v3d = CTX_wm_view3d(C);
- if (v3d == NULL)
+ if (v3d == NULL) {
return OPERATOR_CANCELLED;
+ }
/* Just toggle alpha... */
if (v3d->vertex_opacity > 0.0f) {
@@ -685,8 +689,9 @@ static int gp_duplicate_exec(bContext *C, wmOperator *op)
bGPDframe *gpf = gpl->actframe;
bGPDstroke *gps;
- if (gpf == NULL)
+ if (gpf == NULL) {
continue;
+ }
/* make copies of selected strokes, and deselect these once we're done */
for (gps = gpf->strokes.first; gps; gps = gps->next) {
@@ -931,13 +936,15 @@ static int gp_extrude_exec(bContext *C, wmOperator *op)
for (bGPDframe *gpf = init_gpf; gpf; gpf = gpf->next) {
if ((gpf == gpl->actframe) || ((gpf->flag & GP_FRAME_SELECT) && (is_multiedit))) {
- if (gpf == NULL)
+ if (gpf == NULL) {
continue;
+ }
for (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;
+ }
if (gps->flag & GP_STROKE_SELECT) {
gpencil_add_move_points(gpf, gps);
@@ -1123,14 +1130,16 @@ static int gp_strokes_copy_exec(bContext *C, wmOperator *op)
bGPDframe *gpf = gpl->actframe;
bGPDstroke *gps;
- if (gpf == NULL)
+ if (gpf == NULL) {
continue;
+ }
/* make copies of selected strokes, and deselect these once we're done */
for (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;
+ }
if (gps->flag & GP_STROKE_SELECT) {
if (gps->totpoints == 1) {
@@ -1278,10 +1287,12 @@ static int gp_strokes_paste_exec(bContext *C, wmOperator *op)
* (i.e. image editor is incompatible with normal 2D strokes),
* but should be enough to give users a good idea of what's going on.
*/
- if (CTX_wm_area(C)->spacetype == SPACE_VIEW3D)
+ if (CTX_wm_area(C)->spacetype == SPACE_VIEW3D) {
BKE_report(op->reports, RPT_ERROR, "Cannot paste 2D strokes in 3D View");
- else
+ }
+ else {
BKE_report(op->reports, RPT_ERROR, "Cannot paste 3D strokes in 2D editors");
+ }
return OPERATOR_CANCELLED;
}
@@ -1444,16 +1455,18 @@ static int gp_move_to_layer_exec(bContext *C, wmOperator *op)
bGPDstroke *gps, *gpsn;
/* skip if no frame with strokes, or if this is the layer we're moving strokes to */
- if ((gpl == target_layer) || (gpf == NULL))
+ if ((gpl == target_layer) || (gpf == NULL)) {
continue;
+ }
/* make copies of selected strokes, and deselect these once we're done */
for (gps = gpf->strokes.first; gps; gps = gpsn) {
gpsn = 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;
+ }
/* TODO: Don't just move entire strokes - instead, only copy the selected portions... */
if (gps->flag & GP_STROKE_SELECT) {
@@ -1679,8 +1692,9 @@ static int gp_actframe_delete_all_exec(bContext *C, wmOperator *op)
/* try to get the "active" frame - but only if it actually occurs on this frame */
bGPDframe *gpf = BKE_gpencil_layer_getframe(gpl, cfra_eval, GP_GETFRAME_USE_PREV);
- if (gpf == NULL)
+ if (gpf == NULL) {
continue;
+ }
/* delete it... */
BKE_gpencil_layer_delframe(gpl, gpf);
@@ -1755,16 +1769,18 @@ static int gp_delete_selected_strokes(bContext *C)
if ((gpf == gpl->actframe) || ((gpf->flag & GP_FRAME_SELECT) && (is_multiedit))) {
bGPDstroke *gps, *gpsn;
- if (gpf == NULL)
+ if (gpf == NULL) {
continue;
+ }
/* simply delete strokes which are selected */
for (gps = gpf->strokes.first; gps; gps = gpsn) {
gpsn = 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;
+ }
/* free stroke if selected */
if (gps->flag & GP_STROKE_SELECT) {
@@ -1820,8 +1836,9 @@ static int gp_dissolve_selected_points(bContext *C, eGP_DissolveMode mode)
bGPDstroke *gps, *gpsn;
- if (gpf == NULL)
+ if (gpf == NULL) {
continue;
+ }
/* simply delete points from selected strokes
* NOTE: we may still have to remove the stroke if it ends up having no points!
@@ -1830,11 +1847,13 @@ static int gp_dissolve_selected_points(bContext *C, eGP_DissolveMode mode)
gpsn = 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;
+ }
/* check if the color is editable */
- if (ED_gpencil_stroke_color_use(ob, gpl, gps) == false)
+ if (ED_gpencil_stroke_color_use(ob, gpl, gps) == false) {
continue;
+ }
/* the stroke must have at least one point selected for any operator */
if (gps->flag & GP_STROKE_SELECT) {
@@ -2313,19 +2332,22 @@ static int gp_delete_selected_points(bContext *C)
if ((gpf == gpl->actframe) || ((gpf->flag & GP_FRAME_SELECT) && (is_multiedit))) {
bGPDstroke *gps, *gpsn;
- if (gpf == NULL)
+ if (gpf == NULL) {
continue;
+ }
/* simply delete strokes which are selected */
for (gps = gpf->strokes.first; gps; gps = gpsn) {
gpsn = 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;
+ }
/* check if the color is editable */
- if (ED_gpencil_stroke_color_use(ob, gpl, gps) == false)
+ if (ED_gpencil_stroke_color_use(ob, gpl, gps) == false) {
continue;
+ }
if (gps->flag & GP_STROKE_SELECT) {
/* deselect old stroke, since it will be used as template for the new strokes */
@@ -2499,11 +2521,13 @@ static int gp_snap_to_grid(bContext *C, wmOperator *UNUSED(op))
int i;
/* 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;
+ }
/* check if the color is editable */
- if (ED_gpencil_stroke_color_use(obact, gpl, gps) == false)
+ if (ED_gpencil_stroke_color_use(obact, gpl, gps) == false) {
continue;
+ }
// TODO: if entire stroke is selected, offset entire stroke by same amount?
for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
@@ -2574,14 +2598,17 @@ static int gp_snap_to_cursor(bContext *C, wmOperator *op)
int i;
/* 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;
+ }
/* check if the color is editable */
- if (ED_gpencil_stroke_color_use(obact, gpl, gps) == false)
+ if (ED_gpencil_stroke_color_use(obact, gpl, gps) == false) {
continue;
+ }
/* only continue if this stroke is selected (editable doesn't guarantee this)... */
- if ((gps->flag & GP_STROKE_SELECT) == 0)
+ if ((gps->flag & GP_STROKE_SELECT) == 0) {
continue;
+ }
if (use_offset) {
float offset[3];
@@ -2669,14 +2696,17 @@ static int gp_snap_cursor_to_sel(bContext *C, wmOperator *UNUSED(op))
int i;
/* 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;
+ }
/* check if the color is editable */
- if (ED_gpencil_stroke_color_use(obact, gpl, gps) == false)
+ if (ED_gpencil_stroke_color_use(obact, gpl, gps) == false) {
continue;
+ }
/* only continue if this stroke is selected (editable doesn't guarantee this)... */
- if ((gps->flag & GP_STROKE_SELECT) == 0)
+ if ((gps->flag & GP_STROKE_SELECT) == 0) {
continue;
+ }
for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
if (pt->flag & GP_SPOINT_SELECT) {
@@ -2731,8 +2761,9 @@ static int gp_stroke_apply_thickness_exec(bContext *C, wmOperator *UNUSED(op))
bGPDlayer *gpl = BKE_gpencil_layer_getactive(gpd);
/* sanity checks */
- if (ELEM(NULL, gpd, gpl, gpl->frames.first))
+ if (ELEM(NULL, gpd, gpl, gpl->frames.first)) {
return OPERATOR_CANCELLED;
+ }
/* loop all strokes */
for (bGPDframe *gpf = gpl->frames.first; gpf; gpf = gpf->next) {
@@ -2785,24 +2816,28 @@ static int gp_stroke_cyclical_set_exec(bContext *C, wmOperator *op)
const int type = RNA_enum_get(op->ptr, "type");
/* sanity checks */
- if (ELEM(NULL, gpd))
+ if (ELEM(NULL, gpd)) {
return OPERATOR_CANCELLED;
+ }
/* loop all selected strokes */
CTX_DATA_BEGIN (C, bGPDlayer *, gpl, editable_gpencil_layers) {
- if (gpl->actframe == NULL)
+ if (gpl->actframe == NULL) {
continue;
+ }
for (bGPDstroke *gps = gpl->actframe->strokes.last; gps; gps = gps->prev) {
MaterialGPencilStyle *gp_style = BKE_material_gpencil_settings_get(ob, gps->mat_nr + 1);
/* skip strokes that are not selected or invalid for current view */
- if (((gps->flag & GP_STROKE_SELECT) == 0) || ED_gpencil_stroke_can_use(C, gps) == false)
+ if (((gps->flag & GP_STROKE_SELECT) == 0) || ED_gpencil_stroke_can_use(C, gps) == false) {
continue;
+ }
/* skip hidden or locked colors */
if (!gp_style || (gp_style->flag & GP_STYLE_COLOR_HIDE) ||
- (gp_style->flag & GP_STYLE_COLOR_LOCKED))
+ (gp_style->flag & GP_STYLE_COLOR_LOCKED)) {
continue;
+ }
switch (type) {
case GP_STROKE_CYCLIC_CLOSE:
@@ -2878,13 +2913,15 @@ static int gp_stroke_caps_set_exec(bContext *C, wmOperator *op)
const int type = RNA_enum_get(op->ptr, "type");
/* sanity checks */
- if (ELEM(NULL, gpd))
+ if (ELEM(NULL, gpd)) {
return OPERATOR_CANCELLED;
+ }
/* loop all selected strokes */
CTX_DATA_BEGIN (C, bGPDlayer *, gpl, editable_gpencil_layers) {
- if (gpl->actframe == NULL)
+ if (gpl->actframe == NULL) {
continue;
+ }
for (bGPDstroke *gps = gpl->actframe->strokes.last; gps; gps = gps->prev) {
MaterialGPencilStyle *gp_style = BKE_material_gpencil_settings_get(ob, gps->mat_nr + 1);
@@ -3047,11 +3084,13 @@ static void gpencil_stroke_join_strokes(bGPDstroke *gps_a,
float deltatime = 0.0f;
/* sanity checks */
- if (ELEM(NULL, gps_a, gps_b))
+ if (ELEM(NULL, gps_a, gps_b)) {
return;
+ }
- if ((gps_a->totpoints == 0) || (gps_b->totpoints == 0))
+ if ((gps_a->totpoints == 0) || (gps_b->totpoints == 0)) {
return;
+ }
/* define start and end points of each stroke */
float sa[3], sb[3], ea[3], eb[3];
@@ -3112,11 +3151,13 @@ static int gp_stroke_join_exec(bContext *C, wmOperator *op)
const bool leave_gaps = RNA_boolean_get(op->ptr, "leave_gaps");
/* sanity checks */
- if (ELEM(NULL, gpd))
+ if (ELEM(NULL, gpd)) {
return OPERATOR_CANCELLED;
+ }
- if (activegpl->flag & GP_LAYER_LOCKED)
+ if (activegpl->flag & GP_LAYER_LOCKED) {
return OPERATOR_CANCELLED;
+ }
BLI_assert(ELEM(type, GP_STROKE_JOIN, GP_STROKE_JOINCOPY));
@@ -3124,8 +3165,9 @@ static int gp_stroke_join_exec(bContext *C, wmOperator *op)
bool first = false;
CTX_DATA_BEGIN (C, bGPDlayer *, gpl, editable_gpencil_layers) {
bGPDframe *gpf = gpl->actframe;
- if (gpf == NULL)
+ if (gpf == NULL) {
continue;
+ }
for (gps = gpf->strokes.first; gps; gps = gpsn) {
gpsn = gps->next;
@@ -3196,8 +3238,9 @@ static int gp_stroke_join_exec(bContext *C, wmOperator *op)
if (type == GP_STROKE_JOINCOPY) {
if (new_stroke) {
/* Add a new frame if needed */
- if (activegpl->actframe == NULL)
+ if (activegpl->actframe == NULL) {
activegpl->actframe = BKE_gpencil_frame_addnew(activegpl, gpf_a->framenum);
+ }
BLI_addtail(&activegpl->actframe->strokes, new_stroke);
}
@@ -3247,14 +3290,16 @@ static int gp_stroke_flip_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob = CTX_data_active_object(C);
/* sanity checks */
- if (ELEM(NULL, gpd))
+ if (ELEM(NULL, gpd)) {
return OPERATOR_CANCELLED;
+ }
/* read all selected strokes */
CTX_DATA_BEGIN (C, bGPDlayer *, gpl, editable_gpencil_layers) {
bGPDframe *gpf = gpl->actframe;
- if (gpf == NULL)
+ if (gpf == NULL) {
continue;
+ }
for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
if (gps->flag & GP_STROKE_SELECT) {
@@ -3569,8 +3614,9 @@ static int gp_stroke_subdivide_exec(bContext *C, wmOperator *op)
int i2;
/* sanity checks */
- if (ELEM(NULL, gpd))
+ if (ELEM(NULL, gpd)) {
return OPERATOR_CANCELLED;
+ }
/* Go through each editable + selected stroke */
GP_EDITABLE_STROKES_BEGIN (gpstroke_iter, C, gpl, gps) {
@@ -3731,8 +3777,9 @@ static int gp_stroke_simplify_exec(bContext *C, wmOperator *op)
float factor = RNA_float_get(op->ptr, "factor");
/* sanity checks */
- if (ELEM(NULL, gpd))
+ if (ELEM(NULL, gpd)) {
return OPERATOR_CANCELLED;
+ }
/* Go through each editable + selected stroke */
GP_EDITABLE_STROKES_BEGIN (gpstroke_iter, C, gpl, gps) {
@@ -3779,8 +3826,9 @@ static int gp_stroke_simplify_fixed_exec(bContext *C, wmOperator *op)
int steps = RNA_int_get(op->ptr, "step");
/* sanity checks */
- if (ELEM(NULL, gpd))
+ if (ELEM(NULL, gpd)) {
return OPERATOR_CANCELLED;
+ }
/* Go through each editable + selected stroke */
GP_EDITABLE_STROKES_BEGIN (gpstroke_iter, C, gpl, gps) {
@@ -3828,8 +3876,9 @@ static int gp_stroke_trim_exec(bContext *C, wmOperator *UNUSED(op))
bGPdata *gpd = ED_gpencil_data_get_active(C);
/* sanity checks */
- if (ELEM(NULL, gpd))
+ if (ELEM(NULL, gpd)) {
return OPERATOR_CANCELLED;
+ }
/* Go through each editable + selected stroke */
const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd);
@@ -3844,15 +3893,17 @@ static int gp_stroke_trim_exec(bContext *C, wmOperator *UNUSED(op))
if ((gpf == gpl->actframe) || ((gpf->flag & GP_FRAME_SELECT) && (is_multiedit))) {
bGPDstroke *gps, *gpsn;
- if (gpf == NULL)
+ if (gpf == NULL) {
continue;
+ }
for (gps = gpf->strokes.first; gps; gps = gpsn) {
gpsn = 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;
+ }
if (gps->flag & GP_STROKE_SELECT) {
BKE_gpencil_trim_stroke(gps);
@@ -4205,8 +4256,9 @@ static int gp_stroke_smooth_exec(bContext *C, wmOperator *op)
bGPdata *gpd = ED_gpencil_data_get_active(C);
/* sanity checks */
- if (ELEM(NULL, gpd))
+ if (ELEM(NULL, gpd)) {
return OPERATOR_CANCELLED;
+ }
gp_smooth_stroke(C, op);
@@ -4427,8 +4479,9 @@ static bool gpencil_cutter_poll(bContext *C)
bGPdata *gpd = ED_gpencil_data_get_active(C);
if (GPENCIL_PAINT_MODE(gpd)) {
- if (gpd->layers.first)
+ if (gpd->layers.first) {
return true;
+ }
}
return false;
diff --git a/source/blender/editors/gpencil/gpencil_fill.c b/source/blender/editors/gpencil/gpencil_fill.c
index f873b9e2b7c..616db4b73f7 100644
--- a/source/blender/editors/gpencil/gpencil_fill.c
+++ b/source/blender/editors/gpencil/gpencil_fill.c
@@ -250,8 +250,9 @@ static void gp_draw_datablock(tGPDfill *tgpf, const float ink[4])
ED_gpencil_parent_location(tgpw.depsgraph, ob, gpd, gpl, tgpw.diff_mat);
/* do not draw layer if hidden */
- if (gpl->flag & GP_LAYER_HIDE)
+ if (gpl->flag & GP_LAYER_HIDE) {
continue;
+ }
/* if active layer and no keyframe, create a new one */
if (gpl == tgpf->gpl) {
@@ -262,8 +263,9 @@ static void gp_draw_datablock(tGPDfill *tgpf, const float ink[4])
/* get frame to draw */
bGPDframe *gpf = BKE_gpencil_layer_getframe(gpl, cfra_eval, GP_GETFRAME_USE_PREV);
- if (gpf == NULL)
+ if (gpf == NULL) {
continue;
+ }
for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
/* check if stroke can be drawn */
@@ -960,8 +962,9 @@ static void gpencil_get_depth_array(tGPDfill *tgpf)
if (found_depth == false) {
/* eeh... not much we can do.. :/, ignore depth in this case */
- for (i = totpoints - 1; i >= 0; i--)
+ for (i = totpoints - 1; i >= 0; i--) {
tgpf->depth_arr[i] = 0.9999f;
+ }
}
else {
if (interp_depth) {
@@ -1347,8 +1350,9 @@ static int gpencil_fill_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSE
/* try to initialize context data needed */
if (!gpencil_fill_init(C, op)) {
gpencil_fill_exit(C, op);
- if (op->customdata)
+ if (op->customdata) {
MEM_freeN(op->customdata);
+ }
return OPERATOR_CANCELLED;
}
else {
diff --git a/source/blender/editors/gpencil/gpencil_interpolate.c b/source/blender/editors/gpencil/gpencil_interpolate.c
index 5c9b9416330..d83cc7858bd 100644
--- a/source/blender/editors/gpencil/gpencil_interpolate.c
+++ b/source/blender/editors/gpencil/gpencil_interpolate.c
@@ -541,8 +541,9 @@ static int gpencil_interpolate_invoke(bContext *C, wmOperator *op, const wmEvent
/* try to initialize context data needed */
if (!gpencil_interpolate_init(C, op)) {
- if (op->customdata)
+ if (op->customdata) {
MEM_freeN(op->customdata);
+ }
return OPERATOR_CANCELLED;
}
else {
@@ -1129,8 +1130,9 @@ static int gpencil_interpolate_reverse_exec(bContext *C, wmOperator *UNUSED(op))
bGPDframe *gpf, *gpfn;
/* Only continue if we're currently on a breakdown keyframe */
- if ((gpl->actframe == NULL) || (gpl->actframe->key_type != BEZT_KEYTYPE_BREAKDOWN))
+ if ((gpl->actframe == NULL) || (gpl->actframe->key_type != BEZT_KEYTYPE_BREAKDOWN)) {
continue;
+ }
/* Search left for "start_key" (i.e. the first breakdown to remove) */
gpf = gpl->actframe;
diff --git a/source/blender/editors/gpencil/gpencil_merge.c b/source/blender/editors/gpencil/gpencil_merge.c
index 48c761919e5..9d3c2a6e271 100644
--- a/source/blender/editors/gpencil/gpencil_merge.c
+++ b/source/blender/editors/gpencil/gpencil_merge.c
@@ -66,10 +66,12 @@ static int gpencil_sort_points(const void *a1, const void *a2)
{
const tGPencilPointCache *ps1 = a1, *ps2 = a2;
- if (ps1->factor < ps2->factor)
+ if (ps1->factor < ps2->factor) {
return -1;
- else if (ps1->factor > ps2->factor)
+ }
+ else if (ps1->factor > ps2->factor) {
return 1;
+ }
return 0;
}
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index 02f53f09c23..f985ade9c7e 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -368,20 +368,23 @@ static bool gp_stroke_filtermval(tGPsdata *p, const float mval[2], float mvalo[2
/* check if mouse moved at least certain distance on both axes (best case)
* - aims to eliminate some jitter-noise from input when trying to draw straight lines freehand
*/
- else if ((dx > MIN_MANHATTEN_PX) && (dy > MIN_MANHATTEN_PX))
+ else if ((dx > MIN_MANHATTEN_PX) && (dy > MIN_MANHATTEN_PX)) {
return true;
- /* Check if the distance since the last point is significant enough:
+ /* Check if the distance since the last point is significant enough:
* - Prevents points being added too densely
* - Distance here doesn't use sqrt to prevent slowness.
* We should still be safe from overflows though.
*/
- else if ((dx * dx + dy * dy) > MIN_EUCLIDEAN_PX * MIN_EUCLIDEAN_PX)
+ }
+ else if ((dx * dx + dy * dy) > MIN_EUCLIDEAN_PX * MIN_EUCLIDEAN_PX) {
return true;
- /* mouse 'didn't move' */
- else
+ /* mouse 'didn't move' */
+ }
+ else {
return false;
+ }
}
/* reproject stroke to plane locked to axis in 3d cursor location */
@@ -659,8 +662,9 @@ static short gp_stroke_addpoint(tGPsdata *p, const float mval[2], float pressure
}
else if (p->paintmode == GP_PAINTMODE_DRAW) { /* normal drawing */
/* check if still room in buffer */
- if (gpd->runtime.sbuffer_size >= GP_STROKE_BUFFER_MAX)
+ if (gpd->runtime.sbuffer_size >= GP_STROKE_BUFFER_MAX) {
return GP_STROKEADD_OVERFLOW;
+ }
/* get pointer to destination point */
pt = ((tGPspoint *)(gpd->runtime.sbuffer) + gpd->runtime.sbuffer_size);
@@ -795,10 +799,12 @@ static short gp_stroke_addpoint(tGPsdata *p, const float mval[2], float pressure
}
/* check if another operation can still occur */
- if (gpd->runtime.sbuffer_size == GP_STROKE_BUFFER_MAX)
+ if (gpd->runtime.sbuffer_size == GP_STROKE_BUFFER_MAX) {
return GP_STROKEADD_FULL;
- else
+ }
+ else {
return GP_STROKEADD_NORMAL;
+ }
}
else if (p->paintmode == GP_PAINTMODE_DRAW_POLY) {
@@ -883,8 +889,9 @@ static short gp_stroke_addpoint(tGPsdata *p, const float mval[2], float pressure
}
/* increment counters */
- if (gpd->runtime.sbuffer_size == 0)
+ if (gpd->runtime.sbuffer_size == 0) {
gpd->runtime.sbuffer_size++;
+ }
return GP_STROKEADD_NORMAL;
}
@@ -922,16 +929,19 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
/* get total number of points to allocate space for
* - drawing straight-lines only requires the endpoints
*/
- if (p->paintmode == GP_PAINTMODE_DRAW_STRAIGHT)
+ if (p->paintmode == GP_PAINTMODE_DRAW_STRAIGHT) {
totelem = (gpd->runtime.sbuffer_size >= 2) ? 2 : gpd->runtime.sbuffer_size;
- else
+ }
+ else {
totelem = gpd->runtime.sbuffer_size;
+ }
/* exit with error if no valid points from this stroke */
if (totelem == 0) {
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("Error: No valid points in stroke buffer to convert (tot=%d)\n",
gpd->runtime.sbuffer_size);
+ }
return;
}
@@ -1115,8 +1125,9 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
if (found_depth == false) {
/* eeh... not much we can do.. :/, ignore depth in this case, use the 3D cursor */
- for (i = gpd->runtime.sbuffer_size - 1; i >= 0; i--)
+ for (i = gpd->runtime.sbuffer_size - 1; i >= 0; i--) {
depth_arr[i] = 0.9999f;
+ }
}
else {
if ((ts->gpencil_v3d_align & GP_PROJECT_DEPTH_STROKE_ENDPOINTS) ||
@@ -1126,8 +1137,9 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
/* find first valid contact point */
for (i = 0; i < gpd->runtime.sbuffer_size; i++) {
- if (depth_arr[i] != FLT_MAX)
+ if (depth_arr[i] != FLT_MAX) {
break;
+ }
}
first_valid = i;
@@ -1137,8 +1149,9 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
}
else {
for (i = gpd->runtime.sbuffer_size - 1; i >= 0; i--) {
- if (depth_arr[i] != FLT_MAX)
+ if (depth_arr[i] != FLT_MAX) {
break;
+ }
}
last_valid = i;
}
@@ -1226,8 +1239,9 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
ED_gpencil_project_stroke_to_view(p->C, p->gpl, gps);
}
- if (depth_arr)
+ if (depth_arr) {
MEM_freeN(depth_arr);
+ }
}
/* Save material index */
@@ -1365,8 +1379,9 @@ static void gp_free_stroke(bGPdata *gpd, bGPDframe *gpf, bGPDstroke *gps)
MEM_freeN(gps->dvert);
}
- if (gps->triangles)
+ if (gps->triangles) {
MEM_freeN(gps->triangles);
+ }
BLI_freelinkN(&gpf->strokes, gps);
gp_update_cache(gpd);
}
@@ -1461,8 +1476,9 @@ static void gp_stroke_eraser_dostroke(tGPsdata *p,
for (i = 0; (i + 1) < gps->totpoints; i++) {
/* only process if it hasn't been masked out... */
- if ((p->flags & GP_PAINTFLAG_SELECTMASK) && !(gps->points->flag & GP_SPOINT_SELECT))
+ if ((p->flags & GP_PAINTFLAG_SELECTMASK) && !(gps->points->flag & GP_SPOINT_SELECT)) {
continue;
+ }
/* get points to work with */
pt1 = gps->points + i;
@@ -1513,8 +1529,9 @@ static void gp_stroke_eraser_dostroke(tGPsdata *p,
pt2 = gps->points + i + 1;
/* only process if it hasn't been masked out... */
- if ((p->flags & GP_PAINTFLAG_SELECTMASK) && !(gps->points->flag & GP_SPOINT_SELECT))
+ if ((p->flags & GP_PAINTFLAG_SELECTMASK) && !(gps->points->flag & GP_SPOINT_SELECT)) {
continue;
+ }
bGPDspoint npt;
if (pt0) {
@@ -1884,8 +1901,9 @@ static bool gp_session_initdata(bContext *C, wmOperator *op, tGPsdata *p)
/* make sure the active view (at the starting time) is a 3d-view */
if (curarea == NULL) {
p->status = GP_STATUS_ERROR;
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("Error: No active view for painting\n");
+ }
return 0;
}
@@ -1916,10 +1934,11 @@ static bool gp_session_initdata(bContext *C, wmOperator *op, tGPsdata *p)
if (ar->regiondata == NULL) {
p->status = GP_STATUS_ERROR;
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf(
"Error: 3D-View active region doesn't have any region data, so cannot be "
"drawable\n");
+ }
return 0;
}
@@ -1944,8 +1963,9 @@ static bool gp_session_initdata(bContext *C, wmOperator *op, tGPsdata *p)
/* unsupported views */
default: {
p->status = GP_STATUS_ERROR;
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("Error: Active view not appropriate for Grease Pencil drawing\n");
+ }
return 0;
}
}
@@ -1954,14 +1974,16 @@ static bool gp_session_initdata(bContext *C, wmOperator *op, tGPsdata *p)
gpd_ptr = ED_gpencil_data_get_pointers(C, &p->ownerPtr);
if ((gpd_ptr == NULL) || ED_gpencil_data_owner_is_annotation(&p->ownerPtr)) {
p->status = GP_STATUS_ERROR;
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("Error: Current context doesn't allow for any Grease Pencil data\n");
+ }
return 0;
}
else {
/* if no existing GPencil block exists, add one */
- if (*gpd_ptr == NULL)
+ if (*gpd_ptr == NULL) {
*gpd_ptr = BKE_gpencil_data_addnew(bmain, "GPencil");
+ }
p->gpd = *gpd_ptr;
}
@@ -2036,8 +2058,9 @@ static void gp_session_cleanup(tGPsdata *p)
bGPdata *gpd = (p) ? p->gpd : NULL;
/* error checking */
- if (gpd == NULL)
+ if (gpd == NULL) {
return;
+ }
/* free stroke buffer */
if (gpd->runtime.sbuffer) {
@@ -2079,8 +2102,9 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode, Deps
}
if ((paintmode != GP_PAINTMODE_ERASER) && (p->gpl->flag & GP_LAYER_LOCKED)) {
p->status = GP_STATUS_ERROR;
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("Error: Cannot paint on locked layer\n");
+ }
return;
}
@@ -2095,8 +2119,9 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode, Deps
for (bGPDlayer *gpl = p->gpd->layers.first; gpl; gpl = gpl->next) {
/* Skip if layer not editable */
- if (gpencil_layer_is_editable(gpl) == false)
+ if (gpencil_layer_is_editable(gpl) == false) {
continue;
+ }
/* Add a new frame if needed (and based off the active frame,
* as we need some existing strokes to erase)
@@ -2137,17 +2162,20 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode, Deps
/* Drawing Modes - Add a new frame if needed on the active layer */
short add_frame_mode;
- if (ts->gpencil_flags & GP_TOOL_FLAG_RETAIN_LAST)
+ if (ts->gpencil_flags & GP_TOOL_FLAG_RETAIN_LAST) {
add_frame_mode = GP_GETFRAME_ADD_COPY;
- else
+ }
+ else {
add_frame_mode = GP_GETFRAME_ADD_NEW;
+ }
p->gpf = BKE_gpencil_layer_getframe(p->gpl, cfra_eval, add_frame_mode);
if (p->gpf == NULL) {
p->status = GP_STATUS_ERROR;
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("Error: No frame created (gpencil_paint_init)\n");
+ }
return;
}
else {
@@ -2254,8 +2282,9 @@ static void gp_paint_cleanup(tGPsdata *p)
}
/* "unlock" frame */
- if (p->gpf)
+ if (p->gpf) {
p->gpf->flag &= ~GP_FRAME_PAINT;
+ }
}
/* ------------------------------- */
@@ -2588,8 +2617,9 @@ static void gpencil_draw_apply(bContext *C, wmOperator *op, tGPsdata *p, Depsgra
BKE_report(op->reports, RPT_ERROR, "Cannot paint stroke");
p->status = GP_STATUS_ERROR;
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("Error: Grease-Pencil Paint - Add Point Invalid\n");
+ }
return;
}
@@ -2947,8 +2977,9 @@ static int gpencil_draw_exec(bContext *C, wmOperator *op)
/* printf("\tGP - no valid data\n"); */
return OPERATOR_CANCELLED;
}
- else
+ else {
p = op->customdata;
+ }
/* printf("\tGP - Start redrawing stroke\n"); */
@@ -3086,10 +3117,12 @@ static void gpencil_guide_event_handling(bContext *C,
add_notifier = true;
float angle = guide->angle;
float adjust = (float)M_PI / 180.0f;
- if (event->alt)
+ if (event->alt) {
adjust *= 45.0f;
- else if (!event->shift)
+ }
+ else if (!event->shift) {
adjust *= 15.0f;
+ }
angle += (event->type == JKEY) ? adjust : -adjust;
angle = angle_compat_rad(angle, M_PI);
guide->angle = angle;
@@ -3107,8 +3140,9 @@ static int gpencil_draw_invoke(bContext *C, wmOperator *op, const wmEvent *event
Object *ob = CTX_data_active_object(C);
bGPdata *gpd = (bGPdata *)ob->data;
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("GPencil - Starting Drawing\n");
+ }
/* support for tablets eraser pen */
if (gpencil_is_tablet_eraser_active(event)) {
@@ -3144,14 +3178,17 @@ static int gpencil_draw_invoke(bContext *C, wmOperator *op, const wmEvent *event
/* try to initialize context data needed while drawing */
if (!gpencil_draw_init(C, op, event)) {
- if (op->customdata)
+ if (op->customdata) {
MEM_freeN(op->customdata);
- if (G.debug & G_DEBUG)
+ }
+ if (G.debug & G_DEBUG) {
printf("\tGP - no valid data\n");
+ }
return OPERATOR_CANCELLED;
}
- else
+ else {
p = op->customdata;
+ }
/* TODO: set any additional settings that we can take from the events?
* TODO? if tablet is erasing, force eraser to be on? */
@@ -3241,8 +3278,9 @@ static tGPsdata *gpencil_stroke_begin(bContext *C, wmOperator *op)
/* XXX: watch it with the paintmode! in future,
* it'd be nice to allow changing paint-mode when in sketching-sessions */
- if (gp_session_initdata(C, op, p))
+ if (gp_session_initdata(C, op, p)) {
gp_paint_initstroke(p, p->paintmode, CTX_data_depsgraph(C));
+ }
if (p->status != GP_STATUS_ERROR) {
p->status = GP_STATUS_PAINTING;
@@ -3593,8 +3631,9 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event)
p->status = GP_STATUS_ERROR;
estate = OPERATOR_CANCELLED;
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("%s: Region under cursor is out of bounds, so cannot be drawn on\n", __func__);
+ }
}
}
else if (p->ar) {
@@ -3609,8 +3648,9 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event)
p->status = GP_STATUS_ERROR;
estate = OPERATOR_CANCELLED;
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("%s: No active region found in GP Paint session data\n", __func__);
+ }
}
if (in_bounds) {
@@ -3701,8 +3741,9 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event)
case PADMINUS:
p->radius -= 5;
- if (p->radius <= 0)
+ if (p->radius <= 0) {
p->radius = 1;
+ }
break;
}
@@ -3723,8 +3764,9 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
/* gpencil modal operator stores area, which can be removed while using it (like fullscreen) */
- if (0 == gpencil_area_exists(C, p->sa))
+ if (0 == gpencil_area_exists(C, p->sa)) {
estate = OPERATOR_CANCELLED;
+ }
else {
/* update status indicators - cursor, header, etc. */
gpencil_draw_status_indicators(C, p);
diff --git a/source/blender/editors/gpencil/gpencil_primitive.c b/source/blender/editors/gpencil/gpencil_primitive.c
index f178d232376..08fee2bb393 100644
--- a/source/blender/editors/gpencil/gpencil_primitive.c
+++ b/source/blender/editors/gpencil/gpencil_primitive.c
@@ -129,8 +129,9 @@ static void gp_session_validatebuffer(tGPDprimitive *p)
gpd->runtime.sbuffer_sflag = 0;
gpd->runtime.sbuffer_sflag |= GP_STROKE_3DSPACE;
- if (ELEM(p->type, GP_STROKE_BOX, GP_STROKE_CIRCLE))
+ if (ELEM(p->type, GP_STROKE_BOX, GP_STROKE_CIRCLE)) {
gpd->runtime.sbuffer_sflag |= GP_STROKE_CYCLIC;
+ }
}
static void gp_init_colors(tGPDprimitive *p)
@@ -174,16 +175,20 @@ static void gpencil_primitive_to_square(tGPDprimitive *tgpi, const float x, cons
float w = fabsf(x);
float h = fabsf(y);
if ((x > 0 && y > 0) || (x < 0 && y < 0)) {
- if (w > h)
+ if (w > h) {
tgpi->end[1] = tgpi->origin[1] + x;
- else
+ }
+ else {
tgpi->end[0] = tgpi->origin[0] + y;
+ }
}
else {
- if (w > h)
+ if (w > h) {
tgpi->end[1] = tgpi->origin[1] - x;
- else
+ }
+ else {
tgpi->end[0] = tgpi->origin[0] - y;
+ }
}
}
@@ -289,8 +294,9 @@ static void gpencil_primitive_allocate_memory(tGPDprimitive *tgpi)
tgpi->point_count += (tgpi->type == GP_STROKE_BOX) ? (MAX_EDGES * 4 + 1) : (MAX_EDGES + 1);
bGPDstroke *gpsf = tgpi->gpf->strokes.first;
gpsf->points = MEM_reallocN(gpsf->points, sizeof(bGPDspoint) * tgpi->point_count);
- if (gpsf->dvert != NULL)
+ if (gpsf->dvert != NULL) {
gpsf->dvert = MEM_reallocN(gpsf->dvert, sizeof(MDeformVert) * tgpi->point_count);
+ }
tgpi->points = MEM_reallocN(tgpi->points, sizeof(tGPspoint) * tgpi->point_count);
}
@@ -675,13 +681,16 @@ static void gp_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi)
const bool is_camera = (bool)(ts->gp_sculpt.lock_axis == 0) &&
(tgpi->rv3d->persp == RV3D_CAMOB) && (!is_depth);
- if (tgpi->type == GP_STROKE_BOX)
+ if (tgpi->type == GP_STROKE_BOX) {
gps->totpoints = (tgpi->tot_edges * 4 + tgpi->tot_stored_edges);
- else
+ }
+ else {
gps->totpoints = (tgpi->tot_edges + tgpi->tot_stored_edges);
+ }
- if (tgpi->tot_stored_edges)
+ if (tgpi->tot_stored_edges) {
gps->totpoints--;
+ }
tgpi->gpd->runtime.tot_cp_points = 0;
@@ -778,8 +787,9 @@ static void gp_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi)
/* find first valid contact point */
for (i = 0; i < gps->totpoints; i++) {
- if (depth_arr[i] != FLT_MAX)
+ if (depth_arr[i] != FLT_MAX) {
break;
+ }
}
first_valid = i;
@@ -789,8 +799,9 @@ static void gp_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi)
}
else {
for (i = gps->totpoints - 1; i >= 0; i--) {
- if (depth_arr[i] != FLT_MAX)
+ if (depth_arr[i] != FLT_MAX) {
break;
+ }
}
last_valid = i;
}
@@ -1325,16 +1336,18 @@ static void gpencil_primitive_edit_event_handling(
float dy = (tgpi->mval[1] - tgpi->mvalo[1]);
tgpi->cp1[0] += dx;
tgpi->cp1[1] += dy;
- if (event->shift)
+ if (event->shift) {
copy_v2_v2(tgpi->cp2, tgpi->cp1);
+ }
}
else if (tgpi->sel_cp == SELECT_CP2) {
float dx = (tgpi->mval[0] - tgpi->mvalo[0]);
float dy = (tgpi->mval[1] - tgpi->mvalo[1]);
tgpi->cp2[0] += dx;
tgpi->cp2[1] += dy;
- if (event->shift)
+ if (event->shift) {
copy_v2_v2(tgpi->cp1, tgpi->cp2);
+ }
}
/* update screen */
gpencil_primitive_update(C, op, tgpi);
@@ -1344,12 +1357,15 @@ static void gpencil_primitive_edit_event_handling(
case LEFTMOUSE: {
if ((event->val == KM_PRESS)) {
/* find nearest cp based on stroke end points */
- if (move == MOVE_ENDS)
+ if (move == MOVE_ENDS) {
tgpi->sel_cp = (a < b) ? SELECT_START : SELECT_END;
- else if (move == MOVE_CP)
+ }
+ else if (move == MOVE_CP) {
tgpi->sel_cp = (c < d) ? SELECT_CP1 : SELECT_CP2;
- else
+ }
+ else {
tgpi->sel_cp = SELECT_NONE;
+ }
break;
}
else if ((event->val == KM_RELEASE) && (tgpi->flag == IN_PROGRESS)) {
diff --git a/source/blender/editors/gpencil/gpencil_select.c b/source/blender/editors/gpencil/gpencil_select.c
index 6b5c728c4ed..365fb319b3b 100644
--- a/source/blender/editors/gpencil/gpencil_select.c
+++ b/source/blender/editors/gpencil/gpencil_select.c
@@ -74,8 +74,9 @@ static bool gpencil_select_poll(bContext *C)
/* we just need some visible strokes, and to be in editmode or other modes only to catch event */
if (GPENCIL_ANY_MODE(gpd)) {
/* TODO: include a check for visible strokes? */
- if (gpd->layers.first)
+ if (gpd->layers.first) {
return true;
+ }
}
return false;
@@ -309,8 +310,9 @@ static void gp_select_same_layer(bContext *C)
bGPDstroke *gps;
bool found = false;
- if (gpf == NULL)
+ if (gpf == NULL) {
continue;
+ }
/* Search for a selected stroke */
for (gps = gpf->strokes.first; gps; gps = gps->next) {
@@ -1388,17 +1390,21 @@ static int gpencil_select_exec(bContext *C, wmOperator *op)
/* entire stroke's points */
for (i = 0, pt = hit_stroke->points; i < hit_stroke->totpoints; i++, pt++) {
- if (deselect == false)
+ if (deselect == false) {
pt->flag |= GP_SPOINT_SELECT;
- else
+ }
+ else {
pt->flag &= ~GP_SPOINT_SELECT;
+ }
}
/* stroke too... */
- if (deselect == false)
+ if (deselect == false) {
hit_stroke->flag |= GP_STROKE_SELECT;
- else
+ }
+ else {
hit_stroke->flag &= ~GP_STROKE_SELECT;
+ }
}
else {
/* just the point (and the stroke) */
diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c
index 357e570655a..0d920641c5d 100644
--- a/source/blender/editors/gpencil/gpencil_utils.c
+++ b/source/blender/editors/gpencil/gpencil_utils.c
@@ -106,8 +106,9 @@ bGPdata **ED_gpencil_data_get_pointers_direct(
{
if (ob && (ob->type == OB_GPENCIL)) {
/* GP Object */
- if (r_ptr)
+ if (r_ptr) {
RNA_id_pointer_create(&ob->id, r_ptr);
+ }
return (bGPdata **)&ob->data;
}
else {
@@ -122,15 +123,17 @@ bGPdata **ED_gpencil_data_get_pointers_direct(
{
if (ob && (ob->type == OB_GPENCIL)) {
/* GP Object */
- if (r_ptr)
+ if (r_ptr) {
RNA_id_pointer_create(&ob->id, r_ptr);
+ }
return (bGPdata **)&ob->data;
}
else {
/* Annotations */
/* XXX: */
- if (r_ptr)
+ if (r_ptr) {
RNA_id_pointer_create(&scene->id, r_ptr);
+ }
return &scene->gpd;
}
@@ -144,8 +147,9 @@ bGPdata **ED_gpencil_data_get_pointers_direct(
if (snode && snode->nodetree) {
/* for now, as long as there's an active node tree,
* default to using that in the Nodes Editor */
- if (r_ptr)
+ if (r_ptr) {
RNA_id_pointer_create(&snode->nodetree->id, r_ptr);
+ }
return &snode->nodetree->gpd;
}
@@ -159,8 +163,9 @@ bGPdata **ED_gpencil_data_get_pointers_direct(
/* For now, Grease Pencil data is associated with the space
* (actually preview region only). */
/* XXX our convention for everything else is to link to data though... */
- if (r_ptr)
+ if (r_ptr) {
RNA_pointer_create(screen_id, &RNA_SpaceSequenceEditor, sseq, r_ptr);
+ }
return &sseq->gpd;
}
case SPACE_IMAGE: /* Image/UV Editor */
@@ -169,8 +174,9 @@ bGPdata **ED_gpencil_data_get_pointers_direct(
/* for now, Grease Pencil data is associated with the space... */
/* XXX our convention for everything else is to link to data though... */
- if (r_ptr)
+ if (r_ptr) {
RNA_pointer_create(screen_id, &RNA_SpaceImageEditor, sima, r_ptr);
+ }
return &sima->gpd;
}
case SPACE_CLIP: /* Nodes Editor */
@@ -182,16 +188,19 @@ bGPdata **ED_gpencil_data_get_pointers_direct(
if (sc->gpencil_src == SC_GPENCIL_SRC_TRACK) {
MovieTrackingTrack *track = BKE_tracking_track_get_active(&clip->tracking);
- if (!track)
+ if (!track) {
return NULL;
+ }
- if (r_ptr)
+ if (r_ptr) {
RNA_pointer_create(&clip->id, &RNA_MovieTrackingTrack, track, r_ptr);
+ }
return &track->gpd;
}
else {
- if (r_ptr)
+ if (r_ptr) {
RNA_id_pointer_create(&clip->id, r_ptr);
+ }
return &clip->gpd;
}
}
@@ -358,10 +367,12 @@ const EnumPropertyItem *ED_gpencil_layers_enum_itemf(bContext *C,
item_tmp.name = gpl->info;
item_tmp.value = i;
- if (gpl->flag & GP_LAYER_ACTIVE)
+ if (gpl->flag & GP_LAYER_ACTIVE) {
item_tmp.icon = ICON_GREASEPENCIL;
- else
+ }
+ else {
item_tmp.icon = ICON_NONE;
+ }
RNA_enum_item_add(&item, &totitem, &item_tmp);
}
@@ -408,10 +419,12 @@ const EnumPropertyItem *ED_gpencil_layers_with_new_enum_itemf(bContext *C,
item_tmp.name = gpl->info;
item_tmp.value = tot - i - 1;
- if (gpl->flag & GP_LAYER_ACTIVE)
+ if (gpl->flag & GP_LAYER_ACTIVE) {
item_tmp.icon = ICON_GREASEPENCIL;
- else
+ }
+ else {
item_tmp.icon = ICON_NONE;
+ }
RNA_enum_item_add(&item, &totitem, &item_tmp);
}
@@ -458,8 +471,9 @@ bool gp_stroke_inside_circle(
bool ED_gpencil_stroke_can_use_direct(const ScrArea *sa, const bGPDstroke *gps)
{
/* sanity check */
- if (ELEM(NULL, sa, gps))
+ if (ELEM(NULL, sa, gps)) {
return false;
+ }
/* filter stroke types by flags + spacetype */
if (gps->flag & GP_STROKE_3DSPACE) {
@@ -494,10 +508,12 @@ bool ED_gpencil_stroke_color_use(Object *ob, const bGPDlayer *gpl, const bGPDstr
MaterialGPencilStyle *gp_style = BKE_material_gpencil_settings_get(ob, gps->mat_nr + 1);
if (gp_style != NULL) {
- if (gp_style->flag & GP_STYLE_COLOR_HIDE)
+ if (gp_style->flag & GP_STYLE_COLOR_HIDE) {
return false;
- if (((gpl->flag & GP_LAYER_UNLOCK_COLOR) == 0) && (gp_style->flag & GP_STYLE_COLOR_LOCKED))
+ }
+ if (((gpl->flag & GP_LAYER_UNLOCK_COLOR) == 0) && (gp_style->flag & GP_STYLE_COLOR_LOCKED)) {
return false;
+ }
}
return true;
@@ -1400,8 +1416,9 @@ void ED_gpencil_vgroup_assign(bContext *C, Object *ob, float weight)
bGPdata *gpd = (bGPdata *)ob->data;
const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd);
const int def_nr = ob->actdef - 1;
- if (!BLI_findlink(&ob->defbase, def_nr))
+ if (!BLI_findlink(&ob->defbase, def_nr)) {
return;
+ }
CTX_DATA_BEGIN (C, bGPDlayer *, gpl, editable_gpencil_layers) {
bGPDframe *init_gpf = gpl->actframe;
@@ -1412,14 +1429,16 @@ void ED_gpencil_vgroup_assign(bContext *C, Object *ob, float weight)
for (bGPDframe *gpf = init_gpf; gpf; gpf = gpf->next) {
if ((gpf == gpl->actframe) || ((gpf->flag & GP_FRAME_SELECT) && (is_multiedit))) {
- if (gpf == NULL)
+ if (gpf == NULL) {
continue;
+ }
for (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;
+ }
if (gps->flag & GP_STROKE_SELECT) {
/* verify the weight array is created */
@@ -1454,8 +1473,9 @@ void ED_gpencil_vgroup_remove(bContext *C, Object *ob)
bGPdata *gpd = (bGPdata *)ob->data;
const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd);
const int def_nr = ob->actdef - 1;
- if (!BLI_findlink(&ob->defbase, def_nr))
+ if (!BLI_findlink(&ob->defbase, def_nr)) {
return;
+ }
CTX_DATA_BEGIN (C, bGPDlayer *, gpl, editable_gpencil_layers) {
bGPDframe *init_gpf = gpl->actframe;
@@ -1466,14 +1486,16 @@ void ED_gpencil_vgroup_remove(bContext *C, Object *ob)
for (bGPDframe *gpf = init_gpf; gpf; gpf = gpf->next) {
if ((gpf == gpl->actframe) || ((gpf->flag & GP_FRAME_SELECT) && (is_multiedit))) {
- if (gpf == NULL)
+ if (gpf == NULL) {
continue;
+ }
for (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 (int i = 0; i < gps->totpoints; i++) {
bGPDspoint *pt = &gps->points[i];
@@ -1507,8 +1529,9 @@ void ED_gpencil_vgroup_select(bContext *C, Object *ob)
bGPdata *gpd = (bGPdata *)ob->data;
const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd);
const int def_nr = ob->actdef - 1;
- if (!BLI_findlink(&ob->defbase, def_nr))
+ if (!BLI_findlink(&ob->defbase, def_nr)) {
return;
+ }
CTX_DATA_BEGIN (C, bGPDlayer *, gpl, editable_gpencil_layers) {
bGPDframe *init_gpf = gpl->actframe;
@@ -1519,14 +1542,16 @@ void ED_gpencil_vgroup_select(bContext *C, Object *ob)
for (bGPDframe *gpf = init_gpf; gpf; gpf = gpf->next) {
if ((gpf == gpl->actframe) || ((gpf->flag & GP_FRAME_SELECT) && (is_multiedit))) {
- if (gpf == NULL)
+ if (gpf == NULL) {
continue;
+ }
for (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 (int i = 0; i < gps->totpoints; i++) {
bGPDspoint *pt = &gps->points[i];
@@ -1558,8 +1583,9 @@ void ED_gpencil_vgroup_deselect(bContext *C, Object *ob)
bGPdata *gpd = (bGPdata *)ob->data;
const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd);
const int def_nr = ob->actdef - 1;
- if (!BLI_findlink(&ob->defbase, def_nr))
+ if (!BLI_findlink(&ob->defbase, def_nr)) {
return;
+ }
CTX_DATA_BEGIN (C, bGPDlayer *, gpl, editable_gpencil_layers) {
bGPDframe *init_gpf = gpl->actframe;
@@ -1570,14 +1596,16 @@ void ED_gpencil_vgroup_deselect(bContext *C, Object *ob)
for (bGPDframe *gpf = init_gpf; gpf; gpf = gpf->next) {
if ((gpf == gpl->actframe) || ((gpf->flag & GP_FRAME_SELECT) && (is_multiedit))) {
- if (gpf == NULL)
+ if (gpf == NULL) {
continue;
+ }
for (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 (int i = 0; i < gps->totpoints; i++) {
bGPDspoint *pt = &gps->points[i];
@@ -2494,15 +2522,18 @@ void ED_gpencil_select_toggle_all(bContext *C, int action)
break;
}
- if (pt->flag & GP_SPOINT_SELECT)
+ if (pt->flag & GP_SPOINT_SELECT) {
selected = true;
+ }
}
/* Change status of stroke */
- if (selected)
+ if (selected) {
gps->flag |= GP_STROKE_SELECT;
- else
+ }
+ else {
gps->flag &= ~GP_STROKE_SELECT;
+ }
}
CTX_DATA_END;
}
diff --git a/source/blender/editors/io/io_alembic.c b/source/blender/editors/io/io_alembic.c
index dc8e33c817e..2f3e73f32d5 100644
--- a/source/blender/editors/io/io_alembic.c
+++ b/source/blender/editors/io/io_alembic.c
@@ -504,10 +504,12 @@ static int cmp_frame(const void *a, const void *b)
const CacheFrame *frame_a = a;
const CacheFrame *frame_b = b;
- if (frame_a->framenr < frame_b->framenr)
+ if (frame_a->framenr < frame_b->framenr) {
return -1;
- if (frame_a->framenr > frame_b->framenr)
+ }
+ if (frame_a->framenr > frame_b->framenr) {
return 1;
+ }
return 0;
}
diff --git a/source/blender/editors/io/io_collada.c b/source/blender/editors/io/io_collada.c
index 6ccdf8628a8..bfbd3722142 100644
--- a/source/blender/editors/io/io_collada.c
+++ b/source/blender/editors/io/io_collada.c
@@ -60,10 +60,12 @@ static int wm_collada_export_invoke(bContext *C, wmOperator *op, const wmEvent *
char filepath[FILE_MAX];
const char *blendfile_path = BKE_main_blendfile_path(bmain);
- if (blendfile_path[0] == '\0')
+ if (blendfile_path[0] == '\0') {
BLI_strncpy(filepath, "untitled", sizeof(filepath));
- else
+ }
+ else {
BLI_strncpy(filepath, blendfile_path, sizeof(filepath));
+ }
BLI_path_extension_replace(filepath, sizeof(filepath), ".dae");
RNA_string_set(op->ptr, "filepath", filepath);
@@ -221,10 +223,12 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op)
export_settings.keep_bind_info = keep_bind_info != 0;
int includeFilter = OB_REL_NONE;
- if (export_settings.include_armatures)
+ if (export_settings.include_armatures) {
includeFilter |= OB_REL_MOD_ARMATURE;
- if (export_settings.include_children)
+ }
+ if (export_settings.include_children) {
includeFilter |= OB_REL_CHILDREN_RECURSIVE;
+ }
export_count = collada_export(C, &export_settings);
diff --git a/source/blender/editors/lattice/editlattice_select.c b/source/blender/editors/lattice/editlattice_select.c
index 782c0644313..7e89ed9511f 100644
--- a/source/blender/editors/lattice/editlattice_select.c
+++ b/source/blender/editors/lattice/editlattice_select.c
@@ -582,8 +582,9 @@ static void findnearestLattvert__doClosest(void *userData, BPoint *bp, const flo
} *data = userData;
float dist_test = len_manhattan_v2v2(data->mval_fl, screen_co);
- if ((bp->f1 & SELECT) && data->select)
+ if ((bp->f1 & SELECT) && data->select) {
dist_test += 5.0f;
+ }
if (dist_test < data->dist) {
data->dist = dist_test;
diff --git a/source/blender/editors/lattice/editlattice_tools.c b/source/blender/editors/lattice/editlattice_tools.c
index 8ef383de552..0cfe59ef06c 100644
--- a/source/blender/editors/lattice/editlattice_tools.c
+++ b/source/blender/editors/lattice/editlattice_tools.c
@@ -57,8 +57,9 @@ static bool make_regular_poll(bContext *C)
{
Object *ob;
- if (ED_operator_editlattice(C))
+ if (ED_operator_editlattice(C)) {
return 1;
+ }
ob = CTX_data_active_object(C);
return (ob && ob->type == OB_LATTICE);
diff --git a/source/blender/editors/mask/mask_add.c b/source/blender/editors/mask/mask_add.c
index 1c872e73226..3c456f9e2e2 100644
--- a/source/blender/editors/mask/mask_add.c
+++ b/source/blender/editors/mask/mask_add.c
@@ -126,8 +126,9 @@ bool ED_mask_find_nearest_diff_point(const bContext *C,
dist_sq = dist_squared_to_line_segment_v2(co, a, b);
if (dist_sq < dist_best_sq) {
- if (tangent)
+ if (tangent) {
sub_v2_v2v2(tangent, &diff_points[2 * j + 2], &diff_points[2 * j]);
+ }
point_masklay = masklay;
point_spline = spline;
@@ -138,8 +139,9 @@ bool ED_mask_find_nearest_diff_point(const bContext *C,
}
}
- if (feather_points)
+ if (feather_points) {
MEM_freeN(feather_points);
+ }
MEM_freeN(diff_points);
}
@@ -148,14 +150,17 @@ bool ED_mask_find_nearest_diff_point(const bContext *C,
}
if (point && dist_best_sq < threshold) {
- if (masklay_r)
+ if (masklay_r) {
*masklay_r = point_masklay;
+ }
- if (spline_r)
+ if (spline_r) {
*spline_r = point_spline;
+ }
- if (point_r)
+ if (point_r) {
*point_r = point;
+ }
if (u_r) {
/* TODO(sergey): Projection fails in some weirdo cases.. */
@@ -173,14 +178,17 @@ bool ED_mask_find_nearest_diff_point(const bContext *C,
return true;
}
- if (masklay_r)
+ if (masklay_r) {
*masklay_r = NULL;
+ }
- if (spline_r)
+ if (spline_r) {
*spline_r = NULL;
+ }
- if (point_r)
+ if (point_r) {
*point_r = NULL;
+ }
return false;
}
@@ -702,8 +710,9 @@ static int add_feather_vertex_exec(bContext *C, wmOperator *op)
RNA_float_get_array(op->ptr, "location", co);
point = ED_mask_point_find_nearest(C, mask, co, threshold, NULL, NULL, NULL, NULL);
- if (point)
+ if (point) {
return OPERATOR_FINISHED;
+ }
if (ED_mask_find_nearest_diff_point(
C, mask, co, threshold, true, NULL, true, true, &masklay, &spline, &point, &u, NULL)) {
diff --git a/source/blender/editors/mask/mask_draw.c b/source/blender/editors/mask/mask_draw.c
index 479e4fd2d6c..305e3a328ab 100644
--- a/source/blender/editors/mask/mask_draw.c
+++ b/source/blender/editors/mask/mask_draw.c
@@ -203,11 +203,13 @@ static void draw_spline_points(const bContext *C,
float(*feather_points)[2], (*fp)[2];
float min[2], max[2];
- if (!spline->tot_point)
+ if (!spline->tot_point) {
return;
+ }
- if (sc)
+ if (sc) {
undistort = sc->clip && (sc->user.render_flag & MCLIP_PROXY_RENDER_UNDISTORT);
+ }
/* TODO, add this to sequence editor */
float handle_size = 2.0f * UI_GetThemeValuef(TH_HANDLE_VERTEX_SIZE) * U.pixelsize;
@@ -233,8 +235,9 @@ static void draw_spline_points(const bContext *C,
copy_v2_v2(feather_point, *fp);
- if (undistort)
+ if (undistort) {
mask_point_undistort_pos(sc, feather_point, feather_point);
+ }
if (j == 0) {
sel = MASKPOINT_ISSEL_ANY(point);
@@ -244,10 +247,12 @@ static void draw_spline_points(const bContext *C,
}
if (sel) {
- if (point == masklay->act_point)
+ if (point == masklay->act_point) {
immUniformColor3f(1.0f, 1.0f, 1.0f);
- else
+ }
+ else {
immUniformThemeColorShadeAlpha(TH_HANDLE_VERTEX_SELECT, 0, 255);
+ }
}
else {
immUniformThemeColorShadeAlpha(TH_HANDLE_VERTEX, 0, 255);
@@ -314,13 +319,16 @@ static void draw_spline_points(const bContext *C,
/* draw CV point */
if (MASKPOINT_ISSEL_KNOT(point)) {
- if (point == masklay->act_point)
+ if (point == masklay->act_point) {
immUniformColor3f(1.0f, 1.0f, 1.0f);
- else
+ }
+ else {
immUniformThemeColorShadeAlpha(TH_HANDLE_VERTEX_SELECT, 0, 255);
+ }
}
- else
+ else {
immUniformThemeColorShadeAlpha(TH_HANDLE_VERTEX, 0, 255);
+ }
immBegin(GPU_PRIM_POINTS, 1);
immVertex2fv(pos, vert);
@@ -502,8 +510,9 @@ static void mask_draw_curve_type(const bContext *C,
BLI_assert(false);
}
- if (points != orig_points)
+ if (points != orig_points) {
MEM_freeN(points);
+ }
}
static void draw_spline_curve(const bContext *C,
@@ -533,8 +542,9 @@ static void draw_spline_curve(const bContext *C,
diff_points = BKE_mask_spline_differentiate_with_resolution(spline, &tot_diff_point, resol);
- if (!diff_points)
+ if (!diff_points) {
return;
+ }
if (is_smooth) {
GPU_line_smooth(true);
@@ -633,8 +643,9 @@ void ED_mask_draw(const bContext *C, const char draw_flag, const char draw_type)
Mask *mask = CTX_data_edit_mask(C);
int width, height;
- if (!mask)
+ if (!mask) {
return;
+ }
ED_mask_get_size(sa, &width, &height);
diff --git a/source/blender/editors/mask/mask_edit.c b/source/blender/editors/mask/mask_edit.c
index 7325686d4f0..454e7e2a731 100644
--- a/source/blender/editors/mask/mask_edit.c
+++ b/source/blender/editors/mask/mask_edit.c
@@ -374,8 +374,9 @@ bool ED_mask_selected_minmax(const bContext *C, float min[2], float max[2])
MaskLayer *mask_layer;
bool ok = false;
- if (mask == NULL)
+ if (mask == NULL) {
return ok;
+ }
INIT_MINMAX2(min, max);
for (mask_layer = mask->masklayers.first; mask_layer != NULL; mask_layer = mask_layer->next) {
diff --git a/source/blender/editors/mask/mask_editaction.c b/source/blender/editors/mask/mask_editaction.c
index d30e62d89f5..985fa58cace 100644
--- a/source/blender/editors/mask/mask_editaction.c
+++ b/source/blender/editors/mask/mask_editaction.c
@@ -60,15 +60,17 @@ bool ED_masklayer_frames_looper(MaskLayer *masklay,
MaskLayerShape *masklay_shape;
/* error checker */
- if (masklay == NULL)
+ if (masklay == NULL) {
return false;
+ }
/* do loop */
for (masklay_shape = masklay->splines_shapes.first; masklay_shape;
masklay_shape = masklay_shape->next) {
/* execute callback */
- if (masklay_shape_cb(masklay_shape, scene))
+ if (masklay_shape_cb(masklay_shape, scene)) {
return true;
+ }
}
/* nothing to return */
@@ -85,8 +87,9 @@ void ED_masklayer_make_cfra_list(MaskLayer *masklay, ListBase *elems, bool onlys
CfraElem *ce;
/* error checking */
- if (ELEM(NULL, masklay, elems))
+ if (ELEM(NULL, masklay, elems)) {
return;
+ }
/* loop through mask-frames, adding */
for (masklay_shape = masklay->splines_shapes.first; masklay_shape;
@@ -111,14 +114,16 @@ bool ED_masklayer_frame_select_check(MaskLayer *masklay)
MaskLayerShape *masklay_shape;
/* error checking */
- if (masklay == NULL)
+ if (masklay == NULL) {
return 0;
+ }
/* stop at the first one found */
for (masklay_shape = masklay->splines_shapes.first; masklay_shape;
masklay_shape = masklay_shape->next) {
- if (masklay_shape->flag & MASK_SHAPE_SELECT)
+ if (masklay_shape->flag & MASK_SHAPE_SELECT) {
return 1;
+ }
}
/* not found */
@@ -128,8 +133,9 @@ bool ED_masklayer_frame_select_check(MaskLayer *masklay)
/* helper function - select mask-frame based on SELECT_* mode */
static void masklayshape_select(MaskLayerShape *masklay_shape, short select_mode)
{
- if (masklay_shape == NULL)
+ if (masklay_shape == NULL) {
return;
+ }
switch (select_mode) {
case SELECT_ADD:
@@ -150,8 +156,9 @@ void ED_mask_select_frames(MaskLayer *masklay, short select_mode)
MaskLayerShape *masklay_shape;
/* error checking */
- if (masklay == NULL)
+ if (masklay == NULL) {
return;
+ }
/* handle according to mode */
for (masklay_shape = masklay->splines_shapes.first; masklay_shape;
@@ -164,8 +171,9 @@ void ED_mask_select_frames(MaskLayer *masklay, short select_mode)
void ED_masklayer_frame_select_set(MaskLayer *masklay, short mode)
{
/* error checking */
- if (masklay == NULL)
+ if (masklay == NULL) {
return;
+ }
/* now call the standard function */
ED_mask_select_frames(masklay, mode);
@@ -176,8 +184,9 @@ void ED_mask_select_frame(MaskLayer *masklay, int selx, short select_mode)
{
MaskLayerShape *masklay_shape;
- if (masklay == NULL)
+ if (masklay == NULL) {
return;
+ }
masklay_shape = BKE_mask_layer_shape_find_frame(masklay, selx);
@@ -191,14 +200,16 @@ void ED_masklayer_frames_select_box(MaskLayer *masklay, float min, float max, sh
{
MaskLayerShape *masklay_shape;
- if (masklay == NULL)
+ if (masklay == NULL) {
return;
+ }
/* only select those frames which are in bounds */
for (masklay_shape = masklay->splines_shapes.first; masklay_shape;
masklay_shape = masklay_shape->next) {
- if (IN_RANGE(masklay_shape->frame, min, max))
+ if (IN_RANGE(masklay_shape->frame, min, max)) {
masklayshape_select(masklay_shape, select_mode);
+ }
}
}
@@ -210,8 +221,9 @@ void ED_masklayer_frames_select_region(KeyframeEditData *ked,
{
MaskLayerShape *masklay_shape;
- if (masklay == NULL)
+ if (masklay == NULL) {
return;
+ }
/* only select frames which are within the region */
for (masklay_shape = masklay->splines_shapes.first; masklay_shape;
@@ -225,13 +237,15 @@ void ED_masklayer_frames_select_region(KeyframeEditData *ked,
/* check the necessary regions */
if (tool == BEZT_OK_CHANNEL_LASSO) {
/* Lasso */
- if (keyframe_region_lasso_test(ked->data, pt))
+ if (keyframe_region_lasso_test(ked->data, pt)) {
masklayshape_select(masklay_shape, select_mode);
+ }
}
else if (tool == BEZT_OK_CHANNEL_CIRCLE) {
/* Circle */
- if (keyframe_region_circle_test(ked->data, pt))
+ if (keyframe_region_circle_test(ked->data, pt)) {
masklayshape_select(masklay_shape, select_mode);
+ }
}
}
}
@@ -246,8 +260,9 @@ bool ED_masklayer_frames_delete(MaskLayer *masklay)
bool changed = false;
/* error checking */
- if (masklay == NULL)
+ if (masklay == NULL) {
return false;
+ }
/* check for frames to delete */
for (masklay_shape = masklay->splines_shapes.first; masklay_shape;
@@ -269,8 +284,9 @@ void ED_masklayer_frames_duplicate(MaskLayer *masklay)
MaskLayerShape *masklay_shape, *gpfn;
/* error checking */
- if (masklay == NULL)
+ if (masklay == NULL) {
return;
+ }
/* duplicate selected frames */
for (masklay_shape = masklay->splines_shapes.first; masklay_shape; masklay_shape = gpfn) {
@@ -295,31 +311,35 @@ void ED_masklayer_frames_duplicate(MaskLayer *masklay)
static short snap_masklayer_nearest(MaskLayerShape *masklay_shape, Scene *UNUSED(scene))
{
- if (masklay_shape->flag & MASK_SHAPE_SELECT)
+ if (masklay_shape->flag & MASK_SHAPE_SELECT) {
masklay_shape->frame = (int)(floor(masklay_shape->frame + 0.5));
+ }
return 0;
}
static short snap_masklayer_nearestsec(MaskLayerShape *masklay_shape, Scene *scene)
{
float secf = (float)FPS;
- if (masklay_shape->flag & MASK_SHAPE_SELECT)
+ if (masklay_shape->flag & MASK_SHAPE_SELECT) {
masklay_shape->frame = (int)(floorf(masklay_shape->frame / secf + 0.5f) * secf);
+ }
return 0;
}
static short snap_masklayer_cframe(MaskLayerShape *masklay_shape, Scene *scene)
{
- if (masklay_shape->flag & MASK_SHAPE_SELECT)
+ if (masklay_shape->flag & MASK_SHAPE_SELECT) {
masklay_shape->frame = (int)CFRA;
+ }
return 0;
}
static short snap_masklayer_nearmarker(MaskLayerShape *masklay_shape, Scene *scene)
{
- if (masklay_shape->flag & MASK_SHAPE_SELECT)
+ if (masklay_shape->flag & MASK_SHAPE_SELECT) {
masklay_shape->frame = (int)ED_markers_find_nearest_marker_time(&scene->markers,
(float)masklay_shape->frame);
+ }
return 0;
}
diff --git a/source/blender/editors/mask/mask_ops.c b/source/blender/editors/mask/mask_ops.c
index 2b925b9095e..ab774fa13df 100644
--- a/source/blender/editors/mask/mask_ops.c
+++ b/source/blender/editors/mask/mask_ops.c
@@ -179,29 +179,36 @@ MaskSplinePoint *ED_mask_point_find_nearest(const bContext *C,
}
if (len_sq < threshold_sq) {
- if (masklay_r)
+ if (masklay_r) {
*masklay_r = point_masklay;
+ }
- if (spline_r)
+ if (spline_r) {
*spline_r = point_spline;
+ }
- if (which_handle_r)
+ if (which_handle_r) {
*which_handle_r = which_handle;
+ }
- if (score)
+ if (score) {
*score = sqrtf(len_sq);
+ }
return point;
}
- if (masklay_r)
+ if (masklay_r) {
*masklay_r = NULL;
+ }
- if (spline_r)
+ if (spline_r) {
*spline_r = NULL;
+ }
- if (which_handle_r)
+ if (which_handle_r) {
*which_handle_r = MASK_WHICH_HANDLE_NONE;
+ }
return NULL;
}
@@ -262,10 +269,12 @@ bool ED_mask_feather_find_nearest(const bContext *C,
cur_len_sq = len_squared_v2v2(vec, co);
if (point == NULL || cur_len_sq < len) {
- if (j == 0)
+ if (j == 0) {
uw = NULL;
- else
+ }
+ else {
uw = &cur_point->uw[j - 1];
+ }
point_masklay = masklay;
point_spline = spline;
@@ -282,32 +291,40 @@ bool ED_mask_feather_find_nearest(const bContext *C,
}
if (len < threshold_sq) {
- if (masklay_r)
+ if (masklay_r) {
*masklay_r = point_masklay;
+ }
- if (spline_r)
+ if (spline_r) {
*spline_r = point_spline;
+ }
- if (point_r)
+ if (point_r) {
*point_r = point;
+ }
- if (uw_r)
+ if (uw_r) {
*uw_r = uw;
+ }
- if (score)
+ if (score) {
*score = sqrtf(len);
+ }
return true;
}
- if (masklay_r)
+ if (masklay_r) {
*masklay_r = NULL;
+ }
- if (spline_r)
+ if (spline_r) {
*spline_r = NULL;
+ }
- if (point_r)
+ if (point_r) {
*point_r = NULL;
+ }
return false;
}
@@ -720,10 +737,12 @@ static void *slide_point_customdata(bContext *C, wmOperator *op, const wmEvent *
}
if (cv_point && action == SLIDE_ACTION_NONE) {
- if (which_handle != MASK_WHICH_HANDLE_NONE)
+ if (which_handle != MASK_WHICH_HANDLE_NONE) {
action = SLIDE_ACTION_HANDLE;
- else
+ }
+ else {
action = SLIDE_ACTION_POINT;
+ }
masklay = cv_masklay;
spline = cv_spline;
@@ -851,8 +870,9 @@ static void slide_point_restore_spline(SlidePointData *data)
point->bezt = orig_point->bezt;
- for (j = 0; j < point->tot_uw; j++)
+ for (j = 0; j < point->tot_uw; j++) {
point->uw[j] = orig_point->uw[j];
+ }
}
}
@@ -865,10 +885,12 @@ static void cancel_slide_point(SlidePointData *data)
}
else {
if (data->action == SLIDE_ACTION_FEATHER) {
- if (data->uw)
+ if (data->uw) {
data->uw->w = data->weight;
- else
+ }
+ else {
data->point->bezt.weight = data->weight;
+ }
}
else if (data->action != SLIDE_ACTION_SPLINE) {
copy_m3_m3(data->point->bezt.vec, data->vec);
@@ -880,8 +902,9 @@ static void cancel_slide_point(SlidePointData *data)
static void free_slide_point_data(SlidePointData *data)
{
- if (data->orig_spline)
+ if (data->orig_spline) {
BKE_mask_spline_free(data->orig_spline);
+ }
MEM_freeN(data);
}
@@ -906,8 +929,9 @@ static int slide_point_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
}
- if (ELEM(event->type, LEFTSHIFTKEY, RIGHTSHIFTKEY))
+ if (ELEM(event->type, LEFTSHIFTKEY, RIGHTSHIFTKEY)) {
data->is_accurate = (event->val == KM_PRESS);
+ }
ATTR_FALLTHROUGH; /* update CV position */
case MOUSEMOVE: {
@@ -1028,8 +1052,9 @@ static int slide_point_modal(bContext *C, wmOperator *op, const wmEvent *event)
if (is_overall_feather) {
float w_delta;
- if (dot_v2v2(no, vec) <= 0.0f)
+ if (dot_v2v2(no, vec) <= 0.0f) {
w = -w;
+ }
w_delta = w - data->weight * data->weight_scalar;
@@ -1049,8 +1074,9 @@ static int slide_point_modal(bContext *C, wmOperator *op, const wmEvent *event)
slide_point_delta_all_feather(data, w_delta);
}
else {
- if (dot_v2v2(no, vec) <= 0.0f)
+ if (dot_v2v2(no, vec) <= 0.0f) {
w = 0.0f;
+ }
if (data->orig_spline) {
/* restore possible overall feather changes */
@@ -1586,12 +1612,14 @@ static void delete_feather_points(MaskSplinePoint *point)
{
int i, count = 0;
- if (!point->tot_uw)
+ if (!point->tot_uw) {
return;
+ }
for (i = 0; i < point->tot_uw; i++) {
- if ((point->uw[i].flag & SELECT) == 0)
+ if ((point->uw[i].flag & SELECT) == 0) {
count++;
+ }
}
if (count == 0) {
@@ -1644,8 +1672,9 @@ static int delete_exec(bContext *C, wmOperator *UNUSED(op))
for (i = 0; i < spline->tot_point; i++) {
MaskSplinePoint *point = &spline->points[i];
- if (!MASKPOINT_ISSEL_ANY(point))
+ if (!MASKPOINT_ISSEL_ANY(point)) {
count++;
+ }
}
if (count == 0) {
@@ -1670,8 +1699,9 @@ static int delete_exec(bContext *C, wmOperator *UNUSED(op))
MaskSplinePoint *point = &spline->points[i];
if (!MASKPOINT_ISSEL_ANY(point)) {
- if (point == masklay->act_point)
+ if (point == masklay->act_point) {
masklay->act_point = &new_points[j];
+ }
delete_feather_points(point);
@@ -1679,8 +1709,9 @@ static int delete_exec(bContext *C, wmOperator *UNUSED(op))
j++;
}
else {
- if (point == masklay->act_point)
+ if (point == masklay->act_point) {
masklay->act_point = NULL;
+ }
BKE_mask_point_free(point);
spline->tot_point--;
@@ -2138,14 +2169,16 @@ static int mask_layer_move_exec(bContext *C, wmOperator *op)
MaskLayer *mask_layer_other;
int direction = RNA_enum_get(op->ptr, "direction");
- if (!mask_layer)
+ if (!mask_layer) {
return OPERATOR_CANCELLED;
+ }
if (direction == -1) {
mask_layer_other = mask_layer->prev;
- if (!mask_layer_other)
+ if (!mask_layer_other) {
return OPERATOR_CANCELLED;
+ }
BLI_remlink(&mask->masklayers, mask_layer);
BLI_insertlinkbefore(&mask->masklayers, mask_layer_other, mask_layer);
@@ -2154,8 +2187,9 @@ static int mask_layer_move_exec(bContext *C, wmOperator *op)
else if (direction == 1) {
mask_layer_other = mask_layer->next;
- if (!mask_layer_other)
+ if (!mask_layer_other) {
return OPERATOR_CANCELLED;
+ }
BLI_remlink(&mask->masklayers, mask_layer);
BLI_insertlinkafter(&mask->masklayers, mask_layer_other, mask_layer);
diff --git a/source/blender/editors/mask/mask_select.c b/source/blender/editors/mask/mask_select.c
index 076f8d067b9..00699c8ffe0 100644
--- a/source/blender/editors/mask/mask_select.c
+++ b/source/blender/editors/mask/mask_select.c
@@ -57,8 +57,9 @@ bool ED_mask_spline_select_check(MaskSpline *spline)
for (i = 0; i < spline->tot_point; i++) {
MaskSplinePoint *point = &spline->points[i];
- if (MASKPOINT_ISSEL_ANY(point))
+ if (MASKPOINT_ISSEL_ANY(point)) {
return true;
+ }
}
return false;
@@ -99,10 +100,12 @@ void ED_mask_spline_select_set(MaskSpline *spline, const bool do_select)
{
int i;
- if (do_select)
+ if (do_select) {
spline->flag |= SELECT;
- else
+ }
+ else {
spline->flag &= ~SELECT;
+ }
for (i = 0; i < spline->tot_point; i++) {
MaskSplinePoint *point = &spline->points[i];
@@ -131,10 +134,12 @@ void ED_mask_select_toggle_all(Mask *mask, int action)
MaskLayer *masklay;
if (action == SEL_TOGGLE) {
- if (ED_mask_select_check(mask))
+ if (ED_mask_select_check(mask)) {
action = SEL_DESELECT;
- else
+ }
+ else {
action = SEL_SELECT;
+ }
}
for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) {
@@ -265,8 +270,9 @@ static int select_exec(bContext *C, wmOperator *op)
point = ED_mask_point_find_nearest(
C, mask, co, threshold, &masklay, &spline, &which_handle, NULL);
- if (extend == false && deselect == false && toggle == false)
+ if (extend == false && deselect == false && toggle == false) {
ED_mask_select_toggle_all(mask, SEL_DESELECT);
+ }
if (point) {
if (which_handle != MASK_WHICH_HANDLE_NONE) {
@@ -333,12 +339,14 @@ static int select_exec(bContext *C, wmOperator *op)
masklay->act_spline = spline;
masklay->act_point = point;
- if (uw)
+ if (uw) {
uw->flag |= SELECT;
+ }
}
else if (deselect) {
- if (uw)
+ if (uw) {
uw->flag &= ~SELECT;
+ }
}
else {
masklay->act_spline = spline;
diff --git a/source/blender/editors/mesh/editface.c b/source/blender/editors/mesh/editface.c
index f342cc3a809..28b697531ab 100644
--- a/source/blender/editors/mesh/editface.c
+++ b/source/blender/editors/mesh/editface.c
@@ -65,8 +65,9 @@ void paintface_flush_flags(struct bContext *C, Object *ob, short flag)
BLI_assert((flag & ~(SELECT | ME_HIDE)) == 0);
- if (me == NULL)
+ if (me == NULL) {
return;
+ }
/* note, call #BKE_mesh_flush_hidden_from_verts_ex first when changing hidden flags */
@@ -139,8 +140,9 @@ void paintface_hide(bContext *C, Object *ob, const bool unselected)
int a;
me = BKE_mesh_from_object(ob);
- if (me == NULL || me->totpoly == 0)
+ if (me == NULL || me->totpoly == 0) {
return;
+ }
mpoly = me->mpoly;
a = me->totpoly;
@@ -170,8 +172,9 @@ void paintface_reveal(bContext *C, Object *ob, const bool select)
int a;
me = BKE_mesh_from_object(ob);
- if (me == NULL || me->totpoly == 0)
+ if (me == NULL || me->totpoly == 0) {
return;
+ }
mpoly = me->mpoly;
a = me->totpoly;
@@ -227,8 +230,9 @@ static void select_linked_tfaces_with_seams(Mesh *me, const unsigned int index,
/* expand selection */
mp = me->mpoly;
for (a = 0; a < me->totpoly; a++, mp++) {
- if (mp->flag & ME_HIDE)
+ if (mp->flag & ME_HIDE) {
continue;
+ }
if (!BLI_BITMAP_TEST(poly_tag, a)) {
mark = false;
@@ -269,8 +273,9 @@ void paintface_select_linked(bContext *C, Object *ob, const int mval[2], const b
unsigned int index = (unsigned int)-1;
me = BKE_mesh_from_object(ob);
- if (me == NULL || me->totpoly == 0)
+ if (me == NULL || me->totpoly == 0) {
return;
+ }
if (mval) {
if (!ED_mesh_pick_face(C, ob, mval, ED_MESH_PICK_DEFAULT_FACE_DIST, &index)) {
@@ -364,8 +369,9 @@ bool paintface_minmax(Object *ob, float r_min[3], float r_max[3])
mvert = me->mvert;
mp = me->mpoly;
for (a = me->totpoly; a > 0; a--, mp++) {
- if (mp->flag & ME_HIDE || !(mp->flag & ME_FACE_SEL))
+ if (mp->flag & ME_HIDE || !(mp->flag & ME_FACE_SEL)) {
continue;
+ }
ml = me->mloop + mp->totloop;
for (b = 0; b < mp->totloop; b++, ml++) {
@@ -399,8 +405,9 @@ bool paintface_mouse_select(
}
mpoly_sel = me->mpoly + index;
- if (mpoly_sel->flag & ME_HIDE)
+ if (mpoly_sel->flag & ME_HIDE) {
return false;
+ }
/* clear flags */
if (!extend && !deselect && !toggle) {
@@ -416,10 +423,12 @@ bool paintface_mouse_select(
mpoly_sel->flag &= ~ME_FACE_SEL;
}
else if (toggle) {
- if (mpoly_sel->flag & ME_FACE_SEL)
+ if (mpoly_sel->flag & ME_FACE_SEL) {
mpoly_sel->flag &= ~ME_FACE_SEL;
- else
+ }
+ else {
mpoly_sel->flag |= ME_FACE_SEL;
+ }
}
else {
mpoly_sel->flag |= ME_FACE_SEL;
@@ -512,15 +521,17 @@ void paintvert_flush_flags(Object *ob)
int totvert;
int i;
- if (me == NULL)
+ if (me == NULL) {
return;
+ }
/* we could call this directly in all areas that change selection,
* since this could become slow for realtime updates (circle-select for eg) */
BKE_mesh_flush_select_from_verts(me);
- if (me_eval == NULL)
+ if (me_eval == NULL) {
return;
+ }
index_array = CustomData_get_layer(&me_eval->vdata, CD_ORIGINDEX);
diff --git a/source/blender/editors/mesh/editmesh_bevel.c b/source/blender/editors/mesh/editmesh_bevel.c
index 1a05e182c3a..f6940cae953 100644
--- a/source/blender/editors/mesh/editmesh_bevel.c
+++ b/source/blender/editors/mesh/editmesh_bevel.c
@@ -120,10 +120,12 @@ static float get_bevel_offset(wmOperator *op)
{
float val;
- if (RNA_enum_get(op->ptr, "offset_type") == BEVEL_AMT_PERCENT)
+ if (RNA_enum_get(op->ptr, "offset_type") == BEVEL_AMT_PERCENT) {
val = RNA_float_get(op->ptr, "offset_pct");
- else
+ }
+ else {
val = RNA_float_get(op->ptr, "offset");
+ }
return val;
}
@@ -579,10 +581,12 @@ static bool edbm_bevel_poll_property(const bContext *UNUSED(C),
if (STRPREFIX(prop_id, "offset")) {
int offset_type = RNA_enum_get(op->ptr, "offset_type");
- if (STREQ(prop_id, "offset") && offset_type == BEVEL_AMT_PERCENT)
+ if (STREQ(prop_id, "offset") && offset_type == BEVEL_AMT_PERCENT) {
return false;
- else if (STREQ(prop_id, "offset_pct") && offset_type != BEVEL_AMT_PERCENT)
+ }
+ else if (STREQ(prop_id, "offset_pct") && offset_type != BEVEL_AMT_PERCENT) {
return false;
+ }
}
return true;
@@ -648,8 +652,9 @@ wmKeyMap *bevel_modal_keymap(wmKeyConfig *keyconf)
wmKeyMap *keymap = WM_modalkeymap_get(keyconf, "Bevel Modal Map");
/* this function is called for each spacetype, only needs to add map once */
- if (keymap && keymap->modal_items)
+ if (keymap && keymap->modal_items) {
return NULL;
+ }
keymap = WM_modalkeymap_add(keyconf, "Bevel Modal Map", modal_items);
@@ -689,10 +694,12 @@ static int edbm_bevel_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
else if (etype == MOUSEPAN) {
float delta = 0.02f * (event->y - event->prevy);
- if (opdata->segments >= 1 && opdata->segments + delta < 1)
+ if (opdata->segments >= 1 && opdata->segments + delta < 1) {
opdata->segments = 1;
- else
+ }
+ else {
opdata->segments += delta;
+ }
RNA_int_set(op->ptr, "segments", (int)opdata->segments);
edbm_bevel_calc(op);
edbm_bevel_update_header(C, op);
@@ -733,13 +740,16 @@ static int edbm_bevel_modal(bContext *C, wmOperator *op, const wmEvent *event)
if (type > BEVEL_AMT_PERCENT) {
type = BEVEL_AMT_OFFSET;
}
- if (opdata->value_mode == OFFSET_VALUE && type == BEVEL_AMT_PERCENT)
+ if (opdata->value_mode == OFFSET_VALUE && type == BEVEL_AMT_PERCENT) {
opdata->value_mode = OFFSET_VALUE_PERCENT;
- else if (opdata->value_mode == OFFSET_VALUE_PERCENT && type != BEVEL_AMT_PERCENT)
+ }
+ else if (opdata->value_mode == OFFSET_VALUE_PERCENT && type != BEVEL_AMT_PERCENT) {
opdata->value_mode = OFFSET_VALUE;
+ }
RNA_enum_set(op->ptr, "offset_type", type);
- if (opdata->initial_length[opdata->value_mode] == -1.0f)
+ if (opdata->initial_length[opdata->value_mode] == -1.0f) {
edbm_bevel_calc_initial_length(op, event, true);
+ }
}
/* Update offset accordingly to new offset_type. */
if (!has_numinput &&
@@ -805,10 +815,12 @@ static int edbm_bevel_modal(bContext *C, wmOperator *op, const wmEvent *event)
case BEV_MODAL_INNER_MITER_CHANGE: {
int miter_inner = RNA_enum_get(op->ptr, "miter_inner");
miter_inner++;
- if (miter_inner == BEVEL_MITER_PATCH)
+ if (miter_inner == BEVEL_MITER_PATCH) {
miter_inner++; /* no patch option for inner miter */
- if (miter_inner > BEVEL_MITER_ARC)
+ }
+ if (miter_inner > BEVEL_MITER_ARC) {
miter_inner = BEVEL_MITER_SHARP;
+ }
RNA_enum_set(op->ptr, "miter_inner", miter_inner);
edbm_bevel_calc(op);
edbm_bevel_update_header(C, op);
@@ -819,8 +831,9 @@ static int edbm_bevel_modal(bContext *C, wmOperator *op, const wmEvent *event)
case BEV_MODAL_OUTER_MITER_CHANGE: {
int miter_outer = RNA_enum_get(op->ptr, "miter_outer");
miter_outer++;
- if (miter_outer > BEVEL_MITER_ARC)
+ if (miter_outer > BEVEL_MITER_ARC) {
miter_outer = BEVEL_MITER_SHARP;
+ }
RNA_enum_set(op->ptr, "miter_outer", miter_outer);
edbm_bevel_calc(op);
edbm_bevel_update_header(C, op);
diff --git a/source/blender/editors/mesh/editmesh_extrude.c b/source/blender/editors/mesh/editmesh_extrude.c
index eeda7ec5f2d..9314b96afee 100644
--- a/source/blender/editors/mesh/editmesh_extrude.c
+++ b/source/blender/editors/mesh/editmesh_extrude.c
@@ -347,28 +347,37 @@ static bool edbm_extrude_mesh(Object *obedit, BMEditMesh *em, wmOperator *op)
bool changed = false;
if (em->selectmode & SCE_SELECT_VERTEX) {
- if (em->bm->totvertsel == 0)
+ if (em->bm->totvertsel == 0) {
nr = NONE;
- else if (em->bm->totvertsel == 1)
+ }
+ else if (em->bm->totvertsel == 1) {
nr = VERT_ONLY;
- else if (em->bm->totedgesel == 0)
+ }
+ else if (em->bm->totedgesel == 0) {
nr = VERT_ONLY;
- else
+ }
+ else {
nr = ELEM_FLAG;
+ }
}
else if (em->selectmode & SCE_SELECT_EDGE) {
- if (em->bm->totedgesel == 0)
+ if (em->bm->totedgesel == 0) {
nr = NONE;
- else if (em->bm->totfacesel == 0)
+ }
+ else if (em->bm->totfacesel == 0) {
nr = EDGE_ONLY;
- else
+ }
+ else {
nr = ELEM_FLAG;
+ }
}
else {
- if (em->bm->totfacesel == 0)
+ if (em->bm->totfacesel == 0) {
nr = NONE;
- else
+ }
+ else {
nr = ELEM_FLAG;
+ }
}
switch (nr) {
diff --git a/source/blender/editors/mesh/editmesh_extrude_screw.c b/source/blender/editors/mesh/editmesh_extrude_screw.c
index c9422545c7b..252f95a10ac 100644
--- a/source/blender/editors/mesh/editmesh_extrude_screw.c
+++ b/source/blender/editors/mesh/editmesh_extrude_screw.c
@@ -125,8 +125,9 @@ static int edbm_screw_exec(bContext *C, wmOperator *op)
sub_v3_v3v3(dvec, v1_co_global, v2_co_global);
mul_v3_fl(dvec, 1.0f / steps);
- if (dot_v3v3(nor, dvec) > 0.0f)
+ if (dot_v3v3(nor, dvec) > 0.0f) {
negate_v3(dvec);
+ }
BMOperator spinop;
if (!EDBM_op_init(
diff --git a/source/blender/editors/mesh/editmesh_inset.c b/source/blender/editors/mesh/editmesh_inset.c
index 7bee030bb46..2955488a597 100644
--- a/source/blender/editors/mesh/editmesh_inset.c
+++ b/source/blender/editors/mesh/editmesh_inset.c
@@ -91,8 +91,9 @@ static void edbm_inset_update_header(wmOperator *op, bContext *C)
if (sa) {
char flts_str[NUM_STR_REP_LEN * 2];
- if (hasNumInput(&opdata->num_input))
+ if (hasNumInput(&opdata->num_input)) {
outputNumInput(&opdata->num_input, flts_str, &sce->unit);
+ }
else {
BLI_snprintf(flts_str, NUM_STR_REP_LEN, "%f", RNA_float_get(op->ptr, "thickness"));
BLI_snprintf(
@@ -413,18 +414,21 @@ static int edbm_inset_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
/* Fake shift-transform... */
- if (opdata->shift)
+ if (opdata->shift) {
amount = (amount - opdata->shift_amount) * 0.1f + opdata->shift_amount;
+ }
- if (opdata->modify_depth)
+ if (opdata->modify_depth) {
RNA_float_set(op->ptr, "depth", amount);
+ }
else {
amount = max_ff(amount, 0.0f);
RNA_float_set(op->ptr, "thickness", amount);
}
- if (edbm_inset_calc(op))
+ if (edbm_inset_calc(op)) {
edbm_inset_update_header(op, C);
+ }
else {
edbm_inset_cancel(C, op);
return OPERATOR_CANCELLED;
@@ -446,10 +450,12 @@ static int edbm_inset_modal(bContext *C, wmOperator *op, const wmEvent *event)
case LEFTSHIFTKEY:
case RIGHTSHIFTKEY:
if (event->val == KM_PRESS) {
- if (opdata->modify_depth)
+ if (opdata->modify_depth) {
opdata->shift_amount = RNA_float_get(op->ptr, "depth");
- else
+ }
+ else {
opdata->shift_amount = RNA_float_get(op->ptr, "thickness");
+ }
opdata->shift = true;
handled = true;
}
@@ -469,14 +475,16 @@ static int edbm_inset_modal(bContext *C, wmOperator *op, const wmEvent *event)
if (event->val == KM_PRESS) {
opdata->old_thickness = RNA_float_get(op->ptr, "thickness");
- if (opdata->shift)
+ if (opdata->shift) {
opdata->shift_amount = opdata->old_thickness;
+ }
opdata->modify_depth = true;
}
else {
opdata->old_depth = RNA_float_get(op->ptr, "depth");
- if (opdata->shift)
+ if (opdata->shift) {
opdata->shift_amount = opdata->old_depth;
+ }
opdata->modify_depth = false;
}
opdata->initial_length = len_v2(mlen);
diff --git a/source/blender/editors/mesh/editmesh_intersect.c b/source/blender/editors/mesh/editmesh_intersect.c
index 06e2ef6e304..370cc6a2a6d 100644
--- a/source/blender/editors/mesh/editmesh_intersect.c
+++ b/source/blender/editors/mesh/editmesh_intersect.c
@@ -512,12 +512,15 @@ static int bm_edge_sort_length_cb(const void *e_a_v, const void *e_b_v)
const float val_a = -BM_edge_calc_length_squared(*((BMEdge **)e_a_v));
const float val_b = -BM_edge_calc_length_squared(*((BMEdge **)e_b_v));
- if (val_a > val_b)
+ if (val_a > val_b) {
return 1;
- else if (val_a < val_b)
+ }
+ else if (val_a < val_b) {
return -1;
- else
+ }
+ else {
return 0;
+ }
}
static void bm_face_split_by_edges_island_connect(
diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c
index 10a767c2b86..cd5281e1273 100644
--- a/source/blender/editors/mesh/editmesh_knife.c
+++ b/source/blender/editors/mesh/editmesh_knife.c
@@ -366,8 +366,9 @@ static Ref *find_ref(ListBase *lb, void *ref)
Ref *ref1;
for (ref1 = lb->first; ref1; ref1 = ref1->next) {
- if (ref1->ref == ref)
+ if (ref1->ref == ref) {
return ref1;
+ }
}
return NULL;
@@ -375,8 +376,9 @@ static Ref *find_ref(ListBase *lb, void *ref)
static void knife_append_list_no_dup(KnifeTool_OpData *kcd, ListBase *lst, void *elem)
{
- if (!find_ref(lst, elem))
+ if (!find_ref(lst, elem)) {
knife_append_list(kcd, lst, elem);
+ }
}
static KnifeEdge *new_knife_edge(KnifeTool_OpData *kcd)
@@ -410,8 +412,9 @@ static BMFace *knife_find_common_face(ListBase *faces1, ListBase *faces2)
for (ref1 = faces1->first; ref1; ref1 = ref1->next) {
for (ref2 = faces2->first; ref2; ref2 = ref2->next) {
- if (ref1->ref == ref2->ref)
+ if (ref1->ref == ref2->ref) {
return (BMFace *)(ref1->ref);
+ }
}
}
return NULL;
@@ -441,10 +444,12 @@ static KnifeVert *get_bm_knife_vert(KnifeTool_OpData *kcd, BMVert *v)
BMIter bmiter;
BMFace *f;
- if (BM_elem_index_get(v) >= 0)
+ if (BM_elem_index_get(v) >= 0) {
cageco = kcd->cagecos[BM_elem_index_get(v)];
- else
+ }
+ else {
cageco = v->co;
+ }
kfv = new_knife_vert(kcd, v->co, cageco);
kfv->v = v;
BLI_ghash_insert(kcd->origvertmap, v, kfv);
@@ -493,8 +498,9 @@ static void set_lowest_face_tri(KnifeTool_OpData *kcd, BMFace *f, int index)
{
int i;
- if (BLI_ghash_lookup(kcd->facetrimap, f))
+ if (BLI_ghash_lookup(kcd->facetrimap, f)) {
return;
+ }
BLI_assert(index >= 0 && index < kcd->em->tottri);
BLI_assert(kcd->em->looptris[index][0]->f == f);
@@ -504,8 +510,9 @@ static void set_lowest_face_tri(KnifeTool_OpData *kcd, BMFace *f, int index)
break;
}
}
- if (i == -1)
+ if (i == -1) {
i++;
+ }
BLI_ghash_insert(kcd->facetrimap, f, POINTER_FROM_INT(i + 1));
}
@@ -594,8 +601,9 @@ static KnifeVert *knife_split_edge(KnifeTool_OpData *kcd,
* If v1 and v2 are in multiple faces together (e.g., if they
* are in doubled polys) then this arbitrarily chooses one of them */
f = knife_find_common_face(&kfe->v1->faces, &kfe->v2->faces);
- if (f)
+ if (f) {
knife_append_list(kcd, &newkfe->v2->faces, f);
+ }
}
newkfe->basef = kfe->basef;
@@ -605,8 +613,9 @@ static KnifeVert *knife_split_edge(KnifeTool_OpData *kcd,
kfe->v1 = newkfe->v2;
BLI_addtail(&kfe->v1->edges, ref);
- for (ref = kfe->faces.first; ref; ref = ref->next)
+ for (ref = kfe->faces.first; ref; ref = ref->next) {
knife_edge_append_face(kcd, newkfe, ref->ref);
+ }
knife_add_to_vert_edges(kcd, newkfe);
@@ -637,22 +646,29 @@ static int linehit_compare(const void *vlh1, const void *vlh2)
const KnifeLineHit *lh1 = vlh1;
const KnifeLineHit *lh2 = vlh2;
- if (lh1->l < lh2->l)
+ if (lh1->l < lh2->l) {
return -1;
- else if (lh1->l > lh2->l)
+ }
+ else if (lh1->l > lh2->l) {
return 1;
+ }
else {
- if (lh1->m < lh2->m)
+ if (lh1->m < lh2->m) {
return -1;
- else if (lh1->m > lh2->m)
+ }
+ else if (lh1->m > lh2->m) {
return 1;
+ }
else {
- if (lh1->v < lh2->v)
+ if (lh1->v < lh2->v) {
return -1;
- else if (lh1->v > lh2->v)
+ }
+ else if (lh1->v > lh2->v) {
return 1;
- else
+ }
+ else {
return 0;
+ }
}
}
}
@@ -670,8 +686,9 @@ static void prepare_linehits_for_cut(KnifeTool_OpData *kcd)
n = kcd->totlinehit;
linehits = kcd->linehits;
- if (n == 0)
+ if (n == 0) {
return;
+ }
qsort(linehits, n, sizeof(KnifeLineHit), linehit_compare);
@@ -725,8 +742,9 @@ static void prepare_linehits_for_cut(KnifeTool_OpData *kcd)
memcpy(&linehits[i], &linehits[j], sizeof(KnifeLineHit));
}
else {
- if (i + 1 != j)
+ if (i + 1 != j) {
memcpy(&linehits[i + 1], &linehits[j], sizeof(KnifeLineHit));
+ }
i++;
}
j++;
@@ -851,8 +869,9 @@ static void knife_add_single_cut(KnifeTool_OpData *kcd,
knife_add_to_vert_edges(kcd, kfe);
/* TODO: check if this is ever needed */
- if (kfe->basef && !find_ref(&kfe->faces, kfe->basef))
+ if (kfe->basef && !find_ref(&kfe->faces, kfe->basef)) {
knife_edge_append_face(kcd, kfe, kfe->basef);
+ }
}
/* Given a list of KnifeLineHits for one face, sorted by l
@@ -863,8 +882,9 @@ static void knife_cut_face(KnifeTool_OpData *kcd, BMFace *f, ListBase *hits)
{
Ref *r;
- if (BLI_listbase_count_at_most(hits, 2) != 2)
+ if (BLI_listbase_count_at_most(hits, 2) != 2) {
return;
+ }
for (r = hits->first; r->next; r = r->next) {
knife_add_single_cut(kcd, r->ref, r->next->ref, f);
@@ -1167,8 +1187,9 @@ static void knifetool_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void
BLI_mempool_iternew(kcd->kedges, &iter);
for (kfe = BLI_mempool_iterstep(&iter); kfe; kfe = BLI_mempool_iterstep(&iter)) {
- if (!kfe->is_cut)
+ if (!kfe->is_cut) {
continue;
+ }
immVertex3fv(pos, kfe->v1->cageco);
immVertex3fv(pos, kfe->v2->cageco);
@@ -1191,8 +1212,9 @@ static void knifetool_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void
BLI_mempool_iternew(kcd->kverts, &iter);
for (kfv = BLI_mempool_iterstep(&iter); kfv; kfv = BLI_mempool_iterstep(&iter)) {
- if (!kfv->is_cut)
+ if (!kfv->is_cut) {
continue;
+ }
immVertex3fv(pos, kfv->cageco);
}
@@ -1249,8 +1271,9 @@ static bool knife_ray_intersect_face(KnifeTool_OpData *kcd,
float ray_tri_uv[2];
tri = kcd->em->looptris[tri_i];
- if (tri[0]->f != f)
+ if (tri[0]->f != f) {
break;
+ }
lv1 = kcd->cagecos[BM_elem_index_get(tri[0]->v)];
lv2 = kcd->cagecos[BM_elem_index_get(tri[1]->v)];
lv3 = kcd->cagecos[BM_elem_index_get(tri[2]->v)];
@@ -1594,8 +1617,9 @@ static void knife_find_line_hits(KnifeTool_OpData *kcd)
* (which may involve using doubles everywhere!),
* limit the distance between these points */
if (kcd->is_ortho && (kcd->vc.rv3d->persp != RV3D_CAMOB)) {
- if (kcd->ortho_extent == 0.0f)
+ if (kcd->ortho_extent == 0.0f) {
calc_ortho_extent(kcd);
+ }
clip_to_ortho_planes(v1, v3, kcd->ortho_extent_center, kcd->ortho_extent + 10.0f);
clip_to_ortho_planes(v2, v4, kcd->ortho_extent_center, kcd->ortho_extent + 10.0f);
}
@@ -1642,8 +1666,9 @@ static void knife_find_line_hits(KnifeTool_OpData *kcd)
lst = knife_get_face_kedges(kcd, f);
for (ref = lst->first; ref; ref = ref->next) {
kfe = ref->ref;
- if (BLI_smallhash_haskey(&kfes, (uintptr_t)kfe))
+ if (BLI_smallhash_haskey(&kfes, (uintptr_t)kfe)) {
continue;
+ }
BLI_smallhash_insert(&kfes, (uintptr_t)kfe, kfe);
v = kfe->v1;
BLI_smallhash_reinsert(&kfvs, (uintptr_t)v, v);
@@ -1725,12 +1750,14 @@ static void knife_find_line_hits(KnifeTool_OpData *kcd)
if (isect_kind == -1) {
/* isect_seg_seg_v2_simple doesn't do tolerance test around ends of s1-s2 */
closest_to_line_segment_v2(sint, s1, se1, se2);
- if (len_squared_v2v2(sint, s1) <= line_tol_sq)
+ if (len_squared_v2v2(sint, s1) <= line_tol_sq) {
isect_kind = 1;
+ }
else {
closest_to_line_segment_v2(sint, s2, se1, se2);
- if (len_squared_v2v2(sint, s2) <= line_tol_sq)
+ if (len_squared_v2v2(sint, s2) <= line_tol_sq) {
isect_kind = 1;
+ }
}
}
if (isect_kind == 1) {
@@ -1809,8 +1836,9 @@ static void knife_find_line_hits(KnifeTool_OpData *kcd)
BLI_smallhash_release(&kfes);
BLI_smallhash_release(&kfvs);
BLI_bvhtree_free(planetree);
- if (results)
+ if (results) {
MEM_freeN(results);
+ }
}
static void knife_input_ray_segment(KnifeTool_OpData *kcd,
@@ -1852,8 +1880,9 @@ static BMFace *knife_find_closest_face(KnifeTool_OpData *kcd,
f = NULL;
}
- if (is_space)
+ if (is_space) {
*is_space = !f;
+ }
if (!f) {
if (kcd->is_interactive) {
@@ -2025,8 +2054,9 @@ static KnifeEdge *knife_find_closest_edge(
copy_v3_v3(cur_cagep, test_cagep);
}
- if (fptr)
+ if (fptr) {
*fptr = f;
+ }
if (cure) {
if (!kcd->ignore_edge_snapping || !(cure->e)) {
@@ -2056,8 +2086,9 @@ static KnifeEdge *knife_find_closest_edge(
return cure;
}
- if (fptr)
+ if (fptr) {
*fptr = NULL;
+ }
return NULL;
}
@@ -2133,8 +2164,9 @@ static KnifeVert *knife_find_closest_vert(
}
if (!kcd->ignore_vert_snapping || !(curv && curv->v)) {
- if (fptr)
+ if (fptr) {
*fptr = f;
+ }
if (curv) {
copy_v3_v3(p, curv->co);
@@ -2149,15 +2181,17 @@ static KnifeVert *knife_find_closest_vert(
return curv;
}
else {
- if (fptr)
+ if (fptr) {
*fptr = f;
+ }
return NULL;
}
}
- if (fptr)
+ if (fptr) {
*fptr = NULL;
+ }
return NULL;
}
@@ -2262,12 +2296,15 @@ static int sort_verts_by_dist_cb(void *co_p, const void *cur_a_p, const void *cu
const float a_sq = len_squared_v3v3(co, cur_a->co);
const float b_sq = len_squared_v3v3(co, cur_b->co);
- if (a_sq < b_sq)
+ if (a_sq < b_sq) {
return -1;
- else if (a_sq > b_sq)
+ }
+ else if (a_sq > b_sq) {
return 1;
- else
+ }
+ else {
return 0;
+ }
}
static bool knife_verts_edge_in_face(KnifeVert *v1, KnifeVert *v2, BMFace *f)
@@ -2276,8 +2313,9 @@ static bool knife_verts_edge_in_face(KnifeVert *v1, KnifeVert *v2, BMFace *f)
bool v1_inface, v2_inface;
BMLoop *l1, *l2;
- if (!f || !v1 || !v2)
+ if (!f || !v1 || !v2) {
return false;
+ }
l1 = v1->v ? BM_face_vert_share_loop(f, v1->v) : NULL;
l2 = v2->v ? BM_face_vert_share_loop(f, v2->v) : NULL;
@@ -2454,8 +2492,9 @@ static void knife_make_cuts(KnifeTool_OpData *kcd)
}
f = kfe->basef;
- if (!f || kfe->e)
+ if (!f || kfe->e) {
continue;
+ }
lst = BLI_smallhash_lookup(fhash, (uintptr_t)f);
if (!lst) {
lst = knife_empty_list(kcd);
@@ -2467,21 +2506,24 @@ static void knife_make_cuts(KnifeTool_OpData *kcd)
/* put list of splitting vertices for an edge into ehash, keyed by edge */
BLI_mempool_iternew(kcd->kverts, &iter);
for (kfv = BLI_mempool_iterstep(&iter); kfv; kfv = BLI_mempool_iterstep(&iter)) {
- if (kfv->v)
+ if (kfv->v) {
continue; /* already have a BMVert */
+ }
for (ref = kfv->edges.first; ref; ref = ref->next) {
kfe = ref->ref;
e = kfe->e;
- if (!e)
+ if (!e) {
continue;
+ }
lst = BLI_smallhash_lookup(ehash, (uintptr_t)e);
if (!lst) {
lst = knife_empty_list(kcd);
BLI_smallhash_insert(ehash, (uintptr_t)e, lst);
}
/* there can be more than one kfe in kfv's list with same e */
- if (!find_ref(lst, kfv))
+ if (!find_ref(lst, kfv)) {
knife_append_list(kcd, lst, kfv);
+ }
}
}
@@ -2545,8 +2587,9 @@ static void knife_recalc_projmat(KnifeTool_OpData *kcd)
/* called when modal loop selection is done... */
static void knifetool_exit_ex(bContext *C, KnifeTool_OpData *kcd)
{
- if (!kcd)
+ if (!kcd) {
return;
+ }
if (kcd->is_interactive) {
WM_cursor_modal_restore(CTX_wm_window(C));
@@ -2576,8 +2619,9 @@ static void knifetool_exit_ex(bContext *C, KnifeTool_OpData *kcd)
knifetool_free_bmbvh(kcd);
- if (kcd->linehits)
+ if (kcd->linehits) {
MEM_freeN(kcd->linehits);
+ }
/* destroy kcd itself */
MEM_freeN(kcd);
@@ -2774,8 +2818,9 @@ wmKeyMap *knifetool_modal_keymap(wmKeyConfig *keyconf)
wmKeyMap *keymap = WM_modalkeymap_get(keyconf, "Knife Tool Modal Map");
/* this function is called for each spacetype, only needs to add map once */
- if (keymap && keymap->modal_items)
+ if (keymap && keymap->modal_items) {
return NULL;
+ }
keymap = WM_modalkeymap_add(keyconf, "Knife Tool Modal Map", modal_items);
@@ -2802,8 +2847,9 @@ static int knifetool_modal(bContext *C, wmOperator *op, const wmEvent *event)
view3d_operator_needs_opengl(C);
ED_view3d_init_mats_rv3d(obedit, kcd->vc.rv3d); /* needed to initialize clipping */
- if (kcd->mode == MODE_PANNING)
+ if (kcd->mode == MODE_PANNING) {
kcd->mode = kcd->prevmode;
+ }
/* handle modal keymap */
if (event->type == EVT_MODAL_MAP) {
diff --git a/source/blender/editors/mesh/editmesh_loopcut.c b/source/blender/editors/mesh/editmesh_loopcut.c
index d0988811d15..528235e693a 100644
--- a/source/blender/editors/mesh/editmesh_loopcut.c
+++ b/source/blender/editors/mesh/editmesh_loopcut.c
@@ -545,8 +545,9 @@ static int loopcut_modal(bContext *C, wmOperator *op, const wmEvent *event)
case RETKEY:
case PADENTER:
case LEFTMOUSE: /* confirm */ // XXX hardcoded
- if (event->val == KM_PRESS)
+ if (event->val == KM_PRESS) {
return loopcut_finish(lcd, C, op);
+ }
ED_region_tag_redraw(lcd->ar);
handled = true;
@@ -573,8 +574,9 @@ static int loopcut_modal(bContext *C, wmOperator *op, const wmEvent *event)
case MOUSEPAN:
if (event->alt == 0) {
cuts += 0.02f * (event->y - event->prevy);
- if (cuts < 1 && lcd->cuts >= 1)
+ if (cuts < 1 && lcd->cuts >= 1) {
cuts = 1;
+ }
}
else {
smoothness += 0.002f * (event->y - event->prevy);
@@ -584,8 +586,9 @@ static int loopcut_modal(bContext *C, wmOperator *op, const wmEvent *event)
case PADPLUSKEY:
case PAGEUPKEY:
case WHEELUPMOUSE: /* change number of cuts */
- if (event->val == KM_RELEASE)
+ if (event->val == KM_RELEASE) {
break;
+ }
if (event->alt == 0) {
cuts += 1;
}
@@ -597,8 +600,9 @@ static int loopcut_modal(bContext *C, wmOperator *op, const wmEvent *event)
case PADMINUS:
case PAGEDOWNKEY:
case WHEELDOWNMOUSE: /* change number of cuts */
- if (event->val == KM_RELEASE)
+ if (event->val == KM_RELEASE) {
break;
+ }
if (event->alt == 0) {
cuts = max_ff(cuts - 1, 1);
}
diff --git a/source/blender/editors/mesh/editmesh_path.c b/source/blender/editors/mesh/editmesh_path.c
index c6b1ab9f1f2..062008cd656 100644
--- a/source/blender/editors/mesh/editmesh_path.c
+++ b/source/blender/editors/mesh/editmesh_path.c
@@ -281,10 +281,12 @@ static void edgetag_set_cb(BMEdge *e, bool val, void *user_data_v)
case EDGE_MODE_TAG_FREESTYLE: {
FreestyleEdge *fed;
fed = CustomData_bmesh_get(&bm->edata, e->head.data, CD_FREESTYLE_EDGE);
- if (!val)
+ if (!val) {
fed->flag &= ~FREESTYLE_EDGE_MARK;
- else
+ }
+ else {
fed->flag |= FREESTYLE_EDGE_MARK;
+ }
break;
}
#endif
@@ -396,8 +398,9 @@ static void mouse_mesh_shortest_path_edge(Scene *UNUSED(scene),
if (op_params->edge_mode != EDGE_MODE_SELECT) {
if (op_params->track_active) {
/* simple rules - last edge is _always_ active and selected */
- if (e_act)
+ if (e_act) {
BM_edge_select_set(bm, e_act, false);
+ }
BM_edge_select_set(bm, e_dst_last, true);
BM_select_history_store(bm, e_dst_last);
}
@@ -408,10 +411,12 @@ static void mouse_mesh_shortest_path_edge(Scene *UNUSED(scene),
if (op_params->track_active) {
/* even if this is selected it may not be in the selection list */
if (op_params->edge_mode == EDGE_MODE_SELECT) {
- if (edgetag_test_cb(e_dst_last, &user_data) == 0)
+ if (edgetag_test_cb(e_dst_last, &user_data) == 0) {
BM_select_history_remove(bm, e_dst_last);
- else
+ }
+ else {
BM_select_history_store(bm, e_dst_last);
+ }
}
}
@@ -777,12 +782,15 @@ static int edbm_shortest_path_select_exec(bContext *C, wmOperator *op)
if ((em->selectmode & SCE_SELECT_VERTEX) && (bm->totvertsel >= 2)) {
BM_ITER_MESH (ele, &iter, bm, BM_VERTS_OF_MESH) {
if (BM_elem_flag_test(ele, BM_ELEM_SELECT)) {
- if (ele_src == NULL)
+ if (ele_src == NULL) {
ele_src = ele;
- else if (ele_dst == NULL)
+ }
+ else if (ele_dst == NULL) {
ele_dst = ele;
- else
+ }
+ else {
break;
+ }
}
}
}
@@ -791,12 +799,15 @@ static int edbm_shortest_path_select_exec(bContext *C, wmOperator *op)
ele_src = NULL;
BM_ITER_MESH (ele, &iter, bm, BM_EDGES_OF_MESH) {
if (BM_elem_flag_test(ele, BM_ELEM_SELECT)) {
- if (ele_src == NULL)
+ if (ele_src == NULL) {
ele_src = ele;
- else if (ele_dst == NULL)
+ }
+ else if (ele_dst == NULL) {
ele_dst = ele;
- else
+ }
+ else {
break;
+ }
}
}
}
@@ -805,12 +816,15 @@ static int edbm_shortest_path_select_exec(bContext *C, wmOperator *op)
ele_src = NULL;
BM_ITER_MESH (ele, &iter, bm, BM_FACES_OF_MESH) {
if (BM_elem_flag_test(ele, BM_ELEM_SELECT)) {
- if (ele_src == NULL)
+ if (ele_src == NULL) {
ele_src = ele;
- else if (ele_dst == NULL)
+ }
+ else if (ele_dst == NULL) {
ele_dst = ele;
- else
+ }
+ else {
break;
+ }
}
}
}
diff --git a/source/blender/editors/mesh/editmesh_preselect_edgering.c b/source/blender/editors/mesh/editmesh_preselect_edgering.c
index b007343e14e..92a8c7da71d 100644
--- a/source/blender/editors/mesh/editmesh_preselect_edgering.c
+++ b/source/blender/editors/mesh/editmesh_preselect_edgering.c
@@ -93,8 +93,9 @@ static void edgering_find_order(BMEdge *eed_last, BMEdge *eed, BMVert *eve_last,
if (!(BM_edge_in_face(eed, l->f) && BM_edge_in_face(eed_last, l->f))) {
BMIter liter;
BM_ITER_ELEM (l, &liter, l, BM_LOOPS_OF_LOOP) {
- if (BM_edge_in_face(eed, l->f) && BM_edge_in_face(eed_last, l->f))
+ if (BM_edge_in_face(eed, l->f) && BM_edge_in_face(eed_last, l->f)) {
break;
+ }
}
}
diff --git a/source/blender/editors/mesh/editmesh_rip.c b/source/blender/editors/mesh/editmesh_rip.c
index 8d995d542dc..a39944fc145 100644
--- a/source/blender/editors/mesh/editmesh_rip.c
+++ b/source/blender/editors/mesh/editmesh_rip.c
@@ -542,8 +542,9 @@ static int edbm_rip_invoke__vert(bContext *C, const wmEvent *event, Object *obed
ese.ele = NULL;
BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
- if (BM_elem_flag_test(v, BM_ELEM_SELECT))
+ if (BM_elem_flag_test(v, BM_ELEM_SELECT)) {
break;
+ }
}
}
@@ -812,8 +813,9 @@ static int edbm_rip_invoke__vert(bContext *C, const wmEvent *event, Object *obed
BM_vert_select_set(bm, v_rip, true);
}
else {
- if (fill_uloop_pairs)
+ if (fill_uloop_pairs) {
MEM_freeN(fill_uloop_pairs);
+ }
return OPERATOR_CANCELLED;
}
}
@@ -942,8 +944,9 @@ static int edbm_rip_invoke__edge(bContext *C, const wmEvent *event, Object *obed
if (BM_edge_is_manifold(l->e)) {
l = l->radial_next;
- if (totedge_manifold != 3)
+ if (totedge_manifold != 3) {
l = BM_loop_other_edge_loop(l, v);
+ }
if (l) {
BLI_assert(!BM_elem_flag_test(l->e, BM_ELEM_TAG));
diff --git a/source/blender/editors/mesh/editmesh_rip_edge.c b/source/blender/editors/mesh/editmesh_rip_edge.c
index e2b77d8c83b..61253f06f9f 100644
--- a/source/blender/editors/mesh/editmesh_rip_edge.c
+++ b/source/blender/editors/mesh/editmesh_rip_edge.c
@@ -71,8 +71,9 @@ static int edbm_rip_edge_invoke(bContext *C, wmOperator *UNUSED(op), const wmEve
float projectMat[4][4];
- if (bm->totvertsel == 0)
+ if (bm->totvertsel == 0) {
continue;
+ }
ED_view3d_ob_project_mat_get(rv3d, obedit, projectMat);
diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c
index 69066adba41..d81de37add3 100644
--- a/source/blender/editors/mesh/editmesh_select.c
+++ b/source/blender/editors/mesh/editmesh_select.c
@@ -110,8 +110,9 @@ void EDBM_select_mirrored(
EDBM_verts_mirror_cache_begin(em, axis, true, true, use_topology);
- if (!extend)
+ if (!extend) {
EDBM_flag_disable_all(em, BM_ELEM_SELECT);
+ }
if (bm->selectmode & SCE_SELECT_VERTEX) {
BMVert *v;
@@ -241,19 +242,22 @@ bool EDBM_backbuf_check(unsigned int index)
/* odd logic, if selbuf is NULL we assume no zbuf-selection is enabled
* and just ignore the depth buffer, this is error prone since its possible
* code doesn't set the depth buffer by accident, but leave for now. - Campbell */
- if (selbuf == NULL)
+ if (selbuf == NULL) {
return true;
+ }
- if (index > 0 && index <= bm_vertoffs)
+ if (index > 0 && index <= bm_vertoffs) {
return BLI_BITMAP_TEST_BOOL(selbuf, index);
+ }
return false;
}
void EDBM_backbuf_free(void)
{
- if (selbuf)
+ if (selbuf) {
MEM_freeN(selbuf);
+ }
selbuf = NULL;
}
@@ -1423,10 +1427,12 @@ static int edbm_select_mode_invoke(bContext *C, wmOperator *op, const wmEvent *e
/* detecting these options based on shift/ctrl here is weak, but it's done
* to make this work when clicking buttons or menus */
- if (!RNA_struct_property_is_set(op->ptr, "use_extend"))
+ if (!RNA_struct_property_is_set(op->ptr, "use_extend")) {
RNA_boolean_set(op->ptr, "use_extend", event->shift);
- if (!RNA_struct_property_is_set(op->ptr, "use_expand"))
+ }
+ if (!RNA_struct_property_is_set(op->ptr, "use_expand")) {
RNA_boolean_set(op->ptr, "use_expand", event->ctrl);
+ }
return edbm_select_mode_exec(C, op);
}
@@ -2204,8 +2210,9 @@ static void edbm_strip_selections(BMEditMesh *em)
ese = em->bm->selected.first;
while (ese) {
nextese = ese->next;
- if (ese->htype == BM_VERT)
+ if (ese->htype == BM_VERT) {
BLI_freelinkN(&(em->bm->selected), ese);
+ }
ese = nextese;
}
}
@@ -2213,8 +2220,9 @@ static void edbm_strip_selections(BMEditMesh *em)
ese = em->bm->selected.first;
while (ese) {
nextese = ese->next;
- if (ese->htype == BM_EDGE)
+ if (ese->htype == BM_EDGE) {
BLI_freelinkN(&(em->bm->selected), ese);
+ }
ese = nextese;
}
}
@@ -2222,8 +2230,9 @@ static void edbm_strip_selections(BMEditMesh *em)
ese = em->bm->selected.first;
while (ese) {
nextese = ese->next;
- if (ese->htype == BM_FACE)
+ if (ese->htype == BM_FACE) {
BLI_freelinkN(&(em->bm->selected), ese);
+ }
ese = nextese;
}
}
@@ -2575,8 +2584,9 @@ bool EDBM_deselect_by_material(BMEditMesh *em, const short index, const bool sel
bool changed = false;
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (BM_elem_flag_test(efa, BM_ELEM_HIDDEN))
+ if (BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) {
continue;
+ }
if (efa->mat_nr == index) {
changed = true;
BM_face_select_set(em->bm, efa, select);
@@ -2587,10 +2597,12 @@ bool EDBM_deselect_by_material(BMEditMesh *em, const short index, const bool sel
void EDBM_select_toggle_all(BMEditMesh *em) /* exported for UV */
{
- if (em->bm->totvertsel || em->bm->totedgesel || em->bm->totfacesel)
+ if (em->bm->totvertsel || em->bm->totedgesel || em->bm->totfacesel) {
EDBM_flag_disable_all(em, BM_ELEM_SELECT);
- else
+ }
+ else {
EDBM_flag_enable_all(em, BM_ELEM_SELECT);
+ }
}
void EDBM_select_swap(BMEditMesh *em) /* exported for UV */
@@ -2602,22 +2614,25 @@ void EDBM_select_swap(BMEditMesh *em) /* exported for UV */
if (em->bm->selectmode & SCE_SELECT_VERTEX) {
BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) {
- if (BM_elem_flag_test(eve, BM_ELEM_HIDDEN))
+ if (BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) {
continue;
+ }
BM_vert_select_set(em->bm, eve, !BM_elem_flag_test(eve, BM_ELEM_SELECT));
}
}
else if (em->selectmode & SCE_SELECT_EDGE) {
BM_ITER_MESH (eed, &iter, em->bm, BM_EDGES_OF_MESH) {
- if (BM_elem_flag_test(eed, BM_ELEM_HIDDEN))
+ if (BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) {
continue;
+ }
BM_edge_select_set(em->bm, eed, !BM_elem_flag_test(eed, BM_ELEM_SELECT));
}
}
else {
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (BM_elem_flag_test(efa, BM_ELEM_HIDDEN))
+ if (BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) {
continue;
+ }
BM_face_select_set(em->bm, efa, !BM_elem_flag_test(efa, BM_ELEM_SELECT));
}
}
@@ -2674,8 +2689,9 @@ bool EDBM_select_interior_faces(BMEditMesh *em)
bool changed = false;
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (BM_elem_flag_test(efa, BM_ELEM_HIDDEN))
+ if (BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) {
continue;
+ }
ok = true;
BM_ITER_ELEM (eed, &eiter, efa, BM_EDGES_OF_FACE) {
@@ -4601,8 +4617,9 @@ static int edbm_region_to_loop_exec(bContext *C, wmOperator *UNUSED(op))
totsel += BM_elem_flag_test(l2->f, BM_ELEM_SELECT) != 0;
}
- if ((tot != totsel && totsel > 0) || (totsel == 1 && tot == 1))
+ if ((tot != totsel && totsel > 0) || (totsel == 1 && tot == 1)) {
BM_elem_flag_enable(l1->e, BM_ELEM_TAG);
+ }
}
}
@@ -4670,8 +4687,9 @@ static int loop_find_region(BMLoop *l, int flag, GSet *visit_face_set, BMFace **
BLI_array_append(region, f);
BM_ITER_ELEM (l1, &liter1, f, BM_LOOPS_OF_FACE) {
- if (BM_elem_flag_test(l1->e, flag))
+ if (BM_elem_flag_test(l1->e, flag)) {
continue;
+ }
BM_ITER_ELEM (l2, &liter2, l1->e, BM_LOOPS_OF_EDGE) {
/* avoids finding same region twice
@@ -4701,10 +4719,12 @@ static int verg_radial(const void *va, const void *vb)
const int a = BM_edge_face_count(e_a);
const int b = BM_edge_face_count(e_b);
- if (a > b)
+ if (a > b) {
return -1;
- if (a < b)
+ }
+ if (a < b) {
return 1;
+ }
return 0;
}
@@ -4747,12 +4767,14 @@ static int loop_find_regions(BMEditMesh *em, const bool selbigger)
e = edges[i];
- if (!BM_elem_flag_test(e, BM_ELEM_TAG))
+ if (!BM_elem_flag_test(e, BM_ELEM_TAG)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, e, BM_LOOPS_OF_EDGE) {
- if (BLI_gset_haskey(visit_face_set, l->f))
+ if (BLI_gset_haskey(visit_face_set, l->f)) {
continue;
+ }
c = loop_find_region(l, BM_ELEM_SELECT, visit_face_set, &region_out);
diff --git a/source/blender/editors/mesh/editmesh_select_similar.c b/source/blender/editors/mesh/editmesh_select_similar.c
index 3006e2ed73d..2782cc92aca 100644
--- a/source/blender/editors/mesh/editmesh_select_similar.c
+++ b/source/blender/editors/mesh/editmesh_select_similar.c
@@ -1218,12 +1218,15 @@ static int edbm_select_similar_exec(bContext *C, wmOperator *op)
ts->select_thresh = RNA_property_float_get(op->ptr, prop);
}
- if (type < 100)
+ if (type < 100) {
return similar_vert_select_exec(C, op);
- else if (type < 200)
+ }
+ else if (type < 200) {
return similar_edge_select_exec(C, op);
- else
+ }
+ else {
return similar_face_select_exec(C, op);
+ }
}
static const EnumPropertyItem *select_similar_type_itemf(bContext *C,
@@ -1233,8 +1236,9 @@ static const EnumPropertyItem *select_similar_type_itemf(bContext *C,
{
Object *obedit;
- if (!C) /* needed for docs and i18n tools */
+ if (!C) { /* needed for docs and i18n tools */
return prop_similar_types;
+ }
obedit = CTX_data_edit_object(C);
diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c
index 05466ce04bc..0a07b8cf6f6 100644
--- a/source/blender/editors/mesh/editmesh_tools.c
+++ b/source/blender/editors/mesh/editmesh_tools.c
@@ -2273,12 +2273,15 @@ static int edbm_do_smooth_vertex_exec(bContext *C, wmOperator *op)
MirrorModifierData *mmd = (MirrorModifierData *)md;
if (mmd->flag & MOD_MIR_CLIPPING) {
- if (mmd->flag & MOD_MIR_AXIS_X)
+ if (mmd->flag & MOD_MIR_AXIS_X) {
mirrx = true;
- if (mmd->flag & MOD_MIR_AXIS_Y)
+ }
+ if (mmd->flag & MOD_MIR_AXIS_Y) {
mirry = true;
- if (mmd->flag & MOD_MIR_AXIS_Z)
+ }
+ if (mmd->flag & MOD_MIR_AXIS_Z) {
mirrz = true;
+ }
clip_dist = mmd->tolerance;
}
@@ -2498,8 +2501,9 @@ static void mesh_set_smooth_faces(BMEditMesh *em, short smooth)
BMIter iter;
BMFace *efa;
- if (em == NULL)
+ if (em == NULL) {
return;
+ }
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
if (BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
@@ -2837,31 +2841,37 @@ static bool merge_firstlast(BMEditMesh *em,
/* do sanity check in mergemenu in edit.c ?*/
if (use_first == false) {
- if (!em->bm->selected.last || ((BMEditSelection *)em->bm->selected.last)->htype != BM_VERT)
+ if (!em->bm->selected.last || ((BMEditSelection *)em->bm->selected.last)->htype != BM_VERT) {
return false;
+ }
ese = em->bm->selected.last;
mergevert = (BMVert *)ese->ele;
}
else {
- if (!em->bm->selected.first || ((BMEditSelection *)em->bm->selected.first)->htype != BM_VERT)
+ if (!em->bm->selected.first || ((BMEditSelection *)em->bm->selected.first)->htype != BM_VERT) {
return false;
+ }
ese = em->bm->selected.first;
mergevert = (BMVert *)ese->ele;
}
- if (!BM_elem_flag_test(mergevert, BM_ELEM_SELECT))
+ if (!BM_elem_flag_test(mergevert, BM_ELEM_SELECT)) {
return false;
+ }
if (use_uvmerge) {
if (!EDBM_op_callf(
- em, wmop, "pointmerge_facedata verts=%hv vert_snap=%e", BM_ELEM_SELECT, mergevert))
+ em, wmop, "pointmerge_facedata verts=%hv vert_snap=%e", BM_ELEM_SELECT, mergevert)) {
return false;
+ }
}
- if (!EDBM_op_callf(em, wmop, "pointmerge verts=%hv merge_co=%v", BM_ELEM_SELECT, mergevert->co))
+ if (!EDBM_op_callf(
+ em, wmop, "pointmerge verts=%hv merge_co=%v", BM_ELEM_SELECT, mergevert->co)) {
return false;
+ }
return true;
}
@@ -2888,14 +2898,16 @@ static bool merge_target(BMEditMesh *em,
float fac;
int i = 0;
BM_ITER_MESH (v, &iter, em->bm, BM_VERTS_OF_MESH) {
- if (!BM_elem_flag_test(v, BM_ELEM_SELECT))
+ if (!BM_elem_flag_test(v, BM_ELEM_SELECT)) {
continue;
+ }
add_v3_v3(cent, v->co);
i++;
}
- if (!i)
+ if (!i) {
return false;
+ }
fac = 1.0f / (float)i;
mul_v3_fl(cent, fac);
@@ -2903,16 +2915,19 @@ static bool merge_target(BMEditMesh *em,
vco = co;
}
- if (!vco)
+ if (!vco) {
return false;
+ }
if (use_uvmerge) {
- if (!EDBM_op_callf(em, wmop, "average_vert_facedata verts=%hv", BM_ELEM_SELECT))
+ if (!EDBM_op_callf(em, wmop, "average_vert_facedata verts=%hv", BM_ELEM_SELECT)) {
return false;
+ }
}
- if (!EDBM_op_callf(em, wmop, "pointmerge verts=%hv merge_co=%v", BM_ELEM_SELECT, co))
+ if (!EDBM_op_callf(em, wmop, "pointmerge verts=%hv merge_co=%v", BM_ELEM_SELECT, co)) {
return false;
+ }
return true;
}
@@ -2996,8 +3011,9 @@ static const EnumPropertyItem *merge_type_itemf(bContext *C,
EnumPropertyItem *item = NULL;
int totitem = 0;
- if (!C) /* needed for docs */
+ if (!C) { /* needed for docs */
return merge_type_items;
+ }
obedit = CTX_data_edit_object(C);
if (obedit && obedit->type == OB_MESH) {
@@ -3094,12 +3110,15 @@ static int edbm_remove_doubles_exec(bContext *C, wmOperator *op)
/* avoid losing selection state (select -> tags) */
char htype_select;
- if (em->selectmode & SCE_SELECT_VERTEX)
+ if (em->selectmode & SCE_SELECT_VERTEX) {
htype_select = BM_VERT;
- else if (em->selectmode & SCE_SELECT_EDGE)
+ }
+ else if (em->selectmode & SCE_SELECT_EDGE) {
htype_select = BM_EDGE;
- else
+ }
+ else {
htype_select = BM_FACE;
+ }
/* store selection as tags */
BM_mesh_elem_hflag_enable_test(em->bm, htype_select, BM_ELEM_TAG, true, true, BM_ELEM_SELECT);
@@ -3332,8 +3351,9 @@ static int edbm_blend_from_shape_exec(bContext *C, wmOperator *op)
if (kb) {
/* Perform blending on selected vertices. */
BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) {
- if (!BM_elem_flag_test(eve, BM_ELEM_SELECT) || BM_elem_flag_test(eve, BM_ELEM_HIDDEN))
+ if (!BM_elem_flag_test(eve, BM_ELEM_SELECT) || BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) {
continue;
+ }
/* Get coordinates of shapekey we're blending from. */
sco = CustomData_bmesh_get_n(&em->bm->vdata, eve->head.data, CD_SHAPEKEY, shape);
@@ -3383,8 +3403,9 @@ static const EnumPropertyItem *shape_itemf(bContext *C,
int a;
for (a = 0; a < em->bm->vdata.totlayer; a++) {
- if (em->bm->vdata.layers[a].type != CD_SHAPEKEY)
+ if (em->bm->vdata.layers[a].type != CD_SHAPEKEY) {
continue;
+ }
tmp.value = totitem;
tmp.identifier = em->bm->vdata.layers[a].name;
@@ -3619,11 +3640,13 @@ static float bm_edge_seg_isect(const float sco_a[2],
/* sqrt(m2 * m2 + 1); Only looking for change in sign. Skip extra math .*/
dist = (y12 - m2 * x12 - b2);
}
- else
+ else {
dist = x22 - x12;
+ }
- if (i == 0)
+ if (i == 0) {
lastdist = dist;
+ }
/* if dist changes sign, and intersect point in edge's Bound Box */
if ((lastdist * dist) <= 0) {
@@ -3684,10 +3707,12 @@ static float bm_edge_seg_isect(const float sco_a[2],
}
}
}
- if ((m2 <= 1.0f) && (m2 >= -1.0f))
+ if ((m2 <= 1.0f) && (m2 >= -1.0f)) {
perc = (xi - x21) / (x22 - x21);
- else
+ }
+ else {
perc = (yi - y21) / (y22 - y21); /* lower slope more accurate */
+ }
//isect = 32768.0 * (perc + 0.0000153); /* Percentage in 1 / 32768ths */
break;
@@ -3720,8 +3745,9 @@ static int edbm_knife_cut_exec(bContext *C, wmOperator *op)
float(*screen_vert_coords)[2], (*sco)[2], (*mouse_path)[2];
/* edit-object needed for matrix, and ar->regiondata for projections to work */
- if (ELEM(NULL, obedit, ar, ar->regiondata))
+ if (ELEM(NULL, obedit, ar, ar->regiondata)) {
return OPERATOR_CANCELLED;
+ }
if (bm->totvertsel < 2) {
BKE_report(op->reports, RPT_ERROR, "No edges are selected to operate on");
@@ -3797,8 +3823,9 @@ static int edbm_knife_cut_exec(bContext *C, wmOperator *op)
BMO_slot_buffer_from_enabled_flag(bm, &bmop, bmop.slots_in, "edges", BM_EDGE, ELE_EDGE_CUT);
- if (mode == KNIFE_MIDPOINT)
+ if (mode == KNIFE_MIDPOINT) {
numcuts = 1;
+ }
BMO_slot_int_set(bmop.slots_in, "cuts", numcuts);
BMO_slot_int_set(bmop.slots_in, "quad_corner_type", SUBD_CORNER_STRAIGHT_CUT);
@@ -5965,15 +5992,19 @@ static void sort_bmelem_flag(bContext *C,
int affected[3] = {0, 0, 0};
int i, j;
- if (!(types && flag && action))
+ if (!(types && flag && action)) {
return;
+ }
- if (types & BM_VERT)
+ if (types & BM_VERT) {
totelem[0] = em->bm->totvert;
- if (types & BM_EDGE)
+ }
+ if (types & BM_EDGE) {
totelem[1] = em->bm->totedge;
- if (types & BM_FACE)
+ }
+ if (types & BM_FACE) {
totelem[2] = em->bm->totface;
+ }
if (ELEM(action, SRT_VIEW_ZAXIS, SRT_VIEW_XAXIS)) {
float mat[4][4];
@@ -6185,8 +6216,9 @@ static void sort_bmelem_flag(bContext *C,
int aff = affected[j];
tb = tbuf[j];
mp = map[j];
- if (!(tb && mp))
+ if (!(tb && mp)) {
continue;
+ }
if (ELEM(aff, 0, tot)) {
MEM_freeN(tb);
MEM_freeN(mp);
@@ -6327,12 +6359,15 @@ static void sort_bmelem_flag(bContext *C,
/* printf("%d faces: %d to be affected...\n", totelem[2], affected[2]);*/
if (affected[0] == 0 && affected[1] == 0 && affected[2] == 0) {
for (j = 3; j--;) {
- if (pblock[j])
+ if (pblock[j]) {
MEM_freeN(pblock[j]);
- if (sblock[j])
+ }
+ if (sblock[j]) {
MEM_freeN(sblock[j]);
- if (map[j])
+ }
+ if (map[j]) {
MEM_freeN(map[j]);
+ }
}
return;
}
@@ -6362,10 +6397,12 @@ static void sort_bmelem_flag(bContext *C,
}
}
}
- if (pb)
+ if (pb) {
MEM_freeN(pb);
- if (sb)
+ }
+ if (sb) {
MEM_freeN(sb);
+ }
}
BM_mesh_remap(em->bm, map[0], map[1], map[2]);
@@ -6373,8 +6410,9 @@ static void sort_bmelem_flag(bContext *C,
WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);
for (j = 3; j--;) {
- if (map[j])
+ if (map[j]) {
MEM_freeN(map[j]);
+ }
}
}
@@ -6406,12 +6444,15 @@ static int edbm_sort_elements_exec(bContext *C, wmOperator *op)
}
else {
BMEditMesh *em = BKE_editmesh_from_object(ob_active);
- if (em->selectmode & SCE_SELECT_VERTEX)
+ if (em->selectmode & SCE_SELECT_VERTEX) {
elem_types |= BM_VERT;
- if (em->selectmode & SCE_SELECT_EDGE)
+ }
+ if (em->selectmode & SCE_SELECT_EDGE) {
elem_types |= BM_EDGE;
- if (em->selectmode & SCE_SELECT_FACE)
+ }
+ if (em->selectmode & SCE_SELECT_FACE) {
elem_types |= BM_FACE;
+ }
RNA_enum_set(op->ptr, "elements", elem_types);
}
@@ -6453,18 +6494,22 @@ static bool edbm_sort_elements_poll_property(const bContext *UNUSED(C),
/* Only show seed for randomize action! */
if (STREQ(prop_id, "seed")) {
- if (action == SRT_RANDOMIZE)
+ if (action == SRT_RANDOMIZE) {
return true;
- else
+ }
+ else {
return false;
+ }
}
/* Hide seed for reverse and randomize actions! */
if (STREQ(prop_id, "reverse")) {
- if (ELEM(action, SRT_RANDOMIZE, SRT_REVERSE))
+ if (ELEM(action, SRT_RANDOMIZE, SRT_REVERSE)) {
return false;
- else
+ }
+ else {
return true;
+ }
}
return true;
@@ -7601,8 +7646,9 @@ wmKeyMap *point_normals_modal_keymap(wmKeyConfig *keyconf)
wmKeyMap *keymap = WM_modalkeymap_get(keyconf, keymap_name);
/* We only need to add map once */
- if (keymap && keymap->modal_items)
+ if (keymap && keymap->modal_items) {
return NULL;
+ }
keymap = WM_modalkeymap_add(keyconf, keymap_name, modal_items);
diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c
index f3055b5c75e..d7ed14184fa 100644
--- a/source/blender/editors/mesh/editmesh_utils.c
+++ b/source/blender/editors/mesh/editmesh_utils.c
@@ -626,10 +626,12 @@ UvVertMap *BM_uv_vert_map_create(BMesh *bm,
if (fabsf(uvdiff[0]) < limit[0] && fabsf(uvdiff[1]) < limit[1] &&
(!use_winding || winding[iterv->poly_index] == winding[v->poly_index])) {
- if (lastv)
+ if (lastv) {
lastv->next = next;
- else
+ }
+ else {
vlist = next;
+ }
iterv->next = newvlist;
newvlist = iterv;
}
@@ -776,10 +778,12 @@ UvElementMap *BM_uv_element_map_create(BMesh *bm,
if (fabsf(uvdiff[0]) < STD_UV_CONNECT_LIMIT && fabsf(uvdiff[1]) < STD_UV_CONNECT_LIMIT &&
(!use_winding ||
winding[BM_elem_index_get(iterv->l->f)] == winding[BM_elem_index_get(v->l->f)])) {
- if (lastv)
+ if (lastv) {
lastv->next = next;
- else
+ }
+ else {
vlist = next;
+ }
iterv->next = newvlist;
newvlist = iterv;
}
@@ -833,8 +837,9 @@ UvElementMap *BM_uv_element_map_create(BMesh *bm,
UvElement *element, *initelement = element_map->vert[BM_elem_index_get(l->v)];
for (element = initelement; element; element = element->next) {
- if (element->separate)
+ if (element->separate) {
initelement = element;
+ }
if (element->l->f == efa) {
/* found the uv corresponding to our face and vertex.
@@ -848,8 +853,9 @@ UvElementMap *BM_uv_element_map_create(BMesh *bm,
islandbufsize++;
for (element = initelement; element; element = element->next) {
- if (element->separate && element != initelement)
+ if (element->separate && element != initelement) {
break;
+ }
if (island_number[BM_elem_index_get(element->l->f)] == INVALID_ISLAND) {
stack[stacksize++] = element->l->f;
@@ -871,8 +877,9 @@ UvElementMap *BM_uv_element_map_create(BMesh *bm,
/* remap */
for (i = 0; i < bm->totvert; i++) {
/* important since we may do selection only. Some of these may be NULL */
- if (element_map->vert[i])
+ if (element_map->vert[i]) {
element_map->vert[i] = &islandbuf[map[element_map->vert[i] - element_map->buf]];
+ }
}
element_map->islandIndices = MEM_callocN(sizeof(*element_map->islandIndices) * nislands,
@@ -880,10 +887,12 @@ UvElementMap *BM_uv_element_map_create(BMesh *bm,
j = 0;
for (i = 0; i < totuv; i++) {
UvElement *element = element_map->buf[i].next;
- if (element == NULL)
+ if (element == NULL) {
islandbuf[map[i]].next = NULL;
- else
+ }
+ else {
islandbuf[map[i]].next = &islandbuf[map[element - element_map->buf]];
+ }
if (islandbuf[i].island != j) {
j++;
@@ -907,10 +916,12 @@ UvElementMap *BM_uv_element_map_create(BMesh *bm,
void BM_uv_vert_map_free(UvVertMap *vmap)
{
if (vmap) {
- if (vmap->vert)
+ if (vmap->vert) {
MEM_freeN(vmap->vert);
- if (vmap->buf)
+ }
+ if (vmap->buf) {
MEM_freeN(vmap->buf);
+ }
MEM_freeN(vmap);
}
}
@@ -918,12 +929,15 @@ void BM_uv_vert_map_free(UvVertMap *vmap)
void BM_uv_element_map_free(UvElementMap *element_map)
{
if (element_map) {
- if (element_map->vert)
+ if (element_map->vert) {
MEM_freeN(element_map->vert);
- if (element_map->buf)
+ }
+ if (element_map->buf) {
MEM_freeN(element_map->buf);
- if (element_map->islandIndices)
+ }
+ if (element_map->islandIndices) {
MEM_freeN(element_map->islandIndices);
+ }
MEM_freeN(element_map);
}
}
@@ -1243,12 +1257,15 @@ bool EDBM_mesh_hide(BMEditMesh *em, bool swap)
char hflag_swap = swap ? BM_ELEM_SELECT : 0;
bool changed = true;
- if (em->selectmode & SCE_SELECT_VERTEX)
+ if (em->selectmode & SCE_SELECT_VERTEX) {
itermode = BM_VERTS_OF_MESH;
- else if (em->selectmode & SCE_SELECT_EDGE)
+ }
+ else if (em->selectmode & SCE_SELECT_EDGE) {
itermode = BM_EDGES_OF_MESH;
- else
+ }
+ else {
itermode = BM_FACES_OF_MESH;
+ }
BM_ITER_MESH (ele, &iter, em->bm, itermode) {
if (!BM_elem_flag_test(ele, BM_ELEM_HIDDEN)) {
diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c
index fccecf993e8..385b3c69422 100644
--- a/source/blender/editors/mesh/mesh_data.c
+++ b/source/blender/editors/mesh/mesh_data.c
@@ -217,8 +217,9 @@ void ED_mesh_uv_loop_reset_ex(struct Mesh *me, const int layernum)
BLI_assert(cd_loop_uv_offset != -1);
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!BM_elem_flag_test(efa, BM_ELEM_SELECT))
+ if (!BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
continue;
+ }
mesh_uv_reset_bmface(efa, cd_loop_uv_offset);
}
@@ -261,8 +262,9 @@ int ED_mesh_uv_texture_add(Mesh *me, const char *name, const bool active_set, co
em = me->edit_mesh;
layernum_dst = CustomData_number_of_layers(&em->bm->ldata, CD_MLOOPUV);
- if (layernum_dst >= MAX_MTFACE)
+ if (layernum_dst >= MAX_MTFACE) {
return -1;
+ }
/* CD_MLOOPUV */
BM_data_layer_add_named(em->bm, &em->bm->ldata, CD_MLOOPUV, name);
@@ -279,8 +281,9 @@ int ED_mesh_uv_texture_add(Mesh *me, const char *name, const bool active_set, co
}
else {
layernum_dst = CustomData_number_of_layers(&me->ldata, CD_MLOOPUV);
- if (layernum_dst >= MAX_MTFACE)
+ if (layernum_dst >= MAX_MTFACE) {
return -1;
+ }
if (me->mloopuv && do_init) {
CustomData_add_layer_named(
@@ -322,13 +325,15 @@ void ED_mesh_uv_texture_ensure(struct Mesh *me, const char *name)
em = me->edit_mesh;
layernum_dst = CustomData_number_of_layers(&em->bm->ldata, CD_MLOOPUV);
- if (layernum_dst == 0)
+ if (layernum_dst == 0) {
ED_mesh_uv_texture_add(me, name, true, true);
+ }
}
else {
layernum_dst = CustomData_number_of_layers(&me->ldata, CD_MLOOPUV);
- if (layernum_dst == 0)
+ if (layernum_dst == 0) {
ED_mesh_uv_texture_add(me, name, true, true);
+ }
}
}
@@ -341,8 +346,9 @@ bool ED_mesh_uv_texture_remove_index(Mesh *me, const int n)
index = CustomData_get_layer_index_n(ldata, CD_MLOOPUV, n);
cdlu = (index == -1) ? NULL : &ldata->layers[index];
- if (!cdlu)
+ if (!cdlu) {
return false;
+ }
delete_customdata_layer(me, cdlu);
@@ -455,8 +461,9 @@ bool ED_mesh_color_remove_index(Mesh *me, const int n)
index = CustomData_get_layer_index_n(ldata, CD_MLOOPCOL, n);
cdl = (index == -1) ? NULL : &ldata->layers[index];
- if (!cdl)
+ if (!cdl) {
return false;
+ }
delete_customdata_layer(me, cdl);
DEG_id_tag_update(&me->id, 0);
@@ -501,8 +508,9 @@ static int mesh_uv_texture_add_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob = ED_object_context(C);
Mesh *me = ob->data;
- if (ED_mesh_uv_texture_add(me, NULL, true, true) == -1)
+ if (ED_mesh_uv_texture_add(me, NULL, true, true) == -1) {
return OPERATOR_CANCELLED;
+ }
if (ob->mode & OB_MODE_TEXTURE_PAINT) {
Scene *scene = CTX_data_scene(C);
@@ -533,8 +541,9 @@ static int mesh_uv_texture_remove_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob = ED_object_context(C);
Mesh *me = ob->data;
- if (!ED_mesh_uv_texture_remove_active(me))
+ if (!ED_mesh_uv_texture_remove_active(me)) {
return OPERATOR_CANCELLED;
+ }
if (ob->mode & OB_MODE_TEXTURE_PAINT) {
Scene *scene = CTX_data_scene(C);
@@ -567,8 +576,9 @@ static int mesh_vertex_color_add_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob = ED_object_context(C);
Mesh *me = ob->data;
- if (ED_mesh_color_add(me, NULL, true, true) == -1)
+ if (ED_mesh_color_add(me, NULL, true, true) == -1) {
return OPERATOR_CANCELLED;
+ }
return OPERATOR_FINISHED;
}
@@ -593,8 +603,9 @@ static int mesh_vertex_color_remove_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob = ED_object_context(C);
Mesh *me = ob->data;
- if (!ED_mesh_color_remove_active(me))
+ if (!ED_mesh_color_remove_active(me)) {
return OPERATOR_CANCELLED;
+ }
return OPERATOR_FINISHED;
}
@@ -892,8 +903,9 @@ void ED_mesh_update(
BKE_mesh_calc_edges_loose(mesh);
}
- if (calc_edges || ((mesh->totpoly || mesh->totface) && mesh->totedge == 0))
+ if (calc_edges || ((mesh->totpoly || mesh->totface) && mesh->totedge == 0)) {
BKE_mesh_calc_edges(mesh, calc_edges, true);
+ }
if (calc_tessface) {
if (tessface_input == false) {
@@ -917,15 +929,17 @@ static void mesh_add_verts(Mesh *mesh, int len)
MVert *mvert;
int i, totvert;
- if (len == 0)
+ if (len == 0) {
return;
+ }
totvert = mesh->totvert + len;
CustomData_copy(&mesh->vdata, &vdata, CD_MASK_MESH.vmask, CD_DEFAULT, totvert);
CustomData_copy_data(&mesh->vdata, &vdata, 0, 0, mesh->totvert);
- if (!CustomData_has_layer(&vdata, CD_MVERT))
+ if (!CustomData_has_layer(&vdata, CD_MVERT)) {
CustomData_add_layer(&vdata, CD_MVERT, CD_CALLOC, NULL, totvert);
+ }
CustomData_free(&mesh->vdata, mesh->totvert);
mesh->vdata = vdata;
@@ -935,8 +949,9 @@ static void mesh_add_verts(Mesh *mesh, int len)
/* set default flags */
mvert = &mesh->mvert[mesh->totvert];
- for (i = 0; i < len; i++, mvert++)
+ for (i = 0; i < len; i++, mvert++) {
mvert->flag |= SELECT;
+ }
/* set final vertex list size */
mesh->totvert = totvert;
@@ -948,8 +963,9 @@ static void mesh_add_edges(Mesh *mesh, int len)
MEdge *medge;
int i, totedge;
- if (len == 0)
+ if (len == 0) {
return;
+ }
totedge = mesh->totedge + len;
@@ -957,8 +973,9 @@ static void mesh_add_edges(Mesh *mesh, int len)
CustomData_copy(&mesh->edata, &edata, CD_MASK_MESH.emask, CD_DEFAULT, totedge);
CustomData_copy_data(&mesh->edata, &edata, 0, 0, mesh->totedge);
- if (!CustomData_has_layer(&edata, CD_MEDGE))
+ if (!CustomData_has_layer(&edata, CD_MEDGE)) {
CustomData_add_layer(&edata, CD_MEDGE, CD_CALLOC, NULL, totedge);
+ }
CustomData_free(&mesh->edata, mesh->totedge);
mesh->edata = edata;
@@ -966,8 +983,9 @@ static void mesh_add_edges(Mesh *mesh, int len)
/* set default flags */
medge = &mesh->medge[mesh->totedge];
- for (i = 0; i < len; i++, medge++)
+ for (i = 0; i < len; i++, medge++) {
medge->flag = ME_EDGEDRAW | ME_EDGERENDER | SELECT;
+ }
mesh->totedge = totedge;
}
@@ -978,8 +996,9 @@ static void mesh_add_tessfaces(Mesh *mesh, int len)
MFace *mface;
int i, totface;
- if (len == 0)
+ if (len == 0) {
return;
+ }
totface = mesh->totface + len; /* new face count */
@@ -987,8 +1006,9 @@ static void mesh_add_tessfaces(Mesh *mesh, int len)
CustomData_copy(&mesh->fdata, &fdata, CD_MASK_MESH.fmask, CD_DEFAULT, totface);
CustomData_copy_data(&mesh->fdata, &fdata, 0, 0, mesh->totface);
- if (!CustomData_has_layer(&fdata, CD_MFACE))
+ if (!CustomData_has_layer(&fdata, CD_MFACE)) {
CustomData_add_layer(&fdata, CD_MFACE, CD_CALLOC, NULL, totface);
+ }
CustomData_free(&mesh->fdata, mesh->totface);
mesh->fdata = fdata;
@@ -996,8 +1016,9 @@ static void mesh_add_tessfaces(Mesh *mesh, int len)
/* set default flags */
mface = &mesh->mface[mesh->totface];
- for (i = 0; i < len; i++, mface++)
+ for (i = 0; i < len; i++, mface++) {
mface->flag = ME_FACE_SEL;
+ }
mesh->totface = totface;
}
@@ -1007,8 +1028,9 @@ static void mesh_add_loops(Mesh *mesh, int len)
CustomData ldata;
int totloop;
- if (len == 0)
+ if (len == 0) {
return;
+ }
totloop = mesh->totloop + len; /* new face count */
@@ -1016,8 +1038,9 @@ static void mesh_add_loops(Mesh *mesh, int len)
CustomData_copy(&mesh->ldata, &ldata, CD_MASK_MESH.lmask, CD_DEFAULT, totloop);
CustomData_copy_data(&mesh->ldata, &ldata, 0, 0, mesh->totloop);
- if (!CustomData_has_layer(&ldata, CD_MLOOP))
+ if (!CustomData_has_layer(&ldata, CD_MLOOP)) {
CustomData_add_layer(&ldata, CD_MLOOP, CD_CALLOC, NULL, totloop);
+ }
CustomData_free(&mesh->ldata, mesh->totloop);
mesh->ldata = ldata;
@@ -1032,8 +1055,9 @@ static void mesh_add_polys(Mesh *mesh, int len)
MPoly *mpoly;
int i, totpoly;
- if (len == 0)
+ if (len == 0) {
return;
+ }
totpoly = mesh->totpoly + len; /* new face count */
@@ -1041,8 +1065,9 @@ static void mesh_add_polys(Mesh *mesh, int len)
CustomData_copy(&mesh->pdata, &pdata, CD_MASK_MESH.pmask, CD_DEFAULT, totpoly);
CustomData_copy_data(&mesh->pdata, &pdata, 0, 0, mesh->totpoly);
- if (!CustomData_has_layer(&pdata, CD_MPOLY))
+ if (!CustomData_has_layer(&pdata, CD_MPOLY)) {
CustomData_add_layer(&pdata, CD_MPOLY, CD_CALLOC, NULL, totpoly);
+ }
CustomData_free(&mesh->pdata, mesh->totpoly);
mesh->pdata = pdata;
@@ -1050,8 +1075,9 @@ static void mesh_add_polys(Mesh *mesh, int len)
/* set default flags */
mpoly = &mesh->mpoly[mesh->totpoly];
- for (i = 0; i < len; i++, mpoly++)
+ for (i = 0; i < len; i++, mpoly++) {
mpoly->flag = ME_FACE_SEL;
+ }
mesh->totpoly = totpoly;
}
@@ -1060,8 +1086,9 @@ static void mesh_remove_verts(Mesh *mesh, int len)
{
int totvert;
- if (len == 0)
+ if (len == 0) {
return;
+ }
totvert = mesh->totvert - len;
CustomData_free_elem(&mesh->vdata, totvert, len);
@@ -1074,8 +1101,9 @@ static void mesh_remove_edges(Mesh *mesh, int len)
{
int totedge;
- if (len == 0)
+ if (len == 0) {
return;
+ }
totedge = mesh->totedge - len;
CustomData_free_elem(&mesh->edata, totedge, len);
@@ -1087,8 +1115,9 @@ static void mesh_remove_faces(Mesh *mesh, int len)
{
int totface;
- if (len == 0)
+ if (len == 0) {
return;
+ }
totface = mesh->totface - len; /* new face count */
CustomData_free_elem(&mesh->fdata, totface, len);
diff --git a/source/blender/editors/mesh/mesh_mirror.c b/source/blender/editors/mesh/mesh_mirror.c
index 7d0ee19b5ea..eec0c4a57fa 100644
--- a/source/blender/editors/mesh/mesh_mirror.c
+++ b/source/blender/editors/mesh/mesh_mirror.c
@@ -50,8 +50,9 @@ int ED_mesh_mirror_spatial_table(
Object *ob, BMEditMesh *em, Mesh *me_eval, const float co[3], char mode)
{
if (mode == 'u') { /* use table */
- if (MirrKdStore.tree == NULL)
+ if (MirrKdStore.tree == NULL) {
ED_mesh_mirror_spatial_table(ob, em, me_eval, NULL, 's');
+ }
if (MirrKdStore.tree) {
KDTreeNearest_3d nearest;
@@ -70,8 +71,9 @@ int ED_mesh_mirror_spatial_table(
const bool use_em = (!me_eval && em && me->edit_mesh == em);
const int totvert = use_em ? em->bm->totvert : me_eval ? me_eval->totvert : me->totvert;
- if (MirrKdStore.tree) /* happens when entering this call without ending it */
+ if (MirrKdStore.tree) { /* happens when entering this call without ending it */
ED_mesh_mirror_spatial_table(ob, em, me_eval, co, 'e');
+ }
MirrKdStore.tree = BLI_kdtree_3d_new(totvert);
@@ -126,19 +128,23 @@ typedef struct MirrTopoVert_t {
static int mirrtopo_hash_sort(const void *l1, const void *l2)
{
- if ((MirrTopoHash_t)(intptr_t)l1 > (MirrTopoHash_t)(intptr_t)l2)
+ if ((MirrTopoHash_t)(intptr_t)l1 > (MirrTopoHash_t)(intptr_t)l2) {
return 1;
- else if ((MirrTopoHash_t)(intptr_t)l1 < (MirrTopoHash_t)(intptr_t)l2)
+ }
+ else if ((MirrTopoHash_t)(intptr_t)l1 < (MirrTopoHash_t)(intptr_t)l2) {
return -1;
+ }
return 0;
}
static int mirrtopo_vert_sort(const void *v1, const void *v2)
{
- if (((MirrTopoVert_t *)v1)->hash > ((MirrTopoVert_t *)v2)->hash)
+ if (((MirrTopoVert_t *)v1)->hash > ((MirrTopoVert_t *)v2)->hash) {
return 1;
- else if (((MirrTopoVert_t *)v1)->hash < ((MirrTopoVert_t *)v2)->hash)
+ }
+ else if (((MirrTopoVert_t *)v1)->hash < ((MirrTopoVert_t *)v2)->hash) {
return -1;
+ }
return 0;
}
diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c
index 9c799550608..c32fef42d27 100644
--- a/source/blender/editors/mesh/meshtools.c
+++ b/source/blender/editors/mesh/meshtools.c
@@ -323,12 +323,14 @@ int join_mesh_exec(bContext *C, wmOperator *op)
totpoly += me->totpoly;
totmat += ob_iter->totcol;
- if (ob_iter == ob)
+ if (ob_iter == ob) {
ok = true;
+ }
/* check for shapekeys */
- if (me->key)
+ if (me->key) {
haskey++;
+ }
}
}
CTX_DATA_END;
@@ -386,8 +388,9 @@ int join_mesh_exec(bContext *C, wmOperator *op)
/* for all keys in old block, clear data-arrays */
for (kb = key->block.first; kb; kb = kb->next) {
- if (kb->data)
+ if (kb->data) {
MEM_freeN(kb->data);
+ }
kb->data = MEM_callocN(sizeof(float) * 3 * totvert, "join_shapekey");
kb->totelem = totvert;
}
@@ -413,8 +416,9 @@ int join_mesh_exec(bContext *C, wmOperator *op)
BLI_addtail(&ob->defbase, odg);
}
}
- if (ob->defbase.first && ob->actdef == 0)
+ if (ob->defbase.first && ob->actdef == 0) {
ob->actdef = 1;
+ }
if (me->totvert) {
/* Add this object's materials to the base one's if they don't exist already
@@ -609,13 +613,15 @@ int join_mesh_exec(bContext *C, wmOperator *op)
/* old material array */
for (a = 1; a <= ob->totcol; a++) {
ma = ob->mat[a - 1];
- if (ma)
+ if (ma) {
id_us_min(&ma->id);
+ }
}
for (a = 1; a <= me->totcol; a++) {
ma = me->mat[a - 1];
- if (ma)
+ if (ma) {
id_us_min(&ma->id);
+ }
}
MEM_SAFE_FREE(ob->mat);
MEM_SAFE_FREE(ob->matbits);
@@ -683,21 +689,25 @@ int join_mesh_shapes_exec(bContext *C, wmOperator *op)
if (ob_iter->type == OB_MESH) {
selme = (Mesh *)ob_iter->data;
- if (selme->totvert == me->totvert)
+ if (selme->totvert == me->totvert) {
ok = true;
- else
+ }
+ else {
nonequal_verts = 1;
+ }
}
}
CTX_DATA_END;
if (!ok) {
- if (nonequal_verts)
+ if (nonequal_verts) {
BKE_report(op->reports, RPT_WARNING, "Selected meshes must have equal numbers of vertices");
- else
+ }
+ else {
BKE_report(op->reports,
RPT_WARNING,
"No additional selected meshes with equal vertex count to join");
+ }
return OPERATOR_CANCELLED;
}
@@ -793,8 +803,9 @@ static int mesh_get_x_mirror_vert_spatial(Object *ob, Mesh *mesh, int index)
static int mesh_get_x_mirror_vert_topo(Object *ob, Mesh *mesh, int index)
{
- if (ED_mesh_mirror_topo_table(ob, mesh, 'u') == -1)
+ if (ED_mesh_mirror_topo_table(ob, mesh, 'u') == -1) {
return -1;
+ }
return mesh_topo_store.index_lookup[index];
}
@@ -836,8 +847,9 @@ static BMVert *editbmesh_get_x_mirror_vert_topo(Object *ob,
int index)
{
intptr_t poinval;
- if (ED_mesh_mirror_topo_table(ob, NULL, 'u') == -1)
+ if (ED_mesh_mirror_topo_table(ob, NULL, 'u') == -1) {
return NULL;
+ }
if (index == -1) {
BMIter iter;
@@ -845,8 +857,9 @@ static BMVert *editbmesh_get_x_mirror_vert_topo(Object *ob,
index = 0;
BM_ITER_MESH (v, &iter, em->bm, BM_VERTS_OF_MESH) {
- if (v == eve)
+ if (v == eve) {
break;
+ }
index++;
}
@@ -857,8 +870,9 @@ static BMVert *editbmesh_get_x_mirror_vert_topo(Object *ob,
poinval = mesh_topo_store.index_lookup[index];
- if (poinval != -1)
+ if (poinval != -1) {
return (BMVert *)(poinval);
+ }
return NULL;
}
@@ -978,22 +992,29 @@ static unsigned int mirror_facehash(const void *ptr)
static int mirror_facerotation(MFace *a, MFace *b)
{
if (b->v4) {
- if (a->v1 == b->v1 && a->v2 == b->v2 && a->v3 == b->v3 && a->v4 == b->v4)
+ if (a->v1 == b->v1 && a->v2 == b->v2 && a->v3 == b->v3 && a->v4 == b->v4) {
return 0;
- else if (a->v4 == b->v1 && a->v1 == b->v2 && a->v2 == b->v3 && a->v3 == b->v4)
+ }
+ else if (a->v4 == b->v1 && a->v1 == b->v2 && a->v2 == b->v3 && a->v3 == b->v4) {
return 1;
- else if (a->v3 == b->v1 && a->v4 == b->v2 && a->v1 == b->v3 && a->v2 == b->v4)
+ }
+ else if (a->v3 == b->v1 && a->v4 == b->v2 && a->v1 == b->v3 && a->v2 == b->v4) {
return 2;
- else if (a->v2 == b->v1 && a->v3 == b->v2 && a->v4 == b->v3 && a->v1 == b->v4)
+ }
+ else if (a->v2 == b->v1 && a->v3 == b->v2 && a->v4 == b->v3 && a->v1 == b->v4) {
return 3;
+ }
}
else {
- if (a->v1 == b->v1 && a->v2 == b->v2 && a->v3 == b->v3)
+ if (a->v1 == b->v1 && a->v2 == b->v2 && a->v3 == b->v3) {
return 0;
- else if (a->v3 == b->v1 && a->v1 == b->v2 && a->v2 == b->v3)
+ }
+ else if (a->v3 == b->v1 && a->v1 == b->v2 && a->v2 == b->v3) {
return 1;
- else if (a->v2 == b->v1 && a->v3 == b->v2 && a->v1 == b->v3)
+ }
+ else if (a->v2 == b->v1 && a->v3 == b->v2 && a->v1 == b->v3) {
return 2;
+ }
}
return -1;
@@ -1028,14 +1049,16 @@ int *mesh_get_x_mirror_faces(Object *ob, BMEditMesh *em, Mesh *me_eval)
ED_mesh_mirror_spatial_table(ob, em, me_eval, NULL, 's');
- for (a = 0, mv = mvert; a < totvert; a++, mv++)
+ for (a = 0, mv = mvert; a < totvert; a++, mv++) {
mirrorverts[a] = mesh_get_x_mirror_vert(ob, me_eval, a, use_topology);
+ }
ED_mesh_mirror_spatial_table(ob, em, me_eval, NULL, 'e');
fhash = BLI_ghash_new_ex(mirror_facehash, mirror_facecmp, "mirror_facehash gh", me->totface);
- for (a = 0, mf = mface; a < totface; a++, mf++)
+ for (a = 0, mf = mface; a < totface; a++, mf++) {
BLI_ghash_insert(fhash, mf, mf);
+ }
for (a = 0, mf = mface; a < totface; a++, mf++) {
mirrormf.v1 = mirrorverts[mf->v3];
@@ -1054,8 +1077,9 @@ int *mesh_get_x_mirror_faces(Object *ob, BMEditMesh *em, Mesh *me_eval)
mirrorfaces[a * 2] = hashmf - mface;
mirrorfaces[a * 2 + 1] = mirror_facerotation(&mirrormf, hashmf);
}
- else
+ else {
mirrorfaces[a * 2] = -1;
+ }
}
BLI_ghash_free(fhash, NULL, NULL);
@@ -1080,8 +1104,9 @@ bool ED_mesh_pick_face(bContext *C, Object *ob, const int mval[2], uint dist_px,
BLI_assert(me && GS(me->id.name) == ID_ME);
- if (!me || me->totpoly == 0)
+ if (!me || me->totpoly == 0) {
return false;
+ }
ED_view3d_viewcontext_init(C, &vc);
@@ -1261,8 +1286,9 @@ bool ED_mesh_pick_vert(
BLI_assert(me && GS(me->id.name) == ID_ME);
- if (!me || me->totvert == 0)
+ if (!me || me->totvert == 0) {
return false;
+ }
ED_view3d_viewcontext_init(C, &vc);
@@ -1336,15 +1362,17 @@ MDeformVert *ED_mesh_active_dvert_get_em(Object *ob, BMVert **r_eve)
BMVert *eve = BM_mesh_active_vert_get(bm);
if (eve) {
- if (r_eve)
+ if (r_eve) {
*r_eve = eve;
+ }
return BM_ELEM_CD_GET_VOID_P(eve, cd_dvert_offset);
}
}
}
- if (r_eve)
+ if (r_eve) {
*r_eve = NULL;
+ }
return NULL;
}
@@ -1352,8 +1380,9 @@ MDeformVert *ED_mesh_active_dvert_get_ob(Object *ob, int *r_index)
{
Mesh *me = ob->data;
int index = BKE_mesh_mselect_active_get(me, ME_VSEL);
- if (r_index)
+ if (r_index) {
*r_index = index;
+ }
if (index == -1 || me->dvert == NULL) {
return NULL;
}
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;
}
diff --git a/source/blender/editors/physics/dynamicpaint_ops.c b/source/blender/editors/physics/dynamicpaint_ops.c
index e0ea53b06ec..7178a485a6e 100644
--- a/source/blender/editors/physics/dynamicpaint_ops.c
+++ b/source/blender/editors/physics/dynamicpaint_ops.c
@@ -72,14 +72,16 @@ static int surface_slot_add_exec(bContext *C, wmOperator *UNUSED(op))
/* Make sure we're dealing with a canvas */
pmd = (DynamicPaintModifierData *)modifiers_findByType(cObject, eModifierType_DynamicPaint);
- if (!pmd || !pmd->canvas)
+ if (!pmd || !pmd->canvas) {
return OPERATOR_CANCELLED;
+ }
canvas = pmd->canvas;
surface = dynamicPaint_createNewSurface(canvas, CTX_data_scene(C));
- if (!surface)
+ if (!surface) {
return OPERATOR_CANCELLED;
+ }
/* set preview for this surface only and set active */
canvas->active_sur = 0;
@@ -117,8 +119,9 @@ static int surface_slot_remove_exec(bContext *C, wmOperator *UNUSED(op))
/* Make sure we're dealing with a canvas */
pmd = (DynamicPaintModifierData *)modifiers_findByType(obj_ctx, eModifierType_DynamicPaint);
- if (!pmd || !pmd->canvas)
+ if (!pmd || !pmd->canvas) {
return OPERATOR_CANCELLED;
+ }
canvas = pmd->canvas;
surface = canvas->surfaces.first;
@@ -165,8 +168,9 @@ static int type_toggle_exec(bContext *C, wmOperator *op)
cObject, eModifierType_DynamicPaint);
int type = RNA_enum_get(op->ptr, "type");
- if (!pmd)
+ if (!pmd) {
return OPERATOR_CANCELLED;
+ }
/* if type is already enabled, toggle it off */
if (type == MOD_DYNAMICPAINT_TYPE_CANVAS && pmd->canvas) {
@@ -177,8 +181,9 @@ static int type_toggle_exec(bContext *C, wmOperator *op)
}
/* else create a new type */
else {
- if (!dynamicPaint_createType(pmd, type, scene))
+ if (!dynamicPaint_createType(pmd, type, scene)) {
return OPERATOR_CANCELLED;
+ }
}
/* update dependency */
@@ -223,8 +228,9 @@ static int output_toggle_exec(bContext *C, wmOperator *op)
ob, eModifierType_DynamicPaint);
int output = RNA_enum_get(op->ptr, "output"); /* currently only 1/0 */
- if (!pmd || !pmd->canvas)
+ if (!pmd || !pmd->canvas) {
return OPERATOR_CANCELLED;
+ }
surface = get_activeSurface(pmd->canvas);
/* if type is already enabled, toggle it off */
@@ -232,17 +238,21 @@ static int output_toggle_exec(bContext *C, wmOperator *op)
int exists = dynamicPaint_outputLayerExists(surface, ob, output);
const char *name;
- if (output == 0)
+ if (output == 0) {
name = surface->output_name;
- else
+ }
+ else {
name = surface->output_name2;
+ }
/* Vertex Color Layer */
if (surface->type == MOD_DPAINT_SURFACE_T_PAINT) {
- if (!exists)
+ if (!exists) {
ED_mesh_color_add(ob->data, name, true, true);
- else
+ }
+ else {
ED_mesh_color_remove_named(ob->data, name);
+ }
}
/* Vertex Weight Layer */
else if (surface->type == MOD_DPAINT_SURFACE_T_WEIGHT) {
@@ -251,8 +261,9 @@ static int output_toggle_exec(bContext *C, wmOperator *op)
}
else {
bDeformGroup *defgroup = defgroup_find_name(ob, name);
- if (defgroup)
+ if (defgroup) {
BKE_object_defgroup_remove(ob, defgroup);
+ }
}
}
}
diff --git a/source/blender/editors/physics/particle_boids.c b/source/blender/editors/physics/particle_boids.c
index cedb7d6cbc1..55fc49165c9 100644
--- a/source/blender/editors/physics/particle_boids.c
+++ b/source/blender/editors/physics/particle_boids.c
@@ -57,13 +57,15 @@ static int rule_add_exec(bContext *C, wmOperator *op)
BoidRule *rule;
BoidState *state;
- if (!part || part->phystype != PART_PHYS_BOIDS)
+ if (!part || part->phystype != PART_PHYS_BOIDS) {
return OPERATOR_CANCELLED;
+ }
state = boid_get_current_state(part->boids);
- for (rule = state->rules.first; rule; rule = rule->next)
+ for (rule = state->rules.first; rule; rule = rule->next) {
rule->flag &= ~BOIDRULE_CURRENT;
+ }
rule = boid_new_rule(type);
rule->flag |= BOIDRULE_CURRENT;
@@ -99,8 +101,9 @@ static int rule_del_exec(bContext *C, wmOperator *UNUSED(op))
BoidRule *rule;
BoidState *state;
- if (!part || part->phystype != PART_PHYS_BOIDS)
+ if (!part || part->phystype != PART_PHYS_BOIDS) {
return OPERATOR_CANCELLED;
+ }
state = boid_get_current_state(part->boids);
@@ -113,8 +116,9 @@ static int rule_del_exec(bContext *C, wmOperator *UNUSED(op))
}
rule = state->rules.first;
- if (rule)
+ if (rule) {
rule->flag |= BOIDRULE_CURRENT;
+ }
DEG_relations_tag_update(bmain);
DEG_id_tag_update(&part->id, ID_RECALC_GEOMETRY | ID_RECALC_PSYS_RESET);
@@ -144,8 +148,9 @@ static int rule_move_up_exec(bContext *C, wmOperator *UNUSED(op))
BoidRule *rule;
BoidState *state;
- if (!part || part->phystype != PART_PHYS_BOIDS)
+ if (!part || part->phystype != PART_PHYS_BOIDS) {
return OPERATOR_CANCELLED;
+ }
state = boid_get_current_state(part->boids);
for (rule = state->rules.first; rule; rule = rule->next) {
@@ -180,8 +185,9 @@ static int rule_move_down_exec(bContext *C, wmOperator *UNUSED(op))
BoidRule *rule;
BoidState *state;
- if (!part || part->phystype != PART_PHYS_BOIDS)
+ if (!part || part->phystype != PART_PHYS_BOIDS) {
return OPERATOR_CANCELLED;
+ }
state = boid_get_current_state(part->boids);
for (rule = state->rules.first; rule; rule = rule->next) {
@@ -216,11 +222,13 @@ static int state_add_exec(bContext *C, wmOperator *UNUSED(op))
ParticleSettings *part = ptr.data;
BoidState *state;
- if (!part || part->phystype != PART_PHYS_BOIDS)
+ if (!part || part->phystype != PART_PHYS_BOIDS) {
return OPERATOR_CANCELLED;
+ }
- for (state = part->boids->states.first; state; state = state->next)
+ for (state = part->boids->states.first; state; state = state->next) {
state->flag &= ~BOIDSTATE_CURRENT;
+ }
state = boid_new_state(part->boids);
state->flag |= BOIDSTATE_CURRENT;
@@ -250,8 +258,9 @@ static int state_del_exec(bContext *C, wmOperator *UNUSED(op))
ParticleSettings *part = ptr.data;
BoidState *state;
- if (!part || part->phystype != PART_PHYS_BOIDS)
+ if (!part || part->phystype != PART_PHYS_BOIDS) {
return OPERATOR_CANCELLED;
+ }
for (state = part->boids->states.first; state; state = state->next) {
if (state->flag & BOIDSTATE_CURRENT) {
@@ -266,8 +275,9 @@ static int state_del_exec(bContext *C, wmOperator *UNUSED(op))
state = boid_new_state(part->boids);
BLI_addtail(&part->boids->states, state);
}
- else
+ else {
state = part->boids->states.first;
+ }
state->flag |= BOIDSTATE_CURRENT;
@@ -299,8 +309,9 @@ static int state_move_up_exec(bContext *C, wmOperator *UNUSED(op))
BoidSettings *boids;
BoidState *state;
- if (!part || part->phystype != PART_PHYS_BOIDS)
+ if (!part || part->phystype != PART_PHYS_BOIDS) {
return OPERATOR_CANCELLED;
+ }
boids = part->boids;
@@ -334,8 +345,9 @@ static int state_move_down_exec(bContext *C, wmOperator *UNUSED(op))
BoidSettings *boids;
BoidState *state;
- if (!part || part->phystype != PART_PHYS_BOIDS)
+ if (!part || part->phystype != PART_PHYS_BOIDS) {
return OPERATOR_CANCELLED;
+ }
boids = part->boids;
diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c
index 68bbda51482..9921ca02af9 100644
--- a/source/blender/editors/physics/particle_edit.c
+++ b/source/blender/editors/physics/particle_edit.c
@@ -129,21 +129,24 @@ void PE_free_ptcache_edit(PTCacheEdit *edit)
{
POINT_P;
- if (edit == 0)
+ if (edit == 0) {
return;
+ }
if (edit->points) {
LOOP_POINTS
{
- if (point->keys)
+ if (point->keys) {
MEM_freeN(point->keys);
+ }
}
MEM_freeN(edit->points);
}
- if (edit->mirror_cache)
+ if (edit->mirror_cache) {
MEM_freeN(edit->mirror_cache);
+ }
if (edit->emitter_cosnos) {
MEM_freeN(edit->emitter_cosnos);
@@ -168,8 +171,9 @@ int PE_start_edit(PTCacheEdit *edit)
{
if (edit) {
edit->edited = 1;
- if (edit->psys)
+ if (edit->psys) {
edit->psys->flag |= PSYS_EDITED;
+ }
return 1;
}
@@ -242,8 +246,9 @@ static PTCacheEdit *pe_get_current(Depsgraph *depsgraph, Scene *scene, Object *o
ListBase pidlist;
PTCacheID *pid;
- if (pset == NULL || ob == NULL)
+ if (pset == NULL || ob == NULL) {
return NULL;
+ }
pset->scene = scene;
pset->object = ob;
@@ -273,8 +278,9 @@ static PTCacheEdit *pe_get_current(Depsgraph *depsgraph, Scene *scene, Object *o
if (psys->flag & PSYS_CURRENT) {
if (psys->part && psys->part->type == PART_HAIR) {
if (psys->flag & PSYS_HAIR_DYNAMICS && psys->pointcache->flag & PTCACHE_BAKED) {
- if (create && !psys->pointcache->edit)
+ if (create && !psys->pointcache->edit) {
PE_create_particle_edit(depsgraph, scene, ob, pid->cache, NULL);
+ }
edit = pid->cache->edit;
}
else {
@@ -287,8 +293,9 @@ static PTCacheEdit *pe_get_current(Depsgraph *depsgraph, Scene *scene, Object *o
}
}
else {
- if (create && pid->cache->flag & PTCACHE_BAKED && !pid->cache->edit)
+ if (create && pid->cache->flag & PTCACHE_BAKED && !pid->cache->edit) {
PE_create_particle_edit(depsgraph, scene, ob, pid->cache, psys);
+ }
edit = pid->cache->edit;
}
@@ -359,8 +366,9 @@ void PE_hide_keys_time(Scene *scene, PTCacheEdit *edit, float cfra)
{
LOOP_KEYS
{
- if (fabsf(cfra - *key->time) < pset->fade_frames)
+ if (fabsf(cfra - *key->time) < pset->fade_frames) {
key->flag &= ~PEK_HIDE;
+ }
else {
key->flag |= PEK_HIDE;
//key->flag &= ~PEK_SELECT;
@@ -381,8 +389,9 @@ void PE_hide_keys_time(Scene *scene, PTCacheEdit *edit, float cfra)
static int pe_x_mirror(Object *ob)
{
- if (ob->type == OB_MESH)
+ if (ob->type == OB_MESH) {
return (((Mesh *)ob->data)->editflag & ME_EDIT_MIRROR_X);
+ }
return 0;
}
@@ -505,10 +514,11 @@ static bool key_test_depth(const PEData *data, const float co[3], const int scre
float depth;
/* nothing to do */
- if (XRAY_ENABLED(v3d))
+ if (XRAY_ENABLED(v3d)) {
return true;
+ }
- /* used to calculate here but all callers have the screen_co already, so pass as arg */
+ /* used to calculate here but all callers have the screen_co already, so pass as arg */
#if 0
if (ED_view3d_project_int_global(data->vc.ar,
co,
@@ -525,16 +535,19 @@ static bool key_test_depth(const PEData *data, const float co[3], const int scre
/* we know its not clipped */
depth = vd->depths[screen_co[1] * vd->w + screen_co[0]];
}
- else
+ else {
return 0;
+ }
float win[3];
ED_view3d_project(data->vc.ar, co, win);
- if (win[2] - 0.00001f > depth)
+ if (win[2] - 0.00001f > depth) {
return 0;
- else
+ }
+ else {
return 1;
+ }
}
static bool key_inside_circle(const PEData *data, float rad, const float co[3], float *distance)
@@ -552,12 +565,14 @@ static bool key_inside_circle(const PEData *data, float rad, const float co[3],
dy = data->mval[1] - screen_co[1];
dist = sqrtf(dx * dx + dy * dy);
- if (dist > rad)
+ if (dist > rad) {
return 0;
+ }
if (key_test_depth(data, co, screen_co)) {
- if (distance)
+ if (distance) {
*distance = dist;
+ }
return 1;
}
@@ -584,18 +599,21 @@ static bool key_inside_rect(PEData *data, const float co[3])
static bool key_inside_test(PEData *data, const float co[3])
{
- if (data->mval)
+ if (data->mval) {
return key_inside_circle(data, data->rad, co, NULL);
- else
+ }
+ else {
return key_inside_rect(data, co);
+ }
}
static bool point_is_selected(PTCacheEditPoint *point)
{
KEY_K;
- if (point->flag & PEP_HIDE)
+ if (point->flag & PEP_HIDE) {
return 0;
+ }
LOOP_SELECTED_KEYS
{
@@ -641,8 +659,9 @@ static void for_mouse_hit_keys(PEData *data, ForKeyFunc func, const enum ePartic
float dist = data->rad;
/* in path select mode we have no keys */
- if (pset->selectmode == SCE_SELECT_PATH)
+ if (pset->selectmode == SCE_SELECT_PATH) {
return;
+ }
nearest_point = -1;
nearest_key = -1;
@@ -704,8 +723,9 @@ static void foreach_mouse_hit_point(PEData *data, ForHitPointFunc func, int sele
KEY_K;
/* all is selected in path mode */
- if (pset->selectmode == SCE_SELECT_PATH)
+ if (pset->selectmode == SCE_SELECT_PATH) {
selected = 0;
+ }
LOOP_VISIBLE_POINTS
{
@@ -878,8 +898,9 @@ static int count_selected_keys(Scene *scene, PTCacheEdit *edit)
else if (pset->selectmode == SCE_SELECT_END) {
if (point->totkey) {
key = point->keys + point->totkey - 1;
- if (key->flag & PEK_SELECT)
+ if (key->flag & PEK_SELECT) {
sel++;
+ }
}
}
}
@@ -906,8 +927,9 @@ static void PE_update_mirror_cache(Object *ob, ParticleSystem *psys)
psmd_eval = edit->psmd_eval;
totpart = psys->totpart;
- if (!psmd_eval->mesh_final)
+ if (!psmd_eval->mesh_final) {
return;
+ }
tree = BLI_kdtree_3d_new(totpart);
@@ -924,8 +946,9 @@ static void PE_update_mirror_cache(Object *ob, ParticleSystem *psys)
BLI_kdtree_3d_balance(tree);
/* lookup particles and set in mirror cache */
- if (!edit->mirror_cache)
+ if (!edit->mirror_cache) {
edit->mirror_cache = MEM_callocN(sizeof(int) * totpart, "PE mirror cache");
+ }
LOOP_PARTICLES
{
@@ -938,10 +961,12 @@ static void PE_update_mirror_cache(Object *ob, ParticleSystem *psys)
index = BLI_kdtree_3d_find_nearest(tree, co, &nearest);
/* this needs a custom threshold still, duplicated for editmode mirror */
- if (index != -1 && index != p && (nearest.dist <= 0.0002f))
+ if (index != -1 && index != p && (nearest.dist <= 0.0002f)) {
edit->mirror_cache[p] = index;
- else
+ }
+ else {
edit->mirror_cache[p] = -1;
+ }
}
/* make sure mirrors are in two directions */
@@ -949,8 +974,9 @@ static void PE_update_mirror_cache(Object *ob, ParticleSystem *psys)
{
if (edit->mirror_cache[p]) {
index = edit->mirror_cache[p];
- if (edit->mirror_cache[index] != p)
+ if (edit->mirror_cache[index] != p) {
edit->mirror_cache[p] = -1;
+ }
}
}
@@ -972,29 +998,35 @@ static void PE_mirror_particle(
/* find mirrored particle if needed */
if (!mpa) {
- if (!edit->mirror_cache)
+ if (!edit->mirror_cache) {
PE_update_mirror_cache(ob, psys);
+ }
- if (!edit->mirror_cache)
+ if (!edit->mirror_cache) {
return; /* something went wrong! */
+ }
mi = edit->mirror_cache[i];
- if (mi == -1)
+ if (mi == -1) {
return;
+ }
mpa = psys->particles + mi;
}
- else
+ else {
mi = mpa - psys->particles;
+ }
point = edit->points + i;
mpoint = edit->points + mi;
/* make sure they have the same amount of keys */
if (pa->totkey != mpa->totkey) {
- if (mpa->hair)
+ if (mpa->hair) {
MEM_freeN(mpa->hair);
- if (mpoint->keys)
+ }
+ if (mpoint->keys) {
MEM_freeN(mpoint->keys);
+ }
mpa->hair = MEM_dupallocN(pa->hair);
mpa->totkey = pa->totkey;
@@ -1025,16 +1057,19 @@ static void PE_mirror_particle(
mhkey->co[0] = -mhkey->co[0];
mul_m4_v3(immat, mhkey->co);
- if (key->flag & PEK_TAG)
+ if (key->flag & PEK_TAG) {
mkey->flag |= PEK_TAG;
+ }
mkey->length = key->length;
}
- if (point->flag & PEP_TAG)
+ if (point->flag & PEP_TAG) {
mpoint->flag |= PEP_TAG;
- if (point->flag & PEP_EDIT_RECALC)
+ }
+ if (point->flag & PEP_EDIT_RECALC) {
mpoint->flag |= PEP_EDIT_RECALC;
+ }
}
static void PE_apply_mirror(Object *ob, ParticleSystem *psys)
@@ -1043,20 +1078,24 @@ static void PE_apply_mirror(Object *ob, ParticleSystem *psys)
ParticleSystemModifierData *psmd_eval;
POINT_P;
- if (!psys)
+ if (!psys) {
return;
+ }
edit = psys->edit;
psmd_eval = edit->psmd_eval;
- if (!psmd_eval->mesh_final)
+ if (!psmd_eval->mesh_final) {
return;
+ }
- if (!edit->mirror_cache)
+ if (!edit->mirror_cache) {
PE_update_mirror_cache(ob, psys);
+ }
- if (!edit->mirror_cache)
+ if (!edit->mirror_cache) {
return; /* something went wrong */
+ }
/* we delay settings the PARS_EDIT_RECALC for mirrored particles
* to avoid doing mirror twice */
@@ -1065,16 +1104,19 @@ static void PE_apply_mirror(Object *ob, ParticleSystem *psys)
if (point->flag & PEP_EDIT_RECALC) {
PE_mirror_particle(ob, psmd_eval->mesh_final, psys, psys->particles + p, NULL);
- if (edit->mirror_cache[p] != -1)
+ if (edit->mirror_cache[p] != -1) {
edit->points[edit->mirror_cache[p]].flag &= ~PEP_EDIT_RECALC;
+ }
}
}
LOOP_POINTS
{
- if (point->flag & PEP_EDIT_RECALC)
- if (edit->mirror_cache[p] != -1)
+ if (point->flag & PEP_EDIT_RECALC) {
+ if (edit->mirror_cache[p] != -1) {
edit->points[edit->mirror_cache[p]].flag |= PEP_EDIT_RECALC;
+ }
+ }
}
}
@@ -1225,11 +1267,13 @@ static void PE_apply_lengths(Scene *scene, PTCacheEdit *edit)
{
ParticleEditSettings *pset = PE_settings(scene);
- if (edit == 0 || (pset->flag & PE_KEEP_LENGTHS) == 0)
+ if (edit == 0 || (pset->flag & PE_KEEP_LENGTHS) == 0) {
return;
+ }
- if (edit->psys && edit->psys->flag & PSYS_GLOBAL_HAIR)
+ if (edit->psys && edit->psys->flag & PSYS_GLOBAL_HAIR) {
return;
+ }
ApplyLengthsIterData iter_data;
iter_data.edit = edit;
@@ -1321,8 +1365,9 @@ void recalc_lengths(PTCacheEdit *edit)
POINT_P;
KEY_K;
- if (edit == 0)
+ if (edit == 0) {
return;
+ }
LOOP_EDITED_POINTS
{
@@ -1341,11 +1386,13 @@ void recalc_emitter_field(Depsgraph *UNUSED(depsgraph), Object *UNUSED(ob), Part
float *vec, *nor;
int i, totface /*, totvert*/;
- if (!mesh)
+ if (!mesh) {
return;
+ }
- if (edit->emitter_cosnos)
+ if (edit->emitter_cosnos) {
MEM_freeN(edit->emitter_cosnos);
+ }
BLI_kdtree_3d_free(edit->emitter_field);
@@ -1402,11 +1449,12 @@ static void PE_update_selection(Depsgraph *depsgraph, Scene *scene, Object *ob,
KEY_K;
/* flag all particles to be updated if not using flag */
- if (!useflag)
+ if (!useflag) {
LOOP_POINTS
{
point->flag |= PEP_EDIT_RECALC;
}
+ }
/* flush edit key flag to hair key flag to preserve selection
* on save */
@@ -1441,20 +1489,23 @@ void update_world_cos(Depsgraph *UNUSED(depsgraph), Object *ob, PTCacheEdit *edi
KEY_K;
float hairmat[4][4];
- if (psys == 0 || psys->edit == 0 || psmd_eval->mesh_final == NULL)
+ if (psys == 0 || psys->edit == 0 || psmd_eval->mesh_final == NULL) {
return;
+ }
LOOP_POINTS
{
- if (!(psys->flag & PSYS_GLOBAL_HAIR))
+ if (!(psys->flag & PSYS_GLOBAL_HAIR)) {
psys_mat_hair_to_global(
ob, psmd_eval->mesh_final, psys->part->from, psys->particles + p, hairmat);
+ }
LOOP_KEYS
{
copy_v3_v3(key->world_co, key->co);
- if (!(psys->flag & PSYS_GLOBAL_HAIR))
+ if (!(psys->flag & PSYS_GLOBAL_HAIR)) {
mul_m4_v3(hairmat, key->world_co);
+ }
}
}
}
@@ -1466,8 +1517,9 @@ static void update_velocities(PTCacheEdit *edit)
KEY_K;
/* hair doesn't use velocities */
- if (edit->psys || !edit->points || !edit->points->keys->vel)
+ if (edit->psys || !edit->points || !edit->points->keys->vel) {
return;
+ }
frs_sec = edit->pid.flag & PTCACHE_VEL_PER_SEC ? 25.0f : 1.0f;
@@ -1478,8 +1530,9 @@ static void update_velocities(PTCacheEdit *edit)
if (k == 0) {
dfra = *(key + 1)->time - *key->time;
- if (dfra <= 0.0f)
+ if (dfra <= 0.0f) {
continue;
+ }
sub_v3_v3v3(key->vel, (key + 1)->co, key->co);
@@ -1493,8 +1546,9 @@ static void update_velocities(PTCacheEdit *edit)
else if (k == point->totkey - 1) {
dfra = *key->time - *(key - 1)->time;
- if (dfra <= 0.0f)
+ if (dfra <= 0.0f) {
continue;
+ }
sub_v3_v3v3(key->vel, key->co, (key - 1)->co);
@@ -1508,8 +1562,9 @@ static void update_velocities(PTCacheEdit *edit)
else {
dfra = *(key + 1)->time - *(key - 1)->time;
- if (dfra <= 0.0f)
+ if (dfra <= 0.0f) {
continue;
+ }
sub_v3_v3v3(key->vel, (key + 1)->co, (key - 1)->co);
}
@@ -1526,26 +1581,31 @@ void PE_update_object(Depsgraph *depsgraph, Scene *scene, Object *ob, int usefla
PTCacheEdit *edit = PE_get_current(scene, ob);
POINT_P;
- if (!edit)
+ if (!edit) {
return;
+ }
/* flag all particles to be updated if not using flag */
- if (!useflag)
+ if (!useflag) {
LOOP_POINTS
{
point->flag |= PEP_EDIT_RECALC;
}
+ }
/* do post process on particle edit keys */
pe_iterate_lengths(scene, edit);
pe_deflect_emitter(scene, ob, edit);
PE_apply_lengths(scene, edit);
- if (pe_x_mirror(ob))
+ if (pe_x_mirror(ob)) {
PE_apply_mirror(ob, edit->psys);
- if (edit->psys)
+ }
+ if (edit->psys) {
update_world_cos(depsgraph, ob, edit);
- if (pset->flag & PE_AUTO_VELOCITY)
+ }
+ if (pset->flag & PE_AUTO_VELOCITY) {
update_velocities(edit);
+ }
PE_hide_keys_time(scene, edit, CFRA);
/* regenerate path caches */
@@ -1557,8 +1617,9 @@ void PE_update_object(Depsgraph *depsgraph, Scene *scene, Object *ob, int usefla
point->flag &= ~PEP_EDIT_RECALC;
}
- if (edit->psys)
+ if (edit->psys) {
edit->psys->flag &= ~PSYS_HAIR_UPDATED;
+ }
}
/************************************************/
@@ -1573,10 +1634,12 @@ static void select_key(PEData *data, int point_index, int key_index, bool UNUSED
PTCacheEditPoint *point = edit->points + point_index;
PTCacheEditKey *key = point->keys + key_index;
- if (data->select)
+ if (data->select) {
key->flag |= PEK_SELECT;
- else
+ }
+ else {
key->flag &= ~PEK_SELECT;
+ }
point->flag |= PEP_EDIT_RECALC;
data->is_changed = true;
@@ -1607,10 +1670,12 @@ static void select_keys(PEData *data,
LOOP_KEYS
{
- if (data->select)
+ if (data->select) {
key->flag |= PEK_SELECT;
- else
+ }
+ else {
key->flag &= ~PEK_SELECT;
+ }
}
point->flag |= PEP_EDIT_RECALC;
@@ -1712,8 +1777,9 @@ static int pe_select_all_exec(bContext *C, wmOperator *op)
break;
}
- if (action == SEL_DESELECT)
+ if (action == SEL_DESELECT) {
break;
+ }
}
}
@@ -1806,8 +1872,9 @@ static void select_root(PEData *data, int point_index)
PTCacheEditPoint *point = data->edit->points + point_index;
PTCacheEditKey *key = point->keys;
- if (point->flag & PEP_HIDE)
+ if (point->flag & PEP_HIDE) {
return;
+ }
if (data->select_action != SEL_TOGGLE) {
data->is_changed = select_action_apply(point, key, data->select_action);
@@ -1874,8 +1941,9 @@ static void select_tip(PEData *data, int point_index)
key = &point->keys[point->totkey - 1];
- if (point->flag & PEP_HIDE)
+ if (point->flag & PEP_HIDE) {
return;
+ }
if (data->select_action != SEL_TOGGLE) {
data->is_changed = select_action_apply(point, key, data->select_action);
@@ -2190,8 +2258,9 @@ int PE_lasso_select(bContext *C, const int mcords[][2], const short moves, const
unit_m4(mat);
- if (!PE_start_edit(edit))
+ if (!PE_start_edit(edit)) {
return OPERATOR_CANCELLED;
+ }
/* only for depths */
PE_set_view3d_data(C, &data);
@@ -2202,9 +2271,10 @@ int PE_lasso_select(bContext *C, const int mcords[][2], const short moves, const
LOOP_VISIBLE_POINTS
{
- if (edit->psys && !(psys->flag & PSYS_GLOBAL_HAIR))
+ if (edit->psys && !(psys->flag & PSYS_GLOBAL_HAIR)) {
psys_mat_hair_to_global(
ob, psmd_eval->mesh_final, psys->part->from, psys->particles + p, mat);
+ }
if (pset->selectmode == SCE_SELECT_POINT) {
LOOP_KEYS
@@ -2375,16 +2445,19 @@ static void select_less_keys(PEData *data, int point_index)
LOOP_SELECTED_KEYS
{
if (k == 0) {
- if (((key + 1)->flag & PEK_SELECT) == 0)
+ if (((key + 1)->flag & PEK_SELECT) == 0) {
key->flag |= PEK_TAG;
+ }
}
else if (k == point->totkey - 1) {
- if (((key - 1)->flag & PEK_SELECT) == 0)
+ if (((key - 1)->flag & PEK_SELECT) == 0) {
key->flag |= PEK_TAG;
+ }
}
else {
- if ((((key - 1)->flag & (key + 1)->flag) & PEK_SELECT) == 0)
+ if ((((key - 1)->flag & (key + 1)->flag) & PEK_SELECT) == 0) {
key->flag |= PEK_TAG;
+ }
}
}
@@ -2436,20 +2509,24 @@ static void select_more_keys(PEData *data, int point_index)
LOOP_KEYS
{
- if (key->flag & PEK_SELECT)
+ if (key->flag & PEK_SELECT) {
continue;
+ }
if (k == 0) {
- if ((key + 1)->flag & PEK_SELECT)
+ if ((key + 1)->flag & PEK_SELECT) {
key->flag |= PEK_TAG;
+ }
}
else if (k == point->totkey - 1) {
- if ((key - 1)->flag & PEK_SELECT)
+ if ((key - 1)->flag & PEK_SELECT) {
key->flag |= PEK_TAG;
+ }
}
else {
- if (((key - 1)->flag | (key + 1)->flag) & PEK_SELECT)
+ if (((key - 1)->flag | (key + 1)->flag) & PEK_SELECT) {
key->flag |= PEK_TAG;
+ }
}
}
@@ -2534,22 +2611,25 @@ static void rekey_particle(PEData *data, int pa_index)
}
/* replace keys */
- if (pa->hair)
+ if (pa->hair) {
MEM_freeN(pa->hair);
+ }
pa->hair = new_keys;
point->totkey = pa->totkey = data->totrekey;
- if (point->keys)
+ if (point->keys) {
MEM_freeN(point->keys);
+ }
ekey = point->keys = MEM_callocN(pa->totkey * sizeof(PTCacheEditKey), "Hair re-key edit keys");
for (k = 0, key = pa->hair; k < pa->totkey; k++, key++, ekey++) {
ekey->co = key->co;
ekey->time = &key->time;
ekey->flag |= PEK_SELECT;
- if (!(psys->flag & PSYS_GLOBAL_HAIR))
+ if (!(psys->flag & PSYS_GLOBAL_HAIR)) {
ekey->flag |= PEK_USE_WCO;
+ }
}
pa->flag &= ~PARS_REKEY;
@@ -2605,8 +2685,9 @@ static void rekey_particle_to_time(
PTCacheEditKey *ekey;
int k;
- if (!edit || !edit->psys)
+ if (!edit || !edit->psys) {
return;
+ }
psys = edit->psys;
@@ -2629,8 +2710,9 @@ static void rekey_particle_to_time(
}
/* replace hair keys */
- if (pa->hair)
+ if (pa->hair) {
MEM_freeN(pa->hair);
+ }
pa->hair = new_keys;
/* update edit pointers */
@@ -2678,10 +2760,12 @@ static int remove_tagged_particles(Object *ob, ParticleSystem *psys, int mirror)
if (ELEM(NULL, new_pars, new_points)) {
/* allocation error! */
- if (new_pars)
+ if (new_pars) {
MEM_freeN(new_pars);
- if (new_points)
+ }
+ if (new_points) {
MEM_freeN(new_points);
+ }
return 0;
}
}
@@ -2690,10 +2774,12 @@ static int remove_tagged_particles(Object *ob, ParticleSystem *psys, int mirror)
point = edit->points;
for (i = 0; i < psys->totpart; i++, pa++, point++) {
if (point->flag & PEP_TAG) {
- if (point->keys)
+ if (point->keys) {
MEM_freeN(point->keys);
- if (pa->hair)
+ }
+ if (pa->hair) {
MEM_freeN(pa->hair);
+ }
}
else {
memcpy(npa, pa, sizeof(ParticleData));
@@ -2703,12 +2789,14 @@ static int remove_tagged_particles(Object *ob, ParticleSystem *psys, int mirror)
}
}
- if (psys->particles)
+ if (psys->particles) {
MEM_freeN(psys->particles);
+ }
psys->particles = new_pars;
- if (edit->points)
+ if (edit->points) {
MEM_freeN(edit->points);
+ }
edit->points = new_points;
if (edit->mirror_cache) {
@@ -2762,8 +2850,9 @@ static void remove_tagged_keys(Depsgraph *depsgraph, Object *ob, ParticleSystem
new_totkey--;
}
/* we can't have elements with less than two keys*/
- if (new_totkey < 2)
+ if (new_totkey < 2) {
point->flag |= PEP_TAG;
+ }
}
remove_tagged_particles(ob, psys, pe_x_mirror(ob));
@@ -2808,11 +2897,13 @@ static void remove_tagged_keys(Depsgraph *depsgraph, Object *ob, ParticleSystem
hkey++;
}
- if (pa->hair)
+ if (pa->hair) {
MEM_freeN(pa->hair);
+ }
- if (point->keys)
+ if (point->keys) {
MEM_freeN(point->keys);
+ }
pa->hair = new_hkeys;
point->keys = new_keys;
@@ -2849,12 +2940,14 @@ static void subdivide_particle(PEData *data, int pa_index)
sim.psys = edit->psys;
for (k = 0, ekey = point->keys; k < pa->totkey - 1; k++, ekey++) {
- if (ekey->flag & PEK_SELECT && (ekey + 1)->flag & PEK_SELECT)
+ if (ekey->flag & PEK_SELECT && (ekey + 1)->flag & PEK_SELECT) {
totnewkey++;
+ }
}
- if (totnewkey == 0)
+ if (totnewkey == 0) {
return;
+ }
pa->flag |= PARS_REKEY;
@@ -2886,8 +2979,9 @@ static void subdivide_particle(PEData *data, int pa_index)
nekey->co = nkey->co;
nekey->time = &nkey->time;
nekey->flag |= PEK_SELECT;
- if (!(psys->flag & PSYS_GLOBAL_HAIR))
+ if (!(psys->flag & PSYS_GLOBAL_HAIR)) {
nekey->flag |= PEK_USE_WCO;
+ }
nekey++;
nkey++;
@@ -2900,12 +2994,14 @@ static void subdivide_particle(PEData *data, int pa_index)
nekey->co = nkey->co;
nekey->time = &nkey->time;
- if (pa->hair)
+ if (pa->hair) {
MEM_freeN(pa->hair);
+ }
pa->hair = new_keys;
- if (point->keys)
+ if (point->keys) {
MEM_freeN(point->keys);
+ }
point->keys = new_ekeys;
point->totkey = pa->totkey = pa->totkey + totnewkey;
@@ -2959,8 +3055,9 @@ static int remove_doubles_exec(bContext *C, wmOperator *op)
float mat[4][4], co[3], threshold = RNA_float_get(op->ptr, "threshold");
int n, totn, removed, totremoved;
- if (psys->flag & PSYS_GLOBAL_HAIR)
+ if (psys->flag & PSYS_GLOBAL_HAIR) {
return OPERATOR_CANCELLED;
+ }
edit = psys->edit;
psmd_eval = edit->psmd_eval;
@@ -3011,8 +3108,9 @@ static int remove_doubles_exec(bContext *C, wmOperator *op)
totremoved += removed;
} while (removed);
- if (totremoved == 0)
+ if (totremoved == 0) {
return OPERATOR_CANCELLED;
+ }
BKE_reportf(op->reports, RPT_INFO, "Removed %d double particles", totremoved);
@@ -3147,9 +3245,10 @@ static void toggle_particle_cursor(bContext *C, int enable)
WM_paint_cursor_end(CTX_wm_manager(C), pset->paintcursor);
pset->paintcursor = NULL;
}
- else if (enable)
+ else if (enable) {
pset->paintcursor = WM_paint_cursor_activate(
CTX_wm_manager(C), SPACE_VIEW3D, RGN_TYPE_WINDOW, PE_poll_view3d, brush_drawcursor, NULL);
+ }
}
/*************************** delete operator **************************/
@@ -3243,12 +3342,14 @@ static void PE_mirror_x(Scene *scene, Object *ob, int tagged)
int *mirrorfaces = NULL;
int rotation, totpart, newtotpart;
- if (psys->flag & PSYS_GLOBAL_HAIR)
+ if (psys->flag & PSYS_GLOBAL_HAIR) {
return;
+ }
psmd_eval = edit->psmd_eval;
- if (!psmd_eval->mesh_final)
+ if (!psmd_eval->mesh_final) {
return;
+ }
const bool use_dm_final_indices = (psys->part->use_modifier_stack &&
!psmd_eval->mesh_final->runtime.deformed_only);
@@ -3261,8 +3362,9 @@ static void PE_mirror_x(Scene *scene, Object *ob, int tagged)
mirrorfaces = mesh_get_x_mirror_faces(
ob, NULL, use_dm_final_indices ? psmd_eval->mesh_final : NULL);
- if (!edit->mirror_cache)
+ if (!edit->mirror_cache) {
PE_update_mirror_cache(ob, psys);
+ }
totpart = psys->totpart;
newtotpart = psys->totpart;
@@ -3277,13 +3379,15 @@ static void PE_mirror_x(Scene *scene, Object *ob, int tagged)
PE_mirror_particle(ob, psmd_eval->mesh_final, psys, pa, NULL);
continue;
}
- else
+ else {
point->flag |= PEP_TAG;
+ }
}
}
- if ((point->flag & PEP_TAG) && mirrorfaces[pa->num * 2] != -1)
+ if ((point->flag & PEP_TAG) && mirrorfaces[pa->num * 2] != -1) {
newtotpart++;
+ }
}
if (newtotpart != psys->totpart) {
@@ -3320,19 +3424,23 @@ static void PE_mirror_x(Scene *scene, Object *ob, int tagged)
pa = psys->particles + p;
const int pa_num = pa->num;
- if (point->flag & PEP_HIDE)
+ if (point->flag & PEP_HIDE) {
continue;
+ }
- if (!(point->flag & PEP_TAG) || mirrorfaces[pa_num * 2] == -1)
+ if (!(point->flag & PEP_TAG) || mirrorfaces[pa_num * 2] == -1) {
continue;
+ }
/* duplicate */
*newpa = *pa;
*newpoint = *point;
- if (pa->hair)
+ if (pa->hair) {
newpa->hair = MEM_dupallocN(pa->hair);
- if (point->keys)
+ }
+ if (point->keys) {
newpoint->keys = MEM_dupallocN(point->keys);
+ }
/* rotate weights according to vertex index rotation */
rotation = mirrorfaces[pa_num * 2 + 1];
@@ -3428,8 +3536,9 @@ static void brush_comb(PEData *data,
ParticleEditSettings *pset = PE_settings(data->scene);
float cvec[3], fac;
- if (pset->flag & PE_LOCK_FIRST && key_index == 0)
+ if (pset->flag & PE_LOCK_FIRST && key_index == 0) {
return;
+ }
fac = (float)pow((double)(1.0f - mouse_distance / data->rad), (double)data->combfac);
@@ -3460,12 +3569,14 @@ static void brush_cut(PEData *data, int pa_index)
}
/* don't cut hidden */
- if (edit->points[pa_index].flag & PEP_HIDE)
+ if (edit->points[pa_index].flag & PEP_HIDE) {
return;
+ }
if (ED_view3d_project_int_global(ar, key->co, screen_co, V3D_PROJ_TEST_CLIP_NEAR) !=
- V3D_PROJ_RET_OK)
+ V3D_PROJ_RET_OK) {
return;
+ }
rad2 = data->rad * data->rad;
@@ -3616,8 +3727,9 @@ static void brush_puff(PEData *data, int point_index, float mouse_distance)
mul_v3_m4v3(kco, data->ob->imat, co);
point_index = BLI_kdtree_3d_find_nearest(edit->emitter_field, kco, NULL);
- if (point_index == -1)
+ if (point_index == -1) {
return;
+ }
copy_v3_v3(co_root, co);
copy_v3_v3(no_root, &edit->emitter_cosnos[point_index * 6 + 3]);
@@ -3632,8 +3744,9 @@ static void brush_puff(PEData *data, int point_index, float mouse_distance)
fac = (float)pow((double)(1.0f - mouse_distance / data->rad), (double)data->pufffac);
fac *= 0.025f;
- if (data->invert)
+ if (data->invert) {
fac = -fac;
+ }
}
else {
/* compute position as if hair was standing up straight.
@@ -3729,8 +3842,9 @@ static void brush_puff(PEData *data, int point_index, float mouse_distance)
}
}
- if (changed)
+ if (changed) {
point->flag |= PEP_EDIT_RECALC;
+ }
}
static void BKE_brush_weight_get(PEData *data,
@@ -3877,15 +3991,17 @@ static int particle_intersect_mesh(Depsgraph *depsgraph,
copy_v3_v3(v1, vert_cos + 3 * mface->v1);
copy_v3_v3(v2, vert_cos + 3 * mface->v2);
copy_v3_v3(v3, vert_cos + 3 * mface->v3);
- if (mface->v4)
+ if (mface->v4) {
copy_v3_v3(v4, vert_cos + 3 * mface->v4);
+ }
}
else {
copy_v3_v3(v1, mvert[mface->v1].co);
copy_v3_v3(v2, mvert[mface->v2].co);
copy_v3_v3(v3, mvert[mface->v3].co);
- if (mface->v4)
+ if (mface->v4) {
copy_v3_v3(v4, mvert[mface->v4].co);
+ }
}
if (face_minmax == 0) {
@@ -3893,16 +4009,19 @@ static int particle_intersect_mesh(Depsgraph *depsgraph,
DO_MINMAX(v1, min, max);
DO_MINMAX(v2, min, max);
DO_MINMAX(v3, min, max);
- if (mface->v4)
+ if (mface->v4) {
DO_MINMAX(v4, min, max);
- if (isect_aabb_aabb_v3(min, max, p_min, p_max) == 0)
+ }
+ if (isect_aabb_aabb_v3(min, max, p_min, p_max) == 0) {
continue;
+ }
}
else {
copy_v3_v3(min, face_minmax + 6 * i);
copy_v3_v3(max, face_minmax + 6 * i + 3);
- if (isect_aabb_aabb_v3(min, max, p_min, p_max) == 0)
+ if (isect_aabb_aabb_v3(min, max, p_min, p_max) == 0) {
continue;
+ }
}
if (radius > 0.0f) {
@@ -3933,8 +4052,9 @@ static int particle_intersect_mesh(Depsgraph *depsgraph,
min_w[1] = cur_uv[0];
min_w[2] = cur_uv[1];
min_w[3] = 0.0f;
- if (mface->v4)
+ if (mface->v4) {
intersect_dm_quad_weights(v1, v2, v3, v4, min_w);
+ }
*min_face = i;
intersect = 1;
}
@@ -4090,8 +4210,9 @@ static int brush_add(const bContext *C, PEData *data, short number)
invert_m4_m4(imat, ob->obmat);
- if (psys->flag & PSYS_GLOBAL_HAIR)
+ if (psys->flag & PSYS_GLOBAL_HAIR) {
return 0;
+ }
add_pars = MEM_callocN(number * sizeof(ParticleData), "ParticleData add");
@@ -4173,12 +4294,14 @@ static int brush_add(const bContext *C, PEData *data, short number)
memcpy(new_points, edit->points, totpart * sizeof(PTCacheEditPoint));
/* change old arrays to new ones */
- if (psys->particles)
+ if (psys->particles) {
MEM_freeN(psys->particles);
+ }
psys->particles = new_pars;
- if (edit->points)
+ if (edit->points) {
MEM_freeN(edit->points);
+ }
edit->points = new_points;
if (edit->mirror_cache) {
@@ -4225,16 +4348,18 @@ static int brush_add(const bContext *C, PEData *data, short number)
key->co = hkey->co;
key->time = &hkey->time;
- if (!(psys->flag & PSYS_GLOBAL_HAIR))
+ if (!(psys->flag & PSYS_GLOBAL_HAIR)) {
key->flag |= PEK_USE_WCO;
+ }
}
pa->size = 1.0f;
initialize_particle(&sim, pa);
reset_particle(&sim, pa, 0.0, 1.0);
point->flag |= PEP_EDIT_RECALC;
- if (pe_x_mirror(ob))
+ if (pe_x_mirror(ob)) {
point->flag |= PEP_TAG; /* signal for duplicate */
+ }
framestep = pa->lifetime / (float)(pset->totaddkey - 1);
@@ -4270,12 +4395,14 @@ static int brush_add(const bContext *C, PEData *data, short number)
}
if (totw > 0.0f) {
- for (w = 0; w < maxw; w++)
+ for (w = 0; w < maxw; w++) {
weight[w] /= totw;
+ }
}
else {
- for (w = 0; w < maxw; w++)
+ for (w = 0; w < maxw; w++) {
weight[w] = 1.0f / maxw;
+ }
}
ppa = psys->particles + ptn[0].index;
@@ -4305,8 +4432,9 @@ static int brush_add(const bContext *C, PEData *data, short number)
}
}
- if (k == 0)
+ if (k == 0) {
sub_v3_v3v3(co1, pa->state.co, key3[0].co);
+ }
add_v3_v3v3(thkey->co, key3[0].co, co1);
@@ -4327,8 +4455,9 @@ static int brush_add(const bContext *C, PEData *data, short number)
}
}
- if (tree)
+ if (tree) {
BLI_kdtree_3d_free(tree);
+ }
}
MEM_freeN(add_pars);
@@ -4408,8 +4537,9 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr)
float dx, dy, dmax;
int lock_root = pset->flag & PE_LOCK_FIRST;
- if (!PE_start_edit(edit))
+ if (!PE_start_edit(edit)) {
return;
+ }
RNA_float_get_array(itemptr, "mouse", mousef);
mouse[0] = mousef[0];
@@ -4428,8 +4558,9 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr)
mval[1] = mouse[1];
/* disable locking temporatily for disconnected hair */
- if (edit->psys && edit->psys->flag & PSYS_GLOBAL_HAIR)
+ if (edit->psys && edit->psys->flag & PSYS_GLOBAL_HAIR) {
pset->flag &= ~PE_LOCK_FIRST;
+ }
if (((pset->brushtype == PE_BRUSH_ADD) ?
(sqrtf(dx * dx + dy * dy) > pset->brush[PE_BRUSH_ADD].step) :
@@ -4458,10 +4589,12 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr)
data.rad = pe_brush_size_get(scene, brush);
data.combfac = (brush->strength - 0.5f) * 2.0f;
- if (data.combfac < 0.0f)
+ if (data.combfac < 0.0f) {
data.combfac = 1.0f - 9.0f * data.combfac;
- else
+ }
+ else {
data.combfac = 1.0f - data.combfac;
+ }
invert_m4_m4(ob->imat, ob->obmat);
@@ -4477,17 +4610,21 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr)
data.rad = pe_brush_size_get(scene, brush);
data.cutfac = brush->strength;
- if (selected)
+ if (selected) {
foreach_selected_point(&data, brush_cut);
- else
+ }
+ else {
foreach_point(&data, brush_cut);
+ }
removed = remove_tagged_particles(ob, edit->psys, pe_x_mirror(ob));
- if (pset->flag & PE_KEEP_LENGTHS)
+ if (pset->flag & PE_KEEP_LENGTHS) {
recalc_lengths(edit);
+ }
}
- else
+ else {
removed = 0;
+ }
break;
}
@@ -4497,15 +4634,18 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr)
data.rad = pe_brush_size_get(scene, brush);
data.growfac = brush->strength / 50.0f;
- if (brush->invert ^ flip)
+ if (brush->invert ^ flip) {
data.growfac = 1.0f - data.growfac;
- else
+ }
+ else {
data.growfac = 1.0f + data.growfac;
+ }
foreach_mouse_hit_point(&data, brush_length, selected);
- if (pset->flag & PE_KEEP_LENGTHS)
+ if (pset->flag & PE_KEEP_LENGTHS) {
recalc_lengths(edit);
+ }
break;
}
case PE_BRUSH_PUFF: {
@@ -4516,10 +4656,12 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr)
data.select = selected;
data.pufffac = (brush->strength - 0.5f) * 2.0f;
- if (data.pufffac < 0.0f)
+ if (data.pufffac < 0.0f) {
data.pufffac = 1.0f - 9.0f * data.pufffac;
- else
+ }
+ else {
data.pufffac = 1.0f - data.pufffac;
+ }
data.invert = (brush->invert ^ flip);
invert_m4_m4(ob->imat, ob->obmat);
@@ -4534,11 +4676,13 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr)
added = brush_add(C, &data, brush->count);
- if (pset->flag & PE_KEEP_LENGTHS)
+ if (pset->flag & PE_KEEP_LENGTHS) {
recalc_lengths(edit);
+ }
}
- else
+ else {
added = 0;
+ }
break;
}
case PE_BRUSH_SMOOTH: {
@@ -4575,12 +4719,14 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr)
break;
}
}
- if ((pset->flag & PE_KEEP_LENGTHS) == 0)
+ if ((pset->flag & PE_KEEP_LENGTHS) == 0) {
recalc_lengths(edit);
+ }
if (ELEM(pset->brushtype, PE_BRUSH_ADD, PE_BRUSH_CUT) && (added || removed)) {
- if (pset->brushtype == PE_BRUSH_ADD && pe_x_mirror(ob))
+ if (pset->brushtype == PE_BRUSH_ADD && pe_x_mirror(ob)) {
PE_mirror_x(scene, ob, 1);
+ }
update_world_cos(depsgraph, ob, edit);
psys_free_path_cache(NULL, edit);
@@ -4619,8 +4765,9 @@ static void brush_edit_exit(wmOperator *op)
static int brush_edit_exec(bContext *C, wmOperator *op)
{
- if (!brush_edit_init(C, op))
+ if (!brush_edit_init(C, op)) {
return OPERATOR_CANCELLED;
+ }
RNA_BEGIN (op->ptr, itemptr, "stroke") {
brush_edit_apply(C, op, &itemptr);
@@ -4651,8 +4798,9 @@ static void brush_edit_apply_event(bContext *C, wmOperator *op, const wmEvent *e
static int brush_edit_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
- if (!brush_edit_init(C, op))
+ if (!brush_edit_init(C, op)) {
return OPERATOR_CANCELLED;
+ }
brush_edit_apply_event(C, op, event);
@@ -4738,8 +4886,9 @@ static void point_inside_bvh_cb(void *userdata,
data->bvhdata.raycast_callback(&data->bvhdata, index, ray, hit);
- if (hit->index != -1)
+ if (hit->index != -1) {
++data->num_hits;
+ }
}
/* true if the point is inside the shape mesh */
@@ -4771,8 +4920,9 @@ static void shape_cut(PEData *data, int pa_index)
int k, totkeys = 1 << pset->draw_step;
/* don't cut hidden */
- if (edit->points[pa_index].flag & PEP_HIDE)
+ if (edit->points[pa_index].flag & PEP_HIDE) {
return;
+ }
cut = false;
@@ -4833,12 +4983,14 @@ static int shape_cut_exec(bContext *C, wmOperator *UNUSED(op))
int selected = count_selected_keys(scene, edit);
int lock_root = pset->flag & PE_LOCK_FIRST;
- if (!PE_start_edit(edit))
+ if (!PE_start_edit(edit)) {
return OPERATOR_CANCELLED;
+ }
/* disable locking temporatily for disconnected hair */
- if (edit->psys && edit->psys->flag & PSYS_GLOBAL_HAIR)
+ if (edit->psys && edit->psys->flag & PSYS_GLOBAL_HAIR) {
pset->flag &= ~PE_LOCK_FIRST;
+ }
if (edit->psys && edit->pathcache) {
PEData data;
@@ -4850,10 +5002,12 @@ static int shape_cut_exec(bContext *C, wmOperator *UNUSED(op))
return OPERATOR_CANCELLED;
}
- if (selected)
+ if (selected) {
foreach_selected_point(&data, shape_cut);
- else
+ }
+ else {
foreach_point(&data, shape_cut);
+ }
removed = remove_tagged_particles(ob, edit->psys, pe_x_mirror(ob));
recalc_lengths(edit);
@@ -4913,19 +5067,23 @@ int PE_minmax(Scene *scene, ViewLayer *view_layer, float min[3], float max[3])
float co[3], mat[4][4];
int ok = 0;
- if (!edit)
+ if (!edit) {
return ok;
+ }
- if ((psys = edit->psys))
+ if ((psys = edit->psys)) {
psmd_eval = edit->psmd_eval;
- else
+ }
+ else {
unit_m4(mat);
+ }
LOOP_VISIBLE_POINTS
{
- if (psys)
+ if (psys) {
psys_mat_hair_to_global(
ob, psmd_eval->mesh_final, psys->part->from, psys->particles + p, mat);
+ }
LOOP_SELECTED_KEYS
{
@@ -4965,14 +5123,17 @@ void PE_create_particle_edit(
}
/* no psmd->dm happens in case particle system modifier is not enabled */
- if (!(psys && psmd && psmd_eval->mesh_final) && !cache)
+ if (!(psys && psmd && psmd_eval->mesh_final) && !cache) {
return;
+ }
- if (cache && cache->flag & PTCACHE_DISK_CACHE)
+ if (cache && cache->flag & PTCACHE_DISK_CACHE) {
return;
+ }
- if (psys == NULL && (cache && BLI_listbase_is_empty(&cache->mem_cache)))
+ if (psys == NULL && (cache && BLI_listbase_is_empty(&cache->mem_cache))) {
return;
+ }
edit = (psys) ? psys->edit : cache->edit;
@@ -5033,21 +5194,24 @@ void PE_create_particle_edit(
cache->free_edit = PE_free_ptcache_edit;
edit->psys = NULL;
- for (pm = cache->mem_cache.first; pm; pm = pm->next)
+ for (pm = cache->mem_cache.first; pm; pm = pm->next) {
totframe++;
+ }
for (pm = cache->mem_cache.first; pm; pm = pm->next) {
LOOP_POINTS
{
- if (BKE_ptcache_mem_pointers_seek(p, pm) == 0)
+ if (BKE_ptcache_mem_pointers_seek(p, pm) == 0) {
continue;
+ }
if (!point->totkey) {
key = point->keys = MEM_callocN(totframe * sizeof(PTCacheEditKey), "ParticleEditKeys");
point->flag |= PEP_EDIT_RECALC;
}
- else
+ else {
key = point->keys + point->totkey;
+ }
key->co = pm->cur[BPHYS_DATA_LOCATION];
key->vel = pm->cur[BPHYS_DATA_VELOCITY];
@@ -5071,8 +5235,9 @@ void PE_create_particle_edit(
memset(edit->nosel_col, 0x00, sizeof(edit->nosel_col));
#endif
recalc_lengths(edit);
- if (psys && !cache)
+ if (psys && !cache) {
recalc_emitter_field(depsgraph, ob, psys);
+ }
PE_update_object(depsgraph, scene, ob, 1);
}
@@ -5082,12 +5247,15 @@ static bool particle_edit_toggle_poll(bContext *C)
{
Object *ob = CTX_data_active_object(C);
- if (ob == NULL || ob->type != OB_MESH)
+ if (ob == NULL || ob->type != OB_MESH) {
return 0;
- if (!ob->data || ID_IS_LINKED(ob->data))
+ }
+ if (!ob->data || ID_IS_LINKED(ob->data)) {
return 0;
- if (CTX_data_edit_object(C))
+ }
+ if (CTX_data_edit_object(C)) {
return 0;
+ }
return (ob->particlesystem.first || modifiers_findByType(ob, eModifierType_Cloth) ||
modifiers_findByType(ob, eModifierType_Softbody));
diff --git a/source/blender/editors/physics/particle_object.c b/source/blender/editors/physics/particle_object.c
index 214a9f22186..b03ec56c7e4 100644
--- a/source/blender/editors/physics/particle_object.c
+++ b/source/blender/editors/physics/particle_object.c
@@ -84,8 +84,9 @@ static int particle_system_add_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob = ED_object_context(C);
Scene *scene = CTX_data_scene(C);
- if (!scene || !ob)
+ if (!scene || !ob) {
return OPERATOR_CANCELLED;
+ }
object_add_particle_system(bmain, scene, ob, NULL);
@@ -118,8 +119,9 @@ static int particle_system_remove_exec(bContext *C, wmOperator *UNUSED(op))
ViewLayer *view_layer = CTX_data_view_layer(C);
int mode_orig;
- if (!scene || !ob)
+ if (!scene || !ob) {
return OPERATOR_CANCELLED;
+ }
mode_orig = ob->mode;
object_remove_particle_system(bmain, scene, ob);
@@ -177,15 +179,18 @@ static int new_particle_settings_exec(bContext *C, wmOperator *UNUSED(op))
psys = ptr.data;
/* add or copy particle setting */
- if (psys->part)
+ if (psys->part) {
part = BKE_particlesettings_copy(bmain, psys->part);
- else
+ }
+ else {
part = BKE_particlesettings_add(bmain, "ParticleSettings");
+ }
ob = ptr.id.data;
- if (psys->part)
+ if (psys->part) {
id_us_min(&psys->part->id);
+ }
psys->part = part;
@@ -225,12 +230,14 @@ static int new_particle_target_exec(bContext *C, wmOperator *UNUSED(op))
ParticleTarget *pt;
- if (!psys)
+ if (!psys) {
return OPERATOR_CANCELLED;
+ }
pt = psys->targets.first;
- for (; pt; pt = pt->next)
+ for (; pt; pt = pt->next) {
pt->flag &= ~PTARGET_CURRENT;
+ }
pt = MEM_callocN(sizeof(ParticleTarget), "keyed particle target");
@@ -270,8 +277,9 @@ static int remove_particle_target_exec(bContext *C, wmOperator *UNUSED(op))
ParticleTarget *pt;
- if (!psys)
+ if (!psys) {
return OPERATOR_CANCELLED;
+ }
pt = psys->targets.first;
for (; pt; pt = pt->next) {
@@ -283,8 +291,9 @@ static int remove_particle_target_exec(bContext *C, wmOperator *UNUSED(op))
}
pt = psys->targets.last;
- if (pt)
+ if (pt) {
pt->flag |= PTARGET_CURRENT;
+ }
DEG_relations_tag_update(bmain);
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
@@ -317,8 +326,9 @@ static int target_move_up_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob = ptr.id.data;
ParticleTarget *pt;
- if (!psys)
+ if (!psys) {
return OPERATOR_CANCELLED;
+ }
pt = psys->targets.first;
for (; pt; pt = pt->next) {
@@ -356,8 +366,9 @@ static int target_move_down_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob = ptr.id.data;
ParticleTarget *pt;
- if (!psys)
+ if (!psys) {
return OPERATOR_CANCELLED;
+ }
pt = psys->targets.first;
for (; pt; pt = pt->next) {
if (pt->flag & PTARGET_CURRENT && pt->next) {
@@ -392,8 +403,9 @@ static int dupliob_refresh_exec(bContext *C, wmOperator *UNUSED(op))
PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem);
ParticleSystem *psys = ptr.data;
- if (!psys)
+ if (!psys) {
return OPERATOR_CANCELLED;
+ }
psys_check_group_weights(psys->part);
DEG_id_tag_update(&psys->part->id, ID_RECALC_GEOMETRY | ID_RECALC_PSYS_REDO);
@@ -423,8 +435,9 @@ static int dupliob_move_up_exec(bContext *C, wmOperator *UNUSED(op))
ParticleSettings *part;
ParticleDupliWeight *dw;
- if (!psys)
+ if (!psys) {
return OPERATOR_CANCELLED;
+ }
part = psys->part;
for (dw = part->instance_weights.first; dw; dw = dw->next) {
@@ -462,8 +475,9 @@ static int copy_particle_dupliob_exec(bContext *C, wmOperator *UNUSED(op))
ParticleSettings *part;
ParticleDupliWeight *dw;
- if (!psys)
+ if (!psys) {
return OPERATOR_CANCELLED;
+ }
part = psys->part;
for (dw = part->instance_weights.first; dw; dw = dw->next) {
if (dw->flag & PART_DUPLIW_CURRENT) {
@@ -502,8 +516,9 @@ static int remove_particle_dupliob_exec(bContext *C, wmOperator *UNUSED(op))
ParticleSettings *part;
ParticleDupliWeight *dw;
- if (!psys)
+ if (!psys) {
return OPERATOR_CANCELLED;
+ }
part = psys->part;
for (dw = part->instance_weights.first; dw; dw = dw->next) {
@@ -515,8 +530,9 @@ static int remove_particle_dupliob_exec(bContext *C, wmOperator *UNUSED(op))
}
dw = part->instance_weights.last;
- if (dw)
+ if (dw) {
dw->flag |= PART_DUPLIW_CURRENT;
+ }
DEG_id_tag_update(&part->id, ID_RECALC_GEOMETRY | ID_RECALC_PSYS_REDO);
WM_event_add_notifier(C, NC_OBJECT | ND_PARTICLE, NULL);
@@ -547,8 +563,9 @@ static int dupliob_move_down_exec(bContext *C, wmOperator *UNUSED(op))
ParticleSettings *part;
ParticleDupliWeight *dw;
- if (!psys)
+ if (!psys) {
return OPERATOR_CANCELLED;
+ }
part = psys->part;
for (dw = part->instance_weights.first; dw; dw = dw->next) {
@@ -593,11 +610,13 @@ static void disconnect_hair(Depsgraph *depsgraph, Scene *scene, Object *ob, Part
int i, k;
float hairmat[4][4];
- if (!ob || !psys || psys->flag & PSYS_GLOBAL_HAIR)
+ if (!ob || !psys || psys->flag & PSYS_GLOBAL_HAIR) {
return;
+ }
- if (!psys->part || psys->part->type != PART_HAIR)
+ if (!psys->part || psys->part->type != PART_HAIR) {
return;
+ }
edit = psys->edit;
point = edit ? edit->points : NULL;
@@ -639,8 +658,9 @@ static int disconnect_hair_exec(bContext *C, wmOperator *op)
ParticleSystem *psys = NULL;
const bool all = RNA_boolean_get(op->ptr, "all");
- if (!ob)
+ if (!ob) {
return OPERATOR_CANCELLED;
+ }
if (all) {
for (psys = ob->particlesystem.first; psys; psys = psys->next) {
@@ -705,12 +725,15 @@ static bool remap_hair_emitter(Depsgraph *depsgraph,
float from_ob_imat[4][4], to_ob_imat[4][4];
float from_imat[4][4], to_imat[4][4];
- if (!target_psmd->mesh_final)
+ if (!target_psmd->mesh_final) {
return false;
- if (!psys->part || psys->part->type != PART_HAIR)
+ }
+ if (!psys->part || psys->part->type != PART_HAIR) {
return false;
- if (!target_psys->part || target_psys->part->type != PART_HAIR)
+ }
+ if (!target_psys->part || target_psys->part->type != PART_HAIR) {
return false;
+ }
edit_point = target_edit ? target_edit->points : NULL;
@@ -740,8 +763,9 @@ static bool remap_hair_emitter(Depsgraph *depsgraph,
mvert = mesh->mvert;
/* convert to global coordinates */
- for (i = 0; i < numverts; i++)
+ for (i = 0; i < numverts; i++) {
mul_m4_v3(to_mat, mvert[i].co);
+ }
if (mesh->totface != 0) {
mface = mesh->mface;
@@ -761,10 +785,12 @@ static bool remap_hair_emitter(Depsgraph *depsgraph,
float from_co[3];
BVHTreeNearest nearest;
- if (from_global)
+ if (from_global) {
mul_v3_m4v3(from_co, from_ob_imat, pa->hair[0].co);
- else
+ }
+ else {
mul_v3_m4v3(from_co, from_ob_imat, pa->hair[0].world_co);
+ }
mul_m4_v3(from_mat, from_co);
nearest.index = -1;
@@ -773,8 +799,9 @@ static bool remap_hair_emitter(Depsgraph *depsgraph,
BLI_bvhtree_find_nearest(bvhtree.tree, from_co, &nearest, bvhtree.nearest_callback, &bvhtree);
if (nearest.index == -1) {
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("No nearest point found for hair root!");
+ }
continue;
}
@@ -790,8 +817,9 @@ static bool remap_hair_emitter(Depsgraph *depsgraph,
copy_v3_v3(v[3], mvert[mf->v4].co);
interp_weights_poly_v3(tpa->fuv, v, 4, nearest.co);
}
- else
+ else {
interp_weights_poly_v3(tpa->fuv, v, 3, nearest.co);
+ }
tpa->foffset = 0.0f;
tpa->num = nearest.index;
@@ -815,8 +843,9 @@ static bool remap_hair_emitter(Depsgraph *depsgraph,
float hairmat[4][4], imat[4][4];
float offset[3];
- if (to_global)
+ if (to_global) {
copy_m4_m4(imat, target_ob->obmat);
+ }
else {
/* note: using target_dm here, which is in target_ob object space and has full modifiers */
psys_mat_hair_to_object(target_ob, target_mesh, target_psys->part->from, tpa, hairmat);
@@ -832,10 +861,12 @@ static bool remap_hair_emitter(Depsgraph *depsgraph,
k++, key++, tkey++, ekey++) {
float co_orig[3];
- if (from_global)
+ if (from_global) {
mul_v3_m4v3(co_orig, from_ob_imat, key->co);
- else
+ }
+ else {
mul_v3_m4v3(co_orig, from_ob_imat, key->world_co);
+ }
mul_m4_v3(from_mat, co_orig);
add_v3_v3v3(tkey->co, co_orig, offset);
@@ -851,10 +882,12 @@ static bool remap_hair_emitter(Depsgraph *depsgraph,
for (k = 0, key = pa->hair, tkey = tpa->hair; k < tpa->totkey; k++, key++, tkey++) {
float co_orig[3];
- if (from_global)
+ if (from_global) {
mul_v3_m4v3(co_orig, from_ob_imat, key->co);
- else
+ }
+ else {
mul_v3_m4v3(co_orig, from_ob_imat, key->world_co);
+ }
mul_m4_v3(from_mat, co_orig);
add_v3_v3v3(tkey->co, co_orig, offset);
@@ -879,8 +912,9 @@ static bool connect_hair(Depsgraph *depsgraph, Scene *scene, Object *ob, Particl
{
bool ok;
- if (!psys)
+ if (!psys) {
return false;
+ }
ok = remap_hair_emitter(depsgraph,
scene,
@@ -907,8 +941,9 @@ static int connect_hair_exec(bContext *C, wmOperator *op)
const bool all = RNA_boolean_get(op->ptr, "all");
bool any_connected = false;
- if (!ob)
+ if (!ob) {
return OPERATOR_CANCELLED;
+ }
if (all) {
for (psys = ob->particlesystem.first; psys; psys = psys->next) {
@@ -966,8 +1001,9 @@ static void copy_particle_edit(Depsgraph *depsgraph,
KEY_K;
POINT_P;
- if (!edit_from)
+ if (!edit_from) {
return;
+ }
edit = MEM_dupallocN(edit_from);
edit->psys = psys;
@@ -1015,10 +1051,12 @@ static void remove_particle_systems_from_object(Object *ob_to)
{
ModifierData *md, *md_next;
- if (ob_to->type != OB_MESH)
+ if (ob_to->type != OB_MESH) {
return;
- if (!ob_to->data || ID_IS_LINKED(ob_to->data))
+ }
+ if (!ob_to->data || ID_IS_LINKED(ob_to->data)) {
return;
+ }
for (md = ob_to->modifiers.first; md; md = md_next) {
md_next = md->next;
@@ -1056,10 +1094,12 @@ static bool copy_particle_systems_to_object(const bContext *C,
CustomData_MeshMasks cdmask = {0};
int i, totpsys;
- if (ob_to->type != OB_MESH)
+ if (ob_to->type != OB_MESH) {
return false;
- if (!ob_to->data || ID_IS_LINKED(ob_to->data))
+ }
+ if (!ob_to->data || ID_IS_LINKED(ob_to->data)) {
return false;
+ }
/* For remapping we need a valid DM.
* Because the modifiers are appended at the end it's safe to use
@@ -1081,8 +1121,9 @@ static bool copy_particle_systems_to_object(const bContext *C,
psys = BKE_object_copy_particlesystem(psys_from, 0);
tmp_psys[i] = psys;
- if (psys_start == NULL)
+ if (psys_start == NULL) {
psys_start = psys;
+ }
psys_emitter_customdata_mask(psys, &cdmask);
}
@@ -1181,12 +1222,14 @@ static bool copy_particle_systems_to_object(const bContext *C,
static bool copy_particle_systems_poll(bContext *C)
{
Object *ob;
- if (!ED_operator_object_active_editable(C))
+ if (!ED_operator_object_active_editable(C)) {
return false;
+ }
ob = ED_object_active_context(C);
- if (BLI_listbase_is_empty(&ob->particlesystem))
+ if (BLI_listbase_is_empty(&ob->particlesystem)) {
return false;
+ }
return true;
}
@@ -1212,13 +1255,16 @@ static int copy_particle_systems_exec(bContext *C, wmOperator *op)
remove_particle_systems_from_object(ob_to);
changed = true;
}
- if (copy_particle_systems_to_object(C, scene, ob_from, psys_from, ob_to, space, false))
+ if (copy_particle_systems_to_object(C, scene, ob_from, psys_from, ob_to, space, false)) {
changed = true;
- else
+ }
+ else {
fail++;
+ }
- if (changed)
+ if (changed) {
changed_tot++;
+ }
}
}
CTX_DATA_END;
diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c
index d90fefaa67f..1ec0aeffa17 100644
--- a/source/blender/editors/physics/physics_fluid.c
+++ b/source/blender/editors/physics/physics_fluid.c
@@ -80,8 +80,9 @@ static float get_fluid_rate(FluidsimSettings *settings)
rate = settings->animRate;
- if (rate < 0.0f)
+ if (rate < 0.0f) {
rate = 0.0f;
+ }
return rate;
}
@@ -257,8 +258,9 @@ static void set_vertex_channel(Depsgraph *depsgraph,
int framesize = (3 * fobj->numVerts) + 1;
int j;
- if (channel == NULL)
+ if (channel == NULL) {
return;
+ }
initElbeemMesh(depsgraph, scene, ob, &numVerts, &verts, &numTris, &tris, 1, modifierIndex);
@@ -281,8 +283,9 @@ static void set_vertex_channel(Depsgraph *depsgraph,
static void free_domain_channels(FluidAnimChannels *channels)
{
- if (!channels->timeAtFrame)
+ if (!channels->timeAtFrame) {
return;
+ }
MEM_freeN(channels->timeAtFrame);
channels->timeAtFrame = NULL;
MEM_freeN(channels->DomainGravity);
@@ -457,8 +460,9 @@ static void fluid_init_all_channels(bContext *C,
float active = (float)((fluidmd->fss->flag & OB_FLUIDSIM_ACTIVE) ? 1 : 0);
float rot_d[3] = {0.f, 0.f, 0.f}, old_rot[3] = {0.f, 0.f, 0.f};
- if (ELEM(fluidmd->fss->type, OB_FLUIDSIM_DOMAIN, OB_FLUIDSIM_PARTICLE))
+ if (ELEM(fluidmd->fss->type, OB_FLUIDSIM_DOMAIN, OB_FLUIDSIM_PARTICLE)) {
continue;
+ }
/* init euler rotation values and convert to elbeem format */
/* get the rotation from ob->obmat rather than ob->rot to account for parent animations */
@@ -526,8 +530,9 @@ static void export_fluid_objects(const bContext *C, ListBase *fobjects, Scene *s
elbeemMesh fsmesh;
- if (ELEM(fluidmd->fss->type, OB_FLUIDSIM_DOMAIN, OB_FLUIDSIM_PARTICLE))
+ if (ELEM(fluidmd->fss->type, OB_FLUIDSIM_DOMAIN, OB_FLUIDSIM_PARTICLE)) {
continue;
+ }
elbeemResetMesh(&fsmesh);
@@ -554,12 +559,15 @@ static void export_fluid_objects(const bContext *C, ListBase *fobjects, Scene *s
fsmesh.localInivelCoords = ((fluidmd->fss->typeFlags & OB_FSINFLOW_LOCALCOORD) ? 1 : 0);
}
- if (fluidmd->fss->typeFlags & OB_FSBND_NOSLIP)
+ if (fluidmd->fss->typeFlags & OB_FSBND_NOSLIP) {
fsmesh.obstacleType = FLUIDSIM_OBSTACLE_NOSLIP;
- else if (fluidmd->fss->typeFlags & OB_FSBND_PARTSLIP)
+ }
+ else if (fluidmd->fss->typeFlags & OB_FSBND_PARTSLIP) {
fsmesh.obstacleType = FLUIDSIM_OBSTACLE_PARTSLIP;
- else if (fluidmd->fss->typeFlags & OB_FSBND_FREESLIP)
+ }
+ else if (fluidmd->fss->typeFlags & OB_FSBND_FREESLIP) {
fsmesh.obstacleType = FLUIDSIM_OBSTACLE_FREESLIP;
+ }
fsmesh.obstaclePartslip = fluidmd->fss->partSlipValue;
fsmesh.volumeInitType = fluidmd->fss->volumeInitType;
@@ -593,16 +601,19 @@ static void export_fluid_objects(const bContext *C, ListBase *fobjects, Scene *s
fsmesh.channelTranslation = fsmesh.channelRotation = fsmesh.channelScale = NULL;
/* Override user settings, only noslip is supported here! */
- if (fsmesh.type != OB_FLUIDSIM_CONTROL)
+ if (fsmesh.type != OB_FLUIDSIM_CONTROL) {
fsmesh.obstacleType = FLUIDSIM_OBSTACLE_NOSLIP;
+ }
}
elbeemAddMesh(&fsmesh);
- if (verts)
+ if (verts) {
MEM_freeN(verts);
- if (tris)
+ }
+ if (tris) {
MEM_freeN(tris);
+ }
}
}
@@ -619,8 +630,9 @@ static int fluid_validate_scene(ReportList *reports, ViewLayer *view_layer, Obje
ob, eModifierType_Fluidsim);
/* only find objects with fluid modifiers */
- if (!fluidmdtmp || ob->type != OB_MESH)
+ if (!fluidmdtmp || ob->type != OB_MESH) {
continue;
+ }
if (fluidmdtmp->fss->type == OB_FLUIDSIM_DOMAIN) {
/* if no initial domain object given, find another potential domain */
@@ -635,16 +647,19 @@ static int fluid_validate_scene(ReportList *reports, ViewLayer *view_layer, Obje
}
/* count number of objects needed for animation channels */
- if (!ELEM(fluidmdtmp->fss->type, OB_FLUIDSIM_DOMAIN, OB_FLUIDSIM_PARTICLE))
+ if (!ELEM(fluidmdtmp->fss->type, OB_FLUIDSIM_DOMAIN, OB_FLUIDSIM_PARTICLE)) {
channelObjCount++;
+ }
/* count number of fluid input objects */
- if (ELEM(fluidmdtmp->fss->type, OB_FLUIDSIM_FLUID, OB_FLUIDSIM_INFLOW))
+ if (ELEM(fluidmdtmp->fss->type, OB_FLUIDSIM_FLUID, OB_FLUIDSIM_INFLOW)) {
fluidInputCount++;
+ }
}
- if (newdomain)
+ if (newdomain) {
fsDomain = newdomain;
+ }
if (!fsDomain) {
BKE_report(reports, RPT_ERROR, "No domain object found");
@@ -768,8 +783,9 @@ static int fluidbake_breakjob(void *customdata)
{
FluidBakeJob *fb = (FluidBakeJob *)customdata;
- if (fb->stop && *(fb->stop))
+ if (fb->stop && *(fb->stop)) {
return 1;
+ }
/* this is not nice yet, need to make the jobs list template better
* for identifying/acting upon various different jobs */
@@ -1099,19 +1115,24 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor
fsset->runsimCallback = &runSimulationCallback;
fsset->runsimUserData = fb;
- if (domainSettings->typeFlags & OB_FSBND_NOSLIP)
+ if (domainSettings->typeFlags & OB_FSBND_NOSLIP) {
fsset->domainobsType = FLUIDSIM_OBSTACLE_NOSLIP;
- else if (domainSettings->typeFlags & OB_FSBND_PARTSLIP)
+ }
+ else if (domainSettings->typeFlags & OB_FSBND_PARTSLIP) {
fsset->domainobsType = FLUIDSIM_OBSTACLE_PARTSLIP;
- else if (domainSettings->typeFlags & OB_FSBND_FREESLIP)
+ }
+ else if (domainSettings->typeFlags & OB_FSBND_FREESLIP) {
fsset->domainobsType = FLUIDSIM_OBSTACLE_FREESLIP;
+ }
fsset->domainobsPartslip = domainSettings->partSlipValue;
/* use domainobsType also for surface generation flag (bit: >=64) */
- if (domainSettings->typeFlags & OB_FSSG_NOOBS)
+ if (domainSettings->typeFlags & OB_FSSG_NOOBS) {
fsset->mFsSurfGenSetting = FLUIDSIM_FSSG_NOOBS;
- else
+ }
+ else {
fsset->mFsSurfGenSetting = 0; // "normal" mode
+ }
fsset->generateVertexVectors = (domainSettings->domainNovecgen == 0);
@@ -1190,19 +1211,22 @@ static int fluidsimBake(bContext *UNUSED(C),
static int fluid_bake_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
/* only one bake job at a time */
- if (WM_jobs_test(CTX_wm_manager(C), CTX_data_scene(C), WM_JOB_TYPE_OBJECT_SIM_FLUID))
+ if (WM_jobs_test(CTX_wm_manager(C), CTX_data_scene(C), WM_JOB_TYPE_OBJECT_SIM_FLUID)) {
return OPERATOR_CANCELLED;
+ }
- if (!fluidsimBake(C, op->reports, CTX_data_active_object(C), true))
+ if (!fluidsimBake(C, op->reports, CTX_data_active_object(C), true)) {
return OPERATOR_CANCELLED;
+ }
return OPERATOR_FINISHED;
}
static int fluid_bake_exec(bContext *C, wmOperator *op)
{
- if (!fluidsimBake(C, op->reports, CTX_data_active_object(C), false))
+ if (!fluidsimBake(C, op->reports, CTX_data_active_object(C), false)) {
return OPERATOR_CANCELLED;
+ }
return OPERATOR_FINISHED;
}
diff --git a/source/blender/editors/physics/rigidbody_constraint.c b/source/blender/editors/physics/rigidbody_constraint.c
index 2d2c90f9391..2c454448b9b 100644
--- a/source/blender/editors/physics/rigidbody_constraint.c
+++ b/source/blender/editors/physics/rigidbody_constraint.c
@@ -60,8 +60,9 @@ static bool ED_operator_rigidbody_con_active_poll(bContext *C)
Object *ob = CTX_data_active_object(C);
return (ob && ob->rigidbody_constraint);
}
- else
+ else {
return 0;
+ }
}
bool ED_rigidbody_constraint_add(
diff --git a/source/blender/editors/physics/rigidbody_object.c b/source/blender/editors/physics/rigidbody_object.c
index 2914127f8d8..ed6d31dfd9b 100644
--- a/source/blender/editors/physics/rigidbody_object.c
+++ b/source/blender/editors/physics/rigidbody_object.c
@@ -66,8 +66,9 @@ static bool ED_operator_rigidbody_active_poll(bContext *C)
Object *ob = ED_object_active_context(C);
return (ob && ob->rigidbody_object);
}
- else
+ else {
return 0;
+ }
}
static bool ED_operator_rigidbody_add_poll(bContext *C)
@@ -76,8 +77,9 @@ static bool ED_operator_rigidbody_add_poll(bContext *C)
Object *ob = ED_object_active_context(C);
return (ob && ob->type == OB_MESH);
}
- else
+ else {
return 0;
+ }
}
/* ----------------- */
@@ -506,8 +508,9 @@ static int rigidbody_objects_calc_mass_exec(bContext *C, wmOperator *op)
/* get density (kg/m^3) to apply */
if (material >= 0) {
/* get density from table, and store in props for later repeating */
- if (material >= NUM_RB_MATERIAL_PRESETS)
+ if (material >= NUM_RB_MATERIAL_PRESETS) {
material = 0;
+ }
density = RB_MATERIAL_DENSITY_TABLE[material].density;
RNA_float_set(op->ptr, "density", density);
diff --git a/source/blender/editors/physics/rigidbody_world.c b/source/blender/editors/physics/rigidbody_world.c
index 179a5a513f4..558a293ccbf 100644
--- a/source/blender/editors/physics/rigidbody_world.c
+++ b/source/blender/editors/physics/rigidbody_world.c
@@ -172,11 +172,13 @@ static int rigidbody_world_export_exec(bContext *C, wmOperator *op)
static int rigidbody_world_export_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
- if (!RNA_struct_property_is_set(op->ptr, "relative_path"))
+ if (!RNA_struct_property_is_set(op->ptr, "relative_path")) {
RNA_boolean_set(op->ptr, "relative_path", (U.flag & USER_RELPATHS) != 0);
+ }
- if (RNA_struct_property_is_set(op->ptr, "filepath"))
+ if (RNA_struct_property_is_set(op->ptr, "filepath")) {
return rigidbody_world_export_exec(C, op);
+ }
// TODO: use the actual rigidbody world's name + .bullet instead of this temp crap
RNA_string_set(op->ptr, "filepath", "rigidbodyworld_export.bullet");
diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c
index d9a68a060f8..8403f178284 100644
--- a/source/blender/editors/render/render_internal.c
+++ b/source/blender/editors/render/render_internal.c
@@ -149,19 +149,22 @@ static void image_buffer_rect_update(RenderJob *rj,
if (renrect) {
/* if (ymax == recty), rendering of layer is ready,
* we should not draw, other things happen... */
- if (rr->renlay == NULL || renrect->ymax >= rr->recty)
+ if (rr->renlay == NULL || renrect->ymax >= rr->recty) {
return;
+ }
/* xmin here is first subrect x coord, xmax defines subrect width */
xmin = renrect->xmin + rr->crop;
xmax = renrect->xmax - xmin + rr->crop;
- if (xmax < 2)
+ if (xmax < 2) {
return;
+ }
ymin = renrect->ymin + rr->crop;
ymax = renrect->ymax - ymin + rr->crop;
- if (ymax < 2)
+ if (ymax < 2) {
return;
+ }
renrect->ymin = renrect->ymax;
}
else {
@@ -172,19 +175,24 @@ static void image_buffer_rect_update(RenderJob *rj,
/* xmin ymin is in tile coords. transform to ibuf */
rxmin = rr->tilerect.xmin + xmin;
- if (rxmin >= ibuf->x)
+ if (rxmin >= ibuf->x) {
return;
+ }
rymin = rr->tilerect.ymin + ymin;
- if (rymin >= ibuf->y)
+ if (rymin >= ibuf->y) {
return;
+ }
- if (rxmin + xmax > ibuf->x)
+ if (rxmin + xmax > ibuf->x) {
xmax = ibuf->x - rxmin;
- if (rymin + ymax > ibuf->y)
+ }
+ if (rymin + ymax > ibuf->y) {
ymax = ibuf->y - rymin;
+ }
- if (xmax < 1 || ymax < 1)
+ if (xmax < 1 || ymax < 1) {
return;
+ }
/* The thing here is, the logic below (which was default behavior
* of how rectf is acquiring since forever) gives float buffer for
@@ -205,8 +213,9 @@ static void image_buffer_rect_update(RenderJob *rj,
rv = RE_RenderViewGetById(rr, view_id);
/* find current float rect for display, first case is after composite... still weak */
- if (rv->rectf)
+ if (rv->rectf) {
rectf = rv->rectf;
+ }
else {
if (rv->rect32) {
/* special case, currently only happens with sequencer rendering,
@@ -217,13 +226,15 @@ static void image_buffer_rect_update(RenderJob *rj,
return;
}
else {
- if (rr->renlay == NULL)
+ if (rr->renlay == NULL) {
return;
+ }
rectf = RE_RenderLayerGetPass(rr->renlay, RE_PASSNAME_COMBINED, viewname);
}
}
- if (rectf == NULL)
+ if (rectf == NULL) {
return;
+ }
rectf += 4 * (rr->rectx * ymin + xmin);
linear_stride = rr->rectx;
@@ -296,8 +307,9 @@ static void screen_render_single_layer_set(
RNA_string_get(op->ptr, "layer", rl_name);
rl = (ViewLayer *)BLI_findstring(&(*scene)->view_layers, rl_name, offsetof(ViewLayer, name));
- if (rl)
+ if (rl) {
*single_layer = rl;
+ }
}
else if (((*scene)->r.scemode & R_SINGLE_LAYER) && active_layer) {
*single_layer = active_layer;
@@ -351,7 +363,7 @@ static int screen_render_exec(bContext *C, wmOperator *op)
RE_SetReports(re, op->reports);
BLI_threaded_malloc_begin();
- if (is_animation)
+ if (is_animation) {
RE_BlenderAnim(re,
mainp,
scene,
@@ -360,9 +372,11 @@ static int screen_render_exec(bContext *C, wmOperator *op)
scene->r.sfra,
scene->r.efra,
scene->r.frame_step);
- else
+ }
+ else {
RE_BlenderFrame(
re, mainp, scene, single_layer, camera_override, scene->r.cfra, is_write_still);
+ }
BLI_threaded_malloc_end();
RE_SetReports(re, NULL);
@@ -404,10 +418,12 @@ static void make_renderinfo_string(const RenderStats *rs,
megs_peak_memory = (peak_memory) / (1024.0 * 1024.0);
/* local view */
- if (rs->localview)
+ if (rs->localview) {
spos += sprintf(spos, "%s | ", IFACE_("3D Local View"));
- else if (v3d_override)
+ }
+ else if (v3d_override) {
spos += sprintf(spos, "%s | ", IFACE_("3D View"));
+ }
/* frame number */
spos += sprintf(spos, IFACE_("Frame:%d "), (scene->r.cfra));
@@ -416,16 +432,19 @@ static void make_renderinfo_string(const RenderStats *rs,
BLI_timecode_string_from_time_simple(info_time_str, sizeof(info_time_str), rs->lastframetime);
if (rs->infostr && rs->infostr[0]) {
- if (rs->lastframetime != 0.0)
+ if (rs->lastframetime != 0.0) {
spos += sprintf(spos, IFACE_("| Last:%s "), info_time_str);
- else
+ }
+ else {
spos += sprintf(spos, "| ");
+ }
BLI_timecode_string_from_time_simple(
info_time_str, sizeof(info_time_str), PIL_check_seconds_timer() - rs->starttime);
}
- else
+ else {
spos += sprintf(spos, "| ");
+ }
spos += sprintf(spos, IFACE_("Time:%s "), info_time_str);
@@ -436,38 +455,49 @@ static void make_renderinfo_string(const RenderStats *rs,
}
}
else {
- if (rs->totvert || rs->totface || rs->tothalo || rs->totstrand || rs->totlamp)
+ if (rs->totvert || rs->totface || rs->tothalo || rs->totstrand || rs->totlamp) {
spos += sprintf(spos, "| ");
+ }
- if (rs->totvert)
+ if (rs->totvert) {
spos += sprintf(spos, IFACE_("Ve:%d "), rs->totvert);
- if (rs->totface)
+ }
+ if (rs->totface) {
spos += sprintf(spos, IFACE_("Fa:%d "), rs->totface);
- if (rs->tothalo)
+ }
+ if (rs->tothalo) {
spos += sprintf(spos, IFACE_("Ha:%d "), rs->tothalo);
- if (rs->totstrand)
+ }
+ if (rs->totstrand) {
spos += sprintf(spos, IFACE_("St:%d "), rs->totstrand);
- if (rs->totlamp)
+ }
+ if (rs->totlamp) {
spos += sprintf(spos, IFACE_("Li:%d "), rs->totlamp);
+ }
- if (rs->mem_peak == 0.0f)
+ if (rs->mem_peak == 0.0f) {
spos += sprintf(spos,
IFACE_("| Mem:%.2fM (%.2fM, Peak %.2fM) "),
megs_used_memory,
mmap_used_memory,
megs_peak_memory);
- else
+ }
+ else {
spos += sprintf(spos, IFACE_("| Mem:%.2fM, Peak: %.2fM "), rs->mem_used, rs->mem_peak);
+ }
- if (rs->curfield)
+ if (rs->curfield) {
spos += sprintf(spos, IFACE_("Field %d "), rs->curfield);
- if (rs->curblur)
+ }
+ if (rs->curblur) {
spos += sprintf(spos, IFACE_("Blur %d "), rs->curblur);
+ }
}
/* full sample */
- if (rs->curfsa)
+ if (rs->curfsa) {
spos += sprintf(spos, IFACE_("| Full Sample %d "), rs->curfsa);
+ }
/* extra info */
if (rs->infostr && rs->infostr[0]) {
@@ -478,9 +508,11 @@ static void make_renderinfo_string(const RenderStats *rs,
}
/* very weak... but 512 characters is quite safe */
- if (spos >= str + IMA_MAX_RENDER_TEXT)
- if (G.debug & G_DEBUG)
+ if (spos >= str + IMA_MAX_RENDER_TEXT) {
+ if (G.debug & G_DEBUG) {
printf("WARNING! renderwin text beyond limit\n");
+ }
+ }
}
static void image_renderinfo_cb(void *rjv, RenderStats *rs)
@@ -492,8 +524,9 @@ static void image_renderinfo_cb(void *rjv, RenderStats *rs)
if (rr) {
/* malloc OK here, stats_draw is not in tile threads */
- if (rr->text == NULL)
+ if (rr->text == NULL) {
rr->text = MEM_callocN(IMA_MAX_RENDER_TEXT, "rendertext");
+ }
make_renderinfo_string(rs, rj->scene, rj->v3d_override, rr->error, rr->text);
}
@@ -594,8 +627,9 @@ static void image_rect_update(void *rjv, RenderResult *rr, volatile rcti *renrec
return;
}
- if (rr == NULL)
+ if (rr == NULL) {
return;
+ }
/* update part of render */
render_image_update_pass_and_layer(rj, rr, &rj->iuser);
@@ -636,7 +670,7 @@ static void render_startjob(void *rjv, short *stop, short *do_update, float *pro
RE_SetReports(rj->re, rj->reports);
- if (rj->anim)
+ if (rj->anim) {
RE_BlenderAnim(rj->re,
rj->main,
rj->scene,
@@ -645,7 +679,8 @@ static void render_startjob(void *rjv, short *stop, short *do_update, float *pro
rj->scene->r.sfra,
rj->scene->r.efra,
rj->scene->r.frame_step);
- else
+ }
+ else {
RE_BlenderFrame(rj->re,
rj->main,
rj->scene,
@@ -653,6 +688,7 @@ static void render_startjob(void *rjv, short *stop, short *do_update, float *pro
rj->camera_override,
rj->scene->r.cfra,
rj->write_still);
+ }
RE_SetReports(rj->re, NULL);
}
@@ -703,8 +739,9 @@ static void render_endjob(void *rjv)
* to avoid referencing freed renderjobs bug T24508. */
RE_InitRenderCB(rj->re);
- if (rj->main != G_MAIN)
+ if (rj->main != G_MAIN) {
BKE_main_free(rj->main);
+ }
/* else the frame will not update for the original value */
if (rj->anim && !(rj->scene->r.scemode & R_NO_FRAME_UPDATE)) {
@@ -755,8 +792,9 @@ static void render_endjob(void *rjv)
Image *ima = rj->image;
ImBuf *ibuf = BKE_image_acquire_ibuf(ima, &rj->iuser, &lock);
- if (ibuf)
+ if (ibuf) {
ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID;
+ }
BKE_image_release_ibuf(ima, ibuf, lock);
}
@@ -777,10 +815,12 @@ static int render_breakjob(void *rjv)
{
RenderJob *rj = rjv;
- if (G.is_break)
+ if (G.is_break) {
return 1;
- if (rj->stop && *(rj->stop))
+ }
+ if (rj->stop && *(rj->stop)) {
return 1;
+ }
return 0;
}
@@ -788,8 +828,9 @@ static int render_breakjob(void *rjv)
* note: this wont check for the escape key being pressed, but doing so isnt threadsafe */
static int render_break(void *UNUSED(rjv))
{
- if (G.is_break)
+ if (G.is_break) {
return 1;
+ }
return 0;
}
@@ -905,8 +946,9 @@ static int screen_render_invoke(bContext *C, wmOperator *op, const wmEvent *even
screen_render_single_layer_set(op, bmain, active_layer, &scene, &single_layer);
/* only one render job at a time */
- if (WM_jobs_test(CTX_wm_manager(C), scene, WM_JOB_TYPE_RENDER))
+ if (WM_jobs_test(CTX_wm_manager(C), scene, WM_JOB_TYPE_RENDER)) {
return OPERATOR_CANCELLED;
+ }
if (!RE_is_rendering_allowed(scene, single_layer, camera_override, op->reports)) {
return OPERATOR_CANCELLED;
@@ -922,8 +964,9 @@ static int screen_render_invoke(bContext *C, wmOperator *op, const wmEvent *even
WM_jobs_kill_all_except(CTX_wm_manager(C), CTX_wm_screen(C));
/* cancel animation playback */
- if (ED_screen_animation_playing(CTX_wm_manager(C)))
+ if (ED_screen_animation_playing(CTX_wm_manager(C))) {
ED_screen_animation_play(C, 0, 0);
+ }
/* handle UI stuff */
WM_cursor_wait(1);
@@ -946,8 +989,9 @@ static int screen_render_invoke(bContext *C, wmOperator *op, const wmEvent *even
jobflag = WM_JOB_EXCL_RENDER | WM_JOB_PRIORITY | WM_JOB_PROGRESS;
- if (RNA_struct_property_is_set(op->ptr, "layer"))
+ if (RNA_struct_property_is_set(op->ptr, "layer")) {
jobflag |= WM_JOB_SUSPEND;
+ }
/* job custom data */
rj = MEM_callocN(sizeof(RenderJob), "render job");
@@ -977,8 +1021,9 @@ static int screen_render_invoke(bContext *C, wmOperator *op, const wmEvent *even
}
if (v3d) {
- if (camera_override && camera_override != scene->camera)
+ if (camera_override && camera_override != scene->camera) {
rj->v3d_override = true;
+ }
}
/* Lock the user interface depending on render settings. */
@@ -1000,10 +1045,12 @@ static int screen_render_invoke(bContext *C, wmOperator *op, const wmEvent *even
}
/* setup job */
- if (RE_seq_render_active(scene, &scene->r))
+ if (RE_seq_render_active(scene, &scene->r)) {
name = "Sequence Render";
- else
+ }
+ else {
name = "Render";
+ }
wm_job = WM_jobs_get(
CTX_wm_manager(C), CTX_wm_window(C), scene, name, jobflag, WM_JOB_TYPE_RENDER);
@@ -1109,8 +1156,9 @@ Scene *ED_render_job_get_scene(const bContext *C)
wmWindowManager *wm = CTX_wm_manager(C);
RenderJob *rj = (RenderJob *)WM_jobs_customdata_from_type(wm, WM_JOB_TYPE_RENDER);
- if (rj)
+ if (rj) {
return rj->scene;
+ }
return NULL;
}
diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c
index 6862881de59..41ef5d81901 100644
--- a/source/blender/editors/render/render_opengl.c
+++ b/source/blender/editors/render/render_opengl.c
@@ -154,8 +154,9 @@ static bool screen_opengl_is_multiview(OGLRender *oglrender)
RegionView3D *rv3d = oglrender->rv3d;
RenderData *rd = &oglrender->scene->r;
- if ((rd == NULL) || ((v3d != NULL) && (rv3d == NULL)))
+ if ((rd == NULL) || ((v3d != NULL) && (rv3d == NULL))) {
return false;
+ }
return (rd->scemode & R_MULTIVIEW) &&
((v3d == NULL) || (rv3d->persp == RV3D_CAMOB && v3d->camera));
@@ -189,14 +190,17 @@ static void screen_opengl_views_setup(OGLRender *oglrender)
RenderView *rv_del = rv->next;
BLI_remlink(&rr->views, rv_del);
- if (rv_del->rectf)
+ if (rv_del->rectf) {
MEM_freeN(rv_del->rectf);
+ }
- if (rv_del->rectz)
+ if (rv_del->rectz) {
MEM_freeN(rv_del->rectz);
+ }
- if (rv_del->rect32)
+ if (rv_del->rect32) {
MEM_freeN(rv_del->rect32);
+ }
MEM_freeN(rv_del);
}
@@ -219,14 +223,17 @@ static void screen_opengl_views_setup(OGLRender *oglrender)
BLI_remlink(&rr->views, rv_del);
- if (rv_del->rectf)
+ if (rv_del->rectf) {
MEM_freeN(rv_del->rectf);
+ }
- if (rv_del->rectz)
+ if (rv_del->rectz) {
MEM_freeN(rv_del->rectz);
+ }
- if (rv_del->rect32)
+ if (rv_del->rect32) {
MEM_freeN(rv_del->rect32);
+ }
MEM_freeN(rv_del);
}
@@ -234,8 +241,9 @@ static void screen_opengl_views_setup(OGLRender *oglrender)
/* create all the views that are needed */
for (srv = rd->views.first; srv; srv = srv->next) {
- if (BKE_scene_multiview_is_render_view_active(rd, srv) == false)
+ if (BKE_scene_multiview_is_render_view_active(rd, srv) == false) {
continue;
+ }
rv = BLI_findstring(&rr->views, srv->name, offsetof(SceneRenderView, name));
@@ -247,8 +255,9 @@ static void screen_opengl_views_setup(OGLRender *oglrender)
}
}
- if (!(is_multiview && BKE_scene_multiview_is_stereo3d(rd)))
+ if (!(is_multiview && BKE_scene_multiview_is_stereo3d(rd))) {
oglrender->iuser.flag &= ~IMA_SHOW_STEREO;
+ }
/* will only work for non multiview correctly */
if (v3d) {
@@ -431,10 +440,12 @@ static void screen_opengl_render_write(OGLRender *oglrender)
RE_ReleaseResultImage(oglrender->re);
- if (ok)
+ if (ok) {
printf("OpenGL Render written to '%s'\n", name);
- else
+ }
+ else {
printf("OpenGL Render failed to write '%s'\n", name);
+ }
}
static void UNUSED_FUNCTION(addAlphaOverFloat)(float dest[4], const float source[4])
@@ -551,8 +562,9 @@ static bool screen_opengl_render_init(bContext *C, wmOperator *op)
}
/* only one render job at a time */
- if (WM_jobs_test(wm, scene, WM_JOB_TYPE_RENDER))
+ if (WM_jobs_test(wm, scene, WM_JOB_TYPE_RENDER)) {
return false;
+ }
if (is_sequencer) {
is_view_context = false;
@@ -951,8 +963,9 @@ static bool screen_opengl_render_anim_step(bContext *C, wmOperator *op)
RenderResult *rr;
/* go to next frame */
- if (CFRA < oglrender->nfra)
+ if (CFRA < oglrender->nfra) {
CFRA++;
+ }
while (CFRA < oglrender->nfra) {
BKE_scene_graph_update_for_newframe(depsgraph, bmain);
CFRA++;
@@ -1035,8 +1048,9 @@ static int screen_opengl_render_modal(bContext *C, wmOperator *op, const wmEvent
return OPERATOR_FINISHED;
case TIMER:
/* render frame? */
- if (oglrender->timer == event->customdata)
+ if (oglrender->timer == event->customdata) {
break;
+ }
ATTR_FALLTHROUGH;
default:
/* nothing to do */
@@ -1068,12 +1082,14 @@ static int screen_opengl_render_invoke(bContext *C, wmOperator *op, const wmEven
OGLRender *oglrender;
const bool anim = RNA_boolean_get(op->ptr, "animation");
- if (!screen_opengl_render_init(C, op))
+ if (!screen_opengl_render_init(C, op)) {
return OPERATOR_CANCELLED;
+ }
if (anim) {
- if (!screen_opengl_render_anim_initialize(C, op))
+ if (!screen_opengl_render_anim_initialize(C, op)) {
return OPERATOR_CANCELLED;
+ }
}
oglrender = op->customdata;
@@ -1093,8 +1109,9 @@ static int screen_opengl_render_exec(bContext *C, wmOperator *op)
{
const bool is_animation = RNA_boolean_get(op->ptr, "animation");
- if (!screen_opengl_render_init(C, op))
+ if (!screen_opengl_render_init(C, op)) {
return OPERATOR_CANCELLED;
+ }
if (!is_animation) { /* same as invoke */
/* render image */
@@ -1106,8 +1123,9 @@ static int screen_opengl_render_exec(bContext *C, wmOperator *op)
else {
bool ret = true;
- if (!screen_opengl_render_anim_initialize(C, op))
+ if (!screen_opengl_render_anim_initialize(C, op)) {
return OPERATOR_CANCELLED;
+ }
while (ret) {
ret = screen_opengl_render_anim_step(C, op);
diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c
index 2804ea151d6..c9a4f1948ce 100644
--- a/source/blender/editors/render/render_preview.c
+++ b/source/blender/editors/render/render_preview.c
@@ -131,14 +131,16 @@ ImBuf *get_brush_icon(Brush *brush)
}
}
- if (brush->icon_imbuf)
+ if (brush->icon_imbuf) {
BKE_icon_changed(BKE_icon_id_ensure(&brush->id));
+ }
}
}
}
- if (!(brush->icon_imbuf))
+ if (!(brush->icon_imbuf)) {
brush->id.icon_id = 0;
+ }
return brush->icon_imbuf;
}
@@ -234,17 +236,20 @@ static bool check_engine_supports_preview(Scene *scene)
void ED_preview_free_dbase(void)
{
- if (G_pr_main)
+ if (G_pr_main) {
BKE_main_free(G_pr_main);
+ }
- if (G_pr_main_grease_pencil)
+ if (G_pr_main_grease_pencil) {
BKE_main_free(G_pr_main_grease_pencil);
+ }
}
static Scene *preview_get_scene(Main *pr_main)
{
- if (pr_main == NULL)
+ if (pr_main == NULL) {
return NULL;
+ }
return pr_main->scenes.first;
}
@@ -397,10 +402,12 @@ static Scene *preview_prepare_scene(
sce->r.tiley = sce->r.ysch / 4;
}
- if ((id && sp->pr_method == PR_ICON_RENDER) && id_type != ID_WO)
+ if ((id && sp->pr_method == PR_ICON_RENDER) && id_type != ID_WO) {
sce->r.alphamode = R_ALPHAPREMUL;
- else
+ }
+ else {
sce->r.alphamode = R_ADDSKY;
+ }
sce->r.cfra = scene->r.cfra;
@@ -461,8 +468,9 @@ static Scene *preview_prepare_scene(
Material ***matar = give_matarar(base->object);
int actcol = max_ii(base->object->actcol - 1, 0);
- if (matar && actcol < base->object->totcol)
+ if (matar && actcol < base->object->totcol) {
(*matar)[actcol] = mat;
+ }
}
else if (base->object->type == OB_LAMP) {
base->flag |= BASE_VISIBLE;
@@ -510,8 +518,9 @@ static Scene *preview_prepare_scene(
for (Base *base = view_layer->object_bases.first; base; base = base->next) {
if (base->object->id.name[2] == 'p') {
- if (base->object->type == OB_LAMP)
+ if (base->object->type == OB_LAMP) {
base->object->data = la;
+ }
}
}
@@ -562,10 +571,12 @@ static bool ed_preview_draw_rect(ScrArea *sa, int split, int first, rcti *rect,
int newy = BLI_rcti_size_y(rect);
bool ok = false;
- if (!split || first)
+ if (!split || first) {
sprintf(name, "Preview %p", (void *)sa);
- else
+ }
+ else {
sprintf(name, "SecondPreview %p", (void *)sa);
+ }
if (split) {
if (first) {
@@ -581,8 +592,9 @@ static bool ed_preview_draw_rect(ScrArea *sa, int split, int first, rcti *rect,
/* test if something rendered ok */
re = RE_GetRender(name);
- if (re == NULL)
+ if (re == NULL) {
return false;
+ }
RE_AcquireResultImageViews(re, &rres);
@@ -609,8 +621,9 @@ static bool ed_preview_draw_rect(ScrArea *sa, int split, int first, rcti *rect,
float fy = rect->ymin;
/* material preview only needs monoscopy (view 0) */
- if (re)
+ if (re) {
RE_AcquiredResultGet32(re, &rres, (unsigned int *)rect_byte, 0);
+ }
IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR);
immDrawPixelsTex(&state,
@@ -662,11 +675,13 @@ void ED_preview_draw(const bContext *C, void *idp, void *parentp, void *slotp, r
ok = ed_preview_draw_rect(sa, 1, 1, rect, &newrect);
ok &= ed_preview_draw_rect(sa, 1, 0, rect, &newrect);
}
- else
+ else {
ok = ed_preview_draw_rect(sa, 0, 0, rect, &newrect);
+ }
- if (ok)
+ if (ok) {
*rect = newrect;
+ }
/* start a new preview render job if signaled through sbuts->preview,
* if no render result was found and no preview render job is running,
@@ -712,26 +727,30 @@ static void shader_preview_updatejob(void *spv)
if (GS(sp->id->name) == ID_MA) {
Material *mat = (Material *)sp->id;
- if (sp->matcopy && mat->nodetree && sp->matcopy->nodetree)
+ if (sp->matcopy && mat->nodetree && sp->matcopy->nodetree) {
ntreeLocalSync(sp->matcopy->nodetree, mat->nodetree);
+ }
}
else if (GS(sp->id->name) == ID_TE) {
Tex *tex = (Tex *)sp->id;
- if (sp->texcopy && tex->nodetree && sp->texcopy->nodetree)
+ if (sp->texcopy && tex->nodetree && sp->texcopy->nodetree) {
ntreeLocalSync(sp->texcopy->nodetree, tex->nodetree);
+ }
}
else if (GS(sp->id->name) == ID_WO) {
World *wrld = (World *)sp->id;
- if (sp->worldcopy && wrld->nodetree && sp->worldcopy->nodetree)
+ if (sp->worldcopy && wrld->nodetree && sp->worldcopy->nodetree) {
ntreeLocalSync(sp->worldcopy->nodetree, wrld->nodetree);
+ }
}
else if (GS(sp->id->name) == ID_LA) {
Light *la = (Light *)sp->id;
- if (sp->lampcopy && la->nodetree && sp->lampcopy->nodetree)
+ if (sp->lampcopy && la->nodetree && sp->lampcopy->nodetree) {
ntreeLocalSync(sp->lampcopy->nodetree, la->nodetree);
+ }
}
}
}
@@ -809,10 +828,12 @@ static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int firs
/* in case of split preview, use border render */
if (split) {
- if (first)
+ if (first) {
sizex = sp->sizex / 2;
- else
+ }
+ else {
sizex = sp->sizex - sp->sizex / 2;
+ }
}
else {
sizex = sp->sizex;
@@ -828,18 +849,22 @@ static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int firs
/* get the stuff from the builtin preview dbase */
sce = preview_prepare_scene(sp->bmain, sp->scene, id_eval, idtype, sp);
- if (sce == NULL)
+ if (sce == NULL) {
return;
+ }
- if (!split || first)
+ if (!split || first) {
sprintf(name, "Preview %p", sp->owner);
- else
+ }
+ else {
sprintf(name, "SecondPreview %p", sp->owner);
+ }
re = RE_GetRender(name);
/* full refreshed render from first tile */
- if (re == NULL)
+ if (re == NULL) {
re = RE_NewRender(name);
+ }
/* sce->r gets copied in RE_InitState! */
sce->r.scemode &= ~(R_MATNODE_PREVIEW | R_TEXNODE_PREVIEW);
@@ -850,10 +875,12 @@ static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int firs
sce->r.mode |= R_OSA;
}
else if (sp->pr_method == PR_NODE_RENDER) {
- if (idtype == ID_MA)
+ if (idtype == ID_MA) {
sce->r.scemode |= R_MATNODE_PREVIEW;
- else if (idtype == ID_TE)
+ }
+ else if (idtype == ID_TE) {
sce->r.scemode |= R_TEXNODE_PREVIEW;
+ }
sce->r.mode &= ~R_OSA;
}
else { /* PR_BUTS_RENDER */
@@ -869,8 +896,9 @@ static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int firs
/* lens adjust */
oldlens = ((Camera *)sce->camera->data)->lens;
- if (sizex > sp->sizey)
+ if (sizex > sp->sizey) {
((Camera *)sce->camera->data)->lens *= (float)sp->sizey / (float)sizex;
+ }
/* entire cycle for render engine */
if (idtype == ID_TE) {
@@ -887,8 +915,9 @@ static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int firs
if (sp->pr_method == PR_ICON_RENDER) {
// char *rct= (char *)(sp->pr_rect + 32*16 + 16);
- if (sp->pr_rect)
+ if (sp->pr_rect) {
RE_ResultGet32(re, sp->pr_rect);
+ }
}
/* unassign the pointers, reset vars */
@@ -914,8 +943,9 @@ static void shader_preview_startjob(void *customdata, short *stop, short *do_upd
shader_preview_render(sp, sp->id, 1, 1);
shader_preview_render(sp, sp->parent, 1, 0);
}
- else
+ else {
shader_preview_render(sp, sp->id, 0, 0);
+ }
*do_update = true;
}
@@ -986,14 +1016,16 @@ static void icon_copy_rect(ImBuf *ibuf, unsigned int w, unsigned int h, unsigned
short ex, ey, dx, dy;
/* paranoia test */
- if (ibuf == NULL || (ibuf->rect == NULL && ibuf->rect_float == NULL))
+ if (ibuf == NULL || (ibuf->rect == NULL && ibuf->rect_float == NULL)) {
return;
+ }
/* waste of cpu cyles... but the imbuf API has no other way to scale fast (ton) */
ima = IMB_dupImBuf(ibuf);
- if (!ima)
+ if (!ima) {
return;
+ }
if (ima->x > ima->y) {
scaledx = (float)w;
@@ -1013,8 +1045,9 @@ static void icon_copy_rect(ImBuf *ibuf, unsigned int w, unsigned int h, unsigned
IMB_scalefastImBuf(ima, ex, ey);
/* if needed, convert to 32 bits */
- if (ima->rect == NULL)
+ if (ima->rect == NULL) {
IMB_rect_from_float(ima);
+ }
srect = ima->rect;
drect = rect;
@@ -1033,8 +1066,9 @@ static void set_alpha(char *cp, int sizex, int sizey, char alpha)
{
int a, size = sizex * sizey;
- for (a = 0; a < size; a++, cp += 4)
+ for (a = 0; a < size; a++, cp += 4) {
cp[3] = alpha;
+ }
}
static void icon_preview_startjob(void *customdata, short *stop, short *do_update)
@@ -1070,8 +1104,9 @@ static void icon_preview_startjob(void *customdata, short *stop, short *do_updat
ImageUser iuser = {NULL};
/* ima->ok is zero when Image cannot load */
- if (ima == NULL || ima->ok == 0)
+ if (ima == NULL || ima->ok == 0) {
return;
+ }
/* setup dummy image user */
iuser.ok = iuser.framenr = 1;
@@ -1099,8 +1134,9 @@ static void icon_preview_startjob(void *customdata, short *stop, short *do_updat
memset(sp->pr_rect, 0x88, sp->sizex * sp->sizey * sizeof(unsigned int));
- if (!(br->icon_imbuf) || !(br->icon_imbuf->rect))
+ if (!(br->icon_imbuf) || !(br->icon_imbuf->rect)) {
return;
+ }
icon_copy_rect(br->icon_imbuf, sp->sizex, sp->sizey, sp->pr_rect);
@@ -1135,10 +1171,12 @@ static void common_preview_startjob(void *customdata,
{
ShaderPreview *sp = customdata;
- if (ELEM(sp->pr_method, PR_ICON_RENDER, PR_ICON_DEFERRED))
+ if (ELEM(sp->pr_method, PR_ICON_RENDER, PR_ICON_DEFERRED)) {
icon_preview_startjob(customdata, stop, do_update);
- else
+ }
+ else {
shader_preview_startjob(customdata, stop, do_update);
+ }
}
/* exported functions */
@@ -1228,8 +1266,9 @@ static void icon_preview_endjob(void *customdata)
if (ip->id) {
- if (GS(ip->id->name) == ID_BR)
+ if (GS(ip->id->name) == ID_BR) {
WM_main_add_notifier(NC_BRUSH | NA_EDITED, ip->id);
+ }
#if 0
if (GS(ip->id->name) == ID_MA) {
Material *ma = (Material *)ip->id;
@@ -1319,8 +1358,9 @@ void ED_preview_icon_job(
/* render all resolutions from suspended job too */
old_ip = WM_jobs_customdata_get(wm_job);
- if (old_ip)
+ if (old_ip) {
BLI_movelisttolist(&ip->sizes, &old_ip->sizes);
+ }
/* customdata for preview thread */
ip->bmain = CTX_data_main(C);
@@ -1433,6 +1473,7 @@ void ED_preview_shader_job(const bContext *C,
void ED_preview_kill_jobs(wmWindowManager *wm, Main *UNUSED(bmain))
{
- if (wm)
+ if (wm) {
WM_jobs_kill(wm, NULL, common_preview_startjob);
+ }
}
diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c
index 70157abf2ef..3186f011c6a 100644
--- a/source/blender/editors/render/render_shading.c
+++ b/source/blender/editors/render/render_shading.c
@@ -131,8 +131,9 @@ static int material_slot_add_exec(bContext *C, wmOperator *UNUSED(op))
Main *bmain = CTX_data_main(C);
Object *ob = ED_object_context(C);
- if (!ob)
+ if (!ob) {
return OPERATOR_CANCELLED;
+ }
BKE_object_material_slot_add(bmain, ob);
@@ -168,8 +169,9 @@ static int material_slot_remove_exec(bContext *C, wmOperator *op)
{
Object *ob = ED_object_context(C);
- if (!ob)
+ if (!ob) {
return OPERATOR_CANCELLED;
+ }
/* Removing material slots in edit mode screws things up, see bug #21822.*/
if (ob == CTX_data_edit_object(C)) {
@@ -366,10 +368,12 @@ static int material_slot_de_select(bContext *C, bool select)
while (a--) {
if (bp->hide == 0) {
changed = true;
- if (select)
+ if (select) {
bp->f1 |= SELECT;
- else
+ }
+ else {
bp->f1 &= ~SELECT;
+ }
}
bp++;
}
@@ -435,13 +439,15 @@ static int material_slot_copy_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob = ED_object_context(C);
Material ***matar;
- if (!ob || !(matar = give_matarar(ob)))
+ if (!ob || !(matar = give_matarar(ob))) {
return OPERATOR_CANCELLED;
+ }
CTX_DATA_BEGIN (C, Object *, ob_iter, selected_editable_objects) {
if (ob != ob_iter && give_matarar(ob_iter)) {
- if (ob->data != ob_iter->data)
+ if (ob->data != ob_iter->data) {
assign_matarar(bmain, ob_iter, matar, ob->totcol);
+ }
if (ob_iter->totcol == ob->totcol) {
ob_iter->actcol = ob->actcol;
@@ -1026,8 +1032,9 @@ static int render_view_remove_exec(bContext *C, wmOperator *UNUSED(op))
Scene *scene = CTX_data_scene(C);
SceneRenderView *rv = BLI_findlink(&scene->r.views, scene->r.actview);
- if (!BKE_scene_remove_render_view(scene, rv))
+ if (!BKE_scene_remove_render_view(scene, rv)) {
return OPERATOR_CANCELLED;
+ }
WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, scene);
@@ -1544,14 +1551,18 @@ void SCENE_OT_freestyle_geometry_modifier_add(wmOperatorType *ot)
static int freestyle_get_modifier_type(PointerRNA *ptr)
{
- if (RNA_struct_is_a(ptr->type, &RNA_LineStyleColorModifier))
+ if (RNA_struct_is_a(ptr->type, &RNA_LineStyleColorModifier)) {
return LS_MODIFIER_TYPE_COLOR;
- else if (RNA_struct_is_a(ptr->type, &RNA_LineStyleAlphaModifier))
+ }
+ else if (RNA_struct_is_a(ptr->type, &RNA_LineStyleAlphaModifier)) {
return LS_MODIFIER_TYPE_ALPHA;
- else if (RNA_struct_is_a(ptr->type, &RNA_LineStyleThicknessModifier))
+ }
+ else if (RNA_struct_is_a(ptr->type, &RNA_LineStyleThicknessModifier)) {
return LS_MODIFIER_TYPE_THICKNESS;
- else if (RNA_struct_is_a(ptr->type, &RNA_LineStyleGeometryModifier))
+ }
+ else if (RNA_struct_is_a(ptr->type, &RNA_LineStyleGeometryModifier)) {
return LS_MODIFIER_TYPE_GEOMETRY;
+ }
return -1;
}
@@ -1831,8 +1842,9 @@ static int copy_material_exec(bContext *C, wmOperator *UNUSED(op))
{
Material *ma = CTX_data_pointer_get_type(C, "material", &RNA_Material).data;
- if (ma == NULL)
+ if (ma == NULL) {
return OPERATOR_CANCELLED;
+ }
copy_matcopybuf(CTX_data_main(C), ma);
@@ -1858,8 +1870,9 @@ static int paste_material_exec(bContext *C, wmOperator *UNUSED(op))
{
Material *ma = CTX_data_pointer_get_type(C, "material", &RNA_Material).data;
- if (ma == NULL)
+ if (ma == NULL) {
return OPERATOR_CANCELLED;
+ }
paste_matcopybuf(CTX_data_main(C), ma);
@@ -1919,8 +1932,9 @@ static void paste_mtex_copybuf(ID *id)
{
MTex **mtex = NULL;
- if (mtexcopied == 0 || mtexcopybuf.tex == NULL)
+ if (mtexcopied == 0 || mtexcopybuf.tex == NULL) {
return;
+ }
switch (GS(id->name)) {
case ID_PA:
@@ -1999,19 +2013,25 @@ static int paste_mtex_exec(bContext *C, wmOperator *UNUSED(op))
FreestyleLineStyle *linestyle =
CTX_data_pointer_get_type(C, "line_style", &RNA_FreestyleLineStyle).data;
- if (ma)
+ if (ma) {
id = &ma->id;
- else if (la)
+ }
+ else if (la) {
id = &la->id;
- else if (wo)
+ }
+ else if (wo) {
id = &wo->id;
- else if (psys)
+ }
+ else if (psys) {
id = &psys->part->id;
- else if (linestyle)
+ }
+ else if (linestyle) {
id = &linestyle->id;
+ }
- if (id == NULL)
+ if (id == NULL) {
return OPERATOR_CANCELLED;
+ }
}
paste_mtex_copybuf(id);
diff --git a/source/blender/editors/render/render_update.c b/source/blender/editors/render/render_update.c
index dfc7610946a..3f3f98bc6e5 100644
--- a/source/blender/editors/render/render_update.c
+++ b/source/blender/editors/render/render_update.c
@@ -81,16 +81,19 @@ void ED_render_scene_update(const DEGEditorUpdateContext *update_ctx, int update
/* don't do this render engine update if we're updating the scene from
* other threads doing e.g. rendering or baking jobs */
- if (!BLI_thread_is_main())
+ if (!BLI_thread_is_main()) {
return;
+ }
/* don't call this recursively for frame updates */
- if (recursive_check)
+ if (recursive_check) {
return;
+ }
/* Do not call if no WM available, see T42688. */
- if (BLI_listbase_is_empty(&bmain->wm))
+ if (BLI_listbase_is_empty(&bmain->wm)) {
return;
+ }
recursive_check = true;
@@ -160,12 +163,14 @@ void ED_render_engine_area_exit(Main *bmain, ScrArea *sa)
ARegion *ar;
wmWindowManager *wm = bmain->wm.first;
- if (sa->spacetype != SPACE_VIEW3D)
+ if (sa->spacetype != SPACE_VIEW3D) {
return;
+ }
for (ar = sa->regionbase.first; ar; ar = ar->next) {
- if (ar->regiontype != RGN_TYPE_WINDOW || !(ar->regiondata))
+ if (ar->regiontype != RGN_TYPE_WINDOW || !(ar->regiondata)) {
continue;
+ }
ED_view3d_stop_render_preview(wm, ar);
}
}
@@ -237,8 +242,9 @@ static void texture_changed(Main *bmain, Tex *tex)
/* find compositing nodes */
if (scene->use_nodes && scene->nodetree) {
for (node = scene->nodetree->nodes.first; node; node = node->next) {
- if (node->id == &tex->id)
+ if (node->id == &tex->id) {
ED_node_tag_update_id(&scene->id);
+ }
}
}
}
@@ -258,9 +264,11 @@ static void image_changed(Main *bmain, Image *ima)
BKE_icon_changed(BKE_icon_id_ensure(&ima->id));
/* textures */
- for (tex = bmain->textures.first; tex; tex = tex->id.next)
- if (tex->ima == ima)
+ for (tex = bmain->textures.first; tex; tex = tex->id.next) {
+ if (tex->ima == ima) {
texture_changed(bmain, tex);
+ }
+ }
}
static void scene_changed(Main *bmain, Scene *scene)
diff --git a/source/blender/editors/render/render_view.c b/source/blender/editors/render/render_view.c
index 258e98977c7..cd5edcdc3f4 100644
--- a/source/blender/editors/render/render_view.c
+++ b/source/blender/editors/render/render_view.c
@@ -92,12 +92,14 @@ static ScrArea *find_area_showing_r_result(bContext *C, Scene *scene, wmWindow *
for (sa = screen->areabase.first; sa; sa = sa->next) {
if (sa->spacetype == SPACE_IMAGE) {
sima = sa->spacedata.first;
- if (sima->image && sima->image->type == IMA_TYPE_R_RESULT)
+ if (sima->image && sima->image->type == IMA_TYPE_R_RESULT) {
break;
+ }
}
}
- if (sa)
+ if (sa) {
break;
+ }
}
}
@@ -114,8 +116,9 @@ static ScrArea *find_area_image_empty(bContext *C)
for (sa = sc->areabase.first; sa; sa = sa->next) {
if (sa->spacetype == SPACE_IMAGE) {
sima = sa->spacedata.first;
- if (!sima->image)
+ if (!sima->image) {
break;
+ }
}
}
@@ -134,18 +137,21 @@ ScrArea *render_view_open(bContext *C, int mx, int my, ReportList *reports)
SpaceImage *sima;
bool area_was_image = false;
- if (scene->r.displaymode == R_OUTPUT_NONE)
+ if (scene->r.displaymode == R_OUTPUT_NONE) {
return NULL;
+ }
if (scene->r.displaymode == R_OUTPUT_WINDOW) {
int sizex = 30 * UI_DPI_FAC + (scene->r.xsch * scene->r.size) / 100;
int sizey = 60 * UI_DPI_FAC + (scene->r.ysch * scene->r.size) / 100;
/* arbitrary... miniature image window views don't make much sense */
- if (sizex < 320)
+ if (sizex < 320) {
sizex = 320;
- if (sizey < 256)
+ }
+ if (sizey < 256) {
sizey = 256;
+ }
/* changes context! */
if (WM_window_open_temp(C, mx, my, sizex, sizey, WM_WINDOW_RENDER) == NULL) {
@@ -164,8 +170,9 @@ ScrArea *render_view_open(bContext *C, int mx, int my, ReportList *reports)
sa = NULL;
}
else {
- if (sa && sa->spacetype == SPACE_IMAGE)
+ if (sa && sa->spacetype == SPACE_IMAGE) {
area_was_image = true;
+ }
/* this function returns with changed context */
sa = ED_screen_full_newspace(C, sa, SPACE_IMAGE);
@@ -174,12 +181,14 @@ ScrArea *render_view_open(bContext *C, int mx, int my, ReportList *reports)
if (!sa) {
sa = find_area_showing_r_result(C, scene, &win);
- if (sa == NULL)
+ if (sa == NULL) {
sa = find_area_image_empty(C);
+ }
/* if area found in other window, we make that one show in front */
- if (win && win != CTX_wm_window(C))
+ if (win && win != CTX_wm_window(C)) {
wm_window_raise(win);
+ }
if (sa == NULL) {
/* find largest open non-image area */
@@ -221,8 +230,9 @@ ScrArea *render_view_open(bContext *C, int mx, int my, ReportList *reports)
/* Tell the image editor to revert to previous space in space list on close
* _only_ if it wasn't already an image editor when the render was invoked */
- if (area_was_image == 0)
+ if (area_was_image == 0) {
sima->flag |= SI_PREVSPACE;
+ }
else {
/* Leave it alone so the image editor will just go back from
* full screen to the original tiled setup */
diff --git a/source/blender/editors/scene/scene_edit.c b/source/blender/editors/scene/scene_edit.c
index 381b595171a..8834d243d4a 100644
--- a/source/blender/editors/scene/scene_edit.c
+++ b/source/blender/editors/scene/scene_edit.c
@@ -94,12 +94,15 @@ bool ED_scene_delete(bContext *C, Main *bmain, wmWindow *win, Scene *scene)
wmWindowManager *wm = bmain->wm.first;
WM_jobs_kill_type(wm, scene, WM_JOB_TYPE_ANY);
- if (scene->id.prev)
+ if (scene->id.prev) {
scene_new = scene->id.prev;
- else if (scene->id.next)
+ }
+ else if (scene->id.next) {
scene_new = scene->id.next;
- else
+ }
+ else {
return false;
+ }
WM_window_set_active_scene(bmain, C, win, scene_new);
@@ -245,8 +248,9 @@ static int scene_delete_exec(bContext *C, wmOperator *UNUSED(op))
return OPERATOR_CANCELLED;
}
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("scene delete %p\n", scene);
+ }
WM_event_add_notifier(C, NC_SCENE | NA_REMOVED, scene);
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index c38818f3032..5923d0373d5 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -151,16 +151,18 @@ void ED_region_do_listen(
/* generic notes first */
switch (note->category) {
case NC_WM:
- if (note->data == ND_FILEREAD)
+ if (note->data == ND_FILEREAD) {
ED_region_tag_redraw(ar);
+ }
break;
case NC_WINDOW:
ED_region_tag_redraw(ar);
break;
}
- if (ar->type && ar->type->listener)
+ if (ar->type && ar->type->listener) {
ar->type->listener(win, sa, ar, note, scene);
+ }
}
/* only exported for WM */
@@ -335,8 +337,9 @@ static void region_draw_azones(ScrArea *sa, ARegion *ar)
{
AZone *az;
- if (!sa)
+ if (!sa) {
return;
+ }
GPU_line_width(1.0f);
GPU_blend(true);
@@ -529,8 +532,9 @@ void ED_region_do_draw(bContext *C, ARegion *ar)
ARegionType *at = ar->type;
/* see BKE_spacedata_draw_locks() */
- if (at->do_lock)
+ if (at->do_lock) {
return;
+ }
ar->do_draw |= RGN_DRAWING;
@@ -657,8 +661,9 @@ void ED_region_tag_redraw(ARegion *ar)
void ED_region_tag_redraw_overlay(ARegion *ar)
{
- if (ar)
+ if (ar) {
ar->do_draw_overlay = RGN_DRAW;
+ }
}
void ED_region_tag_redraw_no_rebuild(ARegion *ar)
@@ -701,18 +706,22 @@ void ED_area_tag_redraw(ScrArea *sa)
{
ARegion *ar;
- if (sa)
- for (ar = sa->regionbase.first; ar; ar = ar->next)
+ if (sa) {
+ for (ar = sa->regionbase.first; ar; ar = ar->next) {
ED_region_tag_redraw(ar);
+ }
+ }
}
void ED_area_tag_redraw_no_rebuild(ScrArea *sa)
{
ARegion *ar;
- if (sa)
- for (ar = sa->regionbase.first; ar; ar = ar->next)
+ if (sa) {
+ for (ar = sa->regionbase.first; ar; ar = ar->next) {
ED_region_tag_redraw_no_rebuild(ar);
+ }
+ }
}
void ED_area_tag_redraw_regiontype(ScrArea *sa, int regiontype)
@@ -730,8 +739,9 @@ void ED_area_tag_redraw_regiontype(ScrArea *sa, int regiontype)
void ED_area_tag_refresh(ScrArea *sa)
{
- if (sa)
+ if (sa) {
sa->do_refresh = true;
+ }
}
/* *************************************************************** */
@@ -742,14 +752,16 @@ void ED_area_status_text(ScrArea *sa, const char *str)
ARegion *ar;
/* happens when running transform operators in background mode */
- if (sa == NULL)
+ if (sa == NULL) {
return;
+ }
for (ar = sa->regionbase.first; ar; ar = ar->next) {
if (ar->regiontype == RGN_TYPE_HEADER) {
if (str) {
- if (ar->headerstr == NULL)
+ if (ar->headerstr == NULL) {
ar->headerstr = MEM_mallocN(UI_MAX_DRAW_STR, "headerprint");
+ }
BLI_strncpy(ar->headerstr, str, UI_MAX_DRAW_STR);
BLI_str_rstrip(ar->headerstr);
}
@@ -768,12 +780,14 @@ void ED_workspace_status_text(bContext *C, const char *str)
WorkSpace *workspace = CTX_wm_workspace(C);
/* Can be NULL when running operators in background mode. */
- if (workspace == NULL)
+ if (workspace == NULL) {
return;
+ }
if (str) {
- if (workspace->status_text == NULL)
+ if (workspace->status_text == NULL) {
workspace->status_text = MEM_mallocN(UI_MAX_DRAW_STR, "headerprint");
+ }
BLI_strncpy(workspace->status_text, str, UI_MAX_DRAW_STR);
}
else if (workspace->status_text) {
@@ -866,8 +880,9 @@ static void fullscreen_azone_initialize(ScrArea *sa, ARegion *ar)
{
AZone *az;
- if (ED_area_is_global(sa) || (ar->regiontype != RGN_TYPE_WINDOW))
+ if (ED_area_is_global(sa) || (ar->regiontype != RGN_TYPE_WINDOW)) {
return;
+ }
az = (AZone *)MEM_callocN(sizeof(AZone), "fullscreen action zone");
BLI_addtail(&(sa->actionzones), az);
@@ -928,8 +943,9 @@ static void region_azone_tab_plus(ScrArea *sa, AZone *az, ARegion *ar)
const float tab_size_y = 0.4f * U.widget_unit;
for (azt = sa->actionzones.first; azt; azt = azt->next) {
- if (azt->edge == az->edge)
+ if (azt->edge == az->edge) {
tot++;
+ }
}
switch (az->edge) {
@@ -1057,14 +1073,18 @@ static void region_azones_add(const bScreen *screen, ScrArea *sa, ARegion *ar, c
}
/* edge code (t b l r) is along which area edge azone will be drawn */
- if (alignment == RGN_ALIGN_TOP)
+ if (alignment == RGN_ALIGN_TOP) {
region_azone_edge_initialize(sa, ar, AE_BOTTOM_TO_TOPLEFT, is_fullscreen);
- else if (alignment == RGN_ALIGN_BOTTOM)
+ }
+ else if (alignment == RGN_ALIGN_BOTTOM) {
region_azone_edge_initialize(sa, ar, AE_TOP_TO_BOTTOMRIGHT, is_fullscreen);
- else if (alignment == RGN_ALIGN_RIGHT)
+ }
+ else if (alignment == RGN_ALIGN_RIGHT) {
region_azone_edge_initialize(sa, ar, AE_LEFT_TO_TOPRIGHT, is_fullscreen);
- else if (alignment == RGN_ALIGN_LEFT)
+ }
+ else if (alignment == RGN_ALIGN_LEFT) {
region_azone_edge_initialize(sa, ar, AE_RIGHT_TO_TOPLEFT, is_fullscreen);
+ }
if (is_fullscreen) {
fullscreen_azone_initialize(sa, ar);
@@ -1191,8 +1211,9 @@ static void region_rect_recursive(
{
rcti *remainder_prev = remainder;
- if (ar == NULL)
+ if (ar == NULL) {
return;
+ }
int prev_winx = ar->winx;
int prev_winy = ar->winy;
@@ -1201,9 +1222,11 @@ static void region_rect_recursive(
BLI_rcti_init(&ar->winrct, 0, 0, 0, 0);
/* for test; allow split of previously defined region */
- if (ar->alignment & RGN_SPLIT_PREV)
- if (ar->prev)
+ if (ar->alignment & RGN_SPLIT_PREV) {
+ if (ar->prev) {
remainder = &ar->prev->winrct;
+ }
+ }
int alignment = ar->alignment & ~RGN_SPLIT_PREV;
@@ -1304,8 +1327,9 @@ static void region_rect_recursive(
else {
int fac = rct_fits(winrct, 'v', prefsizey);
- if (fac < 0)
+ if (fac < 0) {
prefsizey += fac;
+ }
ar->winrct = *winrct;
@@ -1328,8 +1352,9 @@ static void region_rect_recursive(
else {
int fac = rct_fits(winrct, 'h', prefsizex);
- if (fac < 0)
+ if (fac < 0) {
prefsizex += fac;
+ }
ar->winrct = *winrct;
@@ -1383,8 +1408,9 @@ static void region_rect_recursive(
if (count != 4) {
/* let's stop adding regions */
BLI_rcti_init(remainder, 0, 0, 0, 0);
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("region quadsplit failed\n");
+ }
}
else {
quad = 1;
@@ -1419,10 +1445,12 @@ static void region_rect_recursive(
/* if region opened normally, we store this for hide/reveal usage */
/* prevent rounding errors for UI_DPI_FAC mult and divide */
- if (ar->winx > 1)
+ if (ar->winx > 1) {
ar->sizex = (ar->winx + 0.5f) / UI_DPI_FAC;
- if (ar->winy > 1)
+ }
+ if (ar->winy > 1) {
ar->sizey = (ar->winy + 0.5f) / UI_DPI_FAC;
+ }
/* exception for multiple overlapping regions on same spot */
if (ar->overlap && (alignment != RGN_ALIGN_FLOAT)) {
@@ -1516,8 +1544,9 @@ static void region_subwindow(ARegion *ar)
{
bool hidden = (ar->flag & (RGN_FLAG_HIDDEN | RGN_FLAG_TOO_SMALL)) != 0;
- if ((ar->alignment & RGN_SPLIT_PREV) && ar->prev)
+ if ((ar->alignment & RGN_SPLIT_PREV) && ar->prev) {
hidden = hidden || (ar->prev->flag & (RGN_FLAG_HIDDEN | RGN_FLAG_TOO_SMALL));
+ }
ar->visible = !hidden;
}
@@ -1690,8 +1719,9 @@ void ED_area_initialize(wmWindowManager *wm, wmWindow *win, ScrArea *sa)
sa->type = BKE_spacetype_from_id(sa->spacetype);
}
- for (ar = sa->regionbase.first; ar; ar = ar->next)
+ for (ar = sa->regionbase.first; ar; ar = ar->next) {
ar->type = BKE_regiontype_from_id_or_first(sa->type, ar->regiontype);
+ }
/* area sizes */
area_calc_totrct(sa, &window_rect);
@@ -1705,8 +1735,9 @@ void ED_area_initialize(wmWindowManager *wm, wmWindow *win, ScrArea *sa)
/* default area handlers */
ed_default_handlers(wm, sa, NULL, &sa->handlers, sa->type->keymapflag);
/* checks spacedata, adds own handlers */
- if (sa->type->init)
+ if (sa->type->init) {
sa->type->init(wm, sa);
+ }
/* clear all azones, add the area triangle widgets */
area_azone_initialize(win, screen, sa);
@@ -1787,8 +1818,9 @@ void ED_region_cursor_set(wmWindow *win, ScrArea *sa, ARegion *ar)
/* for use after changing visibility of regions */
void ED_region_visibility_change_update(bContext *C, ScrArea *sa, ARegion *ar)
{
- if (ar->flag & RGN_FLAG_HIDDEN)
+ if (ar->flag & RGN_FLAG_HIDDEN) {
WM_event_remove_handlers(C, &ar->handlers);
+ }
ED_area_initialize(CTX_wm_manager(C), CTX_wm_window(C), sa);
ED_area_tag_redraw(sa);
@@ -1842,8 +1874,9 @@ void ED_area_data_copy(ScrArea *sa_dst, ScrArea *sa_src, const bool do_free)
/* regions */
if (do_free) {
st = BKE_spacetype_from_id(spacetype);
- for (ar = sa_dst->regionbase.first; ar; ar = ar->next)
+ for (ar = sa_dst->regionbase.first; ar; ar = ar->next) {
BKE_area_region_free(st, ar);
+ }
BLI_freelistN(&sa_dst->regionbase);
}
st = BKE_spacetype_from_id(sa_src->spacetype);
@@ -1940,9 +1973,11 @@ void ED_area_newspace(bContext *C, ScrArea *sa, int type, const bool skip_ar_exi
* (e.g. with properties editor) until space-data is properly created */
/* check previously stored space */
- for (sl = sa->spacedata.first; sl; sl = sl->next)
- if (sl->spacetype == type)
+ for (sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == type) {
break;
+ }
+ }
/* old spacedata... happened during work on 2.50, remove */
if (sl && BLI_listbase_is_empty(&sl->regionbase)) {
@@ -1973,8 +2008,9 @@ void ED_area_newspace(bContext *C, ScrArea *sa, int type, const bool skip_ar_exi
BLI_addhead(&sa->spacedata, sl);
/* swap regions */
- if (slold)
+ if (slold) {
slold->regionbase = sa->regionbase;
+ }
sa->regionbase = sl->regionbase;
BLI_listbase_clear(&sl->regionbase);
}
@@ -2269,8 +2305,9 @@ void ED_region_panels_layout_ex(
BLI_SMALLSTACK_DECLARE(pt_stack, PanelType *);
- if (contextnr != -1)
+ if (contextnr != -1) {
is_context_new = UI_view2d_tab_set(v2d, contextnr);
+ }
/* before setting the view */
if (vertical) {
@@ -2560,15 +2597,17 @@ void ED_region_header_layout(const bContext *C, ARegion *ar)
/* for view2d */
xco = uiLayoutGetWidth(layout);
- if (xco > maxco)
+ if (xco > maxco) {
maxco = xco;
+ }
}
UI_block_layout_resolve(block, &xco, &yco);
/* for view2d */
- if (xco > maxco)
+ if (xco > maxco) {
maxco = xco;
+ }
int new_sizex = (maxco + UI_HEADER_OFFSET) / UI_DPI_FAC;
@@ -2909,8 +2948,9 @@ static void metadata_draw_imbuf(ImBuf *ibuf, const rctf *rect, int fontid, const
do_newline = true;
}
- if (do_newline)
+ if (do_newline) {
ofs_y += vertical_offset;
+ }
} /* Strip */
else if (i == 1 || i == 2) {
len = BLI_snprintf_rlen(temp_str, MAX_METADATA_STR, "%s: ", meta_data_list[i + 1]);
@@ -3042,8 +3082,9 @@ void ED_region_image_metadata_draw(
rctf rect;
uiStyle *style = UI_style_get_dpi();
- if (!ibuf->metadata)
+ if (!ibuf->metadata) {
return;
+ }
/* find window pixel coordinates of origin */
GPU_matrix_push();
@@ -3145,8 +3186,9 @@ void ED_region_grid_draw(ARegion *ar, float zoomx, float zoomy)
/* gridsize adapted to zoom level */
gridsize = 0.5f * (zoomx + zoomy);
- if (gridsize <= 0.0f)
+ if (gridsize <= 0.0f) {
return;
+ }
if (gridsize < 1.0f) {
while (gridsize < 1.0f) {
@@ -3222,8 +3264,9 @@ void ED_region_visible_rect(ARegion *ar, rcti *rect)
ARegion *arn = ar;
/* allow function to be called without area */
- while (arn->prev)
+ while (arn->prev) {
arn = arn->prev;
+ }
*rect = ar->winrct;
diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c
index a3273481829..fc771e0db77 100644
--- a/source/blender/editors/screen/glutil.c
+++ b/source/blender/editors/screen/glutil.c
@@ -172,12 +172,15 @@ void immDrawPixelsTexScaled_clipping(IMMDrawPixelsTexState *state,
nsubparts_x = (img_w + (offset_x - 1)) / (offset_x);
nsubparts_y = (img_h + (offset_y - 1)) / (offset_y);
- if (format == GL_RGBA)
+ if (format == GL_RGBA) {
components = 4;
- else if (format == GL_RGB)
+ }
+ else if (format == GL_RGB) {
components = 3;
- else if (format == GL_RED)
+ }
+ else if (format == GL_RED) {
components = 1;
+ }
else {
BLI_assert(!"Incompatible format passed to glaDrawPixelsTexScaled");
return;
@@ -215,8 +218,9 @@ void immDrawPixelsTexScaled_clipping(IMMDrawPixelsTexState *state,
float rast_x = x + subpart_x * offset_x * xzoom;
float rast_y = y + subpart_y * offset_y * yzoom;
/* check if we already got these because we always get 2 more when doing seamless */
- if (subpart_w <= seamless || subpart_h <= seamless)
+ if (subpart_w <= seamless || subpart_h <= seamless) {
continue;
+ }
if (use_clipping) {
if (rast_x + (float)(subpart_w - offset_right) * xzoom * scaleX < clip_min_x ||
@@ -242,7 +246,7 @@ void immDrawPixelsTexScaled_clipping(IMMDrawPixelsTexState *state,
subpart_x * offset_x * components]);
/* add an extra border of pixels so linear looks ok at edges of full image */
- if (subpart_w < tex_w)
+ if (subpart_w < tex_w) {
glTexSubImage2D(GL_TEXTURE_2D,
0,
subpart_w,
@@ -253,7 +257,8 @@ void immDrawPixelsTexScaled_clipping(IMMDrawPixelsTexState *state,
GL_FLOAT,
&f_rect[((size_t)subpart_y) * offset_y * img_w * components +
(subpart_x * offset_x + subpart_w - 1) * components]);
- if (subpart_h < tex_h)
+ }
+ if (subpart_h < tex_h) {
glTexSubImage2D(
GL_TEXTURE_2D,
0,
@@ -265,7 +270,8 @@ void immDrawPixelsTexScaled_clipping(IMMDrawPixelsTexState *state,
GL_FLOAT,
&f_rect[(((size_t)subpart_y) * offset_y + subpart_h - 1) * img_w * components +
subpart_x * offset_x * components]);
- if (subpart_w < tex_w && subpart_h < tex_h)
+ }
+ if (subpart_w < tex_w && subpart_h < tex_h) {
glTexSubImage2D(
GL_TEXTURE_2D,
0,
@@ -277,6 +283,7 @@ void immDrawPixelsTexScaled_clipping(IMMDrawPixelsTexState *state,
GL_FLOAT,
&f_rect[(((size_t)subpart_y) * offset_y + subpart_h - 1) * img_w * components +
(subpart_x * offset_x + subpart_w - 1) * components]);
+ }
}
else {
glTexSubImage2D(GL_TEXTURE_2D,
@@ -290,7 +297,7 @@ void immDrawPixelsTexScaled_clipping(IMMDrawPixelsTexState *state,
&uc_rect[((size_t)subpart_y) * offset_y * img_w * components +
subpart_x * offset_x * components]);
- if (subpart_w < tex_w)
+ if (subpart_w < tex_w) {
glTexSubImage2D(GL_TEXTURE_2D,
0,
subpart_w,
@@ -301,7 +308,8 @@ void immDrawPixelsTexScaled_clipping(IMMDrawPixelsTexState *state,
GL_UNSIGNED_BYTE,
&uc_rect[((size_t)subpart_y) * offset_y * img_w * components +
(subpart_x * offset_x + subpart_w - 1) * components]);
- if (subpart_h < tex_h)
+ }
+ if (subpart_h < tex_h) {
glTexSubImage2D(
GL_TEXTURE_2D,
0,
@@ -313,7 +321,8 @@ void immDrawPixelsTexScaled_clipping(IMMDrawPixelsTexState *state,
GL_UNSIGNED_BYTE,
&uc_rect[(((size_t)subpart_y) * offset_y + subpart_h - 1) * img_w * components +
subpart_x * offset_x * components]);
- if (subpart_w < tex_w && subpart_h < tex_h)
+ }
+ if (subpart_w < tex_w && subpart_h < tex_h) {
glTexSubImage2D(
GL_TEXTURE_2D,
0,
@@ -325,6 +334,7 @@ void immDrawPixelsTexScaled_clipping(IMMDrawPixelsTexState *state,
GL_UNSIGNED_BYTE,
&uc_rect[(((size_t)subpart_y) * offset_y + subpart_h - 1) * img_w * components +
(subpart_x * offset_x + subpart_w - 1) * components]);
+ }
}
immBegin(GPU_PRIM_TRI_FAN, 4);
@@ -552,8 +562,9 @@ void ED_draw_imbuf_clipping(ImBuf *ibuf,
bool need_fallback = true;
/* Early out */
- if (ibuf->rect == NULL && ibuf->rect_float == NULL)
+ if (ibuf->rect == NULL && ibuf->rect_float == NULL) {
return;
+ }
/* Single channel images could not be transformed using GLSL yet */
force_fallback |= ibuf->channels == 1;
@@ -589,12 +600,15 @@ void ED_draw_imbuf_clipping(ImBuf *ibuf,
if (ibuf->rect_float) {
int format = 0;
- if (ibuf->channels == 3)
+ if (ibuf->channels == 3) {
format = GL_RGB;
- else if (ibuf->channels == 4)
+ }
+ else if (ibuf->channels == 4) {
format = GL_RGBA;
- else
+ }
+ else {
BLI_assert(!"Incompatible number of channels for GLSL display");
+ }
if (format != 0) {
immDrawPixelsTex_clipping(&state,
diff --git a/source/blender/editors/screen/screen_context.c b/source/blender/editors/screen/screen_context.c
index 00942a4d1b8..6dcb9f8a82c 100644
--- a/source/blender/editors/screen/screen_context.c
+++ b/source/blender/editors/screen/screen_context.c
@@ -276,8 +276,9 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
* We need to make sure that these mirrored copies are not selected, otherwise some
* bones will be operated on twice.
*/
- if (arm->flag & ARM_MIRROR_EDIT)
+ if (arm->flag & ARM_MIRROR_EDIT) {
flipbone = ED_armature_ebone_get_mirrored(arm->edbo, ebone);
+ }
/* if we're filtering for editable too, use the check for that instead,
* as it has selection check too */
@@ -286,16 +287,18 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
if (EBONE_EDITABLE(ebone)) {
CTX_data_list_add(result, &arm->id, &RNA_EditBone, ebone);
- if ((flipbone) && !(flipbone->flag & BONE_SELECTED))
+ if ((flipbone) && !(flipbone->flag & BONE_SELECTED)) {
CTX_data_list_add(result, &arm->id, &RNA_EditBone, flipbone);
+ }
}
}
else {
/* only include bones if visible */
CTX_data_list_add(result, &arm->id, &RNA_EditBone, ebone);
- if ((flipbone) && EBONE_VISIBLE(arm, flipbone) == 0)
+ if ((flipbone) && EBONE_VISIBLE(arm, flipbone) == 0) {
CTX_data_list_add(result, &arm->id, &RNA_EditBone, flipbone);
+ }
}
}
}
@@ -330,8 +333,9 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
* We need to make sure that these mirrored copies are not selected, otherwise some
* bones will be operated on twice.
*/
- if (arm->flag & ARM_MIRROR_EDIT)
+ if (arm->flag & ARM_MIRROR_EDIT) {
flipbone = ED_armature_ebone_get_mirrored(arm->edbo, ebone);
+ }
/* if we're filtering for editable too, use the check for that instead,
* as it has selection check too */
@@ -340,16 +344,18 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
if (EBONE_EDITABLE(ebone)) {
CTX_data_list_add(result, &arm->id, &RNA_EditBone, ebone);
- if ((flipbone) && !(flipbone->flag & BONE_SELECTED))
+ if ((flipbone) && !(flipbone->flag & BONE_SELECTED)) {
CTX_data_list_add(result, &arm->id, &RNA_EditBone, flipbone);
+ }
}
}
else {
/* only include bones if selected */
CTX_data_list_add(result, &arm->id, &RNA_EditBone, ebone);
- if ((flipbone) && !(flipbone->flag & BONE_SELECTED))
+ if ((flipbone) && !(flipbone->flag & BONE_SELECTED)) {
CTX_data_list_add(result, &arm->id, &RNA_EditBone, flipbone);
+ }
}
}
}
@@ -451,57 +457,66 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
}
}
else if (CTX_data_equals(member, "active_base")) {
- if (view_layer->basact)
+ if (view_layer->basact) {
CTX_data_pointer_set(result, &scene->id, &RNA_ObjectBase, view_layer->basact);
+ }
return 1;
}
else if (CTX_data_equals(member, "active_object")) {
- if (obact)
+ if (obact) {
CTX_data_id_pointer_set(result, &obact->id);
+ }
return 1;
}
else if (CTX_data_equals(member, "object")) {
- if (obact)
+ if (obact) {
CTX_data_id_pointer_set(result, &obact->id);
+ }
return 1;
}
else if (CTX_data_equals(member, "edit_object")) {
/* convenience for now, 1 object per scene in editmode */
- if (obedit)
+ if (obedit) {
CTX_data_id_pointer_set(result, &obedit->id);
+ }
return 1;
}
else if (CTX_data_equals(member, "sculpt_object")) {
- if (obact && (obact->mode & OB_MODE_SCULPT))
+ if (obact && (obact->mode & OB_MODE_SCULPT)) {
CTX_data_id_pointer_set(result, &obact->id);
+ }
return 1;
}
else if (CTX_data_equals(member, "vertex_paint_object")) {
- if (obact && (obact->mode & OB_MODE_VERTEX_PAINT))
+ if (obact && (obact->mode & OB_MODE_VERTEX_PAINT)) {
CTX_data_id_pointer_set(result, &obact->id);
+ }
return 1;
}
else if (CTX_data_equals(member, "weight_paint_object")) {
- if (obact && (obact->mode & OB_MODE_WEIGHT_PAINT))
+ if (obact && (obact->mode & OB_MODE_WEIGHT_PAINT)) {
CTX_data_id_pointer_set(result, &obact->id);
+ }
return 1;
}
else if (CTX_data_equals(member, "image_paint_object")) {
- if (obact && (obact->mode & OB_MODE_TEXTURE_PAINT))
+ if (obact && (obact->mode & OB_MODE_TEXTURE_PAINT)) {
CTX_data_id_pointer_set(result, &obact->id);
+ }
return 1;
}
else if (CTX_data_equals(member, "particle_edit_object")) {
- if (obact && (obact->mode & OB_MODE_PARTICLE_EDIT))
+ if (obact && (obact->mode & OB_MODE_PARTICLE_EDIT)) {
CTX_data_id_pointer_set(result, &obact->id);
+ }
return 1;
}
@@ -730,8 +745,9 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
for (ale = anim_data.first; ale; ale = ale->next) {
- if (ale->type == ANIMTYPE_FCURVE)
+ if (ale->type == ANIMTYPE_FCURVE) {
CTX_data_list_add(result, ale->id, &RNA_FCurve, ale->data);
+ }
}
ANIM_animdata_freelist(&anim_data);
diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c
index d9e7a50c646..95bade1da64 100644
--- a/source/blender/editors/screen/screen_edit.c
+++ b/source/blender/editors/screen/screen_edit.c
@@ -113,14 +113,16 @@ ScrArea *area_split(const wmWindow *win, bScreen *sc, ScrArea *sa, char dir, flo
short split;
rcti window_rect;
- if (sa == NULL)
+ if (sa == NULL) {
return NULL;
+ }
WM_window_rect_calc(win, &window_rect);
split = screen_geom_find_area_split_point(sa, &window_rect, dir, fac);
- if (split == 0)
+ if (split == 0) {
return NULL;
+ }
/* note regarding (fac > 0.5f) checks below.
* normally it shouldn't matter which is used since the copy should match the original
@@ -190,8 +192,9 @@ ScrArea *area_split(const wmWindow *win, bScreen *sc, ScrArea *sa, char dir, flo
}
/* remove double vertices en edges */
- if (merge)
+ if (merge) {
BKE_screen_remove_double_scrverts(sc);
+ }
BKE_screen_remove_double_scredges(sc);
BKE_screen_remove_unused_scredges(sc);
@@ -269,8 +272,9 @@ void screen_data_copy(bScreen *to, bScreen *from)
}
/* put at zero (needed?) */
- for (s1 = from->vertbase.first; s1; s1 = s1->next)
+ for (s1 = from->vertbase.first; s1; s1 = s1->next) {
s1->newv = NULL;
+ }
}
/**
@@ -291,8 +295,9 @@ int area_getorientation(ScrArea *sa, ScrArea *sb)
ScrVert *sav1, *sav2, *sav3, *sav4;
ScrVert *sbv1, *sbv2, *sbv3, *sbv4;
- if (sa == NULL || sb == NULL)
+ if (sa == NULL || sb == NULL) {
return -1;
+ }
sav1 = sa->v1;
sav2 = sa->v2;
@@ -399,19 +404,22 @@ void ED_screen_do_listen(bContext *C, wmNotifier *note)
/* generic notes */
switch (note->category) {
case NC_WM:
- if (note->data == ND_FILEREAD)
+ if (note->data == ND_FILEREAD) {
screen->do_draw = true;
+ }
break;
case NC_WINDOW:
screen->do_draw = true;
break;
case NC_SCREEN:
- if (note->action == NA_EDITED)
+ if (note->action == NA_EDITED) {
screen->do_draw = screen->do_refresh = true;
+ }
break;
case NC_SCENE:
- if (note->data == ND_MODE)
+ if (note->data == ND_MODE) {
region_cursor_set(win, true);
+ }
break;
}
}
@@ -425,16 +433,19 @@ static void screen_refresh_headersizes(void)
for (st = lb->first; st; st = st->next) {
ARegionType *art;
art = BKE_regiontype_from_id(st, RGN_TYPE_HEADER);
- if (art)
+ if (art) {
art->prefsizey = ED_area_headersize();
+ }
art = BKE_regiontype_from_id(st, RGN_TYPE_TOOL_HEADER);
- if (art)
+ if (art) {
art->prefsizey = ED_area_headersize();
+ }
art = BKE_regiontype_from_id(st, RGN_TYPE_FOOTER);
- if (art)
+ if (art) {
art->prefsizey = ED_area_headersize();
+ }
}
}
@@ -462,8 +473,9 @@ void ED_screen_refresh(wmWindowManager *wm, wmWindow *win)
}
/* wake up animtimer */
- if (screen->animtimer)
+ if (screen->animtimer) {
WM_event_timer_sleep(wm, win, screen->animtimer, false);
+ }
}
if (G.debug & G_DEBUG_EVENTS) {
@@ -514,8 +526,9 @@ void ED_region_exit(bContext *C, ARegion *ar)
wmWindow *win = CTX_wm_window(C);
ARegion *prevar = CTX_wm_region(C);
- if (ar->type && ar->type->exit)
+ if (ar->type && ar->type->exit) {
ar->type->exit(wm, ar);
+ }
CTX_wm_region_set(C, ar);
@@ -545,13 +558,15 @@ void ED_area_exit(bContext *C, ScrArea *sa)
ScrArea *prevsa = CTX_wm_area(C);
ARegion *ar;
- if (sa->type && sa->type->exit)
+ if (sa->type && sa->type->exit) {
sa->type->exit(wm, sa);
+ }
CTX_wm_area_set(C, sa);
- for (ar = sa->regionbase.first; ar; ar = ar->next)
+ for (ar = sa->regionbase.first; ar; ar = ar->next) {
ED_region_exit(C, ar);
+ }
WM_event_remove_handlers(C, &sa->handlers);
WM_event_modal_handler_area_replace(win, sa, NULL);
@@ -566,8 +581,9 @@ void ED_screen_exit(bContext *C, wmWindow *window, bScreen *screen)
CTX_wm_window_set(C, window);
- if (screen->animtimer)
+ if (screen->animtimer) {
WM_event_remove_timer(wm, window, screen->animtimer);
+ }
screen->animtimer = NULL;
screen->scrubbing = false;
@@ -606,31 +622,39 @@ static void screen_cursor_set(wmWindow *win, const int xy[2])
AZone *az = NULL;
ScrArea *sa;
- for (sa = screen->areabase.first; sa; sa = sa->next)
- if ((az = ED_area_actionzone_find_xy(sa, xy)))
+ for (sa = screen->areabase.first; sa; sa = sa->next) {
+ if ((az = ED_area_actionzone_find_xy(sa, xy))) {
break;
+ }
+ }
if (sa) {
- if (az->type == AZONE_AREA)
+ if (az->type == AZONE_AREA) {
WM_cursor_set(win, CURSOR_EDIT);
+ }
else if (az->type == AZONE_REGION) {
- if (az->edge == AE_LEFT_TO_TOPRIGHT || az->edge == AE_RIGHT_TO_TOPLEFT)
+ if (az->edge == AE_LEFT_TO_TOPRIGHT || az->edge == AE_RIGHT_TO_TOPLEFT) {
WM_cursor_set(win, CURSOR_X_MOVE);
- else
+ }
+ else {
WM_cursor_set(win, CURSOR_Y_MOVE);
+ }
}
}
else {
ScrEdge *actedge = screen_geom_find_active_scredge(win, screen, xy[0], xy[1]);
if (actedge) {
- if (screen_geom_edge_is_horizontal(actedge))
+ if (screen_geom_edge_is_horizontal(actedge)) {
WM_cursor_set(win, CURSOR_Y_MOVE);
- else
+ }
+ else {
WM_cursor_set(win, CURSOR_X_MOVE);
+ }
}
- else
+ else {
WM_cursor_set(win, CURSOR_STD);
+ }
}
}
@@ -665,8 +689,9 @@ void ED_screen_set_active_region(bContext *C, wmWindow *win, const int xy[2])
}
}
}
- else
+ else {
scr->active_region = NULL;
+ }
/* check for redraw headers */
if (old_ar != scr->active_region) {
@@ -707,8 +732,9 @@ void ED_screen_set_active_region(bContext *C, wmWindow *win, const int xy[2])
UI_screen_free_active_but(C, scr);
}
}
- else
+ else {
region_cursor_set(win, false);
+ }
}
}
}
@@ -723,12 +749,15 @@ int ED_screen_area_active(const bContext *C)
AZone *az = ED_area_actionzone_find_xy(sa, &win->eventstate->x);
ARegion *ar;
- if (az && az->type == AZONE_REGION)
+ if (az && az->type == AZONE_REGION) {
return 1;
+ }
- for (ar = sa->regionbase.first; ar; ar = ar->next)
- if (ar == sc->active_region)
+ for (ar = sa->regionbase.first; ar; ar = ar->next) {
+ if (ar == sc->active_region) {
return 1;
+ }
+ }
}
return 0;
}
@@ -994,10 +1023,12 @@ static void screen_set_3dview_camera(Scene *scene, ViewLayer *view_layer, ScrAre
ListBase *regionbase;
/* regionbase is in different place depending if space is active */
- if (v3d == sa->spacedata.first)
+ if (v3d == sa->spacedata.first) {
regionbase = &sa->regionbase;
- else
+ }
+ else {
regionbase = &v3d->regionbase;
+ }
for (ar = regionbase->first; ar; ar = ar->next) {
if (ar->regiontype == RGN_TYPE_WINDOW) {
@@ -1194,8 +1225,9 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *sa, const s
sa->full = NULL;
if (fullsa == NULL) {
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("%s: something wrong in areafullscreen\n", __func__);
+ }
return NULL;
}
@@ -1310,9 +1342,10 @@ void ED_refresh_viewport_fps(bContext *C)
ScreenFrameRateInfo *fpsi = scene->fps_info;
/* if there isn't any info, init it first */
- if (fpsi == NULL)
+ if (fpsi == NULL) {
fpsi = scene->fps_info = MEM_callocN(sizeof(ScreenFrameRateInfo),
"refresh_viewport_fps fps_info");
+ }
/* update the values */
fpsi->redrawtime = fpsi->lredrawtime;
@@ -1320,8 +1353,9 @@ void ED_refresh_viewport_fps(bContext *C)
}
else {
/* playback stopped or shouldn't be running */
- if (scene->fps_info)
+ if (scene->fps_info) {
MEM_freeN(scene->fps_info);
+ }
scene->fps_info = NULL;
}
}
@@ -1355,16 +1389,18 @@ void ED_screen_animation_timer(bContext *C, int redraws, int refresh, int sync,
sad->sfra = scene->r.cfra;
scene->r.cfra = scene->r.psfra;
}
- else
+ else {
sad->sfra = scene->r.cfra;
+ }
}
else {
if (scene->r.sfra > scene->r.cfra) {
sad->sfra = scene->r.cfra;
scene->r.cfra = scene->r.sfra;
}
- else
+ else {
sad->sfra = scene->r.cfra;
+ }
}
sad->redraws = redraws;
sad->refresh = refresh;
@@ -1375,8 +1411,9 @@ void ED_screen_animation_timer(bContext *C, int redraws, int refresh, int sync,
char spacetype = -1;
- if (sa)
+ if (sa) {
spacetype = sa->spacetype;
+ }
sad->from_anim_edit = (ELEM(spacetype, SPACE_GRAPH, SPACE_ACTION, SPACE_NLA));
@@ -1420,8 +1457,9 @@ void ED_screen_animation_timer_update(bScreen *screen, int redraws, int refresh)
sad->redraws = redraws;
sad->refresh = refresh;
sad->ar = NULL;
- if (redraws & TIME_REGION)
+ if (redraws & TIME_REGION) {
sad->ar = time_top_left_3dwindow(screen);
+ }
}
}
@@ -1462,8 +1500,9 @@ bool ED_screen_stereo3d_required(const bScreen *screen, const Scene *scene)
case SPACE_VIEW3D: {
View3D *v3d;
- if (!is_multiview)
+ if (!is_multiview) {
continue;
+ }
v3d = sa->spacedata.first;
if (v3d->camera && v3d->stereo3d_camera == STEREO_3D_ID) {
@@ -1494,8 +1533,9 @@ bool ED_screen_stereo3d_required(const bScreen *screen, const Scene *scene)
case SPACE_NODE: {
SpaceNode *snode;
- if (!is_multiview)
+ if (!is_multiview) {
continue;
+ }
snode = sa->spacedata.first;
if ((snode->flag & SNODE_BACKDRAW) && ED_node_is_compositor(snode)) {
@@ -1506,8 +1546,9 @@ bool ED_screen_stereo3d_required(const bScreen *screen, const Scene *scene)
case SPACE_SEQ: {
SpaceSeq *sseq;
- if (!is_multiview)
+ if (!is_multiview) {
continue;
+ }
sseq = sa->spacedata.first;
if (ELEM(sseq->view, SEQ_VIEW_PREVIEW, SEQ_VIEW_SEQUENCE_PREVIEW)) {
diff --git a/source/blender/editors/screen/screen_geometry.c b/source/blender/editors/screen/screen_geometry.c
index a9aebca7724..a0d9c232195 100644
--- a/source/blender/editors/screen/screen_geometry.c
+++ b/source/blender/editors/screen/screen_geometry.c
@@ -103,8 +103,9 @@ ScrEdge *screen_geom_area_map_find_active_scredge(const ScrAreaMap *area_map,
min = MIN2(se->v1->vec.x, se->v2->vec.x);
max = MAX2(se->v1->vec.x, se->v2->vec.x);
- if (abs(my - se->v1->vec.y) <= safety && mx >= min && mx <= max)
+ if (abs(my - se->v1->vec.y) <= safety && mx >= min && mx <= max) {
return se;
+ }
}
}
else {
@@ -113,8 +114,9 @@ ScrEdge *screen_geom_area_map_find_active_scredge(const ScrAreaMap *area_map,
min = MIN2(se->v1->vec.y, se->v2->vec.y);
max = MAX2(se->v1->vec.y, se->v2->vec.y);
- if (abs(mx - se->v1->vec.x) <= safety && my >= min && my <= max)
+ if (abs(mx - se->v1->vec.x) <= safety && my >= min && my <= max) {
return se;
+ }
}
}
}
@@ -200,10 +202,12 @@ void screen_geom_vertices_scale(const wmWindow *win, bScreen *sc)
int headery = headery_init;
/* adjust headery if verts are along the edge of window */
- if (sa->v1->vec.y > window_rect.ymin)
+ if (sa->v1->vec.y > window_rect.ymin) {
headery += U.pixelsize;
- if (sa->v2->vec.y < (window_rect.ymax - 1))
+ }
+ if (sa->v2->vec.y < (window_rect.ymax - 1)) {
headery += U.pixelsize;
+ }
if (screen_geom_area_height(sa) < headery) {
/* lower edge */
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c
index cb2effd6657..27fd7c37dee 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -102,44 +102,55 @@
bool ED_operator_regionactive(bContext *C)
{
- if (CTX_wm_window(C) == NULL)
+ if (CTX_wm_window(C) == NULL) {
return 0;
- if (CTX_wm_screen(C) == NULL)
+ }
+ if (CTX_wm_screen(C) == NULL) {
return 0;
- if (CTX_wm_region(C) == NULL)
+ }
+ if (CTX_wm_region(C) == NULL) {
return 0;
+ }
return 1;
}
bool ED_operator_areaactive(bContext *C)
{
- if (CTX_wm_window(C) == NULL)
+ if (CTX_wm_window(C) == NULL) {
return 0;
- if (CTX_wm_screen(C) == NULL)
+ }
+ if (CTX_wm_screen(C) == NULL) {
return 0;
- if (CTX_wm_area(C) == NULL)
+ }
+ if (CTX_wm_area(C) == NULL) {
return 0;
+ }
return 1;
}
bool ED_operator_screenactive(bContext *C)
{
- if (CTX_wm_window(C) == NULL)
+ if (CTX_wm_window(C) == NULL) {
return 0;
- if (CTX_wm_screen(C) == NULL)
+ }
+ if (CTX_wm_screen(C) == NULL) {
return 0;
+ }
return 1;
}
/* XXX added this to prevent anim state to change during renders */
static bool ED_operator_screenactive_norender(bContext *C)
{
- if (G.is_rendering)
+ if (G.is_rendering) {
return 0;
- if (CTX_wm_window(C) == NULL)
+ }
+ if (CTX_wm_window(C) == NULL) {
return 0;
- if (CTX_wm_screen(C) == NULL)
+ }
+ if (CTX_wm_screen(C) == NULL) {
return 0;
+ }
return 1;
}
@@ -147,29 +158,34 @@ static bool ED_operator_screenactive_norender(bContext *C)
bool ED_operator_screen_mainwinactive(bContext *C)
{
bScreen *screen;
- if (CTX_wm_window(C) == NULL)
+ if (CTX_wm_window(C) == NULL) {
return 0;
+ }
screen = CTX_wm_screen(C);
- if (screen == NULL)
+ if (screen == NULL) {
return 0;
- if (screen->active_region != NULL)
+ }
+ if (screen->active_region != NULL) {
return 0;
+ }
return 1;
}
bool ED_operator_scene(bContext *C)
{
Scene *scene = CTX_data_scene(C);
- if (scene)
+ if (scene) {
return 1;
+ }
return 0;
}
bool ED_operator_scene_editable(bContext *C)
{
Scene *scene = CTX_data_scene(C);
- if (scene && !ID_IS_LINKED(scene))
+ if (scene && !ID_IS_LINKED(scene)) {
return 1;
+ }
return 0;
}
@@ -178,14 +194,17 @@ bool ED_operator_objectmode(bContext *C)
Scene *scene = CTX_data_scene(C);
Object *obact = CTX_data_active_object(C);
- if (scene == NULL || ID_IS_LINKED(scene))
+ if (scene == NULL || ID_IS_LINKED(scene)) {
return 0;
- if (CTX_data_edit_object(C))
+ }
+ if (CTX_data_edit_object(C)) {
return 0;
+ }
/* add a check for ob->mode too? */
- if (obact && (obact->mode != OB_MODE_OBJECT))
+ if (obact && (obact->mode != OB_MODE_OBJECT)) {
return 0;
+ }
return 1;
}
@@ -206,8 +225,9 @@ bool ED_operator_view3d_active(bContext *C)
bool ED_operator_region_view3d_active(bContext *C)
{
- if (CTX_wm_region_view3d(C))
+ if (CTX_wm_region_view3d(C)) {
return true;
+ }
CTX_wm_operator_poll_msg_set(C, "expected a view3d region");
return false;
@@ -218,8 +238,9 @@ bool ED_operator_animview_active(bContext *C)
{
if (ED_operator_areaactive(C)) {
SpaceLink *sl = (SpaceLink *)CTX_wm_space_data(C);
- if (sl && (ELEM(sl->spacetype, SPACE_SEQ, SPACE_ACTION, SPACE_NLA, SPACE_GRAPH)))
+ if (sl && (ELEM(sl->spacetype, SPACE_SEQ, SPACE_ACTION, SPACE_NLA, SPACE_GRAPH))) {
return true;
+ }
}
CTX_wm_operator_poll_msg_set(C, "expected a timeline/animation area to be active");
@@ -236,10 +257,12 @@ bool ED_operator_outliner_active_no_editobject(bContext *C)
if (ed_spacetype_test(C, SPACE_OUTLINER)) {
Object *ob = ED_object_active_context(C);
Object *obedit = CTX_data_edit_object(C);
- if (ob && ob == obedit)
+ if (ob && ob == obedit) {
return 0;
- else
+ }
+ else {
return 1;
+ }
}
return 0;
}
@@ -263,8 +286,9 @@ bool ED_operator_node_active(bContext *C)
{
SpaceNode *snode = CTX_wm_space_node(C);
- if (snode && snode->edittree)
+ if (snode && snode->edittree) {
return 1;
+ }
return 0;
}
@@ -273,8 +297,9 @@ bool ED_operator_node_editable(bContext *C)
{
SpaceNode *snode = CTX_wm_space_node(C);
- if (snode && snode->edittree && !ID_IS_LINKED(snode->edittree))
+ if (snode && snode->edittree && !ID_IS_LINKED(snode->edittree)) {
return 1;
+ }
return 0;
}
@@ -348,8 +373,9 @@ bool ED_operator_object_active_editable_font(bContext *C)
bool ED_operator_editmesh(bContext *C)
{
Object *obedit = CTX_data_edit_object(C);
- if (obedit && obedit->type == OB_MESH)
+ if (obedit && obedit->type == OB_MESH) {
return NULL != BKE_editmesh_from_object(obedit);
+ }
return 0;
}
@@ -360,8 +386,9 @@ bool ED_operator_editmesh_view3d(bContext *C)
bool ED_operator_editmesh_region_view3d(bContext *C)
{
- if (ED_operator_editmesh(C) && CTX_wm_region_view3d(C))
+ if (ED_operator_editmesh(C) && CTX_wm_region_view3d(C)) {
return 1;
+ }
CTX_wm_operator_poll_msg_set(C, "expected a view3d region & editmesh");
return 0;
@@ -379,8 +406,9 @@ bool ED_operator_editmesh_auto_smooth(bContext *C)
bool ED_operator_editarmature(bContext *C)
{
Object *obedit = CTX_data_edit_object(C);
- if (obedit && obedit->type == OB_ARMATURE)
+ if (obedit && obedit->type == OB_ARMATURE) {
return NULL != ((bArmature *)obedit->data)->edbo;
+ }
return 0;
}
@@ -482,15 +510,17 @@ bool ED_operator_uvmap(bContext *C)
bool ED_operator_editsurfcurve(bContext *C)
{
Object *obedit = CTX_data_edit_object(C);
- if (obedit && ELEM(obedit->type, OB_CURVE, OB_SURF))
+ if (obedit && ELEM(obedit->type, OB_CURVE, OB_SURF)) {
return NULL != ((Curve *)obedit->data)->editnurb;
+ }
return 0;
}
bool ED_operator_editsurfcurve_region_view3d(bContext *C)
{
- if (ED_operator_editsurfcurve(C) && CTX_wm_region_view3d(C))
+ if (ED_operator_editsurfcurve(C) && CTX_wm_region_view3d(C)) {
return 1;
+ }
CTX_wm_operator_poll_msg_set(C, "expected a view3d region & editcurve");
return 0;
@@ -499,8 +529,9 @@ bool ED_operator_editsurfcurve_region_view3d(bContext *C)
bool ED_operator_editcurve(bContext *C)
{
Object *obedit = CTX_data_edit_object(C);
- if (obedit && obedit->type == OB_CURVE)
+ if (obedit && obedit->type == OB_CURVE) {
return NULL != ((Curve *)obedit->data)->editnurb;
+ }
return 0;
}
@@ -518,32 +549,36 @@ bool ED_operator_editcurve_3d(bContext *C)
bool ED_operator_editsurf(bContext *C)
{
Object *obedit = CTX_data_edit_object(C);
- if (obedit && obedit->type == OB_SURF)
+ if (obedit && obedit->type == OB_SURF) {
return NULL != ((Curve *)obedit->data)->editnurb;
+ }
return 0;
}
bool ED_operator_editfont(bContext *C)
{
Object *obedit = CTX_data_edit_object(C);
- if (obedit && obedit->type == OB_FONT)
+ if (obedit && obedit->type == OB_FONT) {
return NULL != ((Curve *)obedit->data)->editfont;
+ }
return 0;
}
bool ED_operator_editlattice(bContext *C)
{
Object *obedit = CTX_data_edit_object(C);
- if (obedit && obedit->type == OB_LATTICE)
+ if (obedit && obedit->type == OB_LATTICE) {
return NULL != ((Lattice *)obedit->data)->editlatt;
+ }
return 0;
}
bool ED_operator_editmball(bContext *C)
{
Object *obedit = CTX_data_edit_object(C);
- if (obedit && obedit->type == OB_MBALL)
+ if (obedit && obedit->type == OB_MBALL) {
return NULL != ((MetaBall *)obedit->data)->editelems;
+ }
return 0;
}
@@ -588,8 +623,9 @@ static bool screen_active_editable(bContext *C)
{
if (ED_operator_screenactive(C)) {
/* no full window splitting allowed */
- if (CTX_wm_screen(C)->state != SCREENNORMAL)
+ if (CTX_wm_screen(C)->state != SCREENNORMAL) {
return 0;
+ }
return 1;
}
return 0;
@@ -658,9 +694,11 @@ static bool actionzone_area_poll(bContext *C)
AZone *az;
for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
- for (az = sa->actionzones.first; az; az = az->next)
- if (BLI_rcti_isect_pt_v(&az->rect, xy))
+ for (az = sa->actionzones.first; az; az = az->next) {
+ if (BLI_rcti_isect_pt_v(&az->rect, xy)) {
return 1;
+ }
+ }
}
}
return 0;
@@ -867,8 +905,9 @@ AZone *ED_area_azones_update(ScrArea *sa, const int xy[2])
static void actionzone_exit(wmOperator *op)
{
- if (op->customdata)
+ if (op->customdata) {
MEM_freeN(op->customdata);
+ }
op->customdata = NULL;
}
@@ -883,12 +922,15 @@ static void actionzone_apply(bContext *C, wmOperator *op, int type)
wm_event_init_from_window(win, &event);
- if (type == AZONE_AREA)
+ if (type == AZONE_AREA) {
event.type = EVT_ACTIONZONE_AREA;
- else if (type == AZONE_FULLSCREEN)
+ }
+ else if (type == AZONE_FULLSCREEN) {
event.type = EVT_ACTIONZONE_FULLSCREEN;
- else
+ }
+ else {
event.type = EVT_ACTIONZONE_REGION;
+ }
event.val = KM_NOTHING;
event.customdata = op->customdata;
@@ -905,8 +947,9 @@ static int actionzone_invoke(bContext *C, wmOperator *op, const wmEvent *event)
sActionzoneData *sad;
/* quick escape - Scroll azones only hide/unhide the scroll-bars, they have their own handling. */
- if (az == NULL || ELEM(az->type, AZONE_REGION_SCROLL))
+ if (az == NULL || ELEM(az->type, AZONE_REGION_SCROLL)) {
return OPERATOR_PASS_THROUGH;
+ }
/* ok we do the action-zone */
sad = op->customdata = MEM_callocN(sizeof(sActionzoneData), "sActionzoneData");
@@ -950,14 +993,18 @@ static int actionzone_modal(bContext *C, wmOperator *op, const wmEvent *event)
const int area_threshold = (0.1 * U.widget_unit);
/* Calculate gesture cardinal direction. */
- if (delta_y > ABS(delta_x))
+ if (delta_y > ABS(delta_x)) {
sad->gesture_dir = 'n';
- else if (delta_x >= ABS(delta_y))
+ }
+ else if (delta_x >= ABS(delta_y)) {
sad->gesture_dir = 'e';
- else if (delta_y < -ABS(delta_x))
+ }
+ else if (delta_y < -ABS(delta_x)) {
sad->gesture_dir = 's';
- else
+ }
+ else {
sad->gesture_dir = 'w';
+ }
if (sad->az->type == AZONE_AREA) {
wmWindow *win = CTX_wm_window(C);
@@ -978,14 +1025,18 @@ static int actionzone_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
else {
/* Different area, so posible join. */
- if (sad->gesture_dir == 'n')
+ if (sad->gesture_dir == 'n') {
WM_cursor_set(win, BC_N_ARROWCURSOR);
- else if (sad->gesture_dir == 's')
+ }
+ else if (sad->gesture_dir == 's') {
WM_cursor_set(win, BC_S_ARROWCURSOR);
- else if (sad->gesture_dir == 'e')
+ }
+ else if (sad->gesture_dir == 'e') {
WM_cursor_set(win, BC_E_ARROWCURSOR);
- else
+ }
+ else {
WM_cursor_set(win, BC_W_ARROWCURSOR);
+ }
is_gesture = (delta_max > join_threshold);
}
}
@@ -1079,8 +1130,9 @@ static int area_swap_init(wmOperator *op, const wmEvent *event)
sAreaSwapData *sd = NULL;
sActionzoneData *sad = event->customdata;
- if (sad == NULL || sad->sa1 == NULL)
+ if (sad == NULL || sad->sa1 == NULL) {
return 0;
+ }
sd = MEM_callocN(sizeof(sAreaSwapData), "sAreaSwapData");
sd->sa1 = sad->sa1;
@@ -1093,8 +1145,9 @@ static int area_swap_init(wmOperator *op, const wmEvent *event)
static void area_swap_exit(bContext *C, wmOperator *op)
{
WM_cursor_modal_restore(CTX_wm_window(C));
- if (op->customdata)
+ if (op->customdata) {
MEM_freeN(op->customdata);
+ }
op->customdata = NULL;
}
@@ -1106,8 +1159,9 @@ static void area_swap_cancel(bContext *C, wmOperator *op)
static int area_swap_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
- if (!area_swap_init(op, event))
+ if (!area_swap_init(op, event)) {
return OPERATOR_PASS_THROUGH;
+ }
/* add modal handler */
WM_cursor_modal_set(CTX_wm_window(C), BC_SWAPAREA_CURSOR);
@@ -1195,8 +1249,9 @@ static int area_dupli_invoke(bContext *C, wmOperator *op, const wmEvent *event)
if (event->type == EVT_ACTIONZONE_AREA) {
sActionzoneData *sad = event->customdata;
- if (sad == NULL)
+ if (sad == NULL) {
return OPERATOR_PASS_THROUGH;
+ }
sa = sad->sa1;
}
@@ -1233,8 +1288,9 @@ static int area_dupli_invoke(bContext *C, wmOperator *op, const wmEvent *event)
WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL);
finally:
- if (event->type == EVT_ACTIONZONE_AREA)
+ if (event->type == EVT_ACTIONZONE_AREA) {
actionzone_exit(op);
+ }
if (newwin) {
return OPERATOR_FINISHED;
@@ -1365,35 +1421,43 @@ static void area_move_set_limits(
int y1;
areamin = areaminy;
- if (sa->v1->vec.y > window_rect.ymin)
+ if (sa->v1->vec.y > window_rect.ymin) {
areamin += U.pixelsize;
- if (sa->v2->vec.y < (window_rect.ymax - 1))
+ }
+ if (sa->v2->vec.y < (window_rect.ymax - 1)) {
areamin += U.pixelsize;
+ }
y1 = screen_geom_area_height(sa) - areamin;
/* if top or down edge selected, test height */
- if (sa->v1->editflag && sa->v4->editflag)
+ if (sa->v1->editflag && sa->v4->editflag) {
*bigger = min_ii(*bigger, y1);
- else if (sa->v2->editflag && sa->v3->editflag)
+ }
+ else if (sa->v2->editflag && sa->v3->editflag) {
*smaller = min_ii(*smaller, y1);
+ }
}
else {
int x1;
areamin = AREAMINX;
- if (sa->v1->vec.x > window_rect.xmin)
+ if (sa->v1->vec.x > window_rect.xmin) {
areamin += U.pixelsize;
- if (sa->v4->vec.x < (window_rect.xmax - 1))
+ }
+ if (sa->v4->vec.x < (window_rect.xmax - 1)) {
areamin += U.pixelsize;
+ }
x1 = screen_geom_area_width(sa) - areamin;
/* if left or right edge selected, test width */
- if (sa->v1->editflag && sa->v2->editflag)
+ if (sa->v1->editflag && sa->v2->editflag) {
*bigger = min_ii(*bigger, x1);
- else if (sa->v3->editflag && sa->v4->editflag)
+ }
+ else if (sa->v3->editflag && sa->v4->editflag) {
*smaller = min_ii(*smaller, x1);
+ }
}
}
}
@@ -1414,17 +1478,20 @@ static int area_move_init(bContext *C, wmOperator *op)
/* setup */
actedge = screen_geom_find_active_scredge(win, sc, x, y);
- if (actedge == NULL)
+ if (actedge == NULL) {
return 0;
+ }
md = MEM_callocN(sizeof(sAreaMoveData), "sAreaMoveData");
op->customdata = md;
md->dir = screen_geom_edge_is_horizontal(actedge) ? 'h' : 'v';
- if (md->dir == 'h')
+ if (md->dir == 'h') {
md->origval = actedge->v1->vec.y;
- else
+ }
+ else {
md->origval = actedge->v1->vec.x;
+ }
screen_geom_select_connected_edge(win, actedge);
/* now all vertices with 'flag == 1' are the ones that can be moved. Move this to editflag */
@@ -1623,8 +1690,9 @@ static void area_move_apply(bContext *C, wmOperator *op)
static void area_move_exit(bContext *C, wmOperator *op)
{
- if (op->customdata)
+ if (op->customdata) {
MEM_freeN(op->customdata);
+ }
op->customdata = NULL;
/* this makes sure aligned edges will result in aligned grabbing */
@@ -1636,8 +1704,9 @@ static void area_move_exit(bContext *C, wmOperator *op)
static int area_move_exec(bContext *C, wmOperator *op)
{
- if (!area_move_init(C, op))
+ if (!area_move_init(C, op)) {
return OPERATOR_CANCELLED;
+ }
area_move_apply(C, op);
area_move_exit(C, op);
@@ -1651,8 +1720,9 @@ static int area_move_invoke(bContext *C, wmOperator *op, const wmEvent *event)
RNA_int_set(op->ptr, "x", event->x);
RNA_int_set(op->ptr, "y", event->y);
- if (!area_move_init(C, op))
+ if (!area_move_init(C, op)) {
return OPERATOR_PASS_THROUGH;
+ }
G.moving |= G_TRANSFORM_WM;
@@ -1830,17 +1900,20 @@ static int area_split_init(bContext *C, wmOperator *op)
int dir;
/* required context */
- if (sa == NULL)
+ if (sa == NULL) {
return 0;
+ }
/* required properties */
dir = RNA_enum_get(op->ptr, "direction");
/* minimal size */
- if (dir == 'v' && sa->winx < 2 * AREAMINX)
+ if (dir == 'v' && sa->winx < 2 * AREAMINX) {
return 0;
- if (dir == 'h' && sa->winy < 2 * areaminy)
+ }
+ if (dir == 'h' && sa->winy < 2 * areaminy) {
return 0;
+ }
/* custom data */
sd = (sAreaSplitData *)MEM_callocN(sizeof(sAreaSplitData), "op_area_split");
@@ -1914,10 +1987,12 @@ static int area_split_apply(bContext *C, wmOperator *op)
sd->nedge->v1->editflag = 1;
sd->nedge->v2->editflag = 1;
- if (dir == 'h')
+ if (dir == 'h') {
sd->origval = sd->nedge->v1->vec.y;
- else
+ }
+ else {
sd->origval = sd->nedge->v1->vec.x;
+ }
ED_area_tag_redraw(sd->sarea);
ED_area_tag_redraw(sd->narea);
@@ -1936,13 +2011,16 @@ static void area_split_exit(bContext *C, wmOperator *op)
{
if (op->customdata) {
sAreaSplitData *sd = (sAreaSplitData *)op->customdata;
- if (sd->sarea)
+ if (sd->sarea) {
ED_area_tag_redraw(sd->sarea);
- if (sd->narea)
+ }
+ if (sd->narea) {
ED_area_tag_redraw(sd->narea);
+ }
- if (sd->draw_callback)
+ if (sd->draw_callback) {
WM_draw_cb_exit(CTX_wm_window(C), sd->draw_callback);
+ }
MEM_freeN(op->customdata);
op->customdata = NULL;
@@ -1986,12 +2064,14 @@ static int area_split_invoke(bContext *C, wmOperator *op, const wmEvent *event)
}
/* verify *sad itself */
- if (sad->sa1 == NULL || sad->az == NULL)
+ if (sad->sa1 == NULL || sad->az == NULL) {
return OPERATOR_PASS_THROUGH;
+ }
/* is this our *sad? if areas not equal it should be passed on */
- if (CTX_wm_area(C) != sad->sa1 || sad->sa1 != sad->sa2)
+ if (CTX_wm_area(C) != sad->sa1 || sad->sa1 != sad->sa2) {
return OPERATOR_PASS_THROUGH;
+ }
/* The factor will be close to 1.0f when near the top-left and the bottom-right corners. */
const float factor_v = ((float)(event->y - sad->sa1->v1->vec.y)) / (float)sad->sa1->winy;
@@ -2106,8 +2186,9 @@ static int area_split_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static int area_split_exec(bContext *C, wmOperator *op)
{
- if (!area_split_init(C, op))
+ if (!area_split_init(C, op)) {
return OPERATOR_CANCELLED;
+ }
area_split_apply(C, op);
area_split_exit(C, op);
@@ -2327,8 +2408,9 @@ static int area_max_regionsize(ScrArea *sa, ARegion *scalear, AZEdge edge)
/* subtractwidth of regions on opposite side
* prevents dragging regions into other opposite regions */
for (ARegion *ar = sa->regionbase.first; ar; ar = ar->next) {
- if (ar == scalear)
+ if (ar == scalear) {
continue;
+ }
if (scalear->alignment == RGN_ALIGN_LEFT && ar->alignment == RGN_ALIGN_RIGHT) {
dist -= ar->winx;
@@ -2379,10 +2461,12 @@ static int region_scale_invoke(bContext *C, wmOperator *op, const wmEvent *event
rmd->maxsize = area_max_regionsize(rmd->sa, rmd->ar, rmd->edge);
/* if not set we do now, otherwise it uses type */
- if (rmd->ar->sizex == 0)
+ if (rmd->ar->sizex == 0) {
rmd->ar->sizex = rmd->ar->winx;
- if (rmd->ar->sizey == 0)
+ }
+ if (rmd->ar->sizey == 0) {
rmd->ar->sizey = rmd->ar->winy;
+ }
/* now copy to regionmovedata */
if (rmd->edge == AE_LEFT_TO_TOPRIGHT || rmd->edge == AE_RIGHT_TO_TOPLEFT) {
@@ -2408,15 +2492,18 @@ static void region_scale_validate_size(RegionMoveData *rmd)
if ((rmd->ar->flag & RGN_FLAG_HIDDEN) == 0) {
short *size, maxsize = -1;
- if (rmd->edge == AE_LEFT_TO_TOPRIGHT || rmd->edge == AE_RIGHT_TO_TOPLEFT)
+ if (rmd->edge == AE_LEFT_TO_TOPRIGHT || rmd->edge == AE_RIGHT_TO_TOPLEFT) {
size = &rmd->ar->sizex;
- else
+ }
+ else {
size = &rmd->ar->sizey;
+ }
maxsize = rmd->maxsize - (UI_UNIT_Y / UI_DPI_FAC);
- if (*size > maxsize && maxsize > 0)
+ if (*size > maxsize && maxsize > 0) {
*size = maxsize;
+ }
}
}
@@ -2457,8 +2544,9 @@ static int region_scale_modal(bContext *C, wmOperator *op, const wmEvent *event)
const int snap_size_threshold = (U.widget_unit * 2) / aspect;
if (rmd->edge == AE_LEFT_TO_TOPRIGHT || rmd->edge == AE_RIGHT_TO_TOPLEFT) {
delta = event->x - rmd->origx;
- if (rmd->edge == AE_LEFT_TO_TOPRIGHT)
+ if (rmd->edge == AE_LEFT_TO_TOPRIGHT) {
delta = -delta;
+ }
/* region sizes now get multiplied */
delta /= UI_DPI_FAC;
@@ -2475,8 +2563,9 @@ static int region_scale_modal(bContext *C, wmOperator *op, const wmEvent *event)
if (rmd->ar->sizex < UI_UNIT_X) {
rmd->ar->sizex = rmd->origval;
- if (!(rmd->ar->flag & RGN_FLAG_HIDDEN))
+ if (!(rmd->ar->flag & RGN_FLAG_HIDDEN)) {
region_scale_toggle_hidden(C, rmd);
+ }
}
else if (rmd->ar->flag & RGN_FLAG_HIDDEN) {
region_scale_toggle_hidden(C, rmd);
@@ -2487,8 +2576,9 @@ static int region_scale_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
else {
delta = event->y - rmd->origy;
- if (rmd->edge == AE_BOTTOM_TO_TOPLEFT)
+ if (rmd->edge == AE_BOTTOM_TO_TOPLEFT) {
delta = -delta;
+ }
/* region sizes now get multiplied */
delta /= UI_DPI_FAC;
@@ -2508,8 +2598,9 @@ static int region_scale_modal(bContext *C, wmOperator *op, const wmEvent *event)
* otherwise its too easy to do this by accident */
if (rmd->ar->sizey < UI_UNIT_Y / 4) {
rmd->ar->sizey = rmd->origval;
- if (!(rmd->ar->flag & RGN_FLAG_HIDDEN))
+ if (!(rmd->ar->flag & RGN_FLAG_HIDDEN)) {
region_scale_toggle_hidden(C, rmd);
+ }
}
else if (rmd->ar->flag & RGN_FLAG_HIDDEN) {
region_scale_toggle_hidden(C, rmd);
@@ -2679,16 +2770,20 @@ static int frame_jump_exec(bContext *C, wmOperator *op)
sad->flag |= ANIMPLAY_FLAG_USE_NEXT_FRAME;
- if (RNA_boolean_get(op->ptr, "end"))
+ if (RNA_boolean_get(op->ptr, "end")) {
sad->nextfra = PEFRA;
- else
+ }
+ else {
sad->nextfra = PSFRA;
+ }
}
else {
- if (RNA_boolean_get(op->ptr, "end"))
+ if (RNA_boolean_get(op->ptr, "end")) {
CFRA = PEFRA;
- else
+ }
+ else {
CFRA = PSFRA;
+ }
areas_do_frame_follow(C, true);
@@ -2736,8 +2831,9 @@ static int keyframe_jump_exec(bContext *C, wmOperator *op)
bool done = false;
/* sanity checks */
- if (scene == NULL)
+ if (scene == NULL) {
return OPERATOR_CANCELLED;
+ }
cfra = (float)(CFRA);
@@ -2771,10 +2867,12 @@ static int keyframe_jump_exec(bContext *C, wmOperator *op)
}
/* find matching keyframe in the right direction */
- if (next)
+ if (next) {
ak = (ActKeyColumn *)BLI_dlrbTree_search_next(&keys, compare_ak_cfraPtr, &cfra);
- else
+ }
+ else {
ak = (ActKeyColumn *)BLI_dlrbTree_search_prev(&keys, compare_ak_cfraPtr, &cfra);
+ }
while ((ak != NULL) && (done == false)) {
if (CFRA != (int)ak->cfra) {
@@ -2944,8 +3042,9 @@ static int screen_maximize_area_exec(bContext *C, wmOperator *op)
/* search current screen for 'fullscreen' areas */
/* prevents restoring info header, when mouse is over it */
for (sa = screen->areabase.first; sa; sa = sa->next) {
- if (sa->full)
+ if (sa->full) {
break;
+ }
}
if (sa == NULL) {
@@ -3094,8 +3193,9 @@ static int area_join_init(bContext *C, wmOperator *op)
static int area_join_apply(bContext *C, wmOperator *op)
{
sAreaJoinData *jd = (sAreaJoinData *)op->customdata;
- if (!jd)
+ if (!jd) {
return 0;
+ }
if (!screen_area_join(C, CTX_wm_screen(C), jd->sa1, jd->sa2)) {
return 0;
@@ -3114,8 +3214,9 @@ static void area_join_exit(bContext *C, wmOperator *op)
sAreaJoinData *jd = (sAreaJoinData *)op->customdata;
if (jd) {
- if (jd->draw_callback)
+ if (jd->draw_callback) {
WM_draw_cb_exit(CTX_wm_window(C), jd->draw_callback);
+ }
MEM_freeN(jd);
op->customdata = NULL;
@@ -3129,8 +3230,9 @@ static void area_join_exit(bContext *C, wmOperator *op)
static int area_join_exec(bContext *C, wmOperator *op)
{
- if (!area_join_init(C, op))
+ if (!area_join_init(C, op)) {
return OPERATOR_CANCELLED;
+ }
area_join_apply(C, op);
area_join_exit(C, op);
@@ -3150,12 +3252,14 @@ static int area_join_invoke(bContext *C, wmOperator *op, const wmEvent *event)
}
/* verify *sad itself */
- if (sad->sa1 == NULL || sad->sa2 == NULL)
+ if (sad->sa1 == NULL || sad->sa2 == NULL) {
return OPERATOR_PASS_THROUGH;
+ }
/* is this our *sad? if areas equal it should be passed on */
- if (sad->sa1 == sad->sa2)
+ if (sad->sa1 == sad->sa2) {
return OPERATOR_PASS_THROUGH;
+ }
/* prepare operator state vars */
RNA_int_set(op->ptr, "min_x", sad->sa1->totrct.xmin);
@@ -3164,8 +3268,9 @@ static int area_join_invoke(bContext *C, wmOperator *op, const wmEvent *event)
RNA_int_set(op->ptr, "max_y", sad->sa2->totrct.ymin);
}
- if (!area_join_init(C, op))
+ if (!area_join_init(C, op)) {
return OPERATOR_CANCELLED;
+ }
/* add temp handler */
WM_event_add_modal_handler(C, op);
@@ -3237,16 +3342,21 @@ static int area_join_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
}
- if (dir == 1)
+ if (dir == 1) {
WM_cursor_set(win, BC_N_ARROWCURSOR);
- else if (dir == 3)
+ }
+ else if (dir == 3) {
WM_cursor_set(win, BC_S_ARROWCURSOR);
- else if (dir == 2)
+ }
+ else if (dir == 2) {
WM_cursor_set(win, BC_E_ARROWCURSOR);
- else if (dir == 0)
+ }
+ else if (dir == 0) {
WM_cursor_set(win, BC_W_ARROWCURSOR);
- else
+ }
+ else {
WM_cursor_set(win, BC_STOPCURSOR);
+ }
break;
}
@@ -3316,8 +3426,9 @@ static int screen_area_options_invoke(bContext *C, wmOperator *op, const wmEvent
actedge = screen_geom_area_map_find_active_scredge(
AREAMAP_FROM_SCREEN(sc), &window_rect, event->x, event->y);
- if (actedge == NULL)
+ if (actedge == NULL) {
return OPERATOR_CANCELLED;
+ }
pup = UI_popup_menu_begin(C, RNA_struct_ui_name(op->type->srna), ICON_NONE);
layout = UI_popup_menu_layout(pup);
@@ -3454,17 +3565,19 @@ static int repeat_history_invoke(bContext *C, wmOperator *op, const wmEvent *UNU
int items, i;
items = BLI_listbase_count(&wm->operators);
- if (items == 0)
+ if (items == 0) {
return OPERATOR_CANCELLED;
+ }
pup = UI_popup_menu_begin(C, RNA_struct_ui_name(op->type->srna), ICON_NONE);
layout = UI_popup_menu_layout(pup);
- for (i = items - 1, lastop = wm->operators.last; lastop; lastop = lastop->prev, i--)
+ for (i = items - 1, lastop = wm->operators.last; lastop; lastop = lastop->prev, i--) {
if ((lastop->type->flag & OPTYPE_REGISTER) && WM_operator_repeat_check(C, lastop)) {
uiItemIntO(
layout, RNA_struct_ui_name(lastop->type->srna), ICON_NONE, op->type->idname, "index", i);
}
+ }
UI_popup_menu_end(C, pup);
@@ -3513,8 +3626,9 @@ static int redo_last_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *
{
wmOperator *lastop = WM_operator_last_redo(C);
- if (lastop)
+ if (lastop) {
WM_operator_redo_popup(C, lastop);
+ }
return OPERATOR_CANCELLED;
}
@@ -3711,17 +3825,22 @@ static int region_flip_exec(bContext *C, wmOperator *UNUSED(op))
{
ARegion *ar = CTX_wm_region(C);
- if (!ar)
+ if (!ar) {
return OPERATOR_CANCELLED;
+ }
- if (ar->alignment == RGN_ALIGN_TOP)
+ if (ar->alignment == RGN_ALIGN_TOP) {
ar->alignment = RGN_ALIGN_BOTTOM;
- else if (ar->alignment == RGN_ALIGN_BOTTOM)
+ }
+ else if (ar->alignment == RGN_ALIGN_BOTTOM) {
ar->alignment = RGN_ALIGN_TOP;
- else if (ar->alignment == RGN_ALIGN_LEFT)
+ }
+ else if (ar->alignment == RGN_ALIGN_LEFT) {
ar->alignment = RGN_ALIGN_RIGHT;
- else if (ar->alignment == RGN_ALIGN_RIGHT)
+ }
+ else if (ar->alignment == RGN_ALIGN_RIGHT) {
ar->alignment = RGN_ALIGN_LEFT;
+ }
ED_area_tag_redraw(CTX_wm_area(C));
WM_event_add_mousemove(C);
@@ -4002,8 +4121,9 @@ static int match_area_with_refresh(int spacetype, int refresh)
{
switch (spacetype) {
case SPACE_TIME:
- if (refresh & SPACE_TIME)
+ if (refresh & SPACE_TIME) {
return 1;
+ }
break;
}
@@ -4019,40 +4139,48 @@ static int match_region_with_redraws(int spacetype,
switch (spacetype) {
case SPACE_VIEW3D:
- if ((redraws & TIME_ALL_3D_WIN) || from_anim_edit)
+ if ((redraws & TIME_ALL_3D_WIN) || from_anim_edit) {
return 1;
+ }
break;
case SPACE_GRAPH:
case SPACE_NLA:
- if ((redraws & TIME_ALL_ANIM_WIN) || from_anim_edit)
+ if ((redraws & TIME_ALL_ANIM_WIN) || from_anim_edit) {
return 1;
+ }
break;
case SPACE_ACTION:
/* if only 1 window or 3d windows, we do timeline too
* NOTE: Now we do do action editor in all these cases, since timeline is here
*/
- if ((redraws & (TIME_ALL_ANIM_WIN | TIME_REGION | TIME_ALL_3D_WIN)) || from_anim_edit)
+ if ((redraws & (TIME_ALL_ANIM_WIN | TIME_REGION | TIME_ALL_3D_WIN)) || from_anim_edit) {
return 1;
+ }
break;
case SPACE_PROPERTIES:
- if (redraws & TIME_ALL_BUTS_WIN)
+ if (redraws & TIME_ALL_BUTS_WIN) {
return 1;
+ }
break;
case SPACE_SEQ:
- if ((redraws & (TIME_SEQ | TIME_ALL_ANIM_WIN)) || from_anim_edit)
+ if ((redraws & (TIME_SEQ | TIME_ALL_ANIM_WIN)) || from_anim_edit) {
return 1;
+ }
break;
case SPACE_NODE:
- if (redraws & (TIME_NODES))
+ if (redraws & (TIME_NODES)) {
return 1;
+ }
break;
case SPACE_IMAGE:
- if ((redraws & TIME_ALL_IMAGE_WIN) || from_anim_edit)
+ if ((redraws & TIME_ALL_IMAGE_WIN) || from_anim_edit) {
return 1;
+ }
break;
case SPACE_CLIP:
- if ((redraws & TIME_CLIPS) || from_anim_edit)
+ if ((redraws & TIME_CLIPS) || from_anim_edit) {
return 1;
+ }
break;
}
}
@@ -4061,8 +4189,9 @@ static int match_region_with_redraws(int spacetype,
case SPACE_GRAPH:
case SPACE_ACTION:
case SPACE_NLA:
- if (redraws & TIME_ALL_ANIM_WIN)
+ if (redraws & TIME_ALL_ANIM_WIN) {
return 1;
+ }
break;
}
}
@@ -4076,18 +4205,21 @@ static int match_region_with_redraws(int spacetype,
return 1;
}
- if (redraws & TIME_ALL_BUTS_WIN)
+ if (redraws & TIME_ALL_BUTS_WIN) {
return 1;
+ }
}
else if (ELEM(regiontype, RGN_TYPE_HEADER, RGN_TYPE_TOOL_HEADER)) {
- if (spacetype == SPACE_ACTION)
+ if (spacetype == SPACE_ACTION) {
return 1;
+ }
}
else if (regiontype == RGN_TYPE_PREVIEW) {
switch (spacetype) {
case SPACE_SEQ:
- if (redraws & (TIME_SEQ | TIME_ALL_ANIM_WIN))
+ if (redraws & (TIME_SEQ | TIME_ALL_ANIM_WIN)) {
return 1;
+ }
break;
case SPACE_CLIP:
return 1;
@@ -4120,22 +4252,27 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), const wmEv
float time;
/* sync, don't sync, or follow scene setting */
- if (sad->flag & ANIMPLAY_FLAG_SYNC)
+ if (sad->flag & ANIMPLAY_FLAG_SYNC) {
sync = 1;
- else if (sad->flag & ANIMPLAY_FLAG_NO_SYNC)
+ }
+ else if (sad->flag & ANIMPLAY_FLAG_NO_SYNC) {
sync = 0;
- else
+ }
+ else {
sync = (scene->flag & SCE_FRAME_DROP);
+ }
if ((scene->audio.flag & AUDIO_SYNC) && (sad->flag & ANIMPLAY_FLAG_REVERSE) == false &&
isfinite(time = BKE_sound_sync_scene(scene))) {
double newfra = (double)time * FPS;
/* give some space here to avoid jumps */
- if (newfra + 0.5 > scene->r.cfra && newfra - 0.5 < scene->r.cfra)
+ if (newfra + 0.5 > scene->r.cfra && newfra - 0.5 < scene->r.cfra) {
scene->r.cfra++;
- else
+ }
+ else {
scene->r.cfra = newfra + 0.5;
+ }
#ifdef PROFILE_AUDIO_SYNCH
newfra_int = scene->r.cfra;
@@ -4157,17 +4294,21 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), const wmEv
const int step = max_ii(1, floor((wt->duration - sad->last_duration) * FPS));
/* skip frames */
- if (sad->flag & ANIMPLAY_FLAG_REVERSE)
+ if (sad->flag & ANIMPLAY_FLAG_REVERSE) {
scene->r.cfra -= step;
- else
+ }
+ else {
scene->r.cfra += step;
+ }
}
else {
/* one frame +/- */
- if (sad->flag & ANIMPLAY_FLAG_REVERSE)
+ if (sad->flag & ANIMPLAY_FLAG_REVERSE) {
scene->r.cfra--;
- else
+ }
+ else {
scene->r.cfra++;
+ }
}
}
@@ -4260,8 +4401,9 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), const wmEv
}
}
- if (match_area_with_refresh(sa->spacetype, sad->refresh))
+ if (match_area_with_refresh(sa->spacetype, sad->refresh)) {
ED_area_tag_refresh(sa);
+ }
}
}
@@ -4348,8 +4490,9 @@ int ED_screen_animation_play(bContext *C, int sync, int mode)
/* these settings are currently only available from a menu in the TimeLine */
int refresh = SPACE_ACTION;
- if (mode == 1) /* XXX only play audio forwards!? */
+ if (mode == 1) { /* XXX only play audio forwards!? */
BKE_sound_play_scene(scene);
+ }
ED_screen_animation_timer(C, screen->redraws_flag, refresh, sync, mode);
@@ -4369,8 +4512,9 @@ static int screen_animation_play_exec(bContext *C, wmOperator *op)
int mode = (RNA_boolean_get(op->ptr, "reverse")) ? -1 : 1;
int sync = -1;
- if (RNA_struct_property_is_set(op->ptr, "sync"))
+ if (RNA_struct_property_is_set(op->ptr, "sync")) {
sync = (RNA_boolean_get(op->ptr, "sync"));
+ }
return ED_screen_animation_play(C, sync, mode);
}
@@ -4519,8 +4663,9 @@ static int fullscreen_back_exec(bContext *C, wmOperator *op)
/* search current screen for 'fullscreen' areas */
for (sa = screen->areabase.first; sa; sa = sa->next) {
- if (sa->full)
+ if (sa->full) {
break;
+ }
}
if (!sa) {
BKE_report(op->reports, RPT_ERROR, "No fullscreen areas were found");
@@ -4741,8 +4886,9 @@ float ED_region_blend_alpha(ARegion *ar)
alpha = (float)ar->regiontimer->duration / TIMEOUT;
/* makes sure the blend out works 100% - without area redraws */
- if (rgi->hidden)
+ if (rgi->hidden) {
alpha = 0.9f - TIMESTEP - alpha;
+ }
CLAMP(alpha, 0.0f, 1.0f);
return alpha;
@@ -4757,13 +4903,15 @@ static void region_blend_end(bContext *C, ARegion *ar, const bool is_running)
/* always send redraw */
ED_region_tag_redraw(ar);
- if (rgi->child_ar)
+ if (rgi->child_ar) {
ED_region_tag_redraw(rgi->child_ar);
+ }
/* if running timer was hiding, the flag toggle went wrong */
if (is_running) {
- if (rgi->hidden)
+ if (rgi->hidden) {
rgi->ar->flag &= ~RGN_FLAG_HIDDEN;
+ }
}
else {
if (rgi->hidden) {
@@ -4796,10 +4944,12 @@ void ED_region_visibility_change_update_animated(bContext *C, ScrArea *sa, ARegi
ar->flag &= ~RGN_FLAG_HIDDEN;
/* blend in, reinitialize regions because it got unhidden */
- if (rgi->hidden == 0)
+ if (rgi->hidden == 0) {
ED_area_initialize(wm, win, sa);
- else
+ }
+ else {
WM_event_remove_handlers(C, &ar->handlers);
+ }
if (ar->next) {
if (ar->next->alignment & RGN_SPLIT_PREV) {
@@ -4819,15 +4969,17 @@ static int region_blend_invoke(bContext *C, wmOperator *UNUSED(op), const wmEven
wmTimer *timer = event->customdata;
/* event type is TIMERREGION, but we better check */
- if (event->type != TIMERREGION || timer == NULL)
+ if (event->type != TIMERREGION || timer == NULL) {
return OPERATOR_PASS_THROUGH;
+ }
rgi = timer->customdata;
/* always send redraws */
ED_region_tag_redraw(rgi->ar);
- if (rgi->child_ar)
+ if (rgi->child_ar) {
ED_region_tag_redraw(rgi->child_ar);
+ }
/* end timer? */
if (rgi->ar->regiontimer->duration > (double)TIMEOUT) {
@@ -5170,8 +5322,9 @@ static bool blend_file_drop_poll(bContext *UNUSED(C),
const char **UNUSED(tooltip))
{
if (drag->type == WM_DRAG_PATH) {
- if (drag->icon == ICON_FILE_BLEND)
+ if (drag->icon == ICON_FILE_BLEND) {
return 1;
+ }
}
return 0;
}
diff --git a/source/blender/editors/screen/screendump.c b/source/blender/editors/screen/screendump.c
index 37ffdef0b9b..3b763c7d47a 100644
--- a/source/blender/editors/screen/screendump.c
+++ b/source/blender/editors/screen/screendump.c
@@ -71,8 +71,9 @@ static void screenshot_read_pixels(int x, int y, int w, int h, unsigned char *re
glFinish();
/* clear alpha, it is not set to a meaningful value in opengl */
- for (i = 0, rect += 3; i < w * h; i++, rect += 4)
+ for (i = 0, rect += 3; i < w * h; i++, rect += 4) {
*rect = 255;
+ }
}
/* get shot from frontbuffer */
@@ -137,8 +138,9 @@ static void screenshot_data_free(wmOperator *op)
ScreenshotData *scd = op->customdata;
if (scd) {
- if (scd->dumprect)
+ if (scd->dumprect) {
MEM_freeN(scd->dumprect);
+ }
MEM_freeN(scd);
op->customdata = NULL;
}
@@ -153,8 +155,9 @@ static void screenshot_crop(ImBuf *ibuf, rcti crop)
int y;
if (crop_x > 0 && crop_y > 0) {
- for (y = 0; y < crop_y; y++, to += crop_x, from += ibuf->x)
+ for (y = 0; y < crop_y; y++, to += crop_x, from += ibuf->x) {
memmove(to, from, sizeof(unsigned int) * crop_x);
+ }
ibuf->x = crop_x;
ibuf->y = crop_y;
@@ -185,8 +188,9 @@ static int screenshot_exec(bContext *C, wmOperator *op)
ibuf->rect = scd->dumprect;
/* crop to show only single editor */
- if (!RNA_boolean_get(op->ptr, "full"))
+ if (!RNA_boolean_get(op->ptr, "full")) {
screenshot_crop(ibuf, scd->crop);
+ }
if (scd->im_format.planes == R_IMF_PLANES_BW) {
/* bw screenshot? - users will notice if it fails! */
@@ -211,8 +215,9 @@ static int screenshot_exec(bContext *C, wmOperator *op)
static int screenshot_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
if (screenshot_data_create(C, op)) {
- if (RNA_struct_property_is_set(op->ptr, "filepath"))
+ if (RNA_struct_property_is_set(op->ptr, "filepath")) {
return screenshot_exec(C, op);
+ }
/* extension is added by 'screenshot_check' after */
char filepath[FILE_MAX] = "//screen";
@@ -267,8 +272,9 @@ static void screenshot_draw(bContext *UNUSED(C), wmOperator *op)
static bool screenshot_poll(bContext *C)
{
- if (G.background)
+ if (G.background) {
return false;
+ }
return WM_operator_winactive(C);
}
diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c
index f69ee66e15c..697622aae96 100644
--- a/source/blender/editors/sculpt_paint/paint_cursor.c
+++ b/source/blender/editors/sculpt_paint/paint_cursor.c
@@ -96,12 +96,15 @@ static CursorSnapshot cursor_snap = {0};
/* delete overlay cursor textures to preserve memory and invalidate all overlay flags */
void paint_cursor_delete_textures(void)
{
- if (primary_snap.overlay_texture)
+ if (primary_snap.overlay_texture) {
glDeleteTextures(1, &primary_snap.overlay_texture);
- if (secondary_snap.overlay_texture)
+ }
+ if (secondary_snap.overlay_texture) {
glDeleteTextures(1, &secondary_snap.overlay_texture);
- if (cursor_snap.overlay_texture)
+ }
+ if (cursor_snap.overlay_texture) {
glDeleteTextures(1, &cursor_snap.overlay_texture);
+ }
memset(&primary_snap, 0, sizeof(TexSnapshot));
memset(&secondary_snap, 0, sizeof(TexSnapshot));
@@ -271,16 +274,19 @@ static int load_tex(Brush *br, ViewContext *vc, float zoom, bool col, bool prima
int s = BKE_brush_size_get(vc->scene, br);
int r = 1;
- for (s >>= 1; s > 0; s >>= 1)
+ for (s >>= 1; s > 0; s >>= 1) {
r++;
+ }
size = (1 << r);
- if (size < 256)
+ if (size < 256) {
size = 256;
+ }
- if (size < target->old_size)
+ if (size < target->old_size) {
size = target->old_size;
+ }
}
else {
size = 512;
@@ -296,10 +302,12 @@ static int load_tex(Brush *br, ViewContext *vc, float zoom, bool col, bool prima
target->old_size = size;
}
- if (col)
+ if (col) {
buffer = MEM_mallocN(sizeof(GLubyte) * size * size * 4, "load_tex");
- else
+ }
+ else {
buffer = MEM_mallocN(sizeof(GLubyte) * size * size, "load_tex");
+ }
pool = BKE_image_pool_new();
@@ -324,14 +332,17 @@ static int load_tex(Brush *br, ViewContext *vc, float zoom, bool col, bool prima
BLI_parallel_range_settings_defaults(&settings);
BLI_task_parallel_range(0, size, &data, load_tex_task_cb_ex, &settings);
- if (mtex->tex && mtex->tex->nodetree)
+ if (mtex->tex && mtex->tex->nodetree) {
ntreeTexEndExecTree(mtex->tex->nodetree->execdata);
+ }
- if (pool)
+ if (pool) {
BKE_image_pool_free(pool);
+ }
- if (!target->overlay_texture)
+ if (!target->overlay_texture) {
glGenTextures(1, &target->overlay_texture);
+ }
}
else {
size = target->old_size;
@@ -352,8 +363,9 @@ static int load_tex(Brush *br, ViewContext *vc, float zoom, bool col, bool prima
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, size, size, format, GL_UNSIGNED_BYTE, buffer);
}
- if (buffer)
+ if (buffer) {
MEM_freeN(buffer);
+ }
target->old_col = col;
}
@@ -422,16 +434,19 @@ static int load_tex_cursor(Brush *br, ViewContext *vc, float zoom)
s = BKE_brush_size_get(vc->scene, br);
r = 1;
- for (s >>= 1; s > 0; s >>= 1)
+ for (s >>= 1; s > 0; s >>= 1) {
r++;
+ }
size = (1 << r);
- if (size < 256)
+ if (size < 256) {
size = 256;
+ }
- if (size < cursor_snap.size)
+ if (size < cursor_snap.size) {
size = cursor_snap.size;
+ }
if (cursor_snap.size != size) {
if (cursor_snap.overlay_texture) {
@@ -457,8 +472,9 @@ static int load_tex_cursor(Brush *br, ViewContext *vc, float zoom)
BLI_parallel_range_settings_defaults(&settings);
BLI_task_parallel_range(0, size, &data, load_tex_cursor_task_cb, &settings);
- if (!cursor_snap.overlay_texture)
+ if (!cursor_snap.overlay_texture) {
glGenTextures(1, &cursor_snap.overlay_texture);
+ }
}
else {
size = cursor_snap.size;
@@ -475,8 +491,9 @@ static int load_tex_cursor(Brush *br, ViewContext *vc, float zoom)
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, size, size, GL_RED, GL_UNSIGNED_BYTE, buffer);
}
- if (buffer)
+ if (buffer) {
MEM_freeN(buffer);
+ }
}
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
@@ -567,8 +584,9 @@ static bool sculpt_get_brush_geometry(bContext *C,
*pixel_radius = project_brush_radius(
vc, BKE_brush_unprojected_radius_get(scene, brush), location);
- if (*pixel_radius == 0)
+ if (*pixel_radius == 0) {
*pixel_radius = BKE_brush_size_get(scene, brush);
+ }
mul_m4_v3(vc->obact->obmat, location);
}
@@ -665,10 +683,12 @@ static void paint_draw_tex_overlay(UnifiedPaintSettings *ups,
quad.ymax = brush->mask_stencil_dimension[1];
}
GPU_matrix_push();
- if (primary)
+ if (primary) {
GPU_matrix_translate_2fv(brush->stencil_pos);
- else
+ }
+ else {
GPU_matrix_translate_2fv(brush->mask_stencil_pos);
+ }
GPU_matrix_rotate_2d(RAD2DEGF(mtex->rot));
}
@@ -787,8 +807,9 @@ static void paint_draw_cursor_overlay(
GPU_blend_set_func(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA);
- if (do_pop)
+ if (do_pop) {
GPU_matrix_pop();
+ }
}
}
@@ -814,18 +835,23 @@ static void paint_draw_alpha_overlay(UnifiedPaintSettings *ups,
/* coloured overlay should be drawn separately */
if (col) {
- if (!(flags & PAINT_OVERLAY_OVERRIDE_PRIMARY))
+ if (!(flags & PAINT_OVERLAY_OVERRIDE_PRIMARY)) {
paint_draw_tex_overlay(ups, brush, vc, x, y, zoom, true, true);
- if (!(flags & PAINT_OVERLAY_OVERRIDE_SECONDARY))
+ }
+ if (!(flags & PAINT_OVERLAY_OVERRIDE_SECONDARY)) {
paint_draw_tex_overlay(ups, brush, vc, x, y, zoom, false, false);
- if (!(flags & PAINT_OVERLAY_OVERRIDE_CURSOR))
+ }
+ if (!(flags & PAINT_OVERLAY_OVERRIDE_CURSOR)) {
paint_draw_cursor_overlay(ups, brush, vc, x, y, zoom);
+ }
}
else {
- if (!(flags & PAINT_OVERLAY_OVERRIDE_PRIMARY) && (mode != PAINT_MODE_WEIGHT))
+ if (!(flags & PAINT_OVERLAY_OVERRIDE_PRIMARY) && (mode != PAINT_MODE_WEIGHT)) {
paint_draw_tex_overlay(ups, brush, vc, x, y, zoom, false, true);
- if (!(flags & PAINT_OVERLAY_OVERRIDE_CURSOR))
+ }
+ if (!(flags & PAINT_OVERLAY_OVERRIDE_CURSOR)) {
paint_draw_cursor_overlay(ups, brush, vc, x, y, zoom);
+ }
}
GPU_matrix_pop();
@@ -954,7 +980,7 @@ static void paint_draw_curve_cursor(Brush *brush, ViewContext *vc)
draw_rect_point(
pos, selec_col, handle_col, &cp->bez.vec[2][0], 8.0f, cp->bez.f3 || cp->bez.f2);
- for (j = 0; j < 2; j++)
+ for (j = 0; j < 2; j++) {
BKE_curve_forward_diff_bezier(cp->bez.vec[1][j],
cp->bez.vec[2][j],
cp_next->bez.vec[0][j],
@@ -962,6 +988,7 @@ static void paint_draw_curve_cursor(Brush *brush, ViewContext *vc)
data + j,
PAINT_CURVE_NUM_SEGMENTS,
sizeof(float[2]));
+ }
float(*v)[2] = (float(*)[2])data;
@@ -1010,21 +1037,25 @@ static void paint_cursor_on_hit(UnifiedPaintSettings *ups,
/* update the brush's cached 3D radius */
if (!BKE_brush_use_locked_size(vc->scene, brush)) {
/* get 2D brush radius */
- if (ups->draw_anchored)
+ if (ups->draw_anchored) {
projected_radius = ups->anchored_size;
+ }
else {
- if (brush->flag & BRUSH_ANCHORED)
+ if (brush->flag & BRUSH_ANCHORED) {
projected_radius = 8;
- else
+ }
+ else {
projected_radius = BKE_brush_size_get(vc->scene, brush);
+ }
}
/* convert brush radius from 2D to 3D */
unprojected_radius = paint_calc_object_space_radius(vc, location, projected_radius);
/* scale 3D brush radius by pressure */
- if (ups->stroke_active && BKE_brush_use_size_pressure(vc->scene, brush))
+ if (ups->stroke_active && BKE_brush_use_size_pressure(vc->scene, brush)) {
unprojected_radius *= ups->size_pressure_value;
+ }
/* set cached value in either Brush or UnifiedPaintSettings */
BKE_brush_unprojected_radius_set(vc->scene, brush, unprojected_radius);
@@ -1053,8 +1084,9 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
ePaintMode mode = BKE_paintmode_get_active_from_context(C);
/* check that brush drawing is enabled */
- if (ommit_cursor_drawing(paint, mode, brush))
+ if (ommit_cursor_drawing(paint, mode, brush)) {
return;
+ }
/* can't use stroke vc here because this will be called during
* mouse over too, not just during a stroke */
@@ -1100,8 +1132,9 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
/* test if brush is over the mesh */
bool hit = sculpt_get_brush_geometry(C, &vc, x, y, &pixel_radius, location, ups);
- if (BKE_brush_use_locked_size(scene, brush))
+ if (BKE_brush_use_locked_size(scene, brush)) {
BKE_brush_size_set(scene, brush, pixel_radius);
+ }
/* check if brush is subtracting, use different color then */
/* TODO: no way currently to know state of pen flip or
@@ -1112,8 +1145,9 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
}
/* only do if brush is over the mesh */
- if (hit)
+ if (hit) {
paint_cursor_on_hit(ups, brush, &vc, location);
+ }
}
if (ups->draw_anchored) {
diff --git a/source/blender/editors/sculpt_paint/paint_curve.c b/source/blender/editors/sculpt_paint/paint_curve.c
index bc6e019142a..d9fd194e96f 100644
--- a/source/blender/editors/sculpt_paint/paint_curve.c
+++ b/source/blender/editors/sculpt_paint/paint_curve.c
@@ -60,13 +60,15 @@ bool paint_curve_poll(bContext *C)
RegionView3D *rv3d = CTX_wm_region_view3d(C);
SpaceImage *sima;
- if (rv3d && !(ob && ((ob->mode & OB_MODE_ALL_PAINT) != 0)))
+ if (rv3d && !(ob && ((ob->mode & OB_MODE_ALL_PAINT) != 0))) {
return false;
+ }
sima = CTX_wm_space_image(C);
- if (sima && sima->mode != SI_MODE_PAINT)
+ if (sima && sima->mode != SI_MODE_PAINT) {
return false;
+ }
p = BKE_paint_get_active_from_context(C);
@@ -95,8 +97,9 @@ static PaintCurvePoint *paintcurve_point_get_closest(
if (dist < closest_dist) {
closest = pcp;
closest_dist = dist;
- if (point)
+ if (point) {
*point = SEL_F1;
+ }
}
}
if (!ignore_pivot) {
@@ -105,8 +108,9 @@ static PaintCurvePoint *paintcurve_point_get_closest(
if (dist < closest_dist) {
closest = pcp;
closest_dist = dist;
- if (point)
+ if (point) {
*point = SEL_F2;
+ }
}
}
}
@@ -115,8 +119,9 @@ static PaintCurvePoint *paintcurve_point_get_closest(
if (dist < closest_dist) {
closest = pcp;
closest_dist = dist;
- if (point)
+ if (point) {
*point = SEL_F3;
+ }
}
}
}
@@ -213,12 +218,14 @@ static void paintcurve_point_add(bContext *C, wmOperator *op, const int loc[2])
add_index = pc->add_index;
if (pc->points) {
- if (add_index > 0)
+ if (add_index > 0) {
memcpy(pcp, pc->points, add_index * sizeof(PaintCurvePoint));
- if (add_index < pc->tot_points)
+ }
+ if (add_index < pc->tot_points) {
memcpy(pcp + add_index + 1,
pc->points + add_index,
(pc->tot_points - add_index) * sizeof(PaintCurvePoint));
+ }
MEM_freeN(pc->points);
}
@@ -332,8 +339,9 @@ static int paintcurve_delete_point_exec(bContext *C, wmOperator *op)
int j = 0;
int new_tot = pc->tot_points - tot_del;
PaintCurvePoint *points_new = NULL;
- if (new_tot > 0)
+ if (new_tot > 0) {
points_new = MEM_mallocN(new_tot * sizeof(PaintCurvePoint), "PaintCurvePoint");
+ }
for (i = 0, pcp = pc->points; i < pc->tot_points; i++, pcp++) {
if (!(pcp->bez.f2 & DELETE_TAG)) {
@@ -392,8 +400,9 @@ static bool paintcurve_point_select(
pc = br->paint_curve;
- if (!pc)
+ if (!pc) {
return false;
+ }
ED_paintcurve_undo_push_begin(op->type->name);
@@ -429,22 +438,28 @@ static bool paintcurve_point_select(
BKE_paint_curve_clamp_endpoint_add_index(pc, pcp - pc->points);
if (selflag == SEL_F2) {
- if (extend)
+ if (extend) {
pcp->bez.f2 ^= SELECT;
- else
+ }
+ else {
pcp->bez.f2 |= SELECT;
+ }
}
else if (selflag == SEL_F1) {
- if (extend)
+ if (extend) {
pcp->bez.f1 ^= SELECT;
- else
+ }
+ else {
pcp->bez.f1 |= SELECT;
+ }
}
else if (selflag == SEL_F3) {
- if (extend)
+ if (extend) {
pcp->bez.f3 ^= SELECT;
- else
+ }
+ else {
pcp->bez.f3 |= SELECT;
+ }
}
}
@@ -495,8 +510,9 @@ static int paintcurve_select_point_exec(bContext *C, wmOperator *op)
bool toggle = RNA_boolean_get(op->ptr, "toggle");
bool extend = RNA_boolean_get(op->ptr, "extend");
RNA_int_get_array(op->ptr, "location", loc);
- if (paintcurve_point_select(C, op, loc, toggle, extend))
+ if (paintcurve_point_select(C, op, loc, toggle, extend)) {
return OPERATOR_FINISHED;
+ }
}
return OPERATOR_CANCELLED;
@@ -557,8 +573,9 @@ static int paintcurve_slide_invoke(bContext *C, wmOperator *op, const wmEvent *e
PaintCurve *pc = br->paint_curve;
PaintCurvePoint *pcp;
- if (!pc)
+ if (!pc) {
return OPERATOR_PASS_THROUGH;
+ }
if (do_select) {
pcp = paintcurve_point_get_closest(pc, loc_fl, align, PAINT_CURVE_SELECT_THRESHOLD, &select);
@@ -589,8 +606,9 @@ static int paintcurve_slide_invoke(bContext *C, wmOperator *op, const wmEvent *e
op->customdata = psd;
/* first, clear all selection from points */
- for (i = 0; i < pc->tot_points; i++)
+ for (i = 0; i < pc->tot_points; i++) {
pc->points[i].bez.f1 = pc->points[i].bez.f3 = pc->points[i].bez.f2 = 0;
+ }
/* only select the active point */
PAINT_CURVE_POINT_SELECT(pcp, psd->select);
@@ -622,8 +640,9 @@ static int paintcurve_slide_modal(bContext *C, wmOperator *op, const wmEvent *ev
float diff[2] = {event->mval[0] - psd->initial_loc[0], event->mval[1] - psd->initial_loc[1]};
if (psd->select == 1) {
int i;
- for (i = 0; i < 3; i++)
+ for (i = 0; i < 3; i++) {
add_v2_v2v2(psd->pcp->bez.vec[i], diff, psd->point_initial_loc[i]);
+ }
}
else {
add_v2_v2(diff, psd->point_initial_loc[psd->select]);
@@ -718,8 +737,9 @@ static int paintcurve_cursor_invoke(bContext *C, wmOperator *UNUSED(op), const w
SpaceImage *sima = CTX_wm_space_image(C);
float location[2];
- if (!sima)
+ if (!sima) {
return OPERATOR_CANCELLED;
+ }
UI_view2d_region_to_view(
&ar->v2d, event->mval[0], event->mval[1], &location[0], &location[1]);
diff --git a/source/blender/editors/sculpt_paint/paint_hide.c b/source/blender/editors/sculpt_paint/paint_hide.c
index c1f87f676e2..dded9fcf45a 100644
--- a/source/blender/editors/sculpt_paint/paint_hide.c
+++ b/source/blender/editors/sculpt_paint/paint_hide.c
@@ -66,8 +66,9 @@ static bool is_effected(PartialVisArea area,
const float co[3],
const float mask)
{
- if (area == PARTIALVIS_ALL)
+ if (area == PARTIALVIS_ALL) {
return 1;
+ }
else if (area == PARTIALVIS_MASKED) {
return mask > 0.5f;
}
@@ -103,15 +104,18 @@ static void partialvis_update_mesh(Object *ob,
/* hide vertex if in the hide volume */
if (is_effected(area, planes, v->co, vmask)) {
- if (action == PARTIALVIS_HIDE)
+ if (action == PARTIALVIS_HIDE) {
v->flag |= ME_HIDE;
- else
+ }
+ else {
v->flag &= ~ME_HIDE;
+ }
any_changed = true;
}
- if (!(v->flag & ME_HIDE))
+ if (!(v->flag & ME_HIDE)) {
any_visible = true;
+ }
}
if (any_changed) {
@@ -183,10 +187,12 @@ static void partialvis_update_grids(Object *ob,
}
/* keep track of whether any elements are still hidden */
- if (BLI_BITMAP_TEST(gh, y * key.grid_size + x))
+ if (BLI_BITMAP_TEST(gh, y * key.grid_size + x)) {
any_hidden = true;
- else
+ }
+ else {
any_visible = true;
+ }
}
}
@@ -222,15 +228,18 @@ static void partialvis_update_bmesh_verts(BMesh *bm,
/* hide vertex if in the hide volume */
if (is_effected(area, planes, v->co, *vmask)) {
- if (action == PARTIALVIS_HIDE)
+ if (action == PARTIALVIS_HIDE) {
BM_elem_flag_enable(v, BM_ELEM_HIDDEN);
- else
+ }
+ else {
BM_elem_flag_disable(v, BM_ELEM_HIDDEN);
+ }
(*any_changed) = true;
}
- if (!BM_elem_flag_test(v, BM_ELEM_HIDDEN))
+ if (!BM_elem_flag_test(v, BM_ELEM_HIDDEN)) {
(*any_visible) = true;
+ }
}
}
@@ -241,10 +250,12 @@ static void partialvis_update_bmesh_faces(GSet *faces)
GSET_ITER (gs_iter, faces) {
BMFace *f = BLI_gsetIterator_getKey(&gs_iter);
- if (paint_is_bmesh_face_hidden(f))
+ if (paint_is_bmesh_face_hidden(f)) {
BM_elem_flag_enable(f, BM_ELEM_HIDDEN);
- else
+ }
+ else {
BM_elem_flag_disable(f, BM_ELEM_HIDDEN);
+ }
}
}
@@ -375,8 +386,9 @@ static int hide_show_exec(bContext *C, wmOperator *op)
}
}
- if (nodes)
+ if (nodes) {
MEM_freeN(nodes);
+ }
/* end undo */
sculpt_undo_push_end();
@@ -396,10 +408,12 @@ static int hide_show_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
PartialVisArea area = RNA_enum_get(op->ptr, "area");
- if (!ELEM(area, PARTIALVIS_ALL, PARTIALVIS_MASKED))
+ if (!ELEM(area, PARTIALVIS_ALL, PARTIALVIS_MASKED)) {
return WM_gesture_box_invoke(C, op, event);
- else
+ }
+ else {
return op->type->exec(C, op);
+ }
}
void PAINT_OT_hide_show(struct wmOperatorType *ot)
diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c
index b82014dcfec..5a45f4946f2 100644
--- a/source/blender/editors/sculpt_paint/paint_image.c
+++ b/source/blender/editors/sculpt_paint/paint_image.c
@@ -126,8 +126,9 @@ void ED_imapaint_dirty_region(Image *ima, ImBuf *ibuf, int x, int y, int w, int
IMB_rectclip(ibuf, NULL, &x, &y, &srcx, &srcy, &w, &h);
- if (w == 0 || h == 0)
+ if (w == 0 || h == 0) {
return;
+ }
if (!imapaintpartial.enabled) {
imapaintpartial.x1 = x;
@@ -147,14 +148,17 @@ void ED_imapaint_dirty_region(Image *ima, ImBuf *ibuf, int x, int y, int w, int
ListBase *undo_tiles = ED_image_undo_get_tiles();
- for (ty = tiley; ty <= tileh; ty++)
- for (tx = tilex; tx <= tilew; tx++)
+ for (ty = tiley; ty <= tileh; ty++) {
+ for (tx = tilex; tx <= tilew; tx++) {
image_undo_push_tile(undo_tiles, ima, ibuf, &tmpibuf, tx, ty, NULL, NULL, false, find_old);
+ }
+ }
ibuf->userflags |= IB_BITMAPDIRTY;
- if (tmpibuf)
+ if (tmpibuf) {
IMB_freeImBuf(tmpibuf);
+ }
}
void imapaint_image_update(SpaceImage *sima, Image *image, ImBuf *ibuf, short texpaint)
@@ -164,8 +168,9 @@ void imapaint_image_update(SpaceImage *sima, Image *image, ImBuf *ibuf, short te
ibuf, imapaintpartial.x1, imapaintpartial.y1, imapaintpartial.x2, imapaintpartial.y2);
}
- if (ibuf->mipmap[0])
+ if (ibuf->mipmap[0]) {
ibuf->userflags |= IB_MIPMAP_INVALID;
+ }
/* todo: should set_tpage create ->rect? */
if (texpaint || (sima && sima->lock)) {
@@ -197,8 +202,9 @@ BlurKernel *paint_new_blur_kernel(Brush *br, bool proj)
kernel->pixel_len = radius;
}
else {
- if (br->blur_kernel_radius <= 0)
+ if (br->blur_kernel_radius <= 0) {
br->blur_kernel_radius = 1;
+ }
radius = br->blur_kernel_radius;
@@ -210,8 +216,9 @@ BlurKernel *paint_new_blur_kernel(Brush *br, bool proj)
switch (type) {
case KERNEL_BOX:
- for (i = 0; i < kernel->side_squared; i++)
+ for (i = 0; i < kernel->side_squared; i++) {
kernel->wdata[i] = 1.0;
+ }
break;
case KERNEL_GAUSSIAN: {
@@ -246,8 +253,9 @@ BlurKernel *paint_new_blur_kernel(Brush *br, bool proj)
void paint_delete_blur_kernel(BlurKernel *kernel)
{
- if (kernel->wdata)
+ if (kernel->wdata) {
MEM_freeN(kernel->wdata);
+ }
}
/************************ image paint poll ************************/
@@ -264,8 +272,9 @@ static bool image_paint_poll_ex(bContext *C, bool check_tool)
{
Object *obact;
- if (!image_paint_brush(C))
+ if (!image_paint_brush(C)) {
return 0;
+ }
obact = CTX_data_active_object(C);
if ((obact && obact->mode & OB_MODE_TEXTURE_PAINT) && CTX_wm_region_view3d(C)) {
@@ -302,10 +311,13 @@ static bool image_paint_2d_clone_poll(bContext *C)
{
Brush *brush = image_paint_brush(C);
- if (!CTX_wm_region_view3d(C) && image_paint_poll(C))
- if (brush && (brush->imagepaint_tool == PAINT_TOOL_CLONE))
- if (brush->clone.image)
+ if (!CTX_wm_region_view3d(C) && image_paint_poll(C)) {
+ if (brush && (brush->imagepaint_tool == PAINT_TOOL_CLONE)) {
+ if (brush->clone.image) {
return 1;
+ }
+ }
+ }
return 0;
}
@@ -353,8 +365,9 @@ void paint_brush_color_get(struct Scene *scene,
float color[3],
struct ColorManagedDisplay *display)
{
- if (invert)
+ if (invert) {
copy_v3_v3(color, BKE_brush_secondary_color_get(scene, br));
+ }
else {
if (br->flag & BRUSH_USE_GRADIENT) {
float color_gr[4];
@@ -374,11 +387,13 @@ void paint_brush_color_get(struct Scene *scene,
}
copy_v3_v3(color, color_gr);
}
- else
+ else {
copy_v3_v3(color, BKE_brush_color_get(scene, br));
+ }
}
- if (color_correction)
+ if (color_correction) {
IMB_colormanagement_display_to_scene_linear_v3(color, display);
+ }
}
void paint_brush_init_tex(Brush *brush)
@@ -401,11 +416,13 @@ void paint_brush_exit_tex(Brush *brush)
{
if (brush) {
MTex *mtex = &brush->mtex;
- if (mtex->tex && mtex->tex->nodetree)
+ if (mtex->tex && mtex->tex->nodetree) {
ntreeTexEndExecTree(mtex->tex->nodetree->execdata);
+ }
mtex = &brush->mask_mtex;
- if (mtex->tex && mtex->tex->nodetree)
+ if (mtex->tex && mtex->tex->nodetree) {
ntreeTexEndExecTree(mtex->tex->nodetree->execdata);
+ }
}
}
@@ -528,10 +545,12 @@ static void paint_stroke_update_step(bContext *C, struct PaintStroke *stroke, Po
return;
}
- if (BKE_brush_use_alpha_pressure(scene, brush))
+ if (BKE_brush_use_alpha_pressure(scene, brush)) {
BKE_brush_alpha_set(scene, brush, max_ff(0.0f, startalpha * pressure * alphafac));
- else
+ }
+ else {
BKE_brush_alpha_set(scene, brush, max_ff(0.0f, startalpha * alphafac));
+ }
if ((brush->flag & BRUSH_DRAG_DOT) || (brush->flag & BRUSH_ANCHORED)) {
UndoStack *ustack = CTX_wm_manager(C)->undo_stack;
@@ -697,8 +716,9 @@ static int paint_exec(bContext *C, wmOperator *op)
strokeprop = RNA_struct_find_property(op->ptr, "stroke");
- if (!RNA_property_collection_lookup_int(op->ptr, strokeprop, 0, &firstpoint))
+ if (!RNA_property_collection_lookup_int(op->ptr, strokeprop, 0, &firstpoint)) {
return OPERATOR_CANCELLED;
+ }
RNA_float_get_array(&firstpoint, "mouse", mouse);
@@ -767,8 +787,9 @@ static void toggle_paint_cursor(bContext *C, int enable)
settings->imapaint.paintcursor = NULL;
paint_cursor_delete_textures();
}
- else if (enable)
+ else if (enable) {
paint_cursor_start(C, image_paint_poll);
+ }
}
/* enable the paint cursor if it isn't already.
@@ -1094,12 +1115,15 @@ void PAINT_OT_sample_color(wmOperatorType *ot)
static bool texture_paint_toggle_poll(bContext *C)
{
Object *ob = CTX_data_active_object(C);
- if (ob == NULL || ob->type != OB_MESH)
+ if (ob == NULL || ob->type != OB_MESH) {
return 0;
- if (!ob->data || ID_IS_LINKED(ob->data))
+ }
+ if (!ob->data || ID_IS_LINKED(ob->data)) {
return 0;
- if (CTX_data_edit_object(C))
+ }
+ if (CTX_data_edit_object(C)) {
return 0;
+ }
return 1;
}
@@ -1122,8 +1146,9 @@ static int texture_paint_toggle_exec(bContext *C, wmOperator *op)
if (ob->mode & mode_flag) {
ob->mode &= ~mode_flag;
- if (U.glreslimit != 0)
+ if (U.glreslimit != 0) {
GPU_free_images(bmain);
+ }
GPU_paint_set_mipmap(bmain, 1);
toggle_paint_cursor(C, 0);
@@ -1144,8 +1169,9 @@ static int texture_paint_toggle_exec(bContext *C, wmOperator *op)
/* set the current material active paint slot on image editor */
Material *ma = give_current_material(ob, ob->actcol);
- if (ma && ma->texpaintslot)
+ if (ma && ma->texpaintslot) {
ima = ma->texpaintslot[ma->paint_active_slot].ima;
+ }
}
else if (imapaint->mode == IMAGEPAINT_MODE_IMAGE) {
ima = imapaint->canvas;
@@ -1176,8 +1202,9 @@ static int texture_paint_toggle_exec(bContext *C, wmOperator *op)
BKE_paint_toolslots_brush_validate(bmain, &imapaint->paint);
- if (U.glreslimit != 0)
+ if (U.glreslimit != 0) {
GPU_free_images(bmain);
+ }
GPU_paint_set_mipmap(bmain, 0);
toggle_paint_cursor(C, 1);
@@ -1235,8 +1262,9 @@ static bool brush_colors_flip_poll(bContext *C)
{
if (image_paint_poll(C)) {
Brush *br = image_paint_brush(C);
- if (ELEM(br->imagepaint_tool, PAINT_TOOL_DRAW, PAINT_TOOL_FILL))
+ if (ELEM(br->imagepaint_tool, PAINT_TOOL_DRAW, PAINT_TOOL_FILL)) {
return true;
+ }
}
else {
Object *ob = CTX_data_active_object(C);
@@ -1283,9 +1311,11 @@ void ED_imapaint_bucket_fill(struct bContext *C, float color[3], wmOperator *op)
static bool texture_paint_poll(bContext *C)
{
- if (texture_paint_toggle_poll(C))
- if (CTX_data_active_object(C)->mode & OB_MODE_TEXTURE_PAINT)
+ if (texture_paint_toggle_poll(C)) {
+ if (CTX_data_active_object(C)->mode & OB_MODE_TEXTURE_PAINT) {
return 1;
+ }
+ }
return 0;
}
diff --git a/source/blender/editors/sculpt_paint/paint_image_2d.c b/source/blender/editors/sculpt_paint/paint_image_2d.c
index 5390f18304a..78832bbbd8f 100644
--- a/source/blender/editors/sculpt_paint/paint_image_2d.c
+++ b/source/blender/editors/sculpt_paint/paint_image_2d.c
@@ -158,14 +158,18 @@ static void brush_painter_2d_require_imbuf(BrushPainter *painter,
Brush *brush = painter->brush;
if ((painter->cache.use_float != use_float)) {
- if (painter->cache.ibuf)
+ if (painter->cache.ibuf) {
IMB_freeImBuf(painter->cache.ibuf);
- if (painter->cache.curve_mask)
+ }
+ if (painter->cache.curve_mask) {
MEM_freeN(painter->cache.curve_mask);
- if (painter->cache.tex_mask)
+ }
+ if (painter->cache.tex_mask) {
MEM_freeN(painter->cache.tex_mask);
- if (painter->cache.tex_mask_old)
+ }
+ if (painter->cache.tex_mask_old) {
MEM_freeN(painter->cache.tex_mask_old);
+ }
painter->cache.ibuf = NULL;
painter->cache.curve_mask = NULL;
painter->cache.tex_mask = NULL;
@@ -182,16 +186,21 @@ static void brush_painter_2d_require_imbuf(BrushPainter *painter,
static void brush_painter_2d_free(BrushPainter *painter)
{
- if (painter->cache.ibuf)
+ if (painter->cache.ibuf) {
IMB_freeImBuf(painter->cache.ibuf);
- if (painter->cache.texibuf)
+ }
+ if (painter->cache.texibuf) {
IMB_freeImBuf(painter->cache.texibuf);
- if (painter->cache.curve_mask)
+ }
+ if (painter->cache.curve_mask) {
MEM_freeN(painter->cache.curve_mask);
- if (painter->cache.tex_mask)
+ }
+ if (painter->cache.tex_mask) {
MEM_freeN(painter->cache.tex_mask);
- if (painter->cache.tex_mask_old)
+ }
+ if (painter->cache.tex_mask_old) {
MEM_freeN(painter->cache.tex_mask_old);
+ }
MEM_freeN(painter);
}
@@ -297,9 +306,10 @@ static void brush_painter_mask_imbuf_partial_update(BrushPainter *painter,
int destx, desty, srcx, srcy, w, h, x1, y1, x2, y2;
/* create brush image buffer if it didn't exist yet */
- if (!cache->tex_mask)
+ if (!cache->tex_mask) {
cache->tex_mask = MEM_mallocN(sizeof(unsigned short) * diameter * diameter,
"brush_painter_mask");
+ }
/* create new texture image buffer with coordinates relative to old */
tex_mask_old = cache->tex_mask_old;
@@ -334,21 +344,27 @@ static void brush_painter_mask_imbuf_partial_update(BrushPainter *painter,
y2 = min_ii(desty + h, diameter);
/* blend existing texture in new position */
- if ((x1 < x2) && (y1 < y2))
+ if ((x1 < x2) && (y1 < y2)) {
brush_painter_mask_imbuf_update(painter, tex_mask_old, x1, y1, x2, y2, srcx, srcy, diameter);
+ }
- if (tex_mask_old)
+ if (tex_mask_old) {
MEM_freeN(tex_mask_old);
+ }
/* sample texture in new areas */
- if ((0 < x1) && (0 < diameter))
+ if ((0 < x1) && (0 < diameter)) {
brush_painter_mask_imbuf_update(painter, NULL, 0, 0, x1, diameter, 0, 0, diameter);
- if ((x2 < diameter) && (0 < diameter))
+ }
+ if ((x2 < diameter) && (0 < diameter)) {
brush_painter_mask_imbuf_update(painter, NULL, x2, 0, diameter, diameter, 0, 0, diameter);
- if ((x1 < x2) && (0 < y1))
+ }
+ if ((x1 < x2) && (0 < y1)) {
brush_painter_mask_imbuf_update(painter, NULL, x1, 0, x2, y1, 0, 0, diameter);
- if ((x1 < x2) && (y2 < diameter))
+ }
+ if ((x1 < x2) && (y2 < diameter)) {
brush_painter_mask_imbuf_update(painter, NULL, x1, y2, x2, diameter, 0, 0, diameter);
+ }
/* through with sampling, now update sizes */
cache->tex_mask_old_w = diameter;
@@ -556,8 +572,9 @@ static void brush_painter_imbuf_update(
crgba[2] = ot[2];
crgba[3] = ot[3];
}
- else
+ else {
rgba_float_to_uchar(crgba, rgba);
+ }
/* write to new texture buffer */
t[0] = crgba[0];
@@ -588,8 +605,9 @@ static void brush_painter_imbuf_partial_update(BrushPainter *painter,
/* create brush image buffer if it didn't exist yet */
imbflag = (cache->use_float) ? IB_rectfloat : IB_rect;
- if (!cache->ibuf)
+ if (!cache->ibuf) {
cache->ibuf = IMB_allocImBuf(diameter, diameter, 32, imbflag);
+ }
ibuf = cache->ibuf;
/* create new texture image buffer with coordinates relative to old */
@@ -617,21 +635,27 @@ static void brush_painter_imbuf_partial_update(BrushPainter *painter,
y2 = min_ii(desty + h, ibuf->y);
/* blend existing texture in new position */
- if ((x1 < x2) && (y1 < y2))
+ if ((x1 < x2) && (y1 < y2)) {
brush_painter_imbuf_update(painter, oldtexibuf, x1, y1, x2, y2, srcx, srcy);
+ }
- if (oldtexibuf)
+ if (oldtexibuf) {
IMB_freeImBuf(oldtexibuf);
+ }
/* sample texture in new areas */
- if ((0 < x1) && (0 < ibuf->y))
+ if ((0 < x1) && (0 < ibuf->y)) {
brush_painter_imbuf_update(painter, NULL, 0, 0, x1, ibuf->y, 0, 0);
- if ((x2 < ibuf->x) && (0 < ibuf->y))
+ }
+ if ((x2 < ibuf->x) && (0 < ibuf->y)) {
brush_painter_imbuf_update(painter, NULL, x2, 0, ibuf->x, ibuf->y, 0, 0);
- if ((x1 < x2) && (0 < y1))
+ }
+ if ((x1 < x2) && (0 < y1)) {
brush_painter_imbuf_update(painter, NULL, x1, 0, x2, y1, 0, 0);
- if ((x1 < x2) && (y2 < ibuf->y))
+ }
+ if ((x1 < x2) && (y2 < ibuf->y)) {
brush_painter_imbuf_update(painter, NULL, x1, y2, x2, ibuf->y, 0, 0);
+ }
}
static void brush_painter_2d_tex_mapping(ImagePaintState *s,
@@ -716,10 +740,12 @@ static void brush_painter_2d_refresh_cache(ImagePaintState *s,
if (brush->mtex.brush_map_mode == MTEX_MAP_MODE_VIEW) {
tex_rotation += ups->brush_rotation;
}
- else if (brush->mtex.brush_map_mode == MTEX_MAP_MODE_RANDOM)
+ else if (brush->mtex.brush_map_mode == MTEX_MAP_MODE_RANDOM) {
do_random = true;
- else if (!((brush->flag & BRUSH_ANCHORED) || update_color))
+ }
+ else if (!((brush->flag & BRUSH_ANCHORED) || update_color)) {
do_partial_update = true;
+ }
brush_painter_2d_tex_mapping(s,
diameter,
@@ -765,10 +791,12 @@ static void brush_painter_2d_refresh_cache(ImagePaintState *s,
brush->mask_mtex.brush_map_mode,
&painter->mask_mapping);
- if (do_partial_update_mask)
+ if (do_partial_update_mask) {
brush_painter_mask_imbuf_partial_update(painter, pos, diameter);
- else
+ }
+ else {
cache->tex_mask = brush_painter_mask_ibuf_new(painter, diameter);
+ }
cache->last_mask_rotation = mask_rotation;
}
}
@@ -835,11 +863,13 @@ static void paint_2d_ibuf_rgb_set(
{
if (is_torus) {
x %= ibuf->x;
- if (x < 0)
+ if (x < 0) {
x += ibuf->x;
+ }
y %= ibuf->y;
- if (y < 0)
+ if (y < 0) {
y += ibuf->y;
+ }
}
if (ibuf->rect_float) {
@@ -865,13 +895,15 @@ static void paint_2d_ibuf_tile_convert(ImBuf *ibuf, int *x, int *y, short tile)
{
if (tile & PAINT_TILE_X) {
*x %= ibuf->x;
- if (*x < 0)
+ if (*x < 0) {
*x += ibuf->x;
+ }
}
if (tile & PAINT_TILE_Y) {
*y %= ibuf->y;
- if (*y < 0)
+ if (*y < 0) {
*y += ibuf->y;
+ }
}
}
@@ -879,15 +911,17 @@ static float paint_2d_ibuf_add_if(ImBuf *ibuf, int x, int y, float *outrgb, shor
{
float inrgb[4];
- if (tile)
+ if (tile) {
paint_2d_ibuf_tile_convert(ibuf, &x, &y, tile);
+ }
/* need to also do clipping here always since tiled coordinates
* are not always within bounds */
if (x < ibuf->x && x >= 0 && y < ibuf->y && y >= 0) {
paint_2d_ibuf_rgb_get(ibuf, x, y, inrgb);
}
- else
+ else {
return 0;
+ }
mul_v4_fl(inrgb, w);
add_v4_v4(outrgb, inrgb);
@@ -917,8 +951,9 @@ static void paint_2d_lift_soften(
if (!tile) {
IMB_rectclip(ibuf, ibufb, &in_off[0], &in_off[1], &out_off[0], &out_off[1], &dim[0], &dim[1]);
- if ((dim[0] == 0) || (dim[1] == 0))
+ if ((dim[0] == 0) || (dim[1] == 0)) {
return;
+ }
}
/* find offset inside mask buffers to sample them */
@@ -933,10 +968,12 @@ static void paint_2d_lift_soften(
count = 0.0;
if (tile) {
paint_2d_ibuf_tile_convert(ibuf, &xi, &yi, tile);
- if (xi < ibuf->x && xi >= 0 && yi < ibuf->y && yi >= 0)
+ if (xi < ibuf->x && xi >= 0 && yi < ibuf->y && yi >= 0) {
paint_2d_ibuf_rgb_get(ibuf, xi, yi, rgba);
- else
+ }
+ else {
zero_v4(rgba);
+ }
}
else {
/* coordinates have been clipped properly here, it should be safe to do this */
@@ -974,12 +1011,14 @@ static void paint_2d_lift_soften(
blend_color_add_float(outrgb, rgba, outrgb);
outrgb[3] = alpha;
}
- else
+ else {
copy_v4_v4(outrgb, rgba);
+ }
}
}
- else
+ else {
copy_v4_v4(outrgb, rgba);
+ }
/* write into brush buffer */
xo = out_off[0] + x;
yo = out_off[1] + y;
@@ -1015,19 +1054,23 @@ static int paint_2d_torus_split_region(ImagePaintRegion region[4],
/* convert destination and source coordinates to be within image */
if (tile & PAINT_TILE_X) {
destx = destx % dbuf->x;
- if (destx < 0)
+ if (destx < 0) {
destx += dbuf->x;
+ }
srcx = srcx % sbuf->x;
- if (srcx < 0)
+ if (srcx < 0) {
srcx += sbuf->x;
+ }
}
if (tile & PAINT_TILE_Y) {
desty = desty % dbuf->y;
- if (desty < 0)
+ if (desty < 0) {
desty += dbuf->y;
+ }
srcy = srcy % sbuf->y;
- if (srcy < 0)
+ if (srcy < 0) {
srcy += sbuf->y;
+ }
}
/* clip width of blending area to destination imbuf, to avoid writing the
* same pixel twice */
@@ -1039,13 +1082,15 @@ static int paint_2d_torus_split_region(ImagePaintRegion region[4],
paint_2d_set_region(&region[tot++], destx, desty, srcx, srcy, w, h);
/* do 3 other rects if needed */
- if ((tile & PAINT_TILE_X) && w < origw)
+ if ((tile & PAINT_TILE_X) && w < origw) {
paint_2d_set_region(
&region[tot++], (destx + w) % dbuf->x, desty, (srcx + w) % sbuf->x, srcy, origw - w, h);
- if ((tile & PAINT_TILE_Y) && h < origh)
+ }
+ if ((tile & PAINT_TILE_Y) && h < origh) {
paint_2d_set_region(
&region[tot++], destx, (desty + h) % dbuf->y, srcx, (srcy + h) % sbuf->y, w, origh - h);
- if ((tile & PAINT_TILE_X) && (tile & PAINT_TILE_Y) && (w < origw) && (h < origh))
+ }
+ if ((tile & PAINT_TILE_X) && (tile & PAINT_TILE_Y) && (w < origw) && (h < origh)) {
paint_2d_set_region(&region[tot++],
(destx + w) % dbuf->x,
(desty + h) % dbuf->y,
@@ -1053,6 +1098,7 @@ static int paint_2d_torus_split_region(ImagePaintRegion region[4],
(srcy + h) % sbuf->y,
origw - w,
origh - h);
+ }
return tot;
}
@@ -1065,7 +1111,7 @@ static void paint_2d_lift_smear(ImBuf *ibuf, ImBuf *ibufb, int *pos, short tile)
paint_2d_set_region(region, 0, 0, pos[0], pos[1], ibufb->x, ibufb->y);
tot = paint_2d_torus_split_region(region, ibufb, ibuf, tile);
- for (a = 0; a < tot; a++)
+ for (a = 0; a < tot; a++) {
IMB_rectblend(ibufb,
ibufb,
ibuf,
@@ -1083,6 +1129,7 @@ static void paint_2d_lift_smear(ImBuf *ibuf, ImBuf *ibufb, int *pos, short tile)
region[a].height,
IMB_BLEND_COPY,
false);
+ }
}
static ImBuf *paint_2d_lift_clone(ImBuf *ibuf, ImBuf *ibufb, int *pos)
@@ -1161,11 +1208,13 @@ static void paint_2d_do_making_brush(ImagePaintState *s,
int origx = region->destx - tx * IMAPAINT_TILE_SIZE;
int origy = region->desty - ty * IMAPAINT_TILE_SIZE;
- if (s->canvas->rect_float)
+ if (s->canvas->rect_float) {
tmpbuf.rect_float = image_undo_find_tile(
undo_tiles, s->image, s->canvas, tx, ty, &mask, false);
- else
+ }
+ else {
tmpbuf.rect = image_undo_find_tile(undo_tiles, s->image, s->canvas, tx, ty, &mask, false);
+ }
IMB_rectblend(s->canvas,
&tmpbuf,
@@ -1244,8 +1293,9 @@ static int paint_2d_op(void *state,
blend = IMB_BLEND_INTERPOLATE;
}
else if (s->tool == PAINT_TOOL_SMEAR) {
- if (lastpos[0] == pos[0] && lastpos[1] == pos[1])
+ if (lastpos[0] == pos[0] && lastpos[1] == pos[1]) {
return 0;
+ }
paint_2d_convert_brushco(ibufb, lastpos, blastpos);
paint_2d_lift_smear(s->canvas, ibufb, blastpos, tile);
@@ -1337,8 +1387,9 @@ static int paint_2d_op(void *state,
}
}
- if (clonebuf)
+ if (clonebuf) {
IMB_freeImBuf(clonebuf);
+ }
return 1;
}
@@ -1359,8 +1410,9 @@ static int paint_2d_canvas_set(ImagePaintState *s, Image *ima)
s->warnmultifile = ima->id.name + 2;
return 0;
}
- else if (!ibuf || !(ibuf->rect || ibuf->rect_float))
+ else if (!ibuf || !(ibuf->rect || ibuf->rect_float)) {
return 0;
+ }
s->image = ima;
s->canvas = ibuf;
@@ -1382,8 +1434,9 @@ static int paint_2d_canvas_set(ImagePaintState *s, Image *ima)
if (s->canvas->rect_float && !s->clonecanvas->rect_float) {
IMB_float_from_rect(s->clonecanvas);
}
- else if (!s->canvas->rect_float && !s->clonecanvas->rect)
+ else if (!s->canvas->rect_float && !s->clonecanvas->rect) {
IMB_rect_from_float(s->clonecanvas);
+ }
}
/* set masking */
@@ -1419,12 +1472,14 @@ void paint_2d_stroke(void *ps,
ImBuf *ibuf = BKE_image_acquire_ibuf(s->image, s->sima ? &s->sima->iuser : NULL, NULL);
const bool is_data = (ibuf && ibuf->colormanage_flag & IMB_COLORMANAGE_IS_DATA);
- if (!ibuf)
+ if (!ibuf) {
return;
+ }
s->blend = s->brush->blend;
- if (eraser)
+ if (eraser) {
s->blend = IMB_BLEND_ERASE_ALPHA;
+ }
UI_view2d_region_to_view(s->v2d, mval[0], mval[1], &newuv[0], &newuv[1]);
UI_view2d_region_to_view(s->v2d, prev_mval[0], prev_mval[1], &olduv[0], &olduv[1]);
@@ -1463,8 +1518,9 @@ void paint_2d_stroke(void *ps,
painter->cache.curve_mask,
painter->cache.tex_mask,
olduv,
- newuv))
+ newuv)) {
s->need_redraw = true;
+ }
BKE_image_release_ibuf(s->image, ibuf, NULL);
}
@@ -1490,10 +1546,12 @@ void *paint_2d_new_stroke(bContext *C, wmOperator *op, int mode)
s->symmetry = settings->imapaint.paint.symmetry_flags;
if (!paint_2d_canvas_set(s, s->image)) {
- if (s->warnmultifile)
+ if (s->warnmultifile) {
BKE_report(op->reports, RPT_WARNING, "Image requires 4 color channels to paint");
- if (s->warnpackedfile)
+ }
+ if (s->warnpackedfile) {
BKE_report(op->reports, RPT_WARNING, "Packed MultiLayer files cannot be painted");
+ }
MEM_freeN(s);
return NULL;
@@ -1530,18 +1588,21 @@ void paint_2d_redraw(const bContext *C, void *ps, bool final)
}
if (final) {
- if (s->image && !(s->sima && s->sima->lock))
+ if (s->image && !(s->sima && s->sima->lock)) {
GPU_free_image(s->image);
+ }
/* compositor listener deals with updating */
WM_event_add_notifier(C, NC_IMAGE | NA_EDITED, s->image);
DEG_id_tag_update(&s->image->id, 0);
}
else {
- if (!s->sima || !s->sima->lock)
+ if (!s->sima || !s->sima->lock) {
ED_region_tag_redraw(CTX_wm_region(C));
- else
+ }
+ else {
WM_event_add_notifier(C, NC_IMAGE | NA_PAINTING, s->image);
+ }
}
}
@@ -1566,8 +1627,9 @@ static void paint_2d_fill_add_pixel_byte(const int x_px,
{
size_t coordinate;
- if (x_px >= ibuf->x || x_px < 0 || y_px >= ibuf->y || y_px < 0)
+ if (x_px >= ibuf->x || x_px < 0 || y_px >= ibuf->y || y_px < 0) {
return;
+ }
coordinate = ((size_t)y_px) * ibuf->x + x_px;
@@ -1594,8 +1656,9 @@ static void paint_2d_fill_add_pixel_float(const int x_px,
{
size_t coordinate;
- if (x_px >= ibuf->x || x_px < 0 || y_px >= ibuf->y || y_px < 0)
+ if (x_px >= ibuf->x || x_px < 0 || y_px >= ibuf->y || y_px < 0) {
return;
+ }
coordinate = ((size_t)y_px) * ibuf->x + x_px;
@@ -1624,13 +1687,15 @@ void paint_2d_bucket_fill(
bool do_float;
- if (!ima)
+ if (!ima) {
return;
+ }
ibuf = BKE_image_acquire_ibuf(ima, &sima->iuser, NULL);
- if (!ibuf)
+ if (!ibuf) {
return;
+ }
do_float = (ibuf->rect_float != NULL);
/* first check if our image is float. If it is not we should correct the color to
@@ -1742,14 +1807,18 @@ void paint_2d_bucket_fill(
paint_2d_fill_add_pixel_float(
x_px + 1, y_px + 1, ibuf, stack, touched, pixel_color, threshold_sq);
- if (x_px > maxx)
+ if (x_px > maxx) {
maxx = x_px;
- if (x_px < minx)
+ }
+ if (x_px < minx) {
minx = x_px;
- if (y_px > maxy)
+ }
+ if (y_px > maxy) {
maxy = y_px;
- if (x_px > miny)
+ }
+ if (x_px > miny) {
miny = y_px;
+ }
}
}
else {
@@ -1782,14 +1851,18 @@ void paint_2d_bucket_fill(
paint_2d_fill_add_pixel_byte(
x_px + 1, y_px + 1, ibuf, stack, touched, pixel_color, threshold_sq);
- if (x_px > maxx)
+ if (x_px > maxx) {
maxx = x_px;
- if (x_px < minx)
+ }
+ if (x_px < minx) {
minx = x_px;
- if (y_px > maxy)
+ }
+ if (y_px > maxy) {
maxy = y_px;
- if (x_px > miny)
+ }
+ if (x_px > miny) {
miny = y_px;
+ }
}
}
@@ -1822,13 +1895,15 @@ void paint_2d_gradient_fill(
bool do_float;
- if (!ima)
+ if (!ima) {
return;
+ }
ibuf = BKE_image_acquire_ibuf(ima, &sima->iuser, NULL);
- if (!ibuf)
+ if (!ibuf) {
return;
+ }
UI_view2d_region_to_view(
s->v2d, mouse_final[0], mouse_final[1], &image_final[0], &image_final[1]);
diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c
index 6b4951d1ca4..5436c5912bc 100644
--- a/source/blender/editors/sculpt_paint/paint_image_proj.c
+++ b/source/blender/editors/sculpt_paint/paint_image_proj.c
@@ -627,8 +627,9 @@ static float VecZDepthPersp(
w_tmp[1] = w_tmp[1] * wtot_inv;
w_tmp[2] = w_tmp[2] * wtot_inv;
}
- else /* dummy values for zero area face */
+ else { /* dummy values for zero area face */
w_tmp[0] = w_tmp[1] = w_tmp[2] = 1.0f / 3.0f;
+ }
/* done mimicking barycentric_weights_v2() */
return (v1[2] * w_tmp[0]) + (v2[2] * w_tmp[1]) + (v3[2] * w_tmp[2]);
@@ -644,8 +645,9 @@ static int project_paint_PickFace(const ProjPaintState *ps, const float pt[2], f
float z_depth_best = FLT_MAX, z_depth;
bucket_index = project_bucket_offset_safe(ps, pt);
- if (bucket_index == -1)
+ if (bucket_index == -1) {
return -1;
+ }
/* we could return 0 for 1 face buckets, as long as this function assumes
* that the point its testing is only every originated from an existing face */
@@ -686,10 +688,12 @@ static void uvco_to_wrapped_pxco(const float uv[2], int ibuf_x, int ibuf_y, floa
*x = fmodf(uv[0], 1.0f);
*y = fmodf(uv[1], 1.0f);
- if (*x < 0.0f)
+ if (*x < 0.0f) {
*x += 1.0f;
- if (*y < 0.0f)
+ }
+ if (*y < 0.0f) {
*y += 1.0f;
+ }
*x = *x * ibuf_x - 0.5f;
*y = *y * ibuf_y - 0.5f;
@@ -713,8 +717,9 @@ static bool project_paint_PickColor(const ProjPaintState *ps,
tri_index = project_paint_PickFace(ps, pt, w);
- if (tri_index == -1)
+ if (tri_index == -1) {
return 0;
+ }
lt = &ps->mlooptri_eval[tri_index];
PS_LOOPTRI_ASSIGN_UV_3(lt_tri_uv, ps->poly_to_loop_uv, lt);
@@ -724,8 +729,9 @@ static bool project_paint_PickColor(const ProjPaintState *ps,
ima = project_paint_face_paint_image(ps, tri_index);
/** we must have got the imbuf before getting here. */
ibuf = BKE_image_get_first_ibuf(ima);
- if (!ibuf)
+ if (!ibuf) {
return 0;
+ }
if (interp) {
float x, y;
@@ -802,12 +808,14 @@ static int project_paint_occlude_ptv(const float pt[3],
const bool is_ortho)
{
/* if all are behind us, return false */
- if (v1[2] > pt[2] && v2[2] > pt[2] && v3[2] > pt[2])
+ if (v1[2] > pt[2] && v2[2] > pt[2] && v3[2] > pt[2]) {
return 0;
+ }
/* do a 2D point in try intersection */
- if (!isect_point_tri_v2(pt, v1, v2, v3))
+ if (!isect_point_tri_v2(pt, v1, v2, v3)) {
return 0;
+ }
/* From here on we know there IS an intersection */
/* if ALL of the verts are infront of us then we know it intersects ? */
@@ -818,12 +826,14 @@ static int project_paint_occlude_ptv(const float pt[3],
/* we intersect? - find the exact depth at the point of intersection */
/* Is this point is occluded by another face? */
if (is_ortho) {
- if (VecZDepthOrtho(pt, v1, v2, v3, w) < pt[2])
+ if (VecZDepthOrtho(pt, v1, v2, v3, w) < pt[2]) {
return 2;
+ }
}
else {
- if (VecZDepthPersp(pt, v1, v2, v3, w) < pt[2])
+ if (VecZDepthPersp(pt, v1, v2, v3, w) < pt[2]) {
return 2;
+ }
}
}
return -1;
@@ -843,8 +853,9 @@ static int project_paint_occlude_ptv_clip(const float pt[3],
float wco[3];
int ret = project_paint_occlude_ptv(pt, v1, v2, v3, w, is_ortho);
- if (ret <= 0)
+ if (ret <= 0) {
return ret;
+ }
if (ret == 1) { /* weights not calculated */
if (is_ortho) {
@@ -1009,15 +1020,19 @@ static bool cmp_uv(const float vec2a[2], const float vec2b[2])
float xb = fmodf(vec2b[0], 1.0f);
float yb = fmodf(vec2b[1], 1.0f);
- if (xa < 0.0f)
+ if (xa < 0.0f) {
xa += 1.0f;
- if (ya < 0.0f)
+ }
+ if (ya < 0.0f) {
ya += 1.0f;
+ }
- if (xb < 0.0f)
+ if (xb < 0.0f) {
xb += 1.0f;
- if (yb < 0.0f)
+ }
+ if (yb < 0.0f) {
yb += 1.0f;
+ }
return ((fabsf(xa - xb) < PROJ_GEOM_TOLERANCE) && (fabsf(ya - yb) < PROJ_GEOM_TOLERANCE)) ? 1 :
0;
@@ -1093,8 +1108,9 @@ static void project_face_winding_init(const ProjPaintState *ps, const int tri_in
const float *lt_tri_uv[3] = {PS_LOOPTRI_AS_UV_3(ps->poly_to_loop_uv, lt)};
float winding = cross_tri_v2(lt_tri_uv[0], lt_tri_uv[1], lt_tri_uv[2]);
- if (winding > 0)
+ if (winding > 0) {
ps->faceWindingFlags[tri_index] |= PROJ_FACE_WINDING_CW;
+ }
ps->faceWindingFlags[tri_index] |= PROJ_FACE_WINDING_INIT;
}
@@ -1149,8 +1165,9 @@ static bool check_seam(const ProjPaintState *ps,
*orig_fidx = (i1_fidx < i2_fidx && (i2_fidx - i1_fidx == 1)) ? i1_fidx : i2_fidx;
/* initialize face winding if needed */
- if ((ps->faceWindingFlags[tri_index] & PROJ_FACE_WINDING_INIT) == 0)
+ if ((ps->faceWindingFlags[tri_index] & PROJ_FACE_WINDING_INIT) == 0) {
project_face_winding_init(ps, tri_index);
+ }
/* first test if they have the same image */
if ((orig_tpage == tpage) && cmp_uv(orig_lt_tri_uv[orig_i1_fidx], lt_tri_uv[i1_fidx]) &&
@@ -1415,8 +1432,9 @@ static void project_face_seams_init(const ProjPaintState *ps,
LinkNode *node;
/* initialize face winding if needed */
- if ((ps->faceWindingFlags[tri_index] & PROJ_FACE_WINDING_INIT) == 0)
+ if ((ps->faceWindingFlags[tri_index] & PROJ_FACE_WINDING_INIT) == 0) {
project_face_winding_init(ps, tri_index);
+ }
do {
if (init_all || (ps->mloop_eval[lt->tri[fidx[0]]].v == vert_index) ||
@@ -1779,14 +1797,16 @@ static int project_paint_undo_subtiles(const TileInfo *tinf, int tx, int ty)
/* double check lock to avoid locking */
if (UNLIKELY(!pjIma->undoRect[tile_index])) {
- if (tinf->lock)
+ if (tinf->lock) {
BLI_spin_lock(tinf->lock);
+ }
if (LIKELY(!pjIma->undoRect[tile_index])) {
pjIma->undoRect[tile_index] = TILE_PENDING;
generate_tile = true;
}
- if (tinf->lock)
+ if (tinf->lock) {
BLI_spin_unlock(tinf->lock);
+ }
}
if (generate_tile) {
@@ -1819,11 +1839,13 @@ static int project_paint_undo_subtiles(const TileInfo *tinf, int tx, int ty)
pjIma->ibuf->userflags |= IB_BITMAPDIRTY;
/* tile ready, publish */
- if (tinf->lock)
+ if (tinf->lock) {
BLI_spin_lock(tinf->lock);
+ }
pjIma->undoRect[tile_index] = undorect;
- if (tinf->lock)
+ if (tinf->lock) {
BLI_spin_unlock(tinf->lock);
+ }
}
return tile_index;
@@ -1872,8 +1894,9 @@ static ProjPixel *project_paint_uvpixel_init(const ProjPaintState *ps,
tile_index = project_paint_undo_subtiles(tinf, x_tile, y_tile);
/* other thread may be initializing the tile so wait here */
- while (projima->undoRect[tile_index] == TILE_PENDING)
+ while (projima->undoRect[tile_index] == TILE_PENDING) {
;
+ }
BLI_assert(tile_index < (IMAPAINT_TILE_NUMBER(ibuf->x) * IMAPAINT_TILE_NUMBER(ibuf->y)));
BLI_assert(tile_offset < (IMAPAINT_TILE_SIZE * IMAPAINT_TILE_SIZE));
@@ -1902,10 +1925,12 @@ static ProjPixel *project_paint_uvpixel_init(const ProjPaintState *ps,
projPixel->y_px = y_px;
projPixel->mask = (unsigned short)(mask * 65535);
- if (ps->do_masking)
+ if (ps->do_masking) {
projPixel->mask_accum = projima->maskRect[tile_index] + tile_offset;
- else
+ }
+ else {
projPixel->mask_accum = NULL;
+ }
/* which bounding box cell are we in?, needed for undo */
projPixel->bb_cell_index = ((int)(((float)x_px / (float)ibuf->x) * PROJ_BOUNDBOX_DIV)) +
@@ -1995,10 +2020,12 @@ static ProjPixel *project_paint_uvpixel_init(const ProjPaintState *ps,
}
#ifdef PROJ_DEBUG_PAINT
- if (ibuf->rect_float)
+ if (ibuf->rect_float) {
projPixel->pixel.f_pt[0] = 0;
- else
+ }
+ else {
projPixel->pixel.ch_pt[0] = 0;
+ }
#endif
/* pointer arithmetic */
projPixel->image_index = projima - ps->projImages;
@@ -2091,8 +2118,9 @@ static bool line_clip_rect2f(const rctf *cliprect,
}
/* line inside rect */
- if (ok1 && ok2)
+ if (ok1 && ok2) {
return 1;
+ }
/* top/bottom */
if (line_isect_y(l1, l2, rect->ymin, &isect) && (isect >= cliprect->xmin) &&
@@ -2109,8 +2137,9 @@ static bool line_clip_rect2f(const rctf *cliprect,
}
}
- if (ok1 && ok2)
+ if (ok1 && ok2) {
return 1;
+ }
if (line_isect_y(l1, l2, rect->ymax, &isect) && (isect >= cliprect->xmin) &&
(isect <= cliprect->xmax)) {
@@ -2126,8 +2155,9 @@ static bool line_clip_rect2f(const rctf *cliprect,
}
}
- if (ok1 && ok2)
+ if (ok1 && ok2) {
return 1;
+ }
/* left/right */
if (line_isect_x(l1, l2, rect->xmin, &isect) && (isect >= cliprect->ymin) &&
@@ -2144,8 +2174,9 @@ static bool line_clip_rect2f(const rctf *cliprect,
}
}
- if (ok1 && ok2)
+ if (ok1 && ok2) {
return 1;
+ }
if (line_isect_x(l1, l2, rect->xmax, &isect) && (isect >= cliprect->ymin) &&
(isect <= cliprect->ymax)) {
@@ -2430,8 +2461,9 @@ static bool line_rect_clip(const rctf *rect,
}
}
- if (min == FLT_MAX)
+ if (min == FLT_MAX) {
return false;
+ }
tmp = (is_ortho) ? 1.0f : (l1[3] + min * (l2[3] - l1[3]));
@@ -2504,8 +2536,9 @@ static void project_bucket_clip_face(const bool is_ortho,
(*tot) = 0;
- if (cull)
+ if (cull) {
return;
+ }
if (inside_bucket_flag & ISECT_1) {
copy_v2_v2(bucket_bounds_uv[*tot], uv1co);
@@ -2515,8 +2548,9 @@ static void project_bucket_clip_face(const bool is_ortho,
flag = inside_bucket_flag & (ISECT_1 | ISECT_2);
if (flag && flag != (ISECT_1 | ISECT_2)) {
if (line_rect_clip(
- bucket_bounds, v1coSS, v2coSS, uv1co, uv2co, bucket_bounds_uv[*tot], is_ortho))
+ bucket_bounds, v1coSS, v2coSS, uv1co, uv2co, bucket_bounds_uv[*tot], is_ortho)) {
(*tot)++;
+ }
}
if (inside_bucket_flag & ISECT_2) {
@@ -2527,8 +2561,9 @@ static void project_bucket_clip_face(const bool is_ortho,
flag = inside_bucket_flag & (ISECT_2 | ISECT_3);
if (flag && flag != (ISECT_2 | ISECT_3)) {
if (line_rect_clip(
- bucket_bounds, v2coSS, v3coSS, uv2co, uv3co, bucket_bounds_uv[*tot], is_ortho))
+ bucket_bounds, v2coSS, v3coSS, uv2co, uv3co, bucket_bounds_uv[*tot], is_ortho)) {
(*tot)++;
+ }
}
if (inside_bucket_flag & ISECT_3) {
@@ -2539,8 +2574,9 @@ static void project_bucket_clip_face(const bool is_ortho,
flag = inside_bucket_flag & (ISECT_3 | ISECT_1);
if (flag && flag != (ISECT_3 | ISECT_1)) {
if (line_rect_clip(
- bucket_bounds, v3coSS, v1coSS, uv3co, uv1co, bucket_bounds_uv[*tot], is_ortho))
+ bucket_bounds, v3coSS, v1coSS, uv3co, uv1co, bucket_bounds_uv[*tot], is_ortho)) {
(*tot)++;
+ }
}
if ((*tot) < 3) {
@@ -2743,10 +2779,12 @@ static void project_bucket_clip_face(const bool is_ortho,
v1_clipSS[0] * v2_clipSS[0] + v1_clipSS[1] * v2_clipSS[1]);
}
- if (flip)
+ if (flip) {
qsort(isectVCosSS, *tot, sizeof(float) * 3, float_z_sort_flip);
- else
+ }
+ else {
qsort(isectVCosSS, *tot, sizeof(float) * 3, float_z_sort);
+ }
doubles = true;
while (doubles == true) {
@@ -2795,12 +2833,14 @@ static void project_bucket_clip_face(const bool is_ortho,
/* If there are ever any problems, */
float test_uv[4][2];
int i;
- if (is_ortho)
+ if (is_ortho) {
rect_to_uvspace_ortho(
bucket_bounds, v1coSS, v2coSS, v3coSS, uv1co, uv2co, uv3co, test_uv, flip);
- else
+ }
+ else {
rect_to_uvspace_persp(
bucket_bounds, v1coSS, v2coSS, v3coSS, uv1co, uv2co, uv3co, test_uv, flip);
+ }
printf("( [(%f,%f), (%f,%f), (%f,%f), (%f,%f)], ",
test_uv[0][0],
test_uv[0][1],
@@ -2886,12 +2926,14 @@ static void project_bucket_clip_face(const bool is_ortho,
static bool IsectPoly2Df(const float pt[2], float uv[][2], const int tot)
{
int i;
- if (line_point_side_v2(uv[tot - 1], uv[0], pt) < 0.0f)
+ if (line_point_side_v2(uv[tot - 1], uv[0], pt) < 0.0f) {
return 0;
+ }
for (i = 1; i < tot; i++) {
- if (line_point_side_v2(uv[i - 1], uv[i], pt) < 0.0f)
+ if (line_point_side_v2(uv[i - 1], uv[i], pt) < 0.0f) {
return 0;
+ }
}
return 1;
@@ -2902,8 +2944,9 @@ static bool IsectPoly2Df_twoside(const float pt[2], float uv[][2], const int tot
bool side = (line_point_side_v2(uv[tot - 1], uv[0], pt) > 0.0f);
for (i = 1; i < tot; i++) {
- if ((line_point_side_v2(uv[i - 1], uv[i], pt) > 0.0f) != side)
+ if ((line_point_side_v2(uv[i - 1], uv[i], pt) > 0.0f) != side) {
return 0;
+ }
}
return 1;
@@ -3067,12 +3110,14 @@ static void project_paint_face_init(const ProjPaintState *ps,
has_x_isect = has_isect = 1;
- if (is_ortho)
+ if (is_ortho) {
screen_px_from_ortho(
uv, v1coSS, v2coSS, v3coSS, uv1co, uv2co, uv3co, pixelScreenCo, w);
- else
+ }
+ else {
screen_px_from_persp(
uv, v1coSS, v2coSS, v3coSS, uv1co, uv2co, uv3co, pixelScreenCo, w);
+ }
/* a pity we need to get the worldspace pixel location here */
if (do_clip || do_3d_mapping) {
@@ -3488,8 +3533,9 @@ static void project_bucket_init(const ProjPaintState *ps,
}
}
- if (tmpibuf)
+ if (tmpibuf) {
IMB_freeImBuf(tmpibuf);
+ }
ps->bucketFlags[bucket_index] |= PROJ_BUCKET_INIT;
}
@@ -3834,8 +3880,9 @@ static void proj_paint_state_cavity_init(ProjPaintState *ps)
/* augment the diffe*/
cavities[a] = saacos(10.0f * dot_v3v3(no, edges[a])) * (float)M_1_PI;
}
- else
+ else {
cavities[a] = 0.0;
+ }
}
MEM_freeN(counter);
@@ -3871,8 +3918,9 @@ static void proj_paint_state_thread_init(ProjPaintState *ps, const bool reset_th
/* workaround for #35057, disable threading if diameter is less than is possible for
* optimum bucket number generation */
- if (reset_threads)
+ if (reset_threads) {
ps->thread_tot = 1;
+ }
if (ps->is_shared_user == false) {
if (ps->thread_tot > 1) {
@@ -4048,8 +4096,9 @@ static void proj_paint_layer_clone_init(ProjPaintState *ps, ProjPaintLayerClone
ps->poly_to_loop_uv_clone = MEM_mallocN(ps->totpoly_eval * sizeof(MLoopUV *),
"proj_paint_mtfaces");
- if (layer_num != -1)
+ if (layer_num != -1) {
mloopuv_clone_base = CustomData_get_layer_n(&ps->me_eval->ldata, CD_MLOOPUV, layer_num);
+ }
if (mloopuv_clone_base == NULL) {
/* get active instead */
@@ -4071,11 +4120,13 @@ static bool project_paint_clone_face_skip(ProjPaintState *ps,
if (ps->do_material_slots) {
lc->slot_clone = project_paint_face_clone_slot(ps, tri_index);
/* all faces should have a valid slot, reassert here */
- if (ELEM(lc->slot_clone, NULL, slot))
+ if (ELEM(lc->slot_clone, NULL, slot)) {
return true;
+ }
}
- else if (ps->clone_ima == ps->canvas_ima)
+ else if (ps->clone_ima == ps->canvas_ima) {
return true;
+ }
if (ps->do_material_slots) {
if (lc->slot_clone != lc->slot_last_clone) {
@@ -4242,8 +4293,9 @@ static void project_paint_prepare_all_faces(ProjPaintState *ps,
else {
if (slot != slot_last) {
if (!slot->uvname || !(mloopuv_base = CustomData_get_layer_named(
- &ps->me_eval->ldata, CD_MLOOPUV, slot->uvname)))
+ &ps->me_eval->ldata, CD_MLOOPUV, slot->uvname))) {
mloopuv_base = CustomData_get_layer(&ps->me_eval->ldata, CD_MLOOPUV);
+ }
slot_last = slot;
}
@@ -4398,17 +4450,19 @@ static void project_paint_begin(const bContext *C,
if (ps->do_layer_stencil || ps->do_stencil_brush) {
//int layer_num = CustomData_get_stencil_layer(&ps->me_eval->ldata, CD_MLOOPUV);
int layer_num = CustomData_get_stencil_layer(&((Mesh *)ps->ob->data)->ldata, CD_MLOOPUV);
- if (layer_num != -1)
+ if (layer_num != -1) {
ps->mloopuv_stencil_eval = CustomData_get_layer_n(
&ps->me_eval->ldata, CD_MLOOPUV, layer_num);
+ }
if (ps->mloopuv_stencil_eval == NULL) {
/* get active instead */
ps->mloopuv_stencil_eval = CustomData_get_layer(&ps->me_eval->ldata, CD_MLOOPUV);
}
- if (ps->do_stencil_brush)
+ if (ps->do_stencil_brush) {
mloopuv_base = ps->mloopuv_stencil_eval;
+ }
}
/* when using subsurf or multires, mface arrays are thrown away, we need to keep a copy */
@@ -4513,11 +4567,13 @@ static void project_paint_end(ProjPaintState *ps)
/* must be set for non-shared */
BLI_assert(ps->poly_to_loop_uv || ps->is_shared_user);
- if (ps->poly_to_loop_uv)
+ if (ps->poly_to_loop_uv) {
MEM_freeN((void *)ps->poly_to_loop_uv);
+ }
- if (ps->do_layer_clone)
+ if (ps->do_layer_clone) {
MEM_freeN((void *)ps->poly_to_loop_uv_clone);
+ }
if (ps->thread_tot > 1) {
BLI_spin_end(ps->tile_lock);
MEM_freeN((void *)ps->tile_lock);
@@ -4550,8 +4606,9 @@ static void project_paint_end(ProjPaintState *ps)
MEM_freeN(ps->blurkernel);
}
- if (ps->vertFlags)
+ if (ps->vertFlags) {
MEM_freeN(ps->vertFlags);
+ }
for (a = 0; a < ps->thread_tot; a++) {
BLI_memarena_free(ps->arena_mt[a]);
@@ -4591,8 +4648,9 @@ static bool partial_redraw_array_merge(ImagePaintPartialRedraw *pr,
pr->x2 = max_ii(pr->x2, pr_other->x2);
pr->y2 = max_ii(pr->y2, pr_other->y2);
- if (pr->x2 != -1)
+ if (pr->x2 != -1) {
touch = 1;
+ }
pr++;
pr_other++;
@@ -4678,8 +4736,9 @@ static bool project_bucket_iter_next(ProjPaintState *ps,
{
const int diameter = 2 * ps->brush_size;
- if (ps->thread_tot > 1)
+ if (ps->thread_tot > 1) {
BLI_thread_lock(LOCK_CUSTOM1);
+ }
//printf("%d %d\n", ps->context_bucket_x, ps->context_bucket_y);
@@ -4694,8 +4753,9 @@ static bool project_bucket_iter_next(ProjPaintState *ps,
*bucket_index = ps->context_bucket_x + (ps->context_bucket_y * ps->buckets_x);
ps->context_bucket_x++;
- if (ps->thread_tot > 1)
+ if (ps->thread_tot > 1) {
BLI_thread_unlock(LOCK_CUSTOM1);
+ }
return 1;
}
@@ -4703,8 +4763,9 @@ static bool project_bucket_iter_next(ProjPaintState *ps,
ps->context_bucket_x = ps->bucketMin[0];
}
- if (ps->thread_tot > 1)
+ if (ps->thread_tot > 1) {
BLI_thread_unlock(LOCK_CUSTOM1);
+ }
return 0;
}
@@ -4782,8 +4843,9 @@ static void do_projectpaint_smear(ProjPaintState *ps,
{
unsigned char rgba_ub[4];
- if (project_paint_PickColor(ps, co, NULL, rgba_ub, 1) == 0)
+ if (project_paint_PickColor(ps, co, NULL, rgba_ub, 1) == 0) {
return;
+ }
blend_color_interpolate_byte(
((ProjPixelClone *)projPixel)->clonepx.ch, projPixel->pixel.ch_pt, rgba_ub, mask);
@@ -4799,8 +4861,9 @@ static void do_projectpaint_smear_f(ProjPaintState *ps,
{
float rgba[4];
- if (project_paint_PickColor(ps, co, rgba, NULL, 1) == 0)
+ if (project_paint_PickColor(ps, co, rgba, NULL, 1) == 0) {
return;
+ }
blend_color_interpolate_float(
((ProjPixelClone *)projPixel)->clonepx.f, projPixel->pixel.f_pt, rgba, mask);
@@ -4855,8 +4918,9 @@ static void do_projectpaint_soften_f(ProjPaintState *ps,
blend_color_add_float(rgba, projPixel->pixel.f_pt, rgba);
rgba[3] = alpha;
}
- else
+ else {
return;
+ }
}
else {
blend_color_interpolate_float(rgba, projPixel->pixel.f_pt, rgba, mask);
@@ -4922,8 +4986,9 @@ static void do_projectpaint_soften(ProjPaintState *ps,
rgba[3] = alpha;
premul_float_to_straight_uchar(rgba_ub, rgba);
}
- else
+ else {
return;
+ }
}
else {
premul_float_to_straight_uchar(rgba_ub, rgba);
@@ -4983,8 +5048,9 @@ static void do_projectpaint_draw_f(ProjPaintState *ps,
copy_v3_v3(rgba, ps->paint_color_linear);
- if (ps->is_texbrush)
+ if (ps->is_texbrush) {
mul_v3_v3(rgba, texrgb);
+ }
mul_v3_fl(rgba, mask);
rgba[3] = mask;
@@ -5330,10 +5396,12 @@ static void *do_projectpaint_thread(void *ph_v)
float mask_accum = *projPixel->mask_accum;
float max_mask = brush_alpha * custom_mask * falloff * 65535.0f;
- if (brush->flag & BRUSH_ACCUMULATE)
+ if (brush->flag & BRUSH_ACCUMULATE) {
mask = mask_accum + max_mask;
- else
+ }
+ else {
mask = mask_accum + (max_mask - mask_accum * falloff);
+ }
mask = min_ff(mask, 65535.0f);
mask_short = (unsigned short)mask;
@@ -5372,37 +5440,47 @@ static void *do_projectpaint_thread(void *ph_v)
/* texrgb is not used for clone, smear or soften */
switch (tool) {
case PAINT_TOOL_CLONE:
- if (is_floatbuf)
+ if (is_floatbuf) {
do_projectpaint_clone_f(ps, projPixel, mask);
- else
+ }
+ else {
do_projectpaint_clone(ps, projPixel, mask);
+ }
break;
case PAINT_TOOL_SMEAR:
sub_v2_v2v2(co, projPixel->projCoSS, pos_ofs);
- if (is_floatbuf)
+ if (is_floatbuf) {
do_projectpaint_smear_f(ps, projPixel, mask, smearArena, &smearPixels_f, co);
- else
+ }
+ else {
do_projectpaint_smear(ps, projPixel, mask, smearArena, &smearPixels, co);
+ }
break;
case PAINT_TOOL_SOFTEN:
- if (is_floatbuf)
+ if (is_floatbuf) {
do_projectpaint_soften_f(ps, projPixel, mask, softenArena, &softenPixels_f);
- else
+ }
+ else {
do_projectpaint_soften(ps, projPixel, mask, softenArena, &softenPixels);
+ }
break;
case PAINT_TOOL_MASK:
- if (is_floatbuf)
+ if (is_floatbuf) {
do_projectpaint_mask_f(ps, projPixel, mask);
- else
+ }
+ else {
do_projectpaint_mask(ps, projPixel, mask);
+ }
break;
default:
- if (is_floatbuf)
+ if (is_floatbuf) {
do_projectpaint_draw_f(ps, projPixel, texrgb, mask);
- else
+ }
+ else {
do_projectpaint_draw(
ps, projPixel, texrgb, mask, ps->dither, projPixel->x_px, projPixel->y_px);
+ }
break;
}
@@ -5476,8 +5554,9 @@ static bool project_paint_op(void *state, const float lastpos[2], const float po
return touch_any;
}
- if (ps->thread_tot > 1)
+ if (ps->thread_tot > 1) {
BLI_threadpool_init(&threads, do_projectpaint_thread, ps->thread_tot);
+ }
pool = BKE_image_pool_new();
@@ -5510,14 +5589,17 @@ static bool project_paint_op(void *state, const float lastpos[2], const float po
handles[a].pool = pool;
- if (ps->thread_tot > 1)
+ if (ps->thread_tot > 1) {
BLI_threadpool_insert(&threads, &handles[a]);
+ }
}
- if (ps->thread_tot > 1) /* wait for everything to be done */
+ if (ps->thread_tot > 1) { /* wait for everything to be done */
BLI_threadpool_end(&threads);
- else
+ }
+ else {
do_projectpaint_thread(&handles[0]);
+ }
BKE_image_pool_free(pool);
@@ -5582,8 +5664,9 @@ static void paint_proj_stroke_ps(const bContext *UNUSED(C),
ps->brush_size = size;
ps->blend = brush->blend;
- if (eraser)
+ if (eraser) {
ps->blend = IMB_BLEND_ERASE_ALPHA;
+ }
/* handle gradient and inverted stroke color here */
if (ELEM(ps->tool, PAINT_TOOL_DRAW, PAINT_TOOL_FILL)) {
@@ -5723,8 +5806,9 @@ static void project_state_init(bContext *C, Object *ob, ProjPaintState *ps, int
ps->do_backfacecull = ps->do_occlude = ps->do_mask_normal = 0;
}
- if (ps->tool == PAINT_TOOL_CLONE)
+ if (ps->tool == PAINT_TOOL_CLONE) {
ps->do_layer_clone = (settings->imapaint.flag & IMAGEPAINT_PROJECT_LAYER_CLONE) ? 1 : 0;
+ }
ps->do_stencil_brush = (ps->brush && ps->brush->imagepaint_tool == PAINT_TOOL_MASK);
/* deactivate stenciling for the stencil brush :) */
@@ -5827,8 +5911,9 @@ void *paint_proj_new_stroke(bContext *C, Object *ob, const float mouse[2], int m
}
/* Don't allow brush size below 2 */
- if (BKE_brush_size_get(scene, ps_handle->brush) < 2)
+ if (BKE_brush_size_get(scene, ps_handle->brush) < 2) {
BKE_brush_size_set(scene, ps_handle->brush, 2 * U.pixelsize);
+ }
/* allocate and initialize spatial data structures */
@@ -6087,10 +6172,12 @@ static int texture_paint_image_from_view_exec(bContext *C, wmOperator *op)
maxsize = GPU_max_texture_size();
- if (w > maxsize)
+ if (w > maxsize) {
w = maxsize;
- if (h > maxsize)
+ }
+ if (h > maxsize) {
h = maxsize;
+ }
ibuf = ED_view3d_draw_offscreen_imbuf(depsgraph,
scene,
@@ -6255,14 +6342,18 @@ bool BKE_paint_proj_mesh_data_check(
}
}
- if (!hasuvs)
+ if (!hasuvs) {
imapaint->missing_data |= IMAGEPAINT_MISSING_UVS;
- if (!hasmat)
+ }
+ if (!hasmat) {
imapaint->missing_data |= IMAGEPAINT_MISSING_MATERIAL;
- if (!hastex)
+ }
+ if (!hastex) {
imapaint->missing_data |= IMAGEPAINT_MISSING_TEX;
- if (!hasstencil)
+ }
+ if (!hasstencil) {
imapaint->missing_data |= IMAGEPAINT_MISSING_STENCIL;
+ }
if (uvs) {
*uvs = hasuvs;
@@ -6386,8 +6477,9 @@ static bool proj_paint_add_slot(bContext *C, wmOperator *op)
Material *ma;
Image *ima = NULL;
- if (!ob)
+ if (!ob) {
return false;
+ }
ma = give_current_material(ob, ob->actcol);
diff --git a/source/blender/editors/sculpt_paint/paint_mask.c b/source/blender/editors/sculpt_paint/paint_mask.c
index 4a4dbe364a0..79d09967b75 100644
--- a/source/blender/editors/sculpt_paint/paint_mask.c
+++ b/source/blender/editors/sculpt_paint/paint_mask.c
@@ -121,8 +121,9 @@ static void mask_flood_fill_task_cb(void *__restrict userdata,
BKE_pbvh_vertex_iter_end;
BKE_pbvh_node_mark_redraw(node);
- if (data->multires)
+ if (data->multires) {
BKE_pbvh_node_mark_normals_update(node);
+ }
}
static int mask_flood_fill_exec(bContext *C, wmOperator *op)
@@ -166,13 +167,15 @@ static int mask_flood_fill_exec(bContext *C, wmOperator *op)
0, totnode, &data, mask_flood_fill_task_cb, &settings);
- if (multires)
+ if (multires) {
multires_mark_as_modified(ob, MULTIRES_COORDS_MODIFIED);
+ }
sculpt_undo_push_end();
- if (nodes)
+ if (nodes) {
MEM_freeN(nodes);
+ }
ED_region_tag_redraw(ar);
@@ -217,18 +220,24 @@ static bool is_effected(float planes[4][4], const float co[3])
static void flip_plane(float out[4], const float in[4], const char symm)
{
- if (symm & PAINT_SYMM_X)
+ if (symm & PAINT_SYMM_X) {
out[0] = -in[0];
- else
+ }
+ else {
out[0] = in[0];
- if (symm & PAINT_SYMM_Y)
+ }
+ if (symm & PAINT_SYMM_Y) {
out[1] = -in[1];
- else
+ }
+ else {
out[1] = in[1];
- if (symm & PAINT_SYMM_Z)
+ }
+ if (symm & PAINT_SYMM_Z) {
out[2] = -in[2];
- else
+ }
+ else {
out[2] = in[2];
+ }
out[3] = in[3];
}
@@ -257,8 +266,9 @@ static void mask_box_select_task_cb(void *__restrict userdata,
sculpt_undo_push_node(data->ob, node, SCULPT_UNDO_MASK);
BKE_pbvh_node_mark_redraw(node);
- if (data->multires)
+ if (data->multires) {
BKE_pbvh_node_mark_normals_update(node);
+ }
}
mask_flood_fill_set_elem(vi.mask, mode, value);
}
@@ -326,13 +336,15 @@ bool ED_sculpt_mask_box_select(struct bContext *C, ViewContext *vc, const rcti *
totnode > SCULPT_THREADED_LIMIT);
BLI_task_parallel_range(0, totnode, &data, mask_box_select_task_cb, &settings);
- if (nodes)
+ if (nodes) {
MEM_freeN(nodes);
+ }
}
}
- if (multires)
+ if (multires) {
multires_mark_as_modified(ob, MULTIRES_COORDS_MODIFIED);
+ }
sculpt_undo_push_end();
@@ -417,8 +429,9 @@ static void mask_gesture_lasso_task_cb(void *__restrict userdata,
sculpt_undo_push_node(data->ob, node, SCULPT_UNDO_MASK);
BKE_pbvh_node_mark_redraw(node);
- if (data->multires)
+ if (data->multires) {
BKE_pbvh_node_mark_normals_update(node);
+ }
}
mask_flood_fill_set_elem(vi.mask, mode, value);
@@ -511,13 +524,15 @@ static int paint_mask_gesture_lasso_exec(bContext *C, wmOperator *op)
(totnode > SCULPT_THREADED_LIMIT));
BLI_task_parallel_range(0, totnode, &data, mask_gesture_lasso_task_cb, &settings);
- if (nodes)
+ if (nodes) {
MEM_freeN(nodes);
+ }
}
}
- if (multires)
+ if (multires) {
multires_mark_as_modified(ob, MULTIRES_COORDS_MODIFIED);
+ }
sculpt_undo_push_end();
diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c
index 6686e255b08..e15912efdd4 100644
--- a/source/blender/editors/sculpt_paint/paint_ops.c
+++ b/source/blender/editors/sculpt_paint/paint_ops.c
@@ -168,8 +168,9 @@ static int brush_scale_size_exec(bContext *C, wmOperator *op)
{
float unprojected_radius = scalar * BKE_brush_unprojected_radius_get(scene, brush);
- if (unprojected_radius < 0.001f) // XXX magic number
+ if (unprojected_radius < 0.001f) { // XXX magic number
unprojected_radius = 0.001f;
+ }
BKE_brush_unprojected_radius_set(scene, brush, unprojected_radius);
}
@@ -229,8 +230,9 @@ static bool palette_poll(bContext *C)
{
Paint *paint = BKE_paint_get_active_from_context(C);
- if (paint && paint->palette != NULL)
+ if (paint && paint->palette != NULL) {
return true;
+ }
return false;
}
@@ -306,8 +308,9 @@ static int brush_reset_exec(bContext *C, wmOperator *UNUSED(op))
Brush *brush = BKE_paint_brush(paint);
Object *ob = CTX_data_active_object(C);
- if (!ob || !brush)
+ if (!ob || !brush) {
return OPERATOR_CANCELLED;
+ }
/* TODO: other modes */
if (ob->mode & OB_MODE_SCULPT) {
@@ -396,8 +399,9 @@ static Brush *brush_tool_toggle(Main *bmain, Paint *paint, Brush *brush_orig, co
* for one that is */
br = brush_tool_cycle(bmain, paint, brush_orig, tool);
/* store the previously-selected brush */
- if (br)
+ if (br) {
br->toggle_brush = brush_orig;
+ }
return br;
}
@@ -406,8 +410,9 @@ static Brush *brush_tool_toggle(Main *bmain, Paint *paint, Brush *brush_orig, co
* back to the previously selected brush. */
return brush_orig->toggle_brush;
}
- else
+ else {
return NULL;
+ }
}
static int brush_generic_tool_set(Main *bmain,
@@ -628,12 +633,14 @@ static int stencil_control_invoke(bContext *C, wmOperator *op, const wmEvent *ev
int mask = RNA_enum_get(op->ptr, "texmode");
if (mask) {
- if (br->mask_mtex.brush_map_mode != MTEX_MAP_MODE_STENCIL)
+ if (br->mask_mtex.brush_map_mode != MTEX_MAP_MODE_STENCIL) {
return OPERATOR_CANCELLED;
+ }
}
else {
- if (br->mtex.brush_map_mode != MTEX_MAP_MODE_STENCIL)
+ if (br->mtex.brush_map_mode != MTEX_MAP_MODE_STENCIL) {
return OPERATOR_CANCELLED;
+ }
}
scd = MEM_mallocN(sizeof(StencilControlData), "stencil_control");
@@ -695,10 +702,12 @@ static void stencil_control_calculate(StencilControlData *scd, const int mval[2]
len = len_v2(mdiff);
factor = len / scd->lenorig;
copy_v2_v2(mdiff, scd->init_sdim);
- if (scd->constrain_mode != STENCIL_CONSTRAINT_Y)
+ if (scd->constrain_mode != STENCIL_CONSTRAINT_Y) {
mdiff[0] = factor * scd->init_sdim[0];
- if (scd->constrain_mode != STENCIL_CONSTRAINT_X)
+ }
+ if (scd->constrain_mode != STENCIL_CONSTRAINT_X) {
mdiff[1] = factor * scd->init_sdim[1];
+ }
CLAMP(mdiff[0], 5.0f, 10000.0f);
CLAMP(mdiff[1], 5.0f, 10000.0f);
copy_v2_v2(scd->dim_target, mdiff);
@@ -709,10 +718,12 @@ static void stencil_control_calculate(StencilControlData *scd, const int mval[2]
sub_v2_v2v2(mdiff, mvalf, scd->pos_target);
angle = atan2f(mdiff[1], mdiff[0]);
angle = scd->init_rot + angle - scd->init_angle;
- if (angle < 0.0f)
+ if (angle < 0.0f) {
angle += (float)(2 * M_PI);
- if (angle > (float)(2 * M_PI))
+ }
+ if (angle > (float)(2 * M_PI)) {
angle -= (float)(2 * M_PI);
+ }
*scd->rot_target = angle;
break;
}
@@ -744,20 +755,24 @@ static int stencil_control_modal(bContext *C, wmOperator *op, const wmEvent *eve
case XKEY:
if (event->val == KM_PRESS) {
- if (scd->constrain_mode == STENCIL_CONSTRAINT_X)
+ if (scd->constrain_mode == STENCIL_CONSTRAINT_X) {
scd->constrain_mode = 0;
- else
+ }
+ else {
scd->constrain_mode = STENCIL_CONSTRAINT_X;
+ }
stencil_control_calculate(scd, event->mval);
}
break;
case YKEY:
if (event->val == KM_PRESS) {
- if (scd->constrain_mode == STENCIL_CONSTRAINT_Y)
+ if (scd->constrain_mode == STENCIL_CONSTRAINT_Y) {
scd->constrain_mode = 0;
- else
+ }
+ else {
scd->constrain_mode = STENCIL_CONSTRAINT_Y;
+ }
stencil_control_calculate(scd, event->mval);
}
@@ -778,8 +793,9 @@ static bool stencil_control_poll(bContext *C)
Paint *paint;
Brush *br;
- if (!paint_supports_texture(mode))
+ if (!paint_supports_texture(mode)) {
return false;
+ }
paint = BKE_paint_get_active_from_context(C);
br = BKE_paint_brush(paint);
@@ -905,8 +921,9 @@ static int stencil_reset_transform_exec(bContext *C, wmOperator *op)
Brush *br = BKE_paint_brush(paint);
bool do_mask = RNA_boolean_get(op->ptr, "mask");
- if (!br)
+ if (!br) {
return OPERATOR_CANCELLED;
+ }
if (do_mask) {
br->mask_stencil_pos[0] = 256;
diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c
index 8c1ba213ba0..9a46dab8c20 100644
--- a/source/blender/editors/sculpt_paint/paint_stroke.c
+++ b/source/blender/editors/sculpt_paint/paint_stroke.c
@@ -309,8 +309,9 @@ static bool paint_brush_update(bContext *C,
do_random = true;
}
- if (brush->mtex.brush_map_mode == MTEX_MAP_MODE_RANDOM)
+ if (brush->mtex.brush_map_mode == MTEX_MAP_MODE_RANDOM) {
BKE_brush_randomize_texture_coords(ups, false);
+ }
else {
copy_v2_v2(ups->tex_mouse, mouse);
}
@@ -325,8 +326,9 @@ static bool paint_brush_update(bContext *C,
do_random_mask = true;
}
- if (brush->mask_mtex.brush_map_mode == MTEX_MAP_MODE_RANDOM)
+ if (brush->mask_mtex.brush_map_mode == MTEX_MAP_MODE_RANDOM) {
BKE_brush_randomize_texture_coords(ups, true);
+ }
else {
copy_v2_v2(ups->mask_tex_mouse, mouse);
}
@@ -427,8 +429,9 @@ static bool paint_brush_update(bContext *C,
location_success = true;
*r_location_is_set = true;
}
- else if (!paint_tool_require_location(brush, mode))
+ else if (!paint_tool_require_location(brush, mode)) {
location_success = true;
+ }
}
else {
zero_v3(r_location);
@@ -506,8 +509,9 @@ static void paint_brush_stroke_add_step(bContext *C,
float delta[2];
float factor = stroke->zoom_2d;
- if (brush->flag & BRUSH_JITTER_PRESSURE)
+ if (brush->flag & BRUSH_JITTER_PRESSURE) {
factor *= pressure;
+ }
BKE_brush_jitter_pos(scene, brush, mouse_in, mouse_out);
@@ -589,8 +593,9 @@ static float paint_space_stroke_spacing(const Scene *scene,
float spacing = stroke->brush->spacing;
/* apply spacing pressure */
- if (stroke->brush->flag & BRUSH_SPACING_PRESSURE)
+ if (stroke->brush->flag & BRUSH_SPACING_PRESSURE) {
spacing = spacing * (1.5f - spacing_pressure);
+ }
/* stroke system is used for 2d paint too, so we need to account for
* the fact that brush can be scaled there. */
@@ -614,8 +619,9 @@ static float paint_stroke_overlapped_curve(Brush *br, float x, float spacing)
xx = fabsf(x0 + i * h);
- if (xx < 1.0f)
+ if (xx < 1.0f) {
sum += BKE_brush_curve_strength(br, xx, 1);
+ }
}
return sum;
@@ -630,8 +636,9 @@ static float paint_stroke_integrate_overlap(Brush *br, float factor)
float spacing = br->spacing * factor;
- if (!(br->flag & BRUSH_SPACE_ATTEN && (br->spacing < 100)))
+ if (!(br->flag & BRUSH_SPACE_ATTEN && (br->spacing < 100))) {
return 1.0;
+ }
m = 10;
g = 1.0f / m;
@@ -639,14 +646,17 @@ static float paint_stroke_integrate_overlap(Brush *br, float factor)
for (i = 0; i < m; i++) {
float overlap = fabs(paint_stroke_overlapped_curve(br, i * g, spacing));
- if (overlap > max)
+ if (overlap > max) {
max = overlap;
+ }
}
- if (max == 0.0f)
+ if (max == 0.0f) {
return 1.0f;
- else
+ }
+ else {
return 1.0f / max;
+ }
}
static float paint_space_stroke_spacing_variable(
@@ -774,8 +784,9 @@ PaintStroke *paint_stroke_new(bContext *C,
/* initialize here to avoid initialization conflict with threaded strokes */
curvemapping_initialize(br->curve);
- if (p->flags & PAINT_USE_CAVITY_MASK)
+ if (p->flags & PAINT_USE_CAVITY_MASK) {
curvemapping_initialize(p->cavity_curve);
+ }
BKE_paint_set_overlay_override(br->overlay_flags);
@@ -797,18 +808,22 @@ static void stroke_done(struct bContext *C, struct wmOperator *op)
ups->stroke_active = false;
/* reset rotation here to avoid doing so in cursor display */
- if (!(stroke->brush->mtex.brush_angle_mode & MTEX_ANGLE_RAKE))
+ if (!(stroke->brush->mtex.brush_angle_mode & MTEX_ANGLE_RAKE)) {
ups->brush_rotation = 0.0f;
+ }
- if (!(stroke->brush->mask_mtex.brush_angle_mode & MTEX_ANGLE_RAKE))
+ if (!(stroke->brush->mask_mtex.brush_angle_mode & MTEX_ANGLE_RAKE)) {
ups->brush_rotation_sec = 0.0f;
+ }
if (stroke->stroke_started) {
- if (stroke->redraw)
+ if (stroke->redraw) {
stroke->redraw(C, stroke, true);
+ }
- if (stroke->done)
+ if (stroke->done) {
stroke->done(C, stroke);
+ }
}
if (stroke->timer) {
@@ -819,8 +834,9 @@ static void stroke_done(struct bContext *C, struct wmOperator *op)
BLI_rng_free(stroke->rng);
}
- if (stroke->stroke_cursor)
+ if (stroke->stroke_cursor) {
WM_paint_cursor_end(CTX_wm_manager(C), stroke->stroke_cursor);
+ }
BLI_freelistN(&stroke->line);
@@ -845,13 +861,15 @@ static bool sculpt_is_grab_tool(Brush *br)
/* return true if the brush size can change during paint (normally used for pressure) */
bool paint_supports_dynamic_size(Brush *br, ePaintMode mode)
{
- if (br->flag & BRUSH_ANCHORED)
+ if (br->flag & BRUSH_ANCHORED) {
return false;
+ }
switch (mode) {
case PAINT_MODE_SCULPT:
- if (sculpt_is_grab_tool(br))
+ if (sculpt_is_grab_tool(br)) {
return false;
+ }
break;
case PAINT_MODE_TEXTURE_2D: /* fall through */
@@ -876,8 +894,9 @@ bool paint_supports_smooth_stroke(Brush *br, ePaintMode mode)
switch (mode) {
case PAINT_MODE_SCULPT:
- if (sculpt_is_grab_tool(br))
+ if (sculpt_is_grab_tool(br)) {
return false;
+ }
break;
default:
break;
@@ -895,13 +914,15 @@ bool paint_supports_texture(ePaintMode mode)
/* return true if the brush size can change during paint (normally used for pressure) */
bool paint_supports_dynamic_tex_coords(Brush *br, ePaintMode mode)
{
- if (br->flag & BRUSH_ANCHORED)
+ if (br->flag & BRUSH_ANCHORED) {
return false;
+ }
switch (mode) {
case PAINT_MODE_SCULPT:
- if (sculpt_is_grab_tool(br))
+ if (sculpt_is_grab_tool(br)) {
return false;
+ }
break;
default:
break;
@@ -942,10 +963,12 @@ static void paint_stroke_add_sample(
sample->pressure = pressure;
stroke->cur_sample++;
- if (stroke->cur_sample >= max_samples)
+ if (stroke->cur_sample >= max_samples) {
stroke->cur_sample = 0;
- if (stroke->num_samples < max_samples)
+ }
+ if (stroke->num_samples < max_samples) {
stroke->num_samples++;
+ }
}
static void paint_stroke_sample_average(const PaintStroke *stroke, PaintSample *average)
@@ -991,8 +1014,9 @@ static void paint_line_strokes_spacing(bContext *C,
BLI_assert(length >= 0.0f);
- if (length == 0.0f)
+ if (length == 0.0f) {
return;
+ }
while (length > 0.0f) {
float spacing_final = spacing - *length_residue;
@@ -1043,8 +1067,9 @@ static bool paint_stroke_curve_end(bContext *C, wmOperator *op, PaintStroke *str
float length_residue = 0.0f;
int i;
- if (!pc)
+ if (!pc) {
return true;
+ }
#ifdef DEBUG_TIME
TIMEIT_START_AVERAGED(whole_stroke);
@@ -1175,22 +1200,25 @@ int paint_stroke_modal(bContext *C, wmOperator *op, const wmEvent *event)
* this isn't perfect... even when an extra MOUSEMOVE is spoofed, the stroke discards it
* since the 2D deltas are zero -- code in this file needs to be updated to use the
* post-NDOF_MOTION MOUSEMOVE */
- if (event->type == NDOF_MOTION)
+ if (event->type == NDOF_MOTION) {
return OPERATOR_PASS_THROUGH;
+ }
#endif
/* one time initialization */
if (!stroke->stroke_init) {
- if (paint_stroke_curve_end(C, op, stroke))
+ if (paint_stroke_curve_end(C, op, stroke)) {
return OPERATOR_FINISHED;
+ }
- if (paint_supports_smooth_stroke(br, mode))
+ if (paint_supports_smooth_stroke(br, mode)) {
stroke->stroke_cursor = WM_paint_cursor_activate(CTX_wm_manager(C),
SPACE_TYPE_ANY,
RGN_TYPE_ANY,
paint_poll,
paint_draw_smooth_cursor,
stroke);
+ }
stroke->stroke_init = true;
first_modal = true;
@@ -1204,9 +1232,10 @@ int paint_stroke_modal(bContext *C, wmOperator *op, const wmEvent *event)
BLI_assert((stroke->stroke_started & ~1) == 0); /* 0/1 */
if (stroke->stroke_started) {
- if (br->flag & BRUSH_AIRBRUSH)
+ if (br->flag & BRUSH_AIRBRUSH) {
stroke->timer = WM_event_add_timer(
CTX_wm_manager(C), CTX_wm_window(C), TIMER, stroke->brush->rate);
+ }
if (br->flag & BRUSH_LINE) {
stroke->stroke_cursor = WM_paint_cursor_activate(CTX_wm_manager(C),
@@ -1247,10 +1276,12 @@ int paint_stroke_modal(bContext *C, wmOperator *op, const wmEvent *event)
return OPERATOR_FINISHED;
}
else if (br->flag & BRUSH_LINE) {
- if (event->alt)
+ if (event->alt) {
stroke->constrain_line = true;
- else
+ }
+ else {
stroke->constrain_line = false;
+ }
copy_v2_fl2(mouse, event->mval[0], event->mval[1]);
paint_stroke_line_constrain(stroke, mouse);
@@ -1274,8 +1305,9 @@ int paint_stroke_modal(bContext *C, wmOperator *op, const wmEvent *event)
if (paint_smooth_stroke(stroke, &sample_average, mode, mouse, &pressure)) {
if (stroke->stroke_started) {
if (paint_space_stroke_enabled(br, mode)) {
- if (paint_space_stroke(C, op, mouse, pressure))
+ if (paint_space_stroke(C, op, mouse, pressure)) {
redraw = true;
+ }
}
else {
float dmouse[2];
@@ -1303,11 +1335,13 @@ int paint_stroke_modal(bContext *C, wmOperator *op, const wmEvent *event)
ARegion *ar = CTX_wm_region(C);
/* At the very least, invalidate the cursor */
- if (ar && (p->flags & PAINT_SHOW_BRUSH))
+ if (ar && (p->flags & PAINT_SHOW_BRUSH)) {
WM_paint_cursor_tag_redraw(window, ar);
+ }
- if (redraw && stroke->redraw)
+ if (redraw && stroke->redraw) {
stroke->redraw(C, stroke, false);
+ }
}
return OPERATOR_RUNNING_MODAL;
diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c
index 098e38dbdb5..91a2ebd0603 100644
--- a/source/blender/editors/sculpt_paint/paint_utils.c
+++ b/source/blender/editors/sculpt_paint/paint_utils.c
@@ -93,8 +93,9 @@ bool paint_convert_bb_to_rect(rcti *rect,
BLI_rcti_init_minmax(rect);
/* return zero if the bounding box has non-positive volume */
- if (bb_min[0] > bb_max[0] || bb_min[1] > bb_max[1] || bb_min[2] > bb_max[2])
+ if (bb_min[0] > bb_max[0] || bb_min[1] > bb_max[1] || bb_min[2] > bb_max[2]) {
return 0;
+ }
ED_view3d_ob_project_mat_get(rv3d, ob, projection_mat);
@@ -195,8 +196,9 @@ void paint_get_tex_pixel_col(const MTex *mtex,
rgba[3] = 1.0f;
}
- if (convert_to_linear)
+ if (convert_to_linear) {
IMB_colormanagement_colorspace_to_scene_linear_v3(rgba, colorspace);
+ }
linearrgb_to_srgb_v3_v3(rgba, rgba);
@@ -382,8 +384,9 @@ static int imapaint_pick_face(ViewContext *vc,
unsigned int *r_index,
unsigned int totpoly)
{
- if (totpoly == 0)
+ if (totpoly == 0) {
return 0;
+ }
/* sample only on the exact position */
*r_index = ED_view3d_select_id_sample(vc, mval[0], mval[1]);
@@ -410,18 +413,24 @@ static Image *imapaint_face_image(Object *ob, Mesh *me, int face_index)
/* Uses symm to selectively flip any axis of a coordinate. */
void flip_v3_v3(float out[3], const float in[3], const char symm)
{
- if (symm & PAINT_SYMM_X)
+ if (symm & PAINT_SYMM_X) {
out[0] = -in[0];
- else
+ }
+ else {
out[0] = in[0];
- if (symm & PAINT_SYMM_Y)
+ }
+ if (symm & PAINT_SYMM_Y) {
out[1] = -in[1];
- else
+ }
+ else {
out[1] = in[1];
- if (symm & PAINT_SYMM_Z)
+ }
+ if (symm & PAINT_SYMM_Z) {
out[2] = -in[2];
- else
+ }
+ else {
out[2] = in[2];
+ }
}
void flip_qt_qt(float out[4], const float in[4], const char symm)
@@ -501,10 +510,12 @@ void paint_sample_color(
if (imapaint_pick_face(&vc, mval, &faceindex, totpoly)) {
Image *image;
- if (use_material)
+ if (use_material) {
image = imapaint_face_image(ob_eval, me_eval, faceindex);
- else
+ }
+ else {
image = imapaint->canvas;
+ }
if (image) {
ImBuf *ibuf = BKE_image_acquire_ibuf(image, NULL, NULL);
@@ -517,10 +528,12 @@ void paint_sample_color(
u = fmodf(uv[0], 1.0f);
v = fmodf(uv[1], 1.0f);
- if (u < 0.0f)
+ if (u < 0.0f) {
u += 1.0f;
- if (v < 0.0f)
+ }
+ if (v < 0.0f) {
v += 1.0f;
+ }
u = u * ibuf->x;
v = v * ibuf->y;
@@ -563,8 +576,9 @@ void paint_sample_color(
x + ar->winrct.xmin, y + ar->winrct.ymin, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &col);
glReadBuffer(GL_BACK);
}
- else
+ else {
return;
+ }
}
else {
glReadBuffer(GL_FRONT);
diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c
index cc32d0a44f3..7852cd61ae1 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex.c
@@ -312,16 +312,20 @@ static uint vpaint_blend(const VPaint *vp,
for (a = 0; a < 4; a++) {
if (ct[a] < co[a]) {
- if (cp[a] < ct[a])
+ if (cp[a] < ct[a]) {
cp[a] = ct[a];
- else if (cp[a] > co[a])
+ }
+ else if (cp[a] > co[a]) {
cp[a] = co[a];
+ }
}
else {
- if (cp[a] < co[a])
+ if (cp[a] < co[a]) {
cp[a] = co[a];
- else if (cp[a] > ct[a])
+ }
+ else if (cp[a] > ct[a]) {
cp[a] = ct[a];
+ }
}
}
}
@@ -400,12 +404,15 @@ static float wpaint_blend(const VPaint *wp,
static float wpaint_clamp_monotonic(float oldval, float curval, float newval)
{
- if (newval < oldval)
+ if (newval < oldval) {
return MIN2(newval, curval);
- else if (newval > oldval)
+ }
+ else if (newval > oldval) {
return MAX2(newval, curval);
- else
+ }
+ else {
return newval;
+ }
}
/* ----------------------------------------------------- */
@@ -1326,12 +1333,15 @@ static int wpaint_mode_toggle_exec(bContext *C, wmOperator *op)
static bool paint_poll_test(bContext *C)
{
Object *ob = CTX_data_active_object(C);
- if (ob == NULL || ob->type != OB_MESH)
+ if (ob == NULL || ob->type != OB_MESH) {
return 0;
- if (!ob->data || ID_IS_LINKED(ob->data))
+ }
+ if (!ob->data || ID_IS_LINKED(ob->data)) {
return 0;
- if (CTX_data_edit_object(C))
+ }
+ if (CTX_data_edit_object(C)) {
return 0;
+ }
return 1;
}
@@ -1399,20 +1409,24 @@ static void vwpaint_update_cache_invariants(
}
/* Initial mouse location */
- if (mouse)
+ if (mouse) {
copy_v2_v2(cache->initial_mouse, mouse);
- else
+ }
+ else {
zero_v2(cache->initial_mouse);
+ }
mode = RNA_enum_get(op->ptr, "mode");
cache->invert = mode == BRUSH_STROKE_INVERT;
cache->alt_smooth = mode == BRUSH_STROKE_SMOOTH;
/* not very nice, but with current events system implementation
* we can't handle brush appearance inversion hotkey separately (sergey) */
- if (cache->invert)
+ if (cache->invert) {
ups->draw_inverted = true;
- else
+ }
+ else {
ups->draw_inverted = false;
+ }
copy_v2_v2(cache->mouse, cache->initial_mouse);
/* Truly temporary data that isn't stored in properties */
@@ -1669,8 +1683,9 @@ static void do_wpaint_precompute_weight_cb_ex(void *__restrict userdata,
static void precompute_weight_values(
bContext *C, Object *ob, Brush *brush, struct WPaintData *wpd, WeightPaintInfo *wpi, Mesh *me)
{
- if (wpd->precomputed_weight_ready && !brush_use_accumulate_ex(brush, ob->mode))
+ if (wpd->precomputed_weight_ready && !brush_use_accumulate_ex(brush, ob->mode)) {
return;
+ }
/* threaded loop over vertices */
SculptThreadedTaskData data = {
@@ -1876,8 +1891,9 @@ static void do_wpaint_brush_smear_task_cb_ex(void *__restrict userdata,
const float final_alpha = brush_fade * brush_strength * grid_alpha *
brush_alpha_pressure;
- if (final_alpha <= 0.0f)
+ if (final_alpha <= 0.0f) {
continue;
+ }
do_weight_paint_vertex(
data->vp, data->ob, data->wpi, v_index, final_alpha, (float)weight_final);
@@ -2160,8 +2176,9 @@ static void wpaint_do_paint(bContext *C,
wpaint_paint_leaves(C, ob, sd, wp, wpd, wpi, me, nodes, totnode);
- if (nodes)
+ if (nodes) {
MEM_freeN(nodes);
+ }
}
static void wpaint_do_radial_symmetry(bContext *C,
@@ -2310,8 +2327,9 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
/* previous is not set in the current cache else
* the partial rect will always grow */
if (ss->cache) {
- if (!BLI_rcti_is_empty(&ss->cache->previous_r))
+ if (!BLI_rcti_is_empty(&ss->cache->previous_r)) {
BLI_rcti_union(&r, &ss->cache->previous_r);
+ }
}
r.xmin += vc->ar->winrct.xmin - 2;
@@ -2330,18 +2348,24 @@ static void wpaint_stroke_done(const bContext *C, struct PaintStroke *stroke)
struct WPaintData *wpd = paint_stroke_mode_data(stroke);
if (wpd) {
- if (wpd->defbase_sel)
+ if (wpd->defbase_sel) {
MEM_freeN((void *)wpd->defbase_sel);
- if (wpd->vgroup_validmap)
+ }
+ if (wpd->vgroup_validmap) {
MEM_freeN((void *)wpd->vgroup_validmap);
- if (wpd->lock_flags)
+ }
+ if (wpd->lock_flags) {
MEM_freeN((void *)wpd->lock_flags);
- if (wpd->active.lock)
+ }
+ if (wpd->active.lock) {
MEM_freeN((void *)wpd->active.lock);
- if (wpd->mirror.lock)
+ }
+ if (wpd->mirror.lock) {
MEM_freeN((void *)wpd->mirror.lock);
- if (wpd->precomputed_weight)
+ }
+ if (wpd->precomputed_weight) {
MEM_freeN(wpd->precomputed_weight);
+ }
MEM_freeN(wpd);
}
@@ -2572,12 +2596,14 @@ static bool vpaint_stroke_test_start(bContext *C, struct wmOperator *op, const f
/* context checks could be a poll() */
me = BKE_mesh_from_object(ob);
- if (me == NULL || me->totpoly == 0)
+ if (me == NULL || me->totpoly == 0) {
return false;
+ }
ED_mesh_color_ensure(me, NULL);
- if (me->mloopcol == NULL)
+ if (me->mloopcol == NULL) {
return false;
+ }
/* make mode data storage */
vpd = MEM_callocN(sizeof(*vpd), "VPaintData");
@@ -3282,12 +3308,15 @@ static void vpaint_stroke_done(const bContext *C, struct PaintStroke *stroke)
ED_vpaint_proj_handle_free(vpd->vp_handle);
}
- if (vpd->mlooptag)
+ if (vpd->mlooptag) {
MEM_freeN(vpd->mlooptag);
- if (vpd->smear.color_prev)
+ }
+ if (vpd->smear.color_prev) {
MEM_freeN(vpd->smear.color_prev);
- if (vpd->smear.color_curr)
+ }
+ if (vpd->smear.color_curr) {
MEM_freeN(vpd->smear.color_curr);
+ }
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
diff --git a/source/blender/editors/sculpt_paint/paint_vertex_color_ops.c b/source/blender/editors/sculpt_paint/paint_vertex_color_ops.c
index 7df9ccc0e50..fed477ace14 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex_color_ops.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex_color_ops.c
@@ -82,8 +82,9 @@ static bool vertex_color_set(Object *ob, uint paintcol)
for (i = 0; i < me->totpoly; i++, mp++) {
MLoopCol *lcol = me->mloopcol + mp->loopstart;
- if (use_face_sel && !(mp->flag & ME_FACE_SEL))
+ if (use_face_sel && !(mp->flag & ME_FACE_SEL)) {
continue;
+ }
j = 0;
do {
@@ -220,8 +221,9 @@ static void vertex_color_smooth_looptag(Mesh *me, bool *mlooptag)
/* if no mloopcol: do not do */
/* if mtexpoly: only the involved faces, otherwise all */
- if (me->mloopcol == NULL || me->totvert == 0 || me->totpoly == 0)
+ if (me->mloopcol == NULL || me->totvert == 0 || me->totpoly == 0) {
return;
+ }
scol = MEM_callocN(sizeof(int) * me->totvert * 5, "scol");
@@ -289,8 +291,9 @@ static bool vertex_color_smooth(Object *ob)
const MLoop *ml = me->mloop + mp->loopstart;
int ml_index = mp->loopstart;
- if (use_face_sel && !(mp->flag & ME_FACE_SEL))
+ if (use_face_sel && !(mp->flag & ME_FACE_SEL)) {
continue;
+ }
for (j = 0; j < mp->totloop; j++, ml_index++, ml++) {
mlooptag[ml_index] = true;
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 9ac44c5114d..5ae004fde5f 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -109,8 +109,9 @@ static bool sculpt_has_active_modifiers(Scene *scene, Object *ob)
/* exception for shape keys because we can edit those */
for (; md; md = md->next) {
- if (modifier_isEnabled(scene, md, eModifierMode_Realtime))
+ if (modifier_isEnabled(scene, md, eModifierMode_Realtime)) {
return 1;
+ }
}
return 0;
@@ -394,17 +395,20 @@ static void paint_mesh_restore_co_task_cb(void *__restrict userdata,
if (orig_data.unode->type == SCULPT_UNDO_COORDS) {
copy_v3_v3(vd.co, orig_data.co);
- if (vd.no)
+ if (vd.no) {
copy_v3_v3_short(vd.no, orig_data.no);
- else
+ }
+ else {
normal_short_to_float_v3(vd.fno, orig_data.no);
+ }
}
else if (orig_data.unode->type == SCULPT_UNDO_MASK) {
*vd.mask = orig_data.mask;
}
- if (vd.mvert)
+ if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+ }
}
BKE_pbvh_vertex_iter_end;
@@ -439,8 +443,9 @@ static void paint_mesh_restore_co(Sculpt *sd, Object *ob)
totnode > SCULPT_THREADED_LIMIT);
BLI_task_parallel_range(0, totnode, &data, paint_mesh_restore_co_task_cb, &settings);
- if (nodes)
+ if (nodes) {
MEM_freeN(nodes);
+ }
}
/*** BVH Tree ***/
@@ -456,8 +461,9 @@ static void sculpt_extend_redraw_rect_previous(Object *ob, rcti *rect)
SculptSession *ss = ob->sculpt;
if (ss->cache) {
- if (!BLI_rcti_is_empty(&ss->cache->previous_r))
+ if (!BLI_rcti_is_empty(&ss->cache->previous_r)) {
BLI_rcti_union(rect, &ss->cache->previous_r);
+ }
}
}
@@ -467,8 +473,9 @@ bool sculpt_get_redraw_rect(ARegion *ar, RegionView3D *rv3d, Object *ob, rcti *r
PBVH *pbvh = ob->sculpt->pbvh;
float bb_min[3], bb_max[3];
- if (!pbvh)
+ if (!pbvh) {
return 0;
+ }
BKE_pbvh_redraw_BB(pbvh, bb_min, bb_max);
@@ -497,8 +504,9 @@ void ED_sculpt_redraw_planes_get(float planes[4][4], ARegion *ar, Object *ob)
ob->sculpt->cache->previous_r = ob->sculpt->cache->current_r;
/* clear redraw flag from nodes */
- if (pbvh)
+ if (pbvh) {
BKE_pbvh_update(pbvh, PBVH_UpdateRedraw, NULL);
+ }
}
/************************ Brush Testing *******************/
@@ -726,10 +734,12 @@ static float calc_overlap(StrokeCache *cache, const char symm, const char axis,
/* distsq = len_squared_v3v3(mirror, cache->traced_location); */
distsq = len_squared_v3v3(mirror, cache->true_location);
- if (distsq <= 4.0f * (cache->radius_squared))
+ if (distsq <= 4.0f * (cache->radius_squared)) {
return (2.0f * (cache->radius) - sqrtf(distsq)) / (2.0f * (cache->radius));
- else
+ }
+ else {
return 0;
+ }
}
static float calc_radial_symmetry_feather(Sculpt *sd,
@@ -841,10 +851,12 @@ static void calc_area_normal_and_center_task_cb(void *__restrict userdata,
normal_tri_v3(no, UNPACK3(co_tri));
flip_index = (dot_v3v3(ss->cache->view_normal, no) <= 0.0f);
- if (area_cos)
+ if (area_cos) {
add_v3_v3(private_co[flip_index], co);
- if (area_nos)
+ }
+ if (area_nos) {
add_v3_v3(private_no[flip_index], no);
+ }
private_count[flip_index] += 1;
}
}
@@ -888,10 +900,12 @@ static void calc_area_normal_and_center_task_cb(void *__restrict userdata,
}
flip_index = (dot_v3v3(ss->cache->view_normal, no) <= 0.0f);
- if (area_cos)
+ if (area_cos) {
add_v3_v3(private_co[flip_index], co);
- if (area_nos)
+ }
+ if (area_nos) {
add_v3_v3(private_no[flip_index], no);
+ }
private_count[flip_index] += 1;
}
}
@@ -1212,8 +1226,9 @@ float tex_strength(SculptSession *ss,
flip_v3_v3(symm_point, point, cache->mirror_symmetry_pass);
- if (cache->radial_symmetry_pass)
+ if (cache->radial_symmetry_pass) {
mul_m4_v3(cache->symm_rot_mat_inv, symm_point);
+ }
ED_view3d_project_float_v2_m4(cache->vc->ar, symm_point, point_2d, cache->projection_mat);
@@ -1263,18 +1278,23 @@ bool sculpt_search_sphere_cb(PBVHNode *node, void *data_v)
float t[3], bb_min[3], bb_max[3];
int i;
- if (data->original)
+ if (data->original) {
BKE_pbvh_node_get_original_BB(node, bb_min, bb_max);
- else
+ }
+ else {
BKE_pbvh_node_get_BB(node, bb_min, bb_max);
+ }
for (i = 0; i < 3; ++i) {
- if (bb_min[i] > center[i])
+ if (bb_min[i] > center[i]) {
nearest[i] = bb_min[i];
- else if (bb_max[i] < center[i])
+ }
+ else if (bb_max[i] < center[i]) {
nearest[i] = bb_max[i];
- else
+ }
+ else {
nearest[i] = center[i];
+ }
}
sub_v3_v3v3(t, center, nearest);
@@ -1288,10 +1308,12 @@ bool sculpt_search_circle_cb(PBVHNode *node, void *data_v)
SculptSearchCircleData *data = data_v;
float bb_min[3], bb_max[3];
- if (data->original)
+ if (data->original) {
BKE_pbvh_node_get_original_BB(node, bb_min, bb_max);
- else
+ }
+ else {
BKE_pbvh_node_get_BB(node, bb_min, bb_min);
+ }
float dummy_co[3], dummy_depth;
const float dist_sq = dist_squared_ray_to_aabb_v3(
@@ -1306,13 +1328,16 @@ static void sculpt_clip(Sculpt *sd, SculptSession *ss, float co[3], const float
int i;
for (i = 0; i < 3; ++i) {
- if (sd->flags & (SCULPT_LOCK_X << i))
+ if (sd->flags & (SCULPT_LOCK_X << i)) {
continue;
+ }
- if ((ss->cache->flag & (CLIP_X << i)) && (fabsf(co[i]) <= ss->cache->clip_tolerance[i]))
+ if ((ss->cache->flag & (CLIP_X << i)) && (fabsf(co[i]) <= ss->cache->clip_tolerance[i])) {
co[i] = 0.0f;
- else
+ }
+ else {
co[i] = val[i];
+ }
}
}
@@ -1537,10 +1562,12 @@ static float neighbor_average_mask(SculptSession *ss, unsigned vert)
}
}
- if (total > 0)
+ if (total > 0) {
return avg / (float)total;
- else
+ }
+ else {
return vmask[vert];
+ }
}
/* Same logic as neighbor_average(), but for bmesh rather than mesh */
@@ -1771,8 +1798,9 @@ static void do_smooth_brush_mesh_task_cb_ex(void *__restrict userdata,
sculpt_clip(sd, ss, vd.co, val);
}
- if (vd.mvert)
+ if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+ }
}
}
BKE_pbvh_vertex_iter_end;
@@ -1825,8 +1853,9 @@ static void do_smooth_brush_bmesh_task_cb_ex(void *__restrict userdata,
sculpt_clip(sd, ss, vd.co, val);
}
- if (vd.mvert)
+ if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+ }
}
}
BKE_pbvh_vertex_iter_end;
@@ -1881,8 +1910,9 @@ static void do_topology_rake_bmesh_task_cb_ex(void *__restrict userdata,
sculpt_clip(sd, ss, vd.co, val);
- if (vd.mvert)
+ if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+ }
}
}
BKE_pbvh_vertex_iter_end;
@@ -1924,20 +1954,24 @@ static void do_smooth_brush_multires_task_cb_ex(void *__restrict userdata,
grid_hidden = BKE_pbvh_grid_hidden(ss->pbvh);
- if (smooth_mask)
+ if (smooth_mask) {
tmpgrid_mask = (void *)(data_chunk + 1);
- else
+ }
+ else {
tmpgrid_co = (void *)(data_chunk + 1);
+ }
for (i = 0; i < totgrid; i++) {
int gi = grid_indices[i];
const BLI_bitmap *gh = grid_hidden[gi];
gddata = griddata[gi];
- if (smooth_mask)
+ if (smooth_mask) {
memset(tmpgrid_mask, 0, data_chunk->tmpgrid_size);
- else
+ }
+ else {
memset(tmpgrid_co, 0, data_chunk->tmpgrid_size);
+ }
for (y = 0; y < gridsize - 1; y++) {
const int v = y * gridsize;
@@ -1994,8 +2028,9 @@ static void do_smooth_brush_multires_task_cb_ex(void *__restrict userdata,
const int index = y * gridsize + x;
if (gh) {
- if (BLI_BITMAP_TEST(gh, index))
+ if (BLI_BITMAP_TEST(gh, index)) {
continue;
+ }
}
co = CCG_elem_offset_co(&key, gddata, index);
@@ -2010,11 +2045,13 @@ static void do_smooth_brush_multires_task_cb_ex(void *__restrict userdata,
ss, brush, co, sqrtf(test.dist), NULL, fno, strength_mask, tls->thread_id);
float f = 1.0f / 16.0f;
- if (x == 0 || x == gridsize - 1)
+ if (x == 0 || x == gridsize - 1) {
f *= 2.0f;
+ }
- if (y == 0 || y == gridsize - 1)
+ if (y == 0 || y == gridsize - 1) {
f *= 2.0f;
+ }
if (smooth_mask) {
*mask += ((tmpgrid_mask[index] * f) - *mask) * fade;
@@ -2105,8 +2142,9 @@ static void smooth(Sculpt *sd,
break;
}
- if (ss->multires)
+ if (ss->multires) {
multires_stitch_grids(ob);
+ }
}
}
@@ -2170,8 +2208,9 @@ static void do_mask_brush_draw_task_cb_ex(void *__restrict userdata,
(*vd.mask) += fade * bstrength;
CLAMP(*vd.mask, 0, 1);
- if (vd.mvert)
+ if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+ }
}
BKE_pbvh_vertex_iter_end;
}
@@ -2243,8 +2282,9 @@ static void do_draw_brush_task_cb_ex(void *__restrict userdata,
mul_v3_v3fl(proxy[vd.i], offset, fade);
- if (vd.mvert)
+ if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+ }
}
}
BKE_pbvh_vertex_iter_end;
@@ -2334,8 +2374,9 @@ static void do_crease_brush_task_cb_ex(void *__restrict userdata,
add_v3_v3v3(proxy[vd.i], val1, val2);
- if (vd.mvert)
+ if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+ }
}
}
BKE_pbvh_vertex_iter_end;
@@ -2362,15 +2403,17 @@ static void do_crease_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod
* to give us the pinch strength. */
crease_correction = brush->crease_pinch_factor * brush->crease_pinch_factor;
brush_alpha = BKE_brush_alpha_get(scene, brush);
- if (brush_alpha > 0.0f)
+ if (brush_alpha > 0.0f) {
crease_correction /= brush_alpha * brush_alpha;
+ }
/* we always want crease to pinch or blob to relax even when draw is negative */
flippedbstrength = (bstrength < 0) ? -crease_correction * bstrength :
crease_correction * bstrength;
- if (brush->sculpt_tool == SCULPT_TOOL_BLOB)
+ if (brush->sculpt_tool == SCULPT_TOOL_BLOB) {
flippedbstrength *= -1.0f;
+ }
/* Use surface normal for 'spvc',
* so the vertices are pinched towards a line instead of a single point.
@@ -2431,8 +2474,9 @@ static void do_pinch_brush_task_cb_ex(void *__restrict userdata,
}
mul_v3_v3fl(proxy[vd.i], val, fade);
- if (vd.mvert)
+ if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+ }
}
}
BKE_pbvh_vertex_iter_end;
@@ -2493,8 +2537,9 @@ static void do_grab_brush_task_cb_ex(void *__restrict userdata,
mul_v3_v3fl(proxy[vd.i], grab_delta, fade);
- if (vd.mvert)
+ if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+ }
}
}
BKE_pbvh_vertex_iter_end;
@@ -2559,8 +2604,9 @@ static void do_nudge_brush_task_cb_ex(void *__restrict userdata,
mul_v3_v3fl(proxy[vd.i], cono, fade);
- if (vd.mvert)
+ if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+ }
}
}
BKE_pbvh_vertex_iter_end;
@@ -2666,8 +2712,9 @@ static void do_snake_hook_brush_task_cb_ex(void *__restrict userdata,
add_v3_v3(proxy[vd.i], delta_rotate);
}
- if (vd.mvert)
+ if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+ }
}
}
BKE_pbvh_vertex_iter_end;
@@ -2684,8 +2731,9 @@ static void do_snake_hook_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int to
copy_v3_v3(grab_delta, ss->cache->grab_delta_symmetry);
- if (bstrength < 0)
+ if (bstrength < 0) {
negate_v3(grab_delta);
+ }
if (ss->cache->normal_weight > 0.0f) {
sculpt_project_v3_normal_align(ss, ss->cache->normal_weight, grab_delta);
@@ -2749,8 +2797,9 @@ static void do_thumb_brush_task_cb_ex(void *__restrict userdata,
mul_v3_v3fl(proxy[vd.i], cono, fade);
- if (vd.mvert)
+ if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+ }
}
}
BKE_pbvh_vertex_iter_end;
@@ -2825,8 +2874,9 @@ static void do_rotate_brush_task_cb_ex(void *__restrict userdata,
add_v3_v3(proxy[vd.i], ss->cache->location);
sub_v3_v3(proxy[vd.i], orig_data.co);
- if (vd.mvert)
+ if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+ }
}
}
BKE_pbvh_vertex_iter_end;
@@ -2902,8 +2952,9 @@ static void do_layer_brush_task_cb_ex(void *__restrict userdata,
*disp += fade;
/* Don't let the displacement go past the limit */
- if ((lim < 0.0f && *disp < lim) || (lim >= 0.0f && *disp > lim))
+ if ((lim < 0.0f && *disp < lim) || (lim >= 0.0f && *disp > lim)) {
*disp = lim;
+ }
mul_v3_v3fl(val, offset, *disp);
@@ -2919,8 +2970,9 @@ static void do_layer_brush_task_cb_ex(void *__restrict userdata,
sculpt_clip(sd, ss, vd.co, val);
- if (vd.mvert)
+ if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+ }
}
}
BKE_pbvh_vertex_iter_end;
@@ -2982,16 +3034,19 @@ static void do_inflate_brush_task_cb_ex(void *__restrict userdata,
tls->thread_id);
float val[3];
- if (vd.fno)
+ if (vd.fno) {
copy_v3_v3(val, vd.fno);
- else
+ }
+ else {
normal_short_to_float_v3(val, vd.no);
+ }
mul_v3_fl(val, fade * ss->cache->radius);
mul_v3_v3v3(proxy[vd.i], val, ss->cache->scale);
- if (vd.mvert)
+ if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+ }
}
}
BKE_pbvh_vertex_iter_end;
@@ -3054,8 +3109,9 @@ static void calc_sculpt_plane(
/* for flatten center */
/* flatten center has not been calculated yet if we are not using the area normal */
- if (brush->sculpt_plane != SCULPT_DISP_DIR_AREA)
+ if (brush->sculpt_plane != SCULPT_DISP_DIR_AREA) {
calc_area_center(sd, ob, nodes, totnode, r_area_co);
+ }
/* for area normal */
copy_v3_v3(ss->cache->sculpt_normal, r_area_no);
@@ -3096,8 +3152,9 @@ static int plane_trim(const StrokeCache *cache, const Brush *brush, const float
static bool plane_point_side_flip(const float co[3], const float plane[4], const bool flip)
{
float d = plane_point_side_v3(plane, co);
- if (flip)
+ if (flip) {
d = -d;
+ }
return d <= 0.0f;
}
@@ -3164,8 +3221,9 @@ static void do_flatten_brush_task_cb_ex(void *__restrict userdata,
mul_v3_v3fl(proxy[vd.i], val, fade);
- if (vd.mvert)
+ if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+ }
}
}
}
@@ -3257,8 +3315,9 @@ static void do_clay_brush_task_cb_ex(void *__restrict userdata,
mul_v3_v3fl(proxy[vd.i], val, fade);
- if (vd.mvert)
+ if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+ }
}
}
}
@@ -3353,8 +3412,9 @@ static void do_clay_strips_brush_task_cb_ex(void *__restrict userdata,
mul_v3_v3fl(proxy[vd.i], val, fade);
- if (vd.mvert)
+ if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+ }
}
}
}
@@ -3383,14 +3443,17 @@ static void do_clay_strips_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int t
calc_sculpt_plane(sd, ob, nodes, totnode, area_no_sp, area_co);
- if (brush->sculpt_plane != SCULPT_DISP_DIR_AREA || (brush->flag & BRUSH_ORIGINAL_NORMAL))
+ if (brush->sculpt_plane != SCULPT_DISP_DIR_AREA || (brush->flag & BRUSH_ORIGINAL_NORMAL)) {
calc_area_normal(sd, ob, nodes, totnode, area_no);
- else
+ }
+ else {
copy_v3_v3(area_no, area_no_sp);
+ }
/* delay the first daub because grab delta is not setup */
- if (ss->cache->first_time)
+ if (ss->cache->first_time) {
return;
+ }
mul_v3_v3v3(temp, area_no_sp, ss->cache->scale);
mul_v3_fl(temp, displace);
@@ -3473,8 +3536,9 @@ static void do_fill_brush_task_cb_ex(void *__restrict userdata,
mul_v3_v3fl(proxy[vd.i], val, fade);
- if (vd.mvert)
+ if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+ }
}
}
}
@@ -3564,8 +3628,9 @@ static void do_scrape_brush_task_cb_ex(void *__restrict userdata,
mul_v3_v3fl(proxy[vd.i], val, fade);
- if (vd.mvert)
+ if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+ }
}
}
}
@@ -3643,8 +3708,9 @@ static void do_gravity_task_cb_ex(void *__restrict userdata,
mul_v3_v3fl(proxy[vd.i], offset, fade);
- if (vd.mvert)
+ if (vd.mvert) {
vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+ }
}
}
BKE_pbvh_vertex_iter_end;
@@ -3710,8 +3776,9 @@ void sculpt_vertcos_to_key(Object *ob, KeyBlock *kb, float (*vertCos)[3])
if (kb == me->key->refkey) {
MVert *mvert = me->mvert;
- for (a = 0; a < me->totvert; a++, mvert++)
+ for (a = 0; a < me->totvert; a++, mvert++) {
copy_v3_v3(mvert->co, vertCos[a]);
+ }
BKE_mesh_calc_normals(me);
}
@@ -3825,11 +3892,13 @@ static void do_brush_action(Sculpt *sd, Object *ob, Brush *brush, UnifiedPaintSe
settings.use_threading = ((sd->flags & SCULPT_USE_OPENMP) && totnode > SCULPT_THREADED_LIMIT);
BLI_task_parallel_range(0, totnode, &task_data, do_brush_action_task_cb, &settings);
- if (sculpt_brush_needs_normal(ss, brush))
+ if (sculpt_brush_needs_normal(ss, brush)) {
update_sculpt_normal(sd, ob, nodes, totnode);
+ }
- if (brush->mtex.brush_map_mode == MTEX_MAP_MODE_AREA)
+ if (brush->mtex.brush_map_mode == MTEX_MAP_MODE_AREA) {
update_brush_local_mat(sd, ob);
+ }
/* Apply one type of brush action */
switch (brush->sculpt_tool) {
@@ -3904,8 +3973,9 @@ static void do_brush_action(Sculpt *sd, Object *ob, Brush *brush, UnifiedPaintSe
bmesh_topology_rake(sd, ob, nodes, totnode, brush->topology_rake_factor);
}
- if (ss->cache->supports_gravity)
+ if (ss->cache->supports_gravity) {
do_gravity(sd, ob, nodes, totnode, sd->gravity_factor);
+ }
MEM_freeN(nodes);
@@ -3935,8 +4005,9 @@ static void sculpt_flush_pbvhvert_deform(Object *ob, PBVHVertexIter *vd)
copy_v3_v3(ss->deform_cos[index], vd->co);
copy_v3_v3(ss->orig_cos[index], newco);
- if (!ss->kb)
+ if (!ss->kb) {
copy_v3_v3(me->mvert[index].co, newco);
+ }
}
static void sculpt_combine_proxies_task_cb(void *__restrict userdata,
@@ -3957,8 +4028,9 @@ static void sculpt_combine_proxies_task_cb(void *__restrict userdata,
int proxy_count;
float(*orco)[3] = NULL;
- if (use_orco && !ss->bm)
+ if (use_orco && !ss->bm) {
orco = sculpt_undo_push_node(data->ob, data->nodes[n], SCULPT_UNDO_COORDS)->co;
+ }
BKE_pbvh_node_get_proxies(data->nodes[n], &proxies, &proxy_count);
@@ -3979,13 +4051,15 @@ static void sculpt_combine_proxies_task_cb(void *__restrict userdata,
copy_v3_v3(val, vd.co);
}
- for (p = 0; p < proxy_count; p++)
+ for (p = 0; p < proxy_count; p++) {
add_v3_v3(val, proxies[p].co[vd.i]);
+ }
sculpt_clip(sd, ss, vd.co, val);
- if (ss->modifiers_active)
+ if (ss->modifiers_active) {
sculpt_flush_pbvhvert_deform(ob, &vd);
+ }
}
BKE_pbvh_vertex_iter_end;
@@ -4016,8 +4090,9 @@ static void sculpt_combine_proxies(Sculpt *sd, Object *ob)
BLI_task_parallel_range(0, totnode, &data, sculpt_combine_proxies_task_cb, &settings);
}
- if (nodes)
+ if (nodes) {
MEM_freeN(nodes);
+ }
}
/* copy the modified vertices from bvh to the active key */
@@ -4028,16 +4103,19 @@ static void sculpt_update_keyblock(Object *ob)
/* Keyblock update happens after handling deformation caused by modifiers,
* so ss->orig_cos would be updated with new stroke */
- if (ss->orig_cos)
+ if (ss->orig_cos) {
vertCos = ss->orig_cos;
- else
+ }
+ else {
vertCos = BKE_pbvh_get_vertCos(ss->pbvh);
+ }
if (vertCos) {
sculpt_vertcos_to_key(ob, ss->kb, vertCos);
- if (vertCos != ss->orig_cos)
+ if (vertCos != ss->orig_cos) {
MEM_freeN(vertCos);
+ }
}
}
@@ -4197,8 +4275,9 @@ static void do_tiled(
start[dim] = (bbMin[dim] - orgLoc[dim] - radius) / step[dim];
end[dim] = (bbMax[dim] - orgLoc[dim] + radius) / step[dim];
}
- else
+ else {
start[dim] = end[dim] = 0;
+ }
}
/* first do the "untiled" position to initialize the stroke for this location */
@@ -4210,8 +4289,9 @@ static void do_tiled(
for (cur[0] = start[0]; cur[0] <= end[0]; ++cur[0]) {
for (cur[1] = start[1]; cur[1] <= end[1]; ++cur[1]) {
for (cur[2] = start[2]; cur[2] <= end[2]; ++cur[2]) {
- if (!cur[0] && !cur[1] && !cur[2])
+ if (!cur[0] && !cur[1] && !cur[2]) {
continue; /* skip tile at orgLoc, this was already handled before all others */
+ }
++cache->tile_pass;
@@ -4254,8 +4334,9 @@ static void sculpt_fix_noise_tear(Sculpt *sd, Object *ob)
Brush *brush = BKE_paint_brush(&sd->paint);
MTex *mtex = &brush->mtex;
- if (ss->multires && mtex->tex && mtex->tex->type == TEX_NOISE)
+ if (ss->multires && mtex->tex && mtex->tex->type == TEX_NOISE) {
multires_stitch_grids(ob);
+ }
}
static void do_symmetrical_brush_actions(Sculpt *sd,
@@ -4390,8 +4471,9 @@ static const char *sculpt_tool_name(Sculpt *sd)
void sculpt_cache_free(StrokeCache *cache)
{
- if (cache->dial)
+ if (cache->dial) {
MEM_freeN(cache->dial);
+ }
MEM_freeN(cache);
}
@@ -4463,10 +4545,12 @@ static void sculpt_update_cache_invariants(
sculpt_init_mirror_clipping(ob, ss);
/* Initial mouse location */
- if (mouse)
+ if (mouse) {
copy_v2_v2(cache->initial_mouse, mouse);
- else
+ }
+ else {
zero_v2(cache->initial_mouse);
+ }
mode = RNA_enum_get(op->ptr, "mode");
cache->invert = mode == BRUSH_STROKE_INVERT;
@@ -4483,10 +4567,12 @@ static void sculpt_update_cache_invariants(
/* not very nice, but with current events system implementation
* we can't handle brush appearance inversion hotkey separately (sergey) */
- if (cache->invert)
+ if (cache->invert) {
ups->draw_inverted = true;
- else
+ }
+ else {
ups->draw_inverted = false;
+ }
/* Alt-Smooth */
if (cache->alt_smooth) {
@@ -4557,8 +4643,9 @@ static void sculpt_update_cache_invariants(
if (brush->sculpt_tool == SCULPT_TOOL_LAYER) {
/* not supported yet for multires or dynamic topology */
if (!ss->multires && !ss->bm && !ss->layer_co && (brush->flag & BRUSH_PERSISTENT)) {
- if (!ss->layer_co)
+ if (!ss->layer_co) {
ss->layer_co = MEM_mallocN(sizeof(float) * 3 * ss->totvert, "sculpt mesh vertices copy");
+ }
if (ss->deform_cos) {
memcpy(ss->layer_co, ss->deform_cos, ss->totvert);
@@ -4592,8 +4679,9 @@ static void sculpt_update_cache_invariants(
cache->first_time = 1;
#define PIXEL_INPUT_THRESHHOLD 5
- if (brush->sculpt_tool == SCULPT_TOOL_ROTATE)
+ if (brush->sculpt_tool == SCULPT_TOOL_ROTATE) {
cache->dial = BLI_dial_initialize(cache->initial_mouse, PIXEL_INPUT_THRESHHOLD);
+ }
#undef PIXEL_INPUT_THRESHHOLD
}
@@ -4620,8 +4708,9 @@ static void sculpt_update_brush_delta(UnifiedPaintSettings *ups, Object *ob, Bru
if (cache->first_time) {
copy_v3_v3(cache->orig_grab_location, cache->true_location);
}
- else if (tool == SCULPT_TOOL_SNAKE_HOOK)
+ else if (tool == SCULPT_TOOL_SNAKE_HOOK) {
add_v3_v3(cache->true_location, cache->grab_delta);
+ }
/* compute 3d coordinate at same z from original location + mouse */
mul_v3_m4v3(loc, ob->obmat, cache->orig_grab_location);
@@ -4667,10 +4756,12 @@ static void sculpt_update_brush_delta(UnifiedPaintSettings *ups, Object *ob, Bru
copy_v3_v3(cache->old_grab_location, grab_location);
- if (tool == SCULPT_TOOL_GRAB)
+ if (tool == SCULPT_TOOL_GRAB) {
copy_v3_v3(cache->anchored_location, cache->true_location);
- else if (tool == SCULPT_TOOL_THUMB)
+ }
+ else if (tool == SCULPT_TOOL_THUMB) {
copy_v3_v3(cache->anchored_location, cache->orig_grab_location);
+ }
if (ELEM(tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_THUMB)) {
/* location stays the same for finding vertices in brush radius */
@@ -5186,8 +5277,9 @@ static bool sculpt_stroke_test_start(bContext *C, struct wmOperator *op, const f
return 1;
}
- else
+ else {
return 0;
+ }
}
static void sculpt_stroke_update_step(bContext *C,
@@ -5256,8 +5348,9 @@ static void sculpt_brush_exit_tex(Sculpt *sd)
Brush *brush = BKE_paint_brush(&sd->paint);
MTex *mtex = &brush->mtex;
- if (mtex->tex && mtex->tex->nodetree)
+ if (mtex->tex && mtex->tex->nodetree) {
ntreeTexEndExecTree(mtex->tex->nodetree->execdata);
+ }
}
static void sculpt_stroke_done(const bContext *C, struct PaintStroke *UNUSED(stroke))
@@ -5298,20 +5391,23 @@ static void sculpt_stroke_done(const bContext *C, struct PaintStroke *UNUSED(str
BKE_pbvh_update(ss->pbvh, PBVH_UpdateOriginalBB, NULL);
- if (BKE_pbvh_type(ss->pbvh) == PBVH_BMESH)
+ if (BKE_pbvh_type(ss->pbvh) == PBVH_BMESH) {
BKE_pbvh_bmesh_after_stroke(ss->pbvh);
+ }
/* optimization: if there is locked key and active modifiers present in */
/* the stack, keyblock is updating at each step. otherwise we could update */
/* keyblock only when stroke is finished */
- if (ss->kb && !ss->modifiers_active)
+ if (ss->kb && !ss->modifiers_active) {
sculpt_update_keyblock(ob);
+ }
ss->partial_redraw = 0;
/* try to avoid calling this, only for e.g. linked duplicates now */
- if (((Mesh *)ob->data)->id.us > 1)
+ if (((Mesh *)ob->data)->id.us > 1) {
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
+ }
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
}
@@ -5436,8 +5532,9 @@ static int sculpt_set_persistent_base_exec(bContext *C, wmOperator *UNUSED(op))
SculptSession *ss = CTX_data_active_object(C)->sculpt;
if (ss) {
- if (ss->layer_co)
+ if (ss->layer_co) {
MEM_freeN(ss->layer_co);
+ }
ss->layer_co = NULL;
}
@@ -5765,8 +5862,9 @@ static enum eDynTopoWarnFlag sculpt_dynamic_topology_check(Scene *scene, Object
/* exception for shape keys because we can edit those */
for (; md; md = md->next) {
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
- if (!modifier_isEnabled(scene, md, eModifierMode_Realtime))
+ if (!modifier_isEnabled(scene, md, eModifierMode_Realtime)) {
continue;
+ }
if (mti->type == eModifierTypeType_Constructive) {
flag |= DYNTOPO_WARN_MODIFIER;
@@ -5945,8 +6043,9 @@ void ED_object_sculptmode_enter_ex(Main *bmain,
const int flush_recalc = ed_object_sculptmode_flush_recalc_flag(scene, ob, mmd);
- if (flush_recalc)
+ if (flush_recalc) {
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
+ }
/* Create sculpt mode session data */
if (ob->sculpt) {
@@ -6173,8 +6272,9 @@ static int sculpt_detail_flood_fill_exec(bContext *C, wmOperator *UNUSED(op))
BKE_pbvh_search_gather(ss->pbvh, NULL, NULL, &nodes, &totnodes);
- if (!totnodes)
+ if (!totnodes) {
return OPERATOR_CANCELLED;
+ }
for (i = 0; i < totnodes; i++) {
BKE_pbvh_node_mark_topology_update(nodes[i]);
@@ -6195,8 +6295,9 @@ static int sculpt_detail_flood_fill_exec(bContext *C, wmOperator *UNUSED(op))
while (BKE_pbvh_bmesh_update_topology(
ss->pbvh, PBVH_Collapse | PBVH_Subdivide, center, NULL, size, false, false)) {
- for (i = 0; i < totnodes; i++)
+ for (i = 0; i < totnodes; i++) {
BKE_pbvh_node_mark_topology_update(nodes[i]);
+ }
}
MEM_freeN(nodes);
diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c
index 0b995860feb..c66c1d91a77 100644
--- a/source/blender/editors/sculpt_paint/sculpt_undo.c
+++ b/source/blender/editors/sculpt_paint/sculpt_undo.c
@@ -81,8 +81,9 @@ static UndoSculpt *sculpt_undo_get_nodes(void);
static void update_cb(PBVHNode *node, void *rebuild)
{
BKE_pbvh_node_mark_update(node);
- if (*((bool *)rebuild))
+ if (*((bool *)rebuild)) {
BKE_pbvh_node_mark_rebuild_draw(node);
+ }
BKE_pbvh_node_fully_hidden_set(node, 0);
}
@@ -314,8 +315,9 @@ static bool sculpt_undo_restore_mask(bContext *C, SculptUndoNode *unode)
for (j = 0; j < unode->totgrid; j++) {
grid = grids[unode->grids[j]];
- for (i = 0; i < gridsize * gridsize; i++, mask++)
+ for (i = 0; i < gridsize * gridsize; i++, mask++) {
SWAP(float, *CCG_elem_offset_mask(&key, grid, i), *mask);
+ }
}
}
@@ -357,8 +359,9 @@ static void sculpt_undo_bmesh_restore_generic(bContext *C,
BLI_task_parallel_range(
0, totnode, nodes, sculpt_undo_bmesh_restore_generic_task_cb, &settings);
- if (nodes)
+ if (nodes) {
MEM_freeN(nodes);
+ }
}
else {
sculpt_pbvh_clear(ob);
@@ -483,18 +486,21 @@ static void sculpt_undo_restore_list(bContext *C, ListBase *lb)
BKE_sculpt_update_mesh_elements(depsgraph, scene, sd, ob, false, need_mask);
- if (lb->first && sculpt_undo_bmesh_restore(C, lb->first, ob, ss))
+ if (lb->first && sculpt_undo_bmesh_restore(C, lb->first, ob, ss)) {
return;
+ }
for (unode = lb->first; unode; unode = unode->next) {
- if (!STREQ(unode->idname, ob->id.name))
+ if (!STREQ(unode->idname, ob->id.name)) {
continue;
+ }
/* check if undo data matches current data well enough to
* continue */
if (unode->maxvert) {
- if (ss->totvert != unode->maxvert)
+ if (ss->totvert != unode->maxvert) {
continue;
+ }
}
else if (unode->maxgrid && subdiv_ccg != NULL) {
if ((subdiv_ccg->num_grids != unode->maxgrid) ||
@@ -508,16 +514,19 @@ static void sculpt_undo_restore_list(bContext *C, ListBase *lb)
switch (unode->type) {
case SCULPT_UNDO_COORDS:
- if (sculpt_undo_restore_coords(C, unode))
+ if (sculpt_undo_restore_coords(C, unode)) {
update = true;
+ }
break;
case SCULPT_UNDO_HIDDEN:
- if (sculpt_undo_restore_hidden(C, unode))
+ if (sculpt_undo_restore_hidden(C, unode)) {
rebuild = true;
+ }
break;
case SCULPT_UNDO_MASK:
- if (sculpt_undo_restore_mask(C, unode))
+ if (sculpt_undo_restore_mask(C, unode)) {
update = true;
+ }
break;
case SCULPT_UNDO_DYNTOPO_BEGIN:
@@ -548,10 +557,12 @@ static void sculpt_undo_restore_list(bContext *C, ListBase *lb)
NULL);
if (BKE_sculpt_multires_active(scene, ob)) {
- if (rebuild)
+ if (rebuild) {
multires_mark_as_modified(ob, MULTIRES_HIDDEN_MODIFIED);
- else
+ }
+ else {
multires_mark_as_modified(ob, MULTIRES_COORDS_MODIFIED);
+ }
}
tag_update |= ((Mesh *)ob->data)->id.us > 1;
@@ -578,40 +589,52 @@ static void sculpt_undo_free_list(ListBase *lb)
SculptUndoNode *unode = lb->first;
while (unode != NULL) {
SculptUndoNode *unode_next = unode->next;
- if (unode->co)
+ if (unode->co) {
MEM_freeN(unode->co);
- if (unode->no)
+ }
+ if (unode->no) {
MEM_freeN(unode->no);
- if (unode->index)
+ }
+ if (unode->index) {
MEM_freeN(unode->index);
- if (unode->grids)
+ }
+ if (unode->grids) {
MEM_freeN(unode->grids);
- if (unode->orig_co)
+ }
+ if (unode->orig_co) {
MEM_freeN(unode->orig_co);
- if (unode->vert_hidden)
+ }
+ if (unode->vert_hidden) {
MEM_freeN(unode->vert_hidden);
+ }
if (unode->grid_hidden) {
for (int i = 0; i < unode->totgrid; i++) {
- if (unode->grid_hidden[i])
+ if (unode->grid_hidden[i]) {
MEM_freeN(unode->grid_hidden[i]);
+ }
}
MEM_freeN(unode->grid_hidden);
}
- if (unode->mask)
+ if (unode->mask) {
MEM_freeN(unode->mask);
+ }
if (unode->bm_entry) {
BM_log_entry_drop(unode->bm_entry);
}
- if (unode->bm_enter_totvert)
+ if (unode->bm_enter_totvert) {
CustomData_free(&unode->bm_enter_vdata, unode->bm_enter_totvert);
- if (unode->bm_enter_totedge)
+ }
+ if (unode->bm_enter_totedge) {
CustomData_free(&unode->bm_enter_edata, unode->bm_enter_totedge);
- if (unode->bm_enter_totloop)
+ }
+ if (unode->bm_enter_totloop) {
CustomData_free(&unode->bm_enter_ldata, unode->bm_enter_totloop);
- if (unode->bm_enter_totpoly)
+ }
+ if (unode->bm_enter_totpoly) {
CustomData_free(&unode->bm_enter_pdata, unode->bm_enter_totpoly);
+ }
MEM_freeN(unode);
@@ -665,10 +688,12 @@ static void sculpt_undo_alloc_and_store_hidden(PBVH *pbvh, SculptUndoNode *unode
unode->grid_hidden = MEM_mapallocN(sizeof(*unode->grid_hidden) * totgrid, "unode->grid_hidden");
for (i = 0; i < totgrid; i++) {
- if (grid_hidden[grid_indices[i]])
+ if (grid_hidden[grid_indices[i]]) {
unode->grid_hidden[i] = MEM_dupallocN(grid_hidden[grid_indices[i]]);
- else
+ }
+ else {
unode->grid_hidden[i] = NULL;
+ }
}
}
@@ -690,8 +715,9 @@ static SculptUndoNode *sculpt_undo_alloc_node(Object *ob, PBVHNode *node, Sculpt
unode->totvert = totvert;
}
- else
+ else {
maxgrid = 0;
+ }
/* we will use this while sculpting, is mapalloc slow to access then? */
@@ -704,10 +730,12 @@ static SculptUndoNode *sculpt_undo_alloc_node(Object *ob, PBVHNode *node, Sculpt
usculpt->undo_size = (sizeof(float[3]) + sizeof(short[3]) + sizeof(int)) * allvert;
break;
case SCULPT_UNDO_HIDDEN:
- if (maxgrid)
+ if (maxgrid) {
sculpt_undo_alloc_and_store_hidden(ss->pbvh, unode);
- else
+ }
+ else {
unode->vert_hidden = BLI_BITMAP_NEW(allvert, "SculptUndoNode.vert_hidden");
+ }
break;
case SCULPT_UNDO_MASK:
@@ -738,8 +766,9 @@ static SculptUndoNode *sculpt_undo_alloc_node(Object *ob, PBVHNode *node, Sculpt
unode->index = MEM_mapallocN(sizeof(int) * allvert, "SculptUndoNode.index");
}
- if (ss->modifiers_active)
+ if (ss->modifiers_active) {
unode->orig_co = MEM_callocN(allvert * sizeof(*unode->orig_co), "undoSculpt orig_cos");
+ }
return unode;
}
@@ -752,13 +781,16 @@ static void sculpt_undo_store_coords(Object *ob, SculptUndoNode *unode)
BKE_pbvh_vertex_iter_begin(ss->pbvh, unode->node, vd, PBVH_ITER_ALL)
{
copy_v3_v3(unode->co[vd.i], vd.co);
- if (vd.no)
+ if (vd.no) {
copy_v3_v3_short(unode->no[vd.i], vd.no);
- else
+ }
+ else {
normal_float_to_short_v3(unode->no[vd.i], vd.fno);
+ }
- if (ss->modifiers_active)
+ if (ss->modifiers_active) {
copy_v3_v3(unode->orig_co[vd.i], ss->orig_cos[unode->index[vd.i]]);
+ }
}
BKE_pbvh_vertex_iter_end;
}
@@ -944,10 +976,12 @@ SculptUndoNode *sculpt_undo_push_node(Object *ob, PBVHNode *node, SculptUndoType
}
/* store active shape key */
- if (ss->kb)
+ if (ss->kb) {
BLI_strncpy(unode->shapeName, ss->kb->name, sizeof(ss->kb->name));
- else
+ }
+ else {
unode->shapeName[0] = '\0';
+ }
BLI_thread_unlock(LOCK_CUSTOM1);
@@ -973,8 +1007,9 @@ void sculpt_undo_push_end(void)
unode->no = NULL;
}
- if (unode->node)
+ if (unode->node) {
BKE_pbvh_node_layer_disp_free(unode->node);
+ }
}
/* We could remove this and enforce all callers run in an operator using 'OPTYPE_UNDO'. */
diff --git a/source/blender/editors/sculpt_paint/sculpt_uv.c b/source/blender/editors/sculpt_paint/sculpt_uv.c
index 826db204fd0..3cda90ea3f9 100644
--- a/source/blender/editors/sculpt_paint/sculpt_uv.c
+++ b/source/blender/editors/sculpt_paint/sculpt_uv.c
@@ -144,8 +144,9 @@ static Brush *uv_sculpt_brush(bContext *C)
Scene *scene = CTX_data_scene(C);
ToolSettings *settings = scene->toolsettings;
- if (!settings->uvsculpt)
+ if (!settings->uvsculpt) {
return NULL;
+ }
return BKE_paint_brush(&settings->uvsculpt->paint);
}
@@ -335,8 +336,9 @@ static void HC_relaxation_iteration_uv(BMEditMesh *em,
MLoopUV *luv;
BMLoop *l;
- if (element->separate && element != sculptdata->uv[i].element)
+ if (element->separate && element != sculptdata->uv[i].element) {
break;
+ }
l = element->l;
luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV);
@@ -408,8 +410,9 @@ static void laplacian_relaxation_iteration_uv(BMEditMesh *em,
MLoopUV *luv;
BMLoop *l;
- if (element->separate && element != sculptdata->uv[i].element)
+ if (element->separate && element != sculptdata->uv[i].element) {
break;
+ }
l = element->l;
luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV);
@@ -487,8 +490,9 @@ static void uv_sculpt_stroke_apply(bContext *C,
MLoopUV *luv;
BMLoop *l;
- if (element->separate && element != sculptdata->uv[i].element)
+ if (element->separate && element != sculptdata->uv[i].element) {
break;
+ }
l = element->l;
luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV);
@@ -532,8 +536,9 @@ static void uv_sculpt_stroke_apply(bContext *C,
MLoopUV *luv;
BMLoop *l;
- if (element->separate && element != sculptdata->uv[uvindex].element)
+ if (element->separate && element != sculptdata->uv[uvindex].element) {
break;
+ }
l = element->l;
luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV);
@@ -708,8 +713,9 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, const wm
if (element->separate) {
if (do_island_optimization && (element->island != island_index)) {
/* skip this uv if not on the active island */
- for (; element->next && !(element->next->separate); element = element->next)
+ for (; element->next && !(element->next->separate); element = element->next) {
;
+ }
continue;
}
@@ -737,8 +743,9 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, const wm
char *flag;
/* Skip edge if not found(unlikely) or not on valid island */
- if (itmp1 == -1 || itmp2 == -1)
+ if (itmp1 == -1 || itmp2 == -1) {
continue;
+ }
offset1 = uniqueUv[itmp1];
offset2 = uniqueUv[itmp2];
@@ -905,8 +912,9 @@ static int uv_sculpt_stroke_modal(bContext *C, wmOperator *op, const wmEvent *ev
uv_sculpt_stroke_apply(C, op, event, obedit);
break;
case TIMER:
- if (event->customdata == data->timer)
+ if (event->customdata == data->timer) {
uv_sculpt_stroke_apply(C, op, event, obedit);
+ }
break;
default:
return OPERATOR_RUNNING_MODAL;
diff --git a/source/blender/editors/sound/sound_ops.c b/source/blender/editors/sound/sound_ops.c
index 31dfe0bd30a..c2165e8ec70 100644
--- a/source/blender/editors/sound/sound_ops.c
+++ b/source/blender/editors/sound/sound_ops.c
@@ -94,12 +94,14 @@ static int sound_open_exec(bContext *C, wmOperator *op)
RNA_string_get(op->ptr, "filepath", path);
sound = BKE_sound_new_file(bmain, path);
- if (!op->customdata)
+ if (!op->customdata) {
sound_open_init(C, op);
+ }
if (sound->playback_handle == NULL) {
- if (op->customdata)
+ if (op->customdata) {
MEM_freeN(op->customdata);
+ }
BKE_id_free(bmain, sound);
BKE_report(op->reports, RPT_ERROR, "Unsupported audio format");
return OPERATOR_CANCELLED;
@@ -109,8 +111,9 @@ static int sound_open_exec(bContext *C, wmOperator *op)
if (info.specs.channels == AUD_CHANNELS_INVALID) {
BKE_id_free(bmain, sound);
- if (op->customdata)
+ if (op->customdata) {
MEM_freeN(op->customdata);
+ }
BKE_report(op->reports, RPT_ERROR, "Unsupported audio format");
return OPERATOR_CANCELLED;
}
@@ -154,8 +157,9 @@ static int sound_open_exec(bContext *UNUSED(C), wmOperator *op)
static int sound_open_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
- if (RNA_struct_property_is_set(op->ptr, "filepath"))
+ if (RNA_struct_property_is_set(op->ptr, "filepath")) {
return sound_open_exec(C, op);
+ }
sound_open_init(C, op);
@@ -227,22 +231,28 @@ static int sound_update_animation_flags_cb(Sequence *seq, void *user_data)
bool driven;
fcu = id_data_find_fcurve(&scene->id, seq, &RNA_Sequence, "volume", 0, &driven);
- if (fcu || driven)
+ if (fcu || driven) {
seq->flag |= SEQ_AUDIO_VOLUME_ANIMATED;
- else
+ }
+ else {
seq->flag &= ~SEQ_AUDIO_VOLUME_ANIMATED;
+ }
fcu = id_data_find_fcurve(&scene->id, seq, &RNA_Sequence, "pitch", 0, &driven);
- if (fcu || driven)
+ if (fcu || driven) {
seq->flag |= SEQ_AUDIO_PITCH_ANIMATED;
- else
+ }
+ else {
seq->flag &= ~SEQ_AUDIO_PITCH_ANIMATED;
+ }
fcu = id_data_find_fcurve(&scene->id, seq, &RNA_Sequence, "pan", 0, &driven);
- if (fcu || driven)
+ if (fcu || driven) {
seq->flag |= SEQ_AUDIO_PAN_ANIMATED;
- else
+ }
+ else {
seq->flag &= ~SEQ_AUDIO_PAN_ANIMATED;
+ }
if (seq->type == SEQ_TYPE_SCENE) {
/* TODO(sergey): For now we do manual recursion into the scene strips,
@@ -271,10 +281,12 @@ static void sound_update_animation_flags(Scene *scene)
SEQ_END;
fcu = id_data_find_fcurve(&scene->id, scene, &RNA_Scene, "audio_volume", 0, &driven);
- if (fcu || driven)
+ if (fcu || driven) {
scene->audio.flag |= AUDIO_VOLUME_ANIMATED;
- else
+ }
+ else {
scene->audio.flag &= ~AUDIO_VOLUME_ANIMATED;
+ }
}
static int sound_update_animation_flags_exec(bContext *C, wmOperator *UNUSED(op))
@@ -376,7 +388,7 @@ static int sound_mixdown_exec(bContext *C, wmOperator *op)
BLI_strncpy(filename, path, sizeof(filename));
BLI_path_abs(filename, BKE_main_blendfile_path(bmain));
- if (split)
+ if (split) {
result = AUD_mixdown_per_channel(scene->sound_scene,
SFRA * specs.rate / FPS,
(EFRA - SFRA + 1) * specs.rate / FPS,
@@ -386,7 +398,8 @@ static int sound_mixdown_exec(bContext *C, wmOperator *op)
container,
codec,
bitrate);
- else
+ }
+ else {
result = AUD_mixdown(scene->sound_scene,
SFRA * specs.rate / FPS,
(EFRA - SFRA + 1) * specs.rate / FPS,
@@ -396,6 +409,7 @@ static int sound_mixdown_exec(bContext *C, wmOperator *op)
container,
codec,
bitrate);
+ }
BKE_sound_reset_scene_specs(scene);
@@ -468,13 +482,16 @@ static bool sound_mixdown_check(bContext *UNUSED(C), wmOperator *op)
prop = RNA_struct_find_property(op->ptr, "filepath");
RNA_property_string_get(op->ptr, prop, filepath);
- if (BLI_path_extension_check_array(filepath, snd_ext_sound))
+ if (BLI_path_extension_check_array(filepath, snd_ext_sound)) {
check = BLI_path_extension_replace(filepath, FILE_MAX, extension);
- else
+ }
+ else {
check = BLI_path_extension_ensure(filepath, FILE_MAX, extension);
+ }
- if (!check)
+ if (!check) {
return check;
+ }
RNA_property_string_set(op->ptr, prop, filepath);
return true;
@@ -487,8 +504,9 @@ static bool sound_mixdown_check(bContext *UNUSED(C), wmOperator *op)
static int sound_mixdown_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
- if (RNA_struct_property_is_set(op->ptr, "filepath"))
+ if (RNA_struct_property_is_set(op->ptr, "filepath")) {
return sound_mixdown_exec(C, op);
+ }
return WM_operator_filesel(C, op, event);
}
@@ -738,8 +756,9 @@ static bool sound_poll(bContext *C)
{
Editing *ed = CTX_data_scene(C)->ed;
- if (!ed || !ed->act_seq || ed->act_seq->type != SEQ_TYPE_SOUND_RAM)
+ if (!ed || !ed->act_seq || ed->act_seq->type != SEQ_TYPE_SOUND_RAM) {
return 0;
+ }
return 1;
}
@@ -751,13 +770,15 @@ static int sound_pack_exec(bContext *C, wmOperator *op)
Editing *ed = CTX_data_scene(C)->ed;
bSound *sound;
- if (!ed || !ed->act_seq || ed->act_seq->type != SEQ_TYPE_SOUND_RAM)
+ if (!ed || !ed->act_seq || ed->act_seq->type != SEQ_TYPE_SOUND_RAM) {
return OPERATOR_CANCELLED;
+ }
sound = ed->act_seq->sound;
- if (!sound || sound->packedfile)
+ if (!sound || sound->packedfile) {
return OPERATOR_CANCELLED;
+ }
sound->packedfile = newPackedFile(op->reports, sound->name, ID_BLEND_PATH(bmain, &sound->id));
BKE_sound_load(bmain, sound);
@@ -795,13 +816,15 @@ static int sound_unpack_exec(bContext *C, wmOperator *op)
sound = BLI_findstring(&bmain->sounds, sndname, offsetof(ID, name) + 2);
}
- if (!sound || !sound->packedfile)
+ if (!sound || !sound->packedfile) {
return OPERATOR_CANCELLED;
+ }
- if (G.fileflags & G_FILE_AUTOPACK)
+ if (G.fileflags & G_FILE_AUTOPACK) {
BKE_report(op->reports,
RPT_WARNING,
"AutoPack is enabled, so image will be packed again on file save");
+ }
unpackSound(bmain, op->reports, sound, method);
@@ -813,21 +836,25 @@ static int sound_unpack_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSE
Editing *ed = CTX_data_scene(C)->ed;
bSound *sound;
- if (RNA_struct_property_is_set(op->ptr, "id"))
+ if (RNA_struct_property_is_set(op->ptr, "id")) {
return sound_unpack_exec(C, op);
+ }
- if (!ed || !ed->act_seq || ed->act_seq->type != SEQ_TYPE_SOUND_RAM)
+ if (!ed || !ed->act_seq || ed->act_seq->type != SEQ_TYPE_SOUND_RAM) {
return OPERATOR_CANCELLED;
+ }
sound = ed->act_seq->sound;
- if (!sound || !sound->packedfile)
+ if (!sound || !sound->packedfile) {
return OPERATOR_CANCELLED;
+ }
- if (G.fileflags & G_FILE_AUTOPACK)
+ if (G.fileflags & G_FILE_AUTOPACK) {
BKE_report(op->reports,
RPT_WARNING,
"AutoPack is enabled, so image will be packed again on file save");
+ }
unpack_menu(C, "SOUND_OT_unpack", sound->id.name + 2, sound->name, "sounds", sound->packedfile);
diff --git a/source/blender/editors/space_action/action_data.c b/source/blender/editors/space_action/action_data.c
index da48a7a9fa1..db504272d2f 100644
--- a/source/blender/editors/space_action/action_data.c
+++ b/source/blender/editors/space_action/action_data.c
@@ -127,10 +127,12 @@ static bAction *action_create_new(bContext *C, bAction *oldact)
if (sa->spacetype == SPACE_ACTION) {
SpaceAction *saction = (SpaceAction *)sa->spacedata.first;
- if (saction->mode == SACTCONT_SHAPEKEY)
+ if (saction->mode == SACTCONT_SHAPEKEY) {
action->idroot = ID_KE;
- else
+ }
+ else {
action->idroot = ID_OB;
+ }
}
return action;
@@ -180,15 +182,17 @@ static bool action_new_poll(bContext *C)
if (saction->mode == SACTCONT_ACTION) {
/* XXX: This assumes that actions are assigned to the active object in this mode */
if (ob) {
- if ((ob->adt == NULL) || (ob->adt->flag & ADT_NLA_EDIT_ON) == 0)
+ if ((ob->adt == NULL) || (ob->adt->flag & ADT_NLA_EDIT_ON) == 0) {
return true;
+ }
}
}
else if (saction->mode == SACTCONT_SHAPEKEY) {
Key *key = BKE_key_from_object(ob);
if (key) {
- if ((key->adt == NULL) || (key->adt->flag & ADT_NLA_EDIT_ON) == 0)
+ if ((key->adt == NULL) || (key->adt->flag & ADT_NLA_EDIT_ON) == 0) {
return true;
+ }
}
}
}
@@ -300,8 +304,9 @@ static bool action_pushdown_poll(bContext *C)
/* NOTE: We check this for the AnimData block in question and not the global flag,
* as the global flag may be left dirty by some of the browsing ops here.
*/
- if (!(adt->flag & ADT_NLA_EDIT_ON))
+ if (!(adt->flag & ADT_NLA_EDIT_ON)) {
return true;
+ }
}
}
@@ -432,8 +437,9 @@ static bool action_stash_create_poll(bContext *C)
/* NOTE: unlike for pushdown,
* this operator needs to be run when creating an action from nothing... */
if (adt) {
- if (!(adt->flag & ADT_NLA_EDIT_ON))
+ if (!(adt->flag & ADT_NLA_EDIT_ON)) {
return true;
+ }
}
else {
/* There may not be any action/animdata yet, so, just fallback to the global setting
@@ -628,8 +634,9 @@ static bool action_unlink_poll(bContext *C)
AnimData *adt = ED_actedit_animdata_from_context(C);
/* Only when there's an active action, in the right modes... */
- if (saction->action && adt)
+ if (saction->action && adt) {
return true;
+ }
}
/* something failed... */
diff --git a/source/blender/editors/space_action/action_draw.c b/source/blender/editors/space_action/action_draw.c
index a517aa3573c..9827967f947 100644
--- a/source/blender/editors/space_action/action_draw.c
+++ b/source/blender/editors/space_action/action_draw.c
@@ -210,8 +210,9 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
/* determine if any need to draw channel */
if (ale->datatype != ALE_NONE) {
/* determine if channel is selected */
- if (acf->has_setting(ac, ale, ACHANNEL_SETTING_SELECT))
+ if (acf->has_setting(ac, ale, ACHANNEL_SETTING_SELECT)) {
sel = ANIM_channel_setting_get(ac, ale, ACHANNEL_SETTING_SELECT);
+ }
if (ELEM(ac->datatype, ANIMCONT_ACTION, ANIMCONT_DOPESHEET, ANIMCONT_SHAPEKEY)) {
switch (ale->type) {
@@ -407,8 +408,9 @@ void timeline_draw_cache(SpaceAction *saction, Object *ob, Scene *scene)
const float cache_draw_height = (4.0f * UI_DPI_FAC * U.pixelsize);
float yoffs = 0.f;
- if (!(saction->cache_display & TIME_CACHE_DISPLAY) || (!ob))
+ if (!(saction->cache_display & TIME_CACHE_DISPLAY) || (!ob)) {
return;
+ }
BKE_ptcache_ids_from_object(&pidlist, ob, scene, 0);
@@ -421,34 +423,41 @@ void timeline_draw_cache(SpaceAction *saction, Object *ob, Scene *scene)
switch (pid->type) {
case PTCACHE_TYPE_SOFTBODY:
- if (!(saction->cache_display & TIME_CACHE_SOFTBODY))
+ if (!(saction->cache_display & TIME_CACHE_SOFTBODY)) {
continue;
+ }
break;
case PTCACHE_TYPE_PARTICLES:
- if (!(saction->cache_display & TIME_CACHE_PARTICLES))
+ if (!(saction->cache_display & TIME_CACHE_PARTICLES)) {
continue;
+ }
break;
case PTCACHE_TYPE_CLOTH:
- if (!(saction->cache_display & TIME_CACHE_CLOTH))
+ if (!(saction->cache_display & TIME_CACHE_CLOTH)) {
continue;
+ }
break;
case PTCACHE_TYPE_SMOKE_DOMAIN:
case PTCACHE_TYPE_SMOKE_HIGHRES:
- if (!(saction->cache_display & TIME_CACHE_SMOKE))
+ if (!(saction->cache_display & TIME_CACHE_SMOKE)) {
continue;
+ }
break;
case PTCACHE_TYPE_DYNAMICPAINT:
- if (!(saction->cache_display & TIME_CACHE_DYNAMICPAINT))
+ if (!(saction->cache_display & TIME_CACHE_DYNAMICPAINT)) {
continue;
+ }
break;
case PTCACHE_TYPE_RIGIDBODY:
- if (!(saction->cache_display & TIME_CACHE_RIGIDBODY))
+ if (!(saction->cache_display & TIME_CACHE_RIGIDBODY)) {
continue;
+ }
break;
}
- if (pid->cache->cached_frames == NULL)
+ if (pid->cache->cached_frames == NULL) {
continue;
+ }
GPU_matrix_push();
GPU_matrix_translate_2f(0.0, (float)V2D_SCROLL_HEIGHT_TEXT + yoffs);
diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c
index e504a4ef9c0..93beb3e851e 100644
--- a/source/blender/editors/space_action/action_edit.c
+++ b/source/blender/editors/space_action/action_edit.c
@@ -86,18 +86,22 @@ static bool act_markers_make_local_poll(bContext *C)
SpaceAction *sact = CTX_wm_space_action(C);
/* 1) */
- if (sact == NULL)
+ if (sact == NULL) {
return 0;
+ }
/* 2) */
- if (ELEM(sact->mode, SACTCONT_ACTION, SACTCONT_SHAPEKEY) == 0)
+ if (ELEM(sact->mode, SACTCONT_ACTION, SACTCONT_SHAPEKEY) == 0) {
return 0;
- if (sact->action == NULL)
+ }
+ if (sact->action == NULL) {
return 0;
+ }
/* 3) */
- if (sact->flag & SACTION_POSEMARKERS_SHOW)
+ if (sact->flag & SACTION_POSEMARKERS_SHOW) {
return 0;
+ }
/* 4) */
return ED_markers_get_first_selected(ED_context_get_markers(C)) != NULL;
@@ -113,8 +117,9 @@ static int act_markers_make_local_exec(bContext *C, wmOperator *UNUSED(op))
TimeMarker *marker, *markern = NULL;
/* sanity checks */
- if (ELEM(NULL, markers, act))
+ if (ELEM(NULL, markers, act)) {
return OPERATOR_CANCELLED;
+ }
/* migrate markers */
for (marker = markers->first; marker; marker = markern) {
@@ -260,12 +265,15 @@ static int actkeys_previewrange_exec(bContext *C, wmOperator *UNUSED(op))
float min, max;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
- if (ac.scene == NULL)
+ }
+ if (ac.scene == NULL) {
return OPERATOR_CANCELLED;
- else
+ }
+ else {
scene = ac.scene;
+ }
/* set the range directly */
get_keyframe_extents(&ac, &min, &max, false);
@@ -364,15 +372,17 @@ static int actkeys_viewall(bContext *C, const bool only_sel)
bool found;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
v2d = &ac.ar->v2d;
/* set the horizontal range, with an extra offset so that the extreme keys will be in view */
found = get_keyframe_extents(&ac, &min, &max, only_sel);
- if (only_sel && (found == false))
+ if (only_sel && (found == false)) {
return OPERATOR_CANCELLED;
+ }
if (fabsf(max - min) < 1.0f) {
/* Exception - center the single keyfrme */
@@ -558,8 +568,9 @@ static int actkeys_copy_exec(bContext *C, wmOperator *op)
bAnimContext ac;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* copy keyframes */
if (ac.datatype == ANIMCONT_GPENCIL) {
@@ -607,8 +618,9 @@ static int actkeys_paste_exec(bContext *C, wmOperator *op)
const bool flipped = RNA_boolean_get(op->ptr, "flipped");
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* ac.reports by default will be the global reports list, which won't show warnings */
ac.reports = op->reports;
@@ -745,8 +757,9 @@ static void insert_action_keys(bAnimContext *ac, short mode)
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
/* adjust current frame for NLA-scaling */
- if (adt)
+ if (adt) {
cfra = BKE_nla_tweakedit_remap(adt, (float)CFRA, NLATIME_CONVERT_UNMAP);
+ }
const float curval = evaluate_fcurve(fcu, cfra);
insert_vert_fcurve(fcu, cfra, curval, ts->keyframe_type, 0);
@@ -775,16 +788,19 @@ static void insert_gpencil_keys(bAnimContext *ac, short mode)
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT |
ANIMFILTER_NODUPLIS);
- if (mode == 2)
+ if (mode == 2) {
filter |= ANIMFILTER_SEL;
+ }
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
/* add a copy or a blank frame? */
- if (ts->gpencil_flags & GP_TOOL_FLAG_RETAIN_LAST)
+ if (ts->gpencil_flags & GP_TOOL_FLAG_RETAIN_LAST) {
add_frame_mode = GP_GETFRAME_ADD_COPY; /* XXX: actframe may not be what we want? */
- else
+ }
+ else {
add_frame_mode = GP_GETFRAME_ADD_NEW;
+ }
/* insert gp frames */
for (ale = anim_data.first; ale; ale = ale->next) {
@@ -804,8 +820,9 @@ static int actkeys_insertkey_exec(bContext *C, wmOperator *op)
short mode;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
if (ac.datatype == ANIMCONT_MASK) {
BKE_report(op->reports, RPT_ERROR, "Insert Keyframes is not yet implemented for this mode");
@@ -869,14 +886,18 @@ static void duplicate_action_keys(bAnimContext *ac)
/* loop through filtered data and delete selected keys */
for (ale = anim_data.first; ale; ale = ale->next) {
- if (ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE))
+ if (ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE)) {
duplicate_fcurve_keys((FCurve *)ale->key_data);
- else if (ale->type == ANIMTYPE_GPLAYER)
+ }
+ else if (ale->type == ANIMTYPE_GPLAYER) {
ED_gplayer_frames_duplicate((bGPDlayer *)ale->data);
- else if (ale->type == ANIMTYPE_MASKLAYER)
+ }
+ else if (ale->type == ANIMTYPE_MASKLAYER) {
ED_masklayer_frames_duplicate((MaskLayer *)ale->data);
- else
+ }
+ else {
BLI_assert(0);
+ }
ale->update |= ANIM_UPDATE_DEFAULT;
}
@@ -892,8 +913,9 @@ static int actkeys_duplicate_exec(bContext *C, wmOperator *UNUSED(op))
bAnimContext ac;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* duplicate keyframes */
duplicate_action_keys(&ac);
@@ -983,12 +1005,14 @@ static int actkeys_delete_exec(bContext *C, wmOperator *UNUSED(op))
bAnimContext ac;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* delete keyframes */
- if (!delete_action_keys(&ac))
+ if (!delete_action_keys(&ac)) {
return OPERATOR_CANCELLED;
+ }
/* set notifier that keyframes have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_REMOVED, NULL);
@@ -1045,8 +1069,9 @@ static int actkeys_clean_exec(bContext *C, wmOperator *op)
bool clean_chan;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
if (ELEM(ac.datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) {
BKE_report(op->reports, RPT_ERROR, "Not implemented");
@@ -1119,8 +1144,9 @@ static int actkeys_sample_exec(bContext *C, wmOperator *op)
bAnimContext ac;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
if (ELEM(ac.datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) {
BKE_report(op->reports, RPT_ERROR, "Not implemented");
@@ -1224,8 +1250,9 @@ static void setexpo_action_keys(bAnimContext *ac, short mode)
for (fcm = fcu->modifiers.first; fcm; fcm = fcn) {
fcn = fcm->next;
- if (fcm->type == FMODIFIER_TYPE_CYCLES)
+ if (fcm->type == FMODIFIER_TYPE_CYCLES) {
remove_fmodifier(&fcu->modifiers, fcm);
+ }
}
}
}
@@ -1245,8 +1272,9 @@ static int actkeys_expo_exec(bContext *C, wmOperator *op)
short mode;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
if (ELEM(ac.datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) {
BKE_report(op->reports, RPT_ERROR, "Not implemented");
@@ -1321,8 +1349,9 @@ static int actkeys_ipo_exec(bContext *C, wmOperator *op)
short mode;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
if (ELEM(ac.datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) {
BKE_report(op->reports, RPT_ERROR, "Not implemented");
@@ -1407,8 +1436,9 @@ static int actkeys_handletype_exec(bContext *C, wmOperator *op)
short mode;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
if (ELEM(ac.datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) {
BKE_report(op->reports, RPT_ERROR, "Not implemented");
@@ -1507,8 +1537,9 @@ static int actkeys_keytype_exec(bContext *C, wmOperator *op)
short mode;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
if (ac.datatype == ANIMCONT_MASK) {
BKE_report(op->reports, RPT_ERROR, "Not implemented for Masks");
@@ -1559,8 +1590,9 @@ void ACTION_OT_keyframe_type(wmOperatorType *ot)
static bool actkeys_framejump_poll(bContext *C)
{
/* prevent changes during render */
- if (G.is_rendering)
+ if (G.is_rendering) {
return 0;
+ }
return ED_operator_action_active(C);
}
@@ -1575,8 +1607,9 @@ static int actkeys_framejump_exec(bContext *C, wmOperator *UNUSED(op))
KeyframeEditData ked = {{NULL}};
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* init edit data */
/* loop over action data, averaging values */
@@ -1591,8 +1624,9 @@ static int actkeys_framejump_exec(bContext *C, wmOperator *UNUSED(op))
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, bezt_calc_average, NULL);
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1);
}
- else
+ else {
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, bezt_calc_average, NULL);
+ }
}
ANIM_animdata_freelist(&anim_data);
@@ -1716,8 +1750,9 @@ static int actkeys_snap_exec(bContext *C, wmOperator *op)
short mode;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get snapping mode */
mode = RNA_enum_get(op->ptr, "type");
@@ -1792,10 +1827,12 @@ static void mirror_action_keys(bAnimContext *ac, short mode)
if (mode == ACTKEYS_MIRROR_MARKER) {
TimeMarker *marker = ED_markers_get_first_selected(ac->markers);
- if (marker)
+ if (marker) {
ked.f1 = (float)marker->frame;
- else
+ }
+ else {
return;
+ }
}
/* filter data */
@@ -1843,8 +1880,9 @@ static int actkeys_mirror_exec(bContext *C, wmOperator *op)
short mode;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get mirroring mode */
mode = RNA_enum_get(op->ptr, "type");
diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c
index 8afc9a43f6a..fb35afb6770 100644
--- a/source/blender/editors/space_action/action_select.c
+++ b/source/blender/editors/space_action/action_select.c
@@ -155,8 +155,9 @@ static int actkeys_deselectall_exec(bContext *C, wmOperator *op)
bAnimContext ac;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* 'standard' behavior - check if selected, then apply relevant selection */
const int action = RNA_enum_get(op->ptr, "action");
@@ -243,10 +244,12 @@ static void box_select_action(bAnimContext *ac, const rcti rect, short mode, sho
/* get beztriple editing/validation funcs */
select_cb = ANIM_editkeyframes_select(selectmode);
- if (ELEM(mode, ACTKEYS_BORDERSEL_FRAMERANGE, ACTKEYS_BORDERSEL_ALLKEYS))
+ if (ELEM(mode, ACTKEYS_BORDERSEL_FRAMERANGE, ACTKEYS_BORDERSEL_ALLKEYS)) {
ok_cb = ANIM_editkeyframes_ok(BEZT_OK_FRAMERANGE);
- else
+ }
+ else {
ok_cb = NULL;
+ }
/* init editing data */
memset(&ked, 0, sizeof(KeyframeEditData));
@@ -352,13 +355,16 @@ static int actkeys_box_select_exec(bContext *C, wmOperator *op)
* as frame-range one is often used for tweaking timing when "blocking",
* while channels is not that useful...
*/
- if (BLI_rcti_size_x(&rect) >= BLI_rcti_size_y(&rect))
+ if (BLI_rcti_size_x(&rect) >= BLI_rcti_size_y(&rect)) {
mode = ACTKEYS_BORDERSEL_FRAMERANGE;
- else
+ }
+ else {
mode = ACTKEYS_BORDERSEL_CHANNELS;
+ }
}
- else
+ else {
mode = ACTKEYS_BORDERSEL_ALLKEYS;
+ }
/* apply box_select action */
box_select_action(&ac, rect, mode, selectmode);
@@ -535,13 +541,15 @@ static int actkeys_lassoselect_exec(bContext *C, wmOperator *op)
rctf rect_fl;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
data_lasso.rectf_view = &rect_fl;
data_lasso.mcords = WM_gesture_lasso_path_to_array(C, op, &data_lasso.mcords_tot);
- if (data_lasso.mcords == NULL)
+ if (data_lasso.mcords == NULL) {
return OPERATOR_CANCELLED;
+ }
const eSelectOp sel_op = RNA_enum_get(op->ptr, "mode");
const int selectmode = (sel_op != SEL_OP_SUB) ? SELECT_ADD : SELECT_SUBTRACT;
@@ -600,8 +608,9 @@ static int action_circle_select_exec(bContext *C, wmOperator *op)
float radius = RNA_int_get(op->ptr, "radius");
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
const eSelectOp sel_op = ED_select_op_modal(RNA_enum_get(op->ptr, "mode"),
WM_gesture_is_modal_first(op->customdata));
@@ -747,15 +756,17 @@ static void columnselect_action_keys(bAnimContext *ac, short mode)
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
- for (ale = anim_data.first; ale; ale = ale->next)
+ for (ale = anim_data.first; ale; ale = ale->next) {
ED_gplayer_make_cfra_list(ale->data, &ked.list, 1);
+ }
}
else {
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY*/);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
- for (ale = anim_data.first; ale; ale = ale->next)
+ for (ale = anim_data.first; ale; ale = ale->next) {
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, bezt_to_cfraelem, NULL);
+ }
}
ANIM_animdata_freelist(&anim_data);
break;
@@ -783,10 +794,12 @@ static void columnselect_action_keys(bAnimContext *ac, short mode)
/* loop through all of the keys and select additional keyframes
* based on the keys found to be selected above
*/
- if (ELEM(ac->datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK))
+ if (ELEM(ac->datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) {
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE);
- else
+ }
+ else {
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY*/);
+ }
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
for (ale = anim_data.first; ale; ale = ale->next) {
@@ -797,10 +810,12 @@ static void columnselect_action_keys(bAnimContext *ac, short mode)
*/
for (ce = ked.list.first; ce; ce = ce->next) {
/* set frame for validation callback to refer to */
- if (adt)
+ if (adt) {
ked.f1 = BKE_nla_tweakedit_remap(adt, ce->cfra, NLATIME_CONVERT_UNMAP);
- else
+ }
+ else {
ked.f1 = ce->cfra;
+ }
/* select elements with frame number matching cfraelem */
if (ale->type == ANIMTYPE_GPLAYER) {
@@ -831,16 +846,19 @@ static int actkeys_columnselect_exec(bContext *C, wmOperator *op)
short mode;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* action to take depends on the mode */
mode = RNA_enum_get(op->ptr, "mode");
- if (mode == ACTKEYS_COLUMNSEL_MARKERS_BETWEEN)
+ if (mode == ACTKEYS_COLUMNSEL_MARKERS_BETWEEN) {
markers_selectkeys_between(&ac);
- else
+ }
+ else {
columnselect_action_keys(&ac, mode);
+ }
/* set notifier that keyframe selection have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL);
@@ -880,8 +898,9 @@ static int actkeys_select_linked_exec(bContext *C, wmOperator *UNUSED(op))
KeyframeEditFunc sel_cb = ANIM_editkeyframes_select(SELECT_ADD);
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* loop through all of the keys and select additional keyframes based on these */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY*/ |
@@ -946,8 +965,9 @@ static void select_moreless_action_keys(bAnimContext *ac, short mode)
FCurve *fcu = (FCurve *)ale->key_data;
/* only continue if F-Curve has keyframes */
- if (fcu->bezt == NULL)
+ if (fcu->bezt == NULL) {
continue;
+ }
/* build up map of whether F-Curve's keyframes should be selected or not */
ked.data = MEM_callocN(fcu->totvert, "selmap actEdit more");
@@ -972,8 +992,9 @@ static int actkeys_select_more_exec(bContext *C, wmOperator *UNUSED(op))
bAnimContext ac;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* perform select changes */
select_moreless_action_keys(&ac, SELMAP_MORE);
@@ -1006,8 +1027,9 @@ static int actkeys_select_less_exec(bContext *C, wmOperator *UNUSED(op))
bAnimContext ac;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* perform select changes */
select_moreless_action_keys(&ac, SELMAP_LESS);
@@ -1144,18 +1166,22 @@ static int actkeys_select_leftright_exec(bContext *C, wmOperator *op)
short selectmode;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* select mode is either replace (deselect all, then add) or add/extend */
- if (RNA_boolean_get(op->ptr, "extend"))
+ if (RNA_boolean_get(op->ptr, "extend")) {
selectmode = SELECT_INVERT;
- else
+ }
+ else {
selectmode = SELECT_REPLACE;
+ }
/* if "test" mode is set, we don't have any info to set this with */
- if (leftright == ACTKEYS_LRSEL_TEST)
+ if (leftright == ACTKEYS_LRSEL_TEST) {
return OPERATOR_CANCELLED;
+ }
/* do the selecting now */
actkeys_select_leftright(&ac, leftright, selectmode);
@@ -1173,8 +1199,9 @@ static int actkeys_select_leftright_invoke(bContext *C, wmOperator *op, const wm
short leftright = RNA_enum_get(op->ptr, "mode");
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* handle mode-based testing */
if (leftright == ACTKEYS_LRSEL_TEST) {
@@ -1185,10 +1212,12 @@ static int actkeys_select_leftright_invoke(bContext *C, wmOperator *op, const wm
/* determine which side of the current frame mouse is on */
x = UI_view2d_region_to_view_x(v2d, event->mval[0]);
- if (x < CFRA)
+ if (x < CFRA) {
RNA_enum_set(op->ptr, "mode", ACTKEYS_LRSEL_LEFT);
- else
+ }
+ else {
RNA_enum_set(op->ptr, "mode", ACTKEYS_LRSEL_RIGHT);
+ }
}
/* perform selection */
@@ -1320,10 +1349,12 @@ static void actkeys_mselect_column(bAnimContext *ac, short select_mode, float se
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
/* set frame for validation callback to refer to */
- if (adt)
+ if (adt) {
ked.f1 = BKE_nla_tweakedit_remap(adt, selx, NLATIME_CONVERT_UNMAP);
- else
+ }
+ else {
ked.f1 = selx;
+ }
/* select elements with frame number matching cfra */
if (ale->type == ANIMTYPE_GPLAYER) {
@@ -1411,8 +1442,9 @@ static void mouse_action_keys(
rctf rectf;
/* get dopesheet info */
- if (ELEM(ac->datatype, ANIMCONT_DOPESHEET, ANIMCONT_TIMELINE))
+ if (ELEM(ac->datatype, ANIMCONT_DOPESHEET, ANIMCONT_TIMELINE)) {
ads = ac->data;
+ }
/* use View2D to determine the index of the channel (i.e a row in the list) where keyframe was */
UI_view2d_region_to_view(v2d, mval[0], mval[1], &x, &y);
@@ -1509,10 +1541,12 @@ static void mouse_action_keys(
found = true;
break;
}
- else if (ak->cfra < rectf.xmin)
+ else if (ak->cfra < rectf.xmin) {
akn = ak->right;
- else
+ }
+ else {
akn = ak->left;
+ }
}
/* Remove active channel from list of channels for separate treatment
@@ -1623,17 +1657,20 @@ static int actkeys_clickselect_invoke(bContext *C, wmOperator *op, const wmEvent
bool column, channel;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get useful pointers from animation context data */
/* ar = ac.ar; */ /* UNUSED */
/* select mode is either replace (deselect all, then add) or add/extend */
- if (RNA_boolean_get(op->ptr, "extend"))
+ if (RNA_boolean_get(op->ptr, "extend")) {
selectmode = SELECT_INVERT;
- else
+ }
+ else {
selectmode = SELECT_REPLACE;
+ }
/* column selection */
column = RNA_boolean_get(op->ptr, "column");
diff --git a/source/blender/editors/space_action/space_action.c b/source/blender/editors/space_action/space_action.c
index d9545e51318..d6d46904db3 100644
--- a/source/blender/editors/space_action/space_action.c
+++ b/source/blender/editors/space_action/space_action.c
@@ -215,8 +215,9 @@ static void action_main_region_draw(const bContext *C, ARegion *ar)
}
/* current frame */
- if (saction->flag & SACTION_DRAWTIME)
+ if (saction->flag & SACTION_DRAWTIME) {
cfra_flag |= DRAWCFRA_UNIT_SECONDS;
+ }
ANIM_draw_cfra(C, v2d, cfra_flag);
/* markers */
@@ -224,8 +225,9 @@ static void action_main_region_draw(const bContext *C, ARegion *ar)
marker_flag = ((ac.markers && (ac.markers != &ac.scene->markers)) ? DRAW_MARKERS_LOCAL : 0) |
DRAW_MARKERS_MARGIN;
- if (saction->flag & SACTION_SHOW_MARKER_LINES)
+ if (saction->flag & SACTION_SHOW_MARKER_LINES) {
marker_flag |= DRAW_MARKERS_LINES;
+ }
ED_markers_draw(C, marker_flag);
/* caches */
@@ -336,22 +338,26 @@ static void action_channel_region_listener(wmWindow *UNUSED(win),
ED_region_tag_redraw(ar);
break;
case ND_MODIFIER:
- if (wmn->action == NA_RENAME)
+ if (wmn->action == NA_RENAME) {
ED_region_tag_redraw(ar);
+ }
break;
}
break;
case NC_GPENCIL:
- if (ELEM(wmn->action, NA_RENAME, NA_SELECTED))
+ if (ELEM(wmn->action, NA_RENAME, NA_SELECTED)) {
ED_region_tag_redraw(ar);
+ }
break;
case NC_ID:
- if (wmn->action == NA_RENAME)
+ if (wmn->action == NA_RENAME) {
ED_region_tag_redraw(ar);
+ }
break;
default:
- if (wmn->data == ND_KEYS)
+ if (wmn->data == ND_KEYS) {
ED_region_tag_redraw(ar);
+ }
break;
}
}
@@ -443,8 +449,9 @@ static void action_main_region_listener(wmWindow *UNUSED(win),
}
break;
case NC_ID:
- if (wmn->action == NA_RENAME)
+ if (wmn->action == NA_RENAME) {
ED_region_tag_redraw(ar);
+ }
break;
case NC_SCREEN:
if (ELEM(wmn->data, ND_LAYER)) {
@@ -452,8 +459,9 @@ static void action_main_region_listener(wmWindow *UNUSED(win),
}
break;
default:
- if (wmn->data == ND_KEYS)
+ if (wmn->data == ND_KEYS) {
ED_region_tag_redraw(ar);
+ }
break;
}
}
@@ -661,8 +669,9 @@ static void action_header_region_listener(
switch (wmn->category) {
case NC_SCREEN:
if (saction->mode == SACTCONT_TIMELINE) {
- if (wmn->data == ND_ANIMPLAY)
+ if (wmn->data == ND_ANIMPLAY) {
ED_region_tag_redraw(ar);
+ }
}
break;
case NC_SCENE:
@@ -687,8 +696,9 @@ static void action_header_region_listener(
}
break;
case NC_ID:
- if (wmn->action == NA_RENAME)
+ if (wmn->action == NA_RENAME) {
ED_region_tag_redraw(ar);
+ }
break;
case NC_ANIMATION:
switch (wmn->data) {
@@ -754,8 +764,9 @@ static void action_region_listener(wmWindow *UNUSED(win),
}
break;
default:
- if (wmn->data == ND_KEYS)
+ if (wmn->data == ND_KEYS) {
ED_region_tag_redraw(ar);
+ }
break;
}
}
@@ -781,8 +792,9 @@ static void action_refresh(const bContext *C, ScrArea *sa)
* or else they don't update [#28962]
*/
ED_area_tag_redraw(sa);
- for (ar = sa->regionbase.first; ar; ar = ar->next)
+ for (ar = sa->regionbase.first; ar; ar = ar->next) {
ED_region_tag_redraw(ar);
+ }
}
/* region updates? */
diff --git a/source/blender/editors/space_api/spacetypes.c b/source/blender/editors/space_api/spacetypes.c
index 89758bd35da..95775f80b50 100644
--- a/source/blender/editors/space_api/spacetypes.c
+++ b/source/blender/editors/space_api/spacetypes.c
@@ -179,8 +179,9 @@ void ED_spacemacros_init(void)
/* register dropboxes (can use macros) */
spacetypes = BKE_spacetypes_list();
for (type = spacetypes->first; type; type = type->next) {
- if (type->dropboxes)
+ if (type->dropboxes) {
type->dropboxes();
+ }
}
}
@@ -216,11 +217,13 @@ void ED_spacetypes_keymap(wmKeyConfig *keyconf)
spacetypes = BKE_spacetypes_list();
for (stype = spacetypes->first; stype; stype = stype->next) {
- if (stype->keymap)
+ if (stype->keymap) {
stype->keymap(keyconf);
+ }
for (atype = stype->regiontypes.first; atype; atype = atype->next) {
- if (atype->keymap)
+ if (atype->keymap) {
atype->keymap(keyconf);
+ }
}
}
}
diff --git a/source/blender/editors/space_clip/clip_buttons.c b/source/blender/editors/space_clip/clip_buttons.c
index 6f950ec5bc4..c985d61a8b8 100644
--- a/source/blender/editors/space_clip/clip_buttons.c
+++ b/source/blender/editors/space_clip/clip_buttons.c
@@ -110,8 +110,9 @@ void uiTemplateMovieClip(
uiLayout *row, *split;
uiBlock *block;
- if (!ptr->data)
+ if (!ptr->data) {
return;
+ }
prop = RNA_struct_find_property(ptr, propname);
if (!prop) {
@@ -133,9 +134,10 @@ void uiTemplateMovieClip(
uiLayoutSetContextPointer(layout, "edit_movieclip", &clipptr);
- if (!compact)
+ if (!compact) {
uiTemplateID(
layout, C, ptr, propname, NULL, "CLIP_OT_open", NULL, UI_TEMPLATE_ID_FILTER_ALL, false);
+ }
if (clip) {
uiLayout *col;
@@ -166,8 +168,9 @@ void uiTemplateTrack(uiLayout *layout, PointerRNA *ptr, const char *propname)
uiLayout *col;
MovieClipScopes *scopes;
- if (!ptr->data)
+ if (!ptr->data) {
return;
+ }
prop = RNA_struct_find_property(ptr, propname);
if (!prop) {
@@ -274,8 +277,9 @@ static void marker_update_cb(bContext *C, void *arg_cb, void *UNUSED(arg))
MarkerUpdateCb *cb = (MarkerUpdateCb *)arg_cb;
MovieTrackingMarker *marker;
- if (!cb->compact)
+ if (!cb->compact) {
return;
+ }
marker = BKE_tracking_marker_ensure(cb->track, cb->framenr);
@@ -381,8 +385,9 @@ static void marker_block_handler(bContext *C, void *arg_cb, int event)
sub_v2_v2v2(delta, offset, cb->track->offset);
copy_v2_v2(cb->track->offset, offset);
- for (i = 0; i < cb->track->markersnr; i++)
+ for (i = 0; i < cb->track->markersnr; i++) {
sub_v2_v2(cb->track->markers[i].pos, delta);
+ }
/* to update position of "parented" objects */
DEG_id_tag_update(&cb->clip->id, 0);
@@ -391,8 +396,9 @@ static void marker_block_handler(bContext *C, void *arg_cb, int event)
ok = true;
}
- if (ok)
+ if (ok) {
WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, cb->clip);
+ }
}
void uiTemplateMarker(uiLayout *layout,
@@ -414,8 +420,9 @@ void uiTemplateMarker(uiLayout *layout,
const char *tip;
float pat_min[2], pat_max[2];
- if (!ptr->data)
+ if (!ptr->data) {
return;
+ }
prop = RNA_struct_find_property(ptr, propname);
if (!prop) {
@@ -451,10 +458,12 @@ void uiTemplateMarker(uiLayout *layout,
if (compact) {
block = uiLayoutGetBlock(layout);
- if (cb->marker_flag & MARKER_DISABLED)
+ if (cb->marker_flag & MARKER_DISABLED) {
tip = TIP_("Marker is disabled at current frame");
- else
+ }
+ else {
tip = TIP_("Marker is enabled at current frame");
+ }
bt = uiDefIconButBitI(block,
UI_BTYPE_TOGGLE_N,
@@ -525,10 +534,12 @@ void uiTemplateMarker(uiLayout *layout,
UI_block_func_handle_set(block, marker_block_handler, cb);
UI_block_funcN_set(block, marker_update_cb, cb, NULL);
- if (cb->marker_flag & MARKER_DISABLED)
+ if (cb->marker_flag & MARKER_DISABLED) {
tip = TIP_("Marker is disabled at current frame");
- else
+ }
+ else {
tip = TIP_("Marker is enabled at current frame");
+ }
uiDefButBitI(block,
UI_BTYPE_CHECKBOX_N,
@@ -773,8 +784,9 @@ void uiTemplateMovieclipInformation(uiLayout *layout,
ImBuf *ibuf;
size_t ofs = 0;
- if (!ptr->data)
+ if (!ptr->data) {
return;
+ }
prop = RNA_struct_find_property(ptr, propname);
if (!prop) {
@@ -805,19 +817,24 @@ void uiTemplateMovieclipInformation(uiLayout *layout,
if (ibuf) {
if (ibuf->rect_float) {
- if (ibuf->channels != 4)
+ if (ibuf->channels != 4) {
ofs += BLI_snprintf(
str + ofs, sizeof(str) - ofs, IFACE_(", %d float channel(s)"), ibuf->channels);
- else if (ibuf->planes == R_IMF_PLANES_RGBA)
+ }
+ else if (ibuf->planes == R_IMF_PLANES_RGBA) {
ofs += BLI_strncpy_rlen(str + ofs, IFACE_(", RGBA float"), sizeof(str) - ofs);
- else
+ }
+ else {
ofs += BLI_strncpy_rlen(str + ofs, IFACE_(", RGB float"), sizeof(str) - ofs);
+ }
}
else {
- if (ibuf->planes == R_IMF_PLANES_RGBA)
+ if (ibuf->planes == R_IMF_PLANES_RGBA) {
ofs += BLI_strncpy_rlen(str + ofs, IFACE_(", RGBA byte"), sizeof(str) - ofs);
- else
+ }
+ else {
ofs += BLI_strncpy_rlen(str + ofs, IFACE_(", RGB byte"), sizeof(str) - ofs);
+ }
}
if (clip->anim != NULL) {
@@ -837,10 +854,12 @@ void uiTemplateMovieclipInformation(uiLayout *layout,
/* Display current frame number. */
framenr = BKE_movieclip_remap_scene_to_clip_frame(clip, user->framenr);
- if (framenr <= clip->len)
+ if (framenr <= clip->len) {
BLI_snprintf(str, sizeof(str), IFACE_("Frame: %d / %d"), framenr, clip->len);
- else
+ }
+ else {
BLI_snprintf(str, sizeof(str), IFACE_("Frame: - / %d"), clip->len);
+ }
uiItemL(col, str, ICON_NONE);
/* Display current file name if it's a sequence clip. */
diff --git a/source/blender/editors/space_clip/clip_dopesheet_draw.c b/source/blender/editors/space_clip/clip_dopesheet_draw.c
index 8ac0870f7f1..0f6e7947482 100644
--- a/source/blender/editors/space_clip/clip_dopesheet_draw.c
+++ b/source/blender/editors/space_clip/clip_dopesheet_draw.c
@@ -59,10 +59,12 @@ static void track_channel_color(MovieTrackingTrack *track, float default_color[3
interp_v3_v3v3(color, track->color, bg, 0.5);
}
else {
- if (default_color)
+ if (default_color) {
copy_v3_v3(color, default_color);
- else
+ }
+ else {
UI_GetThemeColor3fv(TH_HEADER, color);
+ }
}
}
@@ -297,8 +299,9 @@ void clip_draw_dopesheet_channels(const bContext *C, ARegion *ar)
uiStyle *style = UI_style_get();
int fontid = style->widget.uifont_id;
- if (!clip)
+ if (!clip) {
return;
+ }
MovieTracking *tracking = &clip->tracking;
MovieTrackingDopesheet *dopesheet = &tracking->dopesheet;
diff --git a/source/blender/editors/space_clip/clip_dopesheet_ops.c b/source/blender/editors/space_clip/clip_dopesheet_ops.c
index e7f0f8c3fcc..785ced96b13 100644
--- a/source/blender/editors/space_clip/clip_dopesheet_ops.c
+++ b/source/blender/editors/space_clip/clip_dopesheet_ops.c
@@ -66,8 +66,9 @@ static bool dopesheet_select_channel_poll(bContext *C)
{
SpaceClip *sc = CTX_wm_space_clip(C);
- if (sc && sc->clip)
+ if (sc && sc->clip) {
return sc->view == SC_VIEW_DOPESHEET;
+ }
return false;
}
@@ -93,10 +94,12 @@ static int dopesheet_select_channel_exec(bContext *C, wmOperator *op)
MovieTrackingTrack *track = channel->track;
if (current_channel_index == channel_index) {
- if (extend)
+ if (extend) {
track->flag ^= TRACK_DOPE_SEL;
- else
+ }
+ else {
track->flag |= TRACK_DOPE_SEL;
+ }
if (track->flag & TRACK_DOPE_SEL) {
tracking->act_track = track;
@@ -106,8 +109,9 @@ static int dopesheet_select_channel_exec(bContext *C, wmOperator *op)
BKE_tracking_track_deselect(track, TRACK_AREA_ALL);
}
}
- else if (!extend)
+ else if (!extend) {
track->flag &= ~TRACK_DOPE_SEL;
+ }
current_channel_index++;
}
diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c
index dbc37fc6727..99f9a91775e 100644
--- a/source/blender/editors/space_clip/clip_draw.c
+++ b/source/blender/editors/space_clip/clip_draw.c
@@ -178,12 +178,14 @@ static void draw_movieclip_cache(SpaceClip *sc, ARegion *ar, MovieClip *clip, Sc
while (a < markersnr) {
int marker_framenr = generic_track_get_marker_framenr(act_track, act_plane_track, a);
- if (marker_framenr >= i)
+ if (marker_framenr >= i) {
break;
+ }
if (a < markersnr - 1 &&
- generic_track_get_marker_framenr(act_track, act_plane_track, a + 1) > i)
+ generic_track_get_marker_framenr(act_track, act_plane_track, a + 1) > i) {
break;
+ }
a++;
}
@@ -284,8 +286,9 @@ static void draw_movieclip_notes(SpaceClip *sc, ARegion *ar)
full_redraw = true;
}
else {
- if (sc->flag & SC_LOCK_SELECTION)
+ if (sc->flag & SC_LOCK_SELECTION) {
strcpy(str, "Locked");
+ }
}
if (str[0]) {
@@ -411,14 +414,16 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin
int tiny = sc->flag & SC_SHOW_TINY_MARKER, framenr, start_frame;
MovieTrackingMarker *marker;
- if (count == 0)
+ if (count == 0) {
return;
+ }
start_frame = framenr = ED_space_clip_get_clip_frame_number(sc);
marker = BKE_tracking_marker_get(track, framenr);
- if (marker->framenr != framenr || marker->flag & MARKER_DISABLED)
+ if (marker->framenr != framenr || marker->flag & MARKER_DISABLED) {
return;
+ }
if (count < MAX_STATIC_PATH) {
path = path_static;
@@ -432,15 +437,17 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin
while (i >= framenr - count) {
marker = BKE_tracking_marker_get(track, i);
- if (!marker || marker->flag & MARKER_DISABLED)
+ if (!marker || marker->flag & MARKER_DISABLED) {
break;
+ }
if (marker->framenr == i) {
add_v2_v2v2(path[--a], marker->pos, track->offset);
ED_clip_point_undistorted_pos(sc, path[a], path[a]);
- if (marker->framenr == start_frame)
+ if (marker->framenr == start_frame) {
curindex = a;
+ }
}
else {
break;
@@ -454,18 +461,21 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin
while (i <= framenr + count) {
marker = BKE_tracking_marker_get(track, i);
- if (!marker || marker->flag & MARKER_DISABLED)
+ if (!marker || marker->flag & MARKER_DISABLED) {
break;
+ }
if (marker->framenr == i) {
- if (marker->framenr == start_frame)
+ if (marker->framenr == start_frame) {
curindex = b;
+ }
add_v2_v2v2(path[b++], marker->pos, track->offset);
ED_clip_point_undistorted_pos(sc, path[b - 1], path[b - 1]);
}
- else
+ else {
break;
+ }
i++;
}
@@ -658,20 +668,24 @@ static void draw_marker_outline(SpaceClip *sc,
static void track_colors(MovieTrackingTrack *track, int act, float col[3], float scol[3])
{
if (track->flag & TRACK_CUSTOMCOLOR) {
- if (act)
+ if (act) {
UI_GetThemeColor3fv(TH_ACT_MARKER, scol);
- else
+ }
+ else {
copy_v3_v3(scol, track->color);
+ }
mul_v3_v3fl(col, track->color, 0.5f);
}
else {
UI_GetThemeColor3fv(TH_MARKER, col);
- if (act)
+ if (act) {
UI_GetThemeColor3fv(TH_ACT_MARKER, scol);
- else
+ }
+ else {
UI_GetThemeColor3fv(TH_SEL_MARKER, scol);
+ }
}
}
@@ -923,11 +937,13 @@ static void draw_marker_slide_zones(SpaceClip *sc,
int tiny = sc->flag & SC_SHOW_TINY_MARKER;
float col[3], scol[3], px[2], side;
- if ((tiny && outline) || (marker->flag & MARKER_DISABLED))
+ if ((tiny && outline) || (marker->flag & MARKER_DISABLED)) {
return;
+ }
- if (!TRACK_VIEW_SELECTED(sc, track) || track->flag & TRACK_LOCKED)
+ if (!TRACK_VIEW_SELECTED(sc, track) || track->flag & TRACK_LOCKED) {
return;
+ }
track_colors(track, act, col, scol);
@@ -1020,8 +1036,9 @@ static void draw_marker_texts(SpaceClip *sc,
uiStyle *style = U.uistyles.first;
int fontid = style->widget.uifont_id;
- if (!TRACK_VIEW_SELECTED(sc, track))
+ if (!TRACK_VIEW_SELECTED(sc, track)) {
return;
+ }
BLF_size(fontid, 11.0f * U.pixelsize, U.dpi);
fontsize = BLF_height_max(fontid);
@@ -1062,19 +1079,25 @@ static void draw_marker_texts(SpaceClip *sc,
pos[0] = pos[0] * zoomx;
pos[1] = pos[1] * zoomy - fontsize;
- if (marker->flag & MARKER_DISABLED)
+ if (marker->flag & MARKER_DISABLED) {
strcpy(state, "disabled");
- else if (marker->framenr != ED_space_clip_get_clip_frame_number(sc))
+ }
+ else if (marker->framenr != ED_space_clip_get_clip_frame_number(sc)) {
strcpy(state, "estimated");
- else if (marker->flag & MARKER_TRACKED)
+ }
+ else if (marker->flag & MARKER_TRACKED) {
strcpy(state, "tracked");
- else
+ }
+ else {
strcpy(state, "keyframed");
+ }
- if (state[0])
+ if (state[0]) {
BLI_snprintf(str, sizeof(str), "%s: %s", track->name, state);
- else
+ }
+ else {
BLI_strncpy(str, track->name, sizeof(str));
+ }
BLF_position(fontid, pos[0], pos[1], 0.0f);
BLF_draw(fontid, str, sizeof(str));
@@ -1479,8 +1502,9 @@ static void draw_tracking_tracks(SpaceClip *sc,
if ((track->flag & TRACK_HIDDEN) == 0) {
marker = BKE_tracking_marker_get(track, framenr);
- if (MARKER_VISIBLE(sc, track, marker))
+ if (MARKER_VISIBLE(sc, track, marker)) {
count++;
+ }
}
track = track->next;
@@ -1499,8 +1523,9 @@ static void draw_tracking_tracks(SpaceClip *sc,
if (MARKER_VISIBLE(sc, track, marker)) {
ED_clip_point_undistorted_pos(sc, marker->pos, fp);
- if (track == act_track)
+ if (track == act_track) {
active_pos = fp;
+ }
fp += 2;
}
@@ -1514,8 +1539,9 @@ static void draw_tracking_tracks(SpaceClip *sc,
if (sc->flag & SC_SHOW_TRACK_PATH) {
track = tracksbase->first;
while (track) {
- if ((track->flag & TRACK_HIDDEN) == 0)
+ if ((track->flag & TRACK_HIDDEN) == 0) {
draw_track_path(sc, clip, track);
+ }
track = track->next;
}
@@ -1541,8 +1567,9 @@ static void draw_tracking_tracks(SpaceClip *sc,
draw_marker_slide_zones(sc, track, marker, cur_pos, 1, 0, 0, width, height, position);
draw_marker_slide_zones(sc, track, marker, cur_pos, 0, 0, 0, width, height, position);
- if (fp)
+ if (fp) {
fp += 2;
+ }
}
}
@@ -1566,8 +1593,9 @@ static void draw_tracking_tracks(SpaceClip *sc,
draw_marker_slide_zones(sc, track, marker, cur_pos, 0, 1, 0, width, height, position);
}
- if (fp)
+ if (fp) {
fp += 2;
+ }
}
}
@@ -1664,8 +1692,9 @@ static void draw_tracking_tracks(SpaceClip *sc,
draw_marker_texts(sc, track, marker, cur_pos, act, width, height, zoomx, zoomy);
- if (fp)
+ if (fp) {
fp += 2;
+ }
}
}
@@ -1675,8 +1704,9 @@ static void draw_tracking_tracks(SpaceClip *sc,
GPU_matrix_pop();
- if (marker_pos)
+ if (marker_pos) {
MEM_freeN(marker_pos);
+ }
}
static void draw_distortion(
@@ -1692,11 +1722,13 @@ static void draw_distortion(
float dx = (float)width / n, dy = (float)height / n * aspy;
float offsx = 0.0f, offsy = 0.0f;
- if (!tracking->camera.focal)
+ if (!tracking->camera.focal) {
return;
+ }
- if ((sc->flag & SC_SHOW_GRID) == 0 && (sc->flag & SC_MANUAL_CALIBRATION) == 0)
+ if ((sc->flag & SC_SHOW_GRID) == 0 && (sc->flag & SC_MANUAL_CALIBRATION) == 0) {
return;
+ }
UI_view2d_view_to_region_fl(&ar->v2d, 0.0f, 0.0f, &x, &y);
@@ -1717,10 +1749,12 @@ static void draw_distortion(
float min[2], max[2];
for (a = 0; a < 4; a++) {
- if (a < 2)
+ if (a < 2) {
val[a][a % 2] = FLT_MAX;
- else
+ }
+ else {
val[a][a % 2] = -FLT_MAX;
+ }
}
zero_v2(pos);
@@ -1732,10 +1766,12 @@ static void draw_distortion(
for (a = 0; a < 4; a++) {
int ok;
- if (a < 2)
+ if (a < 2) {
ok = tpos[a % 2] < val[a][a % 2];
- else
+ }
+ else {
ok = tpos[a % 2] > val[a][a % 2];
+ }
if (ok) {
copy_v2_v2(val[a], tpos);
@@ -1912,10 +1948,12 @@ void clip_draw_main(const bContext *C, SpaceClip *sc, ARegion *ar)
ibuf = ED_space_clip_get_stable_buffer(sc, sc->loc, &sc->scale, &sc->angle);
}
- if (ibuf != NULL && width != ibuf->x)
+ if (ibuf != NULL && width != ibuf->x) {
mul_v2_v2fl(translation, sc->loc, (float)width / ibuf->x);
- else
+ }
+ else {
copy_v2_v2(translation, sc->loc);
+ }
BKE_tracking_stabilization_data_to_mat4(
width, height, aspect, translation, sc->scale, sc->angle, sc->stabmat);
@@ -1970,8 +2008,9 @@ void clip_draw_grease_pencil(bContext *C, int onlyv2d)
SpaceClip *sc = CTX_wm_space_clip(C);
MovieClip *clip = ED_space_clip_get_clip(sc);
- if (!clip)
+ if (!clip) {
return;
+ }
if (onlyv2d) {
bool is_track_source = sc->gpencil_src == SC_GPENCIL_SRC_TRACK;
diff --git a/source/blender/editors/space_clip/clip_editor.c b/source/blender/editors/space_clip/clip_editor.c
index 8351f79aac7..b0b6aa47df1 100644
--- a/source/blender/editors/space_clip/clip_editor.c
+++ b/source/blender/editors/space_clip/clip_editor.c
@@ -72,8 +72,9 @@ bool ED_space_clip_poll(bContext *C)
{
SpaceClip *sc = CTX_wm_space_clip(C);
- if (sc && sc->clip)
+ if (sc && sc->clip) {
return true;
+ }
return false;
}
@@ -93,8 +94,9 @@ bool ED_space_clip_tracking_poll(bContext *C)
{
SpaceClip *sc = CTX_wm_space_clip(C);
- if (sc && sc->clip)
+ if (sc && sc->clip) {
return ED_space_clip_check_show_trackedit(sc);
+ }
return false;
}
@@ -159,10 +161,12 @@ void ED_space_clip_get_aspect(SpaceClip *sc, float *aspx, float *aspy)
{
MovieClip *clip = ED_space_clip_get_clip(sc);
- if (clip)
+ if (clip) {
BKE_movieclip_get_aspect(clip, aspx, aspy);
- else
+ }
+ else {
*aspx = *aspy = 1.0f;
+ }
if (*aspx < *aspy) {
*aspy = *aspy / *aspx;
@@ -224,11 +228,13 @@ ImBuf *ED_space_clip_get_buffer(SpaceClip *sc)
ibuf = BKE_movieclip_get_postprocessed_ibuf(sc->clip, &sc->user, sc->postproc_flag);
- if (ibuf && (ibuf->rect || ibuf->rect_float))
+ if (ibuf && (ibuf->rect || ibuf->rect_float)) {
return ibuf;
+ }
- if (ibuf)
+ if (ibuf) {
IMB_freeImBuf(ibuf);
+ }
}
return NULL;
@@ -242,11 +248,13 @@ ImBuf *ED_space_clip_get_stable_buffer(SpaceClip *sc, float loc[2], float *scale
ibuf = BKE_movieclip_get_stable_ibuf(
sc->clip, &sc->user, loc, scale, angle, sc->postproc_flag);
- if (ibuf && (ibuf->rect || ibuf->rect_float))
+ if (ibuf && (ibuf->rect || ibuf->rect_float)) {
return ibuf;
+ }
- if (ibuf)
+ if (ibuf) {
IMB_freeImBuf(ibuf);
+ }
}
return NULL;
@@ -395,11 +403,13 @@ bool ED_clip_view_selection(const bContext *C, ARegion *ar, bool fit)
ED_space_clip_get_size(sc, &frame_width, &frame_height);
- if ((frame_width == 0) || (frame_height == 0) || (sc->clip == NULL))
+ if ((frame_width == 0) || (frame_height == 0) || (sc->clip == NULL)) {
return false;
+ }
- if (!selected_boundbox(C, min, max))
+ if (!selected_boundbox(C, min, max)) {
return false;
+ }
/* center view */
clip_view_center_to_point(
@@ -423,8 +433,9 @@ bool ED_clip_view_selection(const bContext *C, ARegion *ar, bool fit)
newzoom = 1.0f / power_of_2(1.0f / min_ff(zoomx, zoomy));
- if (fit || sc->zoom > newzoom)
+ if (fit || sc->zoom > newzoom) {
sc->zoom = newzoom;
+ }
}
return true;
@@ -489,8 +500,9 @@ void ED_clip_select_all(SpaceClip *sc, int action, bool *r_has_selection)
}
}
- if (TRACK_VIEW_SELECTED(sc, track))
+ if (TRACK_VIEW_SELECTED(sc, track)) {
has_selection = true;
+ }
}
for (plane_track = plane_tracks_base->first; plane_track; plane_track = plane_track->next) {
@@ -635,8 +647,9 @@ void ED_space_clip_set_clip(bContext *C, bScreen *screen, SpaceClip *sc, MovieCl
MovieClip *old_clip;
bool old_clip_visible = false;
- if (!screen && C)
+ if (!screen && C) {
screen = CTX_wm_screen(C);
+ }
old_clip = sc->clip;
sc->clip = clip;
@@ -654,8 +667,9 @@ void ED_space_clip_set_clip(bContext *C, bScreen *screen, SpaceClip *sc, MovieCl
if (cur_sc != sc) {
if (cur_sc->view == SC_VIEW_CLIP) {
- if (cur_sc->clip == old_clip)
+ if (cur_sc->clip == old_clip) {
old_clip_visible = true;
+ }
}
else {
if (cur_sc->clip == old_clip || cur_sc->clip == NULL) {
@@ -673,8 +687,9 @@ void ED_space_clip_set_clip(bContext *C, bScreen *screen, SpaceClip *sc, MovieCl
BKE_movieclip_clear_cache(old_clip);
}
- if (C)
+ if (C) {
WM_event_add_notifier(C, NC_MOVIECLIP | NA_SELECTED, sc->clip);
+ }
}
/* ******** masking editing functions ******** */
@@ -785,16 +800,18 @@ static int prefetch_find_uncached_frame(MovieClip *clip,
for (current_frame = from_frame; current_frame <= end_frame; current_frame++) {
user.framenr = current_frame;
- if (!BKE_movieclip_has_cached_frame(clip, &user))
+ if (!BKE_movieclip_has_cached_frame(clip, &user)) {
break;
+ }
}
}
else {
for (current_frame = from_frame; current_frame >= end_frame; current_frame--) {
user.framenr = current_frame;
- if (!BKE_movieclip_has_cached_frame(clip, &user))
+ if (!BKE_movieclip_has_cached_frame(clip, &user)) {
break;
+ }
}
}
@@ -956,8 +973,9 @@ static bool prefetch_movie_frame(
MovieClipUser user = {0};
ImBuf *ibuf;
- if (check_prefetch_break() || *stop)
+ if (check_prefetch_break() || *stop) {
return false;
+ }
user.framenr = frame;
user.render_size = render_size;
@@ -1002,8 +1020,9 @@ static void do_prefetch_movie(MovieClip *clip,
/* read frames starting from current frame up to scene end frame */
for (frame = current_frame; frame <= end_frame; frame++) {
- if (!prefetch_movie_frame(clip, frame, render_size, render_flag, stop))
+ if (!prefetch_movie_frame(clip, frame, render_size, render_flag, stop)) {
return;
+ }
frames_processed++;
@@ -1013,8 +1032,9 @@ static void do_prefetch_movie(MovieClip *clip,
/* read frames starting from current frame up to scene start frame */
for (frame = current_frame; frame >= start_frame; frame--) {
- if (!prefetch_movie_frame(clip, frame, render_size, render_flag, stop))
+ if (!prefetch_movie_frame(clip, frame, render_size, render_flag, stop)) {
return;
+ }
frames_processed++;
@@ -1113,8 +1133,9 @@ static bool prefetch_check_early_out(const bContext *C)
first_uncached_frame = prefetch_find_uncached_frame(
clip, sc->user.framenr, start_frame, sc->user.render_size, sc->user.render_flag, -1);
- if (first_uncached_frame < start_frame)
+ if (first_uncached_frame < start_frame) {
return true;
+ }
}
return false;
@@ -1126,8 +1147,9 @@ void clip_start_prefetch_job(const bContext *C)
PrefetchJob *pj;
SpaceClip *sc = CTX_wm_space_clip(C);
- if (prefetch_check_early_out(C))
+ if (prefetch_check_early_out(C)) {
return;
+ }
wm_job = WM_jobs_get(CTX_wm_manager(C),
CTX_wm_window(C),
diff --git a/source/blender/editors/space_clip/clip_graph_draw.c b/source/blender/editors/space_clip/clip_graph_draw.c
index c7602907954..8a5f48d11d2 100644
--- a/source/blender/editors/space_clip/clip_graph_draw.c
+++ b/source/blender/editors/space_clip/clip_graph_draw.c
@@ -111,8 +111,9 @@ static void tracking_segment_knot_cb(void *userdata,
TrackMotionCurveUserData *data = (TrackMotionCurveUserData *)userdata;
int sel = 0, sel_flag;
- if (track != data->act_track)
+ if (track != data->act_track) {
return;
+ }
sel_flag = coord == 0 ? MARKER_GRAPH_SEL_X : MARKER_GRAPH_SEL_Y;
sel = (marker->flag & sel_flag) ? 1 : 0;
@@ -140,8 +141,9 @@ static void draw_tracks_motion_curves(View2D *v2d, SpaceClip *sc, unsigned int p
BKE_movieclip_get_size(clip, &sc->user, &width, &height);
- if (!width || !height)
+ if (!width || !height) {
return;
+ }
/* non-selected knot handles */
userdata.hsize = UI_GetThemeValuef(TH_HANDLE_VERTEX_SIZE);
diff --git a/source/blender/editors/space_clip/clip_graph_ops.c b/source/blender/editors/space_clip/clip_graph_ops.c
index 7a61aced8b5..a3722433e33 100644
--- a/source/blender/editors/space_clip/clip_graph_ops.c
+++ b/source/blender/editors/space_clip/clip_graph_ops.c
@@ -200,16 +200,20 @@ static bool mouse_select_knot(bContext *C, float co[2], bool extend)
}
if (userdata.coord == 0) {
- if (extend && (userdata.marker->flag & MARKER_GRAPH_SEL_X) != 0)
+ if (extend && (userdata.marker->flag & MARKER_GRAPH_SEL_X) != 0) {
userdata.marker->flag &= ~MARKER_GRAPH_SEL_X;
- else
+ }
+ else {
userdata.marker->flag |= MARKER_GRAPH_SEL_X;
+ }
}
else {
- if (extend && (userdata.marker->flag & MARKER_GRAPH_SEL_Y) != 0)
+ if (extend && (userdata.marker->flag & MARKER_GRAPH_SEL_Y) != 0) {
userdata.marker->flag &= ~MARKER_GRAPH_SEL_Y;
- else
+ }
+ else {
userdata.marker->flag |= MARKER_GRAPH_SEL_Y;
+ }
}
return true;
@@ -281,8 +285,9 @@ static int mouse_select(bContext *C, float co[2], bool extend)
sel = mouse_select_curve(C, co, extend);
}
- if (sel)
+ if (sel) {
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, NULL);
+ }
return OPERATOR_FINISHED;
}
@@ -360,10 +365,12 @@ static void box_select_cb(void *userdata,
if (BLI_rctf_isect_pt(&data->rect, scene_framenr, val)) {
int flag = 0;
- if (coord == 0)
+ if (coord == 0) {
flag = MARKER_GRAPH_SEL_X;
- else
+ }
+ else {
flag = MARKER_GRAPH_SEL_Y;
+ }
if (data->select) {
marker->flag |= flag;
@@ -444,8 +451,9 @@ static int graph_select_all_markers_exec(bContext *C, wmOperator *op)
int action = RNA_enum_get(op->ptr, "action");
int a;
- if (!act_track)
+ if (!act_track) {
return OPERATOR_CANCELLED;
+ }
if (action == SEL_TOGGLE) {
action = SEL_SELECT;
@@ -507,8 +515,9 @@ static int delete_curve_exec(bContext *C, wmOperator *UNUSED(op))
MovieTracking *tracking = &clip->tracking;
MovieTrackingTrack *act_track = BKE_tracking_track_get_active(tracking);
- if (!act_track)
+ if (!act_track) {
return OPERATOR_CANCELLED;
+ }
clip_delete_track(C, clip, act_track);
@@ -546,10 +555,12 @@ static int delete_knot_exec(bContext *C, wmOperator *UNUSED(op))
while (a < act_track->markersnr) {
MovieTrackingMarker *marker = &act_track->markers[a];
- if (marker->flag & MARKER_GRAPH_SEL)
+ if (marker->flag & MARKER_GRAPH_SEL) {
clip_delete_marker(C, clip, act_track, marker);
- else
+ }
+ else {
a++;
+ }
}
}
@@ -586,11 +597,13 @@ static void view_all_cb(void *userdata,
{
ViewAllUserData *data = (ViewAllUserData *)userdata;
- if (val < data->min)
+ if (val < data->min) {
data->min = val;
+ }
- if (val > data->max)
+ if (val > data->max) {
data->max = val;
+ }
}
static int view_all_exec(bContext *C, wmOperator *UNUSED(op))
@@ -700,19 +713,23 @@ static int graph_disable_markers_exec(bContext *C, wmOperator *op)
int action = RNA_enum_get(op->ptr, "action");
int a;
- if (!act_track || (act_track->flag & TRACK_LOCKED))
+ if (!act_track || (act_track->flag & TRACK_LOCKED)) {
return OPERATOR_CANCELLED;
+ }
for (a = 0; a < act_track->markersnr; a++) {
marker = &act_track->markers[a];
if (marker->flag & MARKER_GRAPH_SEL) {
- if (action == 0)
+ if (action == 0) {
marker->flag |= MARKER_DISABLED;
- else if (action == 1)
+ }
+ else if (action == 1) {
marker->flag &= ~MARKER_DISABLED;
- else
+ }
+ else {
marker->flag ^= MARKER_DISABLED;
+ }
}
}
diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c
index 3cebb53d31e..3f971c4444a 100644
--- a/source/blender/editors/space_clip/clip_ops.c
+++ b/source/blender/editors/space_clip/clip_ops.c
@@ -97,12 +97,15 @@ static void sclip_zoom_set(const bContext *C, float zoom, float location[2])
width *= sc->zoom;
height *= sc->zoom;
- if ((width < 4) && (height < 4) && sc->zoom < oldzoom)
+ if ((width < 4) && (height < 4) && sc->zoom < oldzoom) {
sc->zoom = oldzoom;
- else if (BLI_rcti_size_x(&ar->winrct) <= sc->zoom)
+ }
+ else if (BLI_rcti_size_x(&ar->winrct) <= sc->zoom) {
sc->zoom = oldzoom;
- else if (BLI_rcti_size_y(&ar->winrct) <= sc->zoom)
+ }
+ else if (BLI_rcti_size_y(&ar->winrct) <= sc->zoom) {
sc->zoom = oldzoom;
+ }
}
if ((U.uiflag & USER_ZOOM_TO_MOUSEPOS) && location) {
@@ -216,8 +219,9 @@ static int open_exec(bContext *C, wmOperator *op)
clip = BKE_movieclip_file_add_exists(bmain, str);
if (!clip) {
- if (op->customdata)
+ if (op->customdata) {
MEM_freeN(op->customdata);
+ }
BKE_reportf(op->reports,
RPT_ERROR,
@@ -228,8 +232,9 @@ static int open_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- if (!op->customdata)
+ if (!op->customdata) {
open_init(C, op);
+ }
/* hook into UI */
pprop = op->customdata;
@@ -261,8 +266,9 @@ static int open_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)
char path[FILE_MAX];
MovieClip *clip = NULL;
- if (sc)
+ if (sc) {
clip = ED_space_clip_get_clip(sc);
+ }
if (clip) {
BLI_strncpy(path, clip->name, sizeof(path));
@@ -274,11 +280,13 @@ static int open_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)
BLI_strncpy(path, U.textudir, sizeof(path));
}
- if (RNA_struct_property_is_set(op->ptr, "files"))
+ if (RNA_struct_property_is_set(op->ptr, "files")) {
return open_exec(C, op);
+ }
- if (!RNA_struct_property_is_set(op->ptr, "relative_path"))
+ if (!RNA_struct_property_is_set(op->ptr, "relative_path")) {
RNA_boolean_set(op->ptr, "relative_path", (U.flag & USER_RELPATHS) != 0);
+ }
open_init(C, op);
@@ -318,8 +326,9 @@ static int reload_exec(bContext *C, wmOperator *UNUSED(op))
{
MovieClip *clip = CTX_data_edit_movieclip(C);
- if (!clip)
+ if (!clip) {
return OPERATOR_CANCELLED;
+ }
WM_jobs_kill_type(CTX_wm_manager(C), NULL, WM_JOB_TYPE_CLIP_PREFETCH);
BKE_movieclip_reload(CTX_data_main(C), clip);
@@ -360,10 +369,12 @@ static void view_pan_init(bContext *C, wmOperator *op, const wmEvent *event)
vpd->x = event->x;
vpd->y = event->y;
- if (sc->flag & SC_LOCK_SELECTION)
+ if (sc->flag & SC_LOCK_SELECTION) {
vpd->vec = &sc->xlockof;
- else
+ }
+ else {
vpd->vec = &sc->xof;
+ }
copy_v2_v2(&vpd->xof, vpd->vec);
copy_v2_v2(&vpd->xorig, &vpd->xof);
@@ -569,8 +580,9 @@ static int view_zoom_invoke(bContext *C, wmOperator *op, const wmEvent *event)
delta = event->prevx - event->x + event->prevy - event->y;
- if (U.uiflag & USER_ZOOM_INVERT)
+ if (U.uiflag & USER_ZOOM_INVERT) {
delta *= -1;
+ }
factor = 1.0f + delta / 300.0f;
RNA_float_set(op->ptr, "factor", factor);
@@ -879,8 +891,9 @@ static int view_all_exec(bContext *C, wmOperator *op)
/* find the zoom value that will fit the image in the image space */
sclip_zoom_set(C, 1.0f / power_of_2(1.0f / min_ff(zoomx, zoomy)), NULL);
}
- else
+ else {
sclip_zoom_set(C, 1.0f, NULL);
+ }
}
sc->xof = sc->yof = 0.0f;
@@ -941,8 +954,9 @@ void CLIP_OT_view_selected(wmOperatorType *ot)
static bool change_frame_poll(bContext *C)
{
/* prevent changes during render */
- if (G.is_rendering)
+ if (G.is_rendering) {
return 0;
+ }
return ED_space_clip_poll(C);
}
@@ -995,8 +1009,9 @@ static int change_frame_invoke(bContext *C, wmOperator *op, const wmEvent *event
ARegion *ar = CTX_wm_region(C);
if (ar->regiontype == RGN_TYPE_WINDOW) {
- if (event->mval[1] > 16)
+ if (event->mval[1] > 16) {
return OPERATOR_PASS_THROUGH;
+ }
}
RNA_int_set(op->ptr, "frame", frame_from_event(C, event));
@@ -1022,8 +1037,9 @@ static int change_frame_modal(bContext *C, wmOperator *op, const wmEvent *event)
case LEFTMOUSE:
case RIGHTMOUSE:
- if (event->val == KM_RELEASE)
+ if (event->val == KM_RELEASE) {
return OPERATOR_FINISHED;
+ }
break;
}
@@ -1079,17 +1095,21 @@ static int proxy_bitflag_to_array(int size_flag, int build_sizes[4], int undisto
MCLIP_PROXY_UNDISTORTED_SIZE_100}};
int size_nr = undistort ? 1 : 0;
- if (size_flag & size_flags[size_nr][0])
+ if (size_flag & size_flags[size_nr][0]) {
build_sizes[build_count++] = MCLIP_PROXY_RENDER_SIZE_25;
+ }
- if (size_flag & size_flags[size_nr][1])
+ if (size_flag & size_flags[size_nr][1]) {
build_sizes[build_count++] = MCLIP_PROXY_RENDER_SIZE_50;
+ }
- if (size_flag & size_flags[size_nr][2])
+ if (size_flag & size_flags[size_nr][2]) {
build_sizes[build_count++] = MCLIP_PROXY_RENDER_SIZE_75;
+ }
- if (size_flag & size_flags[size_nr][3])
+ if (size_flag & size_flags[size_nr][3]) {
build_sizes[build_count++] = MCLIP_PROXY_RENDER_SIZE_100;
+ }
return build_count;
}
@@ -1110,12 +1130,14 @@ static void do_movie_proxy(void *pjv,
struct MovieDistortion *distortion = NULL;
int cfra, sfra = SFRA, efra = EFRA;
- if (pj->index_context)
+ if (pj->index_context) {
IMB_anim_index_rebuild(pj->index_context, stop, do_update, progress);
+ }
if (!build_undistort_count) {
- if (*stop)
+ if (*stop) {
pj->stop = 1;
+ }
return;
}
@@ -1138,18 +1160,21 @@ static void do_movie_proxy(void *pjv,
BKE_movieclip_build_proxy_frame(
clip, pj->clip_flag, distortion, cfra, build_undistort_sizes, build_undistort_count, 1);
- if (*stop || G.is_break)
+ if (*stop || G.is_break) {
break;
+ }
*do_update = true;
*progress = ((float)cfra - sfra) / (efra - sfra);
}
- if (distortion)
+ if (distortion) {
BKE_tracking_distortion_free(distortion);
+ }
- if (*stop)
+ if (*stop) {
pj->stop = 1;
+ }
}
/* *****
@@ -1371,11 +1396,13 @@ static void proxy_endjob(void *pjv)
{
ProxyJob *pj = pjv;
- if (pj->clip->anim)
+ if (pj->clip->anim) {
IMB_close_anim_proxies(pj->clip->anim);
+ }
- if (pj->index_context)
+ if (pj->index_context) {
IMB_anim_index_rebuild_finish(pj->index_context, pj->stop);
+ }
if (pj->clip->source == MCLIP_SRC_MOVIE) {
/* Timecode might have changed, so do a full reload to deal with this. */
@@ -1398,8 +1425,9 @@ static int clip_rebuild_proxy_exec(bContext *C, wmOperator *UNUSED(op))
SpaceClip *sc = CTX_wm_space_clip(C);
MovieClip *clip = ED_space_clip_get_clip(sc);
- if ((clip->flag & MCLIP_USE_PROXY) == 0)
+ if ((clip->flag & MCLIP_USE_PROXY) == 0) {
return OPERATOR_CANCELLED;
+ }
wm_job = WM_jobs_get(CTX_wm_manager(C),
CTX_wm_window(C),
@@ -1491,8 +1519,9 @@ void CLIP_OT_mode_set(wmOperatorType *ot)
static int clip_view_ndof_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
{
- if (event->type != NDOF_MOTION)
+ if (event->type != NDOF_MOTION) {
return OPERATOR_CANCELLED;
+ }
else {
SpaceClip *sc = CTX_wm_space_clip(C);
ARegion *ar = CTX_wm_region(C);
@@ -1534,8 +1563,9 @@ void CLIP_OT_view_ndof(wmOperatorType *ot)
static int clip_prefetch_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_wm_area(C), WM_JOB_TYPE_CLIP_PREFETCH))
+ if (0 == WM_jobs_test(CTX_wm_manager(C), CTX_wm_area(C), WM_JOB_TYPE_CLIP_PREFETCH)) {
return OPERATOR_FINISHED | OPERATOR_PASS_THROUGH;
+ }
/* running render */
switch (event->type) {
@@ -1577,8 +1607,9 @@ static int clip_set_scene_frames_exec(bContext *C, wmOperator *UNUSED(op))
Scene *scene = CTX_data_scene(C);
int clip_length;
- if (ELEM(NULL, scene, clip))
+ if (ELEM(NULL, scene, clip)) {
return OPERATOR_CANCELLED;
+ }
clip_length = BKE_movieclip_get_duration(clip);
diff --git a/source/blender/editors/space_clip/clip_toolbar.c b/source/blender/editors/space_clip/clip_toolbar.c
index d54a6da9a3c..fb0362fffd3 100644
--- a/source/blender/editors/space_clip/clip_toolbar.c
+++ b/source/blender/editors/space_clip/clip_toolbar.c
@@ -58,15 +58,17 @@ ARegion *ED_clip_has_properties_region(ScrArea *sa)
ARegion *ar, *arnew;
ar = BKE_area_find_region_type(sa, RGN_TYPE_UI);
- if (ar)
+ if (ar) {
return ar;
+ }
/* add subdiv level; after header */
ar = BKE_area_find_region_type(sa, RGN_TYPE_HEADER);
/* is error! */
- if (ar == NULL)
+ if (ar == NULL) {
return NULL;
+ }
arnew = MEM_callocN(sizeof(ARegion), "clip properties region");
diff --git a/source/blender/editors/space_clip/clip_utils.c b/source/blender/editors/space_clip/clip_utils.c
index 37a28e6189a..3dfe529f8e8 100644
--- a/source/blender/editors/space_clip/clip_utils.c
+++ b/source/blender/editors/space_clip/clip_utils.c
@@ -81,8 +81,9 @@ void clip_graph_tracking_values_iterate_track(
if (marker->flag & MARKER_DISABLED) {
if (open) {
- if (segment_end)
+ if (segment_end) {
segment_end(userdata, coord);
+ }
open = false;
}
@@ -119,8 +120,9 @@ void clip_graph_tracking_values_iterate_track(
}
if (open) {
- if (segment_end)
+ if (segment_end) {
segment_end(userdata, coord);
+ }
}
}
}
@@ -145,11 +147,13 @@ void clip_graph_tracking_values_iterate(
MovieTrackingTrack *track;
for (track = tracksbase->first; track; track = track->next) {
- if (!include_hidden && (track->flag & TRACK_HIDDEN) != 0)
+ if (!include_hidden && (track->flag & TRACK_HIDDEN) != 0) {
continue;
+ }
- if (selected_only && !TRACK_SELECTED(track))
+ if (selected_only && !TRACK_SELECTED(track)) {
continue;
+ }
clip_graph_tracking_values_iterate_track(
sc, track, userdata, func, segment_start, segment_end);
@@ -170,20 +174,24 @@ void clip_graph_tracking_iterate(SpaceClip *sc,
for (track = tracksbase->first; track; track = track->next) {
int i;
- if (!include_hidden && (track->flag & TRACK_HIDDEN) != 0)
+ if (!include_hidden && (track->flag & TRACK_HIDDEN) != 0) {
continue;
+ }
- if (selected_only && !TRACK_SELECTED(track))
+ if (selected_only && !TRACK_SELECTED(track)) {
continue;
+ }
for (i = 0; i < track->markersnr; i++) {
MovieTrackingMarker *marker = &track->markers[i];
- if (marker->flag & MARKER_DISABLED)
+ if (marker->flag & MARKER_DISABLED) {
continue;
+ }
- if (func)
+ if (func) {
func(userdata, marker);
+ }
}
}
}
diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c
index d12e6634987..f176763abf5 100644
--- a/source/blender/editors/space_clip/space_clip.c
+++ b/source/blender/editors/space_clip/space_clip.c
@@ -136,12 +136,14 @@ static void reinit_preview_region(const bContext *C, ARegion *ar)
SpaceClip *sc = CTX_wm_space_clip(C);
if (sc->view == SC_VIEW_DOPESHEET) {
- if ((ar->v2d.flag & V2D_VIEWSYNC_AREA_VERTICAL) == 0)
+ if ((ar->v2d.flag & V2D_VIEWSYNC_AREA_VERTICAL) == 0) {
init_preview_region(scene, sa, sc, ar);
+ }
}
else {
- if (ar->v2d.flag & V2D_VIEWSYNC_AREA_VERTICAL)
+ if (ar->v2d.flag & V2D_VIEWSYNC_AREA_VERTICAL) {
init_preview_region(scene, sa, sc, ar);
+ }
}
}
@@ -150,15 +152,17 @@ static ARegion *ED_clip_has_preview_region(const bContext *C, ScrArea *sa)
ARegion *ar, *arnew;
ar = BKE_area_find_region_type(sa, RGN_TYPE_PREVIEW);
- if (ar)
+ if (ar) {
return ar;
+ }
/* add subdiv level; after header */
ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
/* is error! */
- if (ar == NULL)
+ if (ar == NULL) {
return NULL;
+ }
arnew = MEM_callocN(sizeof(ARegion), "clip preview region");
@@ -173,15 +177,17 @@ static ARegion *ED_clip_has_channels_region(ScrArea *sa)
ARegion *ar, *arnew;
ar = BKE_area_find_region_type(sa, RGN_TYPE_CHANNELS);
- if (ar)
+ if (ar) {
return ar;
+ }
/* add subdiv level; after header */
ar = BKE_area_find_region_type(sa, RGN_TYPE_PREVIEW);
/* is error! */
- if (ar == NULL)
+ if (ar == NULL) {
return NULL;
+ }
arnew = MEM_callocN(sizeof(ARegion), "clip channels region");
@@ -200,13 +206,15 @@ static void clip_scopes_tag_refresh(ScrArea *sa)
SpaceClip *sc = (SpaceClip *)sa->spacedata.first;
ARegion *ar;
- if (sc->mode != SC_MODE_TRACKING)
+ if (sc->mode != SC_MODE_TRACKING) {
return;
+ }
/* only while properties are visible */
for (ar = sa->regionbase.first; ar; ar = ar->next) {
- if (ar->regiontype == RGN_TYPE_UI && ar->flag & RGN_FLAG_HIDDEN)
+ if (ar->regiontype == RGN_TYPE_UI && ar->flag & RGN_FLAG_HIDDEN) {
return;
+ }
}
sc->scopes.ok = false;
@@ -296,11 +304,13 @@ static void clip_free(SpaceLink *sl)
sc->clip = NULL;
- if (sc->scopes.track_preview)
+ if (sc->scopes.track_preview) {
IMB_freeImBuf(sc->scopes.track_preview);
+ }
- if (sc->scopes.track_search)
+ if (sc->scopes.track_search) {
IMB_freeImBuf(sc->scopes.track_search);
+ }
}
/* spacetype; init callback */
@@ -565,13 +575,15 @@ static int clip_context(const bContext *C, const char *member, bContextDataResul
return true;
}
else if (CTX_data_equals(member, "edit_movieclip")) {
- if (sc->clip)
+ if (sc->clip) {
CTX_data_id_pointer_set(result, &sc->clip->id);
+ }
return true;
}
else if (CTX_data_equals(member, "edit_mask")) {
- if (sc->mask_info.mask)
+ if (sc->mask_info.mask) {
CTX_data_id_pointer_set(result, &sc->mask_info.mask->id);
+ }
return true;
}
@@ -868,8 +880,9 @@ static void clip_main_region_draw(const bContext *C, ARegion *ar)
/* if tracking is in progress, we should synchronize framenr from clipuser
* so latest tracked frame would be shown */
- if (clip && clip->tracking_context)
+ if (clip && clip->tracking_context) {
BKE_autotrack_context_sync_user(clip->tracking_context, &sc->user);
+ }
if (sc->flag & SC_LOCK_SELECTION) {
ImBuf *tmpibuf = NULL;
@@ -883,8 +896,9 @@ static void clip_main_region_draw(const bContext *C, ARegion *ar)
sc->yof += sc->ylockof;
}
- if (tmpibuf)
+ if (tmpibuf) {
IMB_freeImBuf(tmpibuf);
+ }
}
/* clear and setup matrix */
@@ -968,10 +982,12 @@ static void clip_main_region_listener(wmWindow *UNUSED(win),
/* context changes */
switch (wmn->category) {
case NC_GPENCIL:
- if (wmn->action == NA_EDITED)
+ if (wmn->action == NA_EDITED) {
ED_region_tag_redraw(ar);
- else if (wmn->data & ND_GPENCIL_EDITMODE)
+ }
+ else if (wmn->data & ND_GPENCIL_EDITMODE) {
ED_region_tag_redraw(ar);
+ }
break;
}
}
@@ -1004,8 +1020,9 @@ static void graph_region_draw(const bContext *C, ARegion *ar)
short unitx, unity;
short cfra_flag = 0;
- if (sc->flag & SC_LOCK_TIMECURSOR)
+ if (sc->flag & SC_LOCK_TIMECURSOR) {
ED_clip_graph_center_current_frame(scene, ar);
+ }
/* clear and setup matrix */
UI_ThemeClearColor(TH_BACK);
@@ -1017,8 +1034,9 @@ static void graph_region_draw(const bContext *C, ARegion *ar)
clip_draw_graph(sc, ar, scene);
/* current frame indicator line */
- if (sc->flag & SC_SHOW_SECONDS)
+ if (sc->flag & SC_SHOW_SECONDS) {
cfra_flag |= DRAWCFRA_UNIT_SECONDS;
+ }
ANIM_draw_cfra(C, v2d, cfra_flag);
/* reset view matrix */
@@ -1033,8 +1051,9 @@ static void graph_region_draw(const bContext *C, ARegion *ar)
UI_view2d_scrollers_free(scrollers);
/* current frame indicator */
- if (sc->flag & SC_SHOW_SECONDS)
+ if (sc->flag & SC_SHOW_SECONDS) {
cfra_flag |= DRAWCFRA_UNIT_SECONDS;
+ }
UI_view2d_view_orthoSpecial(ar, v2d, 1);
ANIM_draw_cfra_number(C, v2d, cfra_flag);
}
@@ -1049,8 +1068,9 @@ static void dopesheet_region_draw(const bContext *C, ARegion *ar)
View2DScrollers *scrollers;
short unit = 0, cfra_flag = 0;
- if (clip)
+ if (clip) {
BKE_tracking_dopesheet_update(&clip->tracking);
+ }
/* clear and setup matrix */
UI_ThemeClearColor(TH_BACK);
@@ -1069,8 +1089,9 @@ static void dopesheet_region_draw(const bContext *C, ARegion *ar)
clip_draw_dopesheet_main(sc, ar, scene);
/* current frame indicator line */
- if (sc->flag & SC_SHOW_SECONDS)
+ if (sc->flag & SC_SHOW_SECONDS) {
cfra_flag |= DRAWCFRA_UNIT_SECONDS;
+ }
ANIM_draw_cfra(C, v2d, cfra_flag);
/* reset view matrix */
@@ -1091,10 +1112,12 @@ static void clip_preview_region_draw(const bContext *C, ARegion *ar)
{
SpaceClip *sc = CTX_wm_space_clip(C);
- if (sc->view == SC_VIEW_GRAPH)
+ if (sc->view == SC_VIEW_GRAPH) {
graph_region_draw(C, ar);
- else if (sc->view == SC_VIEW_DOPESHEET)
+ }
+ else if (sc->view == SC_VIEW_DOPESHEET) {
dopesheet_region_draw(C, ar);
+ }
}
static void clip_preview_region_listener(wmWindow *UNUSED(win),
@@ -1126,8 +1149,9 @@ static void clip_channels_region_draw(const bContext *C, ARegion *ar)
MovieClip *clip = ED_space_clip_get_clip(sc);
View2D *v2d = &ar->v2d;
- if (clip)
+ if (clip) {
BKE_tracking_dopesheet_update(&clip->tracking);
+ }
/* clear and setup matrix */
UI_ThemeClearColor(TH_BACK);
@@ -1215,20 +1239,24 @@ static void clip_props_region_listener(wmWindow *UNUSED(win),
/* context changes */
switch (wmn->category) {
case NC_WM:
- if (wmn->data == ND_HISTORY)
+ if (wmn->data == ND_HISTORY) {
ED_region_tag_redraw(ar);
+ }
break;
case NC_SCENE:
- if (wmn->data == ND_MODE)
+ if (wmn->data == ND_MODE) {
ED_region_tag_redraw(ar);
+ }
break;
case NC_SPACE:
- if (wmn->data == ND_SPACE_CLIP)
+ if (wmn->data == ND_SPACE_CLIP) {
ED_region_tag_redraw(ar);
+ }
break;
case NC_GPENCIL:
- if (wmn->action == NA_EDITED)
+ if (wmn->action == NA_EDITED) {
ED_region_tag_redraw(ar);
+ }
break;
}
}
@@ -1264,12 +1292,14 @@ static void clip_properties_region_listener(wmWindow *UNUSED(win),
/* context changes */
switch (wmn->category) {
case NC_GPENCIL:
- if (ELEM(wmn->data, ND_DATA, ND_GPENCIL_EDITMODE))
+ if (ELEM(wmn->data, ND_DATA, ND_GPENCIL_EDITMODE)) {
ED_region_tag_redraw(ar);
+ }
break;
case NC_BRUSH:
- if (wmn->action == NA_EDITED)
+ if (wmn->action == NA_EDITED) {
ED_region_tag_redraw(ar);
+ }
break;
}
}
diff --git a/source/blender/editors/space_clip/tracking_ops.c b/source/blender/editors/space_clip/tracking_ops.c
index ce1ade80823..18d48b426e0 100644
--- a/source/blender/editors/space_clip/tracking_ops.c
+++ b/source/blender/editors/space_clip/tracking_ops.c
@@ -512,8 +512,9 @@ static bool slide_check_corners(float (*corners)[2])
float cross = 0.0f;
float p[2] = {0.0f, 0.0f};
- if (!isect_point_quad_v2(p, corners[0], corners[1], corners[2], corners[3]))
+ if (!isect_point_quad_v2(p, corners[0], corners[1], corners[2], corners[3])) {
return false;
+ }
for (i = 0; i < 4; i++) {
float v1[2], v2[2], cur_cross;
@@ -562,8 +563,9 @@ MovieTrackingTrack *tracking_marker_check_slide(
ED_space_clip_get_size(sc, &width, &height);
- if (width == 0 || height == 0)
+ if (width == 0 || height == 0) {
return NULL;
+ }
ED_clip_mouse_pos(sc, ar, event->mval, co);
diff --git a/source/blender/editors/space_clip/tracking_ops_orient.c b/source/blender/editors/space_clip/tracking_ops_orient.c
index 6efc80c5c05..61991993b10 100644
--- a/source/blender/editors/space_clip/tracking_ops_orient.c
+++ b/source/blender/editors/space_clip/tracking_ops_orient.c
@@ -679,8 +679,9 @@ static int do_set_scale(bContext *C, wmOperator *op, bool scale_solution, bool a
DEG_id_tag_update(&clip->id, 0);
- if (object)
+ if (object) {
DEG_id_tag_update(&object->id, ID_RECALC_TRANSFORM);
+ }
WM_event_add_notifier(C, NC_MOVIECLIP | NA_EVALUATED, clip);
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
@@ -700,8 +701,9 @@ static int set_scale_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(e
SpaceClip *sc = CTX_wm_space_clip(C);
MovieClip *clip = ED_space_clip_get_clip(sc);
- if (!RNA_struct_property_is_set(op->ptr, "distance"))
+ if (!RNA_struct_property_is_set(op->ptr, "distance")) {
RNA_float_set(op->ptr, "distance", clip->tracking.settings.dist);
+ }
return set_scale_exec(C, op);
}
diff --git a/source/blender/editors/space_clip/tracking_ops_solve.c b/source/blender/editors/space_clip/tracking_ops_solve.c
index ca57b3ea57f..4490655393e 100644
--- a/source/blender/editors/space_clip/tracking_ops_solve.c
+++ b/source/blender/editors/space_clip/tracking_ops_solve.c
@@ -239,8 +239,9 @@ static int solve_camera_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSE
static int solve_camera_modal(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
{
/* No running solver, remove handler and pass through. */
- if (0 == WM_jobs_test(CTX_wm_manager(C), CTX_wm_area(C), WM_JOB_TYPE_ANY))
+ if (0 == WM_jobs_test(CTX_wm_manager(C), CTX_wm_area(C), WM_JOB_TYPE_ANY)) {
return OPERATOR_FINISHED | OPERATOR_PASS_THROUGH;
+ }
/* Running solver. */
switch (event->type) {
diff --git a/source/blender/editors/space_clip/tracking_select.c b/source/blender/editors/space_clip/tracking_select.c
index 24282ce0e96..207a0f1aff6 100644
--- a/source/blender/editors/space_clip/tracking_select.c
+++ b/source/blender/editors/space_clip/tracking_select.c
@@ -58,11 +58,13 @@ static float dist_to_crns(float co[2], float pos[2], float crns[4][2]);
static int mouse_on_side(
float co[2], float x1, float y1, float x2, float y2, float epsx, float epsy)
{
- if (x1 > x2)
+ if (x1 > x2) {
SWAP(float, x1, x2);
+ }
- if (y1 > y2)
+ if (y1 > y2) {
SWAP(float, y1, y2);
+ }
return (co[0] >= x1 - epsx && co[0] <= x2 + epsx) && (co[1] >= y1 - epsy && co[1] <= y2 + epsy);
}
@@ -115,14 +117,17 @@ static int track_mouse_area(const bContext *C, float co[2], MovieTrackingTrack *
epsy = max_ff(epsy, 2.0f / height);
if (sc->flag & SC_SHOW_MARKER_SEARCH) {
- if (mouse_on_rect(co, marker->pos, marker->search_min, marker->search_max, epsx, epsy))
+ if (mouse_on_rect(co, marker->pos, marker->search_min, marker->search_max, epsx, epsy)) {
return TRACK_AREA_SEARCH;
+ }
}
if ((marker->flag & MARKER_DISABLED) == 0) {
- if (sc->flag & SC_SHOW_MARKER_PATTERN)
- if (mouse_on_crns(co, marker->pos, marker->pattern_corners, epsx, epsy))
+ if (sc->flag & SC_SHOW_MARKER_PATTERN) {
+ if (mouse_on_crns(co, marker->pos, marker->pattern_corners, epsx, epsy)) {
return TRACK_AREA_PAT;
+ }
+ }
epsx = 12.0f / width;
epsy = 12.0f / height;
@@ -204,12 +209,14 @@ static MovieTrackingTrack *find_nearest_track(SpaceClip *sc,
(co[1] - marker->pos[1] - cur->offset[1]) * (co[1] - marker->pos[1] - cur->offset[1]));
/* distance to pattern boundbox */
- if (sc->flag & SC_SHOW_MARKER_PATTERN)
+ if (sc->flag & SC_SHOW_MARKER_PATTERN) {
d2 = dist_to_crns(co, marker->pos, marker->pattern_corners);
+ }
/* distance to search boundbox */
- if (sc->flag & SC_SHOW_MARKER_SEARCH && TRACK_VIEW_SELECTED(sc, cur))
+ if (sc->flag & SC_SHOW_MARKER_SEARCH && TRACK_VIEW_SELECTED(sc, cur)) {
d3 = dist_to_rect(co, marker->pos, marker->search_min, marker->search_max);
+ }
/* choose minimal distance. useful for cases of overlapped markers. */
dist = min_fff(d1, d2, d3);
@@ -305,8 +312,9 @@ static int mouse_select(bContext *C, float co[2], int extend)
if (track) {
int area = track_mouse_area(C, co, track);
- if (!extend || !TRACK_VIEW_SELECTED(sc, track))
+ if (!extend || !TRACK_VIEW_SELECTED(sc, track)) {
area = TRACK_AREA_ALL;
+ }
if (extend && TRACK_AREA_SELECTED(track, area)) {
if (track == act_track) {
@@ -318,8 +326,9 @@ static int mouse_select(bContext *C, float co[2], int extend)
}
}
else {
- if (area == TRACK_AREA_POINT)
+ if (area == TRACK_AREA_POINT) {
area = TRACK_AREA_ALL;
+ }
BKE_tracking_track_select(tracksbase, track, area, extend);
clip->tracking.act_track = track;
@@ -584,10 +593,12 @@ static int do_lasso_select_marker(bContext *C,
if (BLI_rcti_isect_pt(&rect, screen_co[0], screen_co[1]) &&
BLI_lasso_is_point_inside(mcords, moves, screen_co[0], screen_co[1], V2D_IS_CLIPPED)) {
- if (select)
+ if (select) {
BKE_tracking_track_flag_set(track, TRACK_AREA_ALL, SELECT);
- else
+ }
+ else {
BKE_tracking_track_flag_clear(track, TRACK_AREA_ALL, SELECT);
+ }
}
changed = true;
@@ -820,8 +831,9 @@ static int select_all_exec(bContext *C, wmOperator *op)
ED_clip_select_all(sc, action, &has_selection);
- if (!has_selection)
+ if (!has_selection) {
sc->flag &= ~SC_LOCK_SELECTION;
+ }
BKE_tracking_dopesheet_tag_update(tracking);
@@ -888,8 +900,9 @@ static int select_grouped_exec(bContext *C, wmOperator *op)
if (act_track) {
ok = (track->flag & TRACK_CUSTOMCOLOR) == (act_track->flag & TRACK_CUSTOMCOLOR);
- if (ok && track->flag & TRACK_CUSTOMCOLOR)
+ if (ok && track->flag & TRACK_CUSTOMCOLOR) {
ok = equals_v3v3(track->color, act_track->color);
+ }
}
}
else if (group == 6) { /* failed */
@@ -898,10 +911,12 @@ static int select_grouped_exec(bContext *C, wmOperator *op)
if (ok) {
track->flag |= SELECT;
- if (sc->flag & SC_SHOW_MARKER_PATTERN)
+ if (sc->flag & SC_SHOW_MARKER_PATTERN) {
track->pat_flag |= SELECT;
- if (sc->flag & SC_SHOW_MARKER_SEARCH)
+ }
+ if (sc->flag & SC_SHOW_MARKER_SEARCH) {
track->search_flag |= SELECT;
+ }
}
track = track->next;
diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c
index 3245cbf2a29..bb8680682d2 100644
--- a/source/blender/editors/space_file/file_draw.c
+++ b/source/blender/editors/space_file/file_draw.c
@@ -193,8 +193,9 @@ void file_draw_buttons(const bContext *C, ARegion *ar)
/* TODO, directory editing is non-functional while a library is loaded
* until this is properly supported just disable it. */
- if (sfile->files && filelist_lib(sfile->files))
+ if (sfile->files && filelist_lib(sfile->files)) {
UI_but_flag_enable(but, UI_BUT_DISABLED);
+ }
if ((params->flag & FILE_DIRSEL_ONLY) == 0) {
but = uiDefBut(
@@ -660,8 +661,9 @@ void file_draw_list(const bContext *C, ARegion *ar)
}
offset = ED_fileselect_layout_offset(layout, (int)ar->v2d.cur.xmin, (int)-ar->v2d.cur.ymax);
- if (offset < 0)
+ if (offset < 0) {
offset = 0;
+ }
numfiles_layout = ED_fileselect_layout_numfiles(layout, ar);
diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c
index 2f1671aefa7..7d3a042d75a 100644
--- a/source/blender/editors/space_file/file_ops.c
+++ b/source/blender/editors/space_file/file_ops.c
@@ -119,8 +119,9 @@ static void clamp_to_filelist(int numfiles, FileSelection *sel)
}
/* fix if last file invalid */
- if ((sel->first > 0) && (sel->last < 0))
+ if ((sel->first > 0) && (sel->last < 0)) {
sel->last = numfiles - 1;
+ }
/* clamp */
if ((sel->first >= numfiles)) {
@@ -148,8 +149,9 @@ static FileSelection file_selection_get(bContext *C, const rcti *rect, bool fill
int f;
/* Try to find a smaller-index selected item. */
for (f = sel.last; f >= 0; f--) {
- if (filelist_entry_select_index_get(sfile->files, f, CHECK_ALL))
+ if (filelist_entry_select_index_get(sfile->files, f, CHECK_ALL)) {
break;
+ }
}
if (f >= 0) {
sel.first = f + 1;
@@ -157,8 +159,9 @@ static FileSelection file_selection_get(bContext *C, const rcti *rect, bool fill
/* If none found, try to find a higher-index selected item. */
else {
for (f = sel.first; f < numfiles; f++) {
- if (filelist_entry_select_index_get(sfile->files, f, CHECK_ALL))
+ if (filelist_entry_select_index_get(sfile->files, f, CHECK_ALL)) {
break;
+ }
}
if (f < numfiles) {
sel.last = f - 1;
@@ -298,8 +301,9 @@ static FileSelect file_select(
sfile->files, &sel, select, FILE_SEL_SELECTED, check_type);
/* Don't act on multiple selected files */
- if (sel.first != sel.last)
+ if (sel.first != sel.last) {
select = 0;
+ }
/* Do we have a valid selection and are we actually selecting */
if ((sel.last >= 0) && (select != FILE_SEL_REMOVE)) {
@@ -482,14 +486,16 @@ static int file_select_invoke(bContext *C, wmOperator *op, const wmEvent *event)
const bool fill = RNA_boolean_get(op->ptr, "fill");
const bool do_diropen = RNA_boolean_get(op->ptr, "open");
- if (ar->regiontype != RGN_TYPE_WINDOW)
+ if (ar->regiontype != RGN_TYPE_WINDOW) {
return OPERATOR_CANCELLED;
+ }
rect.xmin = rect.xmax = event->mval[0];
rect.ymin = rect.ymax = event->mval[1];
- if (!BLI_rcti_isect_pt(&ar->v2d.mask, rect.xmin, rect.ymin))
+ if (!BLI_rcti_isect_pt(&ar->v2d.mask, rect.xmin, rect.ymin)) {
return OPERATOR_CANCELLED;
+ }
if (sfile && sfile->params) {
int idx = sfile->params->highlight_file;
@@ -512,10 +518,12 @@ static int file_select_invoke(bContext *C, wmOperator *op, const wmEvent *event)
sfile->files, 0, FILE_SEL_REMOVE, FILE_SEL_SELECTED, CHECK_ALL);
}
- if (FILE_SELECT_DIR == ret)
+ if (FILE_SELECT_DIR == ret) {
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL);
- else if (FILE_SELECT_FILE == ret)
+ }
+ else if (FILE_SELECT_FILE == ret) {
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL);
+ }
WM_event_add_mousemove(C); /* for directory changes */
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL);
@@ -1149,8 +1157,9 @@ int file_highlight_set(SpaceFile *sfile, ARegion *ar, int mx, int my)
FileSelectParams *params;
int numfiles, origfile;
- if (sfile == NULL || sfile->files == NULL)
+ if (sfile == NULL || sfile->files == NULL) {
return 0;
+ }
numfiles = filelist_files_ensure(sfile->files);
params = ED_fileselect_get_params(sfile);
@@ -1169,13 +1178,16 @@ int file_highlight_set(SpaceFile *sfile, ARegion *ar, int mx, int my)
highlight_file = ED_fileselect_layout_offset(
sfile->layout, (int)(v2d->tot.xmin + fx), (int)(v2d->tot.ymax - fy));
- if ((highlight_file >= 0) && (highlight_file < numfiles))
+ if ((highlight_file >= 0) && (highlight_file < numfiles)) {
params->highlight_file = highlight_file;
- else
+ }
+ else {
params->highlight_file = -1;
+ }
}
- else
+ else {
params->highlight_file = -1;
+ }
return (params->highlight_file != origfile);
}
@@ -1185,8 +1197,9 @@ static int file_highlight_invoke(bContext *C, wmOperator *UNUSED(op), const wmEv
ARegion *ar = CTX_wm_region(C);
SpaceFile *sfile = CTX_wm_space_file(C);
- if (!file_highlight_set(sfile, ar, event->x, event->y))
+ if (!file_highlight_set(sfile, ar, event->x, event->y)) {
return OPERATOR_PASS_THROUGH;
+ }
ED_area_tag_redraw(CTX_wm_area(C));
@@ -1223,8 +1236,9 @@ static bool file_operator_poll(bContext *C)
bool poll = ED_operator_file_active(C);
SpaceFile *sfile = CTX_wm_space_file(C);
- if (!sfile || !sfile->op)
+ if (!sfile || !sfile->op) {
poll = 0;
+ }
return poll;
}
@@ -1459,8 +1473,9 @@ int file_exec(bContext *C, wmOperator *exec_op)
break;
}
}
- if (active == 0)
+ if (active == 0) {
return OPERATOR_CANCELLED;
+ }
}
sfile->op = NULL;
@@ -1575,8 +1590,9 @@ int file_previous_exec(bContext *C, wmOperator *UNUSED(unused))
SpaceFile *sfile = CTX_wm_space_file(C);
if (sfile->params) {
- if (!sfile->folders_next)
+ if (!sfile->folders_next) {
sfile->folders_next = folderlist_new();
+ }
folderlist_pushdir(sfile->folders_next, sfile->params->dir);
folderlist_popdir(sfile->folders_prev, sfile->params->dir);
@@ -1605,8 +1621,9 @@ int file_next_exec(bContext *C, wmOperator *UNUSED(unused))
{
SpaceFile *sfile = CTX_wm_space_file(C);
if (sfile->params) {
- if (!sfile->folders_next)
+ if (!sfile->folders_next) {
sfile->folders_next = folderlist_new();
+ }
folderlist_pushdir(sfile->folders_prev, sfile->params->dir);
folderlist_popdir(sfile->folders_next, sfile->params->dir);
@@ -1633,8 +1650,9 @@ static int file_smoothscroll_invoke(bContext *C, wmOperator *UNUSED(op), const w
int i;
/* escape if not our timer */
- if (sfile->smoothscroll_timer == NULL || sfile->smoothscroll_timer != event->customdata)
+ if (sfile->smoothscroll_timer == NULL || sfile->smoothscroll_timer != event->customdata) {
return OPERATOR_PASS_THROUGH;
+ }
numfiles = filelist_files_ensure(sfile->files);
@@ -1683,13 +1701,15 @@ static int file_smoothscroll_invoke(bContext *C, wmOperator *UNUSED(op), const w
if (sfile->scroll_offset == 0) {
if (sfile->layout->flag & FILE_LAYOUT_HOR) {
sfile->scroll_offset = (edit_idx / sfile->layout->rows) * sfile->layout->rows;
- if (sfile->scroll_offset <= offset)
+ if (sfile->scroll_offset <= offset) {
sfile->scroll_offset -= sfile->layout->rows;
+ }
}
else {
sfile->scroll_offset = (edit_idx / sfile->layout->columns) * sfile->layout->columns;
- if (sfile->scroll_offset <= offset)
+ if (sfile->scroll_offset <= offset) {
sfile->scroll_offset -= sfile->layout->columns;
+ }
}
}
@@ -2030,8 +2050,9 @@ void file_directory_enter_handle(bContext *C, void *UNUSED(arg_unused), void *UN
#if defined(WIN32)
else if (!can_create_dir(sfile->params->dir)) {
const char *lastdir = folderlist_peeklastdir(sfile->folders_prev);
- if (lastdir)
+ if (lastdir) {
BLI_strncpy(sfile->params->dir, lastdir, sizeof(sfile->params->dir));
+ }
}
#endif
else {
@@ -2050,8 +2071,9 @@ void file_directory_enter_handle(bContext *C, void *UNUSED(arg_unused), void *UN
RNA_string_set(&ptr, "directory", sfile->params->dir);
RNA_boolean_set(&ptr, "open", true);
- if (lastdir)
+ if (lastdir) {
BLI_strncpy(sfile->params->dir, lastdir, sizeof(sfile->params->dir));
+ }
WM_operator_name_call_ptr(C, ot, WM_OP_INVOKE_DEFAULT, &ptr);
WM_operator_properties_free(&ptr);
@@ -2153,15 +2175,17 @@ ARegion *file_tools_region(ScrArea *sa)
{
ARegion *ar, *arnew;
- if ((ar = BKE_area_find_region_type(sa, RGN_TYPE_TOOLS)) != NULL)
+ if ((ar = BKE_area_find_region_type(sa, RGN_TYPE_TOOLS)) != NULL) {
return ar;
+ }
/* add subdiv level; after header */
ar = BKE_area_find_region_type(sa, RGN_TYPE_HEADER);
/* is error! */
- if (ar == NULL)
+ if (ar == NULL) {
return NULL;
+ }
arnew = MEM_callocN(sizeof(ARegion), "tools for file");
BLI_insertlinkafter(&sa->regionbase, ar, arnew);
@@ -2181,8 +2205,9 @@ static int file_bookmark_toggle_exec(bContext *C, wmOperator *UNUSED(unused))
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = file_tools_region(sa);
- if (ar)
+ if (ar) {
ED_region_toggle_hidden(C, ar);
+ }
return OPERATOR_FINISHED;
}
@@ -2224,8 +2249,9 @@ static void filenum_newname(char *name, size_t name_size, int add)
}
pic += add;
- if (pic < 0)
+ if (pic < 0) {
pic = 0;
+ }
BLI_stringenc(name_temp, head, tail, digits, pic);
BLI_strncpy(name, name_temp, name_size);
}
@@ -2340,8 +2366,9 @@ static bool file_delete_poll(bContext *C)
int i;
int num_selected = 0;
- if (filelist_islibrary(sfile->files, dir, NULL))
+ if (filelist_islibrary(sfile->files, dir, NULL)) {
poll = 0;
+ }
for (i = 0; i < numfiles; i++) {
if (filelist_entry_select_index_get(sfile->files, i, CHECK_FILES)) {
num_selected++;
@@ -2351,8 +2378,9 @@ static bool file_delete_poll(bContext *C)
poll = 0;
}
}
- else
+ else {
poll = 0;
+ }
return poll;
}
diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c
index a6a9f3681fd..564dd0ec81d 100644
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@ -139,8 +139,9 @@ const char *folderlist_peeklastdir(ListBase *folderlist)
{
struct FolderList *folder;
- if (!folderlist->last)
+ if (!folderlist->last) {
return NULL;
+ }
folder = folderlist->last;
return folder->foldername;
@@ -151,14 +152,16 @@ int folderlist_clear_next(struct SpaceFile *sfile)
struct FolderList *folder;
/* if there is no folder_next there is nothing we can clear */
- if (!sfile->folders_next)
+ if (!sfile->folders_next) {
return 0;
+ }
/* if previous_folder, next_folder or refresh_folder operators are executed
* it doesn't clear folder_next */
folder = sfile->folders_prev->last;
- if ((!folder) || (BLI_path_cmp(folder->foldername, sfile->params->dir) == 0))
+ if ((!folder) || (BLI_path_cmp(folder->foldername, sfile->params->dir) == 0)) {
return 0;
+ }
/* eventually clear flist->folders_next */
return 1;
@@ -169,8 +172,9 @@ void folderlist_free(ListBase *folderlist)
{
if (folderlist) {
FolderList *folder;
- for (folder = folderlist->first; folder; folder = folder->next)
+ for (folder = folderlist->first; folder; folder = folder->next) {
MEM_freeN(folder->foldername);
+ }
BLI_freelistN(folderlist);
}
}
@@ -400,14 +404,18 @@ static int compare_direntry_generic(const FileListInternEntry *entry1,
}
/* make sure "." and ".." are always first */
- if (FILENAME_IS_CURRENT(entry1->relpath))
+ if (FILENAME_IS_CURRENT(entry1->relpath)) {
return -1;
- if (FILENAME_IS_CURRENT(entry2->relpath))
+ }
+ if (FILENAME_IS_CURRENT(entry2->relpath)) {
return 1;
- if (FILENAME_IS_PARENT(entry1->relpath))
+ }
+ if (FILENAME_IS_PARENT(entry1->relpath)) {
return -1;
- if (FILENAME_IS_PARENT(entry2->relpath))
+ }
+ if (FILENAME_IS_PARENT(entry2->relpath)) {
return 1;
+ }
return 0;
}
@@ -443,10 +451,12 @@ static int compare_date(void *UNUSED(user_data), const void *a1, const void *a2)
time1 = (int64_t)entry1->st.st_mtime;
time2 = (int64_t)entry2->st.st_mtime;
- if (time1 < time2)
+ if (time1 < time2) {
return 1;
- if (time1 > time2)
+ }
+ if (time1 > time2) {
return -1;
+ }
name1 = entry1->name;
name2 = entry2->name;
@@ -468,10 +478,12 @@ static int compare_size(void *UNUSED(user_data), const void *a1, const void *a2)
size1 = entry1->st.st_size;
size2 = entry2->st.st_size;
- if (size1 < size2)
+ if (size1 < size2) {
return 1;
- if (size1 > size2)
+ }
+ if (size1 > size2) {
return -1;
+ }
name1 = entry1->name;
name2 = entry2->name;
@@ -490,31 +502,41 @@ static int compare_extension(void *UNUSED(user_data), const void *a1, const void
return ret;
}
- if ((entry1->typeflag & FILE_TYPE_BLENDERLIB) && !(entry2->typeflag & FILE_TYPE_BLENDERLIB))
+ if ((entry1->typeflag & FILE_TYPE_BLENDERLIB) && !(entry2->typeflag & FILE_TYPE_BLENDERLIB)) {
return -1;
- if (!(entry1->typeflag & FILE_TYPE_BLENDERLIB) && (entry2->typeflag & FILE_TYPE_BLENDERLIB))
+ }
+ if (!(entry1->typeflag & FILE_TYPE_BLENDERLIB) && (entry2->typeflag & FILE_TYPE_BLENDERLIB)) {
return 1;
+ }
if ((entry1->typeflag & FILE_TYPE_BLENDERLIB) && (entry2->typeflag & FILE_TYPE_BLENDERLIB)) {
- if ((entry1->typeflag & FILE_TYPE_DIR) && !(entry2->typeflag & FILE_TYPE_DIR))
+ if ((entry1->typeflag & FILE_TYPE_DIR) && !(entry2->typeflag & FILE_TYPE_DIR)) {
return 1;
- if (!(entry1->typeflag & FILE_TYPE_DIR) && (entry2->typeflag & FILE_TYPE_DIR))
+ }
+ if (!(entry1->typeflag & FILE_TYPE_DIR) && (entry2->typeflag & FILE_TYPE_DIR)) {
return -1;
- if (entry1->blentype < entry2->blentype)
+ }
+ if (entry1->blentype < entry2->blentype) {
return -1;
- if (entry1->blentype > entry2->blentype)
+ }
+ if (entry1->blentype > entry2->blentype) {
return 1;
+ }
}
else {
const char *sufix1, *sufix2;
- if (!(sufix1 = strstr(entry1->relpath, ".blend.gz")))
+ if (!(sufix1 = strstr(entry1->relpath, ".blend.gz"))) {
sufix1 = strrchr(entry1->relpath, '.');
- if (!(sufix2 = strstr(entry2->relpath, ".blend.gz")))
+ }
+ if (!(sufix2 = strstr(entry2->relpath, ".blend.gz"))) {
sufix2 = strrchr(entry2->relpath, '.');
- if (!sufix1)
+ }
+ if (!sufix1) {
sufix1 = "";
- if (!sufix2)
+ }
+ if (!sufix2) {
sufix2 = "";
+ }
if ((ret = BLI_strcasecmp(sufix1, sufix2))) {
return ret;
@@ -954,28 +976,39 @@ static int filelist_geticon_ex(const int typeflag,
}
}
- if (typeflag & FILE_TYPE_BLENDER)
+ if (typeflag & FILE_TYPE_BLENDER) {
return ICON_FILE_BLEND;
- else if (typeflag & FILE_TYPE_BLENDER_BACKUP)
+ }
+ else if (typeflag & FILE_TYPE_BLENDER_BACKUP) {
return ICON_FILE_BACKUP;
- else if (typeflag & FILE_TYPE_IMAGE)
+ }
+ else if (typeflag & FILE_TYPE_IMAGE) {
return ICON_FILE_IMAGE;
- else if (typeflag & FILE_TYPE_MOVIE)
+ }
+ else if (typeflag & FILE_TYPE_MOVIE) {
return ICON_FILE_MOVIE;
- else if (typeflag & FILE_TYPE_PYSCRIPT)
+ }
+ else if (typeflag & FILE_TYPE_PYSCRIPT) {
return ICON_FILE_SCRIPT;
- else if (typeflag & FILE_TYPE_SOUND)
+ }
+ else if (typeflag & FILE_TYPE_SOUND) {
return ICON_FILE_SOUND;
- else if (typeflag & FILE_TYPE_FTFONT)
+ }
+ else if (typeflag & FILE_TYPE_FTFONT) {
return ICON_FILE_FONT;
- else if (typeflag & FILE_TYPE_BTX)
+ }
+ else if (typeflag & FILE_TYPE_BTX) {
return ICON_FILE_BLANK;
- else if (typeflag & FILE_TYPE_COLLADA)
+ }
+ else if (typeflag & FILE_TYPE_COLLADA) {
return ICON_FILE_BLANK;
- else if (typeflag & FILE_TYPE_ALEMBIC)
+ }
+ else if (typeflag & FILE_TYPE_ALEMBIC) {
return ICON_FILE_BLANK;
- else if (typeflag & FILE_TYPE_TEXT)
+ }
+ else if (typeflag & FILE_TYPE_TEXT) {
return ICON_FILE_TEXT;
+ }
else if (typeflag & FILE_TYPE_BLENDERLIB) {
const int ret = UI_idcode_icon_get(blentype);
if (ret != ICON_NONE) {
@@ -1424,8 +1457,9 @@ void filelist_free(struct FileList *filelist)
void filelist_freelib(struct FileList *filelist)
{
- if (filelist->libfiledata)
+ if (filelist->libfiledata) {
BLO_blendhandle_close(filelist->libfiledata);
+ }
filelist->libfiledata = NULL;
}
@@ -2044,14 +2078,16 @@ static bool file_is_blend_backup(const char *str)
else {
const char *loc;
- if (a > b + 1)
+ if (a > b + 1) {
b++;
+ }
/* allow .blend1 .blend2 .blend32 */
loc = BLI_strcasestr(str + a - b, ".blend");
- if (loc)
+ if (loc) {
retval = 1;
+ }
}
return (retval);
@@ -2274,8 +2310,9 @@ static int groupname_to_code(const char *group)
BLI_strncpy(buf, group, sizeof(buf));
lslash = (char *)BLI_last_slash(buf);
- if (lslash)
+ if (lslash) {
lslash[0] = '\0';
+ }
return buf[0] ? BKE_idcode_from_name(buf) : 0;
}
diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c
index 9261c954bb6..e5f19f0164d 100644
--- a/source/blender/editors/space_file/filesel.c
+++ b/source/blender/editors/space_file/filesel.c
@@ -161,32 +161,45 @@ short ED_fileselect_set_params(SpaceFile *sfile)
}
params->filter = 0;
- if ((prop = RNA_struct_find_property(op->ptr, "filter_blender")))
+ if ((prop = RNA_struct_find_property(op->ptr, "filter_blender"))) {
params->filter |= RNA_property_boolean_get(op->ptr, prop) ? FILE_TYPE_BLENDER : 0;
- if ((prop = RNA_struct_find_property(op->ptr, "filter_blenlib")))
+ }
+ if ((prop = RNA_struct_find_property(op->ptr, "filter_blenlib"))) {
params->filter |= RNA_property_boolean_get(op->ptr, prop) ? FILE_TYPE_BLENDERLIB : 0;
- if ((prop = RNA_struct_find_property(op->ptr, "filter_backup")))
+ }
+ if ((prop = RNA_struct_find_property(op->ptr, "filter_backup"))) {
params->filter |= RNA_property_boolean_get(op->ptr, prop) ? FILE_TYPE_BLENDER_BACKUP : 0;
- if ((prop = RNA_struct_find_property(op->ptr, "filter_image")))
+ }
+ if ((prop = RNA_struct_find_property(op->ptr, "filter_image"))) {
params->filter |= RNA_property_boolean_get(op->ptr, prop) ? FILE_TYPE_IMAGE : 0;
- if ((prop = RNA_struct_find_property(op->ptr, "filter_movie")))
+ }
+ if ((prop = RNA_struct_find_property(op->ptr, "filter_movie"))) {
params->filter |= RNA_property_boolean_get(op->ptr, prop) ? FILE_TYPE_MOVIE : 0;
- if ((prop = RNA_struct_find_property(op->ptr, "filter_python")))
+ }
+ if ((prop = RNA_struct_find_property(op->ptr, "filter_python"))) {
params->filter |= RNA_property_boolean_get(op->ptr, prop) ? FILE_TYPE_PYSCRIPT : 0;
- if ((prop = RNA_struct_find_property(op->ptr, "filter_font")))
+ }
+ if ((prop = RNA_struct_find_property(op->ptr, "filter_font"))) {
params->filter |= RNA_property_boolean_get(op->ptr, prop) ? FILE_TYPE_FTFONT : 0;
- if ((prop = RNA_struct_find_property(op->ptr, "filter_sound")))
+ }
+ if ((prop = RNA_struct_find_property(op->ptr, "filter_sound"))) {
params->filter |= RNA_property_boolean_get(op->ptr, prop) ? FILE_TYPE_SOUND : 0;
- if ((prop = RNA_struct_find_property(op->ptr, "filter_text")))
+ }
+ if ((prop = RNA_struct_find_property(op->ptr, "filter_text"))) {
params->filter |= RNA_property_boolean_get(op->ptr, prop) ? FILE_TYPE_TEXT : 0;
- if ((prop = RNA_struct_find_property(op->ptr, "filter_folder")))
+ }
+ if ((prop = RNA_struct_find_property(op->ptr, "filter_folder"))) {
params->filter |= RNA_property_boolean_get(op->ptr, prop) ? FILE_TYPE_FOLDER : 0;
- if ((prop = RNA_struct_find_property(op->ptr, "filter_btx")))
+ }
+ if ((prop = RNA_struct_find_property(op->ptr, "filter_btx"))) {
params->filter |= RNA_property_boolean_get(op->ptr, prop) ? FILE_TYPE_BTX : 0;
- if ((prop = RNA_struct_find_property(op->ptr, "filter_collada")))
+ }
+ if ((prop = RNA_struct_find_property(op->ptr, "filter_collada"))) {
params->filter |= RNA_property_boolean_get(op->ptr, prop) ? FILE_TYPE_COLLADA : 0;
- if ((prop = RNA_struct_find_property(op->ptr, "filter_alembic")))
+ }
+ if ((prop = RNA_struct_find_property(op->ptr, "filter_alembic"))) {
params->filter |= RNA_property_boolean_get(op->ptr, prop) ? FILE_TYPE_ALEMBIC : 0;
+ }
if ((prop = RNA_struct_find_property(op->ptr, "filter_glob"))) {
/* Protection against pyscripts not setting proper size limit... */
char *tmp = RNA_property_string_get_alloc(
@@ -290,8 +303,9 @@ short ED_fileselect_set_params(SpaceFile *sfile)
params->active_file = -1;
/* initialize the list with previous folders */
- if (!sfile->folders_prev)
+ if (!sfile->folders_prev) {
sfile->folders_prev = folderlist_new();
+ }
if (!sfile->params->dir[0]) {
if (blendfile_path[0] != '\0') {
@@ -375,8 +389,9 @@ FileSelection ED_fileselect_layout_offset_rect(FileLayout *layout, const rcti *r
FileSelection sel;
sel.first = sel.last = -1;
- if (layout == NULL)
+ if (layout == NULL) {
return sel;
+ }
colmin = (rect->xmin) / (layout->tile_w + 2 * layout->tile_border_x);
rowmin = (rect->ymin) / (layout->tile_h + 2 * layout->tile_border_y);
@@ -395,19 +410,23 @@ FileSelection ED_fileselect_layout_offset_rect(FileLayout *layout, const rcti *r
sel.first = -1;
}
else {
- if (layout->flag & FILE_LAYOUT_HOR)
+ if (layout->flag & FILE_LAYOUT_HOR) {
sel.first = layout->rows * colmin + rowmin;
- else
+ }
+ else {
sel.first = colmin + layout->columns * rowmin;
+ }
}
if ((colmax > layout->columns - 1) || (rowmax > layout->rows - 1)) {
sel.last = -1;
}
else {
- if (layout->flag & FILE_LAYOUT_HOR)
+ if (layout->flag & FILE_LAYOUT_HOR) {
sel.last = layout->rows * colmax + rowmax;
- else
+ }
+ else {
sel.last = colmax + layout->columns * rowmax;
+ }
}
return sel;
@@ -418,21 +437,26 @@ int ED_fileselect_layout_offset(FileLayout *layout, int x, int y)
int offsetx, offsety;
int active_file;
- if (layout == NULL)
+ if (layout == NULL) {
return -1;
+ }
offsetx = (x) / (layout->tile_w + 2 * layout->tile_border_x);
offsety = (y) / (layout->tile_h + 2 * layout->tile_border_y);
- if (offsetx > layout->columns - 1)
+ if (offsetx > layout->columns - 1) {
return -1;
- if (offsety > layout->rows - 1)
+ }
+ if (offsety > layout->rows - 1) {
return -1;
+ }
- if (layout->flag & FILE_LAYOUT_HOR)
+ if (layout->flag & FILE_LAYOUT_HOR) {
active_file = layout->rows * offsetx + offsety;
- else
+ }
+ else {
active_file = offsetx + layout->columns * offsety;
+ }
return active_file;
}
@@ -536,8 +560,9 @@ void ED_fileselect_init_layout(struct SpaceFile *sfile, ARegion *ar)
layout->tile_h = layout->prv_h + 2 * layout->prv_border_y + textheight;
layout->width = (int)(BLI_rctf_size_x(&v2d->cur) - 2 * layout->tile_border_x);
layout->columns = layout->width / (layout->tile_w + 2 * layout->tile_border_x);
- if (layout->columns > 0)
+ if (layout->columns > 0) {
layout->rows = numfiles / layout->columns + 1; // XXX dirty, modulo is zero
+ }
else {
layout->columns = 1;
layout->rows = numfiles + 1; // XXX dirty, modulo is zero
@@ -577,8 +602,9 @@ void ED_fileselect_init_layout(struct SpaceFile *sfile, ARegion *ar)
(int)layout->column_widths[COLUMN_SIZE] + column_space;
}
layout->tile_w = maxlen;
- if (layout->rows > 0)
+ if (layout->rows > 0) {
layout->columns = numfiles / layout->rows + 1; // XXX dirty, modulo is zero
+ }
else {
layout->rows = 1;
layout->columns = numfiles + 1; // XXX dirty, modulo is zero
@@ -619,8 +645,9 @@ void ED_file_change_dir(bContext *C)
}
filelist_setdir(sfile->files, sfile->params->dir);
- if (folderlist_clear_next(sfile))
+ if (folderlist_clear_next(sfile)) {
folderlist_free(sfile->folders_next);
+ }
folderlist_pushdir(sfile->folders_prev, sfile->params->dir);
@@ -739,8 +766,9 @@ void ED_fileselect_clear(wmWindowManager *wm, ScrArea *sa, SpaceFile *sfile)
void ED_fileselect_exit(wmWindowManager *wm, ScrArea *sa, SpaceFile *sfile)
{
- if (!sfile)
+ if (!sfile) {
return;
+ }
if (sfile->op) {
WM_event_fileselect_event(wm, sfile->op, EVT_FILESELECT_EXTERNAL_CANCEL);
sfile->op = NULL;
diff --git a/source/blender/editors/space_file/fsmenu.c b/source/blender/editors/space_file/fsmenu.c
index f1030a93dc2..982c663cd18 100644
--- a/source/blender/editors/space_file/fsmenu.c
+++ b/source/blender/editors/space_file/fsmenu.c
@@ -351,8 +351,9 @@ void fsmenu_remove_entry(struct FSMenu *fsmenu, FSMenuCategory category, int idx
fsm_head = ED_fsmenu_get_category(fsmenu, category);
- for (fsm_iter = fsm_head; fsm_iter && idx; fsm_prev = fsm_iter, fsm_iter = fsm_iter->next)
+ for (fsm_iter = fsm_head; fsm_iter && idx; fsm_prev = fsm_iter, fsm_iter = fsm_iter->next) {
idx--;
+ }
if (fsm_iter) {
/* you should only be able to remove entries that were
@@ -382,8 +383,9 @@ void fsmenu_write_file(struct FSMenu *fsmenu, const char *filename)
int nwritten = 0;
FILE *fp = BLI_fopen(filename, "w");
- if (!fp)
+ if (!fp) {
return;
+ }
fprintf(fp, "[Bookmarks]\n");
for (fsm_iter = ED_fsmenu_get_category(fsmenu, FS_CATEGORY_BOOKMARKS); fsm_iter;
@@ -419,8 +421,9 @@ void fsmenu_read_bookmarks(struct FSMenu *fsmenu, const char *filename)
FILE *fp;
fp = BLI_fopen(filename, "r");
- if (!fp)
+ if (!fp) {
return;
+ }
name[0] = '\0';
@@ -533,8 +536,9 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks)
char defPath[FILE_MAX];
result = CFURLEnumeratorGetNextURL(volEnum, &cfURL, NULL);
- if (result != kCFURLEnumeratorSuccess)
+ if (result != kCFURLEnumeratorSuccess) {
continue;
+ }
CFURLGetFileSystemRepresentation(cfURL, false, (UInt8 *)defPath, FILE_MAX);
@@ -564,14 +568,16 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks)
kLSSharedFileListDoNotMountVolumes,
&cfURL,
NULL);
- if (err != noErr || !cfURL)
+ if (err != noErr || !cfURL) {
continue;
+ }
CFStringRef pathString = CFURLCopyFileSystemPath(cfURL, kCFURLPOSIXPathStyle);
if (pathString == NULL ||
- !CFStringGetCString(pathString, line, sizeof(line), kCFStringEncodingUTF8))
+ !CFStringGetCString(pathString, line, sizeof(line), kCFStringEncodingUTF8)) {
continue;
+ }
/* Add end slash for consistency with other platforms */
BLI_add_slash(line);
@@ -677,8 +683,9 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks)
# endif
/* fallback */
- if (!found)
+ if (!found) {
fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, "/", NULL, FS_INSERT_SORTED);
+ }
}
}
# endif
diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c
index 53bcf7068f4..e0d370cdde2 100644
--- a/source/blender/editors/space_file/space_file.c
+++ b/source/blender/editors/space_file/space_file.c
@@ -155,8 +155,9 @@ static void file_init(wmWindowManager *UNUSED(wm), ScrArea *sa)
*/
fsmenu_refresh_bookmarks_status(ED_fsmenu_get());
- if (sfile->layout)
+ if (sfile->layout) {
sfile->layout->dirty = true;
+ }
}
static void file_exit(wmWindowManager *wm, ScrArea *sa)
@@ -188,11 +189,13 @@ static SpaceLink *file_duplicate(SpaceLink *sl)
filelist_setdir(sfilen->files, sfilen->params->dir);
}
- if (sfileo->folders_prev)
+ if (sfileo->folders_prev) {
sfilen->folders_prev = folderlist_duplicate(sfileo->folders_prev);
+ }
- if (sfileo->folders_next)
+ if (sfileo->folders_next) {
sfilen->folders_next = folderlist_duplicate(sfileo->folders_next);
+ }
if (sfileo->layout) {
sfilen->layout = MEM_dupallocN(sfileo->layout);
@@ -389,8 +392,9 @@ static void file_main_region_draw(const bContext *C, ARegion *ar)
float col[3];
/* Needed, because filelist is not initialized on loading */
- if (!sfile->files || filelist_empty(sfile->files))
+ if (!sfile->files || filelist_empty(sfile->files)) {
file_refresh(C, NULL);
+ }
/* clear and setup matrix */
UI_GetThemeColor3fv(TH_BACK, col);
diff --git a/source/blender/editors/space_graph/graph_buttons.c b/source/blender/editors/space_graph/graph_buttons.c
index f8f75234852..3b1e70b8db7 100644
--- a/source/blender/editors/space_graph/graph_buttons.c
+++ b/source/blender/editors/space_graph/graph_buttons.c
@@ -81,20 +81,25 @@ static int graph_panel_context(const bContext *C, bAnimListElem **ale, FCurve **
* to work correctly is able to be correctly retrieved.
* There's no point showing empty panels?
*/
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return 0;
+ }
/* try to find 'active' F-Curve */
elem = get_active_fcurve_channel(&ac);
- if (elem == NULL)
+ if (elem == NULL) {
return 0;
+ }
- if (fcu)
+ if (fcu) {
*fcu = (FCurve *)elem->data;
- if (ale)
+ }
+ if (ale) {
*ale = elem;
- else
+ }
+ else {
MEM_freeN(elem);
+ }
return 1;
}
@@ -130,10 +135,12 @@ static void graph_panel_view(const bContext *C, Panel *pa)
sub = uiLayoutColumn(col, true);
uiLayoutSetActive(sub, RNA_boolean_get(&spaceptr, "show_cursor"));
row = uiLayoutSplit(sub, 0.7f, true);
- if (sipo->mode == SIPO_MODE_DRIVERS)
+ if (sipo->mode == SIPO_MODE_DRIVERS) {
uiItemR(row, &spaceptr, "cursor_position_x", 0, IFACE_("Cursor X"), ICON_NONE);
- else
+ }
+ else {
uiItemR(row, &sceneptr, "frame_current", 0, IFACE_("Cursor X"), ICON_NONE);
+ }
uiItemEnumO(row, "GRAPH_OT_snap", IFACE_("To Keys"), 0, "type", GRAPHKEYS_SNAP_CFRA);
row = uiLayoutSplit(sub, 0.7f, true);
@@ -153,8 +160,9 @@ static void graph_panel_properties(const bContext *C, Panel *pa)
char name[256];
int icon = 0;
- if (!graph_panel_context(C, &ale, &fcu))
+ if (!graph_panel_context(C, &ale, &fcu)) {
return;
+ }
/* F-Curve pointer */
RNA_pointer_create(ale->id, &RNA_FCurve, fcu, &fcu_ptr);
@@ -179,8 +187,9 @@ static void graph_panel_properties(const bContext *C, Panel *pa)
}
/* icon */
- if (ale->type == ANIMTYPE_NLACURVE)
+ if (ale->type == ANIMTYPE_NLACURVE) {
icon = ICON_NLA;
+ }
}
uiItemL(col, name, icon);
@@ -221,8 +230,9 @@ static short get_active_fcurve_keyframe_edit(FCurve *fcu, BezTriple **bezt, BezT
*bezt = *prevbezt = NULL;
/* sanity checks */
- if ((fcu->bezt == NULL) || (fcu->totvert == 0))
+ if ((fcu->bezt == NULL) || (fcu->totvert == 0)) {
return 0;
+ }
/* find first selected keyframe for now, and call it the active one
* - this is a reasonable assumption, given that whenever anyone
@@ -332,8 +342,9 @@ static void graph_panel_key_properties(const bContext *C, Panel *pa)
uiLayout *col;
uiBlock *block;
- if (!graph_panel_context(C, &ale, &fcu))
+ if (!graph_panel_context(C, &ale, &fcu)) {
return;
+ }
block = uiLayoutGetBlock(layout);
/* UI_block_func_handle_set(block, do_graph_region_buttons, NULL); */
@@ -367,8 +378,9 @@ static void graph_panel_key_properties(const bContext *C, Panel *pa)
}
/* easing type */
- if (bezt->ipo > BEZT_IPO_BEZ)
+ if (bezt->ipo > BEZT_IPO_BEZ) {
uiItemR(col, &bezt_ptr, "easing", 0, NULL, 0);
+ }
/* easing extra */
switch (bezt->ipo) {
@@ -567,8 +579,9 @@ static void graph_panel_key_properties(const bContext *C, Panel *pa)
IFACE_("F-Curve doesn't have any keyframes as it only contains sampled points"),
ICON_NONE);
}
- else
+ else {
uiItemL(layout, IFACE_("No active keyframe on F-Curve"), ICON_NONE);
+ }
}
MEM_freeN(ale);
@@ -695,8 +708,9 @@ static bool graph_panel_drivers_poll(const bContext *C, PanelType *UNUSED(pt))
{
SpaceGraph *sipo = CTX_wm_space_graph(C);
- if (sipo->mode != SIPO_MODE_DRIVERS)
+ if (sipo->mode != SIPO_MODE_DRIVERS) {
return 0;
+ }
return graph_panel_context(C, NULL, NULL);
}
@@ -969,8 +983,9 @@ static void graph_draw_driver_settings_panel(uiLayout *layout,
col = uiLayoutColumn(layout, true);
block = uiLayoutGetBlock(col);
- if (driver->flag & DRIVER_FLAG_INVALID)
+ if (driver->flag & DRIVER_FLAG_INVALID) {
uiItemL(col, IFACE_("ERROR: Invalid target channel(s)"), ICON_ERROR);
+ }
/* Warnings about a lack of variables
* NOTE: The lack of variables is generally a bad thing, since it indicates
@@ -1201,8 +1216,9 @@ static void graph_panel_driven_property(const bContext *C, Panel *pa)
bAnimListElem *ale;
FCurve *fcu;
- if (!graph_panel_context(C, &ale, &fcu))
+ if (!graph_panel_context(C, &ale, &fcu)) {
return;
+ }
graph_draw_driven_property_panel(pa->layout, ale->id, fcu);
@@ -1217,8 +1233,9 @@ static void graph_panel_drivers(const bContext *C, Panel *pa)
FCurve *fcu;
/* Get settings from context */
- if (!graph_panel_context(C, &ale, &fcu))
+ if (!graph_panel_context(C, &ale, &fcu)) {
return;
+ }
graph_draw_driver_settings_panel(pa->layout, ale->id, fcu, false);
@@ -1306,8 +1323,9 @@ static void graph_panel_modifiers(const bContext *C, Panel *pa)
uiBlock *block;
bool active;
- if (!graph_panel_context(C, &ale, &fcu))
+ if (!graph_panel_context(C, &ale, &fcu)) {
return;
+ }
block = uiLayoutGetBlock(pa->layout);
UI_block_func_handle_set(block, do_graph_region_modifier_buttons, NULL);
diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c
index 3c41b076738..eb392538d23 100644
--- a/source/blender/editors/space_graph/graph_draw.c
+++ b/source/blender/editors/space_graph/graph_draw.c
@@ -185,8 +185,9 @@ static void draw_fcurve_selected_keyframe_vertices(
* - only draw those with correct selection state for the current drawing color
* -
*/
- if ((bezt->f2 & SELECT) == sel)
+ if ((bezt->f2 & SELECT) == sel) {
immVertex2fv(pos, bezt->vec[1]);
+ }
}
else {
/* no check for selection here, as curve is not editable... */
@@ -360,8 +361,9 @@ static void draw_fcurve_handles(SpaceGraph *sipo, FCurve *fcu)
* check that keyframe is selected
*/
if (sipo->flag & SIPO_SELVHANDLESONLY) {
- if (BEZT_ISSEL_ANY(bezt) == 0)
+ if (BEZT_ISSEL_ANY(bezt) == 0) {
continue;
+ }
}
/* draw handle with appropriate set of colors if selection is ok */
@@ -464,8 +466,9 @@ static void draw_fcurve_samples(SpaceGraph *sipo, ARegion *ar, FCurve *fcu)
/* draw */
if (first && last) {
/* anti-aliased lines for more consistent appearance */
- if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0)
+ if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) {
GPU_line_smooth(true);
+ }
GPU_blend(true);
uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
@@ -479,8 +482,9 @@ static void draw_fcurve_samples(SpaceGraph *sipo, ARegion *ar, FCurve *fcu)
immUnbindProgram();
GPU_blend(false);
- if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0)
+ if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) {
GPU_line_smooth(false);
+ }
}
}
@@ -502,8 +506,9 @@ static void draw_fcurve_curve(
/* when opening a blend file on a different sized screen or while dragging the toolbar this can
* happen best just bail out in this case. */
UI_view2d_grid_size(grid, &dx, &dy);
- if (dx <= 0.0f)
+ if (dx <= 0.0f) {
return;
+ }
/* disable any drivers */
FCurve fcurve_for_draw = *fcu_;
@@ -540,13 +545,15 @@ static void draw_fcurve_curve(
* This one still amounts to 10 sample-frames for each 1-frame interval
* which should be quite a decent approximation in many situations.
*/
- if (samplefreq < 0.1f)
+ if (samplefreq < 0.1f) {
samplefreq = 0.1f;
+ }
}
else {
/* "Higher Precision" but slower - especially on larger windows (e.g. T40372) */
- if (samplefreq < 0.00001f)
+ if (samplefreq < 0.00001f) {
samplefreq = 0.00001f;
+ }
}
/* the start/end times are simply the horizontal extents of the 'cur' rect */
@@ -613,8 +620,9 @@ static void draw_fcurve_curve_samples(
else {
/* extrapolate linear doesn't use the handle, use the next points center instead */
fac = (prevfpt->vec[0] - fpt->vec[0]) / (prevfpt->vec[0] - v[0]);
- if (fac)
+ if (fac) {
fac = 1.0f / fac;
+ }
v[1] = prevfpt->vec[1] - fac * (prevfpt->vec[1] - fpt->vec[1]);
}
@@ -647,8 +655,9 @@ static void draw_fcurve_curve_samples(
/* extrapolate linear doesn't use the handle, use the previous points center instead */
fpt = prevfpt - 1;
fac = (prevfpt->vec[0] - fpt->vec[0]) / (prevfpt->vec[0] - v[0]);
- if (fac)
+ if (fac) {
fac = 1.0f / fac;
+ }
v[1] = prevfpt->vec[1] - fac * (prevfpt->vec[1] - fpt->vec[1]);
}
@@ -716,15 +725,17 @@ static void draw_fcurve_curve_bezts(
else if (prevbezt->ipo == BEZT_IPO_LIN) {
/* extrapolate linear dosnt use the handle, use the next points center instead */
fac = (prevbezt->vec[1][0] - bezt->vec[1][0]) / (prevbezt->vec[1][0] - v1[0]);
- if (fac)
+ if (fac) {
fac = 1.0f / fac;
+ }
v1[1] = prevbezt->vec[1][1] - fac * (prevbezt->vec[1][1] - bezt->vec[1][1]);
}
else {
/* based on angle of handle 1 (relative to keyframe) */
fac = (prevbezt->vec[0][0] - prevbezt->vec[1][0]) / (prevbezt->vec[1][0] - v1[0]);
- if (fac)
+ if (fac) {
fac = 1.0f / fac;
+ }
v1[1] = prevbezt->vec[1][1] - fac * (prevbezt->vec[0][1] - prevbezt->vec[1][1]);
}
@@ -782,8 +793,9 @@ static void draw_fcurve_curve_bezts(
else {
/* clamp resolution to max of 32 */
/* NOTE: higher values will crash */
- if (resol > 32)
+ if (resol > 32) {
resol = 32;
+ }
v1[0] = prevbezt->vec[1][0];
v1[1] = prevbezt->vec[1][1];
@@ -833,15 +845,17 @@ static void draw_fcurve_curve_bezts(
/* extrapolate linear dosnt use the handle, use the previous points center instead */
bezt = prevbezt - 1;
fac = (prevbezt->vec[1][0] - bezt->vec[1][0]) / (prevbezt->vec[1][0] - v1[0]);
- if (fac)
+ if (fac) {
fac = 1.0f / fac;
+ }
v1[1] = prevbezt->vec[1][1] - fac * (prevbezt->vec[1][1] - bezt->vec[1][1]);
}
else {
/* based on angle of handle 1 (relative to keyframe) */
fac = (prevbezt->vec[2][0] - prevbezt->vec[1][0]) / (prevbezt->vec[1][0] - v1[0]);
- if (fac)
+ if (fac) {
fac = 1.0f / fac;
+ }
v1[1] = prevbezt->vec[1][1] - fac * (prevbezt->vec[2][1] - prevbezt->vec[1][1]);
}
@@ -1197,8 +1211,9 @@ void graph_draw_curves(
}
/* undo mapping of keyframes for drawing if scaled F-Curve */
- if (adt)
+ if (adt) {
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 0);
+ }
}
/* free list of curves */
diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c
index a526ada2300..1bb14bc3ce2 100644
--- a/source/blender/editors/space_graph/graph_edit.c
+++ b/source/blender/editors/space_graph/graph_edit.c
@@ -94,14 +94,18 @@ void get_graph_keyframe_extents(bAnimContext *ac,
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
/* set large values initial values that will be easy to override */
- if (xmin)
+ if (xmin) {
*xmin = 999999999.0f;
- if (xmax)
+ }
+ if (xmax) {
*xmax = -999999999.0f;
- if (ymin)
+ }
+ if (ymin) {
*ymin = 999999999.0f;
- if (ymax)
+ }
+ if (ymax) {
*ymax = -999999999.0f;
+ }
/* check if any channels to set range with */
if (anim_data.first) {
@@ -132,14 +136,18 @@ void get_graph_keyframe_extents(bAnimContext *ac,
tymax *= unitFac;
/* try to set cur using these values, if they're more extreme than previously set values */
- if ((xmin) && (txmin < *xmin))
+ if ((xmin) && (txmin < *xmin)) {
*xmin = txmin;
- if ((xmax) && (txmax > *xmax))
+ }
+ if ((xmax) && (txmax > *xmax)) {
*xmax = txmax;
- if ((ymin) && (tymin < *ymin))
+ }
+ if ((ymin) && (tymin < *ymin)) {
*ymin = tymin;
- if ((ymax) && (tymax > *ymax))
+ }
+ if ((ymax) && (tymax > *ymax)) {
*ymax = tymax;
+ }
foundBounds = true;
}
@@ -157,14 +165,18 @@ void get_graph_keyframe_extents(bAnimContext *ac,
}
}
else {
- if (xmin)
+ if (xmin) {
*xmin = (float)PSFRA;
- if (xmax)
+ }
+ if (xmax) {
*xmax = (float)PEFRA;
- if (ymin)
+ }
+ if (ymin) {
*ymin = -5;
- if (ymax)
+ }
+ if (ymax) {
*ymax = 5;
+ }
}
/* free memory */
@@ -173,22 +185,28 @@ void get_graph_keyframe_extents(bAnimContext *ac,
else {
/* set default range */
if (ac->scene) {
- if (xmin)
+ if (xmin) {
*xmin = (float)PSFRA;
- if (xmax)
+ }
+ if (xmax) {
*xmax = (float)PEFRA;
+ }
}
else {
- if (xmin)
+ if (xmin) {
*xmin = -5;
- if (xmax)
+ }
+ if (xmax) {
*xmax = 100;
+ }
}
- if (ymin)
+ if (ymin) {
*ymin = -5;
- if (ymax)
+ }
+ if (ymax) {
*ymax = 5;
+ }
}
}
@@ -201,12 +219,15 @@ static int graphkeys_previewrange_exec(bContext *C, wmOperator *UNUSED(op))
float min, max;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
- if (ac.scene == NULL)
+ }
+ if (ac.scene == NULL) {
return OPERATOR_CANCELLED;
- else
+ }
+ else {
scene = ac.scene;
+ }
/* set the range directly */
get_graph_keyframe_extents(&ac, &min, &max, NULL, NULL, false, false);
@@ -248,8 +269,9 @@ static int graphkeys_viewall(bContext *C,
rctf cur_new;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* set the horizontal range, with an extra offset so that the extreme keys will be in view */
get_graph_keyframe_extents(&ac,
@@ -444,8 +466,9 @@ static int graphkeys_create_ghostcurves_exec(bContext *C, wmOperator *UNUSED(op)
int start, end;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* Ghost curves are snapshots of the visible portions of the curves,
* so set range to be the visible range. */
@@ -489,8 +512,9 @@ static int graphkeys_clear_ghostcurves_exec(bContext *C, wmOperator *UNUSED(op))
SpaceGraph *sipo;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
sipo = (SpaceGraph *)ac.sl;
/* if no ghost curves, don't do anything */
@@ -579,21 +603,26 @@ static void insert_graph_keys(bAnimContext *ac, eGraphKeys_InsertKey_Types mode)
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT |
ANIMFILTER_NODUPLIS);
- if (mode & GRAPHKEYS_INSERTKEY_SEL)
+ if (mode & GRAPHKEYS_INSERTKEY_SEL) {
filter |= ANIMFILTER_SEL;
- else if (mode & GRAPHKEYS_INSERTKEY_ACTIVE)
+ }
+ else if (mode & GRAPHKEYS_INSERTKEY_ACTIVE) {
filter |= ANIMFILTER_ACTIVE;
+ }
num_items = ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
if (num_items == 0) {
- if (mode & GRAPHKEYS_INSERTKEY_ACTIVE)
+ if (mode & GRAPHKEYS_INSERTKEY_ACTIVE) {
BKE_report(reports,
RPT_ERROR,
"No active F-Curve to add a keyframe to. Select an editable F-Curve first");
- else if (mode & GRAPHKEYS_INSERTKEY_SEL)
+ }
+ else if (mode & GRAPHKEYS_INSERTKEY_SEL) {
BKE_report(reports, RPT_ERROR, "No selected F-Curves to add keyframes to");
- else
+ }
+ else {
BKE_report(reports, RPT_ERROR, "No channels to add keyframes to");
+ }
return;
}
@@ -615,18 +644,23 @@ static void insert_graph_keys(bAnimContext *ac, eGraphKeys_InsertKey_Types mode)
float x, y;
/* perform time remapping for x-coordinate (if necessary) */
- if ((sipo) && (sipo->mode == SIPO_MODE_DRIVERS))
+ if ((sipo) && (sipo->mode == SIPO_MODE_DRIVERS)) {
x = sipo->cursorTime;
- else if (adt)
+ }
+ else if (adt) {
x = BKE_nla_tweakedit_remap(adt, (float)CFRA, NLATIME_CONVERT_UNMAP);
- else
+ }
+ else {
x = (float)CFRA;
+ }
/* normalise units of cursor's value */
- if (sipo)
+ if (sipo) {
y = (sipo->cursorVal / unit_scale) - offset;
- else
+ }
+ else {
y = 0.0f;
+ }
/* insert keyframe directly into the F-Curve */
insert_vert_fcurve(fcu, x, y, ts->keyframe_type, 0);
@@ -669,10 +703,12 @@ static void insert_graph_keys(bAnimContext *ac, eGraphKeys_InsertKey_Types mode)
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
/* adjust current frame for NLA-mapping */
- if ((sipo) && (sipo->mode == SIPO_MODE_DRIVERS))
+ if ((sipo) && (sipo->mode == SIPO_MODE_DRIVERS)) {
cfra = sipo->cursorTime;
- else if (adt)
+ }
+ else if (adt) {
cfra = BKE_nla_tweakedit_remap(adt, (float)CFRA, NLATIME_CONVERT_UNMAP);
+ }
const float curval = evaluate_fcurve_only_curve(fcu, cfra);
insert_vert_fcurve(fcu, cfra, curval, ts->keyframe_type, 0);
@@ -696,8 +732,9 @@ static int graphkeys_insertkey_exec(bContext *C, wmOperator *op)
eGraphKeys_InsertKey_Types mode;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* which channels to affect? */
mode = RNA_enum_get(op->ptr, "type");
@@ -741,14 +778,16 @@ static int graphkeys_click_insert_exec(bContext *C, wmOperator *op)
float frame, val;
/* get animation context */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get active F-Curve 'anim-list-element' */
ale = get_active_fcurve_channel(&ac);
if (ELEM(NULL, ale, ale->data)) {
- if (ale)
+ if (ale) {
MEM_freeN(ale);
+ }
return OPERATOR_CANCELLED;
}
fcu = ale->data;
@@ -797,12 +836,15 @@ static int graphkeys_click_insert_exec(bContext *C, wmOperator *op)
}
else {
/* warn about why this can't happen */
- if (fcu->fpt)
+ if (fcu->fpt) {
BKE_report(op->reports, RPT_ERROR, "Keyframes cannot be added to sampled F-Curves");
- else if (fcu->flag & FCURVE_PROTECTED)
+ }
+ else if (fcu->flag & FCURVE_PROTECTED) {
BKE_report(op->reports, RPT_ERROR, "Active F-Curve is not editable");
- else
+ }
+ else {
BKE_report(op->reports, RPT_ERROR, "Remove F-Modifiers from F-Curve to add keyframes");
+ }
}
/* free temp data */
@@ -824,8 +866,9 @@ static int graphkeys_click_insert_invoke(bContext *C, wmOperator *op, const wmEv
float x, y;
/* get animation context */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* store mouse coordinates in View2D space, into the operator's properties */
ar = ac.ar;
@@ -919,8 +962,9 @@ static short paste_graph_keys(bAnimContext *ac,
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT |
ANIMFILTER_NODUPLIS);
- if (ANIM_animdata_filter(ac, &anim_data, filter | ANIMFILTER_SEL, ac->data, ac->datatype) == 0)
+ if (ANIM_animdata_filter(ac, &anim_data, filter | ANIMFILTER_SEL, ac->data, ac->datatype) == 0) {
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
+ }
/* paste keyframes */
ok = paste_animedit_keys(ac, &anim_data, offset_mode, merge_mode, flip);
@@ -938,8 +982,9 @@ static int graphkeys_copy_exec(bContext *C, wmOperator *op)
bAnimContext ac;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* copy keyframes */
if (copy_graph_keys(&ac)) {
@@ -975,8 +1020,9 @@ static int graphkeys_paste_exec(bContext *C, wmOperator *op)
const bool flipped = RNA_boolean_get(op->ptr, "flipped");
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* ac.reports by default will be the global reports list, which won't show warnings */
ac.reports = op->reports;
@@ -1060,8 +1106,9 @@ static int graphkeys_duplicate_exec(bContext *C, wmOperator *UNUSED(op))
bAnimContext ac;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* duplicate keyframes */
duplicate_graph_keys(&ac);
@@ -1140,12 +1187,14 @@ static int graphkeys_delete_exec(bContext *C, wmOperator *UNUSED(op))
bAnimContext ac;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* delete keyframes */
- if (!delete_graph_keys(&ac))
+ if (!delete_graph_keys(&ac)) {
return OPERATOR_CANCELLED;
+ }
/* set notifier that keyframes have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_REMOVED, NULL);
@@ -1202,8 +1251,9 @@ static int graphkeys_clean_exec(bContext *C, wmOperator *op)
bool clean_chan;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get cleaning threshold */
thresh = RNA_float_get(op->ptr, "threshold");
@@ -1283,8 +1333,9 @@ static int graphkeys_bake_exec(bContext *C, wmOperator *UNUSED(op))
int start, end;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* for now, init start/end from preview-range extents */
// TODO: add properties for this
@@ -1346,8 +1397,9 @@ static float fcurve_samplingcb_sound(FCurve *UNUSED(fcu), void *data, float eval
tSoundBakeInfo *sbi = (tSoundBakeInfo *)data;
int position = evaltime - sbi->cfra;
- if ((position < 0) || (position >= sbi->length))
+ if ((position < 0) || (position >= sbi->length)) {
return 0.0f;
+ }
return sbi->samples[position];
}
@@ -1368,8 +1420,9 @@ static int graphkeys_sound_bake_exec(bContext *C, wmOperator *op)
char path[FILE_MAX];
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
RNA_string_get(op->ptr, "filepath", path);
@@ -1447,8 +1500,9 @@ static int graphkeys_sound_bake_invoke(bContext *C, wmOperator *op, const wmEven
bAnimContext ac;
/* verify editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
return WM_operator_filesel(C, op, event);
}
@@ -1588,8 +1642,9 @@ static int graphkeys_sample_exec(bContext *C, wmOperator *UNUSED(op))
bAnimContext ac;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* sample keyframes */
sample_graph_keys(&ac);
@@ -1690,8 +1745,9 @@ static void setexpo_graph_keys(bAnimContext *ac, short mode)
for (fcm = fcu->modifiers.first; fcm; fcm = fcn) {
fcn = fcm->next;
- if (fcm->type == FMODIFIER_TYPE_CYCLES)
+ if (fcm->type == FMODIFIER_TYPE_CYCLES) {
remove_fmodifier(&fcu->modifiers, fcm);
+ }
}
}
}
@@ -1711,8 +1767,9 @@ static int graphkeys_expo_exec(bContext *C, wmOperator *op)
short mode;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get handle setting mode */
mode = RNA_enum_get(op->ptr, "type");
@@ -1782,8 +1839,9 @@ static int graphkeys_ipo_exec(bContext *C, wmOperator *op)
short mode;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get handle setting mode */
mode = RNA_enum_get(op->ptr, "type");
@@ -1852,8 +1910,9 @@ static int graphkeys_easing_exec(bContext *C, wmOperator *op)
short mode;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get handle setting mode */
mode = RNA_enum_get(op->ptr, "type");
@@ -1932,8 +1991,9 @@ static int graphkeys_handletype_exec(bContext *C, wmOperator *op)
short mode;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get handle setting mode */
mode = RNA_enum_get(op->ptr, "type");
@@ -2001,8 +2061,9 @@ static int graphkeys_euler_filter_exec(bContext *C, wmOperator *op)
int groups = 0, failed = 0;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* The process is done in two passes:
* 1) Sets of three related rotation curves are identified from the selected channels,
@@ -2023,8 +2084,9 @@ static int graphkeys_euler_filter_exec(bContext *C, wmOperator *op)
* - only rotation curves
* - for pchan curves, make sure we're only using the euler curves
*/
- if (strstr(fcu->rna_path, "rotation_euler") == NULL)
+ if (strstr(fcu->rna_path, "rotation_euler") == NULL) {
continue;
+ }
else if (ELEM(fcu->array_index, 0, 1, 2) == 0) {
BKE_reportf(op->reports,
RPT_WARNING,
@@ -2099,8 +2161,9 @@ static int graphkeys_euler_filter_exec(bContext *C, wmOperator *op)
unsigned int i;
/* skip if not enough vets to do a decent analysis of... */
- if (fcu->totvert <= 2)
+ if (fcu->totvert <= 2) {
continue;
+ }
/* prev follows bezt, bezt = "current" point to be fixed */
/* our method depends on determining a "difference" from the previous vert */
@@ -2178,8 +2241,9 @@ void GRAPH_OT_euler_filter(wmOperatorType *ot)
static bool graphkeys_framejump_poll(bContext *C)
{
/* prevent changes during render */
- if (G.is_rendering)
+ if (G.is_rendering) {
return 0;
+ }
return graphop_visible_keyframes_poll(C);
}
@@ -2194,8 +2258,9 @@ static int graphkeys_framejump_exec(bContext *C, wmOperator *UNUSED(op))
KeyframeEditData ked;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* init edit data */
memset(&ked, 0, sizeof(KeyframeEditData));
@@ -2219,8 +2284,9 @@ static int graphkeys_framejump_exec(bContext *C, wmOperator *UNUSED(op))
ANIM_fcurve_keyframes_loop(&current_ked, ale->key_data, NULL, bezt_calc_average, NULL);
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1);
}
- else
+ else {
ANIM_fcurve_keyframes_loop(&current_ked, ale->key_data, NULL, bezt_calc_average, NULL);
+ }
ked.f1 += current_ked.f1;
ked.i1 += current_ked.i1;
@@ -2368,8 +2434,9 @@ static void snap_graph_keys(bAnimContext *ac, short mode)
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, calchandles_fcurve);
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 0);
}
- else
+ else {
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, calchandles_fcurve);
+ }
ale->update |= ANIM_UPDATE_DEFAULT;
}
@@ -2386,8 +2453,9 @@ static int graphkeys_snap_exec(bContext *C, wmOperator *op)
short mode;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get snapping mode */
mode = RNA_enum_get(op->ptr, "type");
@@ -2477,10 +2545,12 @@ static void mirror_graph_keys(bAnimContext *ac, short mode)
marker = ED_markers_get_first_selected(ac->markers);
/* store marker's time (if available) */
- if (marker)
+ if (marker) {
ked.f1 = (float)marker->frame;
- else
+ }
+ else {
return;
+ }
}
else if (mode == GRAPHKEYS_MIRROR_VALUE) {
cursor_value = (sipo) ? sipo->cursorVal : 0.0f;
@@ -2523,8 +2593,9 @@ static void mirror_graph_keys(bAnimContext *ac, short mode)
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, calchandles_fcurve);
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 0);
}
- else
+ else {
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, calchandles_fcurve);
+ }
ale->update |= ANIM_UPDATE_DEFAULT;
}
@@ -2541,8 +2612,9 @@ static int graphkeys_mirror_exec(bContext *C, wmOperator *op)
short mode;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get mirroring mode */
mode = RNA_enum_get(op->ptr, "type");
@@ -2585,8 +2657,9 @@ static int graphkeys_smooth_exec(bContext *C, wmOperator *UNUSED(op))
int filter;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT |
@@ -2652,8 +2725,9 @@ static const EnumPropertyItem *graph_fmodifier_itemf(bContext *C,
int index;
/* check if modifier is valid for this context */
- if (fmi == NULL)
+ if (fmi == NULL) {
continue;
+ }
index = RNA_enum_from_value(rna_enum_fmodifier_type_items, fmi->type);
if (index != -1) { /* Not all types are implemented yet... */
@@ -2676,19 +2750,22 @@ static int graph_fmodifier_add_exec(bContext *C, wmOperator *op)
short type;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get type of modifier to add */
type = RNA_enum_get(op->ptr, "type");
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
- if (RNA_boolean_get(op->ptr, "only_active"))
+ if (RNA_boolean_get(op->ptr, "only_active")) {
filter |=
ANIMFILTER_ACTIVE; // FIXME: enforce in this case only a single channel to get handled?
- else
+ }
+ else {
filter |= (ANIMFILTER_SEL | ANIMFILTER_CURVE_VISIBLE);
+ }
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
/* add f-modifier to each curve */
@@ -2753,8 +2830,9 @@ static int graph_fmodifier_copy_exec(bContext *C, wmOperator *op)
bool ok = false;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* clear buffer first */
ANIM_fmodifiers_copybuf_free();
@@ -2778,8 +2856,9 @@ static int graph_fmodifier_copy_exec(bContext *C, wmOperator *op)
BKE_report(op->reports, RPT_ERROR, "No F-Modifiers available to be copied");
return OPERATOR_CANCELLED;
}
- else
+ else {
return OPERATOR_FINISHED;
+ }
}
void GRAPH_OT_fmodifier_copy(wmOperatorType *ot)
@@ -2820,8 +2899,9 @@ static int graph_fmodifier_paste_exec(bContext *C, wmOperator *op)
bool ok = false;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* filter data */
if (RNA_boolean_get(op->ptr, "only_active")) {
@@ -2906,8 +2986,9 @@ static int graph_driver_vars_copy_exec(bContext *C, wmOperator *op)
bool ok = false;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* clear buffer first */
ANIM_driver_vars_copybuf_free();
@@ -2926,10 +3007,12 @@ static int graph_driver_vars_copy_exec(bContext *C, wmOperator *op)
}
/* successful or not? */
- if (ok)
+ if (ok) {
return OPERATOR_FINISHED;
- else
+ }
+ else {
return OPERATOR_CANCELLED;
+ }
}
void GRAPH_OT_driver_variables_copy(wmOperatorType *ot)
@@ -2961,8 +3044,9 @@ static int graph_driver_vars_paste_exec(bContext *C, wmOperator *op)
bool ok = false;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* filter data */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_ACTIVE | ANIMFILTER_FOREDIT |
@@ -3028,8 +3112,9 @@ static int graph_driver_delete_invalid_exec(bContext *C, wmOperator *op)
unsigned int deleted = 0;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* NOTE: we might need a scene update to evaluate the driver flags */
@@ -3081,8 +3166,9 @@ static bool graph_driver_delete_invalid_poll(bContext *C)
ScrArea *sa = CTX_wm_area(C);
/* firstly, check if in Graph Editor */
- if ((sa == NULL) || (sa->spacetype != SPACE_GRAPH))
+ if ((sa == NULL) || (sa->spacetype != SPACE_GRAPH)) {
return 0;
+ }
/* try to init Anim-Context stuff ourselves and check */
return ANIM_animdata_get_context(C, &ac) != 0;
diff --git a/source/blender/editors/space_graph/graph_ops.c b/source/blender/editors/space_graph/graph_ops.c
index 30f3960e18a..79df4760939 100644
--- a/source/blender/editors/space_graph/graph_ops.c
+++ b/source/blender/editors/space_graph/graph_ops.c
@@ -64,8 +64,9 @@
static bool graphview_cursor_poll(bContext *C)
{
/* prevent changes during render */
- if (G.is_rendering)
+ if (G.is_rendering) {
return 0;
+ }
return ED_operator_graphedit_active(C);
}
@@ -132,8 +133,9 @@ static void graphview_cursor_setprops(bContext *C, wmOperator *op, const wmEvent
float viewx, viewy;
/* abort if not active region (should not really be possible) */
- if (ar == NULL)
+ if (ar == NULL) {
return;
+ }
/* convert from region coordinates to View2D 'tot' space */
UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &viewx, &viewy);
@@ -157,8 +159,9 @@ static int graphview_cursor_invoke(bContext *C, wmOperator *op, const wmEvent *e
graphview_cursor_apply(C, op);
/* Signal that a scrubbing operating is starting */
- if (screen)
+ if (screen) {
screen->scrubbing = true;
+ }
/* add temp handler */
WM_event_add_modal_handler(C, op);
@@ -174,8 +177,9 @@ static int graphview_cursor_modal(bContext *C, wmOperator *op, const wmEvent *ev
/* execute the events */
switch (event->type) {
case ESCKEY:
- if (screen)
+ if (screen) {
screen->scrubbing = false;
+ }
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
return OPERATOR_FINISHED;
@@ -191,8 +195,9 @@ static int graphview_cursor_modal(bContext *C, wmOperator *op, const wmEvent *ev
case MIDDLEMOUSE:
/* We check for either mouse-button to end, to work with all user keymaps. */
if (event->val == KM_RELEASE) {
- if (screen)
+ if (screen) {
screen->scrubbing = false;
+ }
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
return OPERATOR_FINISHED;
@@ -236,8 +241,9 @@ static int graphview_curves_hide_exec(bContext *C, wmOperator *op)
const bool unselected = RNA_boolean_get(op->ptr, "unselected");
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get list of all channels that selection may need to be flushed to
* - hierarchy must not affect what we have access to here...
@@ -250,10 +256,12 @@ static int graphview_curves_hide_exec(bContext *C, wmOperator *op)
* selected/unselected (depending on "unselected" prop)
*/
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS);
- if (unselected)
+ if (unselected) {
filter |= ANIMFILTER_UNSEL;
- else
+ }
+ else {
filter |= ANIMFILTER_SEL;
+ }
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
@@ -261,8 +269,9 @@ static int graphview_curves_hide_exec(bContext *C, wmOperator *op)
/* hack: skip object channels for now, since flushing those will always flush everything,
* but they are always included */
/* TODO: find out why this is the case, and fix that */
- if (ale->type == ANIMTYPE_OBJECT)
+ if (ale->type == ANIMTYPE_OBJECT) {
continue;
+ }
/* change the hide setting, and unselect it... */
ANIM_channel_setting_set(&ac, ale, ACHANNEL_SETTING_VISIBLE, ACHANNEL_SETFLAG_CLEAR);
@@ -290,8 +299,9 @@ static int graphview_curves_hide_exec(bContext *C, wmOperator *op)
* will always flush everything, but they are always included */
/* TODO: find out why this is the case, and fix that */
- if (ale->type == ANIMTYPE_OBJECT)
+ if (ale->type == ANIMTYPE_OBJECT) {
continue;
+ }
/* change the hide setting, and unselect it... */
ANIM_channel_setting_set(&ac, ale, ACHANNEL_SETTING_VISIBLE, ACHANNEL_SETFLAG_ADD);
@@ -341,8 +351,9 @@ static int graphview_curves_reveal_exec(bContext *C, wmOperator *op)
const bool select = RNA_boolean_get(op->ptr, "select");
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get list of all channels that selection may need to be flushed to
* - hierarchy must not affect what we have access to here...
@@ -360,8 +371,9 @@ static int graphview_curves_reveal_exec(bContext *C, wmOperator *op)
/* hack: skip object channels for now, since flushing those will always flush everything,
* but they are always included. */
/* TODO: find out why this is the case, and fix that */
- if (ale->type == ANIMTYPE_OBJECT)
+ if (ale->type == ANIMTYPE_OBJECT) {
continue;
+ }
/* select if it is not visible */
if (ANIM_channel_setting_get(&ac, ale, ACHANNEL_SETTING_VISIBLE) == 0) {
diff --git a/source/blender/editors/space_graph/graph_select.c b/source/blender/editors/space_graph/graph_select.c
index 05d0ba38461..a5376cd0c0e 100644
--- a/source/blender/editors/space_graph/graph_select.c
+++ b/source/blender/editors/space_graph/graph_select.c
@@ -122,10 +122,12 @@ void deselect_graph_keys(bAnimContext *ac, bool test, short sel, bool do_channel
/* deactivate the F-Curve, and deselect if deselecting keyframes.
* otherwise select the F-Curve too since we've selected all the keyframes
*/
- if (sel == SELECT_SUBTRACT)
+ if (sel == SELECT_SUBTRACT) {
fcu->flag &= ~FCURVE_SELECTED;
- else
+ }
+ else {
fcu->flag |= FCURVE_SELECTED;
+ }
}
/* always deactivate all F-Curves if we perform batch ops for selection */
@@ -145,8 +147,9 @@ static int graphkeys_deselectall_exec(bContext *C, wmOperator *op)
bAnimListElem *ale_active = NULL;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* find active F-Curve, and preserve this for later
* or else it becomes annoying with the current active
@@ -277,8 +280,9 @@ static void box_select_graphkeys(bAnimContext *ac,
ked.iterflags |= KEYFRAME_ITER_INCL_HANDLES;
mapping_flag = 0;
}
- else
+ else {
mapping_flag = ANIM_UNITCONV_ONLYKEYS;
+ }
mapping_flag |= ANIM_get_normalization_flags(ac);
@@ -293,8 +297,9 @@ static void box_select_graphkeys(bAnimContext *ac,
/* apply NLA mapping to all the keyframes, since it's easier than trying to
* guess when a callback might use something different
*/
- if (adt)
+ if (adt) {
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, incl_handles == 0);
+ }
scaled_rectf.xmin = rectf.xmin;
scaled_rectf.xmax = rectf.xmax;
@@ -322,14 +327,16 @@ static void box_select_graphkeys(bAnimContext *ac,
/* only change selection of channel when the visibility of keyframes doesn't depend on this */
if ((sipo->flag & SIPO_SELCUVERTSONLY) == 0) {
/* select the curve too now that curve will be touched */
- if (selectmode == SELECT_ADD)
+ if (selectmode == SELECT_ADD) {
fcu->flag |= FCURVE_SELECTED;
+ }
}
}
/* un-apply NLA mapping from all the keyframes */
- if (adt)
+ if (adt) {
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, incl_handles == 0);
+ }
}
/* cleanup */
@@ -346,8 +353,9 @@ static int graphkeys_box_select_exec(bContext *C, wmOperator *op)
short mode = 0;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
const eSelectOp sel_op = RNA_enum_get(op->ptr, "mode");
const int selectmode = (sel_op != SEL_OP_SUB) ? SELECT_ADD : SELECT_SUBTRACT;
@@ -370,13 +378,16 @@ static int graphkeys_box_select_exec(bContext *C, wmOperator *op)
* as frame-range one is often used for tweaking timing when "blocking",
* while channels is not that useful.
*/
- if ((BLI_rcti_size_x(&rect)) >= (BLI_rcti_size_y(&rect)))
+ if ((BLI_rcti_size_x(&rect)) >= (BLI_rcti_size_y(&rect))) {
mode = BEZT_OK_FRAMERANGE;
- else
+ }
+ else {
mode = BEZT_OK_VALUERANGE;
+ }
}
- else
+ else {
mode = BEZT_OK_REGION;
+ }
BLI_rctf_rcti_copy(&rect_fl, &rect);
@@ -432,13 +443,15 @@ static int graphkeys_lassoselect_exec(bContext *C, wmOperator *op)
bool incl_handles;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
data_lasso.rectf_view = &rect_fl;
data_lasso.mcords = WM_gesture_lasso_path_to_array(C, op, &data_lasso.mcords_tot);
- if (data_lasso.mcords == NULL)
+ if (data_lasso.mcords == NULL) {
return OPERATOR_CANCELLED;
+ }
const eSelectOp sel_op = RNA_enum_get(op->ptr, "mode");
const short selectmode = (sel_op != SEL_OP_SUB) ? SELECT_ADD : SELECT_SUBTRACT;
@@ -508,8 +521,9 @@ static int graph_circle_select_exec(bContext *C, wmOperator *op)
float radius = RNA_int_get(op->ptr, "radius");
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
const eSelectOp sel_op = ED_select_op_modal(RNA_enum_get(op->ptr, "mode"),
WM_gesture_is_modal_first(op->customdata));
@@ -658,8 +672,9 @@ static void columnselect_graph_keys(bAnimContext *ac, short mode)
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
- for (ale = anim_data.first; ale; ale = ale->next)
+ for (ale = anim_data.first; ale; ale = ale->next) {
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, bezt_to_cfraelem, NULL);
+ }
ANIM_animdata_freelist(&anim_data);
break;
@@ -718,16 +733,19 @@ static int graphkeys_columnselect_exec(bContext *C, wmOperator *op)
short mode;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* action to take depends on the mode */
mode = RNA_enum_get(op->ptr, "mode");
- if (mode == GRAPHKEYS_COLUMNSEL_MARKERS_BETWEEN)
+ if (mode == GRAPHKEYS_COLUMNSEL_MARKERS_BETWEEN) {
markers_selectkeys_between(&ac);
- else
+ }
+ else {
columnselect_graph_keys(&ac, mode);
+ }
/* set notifier that keyframe selection has changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL);
@@ -767,8 +785,9 @@ static int graphkeys_select_linked_exec(bContext *C, wmOperator *UNUSED(op))
KeyframeEditFunc sel_cb = ANIM_editkeyframes_select(SELECT_ADD);
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* loop through all of the keys and select additional keyframes based on these */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS);
@@ -832,8 +851,9 @@ static void select_moreless_graph_keys(bAnimContext *ac, short mode)
FCurve *fcu = (FCurve *)ale->key_data;
/* only continue if F-Curve has keyframes */
- if (fcu->bezt == NULL)
+ if (fcu->bezt == NULL) {
continue;
+ }
/* build up map of whether F-Curve's keyframes should be selected or not */
ked.data = MEM_callocN(fcu->totvert, "selmap graphEdit");
@@ -858,8 +878,9 @@ static int graphkeys_select_more_exec(bContext *C, wmOperator *UNUSED(op))
bAnimContext ac;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* perform select changes */
select_moreless_graph_keys(&ac, SELMAP_MORE);
@@ -892,8 +913,9 @@ static int graphkeys_select_less_exec(bContext *C, wmOperator *UNUSED(op))
bAnimContext ac;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* perform select changes */
select_moreless_graph_keys(&ac, SELMAP_LESS);
@@ -978,8 +1000,9 @@ static void graphkeys_select_leftright(bAnimContext *ac, short leftright, short
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL);
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1);
}
- else
+ else {
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL);
+ }
}
/* Cleanup */
@@ -995,18 +1018,22 @@ static int graphkeys_select_leftright_exec(bContext *C, wmOperator *op)
short selectmode;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* select mode is either replace (deselect all, then add) or add/extend */
- if (RNA_boolean_get(op->ptr, "extend"))
+ if (RNA_boolean_get(op->ptr, "extend")) {
selectmode = SELECT_INVERT;
- else
+ }
+ else {
selectmode = SELECT_REPLACE;
+ }
/* if "test" mode is set, we don't have any info to set this with */
- if (leftright == GRAPHKEYS_LRSEL_TEST)
+ if (leftright == GRAPHKEYS_LRSEL_TEST) {
return OPERATOR_CANCELLED;
+ }
/* do the selecting now */
graphkeys_select_leftright(&ac, leftright, selectmode);
@@ -1024,8 +1051,9 @@ static int graphkeys_select_leftright_invoke(bContext *C, wmOperator *op, const
short leftright = RNA_enum_get(op->ptr, "mode");
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* handle mode-based testing */
if (leftright == GRAPHKEYS_LRSEL_TEST) {
@@ -1036,10 +1064,12 @@ static int graphkeys_select_leftright_invoke(bContext *C, wmOperator *op, const
/* determine which side of the current frame mouse is on */
x = UI_view2d_region_to_view_x(v2d, event->mval[0]);
- if (x < CFRA)
+ if (x < CFRA) {
RNA_enum_set(op->ptr, "mode", GRAPHKEYS_LRSEL_LEFT);
- else
+ }
+ else {
RNA_enum_set(op->ptr, "mode", GRAPHKEYS_LRSEL_RIGHT);
+ }
}
/* perform selection */
@@ -1117,10 +1147,12 @@ typedef enum eGraphVertIndex {
// XXX also need to check for int-values only?
static bool fcurve_handle_sel_check(SpaceGraph *sipo, BezTriple *bezt)
{
- if (sipo->flag & SIPO_NOHANDLES)
+ if (sipo->flag & SIPO_NOHANDLES) {
return 0;
- if ((sipo->flag & SIPO_SELVHANDLESONLY) && BEZT_ISSEL_ANY(bezt) == 0)
+ }
+ if ((sipo->flag & SIPO_SELVHANDLESONLY) && BEZT_ISSEL_ANY(bezt) == 0) {
return 0;
+ }
return 1;
}
@@ -1159,12 +1191,14 @@ static void nearest_fcurve_vert_store(ListBase *matches,
/* if there is already a point for the F-Curve, check if this point is closer than that was */
if ((nvi) && (nvi->fcu == fcu)) {
/* replace if we are closer, or if equal and that one wasn't selected but we are... */
- if ((nvi->dist > dist) || ((nvi->sel == 0) && BEZT_ISSEL_ANY(bezt)))
+ if ((nvi->dist > dist) || ((nvi->sel == 0) && BEZT_ISSEL_ANY(bezt))) {
replace = 1;
+ }
}
/* add new if not replacing... */
- if (replace == 0)
+ if (replace == 0) {
nvi = MEM_callocN(sizeof(tNearestVertInfo), "Nearest Graph Vert Info - Bezt");
+ }
/* store values */
nvi->fcu = fcu;
@@ -1179,8 +1213,9 @@ static void nearest_fcurve_vert_store(ListBase *matches,
nvi->sel = BEZT_ISSEL_ANY(bezt); // XXX... should this use the individual verts instead?
/* add to list of matches if appropriate... */
- if (replace == 0)
+ if (replace == 0) {
BLI_addtail(matches, nvi);
+ }
}
}
else if (fpt) {
@@ -1205,8 +1240,9 @@ static void get_nearest_fcurve_verts_list(bAnimContext *ac, const int mval[2], L
*/
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS);
if (sipo->flag &
- SIPO_SELCUVERTSONLY) // FIXME: this should really be check for by the filtering code...
+ SIPO_SELCUVERTSONLY) { // FIXME: this should really be check for by the filtering code...
filter |= ANIMFILTER_SEL;
+ }
mapping_flag |= ANIM_get_normalization_flags(ac);
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
@@ -1218,8 +1254,9 @@ static void get_nearest_fcurve_verts_list(bAnimContext *ac, const int mval[2], L
ac->scene, ale->id, fcu, mapping_flag, &offset);
/* apply NLA mapping to all the keyframes */
- if (adt)
+ if (adt) {
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 0);
+ }
if (fcu->bezt) {
BezTriple *bezt1 = fcu->bezt, *prevbezt = NULL;
@@ -1276,8 +1313,9 @@ static void get_nearest_fcurve_verts_list(bAnimContext *ac, const int mval[2], L
}
/* un-apply NLA mapping from all the keyframes */
- if (adt)
+ if (adt) {
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 0);
+ }
}
/* free channels */
@@ -1291,8 +1329,9 @@ static tNearestVertInfo *get_best_nearest_fcurve_vert(ListBase *matches)
short found = 0;
/* abort if list is empty */
- if (BLI_listbase_is_empty(matches))
+ if (BLI_listbase_is_empty(matches)) {
return NULL;
+ }
/* if list only has 1 item, remove it from the list and return */
if (BLI_listbase_is_single(matches)) {
@@ -1312,8 +1351,9 @@ static tNearestVertInfo *get_best_nearest_fcurve_vert(ListBase *matches)
}
else {
/* if vert is selected, we've got what we want... */
- if (nvi->sel)
+ if (nvi->sel) {
found = 1;
+ }
}
}
@@ -1362,8 +1402,9 @@ static void mouse_graph_keys(bAnimContext *ac,
nvi = find_nearest_fcurve_vert(ac, mval);
/* check if anything to select */
- if (nvi == NULL)
+ if (nvi == NULL) {
return;
+ }
/* deselect all other curves? */
if (select_mode == SELECT_REPLACE) {
@@ -1377,8 +1418,9 @@ static void mouse_graph_keys(bAnimContext *ac,
* selection of channel when the visibility of keyframes
* doesn't depend on this
*/
- if ((sipo->flag & SIPO_SELCUVERTSONLY) == 0)
+ if ((sipo->flag & SIPO_SELCUVERTSONLY) == 0) {
ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR);
+ }
}
/* if points can be selected on this F-Curve */
@@ -1415,10 +1457,12 @@ static void mouse_graph_keys(bAnimContext *ac,
BEZT_SEL_ALL(bezt);
}
/* otherwise, select the handle that applied */
- else if (nvi->hpoint == NEAREST_HANDLE_LEFT)
+ else if (nvi->hpoint == NEAREST_HANDLE_LEFT) {
bezt->f1 |= SELECT;
- else
+ }
+ else {
bezt->f3 |= SELECT;
+ }
}
}
else if (nvi->fpt) {
@@ -1446,18 +1490,22 @@ static void mouse_graph_keys(bAnimContext *ac,
/* take selection status from item that got hit, to prevent flip/flop on channel
* selection status when shift-selecting (i.e. "SELECT_INVERT") points
*/
- if (BEZT_ISSEL_ANY(bezt))
+ if (BEZT_ISSEL_ANY(bezt)) {
nvi->fcu->flag |= FCURVE_SELECTED;
- else
+ }
+ else {
nvi->fcu->flag &= ~FCURVE_SELECTED;
+ }
}
else {
/* Didn't hit any channel,
* so just apply that selection mode to the curve's selection status. */
- if (select_mode == SELECT_INVERT)
+ if (select_mode == SELECT_INVERT) {
nvi->fcu->flag ^= FCURVE_SELECTED;
- else if (select_mode == SELECT_ADD)
+ }
+ else if (select_mode == SELECT_ADD) {
nvi->fcu->flag |= FCURVE_SELECTED;
+ }
}
}
@@ -1493,8 +1541,9 @@ static void graphkeys_mselect_column(bAnimContext *ac, const int mval[2], short
nvi = find_nearest_fcurve_vert(ac, mval);
/* check if anything to select */
- if (nvi == NULL)
+ if (nvi == NULL) {
return;
+ }
/* get frame number on which elements should be selected */
// TODO: should we restrict to integer frames only?
@@ -1528,10 +1577,12 @@ static void graphkeys_mselect_column(bAnimContext *ac, const int mval[2], short
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
/* set frame for validation callback to refer to */
- if (adt)
+ if (adt) {
ked.f1 = BKE_nla_tweakedit_remap(adt, selx, NLATIME_CONVERT_UNMAP);
- else
+ }
+ else {
ked.f1 = selx;
+ }
/* select elements with frame number matching cfra */
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL);
@@ -1552,14 +1603,17 @@ static int graphkeys_clickselect_invoke(bContext *C, wmOperator *op, const wmEve
short selectmode;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* select mode is either replace (deselect all, then add) or add/extend */
- if (RNA_boolean_get(op->ptr, "extend"))
+ if (RNA_boolean_get(op->ptr, "extend")) {
selectmode = SELECT_INVERT;
- else
+ }
+ else {
selectmode = SELECT_REPLACE;
+ }
/* figure out action to take */
if (RNA_boolean_get(op->ptr, "column")) {
diff --git a/source/blender/editors/space_graph/graph_utils.c b/source/blender/editors/space_graph/graph_utils.c
index d8cb173f944..b823ddec696 100644
--- a/source/blender/editors/space_graph/graph_utils.c
+++ b/source/blender/editors/space_graph/graph_utils.c
@@ -139,20 +139,23 @@ bool graphop_visible_keyframes_poll(bContext *C)
/* firstly, check if in Graph Editor */
// TODO: also check for region?
- if ((sa == NULL) || (sa->spacetype != SPACE_GRAPH))
+ if ((sa == NULL) || (sa->spacetype != SPACE_GRAPH)) {
return 0;
+ }
/* try to init Anim-Context stuff ourselves and check */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return 0;
+ }
/* loop over the visible (selection doesn't matter) F-Curves, and see if they're suitable
* stopping on the first successful match
*/
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE);
items = ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
- if (items == 0)
+ if (items == 0) {
return 0;
+ }
for (ale = anim_data.first; ale; ale = ale->next) {
FCurve *fcu = (FCurve *)ale->data;
@@ -162,8 +165,9 @@ bool graphop_visible_keyframes_poll(bContext *C)
* - F-Curve modifiers do not interfere with the result too much
* (i.e. the modifier-control drawing check returns false)
*/
- if (fcu->bezt == NULL)
+ if (fcu->bezt == NULL) {
continue;
+ }
if (fcurve_are_keyframes_usable(fcu)) {
found = 1;
break;
@@ -188,20 +192,23 @@ bool graphop_editable_keyframes_poll(bContext *C)
/* firstly, check if in Graph Editor */
// TODO: also check for region?
- if ((sa == NULL) || (sa->spacetype != SPACE_GRAPH))
+ if ((sa == NULL) || (sa->spacetype != SPACE_GRAPH)) {
return 0;
+ }
/* try to init Anim-Context stuff ourselves and check */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return 0;
+ }
/* loop over the editable F-Curves, and see if they're suitable
* stopping on the first successful match
*/
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVE_VISIBLE);
items = ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
- if (items == 0)
+ if (items == 0) {
return 0;
+ }
for (ale = anim_data.first; ale; ale = ale->next) {
FCurve *fcu = (FCurve *)ale->data;
@@ -212,8 +219,9 @@ bool graphop_editable_keyframes_poll(bContext *C)
* - F-Curve modifiers do not interfere with the result too much
* (i.e. the modifier-control drawing check returns false)
*/
- if (fcu->bezt == NULL)
+ if (fcu->bezt == NULL) {
continue;
+ }
if (fcurve_is_keyframable(fcu)) {
found = 1;
break;
@@ -235,17 +243,20 @@ bool graphop_active_fcurve_poll(bContext *C)
/* firstly, check if in Graph Editor */
// TODO: also check for region?
- if ((sa == NULL) || (sa->spacetype != SPACE_GRAPH))
+ if ((sa == NULL) || (sa->spacetype != SPACE_GRAPH)) {
return 0;
+ }
/* try to init Anim-Context stuff ourselves and check */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return 0;
+ }
/* try to get the Active F-Curve */
ale = get_active_fcurve_channel(&ac);
- if (ale == NULL)
+ if (ale == NULL) {
return 0;
+ }
/* Do we have a suitable F-Curves?
* - For most cases, NLA Control Curves are sufficiently similar to NLA
@@ -277,20 +288,23 @@ bool graphop_selected_fcurve_poll(bContext *C)
/* firstly, check if in Graph Editor */
// TODO: also check for region?
- if ((sa == NULL) || (sa->spacetype != SPACE_GRAPH))
+ if ((sa == NULL) || (sa->spacetype != SPACE_GRAPH)) {
return 0;
+ }
/* try to init Anim-Context stuff ourselves and check */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return 0;
+ }
/* Get the editable + selected F-Curves, and as long as we got some, we can return.
* NOTE: curve-visible flag isn't included,
* otherwise selecting a curve via list to edit is too cumbersome. */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT);
items = ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
- if (items == 0)
+ if (items == 0) {
return 0;
+ }
/* cleanup and return findings */
ANIM_animdata_freelist(&anim_data);
diff --git a/source/blender/editors/space_graph/space_graph.c b/source/blender/editors/space_graph/space_graph.c
index 7f6ee09813a..e45a27a08fb 100644
--- a/source/blender/editors/space_graph/space_graph.c
+++ b/source/blender/editors/space_graph/space_graph.c
@@ -297,8 +297,9 @@ static void graph_main_region_draw(const bContext *C, ARegion *ar)
if (sipo->mode != SIPO_MODE_DRIVERS) {
/* current frame */
- if (sipo->flag & SIPO_DRAWTIME)
+ if (sipo->flag & SIPO_DRAWTIME) {
cfra_flag |= DRAWCFRA_UNIT_SECONDS;
+ }
ANIM_draw_cfra(C, v2d, cfra_flag);
}
@@ -434,8 +435,9 @@ static void graph_region_listener(wmWindow *UNUSED(win),
ED_region_tag_redraw(ar);
break;
case ND_SEQUENCER:
- if (wmn->action == NA_SELECTED)
+ if (wmn->action == NA_SELECTED) {
ED_region_tag_redraw(ar);
+ }
break;
}
break;
@@ -447,8 +449,9 @@ static void graph_region_listener(wmWindow *UNUSED(win),
ED_region_tag_redraw(ar);
break;
case ND_MODIFIER:
- if (wmn->action == NA_RENAME)
+ if (wmn->action == NA_RENAME) {
ED_region_tag_redraw(ar);
+ }
break;
}
break;
@@ -461,8 +464,9 @@ static void graph_region_listener(wmWindow *UNUSED(win),
}
break;
case NC_ID:
- if (wmn->action == NA_RENAME)
+ if (wmn->action == NA_RENAME) {
ED_region_tag_redraw(ar);
+ }
break;
case NC_SCREEN:
if (ELEM(wmn->data, ND_LAYER)) {
@@ -470,8 +474,9 @@ static void graph_region_listener(wmWindow *UNUSED(win),
}
break;
default:
- if (wmn->data == ND_KEYS)
+ if (wmn->data == ND_KEYS) {
ED_region_tag_redraw(ar);
+ }
break;
}
}
@@ -564,10 +569,12 @@ static void graph_listener(wmWindow *UNUSED(win),
case NC_ANIMATION:
/* for selection changes of animation data, we can just redraw...
* otherwise autocolor might need to be done again */
- if (ELEM(wmn->data, ND_KEYFRAME, ND_ANIMCHAN) && (wmn->action == NA_SELECTED))
+ if (ELEM(wmn->data, ND_KEYFRAME, ND_ANIMCHAN) && (wmn->action == NA_SELECTED)) {
ED_area_tag_redraw(sa);
- else
+ }
+ else {
ED_area_tag_refresh(sa);
+ }
break;
case NC_SCENE:
switch (wmn->data) {
@@ -607,8 +614,9 @@ static void graph_listener(wmWindow *UNUSED(win),
}
break;
case NC_SPACE:
- if (wmn->data == ND_SPACE_GRAPH)
+ if (wmn->data == ND_SPACE_GRAPH) {
ED_area_tag_redraw(sa);
+ }
break;
case NC_WINDOW:
if (sipo->runtime.flag &
@@ -636,8 +644,9 @@ static void graph_refresh_fcurve_colors(const bContext *C)
int filter;
int i;
- if (ANIM_animdata_get_context(C, &ac) == false)
+ if (ANIM_animdata_get_context(C, &ac) == false) {
return;
+ }
UI_SetTheme(SPACE_GRAPH, RGN_TYPE_WINDOW);
diff --git a/source/blender/editors/space_info/textview.c b/source/blender/editors/space_info/textview.c
index c81e7574186..108803a865f 100644
--- a/source/blender/editors/space_info/textview.c
+++ b/source/blender/editors/space_info/textview.c
@@ -161,8 +161,9 @@ static int console_draw_string(ConsoleDrawContext *cdc,
CLAMP(ofs, 0, str_len);
*cdc->pos_pick += str_len - ofs;
}
- else
+ else {
*cdc->pos_pick += str_len + 1;
+ }
}
cdc->xy[1] = y_next;
diff --git a/source/blender/editors/space_nla/nla_buttons.c b/source/blender/editors/space_nla/nla_buttons.c
index 18c31d3a7f7..d6353a9b0d4 100644
--- a/source/blender/editors/space_nla/nla_buttons.c
+++ b/source/blender/editors/space_nla/nla_buttons.c
@@ -84,8 +84,9 @@ bool nla_panel_context(const bContext *C,
/* For now, only draw if we could init the anim-context info
* (necessary for all animation-related tools)
* to work correctly is able to be correctly retrieved. There's no point showing empty panels? */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return false;
+ }
/* extract list of active channel(s), of which we should only take the first one
* - we need the channels flag to get the active AnimData block when there are no NLA Tracks
@@ -168,8 +169,9 @@ bool nla_panel_context(const bContext *C,
}
}
- if (found > 0)
+ if (found > 0) {
break;
+ }
}
/* free temp data */
@@ -208,10 +210,12 @@ static bool nla_strip_actclip_panel_poll(const bContext *C, PanelType *UNUSED(pt
PointerRNA ptr;
NlaStrip *strip;
- if (!nla_panel_context(C, NULL, NULL, &ptr))
+ if (!nla_panel_context(C, NULL, NULL, &ptr)) {
return 0;
- if (ptr.data == NULL)
+ }
+ if (ptr.data == NULL) {
return 0;
+ }
strip = ptr.data;
return (strip->type == NLASTRIP_TYPE_CLIP);
@@ -222,15 +226,18 @@ static bool nla_strip_eval_panel_poll(const bContext *C, PanelType *UNUSED(pt))
PointerRNA ptr;
NlaStrip *strip;
- if (!nla_panel_context(C, NULL, NULL, &ptr))
+ if (!nla_panel_context(C, NULL, NULL, &ptr)) {
return 0;
- if (ptr.data == NULL)
+ }
+ if (ptr.data == NULL) {
return 0;
+ }
strip = ptr.data;
- if (strip->type == NLASTRIP_TYPE_SOUND)
+ if (strip->type == NLASTRIP_TYPE_SOUND) {
return 0;
+ }
return 1;
}
@@ -247,8 +254,9 @@ static void nla_panel_animdata(const bContext *C, Panel *pa)
uiBlock *block;
/* check context and also validity of pointer */
- if (!nla_panel_context(C, &adt_ptr, NULL, NULL))
+ if (!nla_panel_context(C, &adt_ptr, NULL, NULL)) {
return;
+ }
/* adt = adt_ptr.data; */
@@ -312,8 +320,9 @@ static void nla_panel_track(const bContext *C, Panel *pa)
uiBlock *block;
/* check context and also validity of pointer */
- if (!nla_panel_context(C, NULL, &nlt_ptr, NULL))
+ if (!nla_panel_context(C, NULL, &nlt_ptr, NULL)) {
return;
+ }
block = uiLayoutGetBlock(layout);
UI_block_func_handle_set(block, do_nla_region_buttons, NULL);
@@ -332,8 +341,9 @@ static void nla_panel_properties(const bContext *C, Panel *pa)
uiBlock *block;
short showEvalProps = 1;
- if (!nla_panel_context(C, NULL, NULL, &strip_ptr))
+ if (!nla_panel_context(C, NULL, NULL, &strip_ptr)) {
return;
+ }
block = uiLayoutGetBlock(layout);
UI_block_func_handle_set(block, do_nla_region_buttons, NULL);
@@ -353,8 +363,9 @@ static void nla_panel_properties(const bContext *C, Panel *pa)
/* Evaluation-Related Strip Properties ------------------ */
/* sound properties strips don't have these settings */
- if (RNA_enum_get(&strip_ptr, "type") == NLASTRIP_TYPE_SOUND)
+ if (RNA_enum_get(&strip_ptr, "type") == NLASTRIP_TYPE_SOUND) {
showEvalProps = 0;
+ }
/* only show if allowed to... */
if (showEvalProps) {
@@ -398,8 +409,9 @@ static void nla_panel_actclip(const bContext *C, Panel *pa)
uiBlock *block;
/* check context and also validity of pointer */
- if (!nla_panel_context(C, NULL, NULL, &strip_ptr))
+ if (!nla_panel_context(C, NULL, NULL, &strip_ptr)) {
return;
+ }
block = uiLayoutGetBlock(layout);
UI_block_func_handle_set(block, do_nla_region_buttons, NULL);
@@ -439,8 +451,9 @@ static void nla_panel_evaluation(const bContext *C, Panel *pa)
uiBlock *block;
/* check context and also validity of pointer */
- if (!nla_panel_context(C, NULL, NULL, &strip_ptr))
+ if (!nla_panel_context(C, NULL, NULL, &strip_ptr)) {
return;
+ }
block = uiLayoutGetBlock(layout);
UI_block_func_handle_set(block, do_nla_region_buttons, NULL);
@@ -472,8 +485,9 @@ static void nla_panel_modifiers(const bContext *C, Panel *pa)
uiBlock *block;
/* check context and also validity of pointer */
- if (!nla_panel_context(C, NULL, NULL, &strip_ptr))
+ if (!nla_panel_context(C, NULL, NULL, &strip_ptr)) {
return;
+ }
strip = strip_ptr.data;
block = uiLayoutGetBlock(pa->layout);
diff --git a/source/blender/editors/space_nla/nla_channels.c b/source/blender/editors/space_nla/nla_channels.c
index 9332a6d6763..638ad62592e 100644
--- a/source/blender/editors/space_nla/nla_channels.c
+++ b/source/blender/editors/space_nla/nla_channels.c
@@ -91,9 +91,10 @@ static int mouse_nla_channels(
ale = BLI_findlink(&anim_data, channel_index);
if (ale == NULL) {
/* channel not found */
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("Error: animation channel (index = %d) not found in mouse_anim_channels()\n",
channel_index);
+ }
ANIM_animdata_freelist(&anim_data);
return 0;
@@ -110,13 +111,15 @@ static int mouse_nla_channels(
if (selectmode == SELECT_INVERT) {
/* swap select */
sce->flag ^= SCE_DS_SELECTED;
- if (adt)
+ if (adt) {
adt->flag ^= ADT_UI_SELECTED;
+ }
}
else {
sce->flag |= SCE_DS_SELECTED;
- if (adt)
+ if (adt) {
adt->flag |= ADT_UI_SELECTED;
+ }
}
notifierFlags |= (ND_ANIMCHAN | NA_SELECTED);
@@ -135,8 +138,9 @@ static int mouse_nla_channels(
ED_object_base_select(base, BA_INVERT);
BKE_scene_object_base_flag_sync_from_base(base);
- if (adt)
+ if (adt) {
adt->flag ^= ADT_UI_SELECTED;
+ }
}
else {
/* deselect all */
@@ -144,22 +148,25 @@ static int mouse_nla_channels(
for (Base *b = view_layer->object_bases.first; b; b = b->next) {
ED_object_base_select(b, BA_DESELECT);
BKE_scene_object_base_flag_sync_from_base(b);
- if (b->object->adt)
+ if (b->object->adt) {
b->object->adt->flag &= ~(ADT_UI_SELECTED | ADT_UI_ACTIVE);
+ }
}
/* select object now */
ED_object_base_select(base, BA_SELECT);
BKE_scene_object_base_flag_sync_from_base(base);
- if (adt)
+ if (adt) {
adt->flag |= ADT_UI_SELECTED;
+ }
}
/* change active object - regardless of whether it is now selected [T37883] */
ED_object_base_activate(C, base); /* adds notifier */
- if ((adt) && (adt->flag & ADT_UI_SELECTED))
+ if ((adt) && (adt->flag & ADT_UI_SELECTED)) {
adt->flag |= ADT_UI_ACTIVE;
+ }
/* notifiers - channel was selected */
notifierFlags |= (ND_ANIMCHAN | NA_SELECTED);
@@ -199,8 +206,9 @@ static int mouse_nla_channels(
}
/* set active? */
- if ((ale->adt) && (ale->adt->flag & ADT_UI_SELECTED))
+ if ((ale->adt) && (ale->adt->flag & ADT_UI_SELECTED)) {
ale->adt->flag |= ADT_UI_ACTIVE;
+ }
}
notifierFlags |= (ND_ANIMCHAN | NA_SELECTED);
@@ -214,13 +222,16 @@ static int mouse_nla_channels(
/* offset for start of channel (on LHS of channel-list) */
if (ale->id) {
/* special exception for materials and particles */
- if (ELEM(GS(ale->id->name), ID_MA, ID_PA))
+ if (ELEM(GS(ale->id->name), ID_MA, ID_PA)) {
offset = 21 + NLACHANNEL_BUTTON_WIDTH;
- else
+ }
+ else {
offset = 14;
+ }
}
- else
+ else {
offset = 0;
+ }
if (x >= (v2d->cur.xmax - NLACHANNEL_BUTTON_WIDTH)) {
/* toggle protection (only if there's a toggle there) */
@@ -259,8 +270,9 @@ static int mouse_nla_channels(
/* if NLA-Track is selected now,
* make NLA-Track the 'active' one in the visible list */
- if (nlt->flag & NLATRACK_SELECTED)
+ if (nlt->flag & NLATRACK_SELECTED) {
ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, nlt, ANIMTYPE_NLATRACK);
+ }
/* notifier flags - channel was selected */
notifierFlags |= (ND_ANIMCHAN | NA_SELECTED);
@@ -319,8 +331,9 @@ static int mouse_nla_channels(
}
/* set active? */
- if (adt->flag & ADT_UI_SELECTED)
+ if (adt->flag & ADT_UI_SELECTED) {
adt->flag |= ADT_UI_ACTIVE;
+ }
notifierFlags |= (ND_ANIMCHAN | NA_SELECTED);
}
@@ -328,8 +341,9 @@ static int mouse_nla_channels(
break;
}
default:
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("Error: Invalid channel type in mouse_nla_channels()\n");
+ }
break;
}
@@ -356,8 +370,9 @@ static int nlachannels_mouseclick_invoke(bContext *C, wmOperator *op, const wmEv
float x, y;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get useful pointers from animation context data */
snla = (SpaceNla *)ac.sl;
@@ -365,10 +380,12 @@ static int nlachannels_mouseclick_invoke(bContext *C, wmOperator *op, const wmEv
v2d = &ar->v2d;
/* select mode is either replace (deselect all, then add) or add/extend */
- if (RNA_boolean_get(op->ptr, "extend"))
+ if (RNA_boolean_get(op->ptr, "extend")) {
selectmode = SELECT_INVERT;
- else
+ }
+ else {
selectmode = SELECT_REPLACE;
+ }
/**
* Figure out which channel user clicked in:
@@ -431,8 +448,9 @@ static int nlachannels_pushdown_exec(bContext *C, wmOperator *op)
int channel_index = RNA_int_get(op->ptr, "channel_index");
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get anim-channel to use (or more specifically, the animdata block behind it) */
if (channel_index == -1) {
@@ -558,13 +576,15 @@ static int nla_action_unlink_exec(bContext *C, wmOperator *op)
AnimData *adt;
/* check context and also validity of pointer */
- if (!nla_panel_context(C, &adt_ptr, NULL, NULL))
+ if (!nla_panel_context(C, &adt_ptr, NULL, NULL)) {
return OPERATOR_CANCELLED;
+ }
/* get animdata */
adt = adt_ptr.data;
- if (adt == NULL)
+ if (adt == NULL) {
return OPERATOR_CANCELLED;
+ }
/* do unlinking */
if (adt && adt->action) {
@@ -701,8 +721,9 @@ static int nlaedit_add_tracks_exec(bContext *C, wmOperator *op)
bool op_done = false;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* perform adding in two passes - existing first so that we don't double up for empty */
op_done |= nlaedit_add_tracks_existing(&ac, above_sel);
@@ -762,8 +783,9 @@ static int nlaedit_delete_tracks_exec(bContext *C, wmOperator *UNUSED(op))
int filter;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get a list of the AnimData blocks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL |
@@ -779,8 +801,9 @@ static int nlaedit_delete_tracks_exec(bContext *C, wmOperator *UNUSED(op))
/* if track is currently 'solo', then AnimData should have its
* 'has solo' flag disabled
*/
- if (nlt->flag & NLATRACK_SOLO)
+ if (nlt->flag & NLATRACK_SOLO) {
adt->flag &= ~ADT_NLA_SOLO_TRACK;
+ }
/* call delete on this track - deletes all strips too */
BKE_nlatrack_free(&adt->nla_tracks, nlt, true);
@@ -833,8 +856,9 @@ static int nlaedit_objects_add_exec(bContext *C, wmOperator *UNUSED(op))
SpaceNla *snla;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* ensure that filters are set so that the effect will be immediately visible */
snla = (SpaceNla *)ac.sl;
diff --git a/source/blender/editors/space_nla/nla_draw.c b/source/blender/editors/space_nla/nla_draw.c
index 65115819874..1df2190b7af 100644
--- a/source/blender/editors/space_nla/nla_draw.c
+++ b/source/blender/editors/space_nla/nla_draw.c
@@ -86,8 +86,9 @@ void nla_action_get_color(AnimData *adt, bAction *act, float color[4])
/* when an NLA track is tagged "solo", action doesn't contribute,
* so shouldn't be as prominent */
- if (adt && (adt->flag & ADT_NLA_SOLO_TRACK))
+ if (adt && (adt->flag & ADT_NLA_SOLO_TRACK)) {
color[3] *= 0.15f;
+ }
}
/* draw the keyframes in the specified Action */
@@ -99,8 +100,9 @@ static void nla_action_draw_keyframes(
BLI_dlrbTree_init(&keys);
action_to_keylist(adt, act, &keys, 0);
- if (ELEM(NULL, act, keys.first))
+ if (ELEM(NULL, act, keys.first)) {
return;
+ }
/* draw a darkened region behind the strips
* - get and reset the background color, this time without the alpha to stand out better
@@ -181,8 +183,9 @@ static void nla_actionclip_draw_markers(
{
const bAction *act = strip->act;
- if (ELEM(NULL, act, act->markers.first))
+ if (ELEM(NULL, act, act->markers.first)) {
return;
+ }
const uint shdr_pos = GPU_vertformat_attr_add(
immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
@@ -351,16 +354,18 @@ static void nla_draw_strip_curves(NlaStrip *strip, float yminc, float ymaxc, uns
immVertex2f(pos, strip->start, yminc);
immVertex2f(pos, strip->start + strip->blendin, ymaxc);
}
- else
+ else {
immVertex2f(pos, strip->start, ymaxc);
+ }
/* end of strip */
if (IS_EQF(strip->blendout, 0.0f) == 0) {
immVertex2f(pos, strip->end - strip->blendout, ymaxc);
immVertex2f(pos, strip->end, yminc);
}
- else
+ else {
immVertex2f(pos, strip->end, ymaxc);
+ }
immEnd();
}
@@ -489,15 +494,17 @@ static void nla_draw_strip(SpaceNla *snla,
/* draw strip's control 'curves'
* - only if user hasn't hidden them...
*/
- if ((snla->flag & SNLA_NOSTRIPCURVES) == 0)
+ if ((snla->flag & SNLA_NOSTRIPCURVES) == 0) {
nla_draw_strip_curves(strip, yminc, ymaxc, shdr_pos);
+ }
immUnbindProgram();
/* draw markings indicating locations of local markers
* (useful for lining up different actions) */
- if ((snla->flag & SNLA_NOLOCALMARKERS) == 0)
+ if ((snla->flag & SNLA_NOLOCALMARKERS) == 0) {
nla_strip_draw_markers(strip, yminc, ymaxc);
+ }
/* draw strip outline
* - color used here is to indicate active vs non-active
@@ -615,10 +622,12 @@ static void nla_draw_strip_text(AnimData *adt,
}
/* text opacity depends on whether if there's a solo'd track, this isn't it */
- if (non_solo == 0)
+ if (non_solo == 0) {
col[3] = 255;
- else
+ }
+ else {
col[3] = 128;
+ }
/* set bounding-box for text
* - padding of 2 'units' on either side
@@ -722,8 +731,9 @@ void draw_nla_main_data(bAnimContext *ac, SpaceNla *snla, ARegion *ar)
/* if transforming strips (only real reason for temp-metas currently),
* add to the cache the frame numbers of the strip's extents
*/
- if (strip->flag & NLASTRIP_FLAG_TEMP_META)
+ if (strip->flag & NLASTRIP_FLAG_TEMP_META) {
nla_draw_strip_frames_text(nlt, strip, v2d, yminc, ymaxc);
+ }
}
}
break;
diff --git a/source/blender/editors/space_nla/nla_edit.c b/source/blender/editors/space_nla/nla_edit.c
index 99c2b7aa99c..76930d3117b 100644
--- a/source/blender/editors/space_nla/nla_edit.c
+++ b/source/blender/editors/space_nla/nla_edit.c
@@ -113,8 +113,9 @@ static int nlaedit_enable_tweakmode_exec(bContext *C, wmOperator *op)
bool ok = false;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get a list of the AnimData blocks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_ANIMDATA);
@@ -257,17 +258,20 @@ static int nlaedit_disable_tweakmode_exec(bContext *C, wmOperator *op)
bool ok = false;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* perform operation */
ok = nlaedit_disable_tweakmode(&ac, do_solo);
/* success? */
- if (ok)
+ if (ok) {
return OPERATOR_FINISHED;
- else
+ }
+ else {
return OPERATOR_CANCELLED;
+ }
}
void NLA_OT_tweakmode_exit(wmOperatorType *ot)
@@ -362,13 +366,16 @@ static int nlaedit_previewrange_exec(bContext *C, wmOperator *UNUSED(op))
float min, max;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
- if (ac.scene == NULL)
+ if (ac.scene == NULL) {
return OPERATOR_CANCELLED;
- else
+ }
+ else {
scene = ac.scene;
+ }
/* set the range directly */
get_nlastrip_extents(&ac, &min, &max, true);
@@ -464,8 +471,9 @@ static int nlaedit_viewall(bContext *C, const bool only_sel)
float extra;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
v2d = &ac.ar->v2d;
/* set the horizontal range, with an extra offset so that the extreme keys will be in view */
@@ -597,8 +605,9 @@ static int nlaedit_add_actionclip_exec(bContext *C, wmOperator *op)
float cfra;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
scene = ac.scene;
cfra = (float)CFRA;
@@ -735,8 +744,9 @@ static int nlaedit_add_transition_exec(bContext *C, wmOperator *op)
bool done = false;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get a list of the editable tracks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT);
@@ -749,8 +759,9 @@ static int nlaedit_add_transition_exec(bContext *C, wmOperator *op)
NlaStrip *s1, *s2;
/* get initial pair of strips */
- if (ELEM(nlt->strips.first, NULL, nlt->strips.last))
+ if (ELEM(nlt->strips.first, NULL, nlt->strips.last)) {
continue;
+ }
s1 = nlt->strips.first;
s2 = s1->next;
@@ -759,20 +770,24 @@ static int nlaedit_add_transition_exec(bContext *C, wmOperator *op)
NlaStrip *strip;
/* check if both are selected */
- if (ELEM(0, (s1->flag & NLASTRIP_FLAG_SELECT), (s2->flag & NLASTRIP_FLAG_SELECT)))
+ if (ELEM(0, (s1->flag & NLASTRIP_FLAG_SELECT), (s2->flag & NLASTRIP_FLAG_SELECT))) {
continue;
+ }
/* check if there's space between the two */
- if (IS_EQF(s1->end, s2->start))
+ if (IS_EQF(s1->end, s2->start)) {
continue;
+ }
/* make sure neither one is a transition
* - although this is impossible to create with the standard tools,
* the user may have altered the settings
*/
- if (ELEM(NLASTRIP_TYPE_TRANSITION, s1->type, s2->type))
+ if (ELEM(NLASTRIP_TYPE_TRANSITION, s1->type, s2->type)) {
continue;
+ }
/* also make sure neither one is a soundclip */
- if (ELEM(NLASTRIP_TYPE_SOUND, s1->type, s2->type))
+ if (ELEM(NLASTRIP_TYPE_SOUND, s1->type, s2->type)) {
continue;
+ }
/* allocate new strip */
strip = MEM_callocN(sizeof(NlaStrip), "NlaStrip");
@@ -856,8 +871,9 @@ static int nlaedit_add_sound_exec(bContext *C, wmOperator *UNUSED(op))
int cfra;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
scene = ac.scene;
cfra = CFRA;
@@ -877,8 +893,9 @@ static int nlaedit_add_sound_exec(bContext *C, wmOperator *UNUSED(op))
NlaStrip *strip;
/* does this belong to speaker - assumed to live on Object level only */
- if ((GS(ale->id->name) != ID_OB) || (ob->type != OB_SPEAKER))
+ if ((GS(ale->id->name) != ID_OB) || (ob->type != OB_SPEAKER)) {
continue;
+ }
/* create a new strip, and offset it to start on the current frame */
strip = BKE_nla_add_soundstrip(ac.scene, ob->data);
@@ -940,8 +957,9 @@ static int nlaedit_add_meta_exec(bContext *C, wmOperator *UNUSED(op))
int filter;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get a list of the editable tracks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT);
@@ -959,8 +977,9 @@ static int nlaedit_add_meta_exec(bContext *C, wmOperator *UNUSED(op))
/* name the metas */
for (strip = nlt->strips.first; strip; strip = strip->next) {
/* auto-name this strip if selected (that means it is a meta) */
- if (strip->flag & NLASTRIP_FLAG_SELECT)
+ if (strip->flag & NLASTRIP_FLAG_SELECT) {
BKE_nlastrip_validate_name(adt, strip);
+ }
}
ale->update |= ANIM_UPDATE_DEPS;
@@ -1004,8 +1023,9 @@ static int nlaedit_remove_meta_exec(bContext *C, wmOperator *UNUSED(op))
int filter;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get a list of the editable tracks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT);
@@ -1064,8 +1084,9 @@ static int nlaedit_duplicate_exec(bContext *C, wmOperator *op)
bool done = false;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get a list of editable tracks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT);
@@ -1127,8 +1148,9 @@ static int nlaedit_duplicate_exec(bContext *C, wmOperator *op)
/* done */
return OPERATOR_FINISHED;
}
- else
+ else {
return OPERATOR_CANCELLED;
+ }
}
static int nlaedit_duplicate_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
@@ -1180,8 +1202,9 @@ static int nlaedit_delete_exec(bContext *C, wmOperator *UNUSED(op))
int filter;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get a list of the editable tracks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT);
@@ -1198,8 +1221,9 @@ static int nlaedit_delete_exec(bContext *C, wmOperator *UNUSED(op))
/* if selected, delete */
if (strip->flag & NLASTRIP_FLAG_SELECT) {
/* if a strip either side of this was a transition, delete those too */
- if ((strip->prev) && (strip->prev->type == NLASTRIP_TYPE_TRANSITION))
+ if ((strip->prev) && (strip->prev->type == NLASTRIP_TYPE_TRANSITION)) {
BKE_nlastrip_free(&nlt->strips, strip->prev, true);
+ }
if ((nstrip) && (nstrip->type == NLASTRIP_TYPE_TRANSITION)) {
nstrip = nstrip->next;
BKE_nlastrip_free(&nlt->strips, strip->next, true);
@@ -1268,17 +1292,21 @@ static void nlaedit_split_strip_actclip(
/* strip extents */
len = strip->end - strip->start;
- if (IS_EQF(len, 0.0f))
+ if (IS_EQF(len, 0.0f)) {
return;
- else
+ }
+ else {
splitframe = strip->start + (len / 2.0f);
+ }
/* action range */
len = strip->actend - strip->actstart;
- if (IS_EQF(len, 0.0f))
+ if (IS_EQF(len, 0.0f)) {
splitaframe = strip->actend;
- else
+ }
+ else {
splitaframe = strip->actstart + (len / 2.0f);
+ }
}
/* make a copy (assume that this is possible) and append
@@ -1324,8 +1352,9 @@ static int nlaedit_split_exec(bContext *C, wmOperator *UNUSED(op))
int filter;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get a list of editable tracks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT);
@@ -1402,8 +1431,9 @@ static int nlaedit_toggle_mute_exec(bContext *C, wmOperator *UNUSED(op))
int filter;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get a list of the editable tracks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT);
@@ -1465,8 +1495,9 @@ static int nlaedit_swap_exec(bContext *C, wmOperator *op)
int filter;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get a list of the editable tracks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT);
@@ -1634,8 +1665,9 @@ static int nlaedit_move_up_exec(bContext *C, wmOperator *UNUSED(op))
int filter;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get a list of the editable tracks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT);
@@ -1650,8 +1682,9 @@ static int nlaedit_move_up_exec(bContext *C, wmOperator *UNUSED(op))
NlaStrip *strip, *stripn;
/* if this track has no tracks after it, skip for now... */
- if (nltn == NULL)
+ if (nltn == NULL) {
continue;
+ }
/* for every selected strip, try to move */
for (strip = nlt->strips.first; strip; strip = stripn) {
@@ -1709,8 +1742,9 @@ static int nlaedit_move_down_exec(bContext *C, wmOperator *UNUSED(op))
int filter;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get a list of the editable tracks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT);
@@ -1725,8 +1759,9 @@ static int nlaedit_move_down_exec(bContext *C, wmOperator *UNUSED(op))
NlaStrip *strip, *stripn;
/* if this track has no tracks before it, skip for now... */
- if (nltp == NULL)
+ if (nltp == NULL) {
continue;
+ }
/* for every selected strip, try to move */
for (strip = nlt->strips.first; strip; strip = stripn) {
@@ -1785,13 +1820,15 @@ static int nlaedit_sync_actlen_exec(bContext *C, wmOperator *op)
const bool active_only = RNA_boolean_get(op->ptr, "active");
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get a list of the editable tracks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT);
- if (active_only)
+ if (active_only) {
filter |= ANIMFILTER_ACTIVE;
+ }
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
/* for each NLA-Track, apply scale of all selected strips */
@@ -1802,18 +1839,21 @@ static int nlaedit_sync_actlen_exec(bContext *C, wmOperator *op)
for (strip = nlt->strips.first; strip; strip = strip->next) {
/* strip selection/active status check */
if (active_only) {
- if ((strip->flag & NLASTRIP_FLAG_ACTIVE) == 0)
+ if ((strip->flag & NLASTRIP_FLAG_ACTIVE) == 0) {
continue;
+ }
}
else {
- if ((strip->flag & NLASTRIP_FLAG_SELECT) == 0)
+ if ((strip->flag & NLASTRIP_FLAG_SELECT) == 0) {
continue;
+ }
}
/* must be action-clip only (transitions don't have scale) */
if (strip->type == NLASTRIP_TYPE_CLIP) {
- if (strip->act == NULL)
+ if (strip->act == NULL) {
continue;
+ }
/* recalculate the length of the action */
calc_action_range(strip->act, &strip->actstart, &strip->actend, 0);
@@ -1874,8 +1914,9 @@ static int nlaedit_make_single_user_exec(bContext *C, wmOperator *UNUSED(op))
bool copied = false;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get a list of the editable tracks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT);
@@ -1892,8 +1933,9 @@ static int nlaedit_make_single_user_exec(bContext *C, wmOperator *UNUSED(op))
for (strip = nlt->strips.last; strip; strip = strip->prev) {
/* must be action-clip only (as only these have actions) */
if ((strip->flag & NLASTRIP_FLAG_SELECT) && (strip->type == NLASTRIP_TYPE_CLIP)) {
- if (strip->act == NULL)
+ if (strip->act == NULL) {
continue;
+ }
/* multi-user? */
if (ID_REAL_USERS(strip->act) > 1) {
@@ -1975,8 +2017,9 @@ static int nlaedit_apply_scale_exec(bContext *C, wmOperator *UNUSED(op))
KeyframeEditData ked = {{NULL}};
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get a list of the editable tracks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT);
@@ -1993,8 +2036,9 @@ static int nlaedit_apply_scale_exec(bContext *C, wmOperator *UNUSED(op))
if ((strip->flag & NLASTRIP_FLAG_SELECT) && (strip->type == NLASTRIP_TYPE_CLIP)) {
/* if the referenced action is used by other strips,
* make this strip use its own copy */
- if (strip->act == NULL)
+ if (strip->act == NULL) {
continue;
+ }
if (strip->act->id.us > 1) {
/* make a copy of the Action to work on */
bAction *act = BKE_action_copy(bmain, strip->act);
@@ -2067,8 +2111,9 @@ static int nlaedit_clear_scale_exec(bContext *C, wmOperator *UNUSED(op))
int filter;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get a list of the editable tracks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT);
@@ -2145,8 +2190,9 @@ static int nlaedit_snap_exec(bContext *C, wmOperator *op)
float secf;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get a list of the editable tracks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT);
@@ -2294,10 +2340,12 @@ static const EnumPropertyItem *nla_fmodifier_itemf(bContext *C,
int index;
/* check if modifier is valid for this context */
- if (fmi == NULL)
+ if (fmi == NULL) {
continue;
- if (i == FMODIFIER_TYPE_CYCLES) /* we already have repeat... */
+ }
+ if (i == FMODIFIER_TYPE_CYCLES) { /* we already have repeat... */
continue;
+ }
index = RNA_enum_from_value(rna_enum_fmodifier_type_items, fmi->type);
if (index != -1) { /* Not all types are implemented yet... */
@@ -2324,8 +2372,9 @@ static int nla_fmodifier_add_exec(bContext *C, wmOperator *op)
const bool active_only = RNA_boolean_get(op->ptr, "only_active");
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get a list of the editable tracks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT);
@@ -2340,18 +2389,21 @@ static int nla_fmodifier_add_exec(bContext *C, wmOperator *op)
/* can F-Modifier be added to the current strip? */
if (active_only) {
/* if not active, cannot add since we're only adding to active strip */
- if ((strip->flag & NLASTRIP_FLAG_ACTIVE) == 0)
+ if ((strip->flag & NLASTRIP_FLAG_ACTIVE) == 0) {
continue;
+ }
}
else {
/* strip must be selected, since we're not just doing active */
- if ((strip->flag & NLASTRIP_FLAG_SELECT) == 0)
+ if ((strip->flag & NLASTRIP_FLAG_SELECT) == 0) {
continue;
+ }
}
/* sound clips are not affected by FModifiers */
- if (strip->type == NLASTRIP_TYPE_SOUND)
+ if (strip->type == NLASTRIP_TYPE_SOUND) {
continue;
+ }
/* add F-Modifier of specified type to selected, and make it the active one */
fcm = add_fmodifier(&strip->modifiers, type, NULL);
@@ -2418,8 +2470,9 @@ static int nla_fmodifier_copy_exec(bContext *C, wmOperator *op)
bool ok = false;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* clear buffer first */
ANIM_fmodifiers_copybuf_free();
@@ -2435,8 +2488,9 @@ static int nla_fmodifier_copy_exec(bContext *C, wmOperator *op)
for (strip = nlt->strips.first; strip; strip = strip->next) {
/* only add F-Modifier if on active strip? */
- if ((strip->flag & NLASTRIP_FLAG_ACTIVE) == 0)
+ if ((strip->flag & NLASTRIP_FLAG_ACTIVE) == 0) {
continue;
+ }
// TODO: when 'active' vs 'all' boolean is added, change last param!
ok |= ANIM_fmodifiers_copy_to_buf(&strip->modifiers, 0);
@@ -2494,8 +2548,9 @@ static int nla_fmodifier_paste_exec(bContext *C, wmOperator *op)
const bool replace = RNA_boolean_get(op->ptr, "replace");
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get a list of the editable tracks being shown in the NLA */
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT |
@@ -2511,13 +2566,15 @@ static int nla_fmodifier_paste_exec(bContext *C, wmOperator *op)
/* can F-Modifier be added to the current strip? */
if (active_only) {
/* if not active, cannot add since we're only adding to active strip */
- if ((strip->flag & NLASTRIP_FLAG_ACTIVE) == 0)
+ if ((strip->flag & NLASTRIP_FLAG_ACTIVE) == 0) {
continue;
+ }
}
else {
/* strip must be selected, since we're not just doing active */
- if ((strip->flag & NLASTRIP_FLAG_SELECT) == 0)
+ if ((strip->flag & NLASTRIP_FLAG_SELECT) == 0) {
continue;
+ }
}
/* paste FModifiers from buffer */
diff --git a/source/blender/editors/space_nla/nla_ops.c b/source/blender/editors/space_nla/nla_ops.c
index 9c2eb541f52..55470388e22 100644
--- a/source/blender/editors/space_nla/nla_ops.c
+++ b/source/blender/editors/space_nla/nla_ops.c
@@ -56,12 +56,14 @@ bool nlaop_poll_tweakmode_off(bContext *C)
* but not all AnimData blocks will be in tweakmode for
* various reasons
*/
- if (ED_operator_nla_active(C) == 0)
+ if (ED_operator_nla_active(C) == 0) {
return 0;
+ }
scene = CTX_data_scene(C);
- if ((scene == NULL) || (scene->flag & SCE_NLA_EDIT_ON))
+ if ((scene == NULL) || (scene->flag & SCE_NLA_EDIT_ON)) {
return 0;
+ }
return 1;
}
@@ -78,12 +80,14 @@ bool nlaop_poll_tweakmode_on(bContext *C)
* but not all AnimData blocks will be in tweakmode for
* various reasons
*/
- if (ED_operator_nla_active(C) == 0)
+ if (ED_operator_nla_active(C) == 0) {
return 0;
+ }
scene = CTX_data_scene(C);
- if ((scene == NULL) || !(scene->flag & SCE_NLA_EDIT_ON))
+ if ((scene == NULL) || !(scene->flag & SCE_NLA_EDIT_ON)) {
return 0;
+ }
return 1;
}
@@ -91,8 +95,9 @@ bool nlaop_poll_tweakmode_on(bContext *C)
/* is tweakmode enabled - for use in NLA operator code */
bool nlaedit_is_tweakmode_on(bAnimContext *ac)
{
- if (ac && ac->scene)
+ if (ac && ac->scene) {
return (ac->scene->flag & SCE_NLA_EDIT_ON) != 0;
+ }
return 0;
}
diff --git a/source/blender/editors/space_nla/nla_select.c b/source/blender/editors/space_nla/nla_select.c
index c872ae3e182..cb54129a820 100644
--- a/source/blender/editors/space_nla/nla_select.c
+++ b/source/blender/editors/space_nla/nla_select.c
@@ -119,8 +119,9 @@ static void deselect_nla_strips(bAnimContext *ac, short test, short sel)
}
}
- if (sel == SELECT_SUBTRACT)
+ if (sel == SELECT_SUBTRACT) {
break;
+ }
}
}
@@ -135,8 +136,9 @@ static void deselect_nla_strips(bAnimContext *ac, short test, short sel)
/* apply same selection to all strips */
for (strip = nlt->strips.first; strip; strip = strip->next) {
/* set selection */
- if (test != DESELECT_STRIPS_CLEARACTIVE)
+ if (test != DESELECT_STRIPS_CLEARACTIVE) {
ACHANNEL_SET_FLAG(strip, smode, NLASTRIP_FLAG_SELECT);
+ }
/* clear active flag */
/* TODO: for clear active,
@@ -156,8 +158,9 @@ static int nlaedit_deselectall_exec(bContext *C, wmOperator *op)
bAnimContext ac;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* 'standard' behavior - check if selected, then apply relevant selection */
const int action = RNA_enum_get(op->ptr, "action");
@@ -284,8 +287,9 @@ static int nlaedit_box_select_exec(bContext *C, wmOperator *op)
short mode = 0;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
const eSelectOp sel_op = RNA_enum_get(op->ptr, "mode");
const int selectmode = (sel_op != SEL_OP_SUB) ? SELECT_ADD : SELECT_SUBTRACT;
@@ -305,13 +309,16 @@ static int nlaedit_box_select_exec(bContext *C, wmOperator *op)
* as frame-range one is often.
* Used for tweaking timing when "blocking", while channels is not that useful.
*/
- if (BLI_rcti_size_x(&rect) >= BLI_rcti_size_y(&rect))
+ if (BLI_rcti_size_x(&rect) >= BLI_rcti_size_y(&rect)) {
mode = NLA_BOXSEL_FRAMERANGE;
- else
+ }
+ else {
mode = NLA_BOXSEL_CHANNELS;
+ }
}
- else
+ else {
mode = NLA_BOXSEL_ALLSTRIPS;
+ }
/* apply box_select action */
box_select_nla_strips(&ac, rect, mode, selectmode);
@@ -373,8 +380,9 @@ static void nlaedit_select_leftright(bContext *C,
float xmin, xmax;
/* if currently in tweakmode, exit tweakmode first */
- if (scene->flag & SCE_NLA_EDIT_ON)
+ if (scene->flag & SCE_NLA_EDIT_ON) {
WM_operator_name_call(C, "NLA_OT_tweakmode_exit", WM_OP_EXEC_DEFAULT, NULL);
+ }
/* if select mode is replace, deselect all keyframes (and channels) first */
if (select_mode == SELECT_REPLACE) {
@@ -428,18 +436,22 @@ static int nlaedit_select_leftright_exec(bContext *C, wmOperator *op)
short selectmode;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* select mode is either replace (deselect all, then add) or add/extend */
- if (RNA_boolean_get(op->ptr, "extend"))
+ if (RNA_boolean_get(op->ptr, "extend")) {
selectmode = SELECT_INVERT;
- else
+ }
+ else {
selectmode = SELECT_REPLACE;
+ }
/* if "test" mode is set, we don't have any info to set this with */
- if (leftright == NLAEDIT_LRSEL_TEST)
+ if (leftright == NLAEDIT_LRSEL_TEST) {
return OPERATOR_CANCELLED;
+ }
/* do the selecting now */
nlaedit_select_leftright(C, &ac, leftright, selectmode);
@@ -457,8 +469,9 @@ static int nlaedit_select_leftright_invoke(bContext *C, wmOperator *op, const wm
short leftright = RNA_enum_get(op->ptr, "mode");
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* handle mode-based testing */
if (leftright == NLAEDIT_LRSEL_TEST) {
@@ -469,10 +482,12 @@ static int nlaedit_select_leftright_invoke(bContext *C, wmOperator *op, const wm
/* determine which side of the current frame mouse is on */
x = UI_view2d_region_to_view_x(v2d, event->mval[0]);
- if (x < CFRA)
+ if (x < CFRA) {
RNA_enum_set(op->ptr, "mode", NLAEDIT_LRSEL_LEFT);
- else
+ }
+ else {
RNA_enum_set(op->ptr, "mode", NLAEDIT_LRSEL_RIGHT);
+ }
}
/* perform selection */
@@ -562,8 +577,9 @@ static void mouse_nla_strips(bContext *C, bAnimContext *ac, const int mval[2], s
/* loop over NLA-strips in this track,
* trying to find one which occurs in the necessary bounds */
for (strip = nlt->strips.first; strip; strip = strip->next) {
- if (BKE_nlastrip_within_bounds(strip, xmin, xmax))
+ if (BKE_nlastrip_within_bounds(strip, xmin, xmax)) {
break;
+ }
}
}
@@ -578,8 +594,9 @@ static void mouse_nla_strips(bContext *C, bAnimContext *ac, const int mval[2], s
/* if currently in tweakmode, exit tweakmode before changing selection states
* now that we've found our target...
*/
- if (scene->flag & SCE_NLA_EDIT_ON)
+ if (scene->flag & SCE_NLA_EDIT_ON) {
WM_operator_name_call(C, "NLA_OT_tweakmode_exit", WM_OP_EXEC_DEFAULT, NULL);
+ }
/* for replacing selection, firstly need to clear existing selection */
if (select_mode == SELECT_REPLACE) {
@@ -636,8 +653,9 @@ static int nlaedit_clickselect_invoke(bContext *C, wmOperator *op, const wmEvent
short selectmode;
/* get editor data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return OPERATOR_CANCELLED;
+ }
/* get useful pointers from animation context data */
/* scene= ac.scene; */ /* UNUSED */
@@ -645,10 +663,12 @@ static int nlaedit_clickselect_invoke(bContext *C, wmOperator *op, const wmEvent
// v2d= &ar->v2d;
/* select mode is either replace (deselect all, then add) or add/extend */
- if (RNA_boolean_get(op->ptr, "extend"))
+ if (RNA_boolean_get(op->ptr, "extend")) {
selectmode = SELECT_INVERT;
- else
+ }
+ else {
selectmode = SELECT_REPLACE;
+ }
/* select strips based upon mouse position */
mouse_nla_strips(C, &ac, event->mval, selectmode);
diff --git a/source/blender/editors/space_nla/space_nla.c b/source/blender/editors/space_nla/space_nla.c
index 26a7b42efd2..527a4f6e5f6 100644
--- a/source/blender/editors/space_nla/space_nla.c
+++ b/source/blender/editors/space_nla/space_nla.c
@@ -272,15 +272,17 @@ static void nla_main_region_draw(const bContext *C, ARegion *ar)
UI_view2d_view_ortho(v2d);
/* current frame */
- if (snla->flag & SNLA_DRAWTIME)
+ if (snla->flag & SNLA_DRAWTIME) {
cfra_flag |= DRAWCFRA_UNIT_SECONDS;
+ }
ANIM_draw_cfra(C, v2d, cfra_flag);
/* markers */
UI_view2d_view_orthoSpecial(ar, v2d, 1);
int marker_draw_flag = DRAW_MARKERS_MARGIN;
- if (snla->flag & SNLA_SHOW_MARKER_LINES)
+ if (snla->flag & SNLA_SHOW_MARKER_LINES) {
marker_draw_flag |= DRAW_MARKERS_LINES;
+ }
ED_markers_draw(C, marker_draw_flag);
/* preview range */
@@ -364,8 +366,9 @@ static void nla_region_listener(wmWindow *UNUSED(win),
}
break;
default:
- if (wmn->data == ND_KEYS)
+ if (wmn->data == ND_KEYS) {
ED_region_tag_redraw(ar);
+ }
break;
}
}
@@ -410,8 +413,9 @@ static void nla_main_region_listener(wmWindow *UNUSED(win),
}
break;
case NC_ID:
- if (wmn->action == NA_RENAME)
+ if (wmn->action == NA_RENAME) {
ED_region_tag_redraw(ar);
+ }
break;
case NC_SCREEN:
if (ELEM(wmn->data, ND_LAYER)) {
@@ -419,8 +423,9 @@ static void nla_main_region_listener(wmWindow *UNUSED(win),
}
break;
default:
- if (wmn->data == ND_KEYS)
+ if (wmn->data == ND_KEYS) {
ED_region_tag_redraw(ar);
+ }
break;
}
}
@@ -495,12 +500,14 @@ static void nla_channel_region_listener(wmWindow *UNUSED(win),
}
break;
case NC_ID:
- if (wmn->action == NA_RENAME)
+ if (wmn->action == NA_RENAME) {
ED_region_tag_redraw(ar);
+ }
break;
default:
- if (wmn->data == ND_KEYS)
+ if (wmn->data == ND_KEYS) {
ED_region_tag_redraw(ar);
+ }
break;
}
}
@@ -570,8 +577,9 @@ static void nla_listener(wmWindow *UNUSED(win), ScrArea *sa, wmNotifier *wmn, Sc
}
break;
case NC_SPACE:
- if (wmn->data == ND_SPACE_NLA)
+ if (wmn->data == ND_SPACE_NLA) {
ED_area_tag_redraw(sa);
+ }
break;
}
}
diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c
index 6e2516460b5..459736a730d 100644
--- a/source/blender/editors/space_outliner/outliner_select.c
+++ b/source/blender/editors/space_outliner/outliner_select.c
@@ -547,10 +547,11 @@ static eOLDrawState tree_element_active_defgroup(bContext *C,
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, ob);
}
else {
- if (ob == OBACT(view_layer))
+ if (ob == OBACT(view_layer)) {
if (ob->actdef == te->index + 1) {
return OL_DRAWSEL_NORMAL;
}
+ }
}
return OL_DRAWSEL_NONE;
}
diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c
index 02890f3bd92..69449f46677 100644
--- a/source/blender/editors/space_outliner/outliner_tree.c
+++ b/source/blender/editors/space_outliner/outliner_tree.c
@@ -958,7 +958,7 @@ static TreeElement *outliner_add_element(
/* Don't display arrays larger, weak but index is stored as a short,
* also the outliner isn't intended for editing such large data-sets. */
- BLI_STATIC_ASSERT(sizeof(te->index) == 2, "Index is no longer short!");
+ BLI_STATIC_ASSERT(sizeof(te->index) == 2, "Index is no longer short!")
const int tot_limit = SHRT_MAX;
int a, tot;
diff --git a/source/blender/editors/space_text/space_text.c b/source/blender/editors/space_text/space_text.c
index 506babafb6e..49d5ae06413 100644
--- a/source/blender/editors/space_text/space_text.c
+++ b/source/blender/editors/space_text/space_text.c
@@ -132,16 +132,18 @@ static void text_listener(wmWindow *UNUSED(win),
/* check if active text was changed, no need to redraw if text isn't active
* (reference == NULL) means text was unlinked, should update anyway for this
* case -- no way to know was text active before unlinking or not */
- if (wmn->reference && wmn->reference != st->text)
+ if (wmn->reference && wmn->reference != st->text) {
break;
+ }
switch (wmn->data) {
case ND_DISPLAY:
ED_area_tag_redraw(sa);
break;
case ND_CURSOR:
- if (st->text && st->text == wmn->reference)
+ if (st->text && st->text == wmn->reference) {
text_scroll_to_cursor__area(st, sa, true);
+ }
ED_area_tag_redraw(sa);
break;
@@ -161,16 +163,18 @@ static void text_listener(wmWindow *UNUSED(win),
ED_area_tag_redraw(sa);
break;
case NA_SELECTED:
- if (st->text && st->text == wmn->reference)
+ if (st->text && st->text == wmn->reference) {
text_scroll_to_cursor__area(st, sa, true);
+ }
break;
}
break;
case NC_SPACE:
- if (wmn->data == ND_SPACE_TEXT)
+ if (wmn->data == ND_SPACE_TEXT) {
ED_area_tag_redraw(sa);
+ }
break;
}
}
diff --git a/source/blender/editors/space_text/text_autocomplete.c b/source/blender/editors/space_text/text_autocomplete.c
index e60ac3d16a3..243642b2e8c 100644
--- a/source/blender/editors/space_text/text_autocomplete.c
+++ b/source/blender/editors/space_text/text_autocomplete.c
@@ -56,24 +56,29 @@ int text_do_suggest_select(SpaceText *st, ARegion *ar)
int tgti, *top;
int mval[2] = {0, 0};
- if (!st || !st->text)
+ if (!st || !st->text) {
return 0;
- if (!texttool_text_is_active(st->text))
+ }
+ if (!texttool_text_is_active(st->text)) {
return 0;
+ }
first = texttool_suggest_first();
last = texttool_suggest_last();
/* sel = texttool_suggest_selected(); */ /* UNUSED */
top = texttool_suggest_top();
- if (!last || !first)
+ if (!last || !first) {
return 0;
+ }
/* Count the visible lines to the cursor */
- for (tmp = st->text->curl, l = -st->top; tmp; tmp = tmp->prev, l++)
+ for (tmp = st->text->curl, l = -st->top; tmp; tmp = tmp->prev, l++) {
;
- if (l < 0)
+ }
+ if (l < 0) {
return 0;
+ }
text_update_character_width(st);
@@ -90,22 +95,27 @@ int text_do_suggest_select(SpaceText *st, ARegion *ar)
// XXX getmouseco_areawin(mval);
- if (mval[0] < x || x + w < mval[0] || mval[1] < y - h || y < mval[1])
+ if (mval[0] < x || x + w < mval[0] || mval[1] < y - h || y < mval[1]) {
return 0;
+ }
/* Work out which of the items is at the top of the visible list */
- for (i = 0, item = first; i < *top && item->next; i++, item = item->next)
+ for (i = 0, item = first; i < *top && item->next; i++, item = item->next) {
;
+ }
/* Work out the target item index in the visible list */
tgti = (y - mval[1] - 4) / st->lheight_dpi;
- if (tgti < 0 || tgti > SUGG_LIST_SIZE)
+ if (tgti < 0 || tgti > SUGG_LIST_SIZE) {
return 1;
+ }
- for (i = tgti; i > 0 && item->next; i--, item = item->next)
+ for (i = tgti; i > 0 && item->next; i--, item = item->next) {
;
- if (item)
+ }
+ if (item) {
texttool_suggest_select(item);
+ }
return 1;
}
@@ -123,10 +133,12 @@ void text_pop_suggest_list(void)
item = item->next;
i++;
}
- if (i > *top + SUGG_LIST_SIZE - 1)
+ if (i > *top + SUGG_LIST_SIZE - 1) {
*top = i - SUGG_LIST_SIZE + 1;
- else if (i < *top)
+ }
+ else if (i < *top) {
*top = i;
+ }
}
/* -------------------------------------------------------------------- */
@@ -235,10 +247,12 @@ static void get_suggest_prefix(Text *text, int offset)
int i, len;
const char *line;
- if (!text)
+ if (!text) {
return;
- if (!texttool_text_is_active(text))
+ }
+ if (!texttool_text_is_active(text)) {
return;
+ }
line = text->curl->line;
i = text_find_identifier_start(line, text->curc + offset);
@@ -252,14 +266,17 @@ static void confirm_suggestion(Text *text, TextUndoBuf *utxt)
int i, over = 0;
const char *line;
- if (!text)
+ if (!text) {
return;
- if (!texttool_text_is_active(text))
+ }
+ if (!texttool_text_is_active(text)) {
return;
+ }
sel = texttool_suggest_selected();
- if (!sel)
+ if (!sel) {
return;
+ }
line = text->curl->line;
i = text_find_identifier_start(line, text->curc /* - skipleft */);
@@ -324,17 +341,20 @@ static int text_autocomplete_modal(bContext *C, wmOperator *op, const wmEvent *e
(void)text;
if (st->doplugins && texttool_text_is_active(st->text)) {
- if (texttool_suggest_first())
+ if (texttool_suggest_first()) {
tools |= TOOL_SUGG_LIST;
- if (texttool_docs_get())
+ }
+ if (texttool_docs_get()) {
tools |= TOOL_DOCUMENT;
+ }
}
switch (event->type) {
case LEFTMOUSE:
if (event->val == KM_PRESS) {
- if (text_do_suggest_select(st, ar))
+ if (text_do_suggest_select(st, ar)) {
swallow = 1;
+ }
else {
if (tools & TOOL_SUGG_LIST) {
texttool_suggest_clear();
@@ -380,8 +400,9 @@ static int text_autocomplete_modal(bContext *C, wmOperator *op, const wmEvent *e
texttool_docs_clear();
doc_scroll = 0;
}
- else
+ else {
draw = swallow = 0;
+ }
retval = OPERATOR_CANCELLED;
}
break;
@@ -510,8 +531,9 @@ static int text_autocomplete_modal(bContext *C, wmOperator *op, const wmEvent *e
case UPARROWKEY:
if (event->val == KM_PRESS) {
if (tools & TOOL_DOCUMENT) {
- if (doc_scroll > 0)
+ if (doc_scroll > 0) {
doc_scroll--;
+ }
swallow = 1;
draw = 1;
}
diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c
index b2c5f42adb4..cdd691fe879 100644
--- a/source/blender/editors/space_text/text_draw.c
+++ b/source/blender/editors/space_text/text_draw.c
@@ -204,10 +204,12 @@ void wrap_offset(
*offl = *offc = 0;
- if (!st->text)
+ if (!st->text) {
return;
- if (!st->wordwrap)
+ }
+ if (!st->wordwrap) {
return;
+ }
text = st->text;
@@ -219,9 +221,10 @@ void wrap_offset(
/* Line before top */
if (linep == linein) {
- if (lines <= i)
+ if (lines <= i) {
/* no visible part of line */
return;
+ }
}
if (i - lines < 0) {
@@ -250,8 +253,9 @@ void wrap_offset(
ch = linep->line[j];
if (ch == '\t') {
chars = st->tabnumber - i % st->tabnumber;
- if (linep == linein && i < cursin)
+ if (linep == linein && i < cursin) {
cursin += chars - 1;
+ }
ch = ' ';
}
else {
@@ -281,14 +285,16 @@ void wrap_offset(
else if (ch == ' ' || ch == '-') {
end = i + 1;
chop = 0;
- if (linep == linein && i >= cursin)
+ if (linep == linein && i >= cursin) {
return;
+ }
}
i += columns;
}
}
- if (linep == linein)
+ if (linep == linein) {
break;
+ }
linep = linep->next;
}
}
@@ -302,10 +308,12 @@ void wrap_offset_in_line(
*offl = *offc = 0;
- if (!st->text)
+ if (!st->text) {
return;
- if (!st->wordwrap)
+ }
+ if (!st->wordwrap) {
return;
+ }
max = wrap_width(st, ar);
@@ -322,12 +330,14 @@ void wrap_offset_in_line(
ch = linein->line[j];
if (ch == '\t') {
chars = st->tabnumber - i % st->tabnumber;
- if (i < cursin)
+ if (i < cursin) {
cursin += chars - 1;
+ }
ch = ' ';
}
- else
+ else {
chars = 1;
+ }
while (chars--) {
if (i + columns - start > max) {
@@ -352,8 +362,9 @@ void wrap_offset_in_line(
else if (ch == ' ' || ch == '-') {
end = i + 1;
chop = 0;
- if (i >= cursin)
+ if (i >= cursin) {
return;
+ }
}
i += columns;
}
@@ -365,10 +376,12 @@ int text_get_char_pos(const SpaceText *st, const char *line, int cur)
int a = 0, i;
for (i = 0; i < cur && line[i]; i += BLI_str_utf8_size_safe(line + i)) {
- if (line[i] == '\t')
+ if (line[i] == '\t') {
a += st->tabnumber - a % st->tabnumber;
- else
+ }
+ else {
a += BLI_str_utf8_char_width_safe(line + i);
+ }
}
return a;
}
@@ -379,15 +392,18 @@ static const char *txt_utf8_forward_columns(const char *str, int columns, int *p
const char *p = str;
while (*p) {
col = BLI_str_utf8_char_width(p);
- if (columns - col < 0)
+ if (columns - col < 0) {
break;
+ }
columns -= col;
p += BLI_str_utf8_size_safe(p);
- if (columns == 0)
+ if (columns == 0) {
break;
+ }
}
- if (padding)
+ if (padding) {
*padding = *p ? columns : 0;
+ }
return p;
}
@@ -414,8 +430,9 @@ static int text_draw_wrapped(const SpaceText *st,
flatten_string(st, &fs, str);
str = fs.buf;
max = w / st->cwidth;
- if (max < 8)
+ if (max < 8) {
max = 8;
+ }
basex = x;
lines = 1;
@@ -444,8 +461,9 @@ static int text_draw_wrapped(const SpaceText *st,
/* Draw the visible portion of text on the overshot line */
for (a = fstart, ma = mstart; ma < mend; a++, ma += BLI_str_utf8_size_safe(str + ma)) {
if (use_syntax) {
- if (fmt_prev != format[a])
+ if (fmt_prev != format[a]) {
format_draw_color(tdc, fmt_prev = format[a]);
+ }
}
x += text_font_draw_character_utf8(tdc, x, y, str + ma);
fpos++;
@@ -458,8 +476,9 @@ static int text_draw_wrapped(const SpaceText *st,
mend = txt_utf8_forward_columns(str + mend, max, &padding) - str;
end = (wrap += max - padding);
- if (y <= clip_min_y)
+ if (y <= clip_min_y) {
break;
+ }
}
else if (str[mi] == ' ' || str[mi] == '-') {
wrap = i + 1;
@@ -471,8 +490,9 @@ static int text_draw_wrapped(const SpaceText *st,
for (a = fstart, ma = mstart; str[ma] && y > clip_min_y;
a++, ma += BLI_str_utf8_size_safe(str + ma)) {
if (use_syntax) {
- if (fmt_prev != format[a])
+ if (fmt_prev != format[a]) {
format_draw_color(tdc, fmt_prev = format[a]);
+ }
}
x += text_font_draw_character_utf8(tdc, x, y, str + ma);
@@ -506,12 +526,14 @@ static void text_draw(const SpaceText *st,
padding = w - cshift;
in = str;
}
- else if (format)
+ else if (format) {
format++;
+ }
}
if (in) {
- if (maxwidth && w + columns > cshift + maxwidth)
+ if (maxwidth && w + columns > cshift + maxwidth) {
break;
+ }
amount++;
}
@@ -530,8 +552,9 @@ static void text_draw(const SpaceText *st,
char fmt_prev = 0xff;
for (a = 0; a < amount; a++) {
- if (format[a] != fmt_prev)
+ if (format[a] != fmt_prev) {
format_draw_color(tdc, fmt_prev = format[a]);
+ }
x += text_font_draw_character_utf8(tdc, x, y, in + str_shift);
str_shift += BLI_str_utf8_size_safe(in + str_shift);
}
@@ -577,8 +600,9 @@ static void text_update_drawcache(SpaceText *st, ARegion *ar)
int full_update = 0, nlines = 0;
Text *txt = st->text;
- if (!st->drawcache)
+ if (!st->drawcache) {
text_drawcache_init(st);
+ }
text_update_character_width(st);
@@ -618,10 +642,12 @@ static void text_update_drawcache(SpaceText *st, ARegion *ar)
nlines = BLI_listbase_count(&txt->lines);
size = sizeof(int) * nlines;
- if (fp)
+ if (fp) {
fp = MEM_reallocN(fp, size);
- else
+ }
+ else {
fp = MEM_callocN(size, "text drawcache line_height");
+ }
drawcache->valid_tail = drawcache->valid_head = 0;
old_tail = fp + drawcache->nlines - drawcache->valid_tail;
@@ -630,8 +656,9 @@ static void text_update_drawcache(SpaceText *st, ARegion *ar)
drawcache->total_lines = 0;
- if (st->showlinenrs)
+ if (st->showlinenrs) {
st->linenrs_tot = integer_digits_i(nlines);
+ }
while (line) {
if (drawcache->valid_head) { /* we're inside valid head lines */
@@ -664,8 +691,9 @@ static void text_update_drawcache(SpaceText *st, ARegion *ar)
if (full_update || drawcache->update_flag) {
nlines = BLI_listbase_count(&txt->lines);
- if (st->showlinenrs)
+ if (st->showlinenrs) {
st->linenrs_tot = integer_digits_i(nlines);
+ }
}
drawcache->total_lines = nlines;
@@ -692,8 +720,9 @@ static void text_update_drawcache(SpaceText *st, ARegion *ar)
void text_drawcache_tag_update(SpaceText *st, int full)
{
/* this happens if text editor ops are caled from python */
- if (st == NULL)
+ if (st == NULL) {
return;
+ }
if (st->drawcache) {
DrawCache *drawcache = (DrawCache *)st->drawcache;
@@ -721,10 +750,12 @@ void text_drawcache_tag_update(SpaceText *st, int full)
/* quick cache recalculation is also used in delete operator,
* which could merge lines which are adjacent to current selection lines
* expand recalculate area to this lines */
- if (drawcache->valid_head > 0)
+ if (drawcache->valid_head > 0) {
drawcache->valid_head--;
- if (drawcache->valid_tail > 0)
+ }
+ if (drawcache->valid_tail > 0) {
drawcache->valid_tail--;
+ }
}
else {
drawcache->valid_head = 0;
@@ -740,8 +771,9 @@ void text_free_caches(SpaceText *st)
DrawCache *drawcache = (DrawCache *)st->drawcache;
if (drawcache) {
- if (drawcache->line_height)
+ if (drawcache->line_height) {
MEM_freeN(drawcache->line_height);
+ }
MEM_freeN(drawcache);
}
@@ -804,8 +836,9 @@ int text_get_span_wrap(const SpaceText *st, ARegion *ar, TextLine *from, TextLin
/* Look forwards */
while (tmp) {
- if (tmp == to)
+ if (tmp == to) {
return ret;
+ }
ret += text_get_visible_lines(st, ar, tmp->line);
tmp = tmp->next;
}
@@ -876,8 +909,9 @@ static void calc_text_rcts(SpaceText *st, ARegion *ar, rcti *scroll, rcti *back)
CLAMP(st->txtbar.ymax, pix_bottom_margin, ar->winy - pix_top_margin);
st->pix_per_line = (pix_available > 0) ? (float)ltexth / pix_available : 0;
- if (st->pix_per_line < 0.1f)
+ if (st->pix_per_line < 0.1f) {
st->pix_per_line = 0.1f;
+ }
curl_off = text_get_span_wrap(st, ar, st->text->lines.first, st->text->curl);
sell_off = text_get_span_wrap(st, ar, st->text->lines.first, st->text->sell);
@@ -1098,16 +1132,19 @@ static void draw_suggestion_list(const SpaceText *st, const TextDrawContext *tdc
const int lheight = st->lheight_dpi + TXT_LINE_SPACING;
const int margin_x = 2;
- if (!st->text)
+ if (!st->text) {
return;
- if (!texttool_text_is_active(st->text))
+ }
+ if (!texttool_text_is_active(st->text)) {
return;
+ }
first = texttool_suggest_first();
last = texttool_suggest_last();
- if (!first || !last)
+ if (!first || !last) {
return;
+ }
text_pop_suggest_list();
sel = texttool_suggest_selected();
@@ -1129,8 +1166,9 @@ static void draw_suggestion_list(const SpaceText *st, const TextDrawContext *tdc
boxw = SUGG_LIST_WIDTH * st->cwidth + 20;
boxh = SUGG_LIST_SIZE * lheight + 8;
- if (x + boxw > ar->winx)
+ if (x + boxw > ar->winx) {
x = MAX2(0, ar->winx - boxw);
+ }
/* not needed but stands out nicer */
UI_draw_box_shadow(220, x, y - boxh, x + boxw, y);
@@ -1147,8 +1185,9 @@ static void draw_suggestion_list(const SpaceText *st, const TextDrawContext *tdc
immUnbindProgram();
/* Set the top 'item' of the visible list */
- for (i = 0, item = first; i < *top && item->next; i++, item = item->next)
+ for (i = 0, item = first; i < *top && item->next; i++, item = item->next) {
;
+ }
for (i = 0; i < SUGG_LIST_SIZE && item; i++, item = item->next) {
int len = txt_utf8_forward_columns(item->name, SUGG_LIST_WIDTH, NULL) - item->name;
@@ -1173,8 +1212,9 @@ static void draw_suggestion_list(const SpaceText *st, const TextDrawContext *tdc
format_draw_color(tdc, item->type);
text_draw(st, tdc, str, 0, 0, x + margin_x, y - 1, NULL);
- if (item == last)
+ if (item == last) {
break;
+ }
}
}
@@ -1307,8 +1347,9 @@ static void draw_text_decoration(SpaceText *st, ARegion *ar)
y += TXT_LINE_SPACING;
w = st->cwidth;
- if (ch == '\t')
+ if (ch == '\t') {
w *= st->tabnumber - (vselc + st->left) % st->tabnumber;
+ }
immRecti(pos, x, y - lheight - 1, x + w, y - lheight + 1);
}
@@ -1332,16 +1373,19 @@ static void draw_brackets(const SpaceText *st, const TextDrawContext *tdc, ARegi
char ch;
// showsyntax must be on or else the format string will be null
- if (!text->curl || !st->showsyntax)
+ if (!text->curl || !st->showsyntax) {
return;
+ }
startl = text->curl;
startc = text->curc;
b = text_check_bracket(startl->line[startc]);
- if (b == 0 && startc > 0)
+ if (b == 0 && startc > 0) {
b = text_check_bracket(startl->line[--startc]);
- if (b == 0)
+ }
+ if (b == 0) {
return;
+ }
linep = startl;
c = startc;
@@ -1353,8 +1397,9 @@ static void draw_brackets(const SpaceText *st, const TextDrawContext *tdc, ARegi
/* Don't highlight backets if syntax HL is off or bracket in string or comment. */
if (!linep->format || linep->format[fc] == FMT_TYPE_STRING ||
- linep->format[fc] == FMT_TYPE_COMMENT)
+ linep->format[fc] == FMT_TYPE_COMMENT) {
return;
+ }
if (b > 0) {
/* opening bracket, search forward for close */
@@ -1380,8 +1425,9 @@ static void draw_brackets(const SpaceText *st, const TextDrawContext *tdc, ARegi
fc++;
c += BLI_str_utf8_size_safe(linep->line + c);
}
- if (endl)
+ if (endl) {
break;
+ }
linep = linep->next;
c = 0;
fc = 0;
@@ -1390,8 +1436,9 @@ static void draw_brackets(const SpaceText *st, const TextDrawContext *tdc, ARegi
else {
/* closing bracket, search backward for open */
fc--;
- if (c > 0)
+ if (c > 0) {
c -= linep->line + c - BLI_str_prev_char_utf8(linep->line + c);
+ }
while (linep) {
while (fc >= 0) {
if (linep->format && linep->format[fc] != FMT_TYPE_STRING &&
@@ -1410,27 +1457,34 @@ static void draw_brackets(const SpaceText *st, const TextDrawContext *tdc, ARegi
}
}
fc--;
- if (c > 0)
+ if (c > 0) {
c -= linep->line + c - BLI_str_prev_char_utf8(linep->line + c);
+ }
}
- if (endl)
+ if (endl) {
break;
+ }
linep = linep->prev;
if (linep) {
- if (linep->format)
+ if (linep->format) {
fc = strlen(linep->format) - 1;
- else
+ }
+ else {
fc = -1;
- if (linep->len)
+ }
+ if (linep->len) {
c = BLI_str_prev_char_utf8(linep->line + linep->len) - linep->line;
- else
+ }
+ else {
fc = -1;
+ }
}
}
}
- if (!endl || endc == -1)
+ if (!endl || endc == -1) {
return;
+ }
UI_FontThemeColor(tdc->font_id, TH_HILITE);
x = st->showlinenrs ? TXT_OFFSET + TEXTXLOC : TXT_OFFSET;
@@ -1480,8 +1534,9 @@ void draw_text_main(SpaceText *st, ARegion *ar)
int margin_column_x;
/* if no text, nothing to do */
- if (!text)
+ if (!text) {
return;
+ }
/* dpi controlled line height and font size */
st->lheight_dpi = (U.widget_unit * st->lheight) / 20;
@@ -1498,8 +1553,9 @@ void draw_text_main(SpaceText *st, ARegion *ar)
text_update_drawcache(st, ar);
/* make sure all the positional pointers exist */
- if (!text->curl || !text->sell || !text->lines.first || !text->lines.last)
+ if (!text->curl || !text->sell || !text->lines.first || !text->lines.last) {
txt_clean_text(text);
+ }
/* update rects for scroll */
calc_text_rcts(st, ar, &scroll, &back); /* scroll will hold the entire bar size */
@@ -1509,8 +1565,9 @@ void draw_text_main(SpaceText *st, ARegion *ar)
tmp = text->lines.first;
lineno = 0;
for (i = 0; i < st->top && tmp; i++) {
- if (st->showsyntax && !tmp->format)
+ if (st->showsyntax && !tmp->format) {
tft->format_line(st, tmp, false);
+ }
if (st->wordwrap) {
int lines = text_get_visible_lines_no(st, lineno);
@@ -1563,8 +1620,9 @@ void draw_text_main(SpaceText *st, ARegion *ar)
UI_FontThemeColor(tdc.font_id, TH_TEXT);
for (i = 0; y > clip_min_y && i < st->viewlines && tmp; i++, tmp = tmp->next) {
- if (st->showsyntax && !tmp->format)
+ if (st->showsyntax && !tmp->format) {
tft->format_line(st, tmp, false);
+ }
if (st->showlinenrs && !wrap_skip) {
/* draw line number */
@@ -1654,8 +1712,9 @@ void text_scroll_to_cursor(SpaceText *st, ARegion *ar, const bool center)
Text *text;
int i, x, winx = ar->winx;
- if (ELEM(NULL, st, st->text, st->text->curl))
+ if (ELEM(NULL, st, st->text, st->text->curl)) {
return;
+ }
text = st->text;
@@ -1704,10 +1763,12 @@ void text_scroll_to_cursor(SpaceText *st, ARegion *ar, const bool center)
}
}
- if (st->top < 0)
+ if (st->top < 0) {
st->top = 0;
- if (st->left < 0)
+ }
+ if (st->left < 0) {
st->left = 0;
+ }
st->scroll_accum[0] = 0.0f;
st->scroll_accum[1] = 0.0f;
@@ -1718,8 +1779,9 @@ void text_scroll_to_cursor__area(SpaceText *st, ScrArea *sa, const bool center)
{
ARegion *ar;
- if (ELEM(NULL, st, st->text, st->text->curl))
+ if (ELEM(NULL, st, st->text, st->text->curl)) {
return;
+ }
ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
diff --git a/source/blender/editors/space_text/text_format.c b/source/blender/editors/space_text/text_format.c
index 0a885fc5875..8c102dc009e 100644
--- a/source/blender/editors/space_text/text_format.c
+++ b/source/blender/editors/space_text/text_format.c
@@ -79,8 +79,9 @@ int flatten_string(const SpaceText *st, FlattenString *fs, const char *in)
i = st->tabnumber - (total % st->tabnumber);
total += i;
- while (i--)
+ while (i--) {
flatten_string_append(fs, " ", r, 1);
+ }
in++;
}
@@ -99,10 +100,12 @@ int flatten_string(const SpaceText *st, FlattenString *fs, const char *in)
void flatten_string_free(FlattenString *fs)
{
- if (fs->buf != fs->fixedbuf)
+ if (fs->buf != fs->fixedbuf) {
MEM_freeN(fs->buf);
- if (fs->accum != fs->fixedaccum)
+ }
+ if (fs->accum != fs->fixedaccum) {
MEM_freeN(fs->accum);
+ }
}
/* takes a string within fs->buf and returns its length */
@@ -121,14 +124,16 @@ int text_check_format_len(TextLine *line, unsigned int len)
if (strlen(line->format) < len) {
MEM_freeN(line->format);
line->format = MEM_mallocN(len + 2, "SyntaxFormat");
- if (!line->format)
+ if (!line->format) {
return 0;
+ }
}
}
else {
line->format = MEM_mallocN(len + 2, "SyntaxFormat");
- if (!line->format)
+ if (!line->format) {
return 0;
+ }
}
return 1;
diff --git a/source/blender/editors/space_text/text_format_lua.c b/source/blender/editors/space_text/text_format_lua.c
index b82e8aec122..347d46a4234 100644
--- a/source/blender/editors/space_text/text_format_lua.c
+++ b/source/blender/editors/space_text/text_format_lua.c
@@ -48,31 +48,33 @@ static int txtfmt_lua_find_keyword(const char *string)
/* Keep aligned args for readability. */
/* clang-format off */
- if (STR_LITERAL_STARTSWITH(string, "and", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "break", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "do", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "else", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "elseif", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "end", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "for", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "function", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "if", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "in", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "local", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "not", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "or", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "repeat", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "return", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "then", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "until", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "while", len)) i = len;
- else i = 0;
+ if (STR_LITERAL_STARTSWITH(string, "and", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "break", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "do", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "else", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "elseif", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "end", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "for", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "function", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "if", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "in", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "local", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "not", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "or", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "repeat", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "return", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "then", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "until", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "while", len)) { i = len;
+ } else { i = 0;
+}
/* clang-format on */
/* If next source char is an identifier (eg. 'i' in "definite") no match */
- if (i == 0 || text_check_identifier(string[i]))
+ if (i == 0 || text_check_identifier(string[i])) {
return -1;
+ }
return i;
}
@@ -94,41 +96,43 @@ static int txtfmt_lua_find_specialvar(const char *string)
/* Keep aligned args for readability. */
/* clang-format off */
- if (STR_LITERAL_STARTSWITH(string, "assert", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "collectgarbage", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "dofile", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "error", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "_G", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "getfenv", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "getmetatable", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "__index", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "ipairs", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "load", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "loadfile", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "loadstring", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "next", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "pairs", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "pcall", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "print", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "rawequal", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "rawget", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "rawset", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "select", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "setfenv", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "setmetatable", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "tonumber", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "tostring", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "type", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "unpack", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "_VERSION", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "xpcall", len)) i = len;
- else i = 0;
+ if (STR_LITERAL_STARTSWITH(string, "assert", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "collectgarbage", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "dofile", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "error", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "_G", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "getfenv", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "getmetatable", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "__index", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "ipairs", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "load", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "loadfile", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "loadstring", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "next", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "pairs", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "pcall", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "print", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "rawequal", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "rawget", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "rawset", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "select", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "setfenv", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "setmetatable", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "tonumber", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "tostring", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "type", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "unpack", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "_VERSION", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "xpcall", len)) { i = len;
+ } else { i = 0;
+}
/* clang-format on */
/* If next source char is an identifier (eg. 'i' in "definite") no match */
- if (i == 0 || text_check_identifier(string[i]))
+ if (i == 0 || text_check_identifier(string[i])) {
return -1;
+ }
return i;
}
@@ -136,20 +140,25 @@ static int txtfmt_lua_find_bool(const char *string)
{
int i, len;
- if (STR_LITERAL_STARTSWITH(string, "nil", len))
+ if (STR_LITERAL_STARTSWITH(string, "nil", len)) {
i = len;
- else if (STR_LITERAL_STARTSWITH(string, "true", len))
+ }
+ else if (STR_LITERAL_STARTSWITH(string, "true", len)) {
i = len;
- else if (STR_LITERAL_STARTSWITH(string, "false", len))
+ }
+ else if (STR_LITERAL_STARTSWITH(string, "false", len)) {
i = len;
- else
+ }
+ else {
i = 0;
+ }
/* clang-format on */
/* If next source char is an identifier (eg. 'i' in "Nonetheless") no match */
- if (i == 0 || text_check_identifier(string[i]))
+ if (i == 0 || text_check_identifier(string[i])) {
return -1;
+ }
return i;
}
@@ -160,9 +169,10 @@ static char txtfmt_lua_format_identifier(const char *str)
/* Keep aligned args for readability. */
/* clang-format off */
- if ((txtfmt_lua_find_specialvar(str)) != -1) fmt = FMT_TYPE_SPECIAL;
- else if ((txtfmt_lua_find_keyword(str)) != -1) fmt = FMT_TYPE_KEYWORD;
- else fmt = FMT_TYPE_DEFAULT;
+ if ((txtfmt_lua_find_specialvar(str)) != -1) { fmt = FMT_TYPE_SPECIAL;
+ } else if ((txtfmt_lua_find_keyword(str)) != -1) { fmt = FMT_TYPE_KEYWORD;
+ } else { fmt = FMT_TYPE_DEFAULT;
+}
/* clang-format on */
@@ -211,8 +221,9 @@ static void txtfmt_lua_format_line(SpaceText *st, TextLine *line, const bool do_
*fmt = prev;
fmt++;
str++;
- if (*str == '\0')
+ if (*str == '\0') {
break;
+ }
*fmt = prev;
fmt++;
str += BLI_str_utf8_size_safe(str);
@@ -236,8 +247,9 @@ static void txtfmt_lua_format_line(SpaceText *st, TextLine *line, const bool do_
}
else {
find = (cont & FMT_CONT_QUOTEDOUBLE) ? '"' : '\'';
- if (*str == find)
+ if (*str == find) {
cont = 0;
+ }
*fmt = FMT_TYPE_STRING;
}
@@ -304,8 +316,9 @@ static void txtfmt_lua_format_line(SpaceText *st, TextLine *line, const bool do_
/* Special vars(v) or built-in keywords(b) */
/* keep in sync with 'txtfmt_osl_format_identifier()' */
- if ((i = txtfmt_lua_find_specialvar(str)) != -1) prev = FMT_TYPE_SPECIAL;
- else if ((i = txtfmt_lua_find_keyword(str)) != -1) prev = FMT_TYPE_KEYWORD;
+ if ((i = txtfmt_lua_find_specialvar(str)) != -1) { prev = FMT_TYPE_SPECIAL;
+ } else if ((i = txtfmt_lua_find_keyword(str)) != -1) { prev = FMT_TYPE_KEYWORD;
+}
/* clang-format on */
diff --git a/source/blender/editors/space_text/text_format_osl.c b/source/blender/editors/space_text/text_format_osl.c
index 8473b3f80ce..fb9ddcb09cb 100644
--- a/source/blender/editors/space_text/text_format_osl.c
+++ b/source/blender/editors/space_text/text_format_osl.c
@@ -40,37 +40,39 @@ static int txtfmt_osl_find_builtinfunc(const char *string)
/* list is from
* https://github.com/imageworks/OpenShadingLanguage/raw/master/src/doc/osl-languagespec.pdf
*/
- if (STR_LITERAL_STARTSWITH(string, "break", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "closure", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "color", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "continue", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "do", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "else", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "emit", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "float", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "for", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "if", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "illuminance", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "illuminate", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "int", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "matrix", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "normal", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "output", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "point", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "public", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "return", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "string", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "struct", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "vector", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "void", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "while", len)) i = len;
- else i = 0;
+ if (STR_LITERAL_STARTSWITH(string, "break", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "closure", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "color", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "continue", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "do", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "else", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "emit", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "float", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "for", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "if", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "illuminance", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "illuminate", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "int", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "matrix", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "normal", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "output", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "point", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "public", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "return", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "string", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "struct", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "vector", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "void", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "while", len)) { i = len;
+ } else { i = 0;
+}
/* clang-format on */
/* If next source char is an identifier (eg. 'i' in "definite") no match */
- if (i == 0 || text_check_identifier(string[i]))
+ if (i == 0 || text_check_identifier(string[i])) {
return -1;
+ }
return i;
}
@@ -84,49 +86,51 @@ static int txtfmt_osl_find_reserved(const char *string)
/* list is from...
* https://github.com/imageworks/OpenShadingLanguage/raw/master/src/doc/osl-languagespec.pdf
*/
- if (STR_LITERAL_STARTSWITH(string, "bool", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "case", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "catch", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "char", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "const", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "delete", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "default", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "double", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "enum", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "extern", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "false", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "friend", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "goto", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "inline", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "long", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "new", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "operator", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "private", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "protected", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "short", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "signed", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "sizeof", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "static", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "switch", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "template", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "this", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "throw", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "true", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "try", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "typedef", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "uniform", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "union", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "unsigned", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "varying", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "virtual", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "volatile", len)) i = len;
- else i = 0;
+ if (STR_LITERAL_STARTSWITH(string, "bool", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "case", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "catch", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "char", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "const", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "delete", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "default", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "double", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "enum", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "extern", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "false", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "friend", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "goto", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "inline", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "long", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "new", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "operator", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "private", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "protected", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "short", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "signed", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "sizeof", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "static", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "switch", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "template", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "this", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "throw", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "true", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "try", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "typedef", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "uniform", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "union", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "unsigned", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "varying", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "virtual", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "volatile", len)) { i = len;
+ } else { i = 0;
+}
/* clang-format on */
/* If next source char is an identifier (eg. 'i' in "definite") no match */
- if (i == 0 || text_check_identifier(string[i]))
+ if (i == 0 || text_check_identifier(string[i])) {
return -1;
+ }
return i;
}
@@ -145,17 +149,19 @@ static int txtfmt_osl_find_specialvar(const char *string)
/* clang-format off */
/* OSL shader types */
- if (STR_LITERAL_STARTSWITH(string, "shader", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "surface", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "volume", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "displacement", len)) i = len;
- else i = 0;
+ if (STR_LITERAL_STARTSWITH(string, "shader", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "surface", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "volume", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "displacement", len)) { i = len;
+ } else { i = 0;
+}
/* clang-format on */
/* If next source char is an identifier (eg. 'i' in "definite") no match */
- if (i == 0 || text_check_identifier(string[i]))
+ if (i == 0 || text_check_identifier(string[i])) {
return -1;
+ }
return i;
}
@@ -183,11 +189,12 @@ static char txtfmt_osl_format_identifier(const char *str)
/* Keep aligned args for readability. */
/* clang-format off */
- if ((txtfmt_osl_find_specialvar(str)) != -1) fmt = FMT_TYPE_SPECIAL;
- else if ((txtfmt_osl_find_builtinfunc(str)) != -1) fmt = FMT_TYPE_KEYWORD;
- else if ((txtfmt_osl_find_reserved(str)) != -1) fmt = FMT_TYPE_RESERVED;
- else if ((txtfmt_osl_find_preprocessor(str)) != -1) fmt = FMT_TYPE_DIRECTIVE;
- else fmt = FMT_TYPE_DEFAULT;
+ if ((txtfmt_osl_find_specialvar(str)) != -1) { fmt = FMT_TYPE_SPECIAL;
+ } else if ((txtfmt_osl_find_builtinfunc(str)) != -1) { fmt = FMT_TYPE_KEYWORD;
+ } else if ((txtfmt_osl_find_reserved(str)) != -1) { fmt = FMT_TYPE_RESERVED;
+ } else if ((txtfmt_osl_find_preprocessor(str)) != -1) { fmt = FMT_TYPE_DIRECTIVE;
+ } else { fmt = FMT_TYPE_DEFAULT;
+}
/* clang-format on */
@@ -236,8 +243,9 @@ static void txtfmt_osl_format_line(SpaceText *st, TextLine *line, const bool do_
*fmt = prev;
fmt++;
str++;
- if (*str == '\0')
+ if (*str == '\0') {
break;
+ }
*fmt = prev;
fmt++;
str += BLI_str_utf8_size_safe(str);
@@ -261,8 +269,9 @@ static void txtfmt_osl_format_line(SpaceText *st, TextLine *line, const bool do_
}
else {
find = (cont & FMT_CONT_QUOTEDOUBLE) ? '"' : '\'';
- if (*str == find)
+ if (*str == find) {
cont = 0;
+ }
*fmt = FMT_TYPE_STRING;
}
@@ -314,10 +323,11 @@ static void txtfmt_osl_format_line(SpaceText *st, TextLine *line, const bool do_
/* Special vars(v) or built-in keywords(b) */
/* keep in sync with 'txtfmt_osl_format_identifier()' */
- if ((i = txtfmt_osl_find_specialvar(str)) != -1) prev = FMT_TYPE_SPECIAL;
- else if ((i = txtfmt_osl_find_builtinfunc(str)) != -1) prev = FMT_TYPE_KEYWORD;
- else if ((i = txtfmt_osl_find_reserved(str)) != -1) prev = FMT_TYPE_RESERVED;
- else if ((i = txtfmt_osl_find_preprocessor(str)) != -1) prev = FMT_TYPE_DIRECTIVE;
+ if ((i = txtfmt_osl_find_specialvar(str)) != -1) { prev = FMT_TYPE_SPECIAL;
+ } else if ((i = txtfmt_osl_find_builtinfunc(str)) != -1) { prev = FMT_TYPE_KEYWORD;
+ } else if ((i = txtfmt_osl_find_reserved(str)) != -1) { prev = FMT_TYPE_RESERVED;
+ } else if ((i = txtfmt_osl_find_preprocessor(str)) != -1) { prev = FMT_TYPE_DIRECTIVE;
+}
/* clang-format on */
diff --git a/source/blender/editors/space_text/text_format_pov.c b/source/blender/editors/space_text/text_format_pov.c
index 8064f4e69e2..a5e1a3845cf 100644
--- a/source/blender/editors/space_text/text_format_pov.c
+++ b/source/blender/editors/space_text/text_format_pov.c
@@ -48,39 +48,40 @@ static int txtfmt_pov_find_keyword(const char *string)
int i, len;
/* Language Directives */
- if (STR_LITERAL_STARTSWITH(string, "deprecated", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "persistent", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "statistics", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "version", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "warning", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "declare", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "default", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "include", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "append", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "elseif", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "debug", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "break", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "else", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "error", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "fclose", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "fopen", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "ifndef", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "ifdef", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "patch", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "local", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "macro", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "range", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "read", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "render", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "switch", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "undef", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "while", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "write", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "case", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "end", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "for", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "if", len)) i = len;
- else i = 0;
+ if (STR_LITERAL_STARTSWITH(string, "deprecated", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "persistent", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "statistics", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "version", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "warning", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "declare", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "default", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "include", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "append", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "elseif", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "debug", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "break", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "else", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "error", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "fclose", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "fopen", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "ifndef", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "ifdef", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "patch", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "local", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "macro", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "range", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "read", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "render", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "switch", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "undef", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "while", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "write", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "case", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "end", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "for", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "if", len)) { i = len;
+ } else { i = 0;
+}
/* clang-format on */
@@ -100,145 +101,146 @@ static int txtfmt_pov_find_reserved_keywords(const char *string)
/* clang-format off */
/* Float Functions */
- if (STR_LITERAL_STARTSWITH(string, "conserve_energy", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "max_intersections", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "dimension_size", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "bitwise_and", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "bitwise_or", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "bitwise_xor", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "file_exists", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "precompute", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "dimensions", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "clipped_by", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "shadowless", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "turb_depth", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "reciprocal", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "quaternion", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "phong_size", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "tesselate", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "save_file", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "load_file", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "max_trace", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "transform", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "translate", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "direction", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "roughness", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "metallic", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "gts_load", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "gts_save", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "location", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "altitude", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "function", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "evaluate", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "inverse", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "collect", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "target", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "albedo", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "rotate", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "matrix", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "look_at", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "jitter", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "angle", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "right", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "scale", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "child", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "crand", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "blink", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "defined", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "degrees", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "inside", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "radians", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "vlength", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "select", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "floor", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "strcmp", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "strlen", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "tessel", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "sturm", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "abs", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "acosh", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "prod", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "with", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "acos", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "asc", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "asinh", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "asin", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "atan2", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "atand", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "atanh", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "atan", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "ceil", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "warp", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "cosh", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "log", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "max", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "min", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "mod", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "pow", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "rand", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "seed", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "form", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "sinh", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "sqrt", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "tanh", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "vdot", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "sin", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "sqr", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "sum", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "pwr", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "tan", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "val", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "cos", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "div", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "exp", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "int", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "sky", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "up", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "ln", len)) i = len;
+ if (STR_LITERAL_STARTSWITH(string, "conserve_energy", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "max_intersections", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "dimension_size", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "bitwise_and", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "bitwise_or", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "bitwise_xor", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "file_exists", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "precompute", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "dimensions", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "clipped_by", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "shadowless", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "turb_depth", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "reciprocal", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "quaternion", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "phong_size", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "tesselate", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "save_file", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "load_file", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "max_trace", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "transform", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "translate", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "direction", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "roughness", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "metallic", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "gts_load", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "gts_save", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "location", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "altitude", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "function", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "evaluate", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "inverse", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "collect", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "target", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "albedo", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "rotate", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "matrix", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "look_at", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "jitter", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "angle", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "right", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "scale", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "child", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "crand", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "blink", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "defined", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "degrees", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "inside", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "radians", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "vlength", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "select", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "floor", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "strcmp", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "strlen", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "tessel", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "sturm", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "abs", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "acosh", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "prod", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "with", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "acos", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "asc", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "asinh", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "asin", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "atan2", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "atand", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "atanh", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "atan", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "ceil", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "warp", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "cosh", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "log", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "max", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "min", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "mod", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "pow", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "rand", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "seed", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "form", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "sinh", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "sqrt", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "tanh", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "vdot", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "sin", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "sqr", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "sum", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "pwr", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "tan", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "val", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "cos", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "div", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "exp", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "int", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "sky", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "up", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "ln", len)) { i = len;
/* Color Identifiers */
- else if (STR_LITERAL_STARTSWITH(string, "transmit", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "filter", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "srgbft", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "srgbf", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "srgbt", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "rgbft", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "gamma", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "green", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "blue", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "gray", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "srgb", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "sRGB", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "SRGB", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "rgbf", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "rgbt", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "rgb", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "red", len)) i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "transmit", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "filter", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "srgbft", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "srgbf", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "srgbt", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "rgbft", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "gamma", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "green", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "blue", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "gray", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "srgb", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "sRGB", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "SRGB", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "rgbf", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "rgbt", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "rgb", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "red", len)) { i = len;
/* Color Spaces */
- else if (STR_LITERAL_STARTSWITH(string, "pov", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "hsl", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "hsv", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "xyl", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "xyv", len)) i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "pov", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "hsl", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "hsv", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "xyl", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "xyv", len)) { i = len;
/* Vector Functions */
- else if (STR_LITERAL_STARTSWITH(string, "vaxis_rotate", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "vturbulence", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "min_extent", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "vnormalize", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "max_extent", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "vrotate", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "vcross", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "trace", len)) i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "vaxis_rotate", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "vturbulence", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "min_extent", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "vnormalize", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "max_extent", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "vrotate", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "vcross", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "trace", len)) { i = len;
/* String Functions */
- else if (STR_LITERAL_STARTSWITH(string, "file_time", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "datetime", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "concat", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "strlwr", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "strupr", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "substr", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "vstr", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "chr", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "str", len)) i = len;
- else i = 0;
+ } else if (STR_LITERAL_STARTSWITH(string, "file_time", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "datetime", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "concat", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "strlwr", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "strupr", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "substr", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "vstr", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "chr", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "str", len)) { i = len;
+ } else { i = 0;
+}
/* clang-format on */
@@ -259,221 +261,222 @@ static int txtfmt_pov_find_reserved_builtins(const char *string)
/* clang-format off */
/* Language Keywords */
- if (STR_LITERAL_STARTSWITH(string, "reflection_exponent", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "area_illumination", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "all_intersections", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "cutaway_textures", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "smooth_triangle", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "lommel_seeliger", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "falloff_angle", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "aa_threshold", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "hypercomplex", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "major_radius", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "max_distance", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "max_iteration", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "colour_space", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "color_space", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "iridescence", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "subsurface", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "scattering", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "absorption", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "water_level", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "reflection", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "max_extent", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "oren_nayar", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "refraction", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "hierarchy", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "radiosity", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "tolerance", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "interior", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "toroidal", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "emission", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "material", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "internal", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "photons", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "arc_angle", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "minnaert", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "texture", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "array", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "black_hole", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "component", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "composite", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "coords", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "cube", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "dist_exp", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "exterior", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "file_gamma", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "flatness", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "planet", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "screw", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "keep", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "flip", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "move", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "roll", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "look_at", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "metric", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "offset", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "orientation", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "pattern", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "precision", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "width", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "repeat", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "bend", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "size", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "alpha", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "slice", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "smooth", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "solid", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "all", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "now", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "pot", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "type", len)) i = len;
+ if (STR_LITERAL_STARTSWITH(string, "reflection_exponent", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "area_illumination", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "all_intersections", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "cutaway_textures", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "smooth_triangle", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "lommel_seeliger", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "falloff_angle", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "aa_threshold", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "hypercomplex", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "major_radius", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "max_distance", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "max_iteration", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "colour_space", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "color_space", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "iridescence", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "subsurface", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "scattering", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "absorption", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "water_level", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "reflection", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "max_extent", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "oren_nayar", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "refraction", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "hierarchy", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "radiosity", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "tolerance", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "interior", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "toroidal", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "emission", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "material", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "internal", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "photons", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "arc_angle", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "minnaert", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "texture", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "array", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "black_hole", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "component", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "composite", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "coords", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "cube", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "dist_exp", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "exterior", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "file_gamma", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "flatness", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "planet", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "screw", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "keep", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "flip", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "move", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "roll", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "look_at", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "metric", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "offset", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "orientation", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "pattern", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "precision", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "width", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "repeat", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "bend", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "size", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "alpha", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "slice", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "smooth", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "solid", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "all", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "now", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "pot", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "type", len)) { i = len;
/* Animation Options */
- else if (STR_LITERAL_STARTSWITH(string, "global_settings", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "input_file_name", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "initial_clock", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "initial_frame", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "frame_number", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "image_height", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "image_width", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "final_clock", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "final_frame", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "clock_delta", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "clock_on", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "clock", len)) i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "global_settings", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "input_file_name", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "initial_clock", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "initial_frame", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "frame_number", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "image_height", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "image_width", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "final_clock", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "final_frame", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "clock_delta", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "clock_on", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "clock", len)) { i = len;
/* Spline Identifiers */
- else if (STR_LITERAL_STARTSWITH(string, "extended_x_spline", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "general_x_spline", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "quadratic_spline", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "basic_x_spline", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "natural_spline", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "linear_spline", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "bezier_spline", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "akima_spline", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "cubic_spline", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "sor_spline", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "tcb_spline", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "linear_sweep", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "conic_sweep", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "b_spline", len)) i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "extended_x_spline", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "general_x_spline", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "quadratic_spline", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "basic_x_spline", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "natural_spline", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "linear_spline", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "bezier_spline", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "akima_spline", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "cubic_spline", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "sor_spline", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "tcb_spline", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "linear_sweep", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "conic_sweep", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "b_spline", len)) { i = len;
/* Patterns */
- else if (STR_LITERAL_STARTSWITH(string, "pigment_pattern", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "image_pattern", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "density_file", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "cylindrical", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "proportion", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "triangular", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "image_map", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "proximity", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "spherical", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "bump_map", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "wrinkles", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "average", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "voronoi", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "masonry", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "binary", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "boxed", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "bozo", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "brick", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "bumps", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "cells", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "checker", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "crackle", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "cubic", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "dents", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "facets", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "gradient", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "granite", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "hexagon", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "julia", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "leopard", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "magnet", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "mandel", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "marble", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "onion", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "pavement", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "planar", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "quilted", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "radial", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "ripples", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "slope", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "spiral1", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "spiral2", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "spotted", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "square", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "tile2", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "tiling", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "tiles", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "waves", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "wood", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "agate", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "aoi", len)) i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "pigment_pattern", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "image_pattern", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "density_file", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "cylindrical", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "proportion", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "triangular", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "image_map", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "proximity", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "spherical", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "bump_map", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "wrinkles", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "average", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "voronoi", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "masonry", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "binary", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "boxed", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "bozo", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "brick", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "bumps", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "cells", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "checker", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "crackle", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "cubic", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "dents", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "facets", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "gradient", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "granite", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "hexagon", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "julia", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "leopard", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "magnet", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "mandel", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "marble", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "onion", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "pavement", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "planar", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "quilted", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "radial", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "ripples", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "slope", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "spiral1", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "spiral2", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "spotted", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "square", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "tile2", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "tiling", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "tiles", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "waves", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "wood", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "agate", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "aoi", len)) { i = len;
/* Objects */
- else if (STR_LITERAL_STARTSWITH(string, "superellipsoid", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "bicubic_patch", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "julia_fractal", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "height_field", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "cubic_spline", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "sphere_sweep", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "light_group", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "light_source", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "intersection", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "isosurface", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "background", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "sky_sphere", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "cylinder", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "difference", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "brilliance", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "parametric", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "interunion", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "intermerge", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "polynomial", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "displace", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "specular", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "ambient", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "diffuse", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "polygon", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "quadric", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "quartic", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "rainbow", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "sphere", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "spline", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "prism", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "camera", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "galley", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "cubic", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "phong", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "cone", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "blob", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "box", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "disc", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "fog", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "lathe", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "merge", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "mesh2", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "mesh", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "object", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "ovus", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "lemon", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "plane", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "poly", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "irid", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "sor", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "text", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "torus", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "triangle", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "union", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "colour", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "color", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "media", len)) i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "superellipsoid", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "bicubic_patch", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "julia_fractal", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "height_field", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "cubic_spline", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "sphere_sweep", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "light_group", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "light_source", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "intersection", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "isosurface", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "background", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "sky_sphere", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "cylinder", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "difference", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "brilliance", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "parametric", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "interunion", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "intermerge", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "polynomial", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "displace", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "specular", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "ambient", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "diffuse", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "polygon", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "quadric", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "quartic", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "rainbow", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "sphere", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "spline", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "prism", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "camera", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "galley", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "cubic", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "phong", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "cone", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "blob", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "box", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "disc", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "fog", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "lathe", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "merge", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "mesh2", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "mesh", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "object", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "ovus", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "lemon", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "plane", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "poly", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "irid", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "sor", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "text", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "torus", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "triangle", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "union", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "colour", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "color", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "media", len)) { i = len;
/* Built-in Vectors */
- else if (STR_LITERAL_STARTSWITH(string, "t", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "u", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "v", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "x", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "y", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "z", len)) i = len;
- else i = 0;
+ } else if (STR_LITERAL_STARTSWITH(string, "t", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "u", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "v", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "x", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "y", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "z", len)) { i = len;
+ } else { i = 0;
+}
/* clang-format off */
@@ -497,202 +500,203 @@ static int txtfmt_pov_find_specialvar(const char *string)
{
int i, len;
/* Modifiers */
- if (STR_LITERAL_STARTSWITH(string, "dispersion_samples", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "projected_through", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "double_illuminate", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "expand_thresholds", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "media_interaction", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "media_attenuation", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "low_error_factor", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "recursion_limit", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "interior_texture", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "max_trace_level", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "gray_threshold", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "pretrace_start", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "normal_indices", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "normal_vectors", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "vertex_vectors", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "noise_generator", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "irid_wavelength", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "number_of_waves", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "ambient_light", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "inside_vector", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "face_indices", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "texture_list", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "max_gradient", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "uv_indices", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "uv_vectors", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "fade_distance", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "global_lights", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "no_bump_scale", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "pretrace_end", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "no_radiosity", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "no_reflection", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "assumed_gamma", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "scallop_wave", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "triangle_wave", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "nearest_count", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "maximum_reuse", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "minimum_reuse", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "always_sample", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "translucency", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "eccentricity", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "contained_by", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "inside_point", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "adc_bailout", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "density_map", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "split_union", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "mm_per_unit", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "agate_turb", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "bounded_by", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "brick_size", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "hf_gray_16", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "dispersion", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "extinction", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "thickness", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "color_map", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "colour_map", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "cubic_wave", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "fade_colour", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "fade_power", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "fade_color", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "normal_map", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "pigment_map", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "quick_color", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "quick_colour", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "material_map", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "pass_through", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "interpolate", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "texture_map", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "error_bound", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "brightness", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "use_color", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "use_alpha", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "use_colour", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "use_index", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "uv_mapping", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "importance", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "max_sample", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "intervals", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "sine_wave", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "slope_map", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "poly_wave", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "no_shadow", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "ramp_wave", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "precision", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "original", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "accuracy", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "map_type", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "no_image", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "distance", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "autostop", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "caustics", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "octaves", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "aa_level", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "frequency", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "fog_offset", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "modulation", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "outbound", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "no_cache", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "pigment", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "charset", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "inbound", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "outside", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "inner", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "turbulence", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "threshold", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "accuracy", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "polarity", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "bump_size", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "circular", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "control0", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "control1", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "maximal", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "minimal", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "fog_type", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "fog_alt", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "samples", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "origin", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "amount", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "adaptive", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "exponent", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "strength", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "density", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "fresnel", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "albinos", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "finish", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "method", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "omega", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "fixed", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "spacing", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "u_steps", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "v_steps", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "offset", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "hollow", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "gather", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "lambda", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "mortar", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "cubic", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "count", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "once", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "orient", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "normal", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "phase", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "ratio", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "open", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "ior", len)) i = len;
+ if (STR_LITERAL_STARTSWITH(string, "dispersion_samples", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "projected_through", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "double_illuminate", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "expand_thresholds", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "media_interaction", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "media_attenuation", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "low_error_factor", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "recursion_limit", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "interior_texture", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "max_trace_level", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "gray_threshold", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "pretrace_start", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "normal_indices", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "normal_vectors", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "vertex_vectors", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "noise_generator", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "irid_wavelength", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "number_of_waves", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "ambient_light", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "inside_vector", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "face_indices", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "texture_list", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "max_gradient", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "uv_indices", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "uv_vectors", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "fade_distance", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "global_lights", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "no_bump_scale", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "pretrace_end", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "no_radiosity", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "no_reflection", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "assumed_gamma", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "scallop_wave", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "triangle_wave", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "nearest_count", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "maximum_reuse", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "minimum_reuse", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "always_sample", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "translucency", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "eccentricity", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "contained_by", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "inside_point", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "adc_bailout", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "density_map", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "split_union", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "mm_per_unit", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "agate_turb", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "bounded_by", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "brick_size", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "hf_gray_16", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "dispersion", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "extinction", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "thickness", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "color_map", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "colour_map", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "cubic_wave", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "fade_colour", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "fade_power", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "fade_color", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "normal_map", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "pigment_map", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "quick_color", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "quick_colour", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "material_map", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "pass_through", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "interpolate", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "texture_map", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "error_bound", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "brightness", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "use_color", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "use_alpha", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "use_colour", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "use_index", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "uv_mapping", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "importance", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "max_sample", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "intervals", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "sine_wave", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "slope_map", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "poly_wave", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "no_shadow", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "ramp_wave", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "precision", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "original", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "accuracy", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "map_type", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "no_image", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "distance", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "autostop", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "caustics", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "octaves", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "aa_level", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "frequency", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "fog_offset", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "modulation", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "outbound", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "no_cache", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "pigment", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "charset", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "inbound", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "outside", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "inner", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "turbulence", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "threshold", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "accuracy", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "polarity", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "bump_size", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "circular", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "control0", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "control1", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "maximal", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "minimal", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "fog_type", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "fog_alt", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "samples", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "origin", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "amount", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "adaptive", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "exponent", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "strength", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "density", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "fresnel", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "albinos", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "finish", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "method", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "omega", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "fixed", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "spacing", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "u_steps", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "v_steps", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "offset", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "hollow", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "gather", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "lambda", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "mortar", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "cubic", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "count", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "once", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "orient", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "normal", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "phase", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "ratio", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "open", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "ior", len)) { i = len;
/* Light Types and options*/
- else if (STR_LITERAL_STARTSWITH(string, "area_light", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "looks_like", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "fade_power", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "tightness", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "spotlight", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "parallel", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "point_at", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "falloff", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "radius", len)) i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "area_light", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "looks_like", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "fade_power", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "tightness", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "spotlight", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "parallel", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "point_at", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "falloff", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "radius", len)) { i = len;
/* Camera Types and options*/
- else if (STR_LITERAL_STARTSWITH(string, "omni_directional_stereo", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "lambert_cylindrical", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "miller_cylindrical", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "lambert_azimuthal", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "ultra_wide_angle", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "camera_direction", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "camera_location ", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "van_der_grinten", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "aitoff_hammer", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "smyth_craster", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "orthographic", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "camera_right", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "blur_samples", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "plate_carree", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "camera_type", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "perspective", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "mesh_camera", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "focal_point", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "balthasart", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "confidence", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "parallaxe", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "hobo_dyer", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "camera_up", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "panoramic", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "eckert_vi", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "eckert_iv", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "mollweide", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "aperture", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "behrmann", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "variance", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "stereo", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "icosa", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "tetra", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "octa", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "mercator", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "omnimax", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "fisheye", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "edwards", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "peters", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "gall", len)) i = len;
- else i = 0;
+ } else if (STR_LITERAL_STARTSWITH(string, "omni_directional_stereo", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "lambert_cylindrical", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "miller_cylindrical", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "lambert_azimuthal", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "ultra_wide_angle", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "camera_direction", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "camera_location ", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "van_der_grinten", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "aitoff_hammer", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "smyth_craster", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "orthographic", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "camera_right", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "blur_samples", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "plate_carree", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "camera_type", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "perspective", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "mesh_camera", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "focal_point", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "balthasart", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "confidence", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "parallaxe", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "hobo_dyer", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "camera_up", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "panoramic", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "eckert_vi", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "eckert_iv", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "mollweide", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "aperture", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "behrmann", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "variance", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "stereo", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "icosa", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "tetra", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "octa", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "mercator", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "omnimax", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "fisheye", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "edwards", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "peters", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "gall", len)) { i = len;
+ } else { i = 0;
+}
/* If next source char is an identifier (eg. 'i' in "definite") no match */
return (i == 0 || text_check_identifier(string[i])) ? -1 : i;
@@ -706,43 +710,44 @@ static int txtfmt_pov_find_bool(const char *string)
/* clang-format off */
/* Built-in Constants */
- if (STR_LITERAL_STARTSWITH(string, "unofficial", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "false", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "no", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "off", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "true", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "yes", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "on", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "pi", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "tau", len)) i = len;
+ if (STR_LITERAL_STARTSWITH(string, "unofficial", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "false", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "no", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "off", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "true", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "yes", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "on", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "pi", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "tau", len)) { i = len;
/* Encodings */
- else if (STR_LITERAL_STARTSWITH(string, "sint16be", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "sint16le", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "sint32be", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "sint32le", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "uint16be", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "uint16le", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "bt2020", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "bt709", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "sint8", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "uint8", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "ascii", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "utf8", len)) i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "sint16be", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "sint16le", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "sint32be", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "sint32le", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "uint16be", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "uint16le", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "bt2020", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "bt709", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "sint8", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "uint8", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "ascii", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "utf8", len)) { i = len;
/* Filetypes */
- else if (STR_LITERAL_STARTSWITH(string, "tiff", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "df3", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "exr", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "gif", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "hdr", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "iff", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "jpeg", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "pgm", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "png", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "ppm", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "sys", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "tga", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "ttf", len)) i = len;
- else i = 0;
+ } else if (STR_LITERAL_STARTSWITH(string, "tiff", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "df3", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "exr", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "gif", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "hdr", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "iff", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "jpeg", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "pgm", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "png", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "ppm", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "sys", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "tga", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "ttf", len)) { i = len;
+ } else { i = 0;
+}
/* clang-format on */
@@ -757,11 +762,12 @@ static char txtfmt_pov_format_identifier(const char *str)
/* Keep aligned args for readability. */
/* clang-format off */
- if ((txtfmt_pov_find_specialvar(str)) != -1) fmt = FMT_TYPE_SPECIAL;
- else if ((txtfmt_pov_find_keyword(str)) != -1) fmt = FMT_TYPE_KEYWORD;
- else if ((txtfmt_pov_find_reserved_keywords(str)) != -1) fmt = FMT_TYPE_RESERVED;
- else if ((txtfmt_pov_find_reserved_builtins(str)) != -1) fmt = FMT_TYPE_DIRECTIVE;
- else fmt = FMT_TYPE_DEFAULT;
+ if ((txtfmt_pov_find_specialvar(str)) != -1) { fmt = FMT_TYPE_SPECIAL;
+ } else if ((txtfmt_pov_find_keyword(str)) != -1) { fmt = FMT_TYPE_KEYWORD;
+ } else if ((txtfmt_pov_find_reserved_keywords(str)) != -1) { fmt = FMT_TYPE_RESERVED;
+ } else if ((txtfmt_pov_find_reserved_builtins(str)) != -1) { fmt = FMT_TYPE_DIRECTIVE;
+ } else { fmt = FMT_TYPE_DEFAULT;
+}
/* clang-format on */
@@ -810,8 +816,9 @@ static void txtfmt_pov_format_line(SpaceText *st, TextLine *line, const bool do_
*fmt = prev;
fmt++;
str++;
- if (*str == '\0')
+ if (*str == '\0') {
break;
+ }
*fmt = prev;
fmt++;
str += BLI_str_utf8_size_safe(str);
@@ -835,8 +842,9 @@ static void txtfmt_pov_format_line(SpaceText *st, TextLine *line, const bool do_
}
else {
find = (cont & FMT_CONT_QUOTEDOUBLE) ? '"' : '\'';
- if (*str == find)
+ if (*str == find) {
cont = 0;
+ }
*fmt = FMT_TYPE_STRING;
}
@@ -897,10 +905,11 @@ static void txtfmt_pov_format_line(SpaceText *st, TextLine *line, const bool do_
/* Special vars(v) or built-in keywords(b) */
/* keep in sync with 'txtfmt_pov_format_identifier()' */
- if ((i = txtfmt_pov_find_specialvar(str)) != -1) prev = FMT_TYPE_SPECIAL;
- else if ((i = txtfmt_pov_find_keyword(str)) != -1) prev = FMT_TYPE_KEYWORD;
- else if ((i = txtfmt_pov_find_reserved_keywords(str)) != -1) prev = FMT_TYPE_RESERVED;
- else if ((i = txtfmt_pov_find_reserved_builtins(str)) != -1) prev = FMT_TYPE_DIRECTIVE;
+ if ((i = txtfmt_pov_find_specialvar(str)) != -1) { prev = FMT_TYPE_SPECIAL;
+ } else if ((i = txtfmt_pov_find_keyword(str)) != -1) { prev = FMT_TYPE_KEYWORD;
+ } else if ((i = txtfmt_pov_find_reserved_keywords(str)) != -1) { prev = FMT_TYPE_RESERVED;
+ } else if ((i = txtfmt_pov_find_reserved_builtins(str)) != -1) { prev = FMT_TYPE_DIRECTIVE;
+}
/* clang-format on */
diff --git a/source/blender/editors/space_text/text_format_pov_ini.c b/source/blender/editors/space_text/text_format_pov_ini.c
index 0dbf2b1bdd3..04f4b992cc6 100644
--- a/source/blender/editors/space_text/text_format_pov_ini.c
+++ b/source/blender/editors/space_text/text_format_pov_ini.c
@@ -49,49 +49,50 @@ static int txtfmt_ini_find_keyword(const char *string)
/* clang-format off */
/* Language Directives */
- if (STR_LITERAL_STARTSWITH(string, "deprecated", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "statistics", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "declare", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "default", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "version", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "warning", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "include", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "fclose", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "ifndef", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "append", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "elseif", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "debug", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "error", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "fopen", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "ifdef", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "local", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "macro", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "range", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "render", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "break", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "switch", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "undef", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "while", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "write", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "case", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "else", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "read", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "end", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "for", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "if", len)) i = len;
-
- else if (STR_LITERAL_STARTSWITH(string, "I", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "S", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "A", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Q", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "U", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "F", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "C", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "N", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "P", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "T", len)) i = len;
-
- else i = 0;
+ if (STR_LITERAL_STARTSWITH(string, "deprecated", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "statistics", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "declare", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "default", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "version", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "warning", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "include", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "fclose", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "ifndef", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "append", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "elseif", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "debug", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "error", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "fopen", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "ifdef", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "local", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "macro", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "range", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "render", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "break", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "switch", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "undef", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "while", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "write", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "case", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "else", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "read", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "end", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "for", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "if", len)) { i = len;
+
+ } else if (STR_LITERAL_STARTSWITH(string, "I", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "S", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "A", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Q", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "U", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "F", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "C", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "N", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "P", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "T", len)) { i = len;
+
+ } else { i = 0;
+}
/* clang-format on */
@@ -110,200 +111,201 @@ static int txtfmt_ini_find_reserved(const char *string)
* list is from...
* http://www.povray.org/documentation/view/3.7.0/212/
*/
- if (STR_LITERAL_STARTSWITH(string, "RenderCompleteSoundEnabled", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Create_Continue_Trace_Log", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "ParseErrorSoundEnabled", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "RenderErrorSoundEnabled", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "HideWhenMainMinimized", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Antialias_Confidence", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "RenderCompleteSound", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "ParseErrorSound", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "RenderErrorSound", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "UseExtensions", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "ReadWriteSourceDir", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "NormalPositionLeft", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "NormalPositionTop", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "NormalPositionRight", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "NormalPositionBottom", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Pre_Scene_Command", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Pre_Frame_Command", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Post_Scene_Command", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Post_Frame_Command", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "User_Abort_Command", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Fatal_Error_Command", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "NormalPositionX", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "NormalPositionY", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Pre_Scene_Return", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Pre_Frame_Return", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Post_Scene_Return", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Post_Frame_Return", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "User_Abort_Return", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Fatal_Error_Return", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Antialias_Threshold", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Antialias_Gamma", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Antialias_Depth", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "input_file_name", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Subset_Start_Frame", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Subset_End_Frame", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "UseToolbar", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "UseTooltips", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Frame_Step", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Cyclic_Animation", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Field_Render", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Odd_Field", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "final_clock", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "final_frame", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "frame_number", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "initial_clock", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "initial_frame", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "image_height", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "image_width", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Start_Column", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Start_Row", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "End_Column", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "End_Row", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Test_Abort_Count", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Test_Abort", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Continue_Trace", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Bounding_Method", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Create_Ini", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Display_Gamma", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Display", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Version", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Pause_When_Done", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Verbose", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Preview_Start_Size", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Preview_End_Size", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Output_to_File", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Input_File_Name", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Output_File_Name", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Output_File_Type", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Output_Alpha", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Bits_Per_Color", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Compression", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Dither_Method", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Include_Header", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Library_Path", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Debug_Console", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Fatal_Console", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Render_Console", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Statistic_Console", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Warning_Console", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Warning_Level", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "All_Console", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Debug_File", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Fatal_File", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Render_File", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Statistic_File", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Warning_File", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "All_File", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Quality", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Bounding_Threshold", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Bounding", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Light_Buffer", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Vista_Buffer", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Remove_Bounds", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Split_Unions", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Antialias", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Glare_Desaturation", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Sampling_Method", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Stochastic_Seed", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Jitter_Amount", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Jitter", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Antialias_Depth", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "CheckNewVersion", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "RunCount", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "CommandLine", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "TextColour", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "WarningColour", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "ErrorColour", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "BackgroundColour", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "DropToEditor", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "LastRenderName", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "LastRenderPath", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "LastQueuePath", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "SecondaryINISection", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "BetaVersionNo64", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "LastBitmapName", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "LastBitmapPath", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "LastINIPath", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "SecondaryINIFile", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "BackgroundFile", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "SaveSettingsOnExit", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "TileBackground", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "HideNewUserHelp", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "SendSystemInfo", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "ItsAboutTime", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "LastPath", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Band0Width", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Band1Width", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Band2Width", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Band3Width", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Band4Width", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "ShowCmd", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Transparency", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Use8BitMode", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "MakeActive", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "KeepAboveMain", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "AutoClose", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "PreserveBitmap", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "FontSize", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "FontWeight", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "KeepMessages", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "AlertSound", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Completion", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Priority", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "DutyCycle", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "AlertOnCompletion", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "AutoRender", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "PreventSleep", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "NoShelloutWait", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "SystemNoActive", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "NoShellOuts", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "VideoSource", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "SceneFile", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "OutputFile", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "IniOutputFile", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "CurrentDirectory", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "SourceFile", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Rendering", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "RenderwinClose", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Append_File", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Warning Level", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "clock_delta", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "clock_on", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "clock", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Height", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Width", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Dither", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Flags", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "Font", len)) i = len;
+ if (STR_LITERAL_STARTSWITH(string, "RenderCompleteSoundEnabled", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Create_Continue_Trace_Log", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "ParseErrorSoundEnabled", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "RenderErrorSoundEnabled", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "HideWhenMainMinimized", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Antialias_Confidence", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "RenderCompleteSound", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "ParseErrorSound", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "RenderErrorSound", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "UseExtensions", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "ReadWriteSourceDir", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "NormalPositionLeft", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "NormalPositionTop", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "NormalPositionRight", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "NormalPositionBottom", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Pre_Scene_Command", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Pre_Frame_Command", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Post_Scene_Command", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Post_Frame_Command", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "User_Abort_Command", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Fatal_Error_Command", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "NormalPositionX", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "NormalPositionY", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Pre_Scene_Return", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Pre_Frame_Return", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Post_Scene_Return", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Post_Frame_Return", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "User_Abort_Return", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Fatal_Error_Return", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Antialias_Threshold", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Antialias_Gamma", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Antialias_Depth", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "input_file_name", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Subset_Start_Frame", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Subset_End_Frame", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "UseToolbar", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "UseTooltips", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Frame_Step", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Cyclic_Animation", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Field_Render", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Odd_Field", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "final_clock", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "final_frame", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "frame_number", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "initial_clock", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "initial_frame", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "image_height", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "image_width", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Start_Column", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Start_Row", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "End_Column", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "End_Row", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Test_Abort_Count", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Test_Abort", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Continue_Trace", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Bounding_Method", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Create_Ini", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Display_Gamma", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Display", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Version", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Pause_When_Done", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Verbose", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Preview_Start_Size", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Preview_End_Size", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Output_to_File", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Input_File_Name", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Output_File_Name", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Output_File_Type", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Output_Alpha", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Bits_Per_Color", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Compression", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Dither_Method", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Include_Header", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Library_Path", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Debug_Console", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Fatal_Console", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Render_Console", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Statistic_Console", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Warning_Console", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Warning_Level", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "All_Console", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Debug_File", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Fatal_File", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Render_File", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Statistic_File", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Warning_File", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "All_File", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Quality", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Bounding_Threshold", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Bounding", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Light_Buffer", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Vista_Buffer", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Remove_Bounds", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Split_Unions", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Antialias", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Glare_Desaturation", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Sampling_Method", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Stochastic_Seed", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Jitter_Amount", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Jitter", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Antialias_Depth", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "CheckNewVersion", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "RunCount", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "CommandLine", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "TextColour", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "WarningColour", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "ErrorColour", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "BackgroundColour", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "DropToEditor", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "LastRenderName", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "LastRenderPath", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "LastQueuePath", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "SecondaryINISection", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "BetaVersionNo64", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "LastBitmapName", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "LastBitmapPath", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "LastINIPath", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "SecondaryINIFile", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "BackgroundFile", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "SaveSettingsOnExit", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "TileBackground", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "HideNewUserHelp", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "SendSystemInfo", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "ItsAboutTime", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "LastPath", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Band0Width", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Band1Width", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Band2Width", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Band3Width", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Band4Width", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "ShowCmd", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Transparency", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Use8BitMode", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "MakeActive", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "KeepAboveMain", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "AutoClose", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "PreserveBitmap", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "FontSize", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "FontWeight", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "KeepMessages", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "AlertSound", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Completion", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Priority", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "DutyCycle", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "AlertOnCompletion", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "AutoRender", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "PreventSleep", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "NoShelloutWait", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "SystemNoActive", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "NoShellOuts", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "VideoSource", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "SceneFile", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "OutputFile", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "IniOutputFile", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "CurrentDirectory", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "SourceFile", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Rendering", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "RenderwinClose", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Append_File", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Warning Level", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "clock_delta", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "clock_on", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "clock", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Height", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Width", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Dither", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Flags", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "Font", len)) { i = len;
/* Filetypes */
- else if (STR_LITERAL_STARTSWITH(string, "df3", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "exr", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "gif", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "hdr", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "iff", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "jpeg", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "pgm", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "png", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "ppm", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "sys", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "tga", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "tiff", len)) i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "df3", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "exr", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "gif", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "hdr", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "iff", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "jpeg", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "pgm", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "png", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "ppm", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "sys", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "tga", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "tiff", len)) { i = len;
/* Encodings */
- else if (STR_LITERAL_STARTSWITH(string, "ascii", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "utf8", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "uint8", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "uint16be", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "uint16le", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "sint8", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "sint16be", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "sint16le", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "sint32be", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "sint32le", len)) i = len;
-
- else i = 0;
+ } else if (STR_LITERAL_STARTSWITH(string, "ascii", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "utf8", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "uint8", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "uint16be", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "uint16le", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "sint8", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "sint16be", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "sint16le", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "sint32be", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "sint32le", len)) { i = len;
+
+ } else { i = 0;
+}
/* clang-format on */
@@ -319,21 +321,22 @@ static int txtfmt_ini_find_bool(const char *string)
/* clang-format off */
/* Built-in Constants */
- if (STR_LITERAL_STARTSWITH(string, "false", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "no", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "off", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "true", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "yes", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "on", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "pi", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "tau", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "%o", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "%s", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "%n", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "%k", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "%h", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "%w", len)) i = len;
- else i = 0;
+ if (STR_LITERAL_STARTSWITH(string, "false", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "no", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "off", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "true", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "yes", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "on", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "pi", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "tau", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "%o", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "%s", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "%n", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "%k", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "%h", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "%w", len)) { i = len;
+ } else { i = 0;
+}
/* clang-format on */
@@ -344,12 +347,15 @@ static int txtfmt_ini_find_bool(const char *string)
static char txtfmt_pov_ini_format_identifier(const char *str)
{
char fmt;
- if ((txtfmt_ini_find_keyword(str)) != -1)
+ if ((txtfmt_ini_find_keyword(str)) != -1) {
fmt = FMT_TYPE_KEYWORD;
- else if ((txtfmt_ini_find_reserved(str)) != -1)
+ }
+ else if ((txtfmt_ini_find_reserved(str)) != -1) {
fmt = FMT_TYPE_RESERVED;
- else
+ }
+ else {
fmt = FMT_TYPE_DEFAULT;
+ }
return fmt;
}
@@ -395,8 +401,9 @@ static void txtfmt_pov_ini_format_line(SpaceText *st, TextLine *line, const bool
*fmt = prev;
fmt++;
str++;
- if (*str == '\0')
+ if (*str == '\0') {
break;
+ }
*fmt = prev;
fmt++;
str += BLI_str_utf8_size_safe(str);
@@ -420,8 +427,9 @@ static void txtfmt_pov_ini_format_line(SpaceText *st, TextLine *line, const bool
}
else {
find = (cont & FMT_CONT_QUOTEDOUBLE) ? '"' : '\'';
- if (*str == find)
+ if (*str == find) {
cont = 0;
+ }
*fmt = FMT_TYPE_STRING;
}
@@ -475,8 +483,9 @@ static void txtfmt_pov_ini_format_line(SpaceText *st, TextLine *line, const bool
/* Special vars(v) or built-in keywords(b) */
/* keep in sync with 'txtfmt_ini_format_identifier()' */
- if ((i = txtfmt_ini_find_keyword(str)) != -1) prev = FMT_TYPE_KEYWORD;
- else if ((i = txtfmt_ini_find_reserved(str)) != -1) prev = FMT_TYPE_RESERVED;
+ if ((i = txtfmt_ini_find_keyword(str)) != -1) { prev = FMT_TYPE_KEYWORD;
+ } else if ((i = txtfmt_ini_find_reserved(str)) != -1) { prev = FMT_TYPE_RESERVED;
+}
/* clang-format on */
diff --git a/source/blender/editors/space_text/text_format_py.c b/source/blender/editors/space_text/text_format_py.c
index 68e42335546..98eeee61c3a 100644
--- a/source/blender/editors/space_text/text_format_py.c
+++ b/source/blender/editors/space_text/text_format_py.c
@@ -58,43 +58,45 @@ static int txtfmt_py_find_builtinfunc(const char *string)
/* Keep aligned args for readability. */
/* clang-format off */
- if (STR_LITERAL_STARTSWITH(string, "and", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "as", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "assert", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "async", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "await", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "break", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "continue", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "del", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "elif", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "else", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "except", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "finally", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "for", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "from", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "global", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "if", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "import", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "in", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "is", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "lambda", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "nonlocal", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "not", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "or", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "pass", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "raise", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "return", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "try", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "while", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "with", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "yield", len)) i = len;
- else i = 0;
+ if (STR_LITERAL_STARTSWITH(string, "and", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "as", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "assert", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "async", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "await", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "break", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "continue", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "del", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "elif", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "else", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "except", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "finally", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "for", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "from", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "global", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "if", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "import", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "in", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "is", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "lambda", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "nonlocal", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "not", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "or", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "pass", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "raise", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "return", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "try", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "while", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "with", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "yield", len)) { i = len;
+ } else { i = 0;
+}
/* clang-format on */
/* If next source char is an identifier (eg. 'i' in "definite") no match */
- if (i == 0 || text_check_identifier(string[i]))
+ if (i == 0 || text_check_identifier(string[i])) {
return -1;
+ }
return i;
}
@@ -112,15 +114,17 @@ static int txtfmt_py_find_specialvar(const char *string)
/* Keep aligned args for readability. */
/* clang-format off */
- if (STR_LITERAL_STARTSWITH(string, "def", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "class", len)) i = len;
- else i = 0;
+ if (STR_LITERAL_STARTSWITH(string, "def", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "class", len)) { i = len;
+ } else { i = 0;
+}
/* clang-format on */
/* If next source char is an identifier (eg. 'i' in "definite") no match */
- if (i == 0 || text_check_identifier(string[i]))
+ if (i == 0 || text_check_identifier(string[i])) {
return -1;
+ }
return i;
}
@@ -151,16 +155,18 @@ static int txtfmt_py_find_bool(const char *string)
/* Keep aligned args for readability. */
/* clang-format off */
- if (STR_LITERAL_STARTSWITH(string, "None", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "True", len)) i = len;
- else if (STR_LITERAL_STARTSWITH(string, "False", len)) i = len;
- else i = 0;
+ if (STR_LITERAL_STARTSWITH(string, "None", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "True", len)) { i = len;
+ } else if (STR_LITERAL_STARTSWITH(string, "False", len)) { i = len;
+ } else { i = 0;
+}
/* clang-format on */
/* If next source char is an identifier (eg. 'i' in "Nonetheless") no match */
- if (i == 0 || text_check_identifier(string[i]))
+ if (i == 0 || text_check_identifier(string[i])) {
return -1;
+ }
return i;
}
@@ -171,10 +177,11 @@ static char txtfmt_py_format_identifier(const char *str)
/* Keep aligned args for readability. */
/* clang-format off */
- if ((txtfmt_py_find_specialvar(str)) != -1) fmt = FMT_TYPE_SPECIAL;
- else if ((txtfmt_py_find_builtinfunc(str)) != -1) fmt = FMT_TYPE_KEYWORD;
- else if ((txtfmt_py_find_decorator(str)) != -1) fmt = FMT_TYPE_RESERVED;
- else fmt = FMT_TYPE_DEFAULT;
+ if ((txtfmt_py_find_specialvar(str)) != -1) { fmt = FMT_TYPE_SPECIAL;
+ } else if ((txtfmt_py_find_builtinfunc(str)) != -1) { fmt = FMT_TYPE_KEYWORD;
+ } else if ((txtfmt_py_find_decorator(str)) != -1) { fmt = FMT_TYPE_RESERVED;
+ } else { fmt = FMT_TYPE_DEFAULT;
+}
/* clang-format on */
return fmt;
@@ -222,8 +229,9 @@ static void txtfmt_py_format_line(SpaceText *st, TextLine *line, const bool do_n
*fmt = prev;
fmt++;
str++;
- if (*str == '\0')
+ if (*str == '\0') {
break;
+ }
*fmt = prev;
fmt++;
str += BLI_str_utf8_size_safe(str);
@@ -247,8 +255,9 @@ static void txtfmt_py_format_line(SpaceText *st, TextLine *line, const bool do_n
}
else {
find = (cont & FMT_CONT_QUOTEDOUBLE) ? '"' : '\'';
- if (*str == find)
+ if (*str == find) {
cont = FMT_CONT_NOP;
+ }
}
*fmt = FMT_TYPE_STRING;
@@ -311,9 +320,10 @@ static void txtfmt_py_format_line(SpaceText *st, TextLine *line, const bool do_n
/* Special vars(v) or built-in keywords(b) */
/* keep in sync with 'txtfmt_py_format_identifier()' */
- if ((i = txtfmt_py_find_specialvar(str)) != -1) prev = FMT_TYPE_SPECIAL;
- else if ((i = txtfmt_py_find_builtinfunc(str)) != -1) prev = FMT_TYPE_KEYWORD;
- else if ((i = txtfmt_py_find_decorator(str)) != -1) prev = FMT_TYPE_DIRECTIVE;
+ if ((i = txtfmt_py_find_specialvar(str)) != -1) { prev = FMT_TYPE_SPECIAL;
+ } else if ((i = txtfmt_py_find_builtinfunc(str)) != -1) { prev = FMT_TYPE_KEYWORD;
+ } else if ((i = txtfmt_py_find_decorator(str)) != -1) { prev = FMT_TYPE_DIRECTIVE;
+}
/* clang-format on */
diff --git a/source/blender/editors/space_text/text_header.c b/source/blender/editors/space_text/text_header.c
index 6f81a3ad659..e2d2bb5ed64 100644
--- a/source/blender/editors/space_text/text_header.c
+++ b/source/blender/editors/space_text/text_header.c
@@ -45,15 +45,17 @@ static ARegion *text_has_properties_region(ScrArea *sa)
ARegion *ar, *arnew;
ar = BKE_area_find_region_type(sa, RGN_TYPE_UI);
- if (ar)
+ if (ar) {
return ar;
+ }
/* add subdiv level; after header */
ar = BKE_area_find_region_type(sa, RGN_TYPE_HEADER);
/* is error! */
- if (ar == NULL)
+ if (ar == NULL) {
return NULL;
+ }
arnew = MEM_callocN(sizeof(ARegion), "properties region");
@@ -78,8 +80,9 @@ static int text_text_search_exec(bContext *C, wmOperator *UNUSED(op))
SpaceText *st = CTX_wm_space_text(C);
if (ar) {
- if (ar->flag & RGN_FLAG_HIDDEN)
+ if (ar->flag & RGN_FLAG_HIDDEN) {
ED_region_toggle_hidden(C, ar);
+ }
/* cannot send a button activate yet for case when region wasn't visible yet */
/* flag gets checked and cleared in main draw callback */
diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c
index f2fdffb15c8..4d904822360 100644
--- a/source/blender/editors/space_text/text_ops.c
+++ b/source/blender/editors/space_text/text_ops.c
@@ -78,8 +78,9 @@ static bool text_edit_poll(bContext *C)
{
Text *text = CTX_data_edit_text(C);
- if (!text)
+ if (!text) {
return 0;
+ }
if (ID_IS_LINKED(text)) {
// BKE_report(op->reports, RPT_ERROR, "Cannot edit external library data");
@@ -94,8 +95,9 @@ bool text_space_edit_poll(bContext *C)
SpaceText *st = CTX_wm_space_text(C);
Text *text = CTX_data_edit_text(C);
- if (!st || !text)
+ if (!st || !text) {
return 0;
+ }
if (ID_IS_LINKED(text)) {
// BKE_report(op->reports, RPT_ERROR, "Cannot edit external library data");
@@ -111,11 +113,13 @@ static bool text_region_edit_poll(bContext *C)
Text *text = CTX_data_edit_text(C);
ARegion *ar = CTX_wm_region(C);
- if (!st || !text)
+ if (!st || !text) {
return 0;
+ }
- if (!ar || ar->regiontype != RGN_TYPE_WINDOW)
+ if (!ar || ar->regiontype != RGN_TYPE_WINDOW) {
return 0;
+ }
if (ID_IS_LINKED(text)) {
// BKE_report(op->reports, RPT_ERROR, "Cannot edit external library data");
@@ -129,8 +133,9 @@ static bool text_region_edit_poll(bContext *C)
void text_update_line_edited(TextLine *line)
{
- if (!line)
+ if (!line) {
return;
+ }
/* we just free format here, and let it rebuild during draw */
if (line->format) {
@@ -143,8 +148,9 @@ void text_update_edited(Text *text)
{
TextLine *line;
- for (line = text->lines.first; line; line = line->next)
+ for (line = text->lines.first; line; line = line->next) {
text_update_line_edited(line);
+ }
}
/******************* new operator *********************/
@@ -226,13 +232,15 @@ static int text_open_exec(bContext *C, wmOperator *op)
text = BKE_text_load_ex(bmain, str, BKE_main_blendfile_path(bmain), internal);
if (!text) {
- if (op->customdata)
+ if (op->customdata) {
MEM_freeN(op->customdata);
+ }
return OPERATOR_CANCELLED;
}
- if (!op->customdata)
+ if (!op->customdata) {
text_open_init(C, op);
+ }
/* hook into UI */
pprop = op->customdata;
@@ -266,8 +274,9 @@ static int text_open_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(e
Text *text = CTX_data_edit_text(C);
const char *path = (text && text->name) ? text->name : BKE_main_blendfile_path(bmain);
- if (RNA_struct_property_is_set(op->ptr, "filepath"))
+ if (RNA_struct_property_is_set(op->ptr, "filepath")) {
return text_open_exec(C, op);
+ }
text_open_init(C, op);
RNA_string_set(op->ptr, "filepath", path);
@@ -323,8 +332,9 @@ static int text_reload_exec(bContext *C, wmOperator *op)
}
#ifdef WITH_PYTHON
- if (text->compiled)
+ if (text->compiled) {
BPY_text_free_code(text);
+ }
#endif
text_update_edited(text);
@@ -446,8 +456,9 @@ static bool text_save_poll(bContext *C)
{
Text *text = CTX_data_edit_text(C);
- if (!text_edit_poll(C))
+ if (!text_edit_poll(C)) {
return 0;
+ }
return (text->name != NULL && !(text->flags & TXT_ISMEM));
}
@@ -532,13 +543,15 @@ static int text_save_as_exec(bContext *C, wmOperator *op)
Text *text = CTX_data_edit_text(C);
char str[FILE_MAX];
- if (!text)
+ if (!text) {
return OPERATOR_CANCELLED;
+ }
RNA_string_get(op->ptr, "filepath", str);
- if (text->name)
+ if (text->name) {
MEM_freeN(text->name);
+ }
text->name = BLI_strdup(str);
text->flags &= ~TXT_ISMEM;
@@ -556,15 +569,19 @@ static int text_save_as_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSE
Text *text = CTX_data_edit_text(C);
const char *str;
- if (RNA_struct_property_is_set(op->ptr, "filepath"))
+ if (RNA_struct_property_is_set(op->ptr, "filepath")) {
return text_save_as_exec(C, op);
+ }
- if (text->name)
+ if (text->name) {
str = text->name;
- else if (text->flags & TXT_ISMEM)
+ }
+ else if (text->flags & TXT_ISMEM) {
str = text->id.name + 2;
- else
+ }
+ else {
str = BKE_main_blendfile_path(bmain);
+ }
RNA_string_set(op->ptr, "filepath", str);
WM_event_add_fileselect(C, op);
@@ -689,8 +706,9 @@ static int text_refresh_pyconstraints_exec(bContext *UNUSED(C), wmOperator *UNUS
for (con = pchan->constraints.first; con; con = con->next) {
if (con->type == CONSTRAINT_TYPE_PYTHON) {
bPythonConstraint *data = con->data;
- if (data->text == text)
+ if (data->text == text) {
BPY_pyconstraint_update(ob, con);
+ }
update = 1;
}
}
@@ -699,8 +717,9 @@ static int text_refresh_pyconstraints_exec(bContext *UNUSED(C), wmOperator *UNUS
for (con = ob->constraints.first; con; con = con->next) {
if (con->type == CONSTRAINT_TYPE_PYTHON) {
bPythonConstraint *data = con->data;
- if (data->text == text)
+ if (data->text == text) {
BPY_pyconstraint_update(ob, con);
+ }
update = 1;
}
}
@@ -738,8 +757,9 @@ static int text_paste_exec(bContext *C, wmOperator *op)
buf = WM_clipboard_text_get(selection, &buf_len);
- if (!buf)
+ if (!buf) {
return OPERATOR_CANCELLED;
+ }
text_drawcache_tag_update(CTX_wm_space_text(C), 0);
@@ -753,8 +773,9 @@ static int text_paste_exec(bContext *C, wmOperator *op)
WM_event_add_notifier(C, NC_TEXT | NA_EDITED, text);
/* run the script while editing, evil but useful */
- if (CTX_wm_space_text(C)->live_edit)
+ if (CTX_wm_space_text(C)->live_edit) {
text_run_script(C, NULL);
+ }
return OPERATOR_FINISHED;
}
@@ -822,8 +843,9 @@ static void txt_copy_clipboard(Text *text)
{
char *buf;
- if (!txt_has_sel(text))
+ if (!txt_has_sel(text)) {
return;
+ }
buf = txt_sel_to_buf(text);
@@ -871,8 +893,9 @@ static int text_cut_exec(bContext *C, wmOperator *UNUSED(op))
WM_event_add_notifier(C, NC_TEXT | NA_EDITED, text);
/* run the script while editing, evil but useful */
- if (CTX_wm_space_text(C)->live_edit)
+ if (CTX_wm_space_text(C)->live_edit) {
text_run_script(C, NULL);
+ }
return OPERATOR_FINISHED;
}
@@ -995,8 +1018,9 @@ static int text_line_break_exec(bContext *C, wmOperator *UNUSED(op))
}
if (text->curl) {
- if (text->curl->prev)
+ if (text->curl->prev) {
text_update_line_edited(text->curl->prev);
+ }
text_update_line_edited(text->curl);
}
@@ -1128,8 +1152,9 @@ static int text_convert_whitespace_exec(bContext *C, wmOperator *op)
flatten_string_free(&fs);
MEM_freeN(tmp->line);
- if (tmp->format)
+ if (tmp->format) {
MEM_freeN(tmp->format);
+ }
/* Put new_line in the tmp->line spot still need to try and set the curc correctly. */
tmp->line = new_line;
@@ -1157,8 +1182,9 @@ static int text_convert_whitespace_exec(bContext *C, wmOperator *op)
/* a + 0 we already know to be ' ' char... */
for (j = 1;
(j < tab_len) && (a + j < text_check_line_len) && (text_check_line[a + j] == ' ');
- j++)
+ j++) {
;
+ }
if (j == tab_len) {
/* We found a set of spaces that can be replaced by a tab... */
@@ -1201,8 +1227,9 @@ static int text_convert_whitespace_exec(bContext *C, wmOperator *op)
#endif
MEM_freeN(tmp->line);
- if (tmp->format)
+ if (tmp->format) {
MEM_freeN(tmp->format);
+ }
/* Put new_line in the tmp->line spot
* still need to try and set the curc correctly. */
@@ -1342,8 +1369,9 @@ static int move_lines_exec(bContext *C, wmOperator *op)
WM_event_add_notifier(C, NC_TEXT | NA_EDITED, text);
/* run the script while editing, evil but useful */
- if (CTX_wm_space_text(C)->live_edit)
+ if (CTX_wm_space_text(C)->live_edit) {
text_run_script(C, NULL);
+ }
return OPERATOR_FINISHED;
}
@@ -1432,14 +1460,16 @@ static int text_get_cursor_rel(SpaceText *st, ARegion *ar, TextLine *linein, int
if (found) {
/* exact cursor position was found, check if it's */
/* still on needed line (hasn't been wrapped) */
- if (selc > endj && !chop)
+ if (selc > endj && !chop) {
selc = endj;
+ }
loop = 0;
break;
}
- if (chop)
+ if (chop) {
endj = j;
+ }
start = end;
end += max;
@@ -1453,8 +1483,9 @@ static int text_get_cursor_rel(SpaceText *st, ARegion *ar, TextLine *linein, int
}
}
else if (ch == '\0') {
- if (!found)
+ if (!found) {
selc = linein->len;
+ }
loop = 0;
break;
}
@@ -1552,8 +1583,9 @@ static int cursor_skip_find_line(
*linep = (*linep)->prev;
}
else { /* moving bottom */
- if (*rell - visible_lines < 0)
+ if (*rell - visible_lines < 0) {
break;
+ }
if (!(*linep)->next) {
*rell = visible_lines - 1;
@@ -1617,14 +1649,16 @@ static void txt_wrap_move_bol(SpaceText *st, ARegion *ar, const bool sel)
*charp = endj;
if (j >= oldc) {
- if (ch == '\0')
+ if (ch == '\0') {
*charp = txt_utf8_column_to_offset((*linep)->line, start);
+ }
loop = 0;
break;
}
- if (chop)
+ if (chop) {
endj = j;
+ }
start = end;
end += max;
@@ -1645,8 +1679,9 @@ static void txt_wrap_move_bol(SpaceText *st, ARegion *ar, const bool sel)
}
}
- if (!sel)
+ if (!sel) {
txt_pop_sel(text);
+ }
}
static void txt_wrap_move_eol(SpaceText *st, ARegion *ar, const bool sel)
@@ -1695,14 +1730,17 @@ static void txt_wrap_move_eol(SpaceText *st, ARegion *ar, const bool sel)
if (i + columns - start > max) {
end = MIN2(end, i);
- if (chop)
+ if (chop) {
endj = BLI_str_prev_char_utf8((*linep)->line + j) - (*linep)->line;
+ }
if (endj >= oldc) {
- if (ch == '\0')
+ if (ch == '\0') {
*charp = (*linep)->len;
- else
+ }
+ else {
*charp = endj;
+ }
loop = 0;
break;
}
@@ -1725,8 +1763,9 @@ static void txt_wrap_move_eol(SpaceText *st, ARegion *ar, const bool sel)
}
}
- if (!sel)
+ if (!sel) {
txt_pop_sel(text);
+ }
}
static void txt_wrap_move_up(SpaceText *st, ARegion *ar, const bool sel)
@@ -1765,8 +1804,9 @@ static void txt_wrap_move_up(SpaceText *st, ARegion *ar, const bool sel)
}
}
- if (!sel)
+ if (!sel) {
txt_pop_sel(text);
+ }
}
static void txt_wrap_move_down(SpaceText *st, ARegion *ar, const bool sel)
@@ -1803,8 +1843,9 @@ static void txt_wrap_move_down(SpaceText *st, ARegion *ar, const bool sel)
}
}
- if (!sel)
+ if (!sel) {
txt_pop_sel(text);
+ }
}
/* Moves the cursor vertically by the specified number of lines.
@@ -1831,8 +1872,9 @@ static void cursor_skip(SpaceText *st, ARegion *ar, Text *text, int lines, const
int rell, relc;
/* find line and offsets inside it needed to set cursor position */
- if (cursor_skip_find_line(st, ar, lines, linep, charp, &rell, &relc))
+ if (cursor_skip_find_line(st, ar, lines, linep, charp, &rell, &relc)) {
*charp = text_get_cursor_rel(st, ar, *linep, rell, relc);
+ }
}
else {
while (lines > 0 && (*linep)->next) {
@@ -1845,11 +1887,13 @@ static void cursor_skip(SpaceText *st, ARegion *ar, Text *text, int lines, const
}
}
- if (*charp > (*linep)->len)
+ if (*charp > (*linep)->len) {
*charp = (*linep)->len;
+ }
- if (!sel)
+ if (!sel) {
txt_pop_sel(text);
+ }
}
static int text_move_cursor(bContext *C, int type, bool select)
@@ -1859,28 +1903,33 @@ static int text_move_cursor(bContext *C, int type, bool select)
ARegion *ar = CTX_wm_region(C);
/* ensure we have the right region, it's optional */
- if (ar && ar->regiontype != RGN_TYPE_WINDOW)
+ if (ar && ar->regiontype != RGN_TYPE_WINDOW) {
ar = NULL;
+ }
switch (type) {
case LINE_BEGIN:
if (!select) {
txt_sel_clear(text);
}
- if (st && st->wordwrap && ar)
+ if (st && st->wordwrap && ar) {
txt_wrap_move_bol(st, ar, select);
- else
+ }
+ else {
txt_move_bol(text, select);
+ }
break;
case LINE_END:
if (!select) {
txt_sel_clear(text);
}
- if (st && st->wordwrap && ar)
+ if (st && st->wordwrap && ar) {
txt_wrap_move_eol(st, ar, select);
- else
+ }
+ else {
txt_move_eol(text, select);
+ }
break;
case FILE_TOP:
@@ -1926,31 +1975,39 @@ static int text_move_cursor(bContext *C, int type, bool select)
break;
case PREV_LINE:
- if (st && st->wordwrap && ar)
+ if (st && st->wordwrap && ar) {
txt_wrap_move_up(st, ar, select);
- else
+ }
+ else {
txt_move_up(text, select);
+ }
break;
case NEXT_LINE:
- if (st && st->wordwrap && ar)
+ if (st && st->wordwrap && ar) {
txt_wrap_move_down(st, ar, select);
- else
+ }
+ else {
txt_move_down(text, select);
+ }
break;
case PREV_PAGE:
- if (st)
+ if (st) {
cursor_skip(st, ar, st->text, -st->viewlines, select);
- else
+ }
+ else {
cursor_skip(NULL, NULL, text, -10, select);
+ }
break;
case NEXT_PAGE:
- if (st)
+ if (st) {
cursor_skip(st, ar, st->text, st->viewlines, select);
- else
+ }
+ else {
cursor_skip(NULL, NULL, text, 10, select);
+ }
break;
}
@@ -2019,12 +2076,15 @@ static int text_jump_exec(bContext *C, wmOperator *op)
int line = RNA_int_get(op->ptr, "line");
short nlines = txt_get_span(text->lines.first, text->lines.last) + 1;
- if (line < 1)
+ if (line < 1) {
txt_move_toline(text, 1, 0);
- else if (line > nlines)
+ }
+ else if (line > nlines) {
txt_move_toline(text, nlines - 1, 0);
- else
+ }
+ else {
txt_move_toline(text, line - 1, 0);
+ }
text_update_cursor_moved(C);
WM_event_add_notifier(C, NC_TEXT | ND_CURSOR, text);
@@ -2077,10 +2137,12 @@ static int text_delete_exec(bContext *C, wmOperator *op)
/* behavior could be changed here,
* but for now just don't jump words when we have a selection */
if (txt_has_sel(text)) {
- if (type == DEL_PREV_WORD)
+ if (type == DEL_PREV_WORD) {
type = DEL_PREV_CHAR;
- else if (type == DEL_NEXT_WORD)
+ }
+ else if (type == DEL_NEXT_WORD) {
type = DEL_NEXT_CHAR;
+ }
}
TextUndoBuf *utxt = ED_text_undo_push_init(C);
@@ -2136,8 +2198,9 @@ static int text_delete_exec(bContext *C, wmOperator *op)
WM_event_add_notifier(C, NC_TEXT | NA_EDITED, text);
/* run the script while editing, evil but useful */
- if (st->live_edit)
+ if (st->live_edit) {
text_run_script(C, NULL);
+ }
return OPERATOR_FINISHED;
}
@@ -2247,8 +2310,9 @@ static int text_scroll_exec(bContext *C, wmOperator *op)
int lines = RNA_int_get(op->ptr, "lines");
- if (lines == 0)
+ if (lines == 0) {
return OPERATOR_CANCELLED;
+ }
txt_screen_skip(st, ar, lines * U.wheellinescroll);
@@ -2305,8 +2369,9 @@ static void text_scroll_apply(bContext *C, wmOperator *op, const wmEvent *event)
}
else {
st->left += scroll_steps[0];
- if (st->left < 0)
+ if (st->left < 0) {
st->left = 0;
+ }
}
ED_area_tag_redraw(CTX_wm_area(C));
@@ -2332,8 +2397,9 @@ static int text_scroll_modal(bContext *C, wmOperator *op, const wmEvent *event)
switch (event->type) {
case MOUSEMOVE:
- if (tsc->zone == SCROLLHANDLE_BAR)
+ if (tsc->zone == SCROLLHANDLE_BAR) {
text_scroll_apply(C, op, event);
+ }
break;
case LEFTMOUSE:
case RIGHTMOUSE:
@@ -2363,8 +2429,9 @@ static int text_scroll_invoke(bContext *C, wmOperator *op, const wmEvent *event)
SpaceText *st = CTX_wm_space_text(C);
TextScroll *tsc;
- if (RNA_struct_property_is_set(op->ptr, "lines"))
+ if (RNA_struct_property_is_set(op->ptr, "lines")) {
return text_scroll_exec(C, op);
+ }
tsc = MEM_callocN(sizeof(TextScroll), "TextScroll");
tsc->first = 1;
@@ -2426,11 +2493,13 @@ static bool text_region_scroll_poll(bContext *C)
Text *text = CTX_data_edit_text(C);
ARegion *ar = CTX_wm_region(C);
- if (!st || !text)
+ if (!st || !text) {
return 0;
+ }
- if (!ar || ar->regiontype != RGN_TYPE_WINDOW)
+ if (!ar || ar->regiontype != RGN_TYPE_WINDOW) {
return 0;
+ }
return 1;
}
@@ -2443,8 +2512,9 @@ static int text_scroll_bar_invoke(bContext *C, wmOperator *op, const wmEvent *ev
const int *mval = event->mval;
int zone = -1;
- if (RNA_struct_property_is_set(op->ptr, "lines"))
+ if (RNA_struct_property_is_set(op->ptr, "lines")) {
return text_scroll_exec(C, op);
+ }
/* verify we are in the right zone */
if (mval[0] > st->txtbar.xmin && mval[0] < st->txtbar.xmax) {
@@ -2453,10 +2523,12 @@ static int text_scroll_bar_invoke(bContext *C, wmOperator *op, const wmEvent *ev
zone = SCROLLHANDLE_BAR;
}
else if (mval[1] > TXT_SCROLL_SPACE && mval[1] < ar->winy - TXT_SCROLL_SPACE) {
- if (mval[1] < st->txtbar.ymin)
+ if (mval[1] < st->txtbar.ymin) {
zone = SCROLLHANDLE_MIN_OUTSIDE;
- else
+ }
+ else {
zone = SCROLLHANDLE_MAX_OUTSIDE;
+ }
}
}
@@ -2540,13 +2612,16 @@ static int flatten_column_to_offset(SpaceText *st, const char *str, int index)
int i = 0, j = 0, col;
while (*(str + j)) {
- if (str[j] == '\t')
+ if (str[j] == '\t') {
col = st->tabnumber - i % st->tabnumber;
- else
+ }
+ else {
col = BLI_str_utf8_char_width_safe(str + j);
+ }
- if (i + col > index)
+ if (i + col > index) {
break;
+ }
i += col;
j += BLI_str_utf8_size_safe(str + j);
@@ -2633,18 +2708,21 @@ static void text_cursor_set_to_pos_wrapped(
if (found) {
/* exact cursor position was found, check if it's still on needed line
* (hasn't been wrapped) */
- if (charp > endj && !chop && ch != '\0')
+ if (charp > endj && !chop && ch != '\0') {
charp = endj;
+ }
break;
}
- if (chop)
+ if (chop) {
endj = j;
+ }
start = end;
end += max;
- if (j < linep->len)
+ if (j < linep->len) {
y--;
+ }
chop = true;
if (y == 0 && i + columns - start > x) {
@@ -2705,13 +2783,16 @@ static void text_cursor_set_to_pos(SpaceText *st, ARegion *ar, int x, int y, con
text_update_character_width(st);
y = (ar->winy - 2 - y) / (st->lheight_dpi + TXT_LINE_SPACING);
- if (st->showlinenrs)
+ if (st->showlinenrs) {
x -= TXT_OFFSET + TEXTXLOC;
- else
+ }
+ else {
x -= TXT_OFFSET;
+ }
- if (x < 0)
+ if (x < 0) {
x = 0;
+ }
x = text_pixel_x_to_column(st, x) + st->left;
if (st->wordwrap) {
@@ -2735,25 +2816,30 @@ static void text_cursor_set_to_pos(SpaceText *st, ARegion *ar, int x, int y, con
if (y > 0) {
while (y-- != 0) {
- if ((*linep)->next)
+ if ((*linep)->next) {
*linep = (*linep)->next;
+ }
}
}
else if (y < 0) {
while (y++ != 0) {
- if ((*linep)->prev)
+ if ((*linep)->prev) {
*linep = (*linep)->prev;
+ }
}
}
w = flatten_width(st, (*linep)->line);
- if (x < w)
+ if (x < w) {
*charp = flatten_column_to_offset(st, (*linep)->line, x);
- else
+ }
+ else {
*charp = (*linep)->len;
+ }
}
- if (!sel)
+ if (!sel) {
txt_pop_sel(text);
+ }
}
static void text_cursor_timer_ensure(bContext *C, SetSelection *ssel)
@@ -2840,8 +2926,9 @@ static int text_set_selection_invoke(bContext *C, wmOperator *op, const wmEvent
SpaceText *st = CTX_wm_space_text(C);
SetSelection *ssel;
- if (event->mval[0] >= st->txtbar.xmin)
+ if (event->mval[0] >= st->txtbar.xmin) {
return OPERATOR_PASS_THROUGH;
+ }
op->customdata = MEM_callocN(sizeof(SetSelection), "SetCursor");
ssel = op->customdata;
@@ -2920,8 +3007,9 @@ static int text_cursor_set_invoke(bContext *C, wmOperator *op, const wmEvent *ev
{
SpaceText *st = CTX_wm_space_text(C);
- if (event->mval[0] >= st->txtbar.xmin)
+ if (event->mval[0] >= st->txtbar.xmin) {
return OPERATOR_PASS_THROUGH;
+ }
RNA_int_set(op->ptr, "x", event->mval[0]);
RNA_int_set(op->ptr, "y", event->mval[1]);
@@ -2960,18 +3048,23 @@ static int text_line_number_invoke(bContext *C, wmOperator *UNUSED(op), const wm
text_update_character_width(st);
- if (!st->showlinenrs)
+ if (!st->showlinenrs) {
return OPERATOR_PASS_THROUGH;
+ }
- if (!(mval[0] > 2 && mval[0] < (TXT_OFFSET + TEXTXLOC) && mval[1] > 2 && mval[1] < ar->winy - 2))
+ if (!(mval[0] > 2 && mval[0] < (TXT_OFFSET + TEXTXLOC) && mval[1] > 2 &&
+ mval[1] < ar->winy - 2)) {
return OPERATOR_PASS_THROUGH;
+ }
- if (!(event->ascii >= '0' && event->ascii <= '9'))
+ if (!(event->ascii >= '0' && event->ascii <= '9')) {
return OPERATOR_PASS_THROUGH;
+ }
time = PIL_check_seconds_timer();
- if (last_jump < time - 1)
+ if (last_jump < time - 1) {
jump_to = 0;
+ }
jump_to *= 10;
jump_to += (int)(event->ascii - '0');
@@ -3029,8 +3122,9 @@ static int text_insert_exec(bContext *C, wmOperator *op)
MEM_freeN(str);
- if (!done)
+ if (!done) {
return OPERATOR_CANCELLED;
+ }
text_update_line_edited(text->curl);
@@ -3073,8 +3167,9 @@ static int text_insert_invoke(bContext *C, wmOperator *op, const wmEvent *event)
ret = text_insert_exec(C, op);
/* run the script while editing, evil but useful */
- if (ret == OPERATOR_FINISHED && CTX_wm_space_text(C)->live_edit)
+ if (ret == OPERATOR_FINISHED && CTX_wm_space_text(C)->live_edit) {
text_run_script(C, NULL);
+ }
return ret;
}
@@ -3117,21 +3212,25 @@ static int text_find_and_replace(bContext *C, wmOperator *op, short mode)
int found = 0;
char *tmp;
- if (!st->findstr[0])
+ if (!st->findstr[0]) {
return OPERATOR_CANCELLED;
+ }
flags = st->flags;
- if (flags & ST_FIND_ALL)
+ if (flags & ST_FIND_ALL) {
flags &= ~ST_FIND_WRAP;
+ }
/* Replace current */
if (mode != TEXT_FIND && txt_has_sel(text)) {
tmp = txt_sel_to_buf(text);
- if (flags & ST_MATCH_CASE)
+ if (flags & ST_MATCH_CASE) {
found = STREQ(st->findstr, tmp);
- else
+ }
+ else {
found = BLI_strcasecmp(st->findstr, tmp) == 0;
+ }
if (found) {
if (mode == TEXT_REPLACE) {
@@ -3156,17 +3255,20 @@ static int text_find_and_replace(bContext *C, wmOperator *op, short mode)
WM_event_add_notifier(C, NC_TEXT | ND_CURSOR, text);
}
else if (flags & ST_FIND_ALL) {
- if (text->id.next)
+ if (text->id.next) {
text = st->text = text->id.next;
- else
+ }
+ else {
text = st->text = bmain->texts.first;
+ }
txt_move_toline(text, 0, 0);
text_update_cursor_moved(C);
WM_event_add_notifier(C, NC_TEXT | ND_CURSOR, text);
}
else {
- if (!found)
+ if (!found) {
BKE_reportf(op->reports, RPT_ERROR, "Text not found: %s", st->findstr);
+ }
}
return OPERATOR_FINISHED;
@@ -3223,8 +3325,9 @@ static int text_find_set_selected_exec(bContext *C, wmOperator *op)
BLI_strncpy(st->findstr, tmp, ST_MAX_FIND_STR);
MEM_freeN(tmp);
- if (!st->findstr[0])
+ if (!st->findstr[0]) {
return OPERATOR_FINISHED;
+ }
return text_find_and_replace(C, op, TEXT_FIND);
}
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index 499971b9a50..c80a0eaa597 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -586,15 +586,18 @@ static void viewRedrawForce(const bContext *C, TransInfo *t)
}
else {
/* Do we need more refined tags? */
- if (t->flag & T_POSE)
+ if (t->flag & T_POSE) {
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, NULL);
- else
+ }
+ else {
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
+ }
/* For real-time animation record - send notifiers recognized by animation editors */
// XXX: is this notifier a lame duck?
- if ((t->animtimer) && IS_AUTOKEY_ON(t->scene))
+ if ((t->animtimer) && IS_AUTOKEY_ON(t->scene)) {
WM_event_add_notifier(C, NC_OBJECT | ND_KEYS, NULL);
+ }
}
}
else if (t->spacetype == SPACE_ACTION) {
@@ -664,8 +667,9 @@ static void viewRedrawPost(bContext *C, TransInfo *t)
if (t->spacetype == SPACE_VIEW3D) {
/* if autokeying is enabled, send notifiers that keyframes were added */
- if (IS_AUTOKEY_ON(t->scene))
+ if (IS_AUTOKEY_ON(t->scene)) {
WM_main_add_notifier(NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
+ }
/* redraw UV editor */
if (ELEM(t->mode, TFM_VERT_SLIDE, TFM_EDGE_SLIDE) &&
@@ -1046,8 +1050,9 @@ int transformEvent(TransInfo *t, const wmEvent *event)
handled = true;
}
else if (event->type == MOUSEMOVE) {
- if (t->modifiers & MOD_CONSTRAINT_SELECT)
+ if (t->modifiers & MOD_CONSTRAINT_SELECT) {
t->con.mode |= CON_SELECT;
+ }
copy_v2_v2_int(t->mval, event->mval);
@@ -1381,8 +1386,9 @@ int transformEvent(TransInfo *t, const wmEvent *event)
if ((t->flag & T_NO_CONSTRAINT) == 0) {
/* exception for switching to dolly, or trackball, in camera view */
if (t->flag & T_CAMERA) {
- if (t->mode == TFM_TRANSLATION)
+ if (t->mode == TFM_TRANSLATION) {
setLocalConstraint(t, (CON_AXIS2), IFACE_("along local Z"));
+ }
else if (t->mode == TFM_ROTATION) {
restoreTransObjects(t);
initTrackball(t);
@@ -1487,8 +1493,9 @@ int transformEvent(TransInfo *t, const wmEvent *event)
case PADPLUSKEY:
if (event->alt && t->flag & T_PROP_EDIT) {
t->prop_size *= (t->modifiers & MOD_PRECISION) ? 1.01f : 1.1f;
- if (t->spacetype == SPACE_VIEW3D && t->persp != RV3D_ORTHO)
+ if (t->spacetype == SPACE_VIEW3D && t->persp != RV3D_ORTHO) {
t->prop_size = min_ff(t->prop_size, ((View3D *)t->view)->clip_end);
+ }
calculatePropRatio(t);
t->redraw = TREDRAW_HARD;
handled = true;
@@ -1770,8 +1777,9 @@ static bool helpline_poll(bContext *C)
{
ARegion *ar = CTX_wm_region(C);
- if (ar && ar->regiontype == RGN_TYPE_WINDOW)
+ if (ar && ar->regiontype == RGN_TYPE_WINDOW) {
return 1;
+ }
return 0;
}
@@ -2117,16 +2125,21 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
if (!(t->options & CTX_NO_PET)) {
if ((prop = RNA_struct_find_property(op->ptr, "proportional")) &&
!RNA_property_is_set(op->ptr, prop)) {
- if (t->spacetype == SPACE_GRAPH)
+ if (t->spacetype == SPACE_GRAPH) {
ts->proportional_fcurve = proportional;
- else if (t->spacetype == SPACE_ACTION)
+ }
+ else if (t->spacetype == SPACE_ACTION) {
ts->proportional_action = proportional;
- else if (t->obedit_type != -1)
+ }
+ else if (t->obedit_type != -1) {
ts->proportional = proportional;
- else if (t->options & CTX_MASK)
+ }
+ else if (t->options & CTX_MASK) {
ts->proportional_mask = (proportional != PROP_EDIT_OFF);
- else
+ }
+ else {
ts->proportional_objects = (proportional != PROP_EDIT_OFF);
+ }
}
if ((prop = RNA_struct_find_property(op->ptr, "proportional_size"))) {
@@ -2586,10 +2599,12 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
/* same as TFM_TIME_EXTEND, but we need the mode info for later
* so that duplicate-culling will work properly
*/
- if (ELEM(t->spacetype, SPACE_GRAPH, SPACE_NLA))
+ if (ELEM(t->spacetype, SPACE_GRAPH, SPACE_NLA)) {
initTranslation(t);
- else
+ }
+ else {
initTimeTranslate(t);
+ }
t->mode = mode;
break;
case TFM_TIME_EXTEND:
@@ -2598,10 +2613,12 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
* (for Graph/NLA Editors only since they uses 'standard' transforms to get 2D movement)
* depending on which editor this was called from
*/
- if (ELEM(t->spacetype, SPACE_GRAPH, SPACE_NLA))
+ if (ELEM(t->spacetype, SPACE_GRAPH, SPACE_NLA)) {
initTranslation(t);
- else
+ }
+ else {
initTimeTranslate(t);
+ }
break;
case TFM_BAKE_TIME:
initBakeTime(t);
@@ -2808,32 +2825,41 @@ int transformEnd(bContext *C, TransInfo *t)
static void protectedTransBits(short protectflag, float vec[3])
{
- if (protectflag & OB_LOCK_LOCX)
+ if (protectflag & OB_LOCK_LOCX) {
vec[0] = 0.0f;
- if (protectflag & OB_LOCK_LOCY)
+ }
+ if (protectflag & OB_LOCK_LOCY) {
vec[1] = 0.0f;
- if (protectflag & OB_LOCK_LOCZ)
+ }
+ if (protectflag & OB_LOCK_LOCZ) {
vec[2] = 0.0f;
+ }
}
static void protectedSizeBits(short protectflag, float size[3])
{
- if (protectflag & OB_LOCK_SCALEX)
+ if (protectflag & OB_LOCK_SCALEX) {
size[0] = 1.0f;
- if (protectflag & OB_LOCK_SCALEY)
+ }
+ if (protectflag & OB_LOCK_SCALEY) {
size[1] = 1.0f;
- if (protectflag & OB_LOCK_SCALEZ)
+ }
+ if (protectflag & OB_LOCK_SCALEZ) {
size[2] = 1.0f;
+ }
}
static void protectedRotateBits(short protectflag, float eul[3], const float oldeul[3])
{
- if (protectflag & OB_LOCK_ROTX)
+ if (protectflag & OB_LOCK_ROTX) {
eul[0] = oldeul[0];
- if (protectflag & OB_LOCK_ROTY)
+ }
+ if (protectflag & OB_LOCK_ROTY) {
eul[1] = oldeul[1];
- if (protectflag & OB_LOCK_ROTZ)
+ }
+ if (protectflag & OB_LOCK_ROTZ) {
eul[2] = oldeul[2];
+ }
}
/* this function only does the delta rotation */
@@ -2842,19 +2868,24 @@ static void protectedAxisAngleBits(
short protectflag, float axis[3], float *angle, float oldAxis[3], float oldAngle)
{
/* check that protection flags are set */
- if ((protectflag & (OB_LOCK_ROTX | OB_LOCK_ROTY | OB_LOCK_ROTZ | OB_LOCK_ROTW)) == 0)
+ if ((protectflag & (OB_LOCK_ROTX | OB_LOCK_ROTY | OB_LOCK_ROTZ | OB_LOCK_ROTW)) == 0) {
return;
+ }
if (protectflag & OB_LOCK_ROT4D) {
/* axis-angle getting limited as 4D entities that they are... */
- if (protectflag & OB_LOCK_ROTW)
+ if (protectflag & OB_LOCK_ROTW) {
*angle = oldAngle;
- if (protectflag & OB_LOCK_ROTX)
+ }
+ if (protectflag & OB_LOCK_ROTX) {
axis[0] = oldAxis[0];
- if (protectflag & OB_LOCK_ROTY)
+ }
+ if (protectflag & OB_LOCK_ROTY) {
axis[1] = oldAxis[1];
- if (protectflag & OB_LOCK_ROTZ)
+ }
+ if (protectflag & OB_LOCK_ROTZ) {
axis[2] = oldAxis[2];
+ }
}
else {
/* axis-angle get limited with euler... */
@@ -2863,12 +2894,15 @@ static void protectedAxisAngleBits(
axis_angle_to_eulO(eul, EULER_ORDER_DEFAULT, axis, *angle);
axis_angle_to_eulO(oldeul, EULER_ORDER_DEFAULT, oldAxis, oldAngle);
- if (protectflag & OB_LOCK_ROTX)
+ if (protectflag & OB_LOCK_ROTX) {
eul[0] = oldeul[0];
- if (protectflag & OB_LOCK_ROTY)
+ }
+ if (protectflag & OB_LOCK_ROTY) {
eul[1] = oldeul[1];
- if (protectflag & OB_LOCK_ROTZ)
+ }
+ if (protectflag & OB_LOCK_ROTZ) {
eul[2] = oldeul[2];
+ }
eulO_to_axis_angle(axis, angle, eul, EULER_ORDER_DEFAULT);
@@ -2885,19 +2919,24 @@ static void protectedAxisAngleBits(
static void protectedQuaternionBits(short protectflag, float quat[4], const float oldquat[4])
{
/* check that protection flags are set */
- if ((protectflag & (OB_LOCK_ROTX | OB_LOCK_ROTY | OB_LOCK_ROTZ | OB_LOCK_ROTW)) == 0)
+ if ((protectflag & (OB_LOCK_ROTX | OB_LOCK_ROTY | OB_LOCK_ROTZ | OB_LOCK_ROTW)) == 0) {
return;
+ }
if (protectflag & OB_LOCK_ROT4D) {
/* quaternions getting limited as 4D entities that they are... */
- if (protectflag & OB_LOCK_ROTW)
+ if (protectflag & OB_LOCK_ROTW) {
quat[0] = oldquat[0];
- if (protectflag & OB_LOCK_ROTX)
+ }
+ if (protectflag & OB_LOCK_ROTX) {
quat[1] = oldquat[1];
- if (protectflag & OB_LOCK_ROTY)
+ }
+ if (protectflag & OB_LOCK_ROTY) {
quat[2] = oldquat[2];
- if (protectflag & OB_LOCK_ROTZ)
+ }
+ if (protectflag & OB_LOCK_ROTZ) {
quat[3] = oldquat[3];
+ }
}
else {
/* quaternions get limited with euler... (compatibility mode) */
@@ -2910,12 +2949,15 @@ static void protectedQuaternionBits(short protectflag, float quat[4], const floa
quat_to_eul(eul, nquat);
quat_to_eul(oldeul, noldquat);
- if (protectflag & OB_LOCK_ROTX)
+ if (protectflag & OB_LOCK_ROTX) {
eul[0] = oldeul[0];
- if (protectflag & OB_LOCK_ROTY)
+ }
+ if (protectflag & OB_LOCK_ROTY) {
eul[1] = oldeul[1];
- if (protectflag & OB_LOCK_ROTZ)
+ }
+ if (protectflag & OB_LOCK_ROTZ) {
eul[2] = oldeul[2];
+ }
eul_to_quat(quat, eul);
@@ -2956,24 +2998,28 @@ static void constraintTransLim(TransInfo *t, TransData *td)
ListBase targets = {NULL, NULL};
/* only consider constraint if enabled */
- if (con->flag & (CONSTRAINT_DISABLE | CONSTRAINT_OFF))
+ if (con->flag & (CONSTRAINT_DISABLE | CONSTRAINT_OFF)) {
continue;
- if (con->enforce == 0.0f)
+ }
+ if (con->enforce == 0.0f) {
continue;
+ }
/* only use it if it's tagged for this purpose (and the right type) */
if (con->type == CONSTRAINT_TYPE_LOCLIMIT) {
bLocLimitConstraint *data = con->data;
- if ((data->flag2 & LIMIT_TRANSFORM) == 0)
+ if ((data->flag2 & LIMIT_TRANSFORM) == 0) {
continue;
+ }
cti = ctiLoc;
}
else if (con->type == CONSTRAINT_TYPE_DISTLIMIT) {
bDistLimitConstraint *data = con->data;
- if ((data->flag & LIMITDIST_TRANSFORM) == 0)
+ if ((data->flag & LIMITDIST_TRANSFORM) == 0) {
continue;
+ }
cti = ctiDist;
}
@@ -3049,22 +3095,26 @@ static void constraintRotLim(TransInfo *UNUSED(t), TransData *td)
/* Evaluate valid constraints */
for (con = td->con; con; con = con->next) {
/* only consider constraint if enabled */
- if (con->flag & (CONSTRAINT_DISABLE | CONSTRAINT_OFF))
+ if (con->flag & (CONSTRAINT_DISABLE | CONSTRAINT_OFF)) {
continue;
- if (con->enforce == 0.0f)
+ }
+ if (con->enforce == 0.0f) {
continue;
+ }
/* we're only interested in Limit-Rotation constraints */
if (con->type == CONSTRAINT_TYPE_ROTLIMIT) {
bRotLimitConstraint *data = con->data;
/* only use it if it's tagged for this purpose */
- if ((data->flag2 & LIMIT_TRANSFORM) == 0)
+ if ((data->flag2 & LIMIT_TRANSFORM) == 0) {
continue;
+ }
/* skip incompatible spacetypes */
- if (!ELEM(con->ownspace, CONSTRAINT_SPACE_WORLD, CONSTRAINT_SPACE_LOCAL))
+ if (!ELEM(con->ownspace, CONSTRAINT_SPACE_WORLD, CONSTRAINT_SPACE_LOCAL)) {
continue;
+ }
/* only do conversion if necessary, to preserve quats and eulers */
if (do_limit == false) {
@@ -3126,8 +3176,9 @@ static void constraintSizeLim(TransInfo *t, TransData *td)
}
else {
/* Reset val if SINGLESIZE but using a constraint */
- if (td->flag & TD_SINGLESIZE)
+ if (td->flag & TD_SINGLESIZE) {
return;
+ }
/* separate out sign to apply back later */
for (i = 0; i < 3; i++) {
@@ -3141,18 +3192,21 @@ static void constraintSizeLim(TransInfo *t, TransData *td)
/* Evaluate valid constraints */
for (con = td->con; con; con = con->next) {
/* only consider constraint if enabled */
- if (con->flag & (CONSTRAINT_DISABLE | CONSTRAINT_OFF))
+ if (con->flag & (CONSTRAINT_DISABLE | CONSTRAINT_OFF)) {
continue;
- if (con->enforce == 0.0f)
+ }
+ if (con->enforce == 0.0f) {
continue;
+ }
/* we're only interested in Limit-Scale constraints */
if (con->type == CONSTRAINT_TYPE_SIZELIMIT) {
bSizeLimitConstraint *data = con->data;
/* only use it if it's tagged for this purpose */
- if ((data->flag2 & LIMIT_TRANSFORM) == 0)
+ if ((data->flag2 & LIMIT_TRANSFORM) == 0) {
continue;
+ }
/* do space conversions */
if (con->ownspace == CONSTRAINT_SPACE_WORLD) {
@@ -3182,8 +3236,9 @@ static void constraintSizeLim(TransInfo *t, TransData *td)
}
else {
/* Reset val if SINGLESIZE but using a constraint */
- if (td->flag & TD_SINGLESIZE)
+ if (td->flag & TD_SINGLESIZE) {
return;
+ }
/* extrace scale from matrix and apply back sign */
mat4_to_size(td->ext->size, cob.matrix);
@@ -3388,11 +3443,13 @@ static void Bend(TransInfo *t, const int UNUSED(mval[2]))
float delta[3];
float fac, fac_scaled;
- if (td->flag & TD_NOACTION)
+ if (td->flag & TD_NOACTION) {
break;
+ }
- if (td->flag & TD_SKIP)
+ if (td->flag & TD_SKIP) {
continue;
+ }
if (UNLIKELY(values.angle == 0.0f)) {
copy_v3_v3(td->loc, td->iloc);
@@ -3576,10 +3633,12 @@ static void applyShear(TransInfo *t, const int UNUSED(mval[2]))
unit_m3(smat);
// Custom data signals shear direction
- if (t->custom.mode.data == NULL)
+ if (t->custom.mode.data == NULL) {
smat[1][0] = value;
- else
+ }
+ else {
smat[0][1] = value;
+ }
copy_v3_v3(axismat_inv[0], t->orient_matrix[t->orient_axis_ortho]);
copy_v3_v3(axismat_inv[2], t->orient_matrix[t->orient_axis]);
@@ -3593,11 +3652,13 @@ static void applyShear(TransInfo *t, const int UNUSED(mval[2]))
for (i = 0; i < tc->data_len; i++, td++) {
const float *center, *co;
- if (td->flag & TD_NOACTION)
+ if (td->flag & TD_NOACTION) {
break;
+ }
- if (td->flag & TD_SKIP)
+ if (td->flag & TD_SKIP) {
continue;
+ }
if (t->flag & T_EDIT) {
mul_m3_series(tmat, td->smtx, totmat, td->mtx);
@@ -3770,12 +3831,15 @@ static void TransMat3ToSize(float mat[3][3], float smat[3][3], float size[3])
mat3_to_rot_size(rmat, size, mat);
/* first tried with dotproduct... but the sign flip is crucial */
- if (dot_v3v3(rmat[0], smat[0]) < 0.0f)
+ if (dot_v3v3(rmat[0], smat[0]) < 0.0f) {
size[0] = -size[0];
- if (dot_v3v3(rmat[1], smat[1]) < 0.0f)
+ }
+ if (dot_v3v3(rmat[1], smat[1]) < 0.0f) {
size[1] = -size[1];
- if (dot_v3v3(rmat[2], smat[2]) < 0.0f)
+ }
+ if (dot_v3v3(rmat[2], smat[2]) < 0.0f) {
size[2] = -size[2];
+ }
}
static void ElementResize(TransInfo *t, TransDataContainer *tc, TransData *td, float mat[3][3])
@@ -3840,8 +3904,9 @@ static void ElementResize(TransInfo *t, TransDataContainer *tc, TransData *td, f
}
else {
/* Reset val if SINGLESIZE but using a constraint */
- if (td->flag & TD_SINGLESIZE)
+ if (td->flag & TD_SINGLESIZE) {
*td->val = td->ival;
+ }
td->ext->size[0] = td->ext->isize[0] * (1 + (fsize[0] - 1) * td->factor);
td->ext->size[1] = td->ext->isize[1] * (1 + (fsize[1] - 1) * td->factor);
@@ -3853,18 +3918,22 @@ static void ElementResize(TransInfo *t, TransDataContainer *tc, TransData *td, f
}
/* For individual element center, Editmode need to use iloc */
- if (t->flag & T_POINTS)
+ if (t->flag & T_POINTS) {
sub_v3_v3v3(vec, td->iloc, center);
- else
+ }
+ else {
sub_v3_v3v3(vec, td->center, center);
+ }
mul_m3_v3(tmat, vec);
add_v3_v3(vec, center);
- if (t->flag & T_POINTS)
+ if (t->flag & T_POINTS) {
sub_v3_v3(vec, td->iloc);
- else
+ }
+ else {
sub_v3_v3(vec, td->center);
+ }
/* grease pencil falloff */
if (t->options & CTX_GPENCIL_STROKES) {
@@ -3946,11 +4015,13 @@ static void applyResize(TransInfo *t, const int UNUSED(mval[2]))
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td = tc->data;
for (i = 0; i < tc->data_len; i++, td++) {
- if (td->flag & TD_NOACTION)
+ if (td->flag & TD_NOACTION) {
break;
+ }
- if (td->flag & TD_SKIP)
+ if (td->flag & TD_SKIP) {
continue;
+ }
ElementResize(t, tc, td, mat);
}
@@ -3966,8 +4037,9 @@ static void applyResize(TransInfo *t, const int UNUSED(mval[2]))
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td = tc->data;
- for (i = 0; i < tc->data_len; i++, td++)
+ for (i = 0; i < tc->data_len; i++, td++) {
ElementResize(t, tc, td, mat);
+ }
/* In proportional edit it can happen that */
/* vertices in the radius of the brush end */
@@ -4057,11 +4129,13 @@ static void applySkinResize(TransInfo *t, const int UNUSED(mval[2]))
float tmat[3][3], smat[3][3];
float fsize[3];
- if (td->flag & TD_NOACTION)
+ if (td->flag & TD_NOACTION) {
break;
+ }
- if (td->flag & TD_SKIP)
+ if (td->flag & TD_SKIP) {
continue;
+ }
if (t->flag & T_EDIT) {
mul_m3_m3m3(smat, mat, td->mtx);
@@ -4160,11 +4234,13 @@ static void applyToSphere(TransInfo *t, const int UNUSED(mval[2]))
TransData *td = tc->data;
for (i = 0; i < tc->data_len; i++, td++) {
float tratio;
- if (td->flag & TD_NOACTION)
+ if (td->flag & TD_NOACTION) {
break;
+ }
- if (td->flag & TD_SKIP)
+ if (td->flag & TD_SKIP) {
continue;
+ }
sub_v3_v3v3(vec, td->iloc, tc->center_local);
@@ -4218,8 +4294,9 @@ static void initRotation(TransInfo *t)
t->num.unit_use_radians = (t->scene->unit.system_rotation == USER_UNIT_ROT_RADIANS);
t->num.unit_type[0] = B_UNIT_ROTATION;
- if (t->flag & T_2D_EDIT)
+ if (t->flag & T_2D_EDIT) {
t->flag |= T_NO_CONSTRAINT;
+ }
}
/* Used by Transform Rotation and Transform Normal Rotation */
@@ -4514,11 +4591,13 @@ static void applyRotationValue(TransInfo *t, float angle, float axis[3])
TransData *td = tc->data;
for (i = 0; i < tc->data_len; i++, td++) {
- if (td->flag & TD_NOACTION)
+ if (td->flag & TD_NOACTION) {
break;
+ }
- if (td->flag & TD_SKIP)
+ if (td->flag & TD_SKIP) {
continue;
+ }
if (t->con.applyRot) {
t->con.applyRot(t, tc, td, axis, NULL);
@@ -4614,11 +4693,13 @@ static void applyTrackballValue(TransInfo *t,
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td = tc->data;
for (i = 0; i < tc->data_len; i++, td++) {
- if (td->flag & TD_NOACTION)
+ if (td->flag & TD_NOACTION) {
break;
+ }
- if (td->flag & TD_SKIP)
+ if (td->flag & TD_SKIP) {
continue;
+ }
if (t->flag & T_PROP_EDIT) {
axis_angle_normalized_to_mat3(mat, axis, td->factor * angle);
@@ -4952,13 +5033,16 @@ static void headerTranslation(TransInfo *t, const float vec[3], char str[UI_MAX_
if (t->flag & T_AUTOIK) {
short chainlen = t->settings->autoik_chainlen;
- if (chainlen)
+ if (chainlen) {
BLI_snprintf(autoik, NUM_STR_REP_LEN, IFACE_("AutoIK-Len: %d"), chainlen);
- else
+ }
+ else {
autoik[0] = '\0';
+ }
}
- else
+ else {
autoik[0] = '\0';
+ }
if (t->con.mode & CON_APPLY) {
switch (t->num.idx_max) {
@@ -5074,11 +5158,13 @@ static void applyTranslationValue(TransInfo *t, const float vec[3])
TransData *td = tc->data;
for (int i = 0; i < tc->data_len; i++, td++) {
- if (td->flag & TD_NOACTION)
+ if (td->flag & TD_NOACTION) {
break;
+ }
- if (td->flag & TD_SKIP)
+ if (td->flag & TD_SKIP) {
continue;
+ }
float rotate_offset[3] = {0};
bool use_rotate_offset = false;
@@ -5091,10 +5177,12 @@ static void applyTranslationValue(TransInfo *t, const float vec[3])
const float *original_normal;
/* In pose mode, we want to align normals with Y axis of bones... */
- if (t->flag & T_POSE)
+ if (t->flag & T_POSE) {
original_normal = td->axismtx[1];
- else
+ }
+ else {
original_normal = td->axismtx[2];
+ }
rotation_between_vecs_to_mat3(mat, original_normal, t->tsnap.snapNormal);
}
@@ -5141,8 +5229,9 @@ static void applyTranslationValue(TransInfo *t, const float vec[3])
protectedTransBits(td->protectflag, tvec);
- if (td->loc)
+ if (td->loc) {
add_v3_v3v3(td->loc, td->iloc, tvec);
+ }
constraintTransLim(t, td);
}
@@ -5285,11 +5374,13 @@ static void applyShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
TransData *td = tc->data;
for (i = 0; i < tc->data_len; i++, td++) {
float tdistance; /* temp dist */
- if (td->flag & TD_NOACTION)
+ if (td->flag & TD_NOACTION) {
break;
+ }
- if (td->flag & TD_SKIP)
+ if (td->flag & TD_SKIP) {
continue;
+ }
/* get the final offset */
tdistance = distance * td->factor;
@@ -5366,11 +5457,13 @@ static void applyTilt(TransInfo *t, const int UNUSED(mval[2]))
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td = tc->data;
for (i = 0; i < tc->data_len; i++, td++) {
- if (td->flag & TD_NOACTION)
+ if (td->flag & TD_NOACTION) {
break;
+ }
- if (td->flag & TD_SKIP)
+ if (td->flag & TD_SKIP) {
continue;
+ }
if (td->val) {
*td->val = td->ival + final * td->factor;
@@ -5443,18 +5536,21 @@ static void applyCurveShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td = tc->data;
for (i = 0; i < tc->data_len; i++, td++) {
- if (td->flag & TD_NOACTION)
+ if (td->flag & TD_NOACTION) {
break;
+ }
- if (td->flag & TD_SKIP)
+ if (td->flag & TD_SKIP) {
continue;
+ }
if (td->val) {
*td->val = td->ival * ratio;
/* apply PET */
*td->val = (*td->val * td->factor) + ((1.0f - td->factor) * td->ival);
- if (*td->val <= 0.0f)
+ if (*td->val <= 0.0f) {
*td->val = 0.001f;
+ }
}
}
}
@@ -5529,14 +5625,17 @@ static void applyMaskShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td = tc->data;
for (i = 0; i < tc->data_len; i++, td++) {
- if (td->flag & TD_NOACTION)
+ if (td->flag & TD_NOACTION) {
break;
+ }
- if (td->flag & TD_SKIP)
+ if (td->flag & TD_SKIP) {
continue;
+ }
- if (td->ival >= 0.001f)
+ if (td->ival >= 0.001f) {
initial_feather = false;
+ }
}
}
}
@@ -5545,22 +5644,27 @@ static void applyMaskShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td = tc->data;
for (td = tc->data, i = 0; i < tc->data_len; i++, td++) {
- if (td->flag & TD_NOACTION)
+ if (td->flag & TD_NOACTION) {
break;
+ }
- if (td->flag & TD_SKIP)
+ if (td->flag & TD_SKIP) {
continue;
+ }
if (td->val) {
- if (initial_feather)
+ if (initial_feather) {
*td->val = td->ival + (ratio - 1.0f) * 0.01f;
- else
+ }
+ else {
*td->val = td->ival * ratio;
+ }
/* apply PET */
*td->val = (*td->val * td->factor) + ((1.0f - td->factor) * td->ival);
- if (*td->val <= 0.0f)
+ if (*td->val <= 0.0f) {
*td->val = 0.001f;
+ }
}
}
}
@@ -5630,18 +5734,21 @@ static void applyGPShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td = tc->data;
for (i = 0; i < tc->data_len; i++, td++) {
- if (td->flag & TD_NOACTION)
+ if (td->flag & TD_NOACTION) {
break;
+ }
- if (td->flag & TD_SKIP)
+ if (td->flag & TD_SKIP) {
continue;
+ }
if (td->val) {
*td->val = td->ival * ratio;
/* apply PET */
*td->val = (*td->val * td->factor) + ((1.0f - td->factor) * td->ival);
- if (*td->val <= 0.0f)
+ if (*td->val <= 0.0f) {
*td->val = 0.001f;
+ }
}
}
}
@@ -5709,11 +5816,13 @@ static void applyGPOpacity(TransInfo *t, const int UNUSED(mval[2]))
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td = tc->data;
for (i = 0; i < tc->data_len; i++, td++) {
- if (td->flag & TD_NOACTION)
+ if (td->flag & TD_NOACTION) {
break;
+ }
- if (td->flag & TD_SKIP)
+ if (td->flag & TD_SKIP) {
continue;
+ }
if (td->val) {
*td->val = td->ival * ratio;
@@ -5788,11 +5897,13 @@ static void applyPushPull(TransInfo *t, const int UNUSED(mval[2]))
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td = tc->data;
for (i = 0; i < tc->data_len; i++, td++) {
- if (td->flag & TD_NOACTION)
+ if (td->flag & TD_NOACTION) {
break;
+ }
- if (td->flag & TD_SKIP)
+ if (td->flag & TD_SKIP) {
continue;
+ }
sub_v3_v3v3(vec, tc->center_local, td->center);
if (t->con.applyRot && t->con.mode & CON_APPLY) {
@@ -5870,31 +5981,38 @@ static void applyBevelWeight(TransInfo *t, const int UNUSED(mval[2]))
outputNumInput(&(t->num), c, &t->scene->unit);
- if (weight >= 0.0f)
+ if (weight >= 0.0f) {
BLI_snprintf(str, sizeof(str), IFACE_("Bevel Weight: +%s %s"), c, t->proptext);
- else
+ }
+ else {
BLI_snprintf(str, sizeof(str), IFACE_("Bevel Weight: %s %s"), c, t->proptext);
+ }
}
else {
/* default header print */
- if (weight >= 0.0f)
+ if (weight >= 0.0f) {
BLI_snprintf(str, sizeof(str), IFACE_("Bevel Weight: +%.3f %s"), weight, t->proptext);
- else
+ }
+ else {
BLI_snprintf(str, sizeof(str), IFACE_("Bevel Weight: %.3f %s"), weight, t->proptext);
+ }
}
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td = tc->data;
for (i = 0; i < tc->data_len; i++, td++) {
- if (td->flag & TD_NOACTION)
+ if (td->flag & TD_NOACTION) {
break;
+ }
if (td->val) {
*td->val = td->ival + weight * td->factor;
- if (*td->val < 0.0f)
+ if (*td->val < 0.0f) {
*td->val = 0.0f;
- if (*td->val > 1.0f)
+ }
+ if (*td->val > 1.0f) {
*td->val = 1.0f;
+ }
}
}
}
@@ -5953,34 +6071,42 @@ static void applyCrease(TransInfo *t, const int UNUSED(mval[2]))
outputNumInput(&(t->num), c, &t->scene->unit);
- if (crease >= 0.0f)
+ if (crease >= 0.0f) {
BLI_snprintf(str, sizeof(str), IFACE_("Crease: +%s %s"), c, t->proptext);
- else
+ }
+ else {
BLI_snprintf(str, sizeof(str), IFACE_("Crease: %s %s"), c, t->proptext);
+ }
}
else {
/* default header print */
- if (crease >= 0.0f)
+ if (crease >= 0.0f) {
BLI_snprintf(str, sizeof(str), IFACE_("Crease: +%.3f %s"), crease, t->proptext);
- else
+ }
+ else {
BLI_snprintf(str, sizeof(str), IFACE_("Crease: %.3f %s"), crease, t->proptext);
+ }
}
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td = tc->data;
for (i = 0; i < tc->data_len; i++, td++) {
- if (td->flag & TD_NOACTION)
+ if (td->flag & TD_NOACTION) {
break;
+ }
- if (td->flag & TD_SKIP)
+ if (td->flag & TD_SKIP) {
continue;
+ }
if (td->val) {
*td->val = td->ival + crease * td->factor;
- if (*td->val < 0.0f)
+ if (*td->val < 0.0f) {
*td->val = 0.0f;
- if (*td->val > 1.0f)
+ }
+ if (*td->val > 1.0f) {
*td->val = 1.0f;
+ }
}
}
}
@@ -6035,10 +6161,11 @@ static void headerBoneSize(TransInfo *t, const float vec[3], char str[UI_MAX_DRA
/* hmm... perhaps the y-axis values don't need to be shown? */
if (t->con.mode & CON_APPLY) {
- if (t->num.idx_max == 0)
+ if (t->num.idx_max == 0) {
BLI_snprintf(
str, UI_MAX_DRAW_STR, IFACE_("ScaleB: %s%s %s"), &tvec[0], t->con.text, t->proptext);
- else
+ }
+ else {
BLI_snprintf(str,
UI_MAX_DRAW_STR,
IFACE_("ScaleB: %s : %s : %s%s %s"),
@@ -6047,6 +6174,7 @@ static void headerBoneSize(TransInfo *t, const float vec[3], char str[UI_MAX_DRA
&tvec[NUM_STR_REP_LEN * 2],
t->con.text,
t->proptext);
+ }
}
else {
BLI_snprintf(str,
@@ -6110,11 +6238,13 @@ static void applyBoneSize(TransInfo *t, const int UNUSED(mval[2]))
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td = tc->data;
for (i = 0; i < tc->data_len; i++, td++) {
- if (td->flag & TD_NOACTION)
+ if (td->flag & TD_NOACTION) {
break;
+ }
- if (td->flag & TD_SKIP)
+ if (td->flag & TD_SKIP) {
continue;
+ }
ElementBoneSize(t, tc, td, mat);
}
@@ -6180,18 +6310,22 @@ static void applyBoneEnvelope(TransInfo *t, const int UNUSED(mval[2]))
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td = tc->data;
for (i = 0; i < tc->data_len; i++, td++) {
- if (td->flag & TD_NOACTION)
+ if (td->flag & TD_NOACTION) {
break;
+ }
- if (td->flag & TD_SKIP)
+ if (td->flag & TD_SKIP) {
continue;
+ }
if (td->val) {
/* if the old/original value was 0.0f, then just use ratio */
- if (td->ival)
+ if (td->ival) {
*td->val = td->ival * ratio;
- else
+ }
+ else {
*td->val = ratio;
+ }
}
}
}
@@ -6837,8 +6971,9 @@ static void calcEdgeSlide_mval_range(TransInfo *t,
float dist_sq;
int j, l_nr;
- if (BM_elem_flag_test(e_other, BM_ELEM_SELECT))
+ if (BM_elem_flag_test(e_other, BM_ELEM_SELECT)) {
continue;
+ }
/* This test is only relevant if object is not wire-drawn! See [#32068]. */
if (use_occlude_geometry &&
@@ -7080,15 +7215,18 @@ static bool createEdgeSlideVerts_double_side(TransInfo *t, TransDataContainer *t
v = NULL;
BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
- if (BM_elem_flag_test(v, BM_ELEM_TAG))
+ if (BM_elem_flag_test(v, BM_ELEM_TAG)) {
break;
+ }
}
- if (!v)
+ if (!v) {
break;
+ }
- if (!v->e)
+ if (!v->e) {
continue;
+ }
v_first = v;
@@ -7103,8 +7241,9 @@ static bool createEdgeSlideVerts_double_side(TransInfo *t, TransDataContainer *t
break;
}
- if (!BM_elem_flag_test(BM_edge_other_vert(e, v), BM_ELEM_TAG))
+ if (!BM_elem_flag_test(BM_edge_other_vert(e, v), BM_ELEM_TAG)) {
break;
+ }
v = BM_edge_other_vert(e, v);
} while (e != v_first->e);
@@ -7258,10 +7397,12 @@ static bool createEdgeSlideVerts_double_side(TransInfo *t, TransDataContainer *t
else {
if (l_a || l_b) {
/* find the opposite loop if it was missing previously */
- if (l_a == NULL && l_b && (l_b->radial_next != l_b))
+ if (l_a == NULL && l_b && (l_b->radial_next != l_b)) {
l_a = l_b->radial_next;
- else if (l_b == NULL && l_a && (l_a->radial_next != l_a))
+ }
+ else if (l_b == NULL && l_a && (l_a->radial_next != l_a)) {
l_b = l_a->radial_next;
+ }
}
else if (e->l != NULL) {
/* if there are non-contiguous faces, we can still recover
@@ -7562,8 +7703,9 @@ void freeEdgeSlideVerts(TransInfo *UNUSED(t),
{
EdgeSlideData *sld = custom_data->data;
- if (!sld)
+ if (!sld) {
return;
+ }
freeEdgeSlideTempFaces(sld);
@@ -7754,12 +7896,14 @@ static void drawEdgeSlide(TransInfo *t)
GPU_point_size(ctrl_size);
immBegin(GPU_PRIM_POINTS, 1);
if (slp->flipped) {
- if (curr_sv->v_side[1])
+ if (curr_sv->v_side[1]) {
immVertex3fv(pos, curr_sv->v_side[1]->co);
+ }
}
else {
- if (curr_sv->v_side[0])
+ if (curr_sv->v_side[0]) {
immVertex3fv(pos, curr_sv->v_side[0]->co);
+ }
}
immEnd();
@@ -8209,8 +8353,9 @@ void freeVertSlideVerts(TransInfo *UNUSED(t),
{
VertSlideData *sld = custom_data->data;
- if (!sld)
+ if (!sld) {
return;
+ }
freeVertSlideTempFaces(sld);
@@ -8622,11 +8767,13 @@ static void applyBoneRoll(TransInfo *t, const int UNUSED(mval[2]))
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td = tc->data;
for (i = 0; i < tc->data_len; i++, td++) {
- if (td->flag & TD_NOACTION)
+ if (td->flag & TD_NOACTION) {
break;
+ }
- if (td->flag & TD_SKIP)
+ if (td->flag & TD_SKIP) {
continue;
+ }
*(td->val) = td->ival - final;
}
@@ -8692,34 +8839,42 @@ static void applyBakeTime(TransInfo *t, const int mval[2])
outputNumInput(&(t->num), c, &t->scene->unit);
- if (time >= 0.0f)
+ if (time >= 0.0f) {
BLI_snprintf(str, sizeof(str), IFACE_("Time: +%s %s"), c, t->proptext);
- else
+ }
+ else {
BLI_snprintf(str, sizeof(str), IFACE_("Time: %s %s"), c, t->proptext);
+ }
}
else {
/* default header print */
- if (time >= 0.0f)
+ if (time >= 0.0f) {
BLI_snprintf(str, sizeof(str), IFACE_("Time: +%.3f %s"), time, t->proptext);
- else
+ }
+ else {
BLI_snprintf(str, sizeof(str), IFACE_("Time: %.3f %s"), time, t->proptext);
+ }
}
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td = tc->data;
for (i = 0; i < tc->data_len; i++, td++) {
- if (td->flag & TD_NOACTION)
+ if (td->flag & TD_NOACTION) {
break;
+ }
- if (td->flag & TD_SKIP)
+ if (td->flag & TD_SKIP) {
continue;
+ }
if (td->val) {
*td->val = td->ival + time * td->factor;
- if (td->ext->size && *td->val < *td->ext->size)
+ if (td->ext->size && *td->val < *td->ext->size) {
*td->val = *td->ext->size;
- if (td->ext->quat && *td->val > *td->ext->quat)
+ }
+ if (td->ext->quat && *td->val > *td->ext->quat) {
*td->val = *td->ext->quat;
+ }
}
}
}
@@ -8774,11 +8929,13 @@ static void applyMirror(TransInfo *t, const int UNUSED(mval[2]))
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td = tc->data;
for (i = 0; i < tc->data_len; i++, td++) {
- if (td->flag & TD_NOACTION)
+ if (td->flag & TD_NOACTION) {
break;
+ }
- if (td->flag & TD_SKIP)
+ if (td->flag & TD_SKIP) {
continue;
+ }
ElementResize(t, tc, td, mat);
}
@@ -8796,11 +8953,13 @@ static void applyMirror(TransInfo *t, const int UNUSED(mval[2]))
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td = tc->data;
for (i = 0; i < tc->data_len; i++, td++) {
- if (td->flag & TD_NOACTION)
+ if (td->flag & TD_NOACTION) {
break;
+ }
- if (td->flag & TD_SKIP)
+ if (td->flag & TD_SKIP) {
continue;
+ }
ElementResize(t, tc, td, mat);
}
@@ -8808,10 +8967,12 @@ static void applyMirror(TransInfo *t, const int UNUSED(mval[2]))
recalcData(t);
- if (t->flag & T_2D_EDIT)
+ if (t->flag & T_2D_EDIT) {
ED_area_status_text(t->sa, IFACE_("Select a mirror axis (X, Y)"));
- else
+ }
+ else {
ED_area_status_text(t->sa, IFACE_("Select a mirror axis (X, Y, Z)"));
+ }
}
}
/** \} */
@@ -8843,11 +9004,13 @@ static void applyAlign(TransInfo *t, const int UNUSED(mval[2]))
for (i = 0; i < tc->data_len; i++, td++) {
float mat[3][3], invmat[3][3];
- if (td->flag & TD_NOACTION)
+ if (td->flag & TD_NOACTION) {
break;
+ }
- if (td->flag & TD_SKIP)
+ if (td->flag & TD_SKIP) {
continue;
+ }
/* around local centers */
if (t->flag & (T_OBJECT | T_POSE)) {
@@ -8937,11 +9100,13 @@ static void applySeqSlideValue(TransInfo *t, const float val[2])
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td = tc->data;
for (i = 0; i < tc->data_len; i++, td++) {
- if (td->flag & TD_NOACTION)
+ if (td->flag & TD_NOACTION) {
break;
+ }
- if (td->flag & TD_SKIP)
+ if (td->flag & TD_SKIP) {
continue;
+ }
madd_v2_v2v2fl(td->loc, td->iloc, val, td->factor);
}
@@ -8997,20 +9162,23 @@ static short getAnimEdit_SnapMode(TransInfo *t)
if (t->spacetype == SPACE_ACTION) {
SpaceAction *saction = (SpaceAction *)t->sa->spacedata.first;
- if (saction)
+ if (saction) {
autosnap = saction->autosnap;
+ }
}
else if (t->spacetype == SPACE_GRAPH) {
SpaceGraph *sipo = (SpaceGraph *)t->sa->spacedata.first;
- if (sipo)
+ if (sipo) {
autosnap = sipo->autosnap;
+ }
}
else if (t->spacetype == SPACE_NLA) {
SpaceNla *snla = (SpaceNla *)t->sa->spacedata.first;
- if (snla)
+ if (snla) {
autosnap = snla->autosnap;
+ }
}
else {
autosnap = SACTSNAP_OFF;
@@ -9020,10 +9188,12 @@ static short getAnimEdit_SnapMode(TransInfo *t)
* - when toggling on, prefer nearest frame over 1.0 frame increments
*/
if (t->modifiers & MOD_SNAP_INVERT) {
- if (autosnap)
+ if (autosnap) {
autosnap = SACTSNAP_OFF;
- else
+ }
+ else {
autosnap = SACTSNAP_FRAME;
+ }
}
return autosnap;
@@ -9042,10 +9212,12 @@ static void doAnimEdit_SnapFrame(
double val;
/* convert frame to nla-action time (if needed) */
- if (adt)
+ if (adt) {
val = BKE_nla_tweakedit_remap(adt, *(td->val), NLATIME_CONVERT_MAP);
- else
+ }
+ else {
val = *(td->val);
+ }
/* do the snapping to nearest frame/second */
if (autosnap == SACTSNAP_FRAME) {
@@ -9056,30 +9228,36 @@ static void doAnimEdit_SnapFrame(
}
/* convert frame out of nla-action time */
- if (adt)
+ if (adt) {
*(td->val) = BKE_nla_tweakedit_remap(adt, val, NLATIME_CONVERT_UNMAP);
- else
+ }
+ else {
*(td->val) = val;
+ }
}
/* snap key to nearest marker? */
else if (autosnap == SACTSNAP_MARKER) {
float val;
/* convert frame to nla-action time (if needed) */
- if (adt)
+ if (adt) {
val = BKE_nla_tweakedit_remap(adt, *(td->val), NLATIME_CONVERT_MAP);
- else
+ }
+ else {
val = *(td->val);
+ }
/* snap to nearest marker */
// TODO: need some more careful checks for where data comes from
val = (float)ED_markers_find_nearest_marker_time(&t->scene->markers, val);
/* convert frame out of nla-action time */
- if (adt)
+ if (adt) {
*(td->val) = BKE_nla_tweakedit_remap(adt, val, NLATIME_CONVERT_UNMAP);
- else
+ }
+ else {
*(td->val) = val;
+ }
}
/* If the handles are to be moved too
@@ -9158,14 +9336,18 @@ static void headerTimeTranslate(TransInfo *t, char str[UI_MAX_DRAW_STR])
val = (float)((double)val / secf);
}
- if (autosnap == SACTSNAP_FRAME)
+ if (autosnap == SACTSNAP_FRAME) {
BLI_snprintf(&tvec[0], NUM_STR_REP_LEN, "%d.00 (%.4f)", (int)val, val);
- else if (autosnap == SACTSNAP_SECOND)
+ }
+ else if (autosnap == SACTSNAP_SECOND) {
BLI_snprintf(&tvec[0], NUM_STR_REP_LEN, "%d.00 sec (%.4f)", (int)val, val);
- else if (autosnap == SACTSNAP_TSTEP)
+ }
+ else if (autosnap == SACTSNAP_TSTEP) {
BLI_snprintf(&tvec[0], NUM_STR_REP_LEN, "%.4f sec", val);
- else
+ }
+ else {
BLI_snprintf(&tvec[0], NUM_STR_REP_LEN, "%.4f", val);
+ }
}
ofs += BLI_snprintf(str, UI_MAX_DRAW_STR, IFACE_("DeltaX: %s"), &tvec[0]);
@@ -9302,13 +9484,16 @@ static void initTimeSlide(TransInfo *t)
float val = *(td->val);
/* strip/action time to global (mapped) time */
- if (adt)
+ if (adt) {
val = BKE_nla_tweakedit_remap(adt, val, NLATIME_CONVERT_MAP);
+ }
- if (min > val)
+ if (min > val) {
min = val;
- if (max < val)
+ }
+ if (max < val) {
max = val;
+ }
}
}
@@ -9508,10 +9693,12 @@ static void headerTimeScale(TransInfo *t, char str[UI_MAX_DRAW_STR])
{
char tvec[NUM_STR_REP_LEN * 3];
- if (hasNumInput(&t->num))
+ if (hasNumInput(&t->num)) {
outputNumInput(&(t->num), tvec, &t->scene->unit);
- else
+ }
+ else {
BLI_snprintf(&tvec[0], NUM_STR_REP_LEN, "%.4f", t->values[0]);
+ }
BLI_snprintf(str, UI_MAX_DRAW_STR, IFACE_("ScaleX: %s"), &tvec[0]);
}
@@ -9547,8 +9734,9 @@ static void applyTimeScaleValue(TransInfo *t)
fac = ((fac - 1.0f) * td->factor) + 1;
/* check if any need to apply nla-mapping */
- if (adt)
+ if (adt) {
startx = BKE_nla_tweakedit_remap(adt, startx, NLATIME_CONVERT_UNMAP);
+ }
/* now, calculate the new value */
*(td->val) = ((td->ival - startx) * fac) + startx;
diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c
index 9414d5862b6..ee08eb20ea3 100644
--- a/source/blender/editors/transform/transform_constraints.c
+++ b/source/blender/editors/transform/transform_constraints.c
@@ -129,14 +129,17 @@ static void postConstraintChecks(TransInfo *t, float vec[3], float pvec[3])
snapGridIncrement(t, vec);
if (t->flag & T_NULL_ONE) {
- if (!(t->con.mode & CON_AXIS0))
+ if (!(t->con.mode & CON_AXIS0)) {
vec[0] = 1.0f;
+ }
- if (!(t->con.mode & CON_AXIS1))
+ if (!(t->con.mode & CON_AXIS1)) {
vec[1] = 1.0f;
+ }
- if (!(t->con.mode & CON_AXIS2))
+ if (!(t->con.mode & CON_AXIS2)) {
vec[2] = 1.0f;
+ }
}
if (applyNumInput(&t->num, vec)) {
@@ -221,10 +224,12 @@ static void axisProjection(const TransInfo *t,
factor = dot_v3v3(t->viewinv[1], vec) * 2.0f;
/* Since camera distance is quite relative, use quadratic relationship.
* holding shift can compensate. */
- if (factor < 0.0f)
+ if (factor < 0.0f) {
factor *= -factor;
- else
+ }
+ else {
factor *= factor;
+ }
/* -factor makes move down going backwards */
normalize_v3_v3_length(out, axis, -factor);
@@ -267,12 +272,15 @@ static void axisProjection(const TransInfo *t,
/* possible some values become nan when
* viewpoint and object are both zero */
- if (!isfinite(out[0]))
+ if (!isfinite(out[0])) {
out[0] = 0.0f;
- if (!isfinite(out[1]))
+ }
+ if (!isfinite(out[1])) {
out[1] = 0.0f;
- if (!isfinite(out[2]))
+ }
+ if (!isfinite(out[2])) {
out[2] = 0.0f;
+ }
}
}
}
@@ -741,12 +749,15 @@ void drawConstraint(TransInfo *t)
{
TransCon *tc = &(t->con);
- if (!ELEM(t->spacetype, SPACE_VIEW3D, SPACE_IMAGE, SPACE_NODE))
+ if (!ELEM(t->spacetype, SPACE_VIEW3D, SPACE_IMAGE, SPACE_NODE)) {
return;
- if (!(tc->mode & CON_APPLY))
+ }
+ if (!(tc->mode & CON_APPLY)) {
return;
- if (t->flag & T_NO_CONSTRAINT)
+ }
+ if (t->flag & T_NO_CONSTRAINT) {
return;
+ }
if (tc->drawExtra) {
tc->drawExtra(t);
@@ -764,8 +775,9 @@ void drawConstraint(TransInfo *t)
drawLine(t, t->center_global, tc->mtx[2], 'Z', 0);
depth_test_enabled = GPU_depth_test_enabled();
- if (depth_test_enabled)
+ if (depth_test_enabled) {
GPU_depth_test(false);
+ }
const uint shdr_pos = GPU_vertformat_attr_add(
immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
@@ -788,8 +800,9 @@ void drawConstraint(TransInfo *t)
immUnbindProgram();
- if (depth_test_enabled)
+ if (depth_test_enabled) {
GPU_depth_test(true);
+ }
}
if (tc->mode & CON_AXIS0) {
@@ -841,8 +854,9 @@ void drawPropCircle(const struct bContext *C, TransInfo *t)
}
depth_test_enabled = GPU_depth_test_enabled();
- if (depth_test_enabled)
+ if (depth_test_enabled) {
GPU_depth_test(false);
+ }
uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
@@ -855,8 +869,9 @@ void drawPropCircle(const struct bContext *C, TransInfo *t)
immUnbindProgram();
- if (depth_test_enabled)
+ if (depth_test_enabled) {
GPU_depth_test(true);
+ }
GPU_matrix_pop();
}
@@ -990,8 +1005,9 @@ void selectConstraint(TransInfo *t)
void postSelectConstraint(TransInfo *t)
{
- if (!(t->con.mode & CON_SELECT))
+ if (!(t->con.mode & CON_SELECT)) {
return;
+ }
t->con.mode &= ~CON_AXIS0;
t->con.mode &= ~CON_AXIS1;
@@ -1150,14 +1166,17 @@ bool isLockConstraint(TransInfo *t)
{
int mode = t->con.mode;
- if ((mode & (CON_AXIS0 | CON_AXIS1)) == (CON_AXIS0 | CON_AXIS1))
+ if ((mode & (CON_AXIS0 | CON_AXIS1)) == (CON_AXIS0 | CON_AXIS1)) {
return true;
+ }
- if ((mode & (CON_AXIS1 | CON_AXIS2)) == (CON_AXIS1 | CON_AXIS2))
+ if ((mode & (CON_AXIS1 | CON_AXIS2)) == (CON_AXIS1 | CON_AXIS2)) {
return true;
+ }
- if ((mode & (CON_AXIS0 | CON_AXIS2)) == (CON_AXIS0 | CON_AXIS2))
+ if ((mode & (CON_AXIS0 | CON_AXIS2)) == (CON_AXIS0 | CON_AXIS2)) {
return true;
+ }
return false;
}
@@ -1174,14 +1193,17 @@ int getConstraintSpaceDimension(TransInfo *t)
{
int n = 0;
- if (t->con.mode & CON_AXIS0)
+ if (t->con.mode & CON_AXIS0) {
n++;
+ }
- if (t->con.mode & CON_AXIS1)
+ if (t->con.mode & CON_AXIS1) {
n++;
+ }
- if (t->con.mode & CON_AXIS2)
+ if (t->con.mode & CON_AXIS2) {
n++;
+ }
return n;
/*
diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c
index 49817db35a8..e4f2adff77d 100644
--- a/source/blender/editors/transform/transform_conversions.c
+++ b/source/blender/editors/transform/transform_conversions.c
@@ -146,12 +146,15 @@ static int trans_data_compare_dist(const void *a, const void *b)
const TransData *td_a = (const TransData *)a;
const TransData *td_b = (const TransData *)b;
- if (td_a->dist < td_b->dist)
+ if (td_a->dist < td_b->dist) {
return -1;
- else if (td_a->dist > td_b->dist)
+ }
+ else if (td_a->dist > td_b->dist) {
return 1;
- else
+ }
+ else {
return 0;
+ }
}
static int trans_data_compare_rdist(const void *a, const void *b)
@@ -159,12 +162,15 @@ static int trans_data_compare_rdist(const void *a, const void *b)
const TransData *td_a = (const TransData *)a;
const TransData *td_b = (const TransData *)b;
- if (td_a->rdist < td_b->rdist)
+ if (td_a->rdist < td_b->rdist) {
return -1;
- else if (td_a->rdist > td_b->rdist)
+ }
+ else if (td_a->rdist > td_b->rdist) {
return 1;
- else
+ }
+ else {
return 0;
+ }
}
static void sort_trans_data_dist_container(const TransInfo *t, TransDataContainer *tc)
@@ -463,10 +469,12 @@ static void createTransEdge(TransInfo *t)
BM_ITER_MESH (eed, &iter, em->bm, BM_EDGES_OF_MESH) {
if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) {
- if (BM_elem_flag_test(eed, BM_ELEM_SELECT))
+ if (BM_elem_flag_test(eed, BM_ELEM_SELECT)) {
countsel++;
- if (is_prop_edit)
+ }
+ if (is_prop_edit) {
count++;
+ }
}
}
@@ -508,10 +516,12 @@ static void createTransEdge(TransInfo *t)
mid_v3_v3v3(td->center, eed->v1->co, eed->v2->co);
td->loc = NULL;
- if (BM_elem_flag_test(eed, BM_ELEM_SELECT))
+ if (BM_elem_flag_test(eed, BM_ELEM_SELECT)) {
td->flag = TD_SELECTED;
- else
+ }
+ else {
td->flag = 0;
+ }
copy_m3_m3(td->smtx, smtx);
copy_m3_m3(td->mtx, mtx);
@@ -538,10 +548,12 @@ static bKinematicConstraint *has_targetless_ik(bPoseChannel *pchan)
if (con->type == CONSTRAINT_TYPE_KINEMATIC && (con->enforce != 0.0f)) {
bKinematicConstraint *data = con->data;
- if (data->tar == NULL)
+ if (data->tar == NULL) {
return data;
- if (data->tar->type == OB_ARMATURE && data->subtarget[0] == 0)
+ }
+ if (data->tar->type == OB_ARMATURE && data->subtarget[0] == 0) {
return data;
+ }
}
}
return NULL;
@@ -565,18 +577,21 @@ static short apply_targetless_ik(Object *ob)
segcount = 0;
/* exclude tip from chain? */
- if (!(data->flag & CONSTRAINT_IK_TIP))
+ if (!(data->flag & CONSTRAINT_IK_TIP)) {
parchan = pchan->parent;
- else
+ }
+ else {
parchan = pchan;
+ }
/* Find the chain's root & count the segments needed */
for (; parchan; parchan = parchan->parent) {
chanlist[segcount] = parchan;
segcount++;
- if (segcount == data->rootbone || segcount > 255)
+ if (segcount == data->rootbone || segcount > 255) {
break; // 255 is weak
+ }
}
for (; segcount; segcount--) {
Bone *bone;
@@ -605,22 +620,28 @@ static short apply_targetless_ik(Object *ob)
* the values here, or else there are huge discrepancies between IK-solver (interactive)
* and applied poses.
*/
- if (parchan->rotmode > 0)
+ if (parchan->rotmode > 0) {
mat3_to_eulO(parchan->eul, parchan->rotmode, rmat3);
- else if (parchan->rotmode == ROT_MODE_AXISANGLE)
+ }
+ else if (parchan->rotmode == ROT_MODE_AXISANGLE) {
mat3_to_axis_angle(parchan->rotAxis, &parchan->rotAngle, rmat3);
- else
+ }
+ else {
mat3_to_quat(parchan->quat, rmat3);
+ }
/* for size, remove rotation */
/* causes problems with some constraints (so apply only if needed) */
if (data->flag & CONSTRAINT_IK_STRETCH) {
- if (parchan->rotmode > 0)
+ if (parchan->rotmode > 0) {
eulO_to_mat3(qrmat, parchan->eul, parchan->rotmode);
- else if (parchan->rotmode == ROT_MODE_AXISANGLE)
+ }
+ else if (parchan->rotmode == ROT_MODE_AXISANGLE) {
axis_angle_to_mat3(qrmat, parchan->rotAxis, parchan->rotAngle);
- else
+ }
+ else {
quat_to_mat3(qrmat, parchan->quat);
+ }
invert_m3_m3(imat3, qrmat);
mul_m3_m3m3(smat, rmat3, imat3);
@@ -707,10 +728,12 @@ static void add_pose_transdata(
float rpmat[3][3];
BKE_bone_parent_transform_calc_from_pchan(pchan, &bpt);
- if (t->mode == TFM_TRANSLATION)
+ if (t->mode == TFM_TRANSLATION) {
copy_m3_m4(pmat, bpt.loc_mat);
- else
+ }
+ else {
copy_m3_m4(pmat, bpt.rotscale_mat);
+ }
/* Grrr! Exceptional case: When translating pose bones that are either Hinge or NoLocal,
* and want align snapping, we just need both loc_mat and rotscale_mat.
@@ -827,16 +850,19 @@ int count_set_pose_transflags(Object *ob,
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
bone = pchan->bone;
if (PBONE_VISIBLE(arm, bone)) {
- if ((bone->flag & BONE_SELECTED))
+ if ((bone->flag & BONE_SELECTED)) {
bone->flag |= BONE_TRANSFORM;
- else
+ }
+ else {
bone->flag &= ~BONE_TRANSFORM;
+ }
bone->flag &= ~BONE_HINGE_CHILD_TRANSFORM;
bone->flag &= ~BONE_TRANSFORM_CHILD;
}
- else
+ else {
bone->flag &= ~BONE_TRANSFORM;
+ }
}
/* make sure no bone can be transformed when a parent is transformed */
@@ -844,8 +870,9 @@ int count_set_pose_transflags(Object *ob,
if (!ELEM(mode, TFM_BONESIZE, TFM_BONE_ENVELOPE_DIST)) {
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
bone = pchan->bone;
- if (bone->flag & BONE_TRANSFORM)
+ if (bone->flag & BONE_TRANSFORM) {
bone_children_clear_transflag(mode, around, &bone->childbase);
+ }
}
}
/* now count, and check if we have autoIK or have to switch from translate to rotate */
@@ -992,8 +1019,9 @@ static void pose_grab_with_ik_clear(Main *bmain, Object *ob)
continue;
}
pchan->constflag |= PCHAN_HAS_IK;
- if (data->tar == NULL || (data->tar->type == OB_ARMATURE && data->subtarget[0] == 0))
+ if (data->tar == NULL || (data->tar->type == OB_ARMATURE && data->subtarget[0] == 0)) {
pchan->constflag |= PCHAN_HAS_TARGET;
+ }
}
}
}
@@ -1012,8 +1040,9 @@ static short pose_grab_with_ik_add(bPoseChannel *pchan)
bConstraint *con;
/* Sanity check */
- if (pchan == NULL)
+ if (pchan == NULL) {
return 0;
+ }
/* Rule: not if there's already an IK on this channel */
for (con = pchan->constraints.first; con; con = con->next) {
@@ -1035,12 +1064,15 @@ static short pose_grab_with_ik_add(bPoseChannel *pchan)
for (; pchan; pchan = pchan->parent) {
/* here, we set ik-settings for bone from pchan->protectflag */
// XXX: careful with quats/axis-angle rotations where we're locking 4d components
- if (pchan->protectflag & OB_LOCK_ROTX)
+ if (pchan->protectflag & OB_LOCK_ROTX) {
pchan->ikflag |= BONE_IK_NO_XDOF_TEMP;
- if (pchan->protectflag & OB_LOCK_ROTY)
+ }
+ if (pchan->protectflag & OB_LOCK_ROTY) {
pchan->ikflag |= BONE_IK_NO_YDOF_TEMP;
- if (pchan->protectflag & OB_LOCK_ROTZ)
+ }
+ if (pchan->protectflag & OB_LOCK_ROTZ) {
pchan->ikflag |= BONE_IK_NO_ZDOF_TEMP;
+ }
}
}
@@ -1048,8 +1080,9 @@ static short pose_grab_with_ik_add(bPoseChannel *pchan)
}
}
- if ((con->flag & CONSTRAINT_DISABLE) == 0 && (con->enforce != 0.0f))
+ if ((con->flag & CONSTRAINT_DISABLE) == 0 && (con->enforce != 0.0f)) {
return 0;
+ }
}
}
@@ -1063,8 +1096,9 @@ static short pose_grab_with_ik_add(bPoseChannel *pchan)
/* if exists, use values from last targetless (but disabled) IK-constraint as base */
*data = *targetless;
}
- else
+ else {
data->flag = CONSTRAINT_IK_TIP;
+ }
data->flag |= CONSTRAINT_IK_TEMP | CONSTRAINT_IK_AUTO | CONSTRAINT_IK_POS;
copy_v3_v3(data->grabtarget, pchan->pose_tail);
@@ -1076,21 +1110,26 @@ static short pose_grab_with_ik_add(bPoseChannel *pchan)
do {
/* here, we set ik-settings for bone from pchan->protectflag */
// XXX: careful with quats/axis-angle rotations where we're locking 4d components
- if (pchan->protectflag & OB_LOCK_ROTX)
+ if (pchan->protectflag & OB_LOCK_ROTX) {
pchan->ikflag |= BONE_IK_NO_XDOF_TEMP;
- if (pchan->protectflag & OB_LOCK_ROTY)
+ }
+ if (pchan->protectflag & OB_LOCK_ROTY) {
pchan->ikflag |= BONE_IK_NO_YDOF_TEMP;
- if (pchan->protectflag & OB_LOCK_ROTZ)
+ }
+ if (pchan->protectflag & OB_LOCK_ROTZ) {
pchan->ikflag |= BONE_IK_NO_ZDOF_TEMP;
+ }
/* now we count this pchan as being included */
data->rootbone++;
/* continue to parent, but only if we're connected to it */
- if (pchan->bone->flag & BONE_CONNECTED)
+ if (pchan->bone->flag & BONE_CONNECTED) {
pchan = pchan->parent;
- else
+ }
+ else {
pchan = NULL;
+ }
} while (pchan);
/* make a copy of maximum chain-length */
@@ -1114,8 +1153,9 @@ static short pose_grab_with_ik_children(bPose *pose, Bone *bone)
}
if (wentdeeper == 0) {
bPoseChannel *pchan = BKE_pose_channel_find_name(pose, bone->name);
- if (pchan)
+ if (pchan) {
added += pose_grab_with_ik_add(pchan);
+ }
}
return added;
@@ -1129,8 +1169,9 @@ static short pose_grab_with_ik(Main *bmain, Object *ob)
Bone *bonec;
short tot_ik = 0;
- if ((ob == NULL) || (ob->pose == NULL) || (ob->mode & OB_MODE_POSE) == 0)
+ if ((ob == NULL) || (ob->pose == NULL) || (ob->mode & OB_MODE_POSE) == 0) {
return 0;
+ }
arm = ob->data;
@@ -1145,18 +1186,21 @@ static short pose_grab_with_ik(Main *bmain, Object *ob)
break;
}
}
- if ((pchan->bone->flag & BONE_CONNECTED) == 0 && (bonec == NULL))
+ if ((pchan->bone->flag & BONE_CONNECTED) == 0 && (bonec == NULL)) {
continue;
+ }
/* rule: if selected Bone is not a root bone, it gets a temporal IK */
if (pchan->parent) {
/* only adds if there's no IK yet (and no parent bone was selected) */
for (parent = pchan->parent; parent; parent = parent->parent) {
- if (parent->bone->flag & BONE_SELECTED)
+ if (parent->bone->flag & BONE_SELECTED) {
break;
+ }
}
- if (parent == NULL)
+ if (parent == NULL) {
tot_ik += pose_grab_with_ik_add(pchan);
+ }
}
else {
/* rule: go over the children and add IK to the tips */
@@ -1337,25 +1381,30 @@ static void createTransArmatureVerts(TransInfo *t)
if (EBONE_VISIBLE(arm, ebo) && !(ebo->flag & BONE_EDITMODE_LOCKED)) {
if (ELEM(t->mode, TFM_BONESIZE, TFM_BONE_ENVELOPE_DIST)) {
- if (ebo->flag & BONE_SELECTED)
+ if (ebo->flag & BONE_SELECTED) {
tc->data_len++;
+ }
}
else if (t->mode == TFM_BONE_ROLL) {
- if (ebo->flag & BONE_SELECTED)
+ if (ebo->flag & BONE_SELECTED) {
tc->data_len++;
+ }
}
else {
- if (ebo->flag & BONE_TIPSEL)
+ if (ebo->flag & BONE_TIPSEL) {
tc->data_len++;
- if (ebo->flag & BONE_ROOTSEL)
+ }
+ if (ebo->flag & BONE_ROOTSEL) {
tc->data_len++;
+ }
}
}
if (mirror && (data_len_prev < tc->data_len)) {
eboflip = ED_armature_ebone_get_mirrored(arm->edbo, ebo);
- if (eboflip)
+ if (eboflip) {
total_mirrored++;
+ }
}
}
if (!tc->data_len) {
@@ -1498,8 +1547,9 @@ static void createTransArmatureVerts(TransInfo *t)
td->loc = ebo->tail;
td->flag = TD_SELECTED;
- if (ebo->flag & BONE_EDITMODE_LOCKED)
+ if (ebo->flag & BONE_EDITMODE_LOCKED) {
td->protectflag = OB_LOCK_LOC | OB_LOCK_ROT | OB_LOCK_SCALE;
+ }
copy_m3_m3(td->smtx, smtx);
copy_m3_m3(td->mtx, mtx);
@@ -1522,8 +1572,9 @@ static void createTransArmatureVerts(TransInfo *t)
copy_v3_v3(td->center, td->iloc);
td->loc = ebo->head;
td->flag = TD_SELECTED;
- if (ebo->flag & BONE_EDITMODE_LOCKED)
+ if (ebo->flag & BONE_EDITMODE_LOCKED) {
td->protectflag = OB_LOCK_LOC | OB_LOCK_ROT | OB_LOCK_SCALE;
+ }
copy_m3_m3(td->smtx, smtx);
copy_m3_m3(td->mtx, mtx);
@@ -1581,10 +1632,12 @@ static void createTransMBallVerts(TransInfo *t)
/* count totals */
for (ml = mb->editelems->first; ml; ml = ml->next) {
- if (ml->flag & SELECT)
+ if (ml->flag & SELECT) {
countsel++;
- if (is_prop_edit)
+ }
+ if (is_prop_edit) {
count++;
+ }
}
/* note: in prop mode we need at least 1 selected */
@@ -1592,10 +1645,12 @@ static void createTransMBallVerts(TransInfo *t)
continue;
}
- if (is_prop_edit)
+ if (is_prop_edit) {
tc->data_len = count;
- else
+ }
+ else {
tc->data_len = countsel;
+ }
td = tc->data = MEM_callocN(tc->data_len * sizeof(TransData), "TransObData(MBall EditMode)");
tx = tc->data_ext = MEM_callocN(tc->data_len * sizeof(TransDataExtension),
@@ -1612,10 +1667,12 @@ static void createTransMBallVerts(TransInfo *t)
quat_to_mat3(td->axismtx, ml->quat);
- if (ml->flag & SELECT)
+ if (ml->flag & SELECT) {
td->flag = TD_SELECTED | TD_USEQUAT | TD_SINGLESIZE;
- else
+ }
+ else {
td->flag = TD_USEQUAT;
+ }
copy_m3_m3(td->smtx, smtx);
copy_m3_m3(td->mtx, mtx);
@@ -1785,18 +1842,21 @@ static void createTransCurveVerts(TransInfo *t)
if (bezt_tx & SEL_F3) {
countsel++;
}
- if (is_prop_edit)
+ if (is_prop_edit) {
count += 3;
+ }
}
}
}
else {
for (a = nu->pntsu * nu->pntsv, bp = nu->bp; a > 0; a--, bp++) {
if (bp->hide == 0) {
- if (is_prop_edit)
+ if (is_prop_edit) {
count++;
- if (bp->f1 & SELECT)
+ }
+ if (bp->f1 & SELECT) {
countsel++;
+ }
}
}
}
@@ -1807,10 +1867,12 @@ static void createTransCurveVerts(TransInfo *t)
continue;
}
- if (is_prop_edit)
+ if (is_prop_edit) {
tc->data_len = count;
- else
+ }
+ else {
tc->data_len = countsel;
+ }
tc->data = MEM_callocN(tc->data_len * sizeof(TransData), "TransObData(Curve EditMode)");
t->data_len_all += tc->data_len;
@@ -1878,16 +1940,20 @@ static void createTransCurveVerts(TransInfo *t)
1 :
0]);
if (hide_handles) {
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
td->flag = TD_SELECTED;
- else
+ }
+ else {
td->flag = 0;
+ }
}
else {
- if (bezt->f1 & SELECT)
+ if (bezt->f1 & SELECT) {
td->flag = TD_SELECTED;
- else
+ }
+ else {
td->flag = 0;
+ }
}
td->ext = NULL;
td->val = NULL;
@@ -1909,10 +1975,12 @@ static void createTransCurveVerts(TransInfo *t)
copy_v3_v3(td->iloc, bezt->vec[1]);
td->loc = bezt->vec[1];
copy_v3_v3(td->center, td->loc);
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
td->flag = TD_SELECTED;
- else
+ }
+ else {
td->flag = 0;
+ }
td->ext = NULL;
/* TODO - make points scale */
@@ -1934,12 +2002,13 @@ static void createTransCurveVerts(TransInfo *t)
copy_m3_m3(td->axismtx, axismtx);
}
- if ((bezt_tx & SEL_F1) == 0 && (bezt_tx & SEL_F3) == 0)
+ if ((bezt_tx & SEL_F1) == 0 && (bezt_tx & SEL_F3) == 0) {
/* If the middle is selected but the sides arnt, this is needed */
if (hdata == NULL) {
/* if the handle was not saved by the previous handle */
hdata = initTransDataCurveHandles(td, bezt);
}
+ }
td++;
tail++;
@@ -1953,16 +2022,20 @@ static void createTransCurveVerts(TransInfo *t)
1 :
2]);
if (hide_handles) {
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
td->flag = TD_SELECTED;
- else
+ }
+ else {
td->flag = 0;
+ }
}
else {
- if (bezt->f3 & SELECT)
+ if (bezt->f3 & SELECT) {
td->flag = TD_SELECTED;
- else
+ }
+ else {
td->flag = 0;
+ }
}
td->ext = NULL;
td->val = NULL;
@@ -1989,8 +2062,9 @@ static void createTransCurveVerts(TransInfo *t)
head = tail;
}
}
- if (is_prop_edit && head != tail)
+ if (is_prop_edit && head != tail) {
calc_distanceCurveVerts(head, tail - 1);
+ }
/* TODO - in the case of tilt and radius we can also avoid allocating the
* initTransDataCurveHandles but for now just don't change handle types */
@@ -2029,10 +2103,12 @@ static void createTransCurveVerts(TransInfo *t)
copy_v3_v3(td->iloc, bp->vec);
td->loc = bp->vec;
copy_v3_v3(td->center, td->loc);
- if (bp->f1 & SELECT)
+ if (bp->f1 & SELECT) {
td->flag = TD_SELECTED;
- else
+ }
+ else {
td->flag = 0;
+ }
td->ext = NULL;
if (t->mode == TFM_CURVE_SHRINKFATTEN || t->mode == TFM_RESIZE) {
@@ -2061,8 +2137,9 @@ static void createTransCurveVerts(TransInfo *t)
head = tail;
}
}
- if (is_prop_edit && head != tail)
+ if (is_prop_edit && head != tail) {
calc_distanceCurveVerts(head, tail - 1);
+ }
}
}
}
@@ -2089,22 +2166,27 @@ static void createTransLatticeVerts(TransInfo *t)
a = latt->pntsu * latt->pntsv * latt->pntsw;
while (a--) {
if (bp->hide == 0) {
- if (bp->f1 & SELECT)
+ if (bp->f1 & SELECT) {
countsel++;
- if (is_prop_edit)
+ }
+ if (is_prop_edit) {
count++;
+ }
}
bp++;
}
/* note: in prop mode we need at least 1 selected */
- if (countsel == 0)
+ if (countsel == 0) {
return;
+ }
- if (is_prop_edit)
+ if (is_prop_edit) {
tc->data_len = count;
- else
+ }
+ else {
tc->data_len = countsel;
+ }
tc->data = MEM_callocN(tc->data_len * sizeof(TransData), "TransObData(Lattice EditMode)");
copy_m3_m4(mtx, tc->obedit->obmat);
@@ -2157,8 +2239,9 @@ static void createTransParticleVerts(bContext *C, TransInfo *t)
int count = 0, hasselected = 0;
const bool is_prop_edit = (t->flag & T_PROP_EDIT) != 0;
- if (edit == NULL || t->settings->particle.selectmode == SCE_SELECT_PATH)
+ if (edit == NULL || t->settings->particle.selectmode == SCE_SELECT_PATH) {
return;
+ }
psys = edit->psys;
@@ -2173,8 +2256,9 @@ static void createTransParticleVerts(bContext *C, TransInfo *t)
hasselected = 1;
transformparticle = 1;
}
- else if (is_prop_edit)
+ else if (is_prop_edit) {
transformparticle = 1;
+ }
}
}
}
@@ -2186,17 +2270,20 @@ static void createTransParticleVerts(bContext *C, TransInfo *t)
}
/* note: in prop mode we need at least 1 selected */
- if (hasselected == 0)
+ if (hasselected == 0) {
return;
+ }
tc->data_len = count;
td = tc->data = MEM_callocN(tc->data_len * sizeof(TransData), "TransObData(Particle Mode)");
- if (t->mode == TFM_BAKE_TIME)
+ if (t->mode == TFM_BAKE_TIME) {
tx = tc->data_ext = MEM_callocN(tc->data_len * sizeof(TransDataExtension),
"Particle_TransExtension");
- else
+ }
+ else {
tx = tc->data_ext = NULL;
+ }
unit_m4(mat);
@@ -2206,8 +2293,9 @@ static void createTransParticleVerts(bContext *C, TransInfo *t)
TransData *head, *tail;
head = tail = td;
- if (!(point->flag & PEP_TRANSFORM))
+ if (!(point->flag & PEP_TRANSFORM)) {
continue;
+ }
if (psys && !(psys->flag & PSYS_GLOBAL_HAIR)) {
ParticleSystemModifierData *psmd_eval = edit->psmd_eval;
@@ -2221,23 +2309,27 @@ static void createTransParticleVerts(bContext *C, TransInfo *t)
mul_m4_v3(mat, key->world_co);
td->loc = key->world_co;
}
- else
+ else {
td->loc = key->co;
+ }
copy_v3_v3(td->iloc, td->loc);
copy_v3_v3(td->center, td->loc);
- if (key->flag & PEK_SELECT)
+ if (key->flag & PEK_SELECT) {
td->flag |= TD_SELECTED;
- else if (!is_prop_edit)
+ }
+ else if (!is_prop_edit) {
td->flag |= TD_SKIP;
+ }
unit_m3(td->mtx);
unit_m3(td->smtx);
/* don't allow moving roots */
- if (k == 0 && pset->flag & PE_LOCK_FIRST && (!psys || !(psys->flag & PSYS_GLOBAL_HAIR)))
+ if (k == 0 && pset->flag & PE_LOCK_FIRST && (!psys || !(psys->flag & PSYS_GLOBAL_HAIR))) {
td->protectflag |= OB_LOCK_LOC;
+ }
td->ob = ob;
td->ext = tx;
@@ -2246,24 +2338,30 @@ static void createTransParticleVerts(bContext *C, TransInfo *t)
td->ival = *(key->time);
/* abuse size and quat for min/max values */
td->flag |= TD_NO_EXT;
- if (k == 0)
+ if (k == 0) {
tx->size = NULL;
- else
+ }
+ else {
tx->size = (key - 1)->time;
+ }
- if (k == point->totkey - 1)
+ if (k == point->totkey - 1) {
tx->quat = NULL;
- else
+ }
+ else {
tx->quat = (key + 1)->time;
+ }
}
td++;
- if (tx)
+ if (tx) {
tx++;
+ }
tail++;
}
- if (is_prop_edit && head != tail)
+ if (is_prop_edit && head != tail) {
calc_distanceCurveVerts(head, tail - 1);
+ }
}
}
}
@@ -2287,8 +2385,9 @@ void flushTransParticles(TransInfo *t)
* back to particle local space (only for hair particles) */
td = tc->data;
for (i = 0, point = edit->points; i < edit->totpoint; i++, point++, td++) {
- if (!(point->flag & PEP_TRANSFORM))
+ if (!(point->flag & PEP_TRANSFORM)) {
continue;
+ }
if (psys && !(psys->flag & PSYS_GLOBAL_HAIR)) {
ParticleSystemModifierData *psmd_eval = edit->psmd_eval;
@@ -2307,8 +2406,9 @@ void flushTransParticles(TransInfo *t)
}
}
}
- else
+ else {
point->flag |= PEP_EDIT_RECALC;
+ }
}
PE_update_object(t->depsgraph, scene, OBACT(view_layer), 1);
@@ -2860,8 +2960,9 @@ static void createTransEditVerts(TransInfo *t)
mappedcos = BKE_crazyspace_get_mapped_editverts(t->depsgraph, t->scene, tc->obedit);
quats = MEM_mallocN(em->bm->totvert * sizeof(*quats), "crazy quats");
BKE_crazyspace_set_quats_editmesh(em, defcos, mappedcos, quats, !prop_mode);
- if (mappedcos)
+ if (mappedcos) {
MEM_freeN(mappedcos);
+ }
}
if (defcos) {
@@ -2900,12 +3001,14 @@ static void createTransEditVerts(TransInfo *t)
/* Do not use the island center in case we are using islands
* only to get axis for snap/rotate to normal... */
VertsToTransData(t, tob, tx, em, eve, bweight, v_island, is_snap_rotate);
- if (tx)
+ if (tx) {
tx++;
+ }
/* selected */
- if (BM_elem_flag_test(eve, BM_ELEM_SELECT))
+ if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) {
tob->flag |= TD_SELECTED;
+ }
if (prop_mode) {
if (prop_mode & T_PROP_CONNECTED) {
@@ -2975,14 +3078,18 @@ static void createTransEditVerts(TransInfo *t)
cleanup:
/* crazy space free */
- if (quats)
+ if (quats) {
MEM_freeN(quats);
- if (defmats)
+ }
+ if (defmats) {
MEM_freeN(defmats);
- if (dists)
+ }
+ if (dists) {
MEM_freeN(dists);
- if (dists_index)
+ }
+ if (dists_index) {
MEM_freeN(dists_index);
+ }
if (tc->mirror.axis_flag) {
EDBM_verts_mirror_cache_end(em);
@@ -3052,8 +3159,9 @@ BLI_INLINE void trans_update_seq(Scene *sce, Sequence *seq, int old_start, int s
BKE_sequence_calc_disp(sce, seq);
}
- if (sel_flag == SELECT)
+ if (sel_flag == SELECT) {
BKE_sequencer_offset_animdata(sce, seq, seq->start - old_start);
+ }
}
void flushTransSeq(TransInfo *t)
@@ -3338,8 +3446,9 @@ static void createTransUVs(bContext *C, TransInfo *t)
* treated just as if they were 3d verts */
tc->data_2d = MEM_callocN(tc->data_len * sizeof(TransData2D), "TransObData2D(UV Editing)");
- if (sima->flag & SI_CLIP_UV)
+ if (sima->flag & SI_CLIP_UV) {
t->flag |= T_CLIP_UV;
+ }
td = tc->data;
td2d = tc->data_2d;
@@ -3347,16 +3456,18 @@ static void createTransUVs(bContext *C, TransInfo *t)
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
BMLoop *l;
- if (!BM_elem_flag_test(efa, BM_ELEM_TAG))
+ if (!BM_elem_flag_test(efa, BM_ELEM_TAG)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
const bool selected = uvedit_uv_select_test(scene, l, cd_loop_uv_offset);
MLoopUV *luv;
const float *center = NULL;
- if (!is_prop_edit && !selected)
+ if (!is_prop_edit && !selected) {
continue;
+ }
if (is_prop_connected || is_island_center) {
UvElement *element = BM_uv_element_get(elementmap, efa, l);
@@ -3469,34 +3580,48 @@ bool clipUVTransform(TransInfo *t, float vec[2], const bool resize)
}
if (resize) {
- if (min[0] < 0.0f && t->center_global[0] > 0.0f && t->center_global[0] < t->aspect[0] * 0.5f)
+ if (min[0] < 0.0f && t->center_global[0] > 0.0f &&
+ t->center_global[0] < t->aspect[0] * 0.5f) {
vec[0] *= t->center_global[0] / (t->center_global[0] - min[0]);
- else if (max[0] > t->aspect[0] && t->center_global[0] < t->aspect[0])
+ }
+ else if (max[0] > t->aspect[0] && t->center_global[0] < t->aspect[0]) {
vec[0] *= (t->center_global[0] - t->aspect[0]) / (t->center_global[0] - max[0]);
- else
+ }
+ else {
clipx = 0;
+ }
- if (min[1] < 0.0f && t->center_global[1] > 0.0f && t->center_global[1] < t->aspect[1] * 0.5f)
+ if (min[1] < 0.0f && t->center_global[1] > 0.0f &&
+ t->center_global[1] < t->aspect[1] * 0.5f) {
vec[1] *= t->center_global[1] / (t->center_global[1] - min[1]);
- else if (max[1] > t->aspect[1] && t->center_global[1] < t->aspect[1])
+ }
+ else if (max[1] > t->aspect[1] && t->center_global[1] < t->aspect[1]) {
vec[1] *= (t->center_global[1] - t->aspect[1]) / (t->center_global[1] - max[1]);
- else
+ }
+ else {
clipy = 0;
+ }
}
else {
- if (min[0] < 0.0f)
+ if (min[0] < 0.0f) {
vec[0] -= min[0];
- else if (max[0] > t->aspect[0])
+ }
+ else if (max[0] > t->aspect[0]) {
vec[0] -= max[0] - t->aspect[0];
- else
+ }
+ else {
clipx = 0;
+ }
- if (min[1] < 0.0f)
+ if (min[1] < 0.0f) {
vec[1] -= min[1];
- else if (max[1] > t->aspect[1])
+ }
+ else if (max[1] > t->aspect[1]) {
vec[1] -= max[1] - t->aspect[1];
- else
+ }
+ else {
clipy = 0;
+ }
}
}
@@ -3508,11 +3633,13 @@ void clipUVData(TransInfo *t)
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td = tc->data;
for (int a = 0; a < tc->data_len; a++, td++) {
- if (td->flag & TD_NOACTION)
+ if (td->flag & TD_NOACTION) {
break;
+ }
- if ((td->flag & TD_SKIP) || (!td->loc))
+ if ((td->flag & TD_SKIP) || (!td->loc)) {
continue;
+ }
td->loc[0] = min_ff(max_ff(0.0f, td->loc[0]), t->aspect[0]);
td->loc[1] = min_ff(max_ff(0.0f, td->loc[1]), t->aspect[1]);
@@ -3526,14 +3653,17 @@ void clipUVData(TransInfo *t)
static bool FrameOnMouseSide(char side, float frame, float cframe)
{
/* both sides, so it doesn't matter */
- if (side == 'B')
+ if (side == 'B') {
return true;
+ }
/* only on the named side */
- if (side == 'R')
+ if (side == 'R') {
return (frame >= cframe);
- else
+ }
+ else {
return (frame <= cframe);
+ }
}
/* ********************* NLA EDITOR ************************* */
@@ -3555,8 +3685,9 @@ static void createTransNlaData(bContext *C, TransInfo *t)
TransDataContainer *tc = TRANS_DATA_CONTAINER_FIRST_SINGLE(t);
/* determine what type of data we are operating on */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return;
+ }
snla = (SpaceNla *)ac.sl;
/* filter data */
@@ -3590,10 +3721,12 @@ static void createTransNlaData(bContext *C, TransInfo *t)
/* transition strips can't get directly transformed */
if (strip->type != NLASTRIP_TYPE_TRANSITION) {
if (strip->flag & NLASTRIP_FLAG_SELECT) {
- if (FrameOnMouseSide(t->frame_side, strip->start, (float)CFRA))
+ if (FrameOnMouseSide(t->frame_side, strip->start, (float)CFRA)) {
count++;
- if (FrameOnMouseSide(t->frame_side, strip->end, (float)CFRA))
+ }
+ if (FrameOnMouseSide(t->frame_side, strip->end, (float)CFRA)) {
count++;
+ }
}
}
}
@@ -3736,10 +3869,12 @@ static void createTransNlaData(bContext *C, TransInfo *t)
* since the counting code is dumb.
* Otherwise, just advance to the next one.
*/
- if (tdn->handle == 2)
+ if (tdn->handle == 2) {
tdn += 2;
- else
+ }
+ else {
tdn++;
+ }
}
}
}
@@ -3757,10 +3892,12 @@ static int gpf_cmp_frame(void *thunk, const void *a, const void *b)
const bGPDframe *frame_a = a;
const bGPDframe *frame_b = b;
- if (frame_a->framenum < frame_b->framenum)
+ if (frame_a->framenum < frame_b->framenum) {
return -1;
- if (frame_a->framenum > frame_b->framenum)
+ }
+ if (frame_a->framenum > frame_b->framenum) {
return 1;
+ }
*((bool *)thunk) = true;
/* selected last */
if ((frame_a->flag & GP_FRAME_SELECT) && ((frame_b->flag & GP_FRAME_SELECT) == 0)) {
@@ -3774,10 +3911,12 @@ static int masklay_shape_cmp_frame(void *thunk, const void *a, const void *b)
const MaskLayerShape *frame_a = a;
const MaskLayerShape *frame_b = b;
- if (frame_a->frame < frame_b->frame)
+ if (frame_a->frame < frame_b->frame) {
return -1;
- if (frame_a->frame > frame_b->frame)
+ }
+ if (frame_a->frame > frame_b->frame) {
return 1;
+ }
*((bool *)thunk) = true;
/* selected last */
if ((frame_a->flag & MASK_SHAPE_SELECT) && ((frame_b->flag & MASK_SHAPE_SELECT) == 0)) {
@@ -3870,8 +4009,9 @@ static void posttrans_fcurve_clean(FCurve *fcu, const bool use_handle)
0);
/* sanity checks */
- if ((fcu->totvert == 0) || (fcu->bezt == NULL))
+ if ((fcu->totvert == 0) || (fcu->bezt == NULL)) {
return;
+ }
/* 1) Identify selected keyframes, and average the values on those
* in case there are collisions due to multiple keys getting scaled
@@ -4004,8 +4144,9 @@ static void posttrans_action_clean(bAnimContext *ac, bAction *act)
posttrans_fcurve_clean(ale->key_data, false); /* only use handles in graph editor */
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 0);
}
- else
+ else {
posttrans_fcurve_clean(ale->key_data, false); /* only use handles in graph editor */
+ }
}
/* free temp data */
@@ -4020,25 +4161,29 @@ static int count_fcurve_keys(FCurve *fcu, char side, float cfra, bool is_prop_ed
BezTriple *bezt;
int i, count = 0, count_all = 0;
- if (ELEM(NULL, fcu, fcu->bezt))
+ if (ELEM(NULL, fcu, fcu->bezt)) {
return count;
+ }
/* only include points that occur on the right side of cfra */
for (i = 0, bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) {
if (FrameOnMouseSide(side, bezt->vec[1][0], cfra)) {
/* no need to adjust the handle selection since they are assumed
* selected (like graph editor with SIPO_NOHANDLES) */
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
count++;
+ }
count_all++;
}
}
- if (is_prop_edit && count > 0)
+ if (is_prop_edit && count > 0) {
return count_all;
- else
+ }
+ else {
return count;
+ }
}
/* fully select selected beztriples, but only include if it's on the right side of cfra */
@@ -4047,22 +4192,26 @@ static int count_gplayer_frames(bGPDlayer *gpl, char side, float cfra, bool is_p
bGPDframe *gpf;
int count = 0, count_all = 0;
- if (gpl == NULL)
+ if (gpl == NULL) {
return count;
+ }
/* only include points that occur on the right side of cfra */
for (gpf = gpl->frames.first; gpf; gpf = gpf->next) {
if (FrameOnMouseSide(side, (float)gpf->framenum, cfra)) {
- if (gpf->flag & GP_FRAME_SELECT)
+ if (gpf->flag & GP_FRAME_SELECT) {
count++;
+ }
count_all++;
}
}
- if (is_prop_edit && count > 0)
+ if (is_prop_edit && count > 0) {
return count_all;
- else
+ }
+ else {
return count;
+ }
}
/* fully select selected beztriples, but only include if it's on the right side of cfra */
@@ -4071,23 +4220,27 @@ static int count_masklayer_frames(MaskLayer *masklay, char side, float cfra, boo
MaskLayerShape *masklayer_shape;
int count = 0, count_all = 0;
- if (masklay == NULL)
+ if (masklay == NULL) {
return count;
+ }
/* only include points that occur on the right side of cfra */
for (masklayer_shape = masklay->splines_shapes.first; masklayer_shape;
masklayer_shape = masklayer_shape->next) {
if (FrameOnMouseSide(side, (float)masklayer_shape->frame, cfra)) {
- if (masklayer_shape->flag & MASK_SHAPE_SELECT)
+ if (masklayer_shape->flag & MASK_SHAPE_SELECT) {
count++;
+ }
count_all++;
}
}
- if (is_prop_edit && count > 0)
+ if (is_prop_edit && count > 0) {
return count_all;
- else
+ }
+ else {
return count;
+ }
}
/* This function assigns the information to transdata */
@@ -4126,8 +4279,9 @@ static TransData *ActionFCurveToTransData(TransData *td,
TransData2D *td2d = *td2dv;
int i;
- if (ELEM(NULL, fcu, fcu->bezt))
+ if (ELEM(NULL, fcu, fcu->bezt)) {
return td;
+ }
for (i = 0, bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) {
/* only add selected keyframes (for now, proportional edit is not enabled) */
@@ -4137,8 +4291,9 @@ static TransData *ActionFCurveToTransData(TransData *td,
if (FrameOnMouseSide(side, bezt->vec[1][0], cfra)) {
TimeToTransData(td, bezt->vec[1], adt, ypos);
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
td->flag |= TD_SELECTED;
+ }
/*set flags to move handles as necessary*/
td->flag |= TD_MOVEHANDLE1 | TD_MOVEHANDLE2;
@@ -4284,14 +4439,17 @@ static void createTransActionData(bContext *C, TransInfo *t)
float ypos = 1.0f / ((ysize / xsize) * (xmask / ymask)) * BLI_rctf_cent_y(&t->ar->v2d.cur);
/* determine what type of data we are operating on */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return;
+ }
/* filter data */
- if (ELEM(ac.datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK))
+ if (ELEM(ac.datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) {
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT);
- else
+ }
+ else {
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/);
+ }
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
/* which side of the current frame should be allowed */
@@ -4314,19 +4472,25 @@ static void createTransActionData(bContext *C, TransInfo *t)
/* convert current-frame to action-time (slightly less accurate, especially under
* higher scaling ratios, but is faster than converting all points)
*/
- if (adt)
+ if (adt) {
cfra = BKE_nla_tweakedit_remap(adt, (float)CFRA, NLATIME_CONVERT_UNMAP);
- else
+ }
+ else {
cfra = (float)CFRA;
+ }
- if (ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE))
+ if (ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE)) {
adt_count = count_fcurve_keys(ale->key_data, t->frame_side, cfra, is_prop_edit);
- else if (ale->type == ANIMTYPE_GPLAYER)
+ }
+ else if (ale->type == ANIMTYPE_GPLAYER) {
adt_count = count_gplayer_frames(ale->data, t->frame_side, cfra, is_prop_edit);
- else if (ale->type == ANIMTYPE_MASKLAYER)
+ }
+ else if (ale->type == ANIMTYPE_MASKLAYER) {
adt_count = count_masklayer_frames(ale->data, t->frame_side, cfra, is_prop_edit);
- else
+ }
+ else {
BLI_assert(0);
+ }
if (adt_count > 0) {
count += adt_count;
@@ -4359,8 +4523,9 @@ static void createTransActionData(bContext *C, TransInfo *t)
/* loop 2: build transdata array */
for (ale = anim_data.first; ale; ale = ale->next) {
- if (is_prop_edit && !ale->tag)
+ if (is_prop_edit && !ale->tag) {
continue;
+ }
cfra = (float)CFRA;
@@ -4404,14 +4569,17 @@ static void createTransActionData(bContext *C, TransInfo *t)
AnimData *adt;
/* F-Curve may not have any keyframes */
- if (!ale->tag)
+ if (!ale->tag) {
continue;
+ }
adt = ANIM_nla_mapping_get(&ac, ale);
- if (adt)
+ if (adt) {
cfra = BKE_nla_tweakedit_remap(adt, (float)CFRA, NLATIME_CONVERT_UNMAP);
- else
+ }
+ else {
cfra = (float)CFRA;
+ }
if (ale->type == ANIMTYPE_GPLAYER) {
bGPDlayer *gpl = (bGPDlayer *)ale->data;
@@ -4487,8 +4655,9 @@ static void createTransActionData(bContext *C, TransInfo *t)
if (bezt_iter->f2 & SELECT) {
if (FrameOnMouseSide(t->frame_side, (float)bezt_iter->vec[1][0], cfra)) {
float val = fabs(bezt->vec[1][0] - bezt_iter->vec[1][0]);
- if (val < min)
+ if (val < min) {
min = val;
+ }
}
}
}
@@ -4588,13 +4757,16 @@ static void bezt_to_transdata(TransData *td,
td->flag |= TD_SELECTED;
td->dist = 0.0f;
}
- else
+ else {
td->dist = FLT_MAX;
+ }
- if (ishandle)
+ if (ishandle) {
td->flag |= TD_NOTIMESNAP;
- if (intvals)
+ }
+ if (intvals) {
td->flag |= TD_INTVALUES;
+ }
/* copy space-conversion matrices for dealing with non-uniform scales */
copy_m3_m3(td->mtx, mtx);
@@ -4663,8 +4835,9 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
short anim_map_flag = ANIM_UNITCONV_ONLYSEL | ANIM_UNITCONV_SELVERTS;
/* determine what type of data we are operating on */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return;
+ }
anim_map_flag |= ANIM_get_normalization_flags(&ac);
@@ -4696,16 +4869,19 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
bool selected = false;
/* F-Curve may not have any keyframes */
- if (fcu->bezt == NULL)
+ if (fcu->bezt == NULL) {
continue;
+ }
/* convert current-frame to action-time (slightly less accurate, especially under
* higher scaling ratios, but is faster than converting all points)
*/
- if (adt)
+ if (adt) {
cfra = BKE_nla_tweakedit_remap(adt, (float)CFRA, NLATIME_CONVERT_UNMAP);
- else
+ }
+ else {
cfra = (float)CFRA;
+ }
/* Only include BezTriples whose 'keyframe'
* occurs on the same side of the current frame as mouse. */
@@ -4717,8 +4893,9 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
if (is_prop_edit) {
curvecount += 3;
- if (sel2 || sel1 || sel3)
+ if (sel2 || sel1 || sel3) {
selected = true;
+ }
}
else {
if (!is_translation_mode || !(sel2)) {
@@ -4785,10 +4962,12 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
mul_v3_fl(mtx[1], yscale);
/* smtx is global (i.e. view) to data conversion */
- if (IS_EQF(xscale, 0.0f) == 0)
+ if (IS_EQF(xscale, 0.0f) == 0) {
mul_v3_fl(smtx[0], 1.0f / xscale);
- if (IS_EQF(yscale, 0.0f) == 0)
+ }
+ if (IS_EQF(yscale, 0.0f) == 0) {
mul_v3_fl(smtx[1], 1.0f / yscale);
+ }
}
/* loop 2: build transdata arrays */
@@ -4800,16 +4979,19 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
float cfra;
/* F-Curve may not have any keyframes */
- if (fcu->bezt == NULL || (is_prop_edit && ale->tag == 0))
+ if (fcu->bezt == NULL || (is_prop_edit && ale->tag == 0)) {
continue;
+ }
/* convert current-frame to action-time (slightly less accurate, especially under
* higher scaling ratios, but is faster than converting all points)
*/
- if (adt)
+ if (adt) {
cfra = BKE_nla_tweakedit_remap(adt, (float)CFRA, NLATIME_CONVERT_UNMAP);
- else
+ }
+ else {
cfra = (float)CFRA;
+ }
unit_scale = ANIM_unit_mapping_get_factor(
ac.scene, ale->id, ale->key_data, anim_map_flag, &offset);
@@ -4897,8 +5079,9 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
}
if (sel3) {
- if (hdata == NULL)
+ if (hdata == NULL) {
hdata = initTransDataCurveHandles(td, bezt);
+ }
bezt_to_transdata(td++,
td2d++,
tdg++,
@@ -4922,16 +5105,19 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
if (sel2 && !use_local_center) {
/* move handles relative to center */
if (is_translation_mode) {
- if (sel1)
+ if (sel1) {
td->flag |= TD_MOVEHANDLE1;
- if (sel3)
+ }
+ if (sel3) {
td->flag |= TD_MOVEHANDLE2;
+ }
}
/* if handles were not selected, store their selection status */
if (!(sel1) || !(sel3)) {
- if (hdata == NULL)
+ if (hdata == NULL) {
hdata = initTransDataCurveHandles(td, bezt);
+ }
}
bezt_to_transdata(td++,
@@ -4981,16 +5167,19 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
float cfra;
/* F-Curve may not have any keyframes */
- if (fcu->bezt == NULL || (ale->tag == 0))
+ if (fcu->bezt == NULL || (ale->tag == 0)) {
continue;
+ }
/* convert current-frame to action-time (slightly less accurate, especially under
* higher scaling ratios, but is faster than converting all points)
*/
- if (adt)
+ if (adt) {
cfra = BKE_nla_tweakedit_remap(adt, (float)CFRA, NLATIME_CONVERT_UNMAP);
- else
+ }
+ else {
cfra = (float)CFRA;
+ }
/* only include BezTriples whose 'keyframe' occurs on the
* same side of the current frame as mouse (if applicable) */
@@ -5054,8 +5243,9 @@ static BeztMap *bezt_to_beztmaps(BezTriple *bezts, int totvert, const short UNUS
int i;
/* allocate memory for this array */
- if (totvert == 0 || bezts == NULL)
+ if (totvert == 0 || bezts == NULL) {
return NULL;
+ }
bezm = bezms = MEM_callocN(sizeof(BeztMap) * totvert, "BeztMaps");
/* assign beztriples to beztmaps */
@@ -5146,34 +5336,41 @@ static void beztmap_to_data(
td = tc->data;
for (j = 0; j < tc->data_len; j++, td2d++, td++) {
/* skip item if already marked */
- if (adjusted[j] != 0)
+ if (adjusted[j] != 0) {
continue;
+ }
/* update all transdata pointers, no need to check for selections etc,
* since only points that are really needed were created as transdata
*/
if (td2d->loc2d == bezm->bezt->vec[0]) {
- if (bezm->swapHs == 1)
+ if (bezm->swapHs == 1) {
td2d->loc2d = (bezts + bezm->newIndex)->vec[2];
- else
+ }
+ else {
td2d->loc2d = (bezts + bezm->newIndex)->vec[0];
+ }
adjusted[j] = 1;
}
else if (td2d->loc2d == bezm->bezt->vec[2]) {
- if (bezm->swapHs == 1)
+ if (bezm->swapHs == 1) {
td2d->loc2d = (bezts + bezm->newIndex)->vec[0];
- else
+ }
+ else {
td2d->loc2d = (bezts + bezm->newIndex)->vec[2];
+ }
adjusted[j] = 1;
}
else if (td2d->loc2d == bezm->bezt->vec[1]) {
td2d->loc2d = (bezts + bezm->newIndex)->vec[1];
/* if only control point is selected, the handle pointers need to be updated as well */
- if (td2d->h1)
+ if (td2d->h1) {
td2d->h1 = (bezts + bezm->newIndex)->vec[0];
- if (td2d->h2)
+ }
+ if (td2d->h2) {
td2d->h2 = (bezts + bezm->newIndex)->vec[2];
+ }
adjusted[j] = 1;
}
@@ -5280,10 +5477,12 @@ void flushTransGraphData(TransInfo *t)
}
/* we need to unapply the nla-mapping from the time in some situations */
- if (adt)
+ if (adt) {
td2d->loc2d[0] = BKE_nla_tweakedit_remap(adt, td2d->loc[0], NLATIME_CONVERT_UNMAP);
- else
+ }
+ else {
td2d->loc2d[0] = td2d->loc[0];
+ }
/** Time-stepping auto-snapping modes don't get applied for Graph Editor transforms,
* as these use the generic transform modes which don't account for this sort of thing.
@@ -5312,10 +5511,12 @@ void flushTransGraphData(TransInfo *t)
}
/* if int-values only, truncate to integers */
- if (td->flag & TD_INTVALUES)
+ if (td->flag & TD_INTVALUES) {
td2d->loc2d[1] = floorf(td2d->loc[1] * inv_unit_scale - tdg->offset + 0.5f);
- else
+ }
+ else {
td2d->loc2d[1] = td2d->loc[1] * inv_unit_scale - tdg->offset;
+ }
if ((td->flag & TD_MOVEHANDLE1) && td2d->h1) {
td2d->h1[0] = td2d->ih1[0] + td->loc[0] - td->iloc[0];
@@ -5360,12 +5561,15 @@ static void SeqTransInfo(TransInfo *t, Sequence *seq, int *recursive, int *count
/* for meta's we only ever need to extend their children, no matter what depth
* just check the meta's are in the bounds */
- if (t->frame_side == 'R' && right <= cfra)
+ if (t->frame_side == 'R' && right <= cfra) {
*recursive = false;
- else if (t->frame_side == 'L' && left >= cfra)
+ }
+ else if (t->frame_side == 'L' && left >= cfra) {
*recursive = false;
- else
+ }
+ else {
*recursive = true;
+ }
*count = 1;
*flag = (seq->flag | SELECT) & ~(SEQ_LEFTSEL | SEQ_RIGHTSEL);
@@ -5382,8 +5586,9 @@ static void SeqTransInfo(TransInfo *t, Sequence *seq, int *recursive, int *count
} /* ignore */
else if (left > cfra) {
} /* keep the selection */
- else
+ else {
*flag |= SEQ_RIGHTSEL;
+ }
}
else {
if (left >= cfra) {
@@ -5391,8 +5596,9 @@ static void SeqTransInfo(TransInfo *t, Sequence *seq, int *recursive, int *count
} /* ignore */
else if (right < cfra) {
} /* keep the selection */
- else
+ else {
*flag |= SEQ_LEFTSEL;
+ }
}
}
}
@@ -5667,8 +5873,9 @@ static void freeSeqData(TransInfo *t, TransDataContainer *tc, TransCustomData *c
if (overlap) {
bool has_effect_root = false, has_effect_any = false;
- for (seq = seqbasep->first; seq; seq = seq->next)
+ for (seq = seqbasep->first; seq; seq = seq->next) {
seq->tmp = NULL;
+ }
td = tc->data;
for (a = 0, seq_prev = NULL; a < tc->data_len; a++, td++, seq_prev = seq) {
@@ -5762,12 +5969,15 @@ static void freeSeqData(TransInfo *t, TransDataContainer *tc, TransCustomData *c
for (seq = seqbasep->first; seq; seq = seq->next) {
/* We might want to build a list of effects that need to be updated during transform */
if (seq->type & SEQ_TYPE_EFFECT) {
- if (seq->seq1 && seq->seq1->flag & SELECT)
+ if (seq->seq1 && seq->seq1->flag & SELECT) {
BKE_sequence_calc(t->scene, seq);
- else if (seq->seq2 && seq->seq2->flag & SELECT)
+ }
+ else if (seq->seq2 && seq->seq2->flag & SELECT) {
BKE_sequence_calc(t->scene, seq);
- else if (seq->seq3 && seq->seq3->flag & SELECT)
+ }
+ else if (seq->seq3 && seq->seq3->flag & SELECT) {
BKE_sequence_calc(t->scene, seq);
+ }
}
}
@@ -5778,8 +5988,9 @@ static void freeSeqData(TransInfo *t, TransDataContainer *tc, TransCustomData *c
for (a = 0; a < tc->data_len; a++, td++) {
seq = ((TransDataSeq *)td->extra)->seq;
if ((seq != seq_prev) && (seq->depth == 0)) {
- if (seq->flag & SEQ_OVERLAP)
+ if (seq->flag & SEQ_OVERLAP) {
BKE_sequence_base_shuffle(seqbasep, seq, t->scene);
+ }
BKE_sequence_calc_disp(t->scene, seq);
}
@@ -5873,8 +6084,9 @@ static void createTransSeqData(bContext *C, TransInfo *t)
SeqTransDataBounds(t, ed->seqbasep, ts);
/* set the snap mode based on how close the mouse is at the end/start points */
- if (abs(xmouse - ts->max) > abs(xmouse - ts->min))
+ if (abs(xmouse - ts->max) > abs(xmouse - ts->min)) {
ts->snap_left = true;
+ }
#undef XXX_DURIAN_ANIM_TX_HACK
}
@@ -5915,23 +6127,26 @@ static bool constraints_list_needinv(TransInfo *t, ListBase *list)
bChildOfConstraint *data = (bChildOfConstraint *)con->data;
if ((data->flag & CHILDOF_LOCX) && (data->flag & CHILDOF_LOCY) &&
- (data->flag & CHILDOF_LOCZ))
+ (data->flag & CHILDOF_LOCZ)) {
return true;
+ }
}
else if (con->type == CONSTRAINT_TYPE_ROTLIKE) {
/* CopyRot constraint only does this when rotating, and offset is on */
bRotateLikeConstraint *data = (bRotateLikeConstraint *)con->data;
- if ((data->flag & ROTLIKE_OFFSET) && (t->mode == TFM_ROTATION))
+ if ((data->flag & ROTLIKE_OFFSET) && (t->mode == TFM_ROTATION)) {
return true;
+ }
}
else if (con->type == CONSTRAINT_TYPE_TRANSFORM) {
/* Transform constraint needs it for rotation at least (r.57309),
* but doing so when translating may also mess things up [#36203]
*/
- if (t->mode == TFM_ROTATION)
+ if (t->mode == TFM_ROTATION) {
return true;
+ }
/* ??? (t->mode == TFM_SCALE) ? */
}
}
@@ -5991,8 +6206,9 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob)
constinv = constraints_list_needinv(t, &ob->constraints);
/* disable constraints inversion for dummy pass */
- if (t->mode == TFM_DUMMY)
+ if (t->mode == TFM_DUMMY) {
skip_invert = true;
+ }
/* NOTE: This is not really following copy-on-write design and we should not
* be re-evaluating the evaluated object. But as the comment above mentioned
@@ -6181,8 +6397,9 @@ static void set_trans_object_base_flags(TransInfo *t)
static bool mark_children(Object *ob)
{
- if (ob->flag & (SELECT | BA_TRANSFORM_CHILD))
+ if (ob->flag & (SELECT | BA_TRANSFORM_CHILD)) {
return true;
+ }
if (ob->parent) {
if (mark_children(ob->parent)) {
@@ -6334,8 +6551,9 @@ void autokeyframe_object(bContext *C, Scene *scene, ViewLayer *view_layer, Objec
}
else if (ELEM(tmode, TFM_ROTATION, TFM_TRACKBALL)) {
if (scene->toolsettings->transform_pivot_point == V3D_AROUND_ACTIVE) {
- if (ob != OBACT(view_layer))
+ if (ob != OBACT(view_layer)) {
do_loc = true;
+ }
}
else if (scene->toolsettings->transform_pivot_point == V3D_AROUND_CURSOR) {
do_loc = true;
@@ -6347,8 +6565,9 @@ void autokeyframe_object(bContext *C, Scene *scene, ViewLayer *view_layer, Objec
}
else if (tmode == TFM_RESIZE) {
if (scene->toolsettings->transform_pivot_point == V3D_AROUND_ACTIVE) {
- if (ob != OBACT(view_layer))
+ if (ob != OBACT(view_layer)) {
do_loc = true;
+ }
}
else if (scene->toolsettings->transform_pivot_point == V3D_AROUND_CURSOR) {
do_loc = true;
@@ -6437,8 +6656,9 @@ void autokeyframe_pose(bContext *C, Scene *scene, Object *ob, int tmode, short t
*/
flag = ANIM_get_keyframing_flags(scene, 1);
- if (targetless_ik)
+ if (targetless_ik) {
flag |= INSERTKEY_MATRIX;
+ }
for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) {
if (pchan->bone->flag & BONE_TRANSFORM) {
@@ -6481,8 +6701,9 @@ void autokeyframe_pose(bContext *C, Scene *scene, Object *ob, int tmode, short t
flag);
}
- if (pchanName)
+ if (pchanName) {
MEM_freeN(pchanName);
+ }
}
}
}
@@ -6494,10 +6715,12 @@ void autokeyframe_pose(bContext *C, Scene *scene, Object *ob, int tmode, short t
/* Filter the conditions when this happens
* (assume that 'curarea->spacetype == SPACE_VIEW3D'). */
if (tmode == TFM_TRANSLATION) {
- if (targetless_ik)
+ if (targetless_ik) {
do_rot = true;
- else
+ }
+ else {
do_loc = true;
+ }
}
else if (ELEM(tmode, TFM_ROTATION, TFM_TRACKBALL)) {
if (ELEM(scene->toolsettings->transform_pivot_point,
@@ -6655,8 +6878,9 @@ static void special_aftertrans_update__node(bContext *C, TransInfo *t)
bNode *node, *node_next;
for (node = ntree->nodes.first; node; node = node_next) {
node_next = node->next;
- if (node->flag & NODE_SELECT)
+ if (node->flag & NODE_SELECT) {
nodeRemoveNode(bmain, ntree, node, true);
+ }
}
}
}
@@ -6790,9 +7014,10 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
* for some reason EXTEND is changed into TRANSLATE, so use frame_side instead */
if (t->mode == TFM_SEQ_SLIDE) {
- if (t->frame_side == 'B')
+ if (t->frame_side == 'B') {
ED_markers_post_apply_transform(
&t->scene->markers, t->scene, TFM_TIME_TRANSLATE, t->values[0], t->frame_side);
+ }
}
else if (ELEM(t->frame_side, 'L', 'R')) {
ED_markers_post_apply_transform(
@@ -6830,8 +7055,9 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
bAnimContext ac;
/* initialize relevant anim-context 'context' data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return;
+ }
ob = ac.obact;
@@ -6861,8 +7087,9 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
posttrans_fcurve_clean(fcu, false); /* only use handles in graph editor */
ANIM_nla_mapping_apply_fcurve(adt, fcu, 1, 0);
}
- else
+ else {
posttrans_fcurve_clean(fcu, false); /* only use handles in graph editor */
+ }
}
}
@@ -6873,11 +7100,13 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
/* Depending on the lock status, draw necessary views */
// fixme... some of this stuff is not good
if (ob) {
- if (ob->pose || BKE_key_from_object(ob))
+ if (ob->pose || BKE_key_from_object(ob)) {
DEG_id_tag_update(&ob->id,
ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION);
- else
+ }
+ else {
DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM);
+ }
}
/* 3 cases here for curve cleanups:
@@ -6906,8 +7135,9 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
// XXX: BAD! this get gpencil datablocks directly from main db...
// but that's how this currently works :/
for (gpd = bmain->gpencils.first; gpd; gpd = gpd->id.next) {
- if (ID_REAL_USERS(gpd))
+ if (ID_REAL_USERS(gpd)) {
posttrans_gpd_clean(gpd);
+ }
}
}
}
@@ -6927,8 +7157,9 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
// XXX: BAD! this get gpencil datablocks directly from main db...
// but that's how this currently works :/
for (mask = bmain->masks.first; mask; mask = mask->id.next) {
- if (ID_REAL_USERS(mask))
+ if (ID_REAL_USERS(mask)) {
posttrans_mask_clean(mask);
+ }
}
}
}
@@ -6958,8 +7189,9 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
}
/* make sure all F-Curves are set correctly */
- if (!ELEM(ac.datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK))
+ if (!ELEM(ac.datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) {
ANIM_editkeyframes_refresh(&ac);
+ }
/* clear flag that was set for time-slide drawing */
saction->flag &= ~SACTION_MOVING;
@@ -6970,8 +7202,9 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
const bool use_handle = (sipo->flag & SIPO_NOHANDLES) == 0;
/* initialize relevant anim-context 'context' data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return;
+ }
if (ac.datatype) {
ListBase anim_data = {NULL, NULL};
@@ -6998,8 +7231,9 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
posttrans_fcurve_clean(fcu, use_handle);
ANIM_nla_mapping_apply_fcurve(adt, fcu, 1, 0);
}
- else
+ else {
posttrans_fcurve_clean(fcu, use_handle);
+ }
}
}
@@ -7012,15 +7246,17 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
* Note: if the refresh is really needed after cancel then some way
* has to be added to not update handle types (see bug 22289).
*/
- if (!canceled)
+ if (!canceled) {
ANIM_editkeyframes_refresh(&ac);
+ }
}
else if (t->spacetype == SPACE_NLA) {
bAnimContext ac;
/* initialize relevant anim-context 'context' data */
- if (ANIM_animdata_get_context(C, &ac) == 0)
+ if (ANIM_animdata_get_context(C, &ac) == 0) {
return;
+ }
if (ac.datatype) {
ListBase anim_data = {NULL, NULL};
@@ -7093,19 +7329,22 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
}
/* if target-less IK grabbing, we calculate the pchan transforms and clear flag */
- if (!canceled && t->mode == TFM_TRANSLATION)
+ if (!canceled && t->mode == TFM_TRANSLATION) {
targetless_ik = apply_targetless_ik(ob);
+ }
else {
/* not forget to clear the auto flag */
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
bKinematicConstraint *data = has_targetless_ik(pchan);
- if (data)
+ if (data) {
data->flag &= ~CONSTRAINT_IK_AUTO;
+ }
}
}
- if (t->mode == TFM_TRANSLATION)
+ if (t->mode == TFM_TRANSLATION) {
pose_grab_with_ik_clear(bmain, ob);
+ }
/* automatic inserting of keys and unkeyed tagging -
* only if transform wasn't canceled (or TFM_DUMMY) */
@@ -7161,11 +7400,13 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
PTCacheID *pid;
ob = td->ob;
- if (td->flag & TD_NOACTION)
+ if (td->flag & TD_NOACTION) {
break;
+ }
- if (td->flag & TD_SKIP)
+ if (td->flag & TD_SKIP) {
continue;
+ }
/* flag object caches as outdated */
BKE_ptcache_ids_from_object(&pidlist, ob, t->scene, MAX_DUPLI_RECUR);
@@ -7178,8 +7419,9 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
BLI_freelistN(&pidlist);
/* pointcache refresh */
- if (BKE_ptcache_object_reset(t->scene, ob, PTCACHE_RESET_OUTDATED))
+ if (BKE_ptcache_object_reset(t->scene, ob, PTCACHE_RESET_OUTDATED)) {
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
+ }
/* Needed for proper updating of "quick cached" dynamics. */
/* Creates troubles for moving animated objects without */
@@ -7197,13 +7439,14 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
/* restore rigid body transform */
if (ob->rigidbody_object && canceled) {
float ctime = BKE_scene_frame_get(t->scene);
- if (BKE_rigidbody_check_sim_running(t->scene->rigidbody_world, ctime))
+ if (BKE_rigidbody_check_sim_running(t->scene->rigidbody_world, ctime)) {
BKE_rigidbody_aftertrans_update(ob,
td->ext->oloc,
td->ext->orot,
td->ext->oquat,
td->ext->orotAxis,
td->ext->orotAngle);
+ }
}
}
@@ -7489,8 +7732,9 @@ static void markerToTransDataInit(TransData *td,
copy_v2_v2(tdt->srelative, rel);
}
- if (off)
+ if (off) {
copy_v2_v2(tdt->soffset, off);
+ }
td->flag = 0;
td->loc = td2d->loc;
@@ -7642,8 +7886,9 @@ static void transDataTrackingFree(TransInfo *UNUSED(t),
{
if (custom_data->data) {
TransDataTracking *tdt = custom_data->data;
- if (tdt->smarkers)
+ if (tdt->smarkers) {
MEM_freeN(tdt->smarkers);
+ }
MEM_freeN(tdt);
custom_data->data = NULL;
@@ -7673,14 +7918,17 @@ static void createTransTrackingTracksData(bContext *C, TransInfo *t)
if (TRACK_VIEW_SELECTED(sc, track) && (track->flag & TRACK_LOCKED) == 0) {
tc->data_len++; /* offset */
- if (track->flag & SELECT)
+ if (track->flag & SELECT) {
tc->data_len++;
+ }
- if (track->pat_flag & SELECT)
+ if (track->pat_flag & SELECT) {
tc->data_len += 4;
+ }
- if (track->search_flag & SELECT)
+ if (track->search_flag & SELECT) {
tc->data_len += 2;
+ }
}
track = track->next;
@@ -7692,8 +7940,9 @@ static void createTransTrackingTracksData(bContext *C, TransInfo *t)
}
}
- if (tc->data_len == 0)
+ if (tc->data_len == 0) {
return;
+ }
td = tc->data = MEM_callocN(tc->data_len * sizeof(TransData), "TransTracking TransData");
td2d = tc->data_2d = MEM_callocN(tc->data_len * sizeof(TransData2D),
@@ -7821,22 +8070,26 @@ static void createTransTrackingCurvesData(bContext *C, TransInfo *t)
marker = &track->markers[i];
prev_marker = &track->markers[i - 1];
- if ((marker->flag & MARKER_DISABLED) || (prev_marker->flag & MARKER_DISABLED))
+ if ((marker->flag & MARKER_DISABLED) || (prev_marker->flag & MARKER_DISABLED)) {
continue;
+ }
- if (marker->flag & MARKER_GRAPH_SEL_X)
+ if (marker->flag & MARKER_GRAPH_SEL_X) {
tc->data_len += 1;
+ }
- if (marker->flag & MARKER_GRAPH_SEL_Y)
+ if (marker->flag & MARKER_GRAPH_SEL_Y) {
tc->data_len += 1;
+ }
}
}
track = track->next;
}
- if (tc->data_len == 0)
+ if (tc->data_len == 0) {
return;
+ }
td = tc->data = MEM_callocN(tc->data_len * sizeof(TransData), "TransTracking TransData");
td2d = tc->data_2d = MEM_callocN(tc->data_len * sizeof(TransData2D),
@@ -7853,8 +8106,9 @@ static void createTransTrackingCurvesData(bContext *C, TransInfo *t)
marker = &track->markers[i];
prev_marker = &track->markers[i - 1];
- if ((marker->flag & MARKER_DISABLED) || (prev_marker->flag & MARKER_DISABLED))
+ if ((marker->flag & MARKER_DISABLED) || (prev_marker->flag & MARKER_DISABLED)) {
continue;
+ }
if (marker->flag & MARKER_GRAPH_SEL_X) {
markerToTransCurveDataInit(
@@ -7890,13 +8144,15 @@ static void createTransTrackingData(bContext *C, TransInfo *t)
tc->data_len = 0;
- if (!clip)
+ if (!clip) {
return;
+ }
BKE_movieclip_get_size(clip, &sc->user, &width, &height);
- if (width == 0 || height == 0)
+ if (width == 0 || height == 0) {
return;
+ }
if (ar->regiontype == RGN_TYPE_PREVIEW) {
/* transformation was called from graph editor */
@@ -7924,14 +8180,17 @@ static void cancelTransTracking(TransInfo *t)
marker->flag = tdt->flag;
- if (track->flag & SELECT)
+ if (track->flag & SELECT) {
i++;
+ }
- if (track->pat_flag & SELECT)
+ if (track->pat_flag & SELECT) {
i += 4;
+ }
- if (track->search_flag & SELECT)
+ if (track->search_flag & SELECT) {
i += 2;
+ }
}
else if (tdt->mode == transDataTracking_ModeCurves) {
MovieTrackingTrack *track = tdt->track;
@@ -7942,8 +8201,9 @@ static void cancelTransTracking(TransInfo *t)
marker = &track->markers[a];
prev_marker = &track->markers[a - 1];
- if ((marker->flag & MARKER_DISABLED) || (prev_marker->flag & MARKER_DISABLED))
+ if ((marker->flag & MARKER_DISABLED) || (prev_marker->flag & MARKER_DISABLED)) {
continue;
+ }
if (marker->flag & (MARKER_GRAPH_SEL_X | MARKER_GRAPH_SEL_Y)) {
marker->flag = tdt->flag;
@@ -7969,8 +8229,9 @@ void flushTransTracking(TransInfo *t)
TransDataTracking *tdt;
int a;
- if (t->state == TRANS_CANCEL)
+ if (t->state == TRANS_CANCEL) {
cancelTransTracking(t);
+ }
TransDataContainer *tc = TRANS_DATA_CONTAINER_FIRST_SINGLE(t);
@@ -7989,8 +8250,9 @@ void flushTransTracking(TransInfo *t)
if (t->flag & T_ALT_TRANSFORM) {
if (t->mode == TFM_RESIZE) {
- if (tdt->area != TRACK_AREA_PAT)
+ if (tdt->area != TRACK_AREA_PAT) {
continue;
+ }
}
else if (t->mode == TFM_TRANSLATION) {
if (tdt->area == TRACK_AREA_POINT && tdt->relative) {
@@ -7999,8 +8261,9 @@ void flushTransTracking(TransInfo *t)
if (!tdt->smarkers) {
tdt->smarkers = MEM_callocN(sizeof(*tdt->smarkers) * tdt->markersnr,
"flushTransTracking markers");
- for (a = 0; a < tdt->markersnr; a++)
+ for (a = 0; a < tdt->markersnr; a++) {
copy_v2_v2(tdt->smarkers[a], tdt->markers[a].pos);
+ }
}
sub_v2_v2v2(d, loc2d, tdt->soffset);
@@ -8008,8 +8271,9 @@ void flushTransTracking(TransInfo *t)
sub_v2_v2v2(d2, loc2d, tdt->srelative);
- for (a = 0; a < tdt->markersnr; a++)
+ for (a = 0; a < tdt->markersnr; a++) {
add_v2_v2v2(tdt->markers[a].pos, tdt->smarkers[a], d2);
+ }
negate_v2_v2(td2d->loc2d, d);
}
@@ -8020,8 +8284,9 @@ void flushTransTracking(TransInfo *t)
td2d->loc2d[0] = loc2d[0];
td2d->loc2d[1] = loc2d[1];
- if (tdt->relative)
+ if (tdt->relative) {
sub_v2_v2(td2d->loc2d, tdt->relative);
+ }
}
}
else if (tdt->mode == transDataTracking_ModeCurves) {
@@ -8268,8 +8533,9 @@ static void createTransMaskingData(bContext *C, TransInfo *t)
tc->data_len = 0;
- if (!mask)
+ if (!mask) {
return;
+ }
if (t->spacetype == SPACE_CLIP) {
SpaceClip *sc = t->sa->spacedata.first;
@@ -8313,8 +8579,9 @@ static void createTransMaskingData(bContext *C, TransInfo *t)
}
}
- if (is_prop_edit)
+ if (is_prop_edit) {
count += 3;
+ }
}
}
}
@@ -8526,8 +8793,9 @@ static void createTransPaintCurveVerts(bContext *C, TransInfo *t)
tc->data_len = 0;
- if (!paint || !paint->brush || !paint->brush->paint_curve)
+ if (!paint || !paint->brush || !paint->brush->paint_curve) {
return;
+ }
br = paint->brush;
pc = br->paint_curve;
@@ -8539,16 +8807,19 @@ static void createTransPaintCurveVerts(bContext *C, TransInfo *t)
continue;
}
else {
- if (pcp->bez.f1 & SELECT)
+ if (pcp->bez.f1 & SELECT) {
total++;
- if (pcp->bez.f3 & SELECT)
+ }
+ if (pcp->bez.f3 & SELECT) {
total++;
+ }
}
}
}
- if (!total)
+ if (!total) {
return;
+ }
tc->data_len = total;
td2d = tc->data_2d = MEM_callocN(tc->data_len * sizeof(TransData2D), "TransData2D");
@@ -8646,8 +8917,9 @@ static void createTransGPencil(bContext *C, TransInfo *t)
*/
tc->data_len = 0;
- if (gpd == NULL)
+ if (gpd == NULL) {
return;
+ }
/* initialize falloff curve */
if (is_multiedit) {
@@ -8683,8 +8955,9 @@ static void createTransGPencil(bContext *C, TransInfo *t)
/* Proportional Editing... */
if (is_prop_edit_connected) {
/* connected only - so only if selected */
- if (gps->flag & GP_STROKE_SELECT)
+ if (gps->flag & GP_STROKE_SELECT) {
tc->data_len += gps->totpoints;
+ }
}
else {
/* everything goes - connection status doesn't matter */
@@ -8699,8 +8972,9 @@ static void createTransGPencil(bContext *C, TransInfo *t)
// TODO: 2D vs 3D?
for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
- if (pt->flag & GP_SPOINT_SELECT)
+ if (pt->flag & GP_SPOINT_SELECT) {
tc->data_len++;
+ }
}
}
}
diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c
index 09593a44a54..e816f4b31ff 100644
--- a/source/blender/editors/transform/transform_generics.c
+++ b/source/blender/editors/transform/transform_generics.c
@@ -167,13 +167,16 @@ static void clipMirrorModifier(TransInfo *t)
int clip;
float loc[3], iloc[3];
- if (td->flag & TD_NOACTION)
+ if (td->flag & TD_NOACTION) {
break;
- if (td->loc == NULL)
+ }
+ if (td->loc == NULL) {
break;
+ }
- if (td->flag & TD_SKIP)
+ if (td->flag & TD_SKIP) {
continue;
+ }
copy_v3_v3(loc, td->loc);
copy_v3_v3(iloc, td->iloc);
@@ -227,12 +230,15 @@ static void editbmesh_apply_to_mirror(TransInfo *t)
int i;
for (i = 0; i < tc->data_len; i++, td++) {
- if (td->flag & TD_NOACTION)
+ if (td->flag & TD_NOACTION) {
break;
- if (td->loc == NULL)
+ }
+ if (td->loc == NULL) {
break;
- if (td->flag & TD_SKIP)
+ }
+ if (td->flag & TD_SKIP) {
continue;
+ }
eve = td->extra;
if (eve) {
@@ -255,8 +261,9 @@ static void animrecord_check_state(Scene *scene, ID *id, wmTimer *animtimer)
ScreenAnimData *sad = (animtimer) ? animtimer->customdata : NULL;
/* sanity checks */
- if (ELEM(NULL, scene, id, sad))
+ if (ELEM(NULL, scene, id, sad)) {
return;
+ }
/* check if we need a new strip if:
* - if animtimer is running
@@ -329,12 +336,14 @@ static bool fcu_test_selected(FCurve *fcu)
BezTriple *bezt = fcu->bezt;
unsigned int i;
- if (bezt == NULL) /* ignore baked */
+ if (bezt == NULL) { /* ignore baked */
return 0;
+ }
for (i = 0; i < fcu->totvert; i++, bezt++) {
- if (BEZT_ISSEL_ANY(bezt))
+ if (BEZT_ISSEL_ANY(bezt)) {
return 1;
+ }
}
return 0;
@@ -430,25 +439,30 @@ static void recalcData_graphedit(TransInfo *t)
FCurve *fcu = (FCurve *)ale->key_data;
/* ignore FC-Curves without any selected verts */
- if (!fcu_test_selected(fcu))
+ if (!fcu_test_selected(fcu)) {
continue;
+ }
/* watch it: if the time is wrong: do not correct handles yet */
- if (test_time_fcurve(fcu))
+ if (test_time_fcurve(fcu)) {
dosort++;
- else
+ }
+ else {
calchandles_fcurve(fcu);
+ }
/* set refresh tags for objects using this animation,
* BUT only if realtime updates are enabled
*/
- if ((sipo->flag & SIPO_NOREALTIMEUPDATES) == 0)
+ if ((sipo->flag & SIPO_NOREALTIMEUPDATES) == 0) {
ANIM_list_elem_update(CTX_data_main(t->context), t->scene, ale);
+ }
}
/* do resort and other updates? */
- if (dosort)
+ if (dosort) {
remake_graph_transdata(t, &anim_data);
+ }
/* now free temp channels */
ANIM_animdata_freelist(&anim_data);
@@ -476,14 +490,16 @@ static void recalcData_nla(TransInfo *t)
int delta_y1, delta_y2;
/* if this tdn has no handles, that means it is just a dummy that should be skipped */
- if (tdn->handle == 0)
+ if (tdn->handle == 0) {
continue;
+ }
/* set refresh tags for objects using this animation,
* BUT only if realtime updates are enabled
*/
- if ((snla->flag & SNLA_NOREALTIMEUPDATES) == 0)
+ if ((snla->flag & SNLA_NOREALTIMEUPDATES) == 0) {
ANIM_id_update(CTX_data_main(t->context), tdn->id);
+ }
/* if canceling transform, just write the values without validating, then move on */
if (t->state == TRANS_CANCEL) {
@@ -494,14 +510,16 @@ static void recalcData_nla(TransInfo *t)
/* start */
strip->start = tdn->h1[0];
- if ((strip->prev) && (strip->prev->type == NLASTRIP_TYPE_TRANSITION))
+ if ((strip->prev) && (strip->prev->type == NLASTRIP_TYPE_TRANSITION)) {
strip->prev->end = tdn->h1[0];
+ }
/* end */
strip->end = tdn->h2[0];
- if ((strip->next) && (strip->next->type == NLASTRIP_TYPE_TRANSITION))
+ if ((strip->next) && (strip->next->type == NLASTRIP_TYPE_TRANSITION)) {
strip->next->start = tdn->h2[0];
+ }
/* flush transforms to child strips (since this should be a meta) */
BKE_nlameta_flush_transforms(strip);
@@ -557,8 +575,9 @@ static void recalcData_nla(TransInfo *t)
tdn->h1[0] += offset;
tdn->h2[0] += offset;
}
- else /* all is fine and well */
+ else { /* all is fine and well */
break;
+ }
}
/* handle auto-snapping
@@ -649,8 +668,9 @@ static void recalcData_nla(TransInfo *t)
tdn->nlt = track;
tdn->trackIndex++;
}
- else /* can't move any further */
+ else { /* can't move any further */
break;
+ }
}
}
else {
@@ -667,8 +687,9 @@ static void recalcData_nla(TransInfo *t)
tdn->nlt = track;
tdn->trackIndex--;
}
- else /* can't move any further */
+ else { /* can't move any further */
break;
+ }
}
}
}
@@ -697,8 +718,9 @@ static void recalcData_image(TransInfo *t)
SpaceImage *sima = t->sa->spacedata.first;
flushTransUVs(t);
- if (sima->flag & SI_LIVE_UNWRAP)
+ if (sima->flag & SI_LIVE_UNWRAP) {
ED_uvedit_live_unwrap_re_solve();
+ }
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
if (tc->data_len) {
@@ -727,20 +749,25 @@ static void recalcData_spaceclip(TransInfo *t)
MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr);
if (t->mode == TFM_TRANSLATION) {
- if (TRACK_AREA_SELECTED(track, TRACK_AREA_PAT))
+ if (TRACK_AREA_SELECTED(track, TRACK_AREA_PAT)) {
BKE_tracking_marker_clamp(marker, CLAMP_PAT_POS);
- if (TRACK_AREA_SELECTED(track, TRACK_AREA_SEARCH))
+ }
+ if (TRACK_AREA_SELECTED(track, TRACK_AREA_SEARCH)) {
BKE_tracking_marker_clamp(marker, CLAMP_SEARCH_POS);
+ }
}
else if (t->mode == TFM_RESIZE) {
- if (TRACK_AREA_SELECTED(track, TRACK_AREA_PAT))
+ if (TRACK_AREA_SELECTED(track, TRACK_AREA_PAT)) {
BKE_tracking_marker_clamp(marker, CLAMP_PAT_DIM);
- if (TRACK_AREA_SELECTED(track, TRACK_AREA_SEARCH))
+ }
+ if (TRACK_AREA_SELECTED(track, TRACK_AREA_SEARCH)) {
BKE_tracking_marker_clamp(marker, CLAMP_SEARCH_DIM);
+ }
}
else if (t->mode == TFM_ROTATION) {
- if (TRACK_AREA_SELECTED(track, TRACK_AREA_PAT))
+ if (TRACK_AREA_SELECTED(track, TRACK_AREA_PAT)) {
BKE_tracking_marker_clamp(marker, CLAMP_PAT_POS);
+ }
}
}
@@ -851,14 +878,16 @@ static void recalcData_objects(TransInfo *t)
/* If this bone has a parent tip that has been moved */
if (ebo_parent->flag & BONE_TIPSEL) {
copy_v3_v3(ebo->head, ebo_parent->tail);
- if (t->mode == TFM_BONE_ENVELOPE)
+ if (t->mode == TFM_BONE_ENVELOPE) {
ebo->rad_head = ebo_parent->rad_tail;
+ }
}
/* If this bone has a parent tip that has NOT been moved */
else {
copy_v3_v3(ebo_parent->tail, ebo->head);
- if (t->mode == TFM_BONE_ENVELOPE)
+ if (t->mode == TFM_BONE_ENVELOPE) {
ebo_parent->rad_tail = ebo->rad_head;
+ }
}
}
@@ -869,8 +898,9 @@ static void recalcData_objects(TransInfo *t)
ebo->rad_tail = 0.10f * ebo->length;
ebo->dist = 0.25f * ebo->length;
if (ebo->parent) {
- if (ebo->rad_head > ebo->parent->rad_tail)
+ if (ebo->rad_head > ebo->parent->rad_tail) {
ebo->rad_head = ebo->parent->rad_tail;
+ }
}
}
else if (t->mode != TFM_BONE_ENVELOPE) {
@@ -1005,11 +1035,13 @@ static void recalcData_objects(TransInfo *t)
for (int i = 0; i < tc->data_len; i++, td++) {
Object *ob = td->ob;
- if (td->flag & TD_NOACTION)
+ if (td->flag & TD_NOACTION) {
break;
+ }
- if (td->flag & TD_SKIP)
+ if (td->flag & TD_SKIP) {
continue;
+ }
/* if animtimer is running, and the object already has animation data,
* check if the auto-record feature means that we should record 'samples'
@@ -1029,8 +1061,9 @@ static void recalcData_objects(TransInfo *t)
*/
DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM);
- if (t->flag & T_TEXTURE)
+ if (t->flag & T_TEXTURE) {
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
+ }
}
}
@@ -1513,10 +1546,12 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
t->view = &ar->v2d;
t->around = sclip->around;
- if (ED_space_clip_check_show_trackedit(sclip))
+ if (ED_space_clip_check_show_trackedit(sclip)) {
t->options |= CTX_MOVIECLIP;
- else if (ED_space_clip_check_show_maskedit(sclip))
+ }
+ else if (ED_space_clip_check_show_maskedit(sclip)) {
t->options |= CTX_MASK;
+ }
}
else {
if (ar) {
@@ -1724,14 +1759,18 @@ void freeTransCustomDataForMode(TransInfo *t)
/* Here I would suggest only TransInfo related issues, like free data & reset vars. Not redraws */
void postTrans(bContext *C, TransInfo *t)
{
- if (t->draw_handle_view)
+ if (t->draw_handle_view) {
ED_region_draw_cb_exit(t->ar->type, t->draw_handle_view);
- if (t->draw_handle_apply)
+ }
+ if (t->draw_handle_apply) {
ED_region_draw_cb_exit(t->ar->type, t->draw_handle_apply);
- if (t->draw_handle_pixel)
+ }
+ if (t->draw_handle_pixel) {
ED_region_draw_cb_exit(t->ar->type, t->draw_handle_pixel);
- if (t->draw_handle_cursor)
+ }
+ if (t->draw_handle_cursor) {
WM_paint_cursor_end(CTX_wm_manager(C), t->draw_handle_cursor);
+ }
if (t->flag & T_MODAL_CURSOR_SET) {
WM_cursor_modal_restore(CTX_wm_window(C));
@@ -1773,8 +1812,9 @@ void postTrans(bContext *C, TransInfo *t)
}
else {
SpaceImage *sima = t->sa->spacedata.first;
- if (sima->flag & SI_LIVE_UNWRAP)
+ if (sima->flag & SI_LIVE_UNWRAP) {
ED_uvedit_live_unwrap_end(t->state == TRANS_CANCEL);
+ }
}
}
else if (t->spacetype == SPACE_VIEW3D) {
@@ -2085,12 +2125,15 @@ static void calculateCenter_FromAround(TransInfo *t, int around, float r_center[
calculateCenterMedian(t, r_center);
break;
case V3D_AROUND_CURSOR:
- if (ELEM(t->spacetype, SPACE_IMAGE, SPACE_CLIP))
+ if (ELEM(t->spacetype, SPACE_IMAGE, SPACE_CLIP)) {
calculateCenterCursor2D(t, r_center);
- else if (t->spacetype == SPACE_GRAPH)
+ }
+ else if (t->spacetype == SPACE_GRAPH) {
calculateCenterCursorGraph2D(t, r_center);
- else
+ }
+ else {
calculateCenterCursor(t, r_center);
+ }
break;
case V3D_AROUND_LOCAL_ORIGINS:
/* Individual element center uses median center for helpline and such */
@@ -2222,18 +2265,21 @@ void calculatePropRatio(TransInfo *t)
/* Use rdist for falloff calculations, it is the real distance */
td->flag &= ~TD_NOACTION;
- if (connected)
+ if (connected) {
dist = (t->prop_size - td->dist) / t->prop_size;
- else
+ }
+ else {
dist = (t->prop_size - td->rdist) / t->prop_size;
+ }
/*
* Clamp to positive numbers.
* Certain corner cases with connectivity and individual centers
* can give values of rdist larger than propsize.
*/
- if (dist < 0.0f)
+ if (dist < 0.0f) {
dist = 0.0f;
+ }
switch (t->prop_mode) {
case PROP_SHARP:
diff --git a/source/blender/editors/transform/transform_gizmo_2d.c b/source/blender/editors/transform/transform_gizmo_2d.c
index f5b8f19ed02..1015b47c304 100644
--- a/source/blender/editors/transform/transform_gizmo_2d.c
+++ b/source/blender/editors/transform/transform_gizmo_2d.c
@@ -231,8 +231,9 @@ void ED_widgetgroup_gizmo2d_setup(const bContext *UNUSED(C), wmGizmoGroup *gzgro
PointerRNA *ptr = WM_gizmo_operator_set(axis, 0, ot_translate, NULL);
bool constraint[3] = {0};
constraint[(axis_idx + 1) % 2] = 1;
- if (RNA_struct_find_property(ptr, "constraint_axis"))
+ if (RNA_struct_find_property(ptr, "constraint_axis")) {
RNA_boolean_set_array(ptr, "constraint_axis", constraint);
+ }
RNA_boolean_set(ptr, "release_confirm", 1);
}
MAN2D_ITER_AXES_END;
@@ -385,8 +386,9 @@ bool ED_widgetgroup_gizmo2d_poll(const bContext *C, wmGizmoGroupType *UNUSED(gzg
/* check if there's a selected poly */
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!uvedit_face_visible_test(scene, obedit, ima, efa))
+ if (!uvedit_face_visible_test(scene, obedit, ima, efa)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) {
diff --git a/source/blender/editors/transform/transform_gizmo_3d.c b/source/blender/editors/transform/transform_gizmo_3d.c
index 58762a933c9..50610f1b3da 100644
--- a/source/blender/editors/transform/transform_gizmo_3d.c
+++ b/source/blender/editors/transform/transform_gizmo_3d.c
@@ -485,26 +485,35 @@ static void calc_tw_center_with_matrix(struct TransformBounds *tbounds,
static void protectflag_to_drawflags(short protectflag, short *drawflags)
{
- if (protectflag & OB_LOCK_LOCX)
+ if (protectflag & OB_LOCK_LOCX) {
*drawflags &= ~MAN_TRANS_X;
- if (protectflag & OB_LOCK_LOCY)
+ }
+ if (protectflag & OB_LOCK_LOCY) {
*drawflags &= ~MAN_TRANS_Y;
- if (protectflag & OB_LOCK_LOCZ)
+ }
+ if (protectflag & OB_LOCK_LOCZ) {
*drawflags &= ~MAN_TRANS_Z;
+ }
- if (protectflag & OB_LOCK_ROTX)
+ if (protectflag & OB_LOCK_ROTX) {
*drawflags &= ~MAN_ROT_X;
- if (protectflag & OB_LOCK_ROTY)
+ }
+ if (protectflag & OB_LOCK_ROTY) {
*drawflags &= ~MAN_ROT_Y;
- if (protectflag & OB_LOCK_ROTZ)
+ }
+ if (protectflag & OB_LOCK_ROTZ) {
*drawflags &= ~MAN_ROT_Z;
+ }
- if (protectflag & OB_LOCK_SCALEX)
+ if (protectflag & OB_LOCK_SCALEX) {
*drawflags &= ~MAN_SCALE_X;
- if (protectflag & OB_LOCK_SCALEY)
+ }
+ if (protectflag & OB_LOCK_SCALEY) {
*drawflags &= ~MAN_SCALE_Y;
- if (protectflag & OB_LOCK_SCALEZ)
+ }
+ if (protectflag & OB_LOCK_SCALEZ) {
*drawflags &= ~MAN_SCALE_Z;
+ }
}
/* for pose mode */
@@ -1055,8 +1064,9 @@ int ED_transform_calc_gizmo_stats(const bContext *C,
if (edit) {
point = edit->points;
for (a = 0; a < edit->totpoint; a++, point++) {
- if (point->flag & PEP_HIDE)
+ if (point->flag & PEP_HIDE) {
continue;
+ }
for (k = 0, ek = point->keys; k < point->totkey; k++, ek++) {
if (ek->flag & PEK_SELECT) {
@@ -1067,8 +1077,9 @@ int ED_transform_calc_gizmo_stats(const bContext *C,
}
/* selection center */
- if (totsel)
+ if (totsel) {
mul_v3_fl(tbounds->center, 1.0f / (float)totsel); // centroid!
+ }
}
}
else {
@@ -1076,8 +1087,9 @@ int ED_transform_calc_gizmo_stats(const bContext *C,
/* we need the one selected object, if its not active */
base = BASACT(view_layer);
ob = OBACT(view_layer);
- if (base && ((base->flag & BASE_SELECTED) == 0))
+ if (base && ((base->flag & BASE_SELECTED) == 0)) {
ob = NULL;
+ }
for (base = view_layer->object_bases.first; base; base = base->next) {
if (!BASE_SELECTED_EDITABLE(v3d, base)) {
diff --git a/source/blender/editors/transform/transform_input.c b/source/blender/editors/transform/transform_input.c
index 46f6e576cf4..6ebed88878f 100644
--- a/source/blender/editors/transform/transform_input.c
+++ b/source/blender/editors/transform/transform_input.c
@@ -223,8 +223,9 @@ static void InputAngle(TransInfo *UNUSED(t), MouseInput *mi, const double mval[2
float dphi;
dphi = saacos((float)deler);
- if ((dx1 * dy2 - dx2 * dy1) > 0.0)
+ if ((dx1 * dy2 - dx2 * dy1) > 0.0) {
dphi = -dphi;
+ }
/* If the angle is zero, because of lack of precision close to the 1.0 value in acos
* approximate the angle with the opposite side of the normalized triangle
@@ -244,8 +245,9 @@ static void InputAngle(TransInfo *UNUSED(t), MouseInput *mi, const double mval[2
dy = dy1 - dy2;
dphi = sqrt(dx * dx + dy * dy);
- if ((dx1 * dy2 - dx2 * dy1) > 0.0)
+ if ((dx1 * dy2 - dx2 * dy1) > 0.0) {
dphi = -dphi;
+ }
}
data->angle += ((double)dphi) * (mi->precision ? (double)mi->precision_factor : 1.0);
diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c
index 14d904fdc6d..b4c539fba8e 100644
--- a/source/blender/editors/transform/transform_ops.c
+++ b/source/blender/editors/transform/transform_ops.c
@@ -230,8 +230,9 @@ static bool delete_orientation_poll(bContext *C)
{
Scene *scene = CTX_data_scene(C);
- if (ED_operator_areaactive(C) == 0)
+ if (ED_operator_areaactive(C) == 0) {
return 0;
+ }
return ((scene->orientation_slots[SCE_ORIENT_DEFAULT].type >= V3D_ORIENT_CUSTOM) &&
(scene->orientation_slots[SCE_ORIENT_DEFAULT].index_custom != -1));
@@ -403,8 +404,9 @@ static int transform_modal(bContext *C, wmOperator *op, const wmEvent *event)
// in other words, 2D deltas are no longer good enough!
// disable until individual 'transformers' behave better
- if (event->type == NDOF_MOTION)
+ if (event->type == NDOF_MOTION) {
return OPERATOR_PASS_THROUGH;
+ }
#endif
/* XXX insert keys are called here, and require context */
diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c
index c0770392eff..e16579aba64 100644
--- a/source/blender/editors/transform/transform_orientations.c
+++ b/source/blender/editors/transform/transform_orientations.c
@@ -100,8 +100,9 @@ static TransformOrientation *createViewSpace(bContext *C,
RegionView3D *rv3d = CTX_wm_region_view3d(C);
float mat[3][3];
- if (!rv3d)
+ if (!rv3d) {
return NULL;
+ }
copy_m3_m4(mat, rv3d->viewinv);
normalize_m3(mat);
@@ -129,8 +130,9 @@ static TransformOrientation *createObjectSpace(bContext *C,
Object *ob;
float mat[3][3];
- if (base == NULL)
+ if (base == NULL) {
return NULL;
+ }
ob = base->object;
@@ -309,12 +311,15 @@ void BIF_createTransformOrientation(bContext *C,
Object *obedit = CTX_data_edit_object(C);
Object *ob = CTX_data_active_object(C);
if (obedit) {
- if (obedit->type == OB_MESH)
+ if (obedit->type == OB_MESH) {
ts = createMeshSpace(C, reports, name, overwrite);
- else if (obedit->type == OB_ARMATURE)
+ }
+ else if (obedit->type == OB_ARMATURE) {
ts = createBoneSpace(C, reports, name, overwrite);
- else if (obedit->type == OB_CURVE)
+ }
+ else if (obedit->type == OB_CURVE) {
ts = createCurveSpace(C, reports, name, overwrite);
+ }
}
else if (ob && (ob->mode & OB_MODE_POSE)) {
ts = createBoneSpace(C, reports, name, overwrite);
@@ -868,12 +873,15 @@ int getTransformOrientation_ex(const bContext *C,
#define SEL_F3 (1 << 2)
if (use_handle) {
- if (bezt->f1 & SELECT)
+ if (bezt->f1 & SELECT) {
flag |= SEL_F1;
- if (bezt->f2 & SELECT)
+ }
+ if (bezt->f2 & SELECT) {
flag |= SEL_F2;
- if (bezt->f3 & SELECT)
+ }
+ if (bezt->f3 & SELECT) {
flag |= SEL_F3;
+ }
}
else {
flag = (bezt->f2 & SELECT) ? (SEL_F1 | SEL_F2 | SEL_F3) : 0;
diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c
index da32908363a..e8bd8e905c9 100644
--- a/source/blender/editors/transform/transform_snap.c
+++ b/source/blender/editors/transform/transform_snap.c
@@ -152,8 +152,9 @@ void drawSnapping(const struct bContext *C, TransInfo *t)
{
unsigned char col[4], selectedCol[4], activeCol[4];
- if (!activeSnap(t))
+ if (!activeSnap(t)) {
return;
+ }
UI_GetThemeColor3ubv(TH_TRANSFORM, col);
col[3] = 128;
@@ -295,14 +296,17 @@ void applyProject(TransInfo *t)
float iloc[3], loc[3], no[3];
float mval_fl[2];
- if (td->flag & TD_NOACTION)
+ if (td->flag & TD_NOACTION) {
break;
+ }
- if (td->flag & TD_SKIP)
+ if (td->flag & TD_SKIP) {
continue;
+ }
- if ((t->flag & T_PROP_EDIT) && (td->factor == 0.0f))
+ if ((t->flag & T_PROP_EDIT) && (td->factor == 0.0f)) {
continue;
+ }
copy_v3_v3(iloc, td->loc);
if (tc->use_local_mat) {
@@ -368,12 +372,14 @@ void applyGridAbsolute(TransInfo *t)
GearsType grid_action;
int i;
- if (!(activeSnap(t) && (t->tsnap.mode & (SCE_SNAP_MODE_INCREMENT | SCE_SNAP_MODE_GRID))))
+ if (!(activeSnap(t) && (t->tsnap.mode & (SCE_SNAP_MODE_INCREMENT | SCE_SNAP_MODE_GRID)))) {
return;
+ }
grid_action = BIG_GEARS;
- if (t->modifiers & MOD_PRECISION)
+ if (t->modifiers & MOD_PRECISION) {
grid_action = SMALL_GEARS;
+ }
switch (grid_action) {
case NO_GEARS:
@@ -387,8 +393,9 @@ void applyGridAbsolute(TransInfo *t)
break;
}
/* early exit on unusable grid size */
- if (grid_size == 0.0f)
+ if (grid_size == 0.0f) {
return;
+ }
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td;
@@ -396,14 +403,17 @@ void applyGridAbsolute(TransInfo *t)
for (i = 0, td = tc->data; i < tc->data_len; i++, td++) {
float iloc[3], loc[3], tvec[3];
- if (td->flag & TD_NOACTION)
+ if (td->flag & TD_NOACTION) {
break;
+ }
- if (td->flag & TD_SKIP)
+ if (td->flag & TD_SKIP) {
continue;
+ }
- if ((t->flag & T_PROP_EDIT) && (td->factor == 0.0f))
+ if ((t->flag & T_PROP_EDIT) && (td->factor == 0.0f)) {
continue;
+ }
copy_v3_v3(iloc, td->loc);
if (tc->use_local_mat) {
@@ -541,8 +551,9 @@ static void initSnappingMode(TransInfo *t)
}
else {
/* force project off when not supported */
- if ((ts->snap_mode & SCE_SNAP_MODE_FACE) == 0)
+ if ((ts->snap_mode & SCE_SNAP_MODE_FACE) == 0) {
t->tsnap.project = 0;
+ }
t->tsnap.mode = ts->snap_mode;
}
@@ -851,10 +862,12 @@ static void ApplySnapTranslation(TransInfo *t, float vec[3])
if (t->spacetype == SPACE_NODE) {
char border = t->tsnap.snapNodeBorder;
- if (border & (NODE_LEFT | NODE_RIGHT))
+ if (border & (NODE_LEFT | NODE_RIGHT)) {
vec[0] = point[0] - t->tsnap.snapTarget[0];
- if (border & (NODE_BOTTOM | NODE_TOP))
+ }
+ if (border & (NODE_BOTTOM | NODE_TOP)) {
vec[1] = point[1] - t->tsnap.snapTarget[1];
+ }
}
else {
if (t->spacetype == SPACE_VIEW3D) {
@@ -921,10 +934,12 @@ static float RotationBetween(TransInfo *t, const float p1[3], const float p2[3])
cross_v3_v3v3(tmp, start, end);
- if (dot_v3v3(tmp, axis) < 0.0f)
+ if (dot_v3v3(tmp, axis) < 0.0f) {
angle = -acosf(dot_v3v3(start, end));
- else
+ }
+ else {
angle = acosf(dot_v3v3(start, end));
+ }
}
else {
float mtx[3][3];
@@ -1062,23 +1077,31 @@ static void TargetSnapOffset(TransInfo *t, TransData *td)
float height = BLI_rctf_size_y(&node->totr);
#ifdef USE_NODE_CENTER
- if (border & NODE_LEFT)
+ if (border & NODE_LEFT) {
t->tsnap.snapTarget[0] -= 0.5f * width;
- if (border & NODE_RIGHT)
+ }
+ if (border & NODE_RIGHT) {
t->tsnap.snapTarget[0] += 0.5f * width;
- if (border & NODE_BOTTOM)
+ }
+ if (border & NODE_BOTTOM) {
t->tsnap.snapTarget[1] -= 0.5f * height;
- if (border & NODE_TOP)
+ }
+ if (border & NODE_TOP) {
t->tsnap.snapTarget[1] += 0.5f * height;
+ }
#else
- if (border & NODE_LEFT)
+ if (border & NODE_LEFT) {
t->tsnap.snapTarget[0] -= 0.0f;
- if (border & NODE_RIGHT)
+ }
+ if (border & NODE_RIGHT) {
t->tsnap.snapTarget[0] += width;
- if (border & NODE_BOTTOM)
+ }
+ if (border & NODE_BOTTOM) {
t->tsnap.snapTarget[1] -= height;
- if (border & NODE_TOP)
+ }
+ if (border & NODE_TOP) {
t->tsnap.snapTarget[1] += 0.0f;
+ }
#endif
}
}
@@ -1502,8 +1525,9 @@ void snapSequenceBounds(TransInfo *t, const int mval[2])
int mframe;
TransSeq *ts = TRANS_DATA_CONTAINER_FIRST_SINGLE(t)->custom.type.data;
/* reuse increment, strictly speaking could be another snap mode, but leave as is */
- if (!(t->modifiers & MOD_SNAP_INVERT))
+ if (!(t->modifiers & MOD_SNAP_INVERT)) {
return;
+ }
/* convert to frame range */
UI_view2d_region_to_view(&t->ar->v2d, mval[0], mval[1], &xmouse, &ymouse);
@@ -1511,8 +1535,9 @@ void snapSequenceBounds(TransInfo *t, const int mval[2])
/* now find the closest sequence */
frame = BKE_sequencer_find_next_prev_edit(t->scene, mframe, SEQ_SIDE_BOTH, true, false, true);
- if (!ts->snap_left)
+ if (!ts->snap_left) {
frame = frame - (ts->max - ts->min);
+ }
t->values[0] = frame - ts->min;
}
diff --git a/source/blender/editors/transform/transform_snap_object.c b/source/blender/editors/transform/transform_snap_object.c
index 5d4867f5ef9..9174f6950ae 100644
--- a/source/blender/editors/transform/transform_snap_object.c
+++ b/source/blender/editors/transform/transform_snap_object.c
@@ -956,8 +956,9 @@ static void cb_mlooptri_edges_get(const int index, int v_index[3], const BVHTree
//printf("real edge found\n");
v_index[j] = mloop[lt->tri[j]].e;
}
- else
+ else {
v_index[j] = -1;
+ }
}
}
diff --git a/source/blender/editors/undo/ed_undo.c b/source/blender/editors/undo/ed_undo.c
index a574b353c16..49b5cada04a 100644
--- a/source/blender/editors/undo/ed_undo.c
+++ b/source/blender/editors/undo/ed_undo.c
@@ -483,8 +483,9 @@ int ED_undo_operator_repeat(bContext *C, wmOperator *op)
(WM_jobs_test(wm, scene, WM_JOB_TYPE_ANY) == 0)) {
int retval;
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("redo_cb: operator redo %s\n", op->type->name);
+ }
WM_operator_free_all_after(wm, op);
@@ -511,8 +512,9 @@ int ED_undo_operator_repeat(bContext *C, wmOperator *op)
retval = WM_operator_repeat(C, op);
if ((retval & OPERATOR_FINISHED) == 0) {
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("redo_cb: operator redo failed: %s, return %d\n", op->type->name, retval);
+ }
ED_undo_redo(C);
}
else {
diff --git a/source/blender/editors/util/ed_transverts.c b/source/blender/editors/util/ed_transverts.c
index 4cc74bec7d9..f054d09094d 100644
--- a/source/blender/editors/util/ed_transverts.c
+++ b/source/blender/editors/util/ed_transverts.c
@@ -74,8 +74,9 @@ void ED_transverts_update_obedit(TransVertStore *tvs, Object *obedit)
while (a--) {
if (bezt->hide == 0) {
bool skip_handle = false;
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
skip_handle = (mode & TM_SKIP_HANDLES) != 0;
+ }
if ((bezt->f1 & SELECT) && !skip_handle) {
BLI_assert(tv->loc == bezt->vec[0]);
@@ -131,8 +132,9 @@ void ED_transverts_update_obedit(TransVertStore *tvs, Object *obedit)
add_v3_v3(ebo->tail, diffvec);
a++;
- if (a < tvs->transverts_tot)
+ if (a < tvs->transverts_tot) {
tv++;
+ }
}
}
}
@@ -150,14 +152,16 @@ void ED_transverts_update_obedit(TransVertStore *tvs, Object *obedit)
}
}
}
- if (arm->flag & ARM_MIRROR_EDIT)
+ if (arm->flag & ARM_MIRROR_EDIT) {
ED_armature_edit_transform_mirror_update(obedit);
+ }
}
else if (obedit->type == OB_LATTICE) {
Lattice *lt = obedit->data;
- if (lt->editlatt->latt->flag & LT_OUTSIDE)
+ if (lt->editlatt->latt->flag & LT_OUTSIDE) {
outside_lattice(lt->editlatt->latt);
+ }
}
}
@@ -247,8 +251,9 @@ void ED_transverts_create_from_obedit(TransVertStore *tvs, Object *obedit, const
}
BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) {
- if (BM_elem_index_get(eve) == TM_INDEX_ON)
+ if (BM_elem_index_get(eve) == TM_INDEX_ON) {
tvs->transverts_tot++;
+ }
}
}
else {
@@ -270,8 +275,9 @@ void ED_transverts_create_from_obedit(TransVertStore *tvs, Object *obedit, const
}
BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) {
- if (BM_elem_index_get(eve) == TM_INDEX_ON)
+ if (BM_elem_index_get(eve) == TM_INDEX_ON) {
tvs->transverts_tot++;
+ }
}
}
/* for any of the 3 loops above which all dirty the indices */
@@ -363,10 +369,12 @@ void ED_transverts_create_from_obedit(TransVertStore *tvs, Object *obedit, const
ListBase *nurbs = BKE_curve_editNurbs_get(cu);
for (nu = nurbs->first; nu; nu = nu->next) {
- if (nu->type == CU_BEZIER)
+ if (nu->type == CU_BEZIER) {
totmalloc += 3 * nu->pntsu;
- else
+ }
+ else {
totmalloc += nu->pntsu * nu->pntsv;
+ }
}
tv = tvs->transverts = MEM_callocN(totmalloc * sizeof(TransVert), __func__);
@@ -378,8 +386,9 @@ void ED_transverts_create_from_obedit(TransVertStore *tvs, Object *obedit, const
while (a--) {
if (bezt->hide == 0) {
bool skip_handle = false;
- if (bezt->f2 & SELECT)
+ if (bezt->f2 & SELECT) {
skip_handle = (mode & TM_SKIP_HANDLES) != 0;
+ }
if ((bezt->f1 & SELECT) && !skip_handle) {
copy_v3_v3(tv->oldloc, bezt->vec[0]);
diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c
index ccaa0d68475..867271229e2 100644
--- a/source/blender/editors/util/ed_util.c
+++ b/source/blender/editors/util/ed_util.c
@@ -271,20 +271,24 @@ void apply_keyb_grid(
int shift, int ctrl, float *val, float fac1, float fac2, float fac3, int invert)
{
/* fac1 is for 'nothing', fac2 for CTRL, fac3 for SHIFT */
- if (invert)
+ if (invert) {
ctrl = !ctrl;
+ }
if (ctrl && shift) {
- if (fac3 != 0.0f)
+ if (fac3 != 0.0f) {
*val = fac3 * floorf(*val / fac3 + 0.5f);
+ }
}
else if (ctrl) {
- if (fac2 != 0.0f)
+ if (fac2 != 0.0f) {
*val = fac2 * floorf(*val / fac2 + 0.5f);
+ }
}
else {
- if (fac1 != 0.0f)
+ if (fac1 != 0.0f) {
*val = fac1 * floorf(*val / fac1 + 0.5f);
+ }
}
}
diff --git a/source/blender/editors/uvedit/uvedit_buttons.c b/source/blender/editors/uvedit/uvedit_buttons.c
index 16620436029..3983cce6769 100644
--- a/source/blender/editors/uvedit/uvedit_buttons.c
+++ b/source/blender/editors/uvedit/uvedit_buttons.c
@@ -69,8 +69,9 @@ static int uvedit_center(Scene *scene, Object *obedit, BMEditMesh *em, Image *im
zero_v2(center);
BM_ITER_MESH (f, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!uvedit_face_visible_test(scene, obedit, ima, f))
+ if (!uvedit_face_visible_test(scene, obedit, ima, f)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) {
@@ -100,8 +101,9 @@ static void uvedit_translate(
const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
BM_ITER_MESH (f, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!uvedit_face_visible_test(scene, obedit, ima, f))
+ if (!uvedit_face_visible_test(scene, obedit, ima, f)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) {
@@ -203,8 +205,9 @@ static void do_uvedit_vertex(bContext *C, void *UNUSED(arg), int event)
float center[2], delta[2];
int imx, imy;
- if (event != B_UVEDIT_VERTEX)
+ if (event != B_UVEDIT_VERTEX) {
return;
+ }
em = BKE_editmesh_from_object(obedit);
diff --git a/source/blender/editors/uvedit/uvedit_draw.c b/source/blender/editors/uvedit/uvedit_draw.c
index 5ff90097840..4fb2c6441a3 100644
--- a/source/blender/editors/uvedit/uvedit_draw.c
+++ b/source/blender/editors/uvedit/uvedit_draw.c
@@ -72,15 +72,19 @@ static int draw_uvs_face_check(const ToolSettings *ts)
{
/* checks if we are selecting only faces */
if (ts->uv_flag & UV_SYNC_SELECTION) {
- if (ts->selectmode == SCE_SELECT_FACE)
+ if (ts->selectmode == SCE_SELECT_FACE) {
return 2;
- else if (ts->selectmode & SCE_SELECT_FACE)
+ }
+ else if (ts->selectmode & SCE_SELECT_FACE) {
return 1;
- else
+ }
+ else {
return 0;
+ }
}
- else
+ else {
return (ts->uv_selectmode == UV_SELECT_FACE);
+ }
}
/* ------------------------- */
@@ -461,8 +465,9 @@ static void draw_uv_shadows_get(
{
*show_shadow = *show_texpaint = false;
- if (ED_space_image_show_render(sima) || (sima->flag & SI_NO_DRAW_TEXPAINT))
+ if (ED_space_image_show_render(sima) || (sima->flag & SI_NO_DRAW_TEXPAINT)) {
return;
+ }
if ((sima->mode == SI_MODE_PAINT) && obedit && obedit->type == OB_MESH) {
struct BMEditMesh *em = BKE_editmesh_from_object(obedit);
@@ -505,7 +510,8 @@ void ED_uvedit_draw_main(SpaceImage *sima,
draw_uvs_texpaint(scene, obact, depsgraph);
}
- if (show_uvedit && !(toolsettings->use_uv_sculpt))
+ if (show_uvedit && !(toolsettings->use_uv_sculpt)) {
ED_image_draw_cursor(ar, sima->cursor);
+ }
}
}
diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c
index ca527be7339..16a4b647cfe 100644
--- a/source/blender/editors/uvedit/uvedit_ops.c
+++ b/source/blender/editors/uvedit/uvedit_ops.c
@@ -114,11 +114,13 @@ bool ED_uvedit_test(Object *obedit)
BMEditMesh *em;
int ret;
- if (!obedit)
+ if (!obedit) {
return 0;
+ }
- if (obedit->type != OB_MESH)
+ if (obedit->type != OB_MESH) {
return 0;
+ }
em = BKE_editmesh_from_object(obedit);
ret = EDBM_uv_check(em);
@@ -142,8 +144,9 @@ static int UNUSED_FUNCTION(ED_operator_uvmap_mesh)(bContext *C)
if (ob && ob->type == OB_MESH) {
Mesh *me = ob->data;
- if (CustomData_get_layer(&me->fdata, CD_MTFACE) != NULL)
+ if (CustomData_get_layer(&me->fdata, CD_MTFACE) != NULL) {
return 1;
+ }
}
return 0;
@@ -172,8 +175,9 @@ bool ED_object_get_active_image(Object *ob,
bNode *node = (ntree) ? nodeGetActiveTexture(ntree) : NULL;
if (node && is_image_texture_node(node)) {
- if (r_ima)
+ if (r_ima) {
*r_ima = (Image *)node->id;
+ }
if (r_iuser) {
if (node->type == SH_NODE_TEX_IMAGE) {
*r_iuser = &((NodeTexImage *)node->storage)->iuser;
@@ -185,21 +189,27 @@ bool ED_object_get_active_image(Object *ob,
*r_iuser = NULL;
}
}
- if (r_node)
+ if (r_node) {
*r_node = node;
- if (r_ntree)
+ }
+ if (r_ntree) {
*r_ntree = ntree;
+ }
return true;
}
- if (r_ima)
+ if (r_ima) {
*r_ima = NULL;
- if (r_iuser)
+ }
+ if (r_iuser) {
*r_iuser = NULL;
- if (r_node)
+ }
+ if (r_node) {
*r_node = node;
- if (r_ntree)
+ }
+ if (r_ntree) {
*r_ntree = ntree;
+ }
return false;
}
@@ -263,10 +273,12 @@ static void uvedit_vertex_select_tagged(BMEditMesh *em,
bool uvedit_face_visible_nolocal_ex(const ToolSettings *ts, BMFace *efa)
{
- if (ts->uv_flag & UV_SYNC_SELECTION)
+ if (ts->uv_flag & UV_SYNC_SELECTION) {
return (BM_elem_flag_test(efa, BM_ELEM_HIDDEN) == 0);
- else
+ }
+ else {
return (BM_elem_flag_test(efa, BM_ELEM_HIDDEN) == 0 && BM_elem_flag_test(efa, BM_ELEM_SELECT));
+ }
}
bool uvedit_face_visible_nolocal(Scene *scene, BMFace *efa)
{
@@ -301,8 +313,9 @@ bool uvedit_face_select_test_ex(const ToolSettings *ts, BMFace *efa, const int c
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
- if (!(luv->flag & MLOOPUV_VERTSEL))
+ if (!(luv->flag & MLOOPUV_VERTSEL)) {
return false;
+ }
}
return true;
@@ -432,10 +445,12 @@ void uvedit_edge_select_enable(
ToolSettings *ts = scene->toolsettings;
if (ts->uv_flag & UV_SYNC_SELECTION) {
- if (ts->selectmode & SCE_SELECT_FACE)
+ if (ts->selectmode & SCE_SELECT_FACE) {
BM_face_select_set(em->bm, l->f, true);
- else if (ts->selectmode & SCE_SELECT_EDGE)
+ }
+ else if (ts->selectmode & SCE_SELECT_EDGE) {
BM_edge_select_set(em->bm, l->e, true);
+ }
else {
BM_vert_select_set(em->bm, l->e->v1, true);
BM_vert_select_set(em->bm, l->e->v2, true);
@@ -465,10 +480,12 @@ void uvedit_edge_select_disable(BMEditMesh *em,
ToolSettings *ts = scene->toolsettings;
if (ts->uv_flag & UV_SYNC_SELECTION) {
- if (ts->selectmode & SCE_SELECT_FACE)
+ if (ts->selectmode & SCE_SELECT_FACE) {
BM_face_select_set(em->bm, l->f, false);
- else if (ts->selectmode & SCE_SELECT_EDGE)
+ }
+ else if (ts->selectmode & SCE_SELECT_EDGE) {
BM_edge_select_set(em->bm, l->e, false);
+ }
else {
BM_vert_select_set(em->bm, l->e->v1, false);
BM_vert_select_set(em->bm, l->e->v2, false);
@@ -488,10 +505,12 @@ void uvedit_edge_select_disable(BMEditMesh *em,
bool uvedit_uv_select_test_ex(const ToolSettings *ts, BMLoop *l, const int cd_loop_uv_offset)
{
if (ts->uv_flag & UV_SYNC_SELECTION) {
- if (ts->selectmode & SCE_SELECT_FACE)
+ if (ts->selectmode & SCE_SELECT_FACE) {
return BM_elem_flag_test_bool(l->f, BM_ELEM_SELECT);
- else
+ }
+ else {
return BM_elem_flag_test_bool(l->v, BM_ELEM_SELECT);
+ }
}
else {
MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
@@ -524,10 +543,12 @@ void uvedit_uv_select_enable(
ToolSettings *ts = scene->toolsettings;
if (ts->uv_flag & UV_SYNC_SELECTION) {
- if (ts->selectmode & SCE_SELECT_FACE)
+ if (ts->selectmode & SCE_SELECT_FACE) {
BM_face_select_set(em->bm, l->f, true);
- else
+ }
+ else {
BM_vert_select_set(em->bm, l->v, true);
+ }
if (do_history) {
BM_select_history_remove(em->bm, (BMElem *)l->v);
@@ -544,10 +565,12 @@ void uvedit_uv_select_disable(BMEditMesh *em, Scene *scene, BMLoop *l, const int
ToolSettings *ts = scene->toolsettings;
if (ts->uv_flag & UV_SYNC_SELECTION) {
- if (ts->selectmode & SCE_SELECT_FACE)
+ if (ts->selectmode & SCE_SELECT_FACE) {
BM_face_select_set(em->bm, l->f, false);
- else
+ }
+ else {
BM_vert_select_set(em->bm, l->v, false);
+ }
}
else {
MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
@@ -623,8 +646,9 @@ bool ED_uvedit_minmax_multi(Scene *scene,
const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!uvedit_face_visible_test(scene, obedit, ima, efa))
+ if (!uvedit_face_visible_test(scene, obedit, ima, efa)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) {
@@ -679,8 +703,9 @@ static bool ED_uvedit_median_multi(
const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!uvedit_face_visible_test(scene, obedit, ima, efa))
+ if (!uvedit_face_visible_test(scene, obedit, ima, efa)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
@@ -1022,14 +1047,16 @@ static void uv_select_edgeloop_vertex_loop_flag(UvMapVert *first)
int count = 0;
for (iterv = first; iterv; iterv = iterv->next) {
- if (iterv->separate && iterv != first)
+ if (iterv->separate && iterv != first) {
break;
+ }
count++;
}
- if (count < 5)
+ if (count < 5) {
first->flag = 1;
+ }
}
static UvMapVert *uv_select_edgeloop_vertex_map_get(UvVertMap *vmap, BMFace *efa, BMLoop *l)
@@ -1038,10 +1065,12 @@ static UvMapVert *uv_select_edgeloop_vertex_map_get(UvVertMap *vmap, BMFace *efa
first = BM_uv_vert_map_at_index(vmap, BM_elem_index_get(l->v));
for (iterv = first; iterv; iterv = iterv->next) {
- if (iterv->separate)
+ if (iterv->separate) {
first = iterv;
- if (iterv->poly_index == BM_elem_index_get(efa))
+ }
+ if (iterv->poly_index == BM_elem_index_get(efa)) {
return first;
+ }
}
return NULL;
@@ -1058,18 +1087,21 @@ static bool uv_select_edgeloop_edge_tag_faces(BMEditMesh *em,
/* count number of faces this edge has */
for (iterv1 = first1; iterv1; iterv1 = iterv1->next) {
- if (iterv1->separate && iterv1 != first1)
+ if (iterv1->separate && iterv1 != first1) {
break;
+ }
for (iterv2 = first2; iterv2; iterv2 = iterv2->next) {
- if (iterv2->separate && iterv2 != first2)
+ if (iterv2->separate && iterv2 != first2) {
break;
+ }
if (iterv1->poly_index == iterv2->poly_index) {
/* if face already tagged, don't do this edge */
efa = BM_face_at_index(em->bm, iterv1->poly_index);
- if (BM_elem_flag_test(efa, BM_ELEM_TAG))
+ if (BM_elem_flag_test(efa, BM_ELEM_TAG)) {
return false;
+ }
tot++;
break;
@@ -1077,19 +1109,23 @@ static bool uv_select_edgeloop_edge_tag_faces(BMEditMesh *em,
}
}
- if (*totface == 0) /* start edge */
+ if (*totface == 0) { /* start edge */
*totface = tot;
- else if (tot != *totface) /* check for same number of faces as start edge */
+ }
+ else if (tot != *totface) { /* check for same number of faces as start edge */
return false;
+ }
/* tag the faces */
for (iterv1 = first1; iterv1; iterv1 = iterv1->next) {
- if (iterv1->separate && iterv1 != first1)
+ if (iterv1->separate && iterv1 != first1) {
break;
+ }
for (iterv2 = first2; iterv2; iterv2 = iterv2->next) {
- if (iterv2->separate && iterv2 != first2)
+ if (iterv2->separate && iterv2 != first2) {
break;
+ }
if (iterv1->poly_index == iterv2->poly_index) {
efa = BM_face_at_index(em->bm, iterv1->poly_index);
@@ -1156,10 +1192,12 @@ static int uv_select_edgeloop(Scene *scene,
uvedit_face_visible_test(scene, obedit, ima, efa)) {
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
/* check face not hidden and not tagged */
- if (!(iterv_curr = uv_select_edgeloop_vertex_map_get(vmap, efa, l)))
+ if (!(iterv_curr = uv_select_edgeloop_vertex_map_get(vmap, efa, l))) {
continue;
- if (!(iterv_next = uv_select_edgeloop_vertex_map_get(vmap, efa, l->next)))
+ }
+ if (!(iterv_next = uv_select_edgeloop_vertex_map_get(vmap, efa, l->next))) {
continue;
+ }
/* check if vertex is tagged and has right valence */
if (iterv_curr->flag || iterv_next->flag) {
@@ -1253,8 +1291,9 @@ static void uv_select_linked_multi(Scene *scene,
* keeping island-select working as is. */
vmap = BM_uv_vert_map_create(em->bm, limit, !select_faces, false);
- if (vmap == NULL)
+ if (vmap == NULL) {
return;
+ }
stack = MEM_mallocN(sizeof(*stack) * (em->bm->totface + 1), "UvLinkStack");
flag = MEM_callocN(sizeof(*flag) * em->bm->totface, "UvLinkFlag");
@@ -1312,15 +1351,18 @@ static void uv_select_linked_multi(Scene *scene,
startv = vlist;
for (iterv = vlist; iterv; iterv = iterv->next) {
- if (iterv->separate)
+ if (iterv->separate) {
startv = iterv;
- if (iterv->poly_index == a)
+ }
+ if (iterv->poly_index == a) {
break;
+ }
}
for (iterv = startv; iterv; iterv = iterv->next) {
- if ((startv != iterv) && (iterv->separate))
+ if ((startv != iterv) && (iterv->separate)) {
break;
+ }
else if (!flag[iterv->poly_index]) {
flag[iterv->poly_index] = 1;
stack[stacksize] = iterv->poly_index;
@@ -1407,8 +1449,9 @@ static float *uv_sel_co_from_eve(
const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
BM_ITER_ELEM (l, &liter, eve, BM_LOOPS_OF_VERT) {
- if (!uvedit_face_visible_test(scene, obedit, ima, l->f))
+ if (!uvedit_face_visible_test(scene, obedit, ima, l->f)) {
continue;
+ }
if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) {
MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
@@ -1620,8 +1663,9 @@ static void uv_weld_align(bContext *C, eUVWeldAlign tool)
BMLoop *l;
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!uvedit_face_visible_test(scene, obedit, ima, efa))
+ if (!uvedit_face_visible_test(scene, obedit, ima, efa)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) {
@@ -1653,8 +1697,9 @@ static void uv_weld_align(bContext *C, eUVWeldAlign tool)
BMLoop *l;
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!uvedit_face_visible_test(scene, obedit, ima, efa))
+ if (!uvedit_face_visible_test(scene, obedit, ima, efa)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) {
@@ -1672,8 +1717,9 @@ static void uv_weld_align(bContext *C, eUVWeldAlign tool)
BMLoop *l;
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!uvedit_face_visible_test(scene, obedit, ima, efa))
+ if (!uvedit_face_visible_test(scene, obedit, ima, efa)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) {
@@ -1698,8 +1744,9 @@ static void uv_weld_align(bContext *C, eUVWeldAlign tool)
/* tag verts with a selected UV */
BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) {
BM_ITER_ELEM (l, &liter, eve, BM_LOOPS_OF_VERT) {
- if (!uvedit_face_visible_test(scene, obedit, ima, l->f))
+ if (!uvedit_face_visible_test(scene, obedit, ima, l->f)) {
continue;
+ }
if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) {
BM_elem_flag_enable(eve, BM_ELEM_TAG);
@@ -1775,23 +1822,28 @@ static void uv_weld_align(bContext *C, eUVWeldAlign tool)
eUVWeldAlign tool_local = tool;
if (tool_local == UV_STRAIGHTEN_X) {
- if (uv_start[1] == uv_end[1])
+ if (uv_start[1] == uv_end[1]) {
tool_local = UV_STRAIGHTEN;
- else
+ }
+ else {
a = (uv_end[0] - uv_start[0]) / (uv_end[1] - uv_start[1]);
+ }
}
else if (tool_local == UV_STRAIGHTEN_Y) {
- if (uv_start[0] == uv_end[0])
+ if (uv_start[0] == uv_end[0]) {
tool_local = UV_STRAIGHTEN;
- else
+ }
+ else {
a = (uv_end[1] - uv_start[1]) / (uv_end[0] - uv_start[0]);
+ }
}
/* go over all verts except for endpoints */
for (i = 0; i < BLI_array_len(eve_line); i++) {
BM_ITER_ELEM (l, &liter, eve_line[i], BM_LOOPS_OF_VERT) {
- if (!uvedit_face_visible_test(scene, obedit, ima, l->f))
+ if (!uvedit_face_visible_test(scene, obedit, ima, l->f)) {
continue;
+ }
if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) {
MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
@@ -1799,12 +1851,15 @@ static void uv_weld_align(bContext *C, eUVWeldAlign tool)
* new_y = (y2 - y1) / (x2 - x1) * (x - x1) + y1
* Maybe this should be a BLI func? Or is it already existing?
* Could use interp_v2_v2v2, but not sure it's worth it here...*/
- if (tool_local == UV_STRAIGHTEN_X)
+ if (tool_local == UV_STRAIGHTEN_X) {
luv->uv[0] = a * (luv->uv[1] - uv_start[1]) + uv_start[0];
- else if (tool_local == UV_STRAIGHTEN_Y)
+ }
+ else if (tool_local == UV_STRAIGHTEN_Y) {
luv->uv[1] = a * (luv->uv[0] - uv_start[0]) + uv_start[1];
- else
+ }
+ else {
closest_to_line_segment_v2(luv->uv, luv->uv, uv_start, uv_end);
+ }
changed = true;
}
}
@@ -2291,8 +2346,9 @@ static void uv_select_all_perform(Scene *scene, Image *ima, Object *obedit, int
}
else {
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!uvedit_face_visible_test(scene, obedit, ima, efa))
+ if (!uvedit_face_visible_test(scene, obedit, ima, efa)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
@@ -2381,17 +2437,20 @@ static bool uv_sticky_select(
/* this function test if some vertex needs to selected
* in addition to the existing ones due to sticky select */
- if (sticky == SI_STICKY_DISABLE)
+ if (sticky == SI_STICKY_DISABLE) {
return false;
+ }
for (i = 0; i < hitlen; i++) {
if (hitv[i] == v) {
if (sticky == SI_STICKY_LOC) {
- if (fabsf(hituv[i][0] - uv[0]) < limit[0] && fabsf(hituv[i][1] - uv[1]) < limit[1])
+ if (fabsf(hituv[i][0] - uv[0]) < limit[0] && fabsf(hituv[i][1] - uv[1]) < limit[1]) {
return true;
+ }
}
- else if (sticky == SI_STICKY_VERTEX)
+ else if (sticky == SI_STICKY_VERTEX) {
return true;
+ }
}
}
@@ -2436,12 +2495,15 @@ static int uv_mouse_select_multi(
if (ts->uv_flag & UV_SYNC_SELECTION) {
sync = 1;
- if (ts->selectmode & SCE_SELECT_FACE)
+ if (ts->selectmode & SCE_SELECT_FACE) {
selectmode = UV_SELECT_FACE;
- else if (ts->selectmode & SCE_SELECT_EDGE)
+ }
+ else if (ts->selectmode & SCE_SELECT_EDGE) {
selectmode = UV_SELECT_EDGE;
- else
+ }
+ else {
selectmode = UV_SELECT_VERTEX;
+ }
sticky = SI_STICKY_DISABLE;
}
@@ -2585,14 +2647,16 @@ static int uv_mouse_select_multi(
BM_mesh_elem_index_ensure(em->bm, BM_VERT);
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!uvedit_face_visible_test(scene, obedit, ima, efa))
+ if (!uvedit_face_visible_test(scene, obedit, ima, efa)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
if (uv_sticky_select(
- limit, hitv, BM_elem_index_get(l->v), hituv, luv->uv, sticky, hitlen))
+ limit, hitv, BM_elem_index_get(l->v), hituv, luv->uv, sticky, hitlen)) {
uvedit_uv_select_set(em, scene, l, select, false, cd_loop_uv_offset);
+ }
}
}
@@ -2621,17 +2685,20 @@ static int uv_mouse_select_multi(
/* select sticky uvs */
if (sticky != SI_STICKY_DISABLE) {
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!uvedit_face_visible_test(scene, obedit, ima, efa))
+ if (!uvedit_face_visible_test(scene, obedit, ima, efa)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
- if (sticky == SI_STICKY_DISABLE)
+ if (sticky == SI_STICKY_DISABLE) {
continue;
+ }
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
if (uv_sticky_select(
- limit, hitv, BM_elem_index_get(l->v), hituv, luv->uv, sticky, hitlen))
+ limit, hitv, BM_elem_index_get(l->v), hituv, luv->uv, sticky, hitlen)) {
uvedit_uv_select_enable(em, scene, l, false, cd_loop_uv_offset);
+ }
flush = 1;
}
@@ -3127,11 +3194,13 @@ static void uv_select_flush_from_tag_sticky_loc_internal(Scene *scene,
vlist_iter = BM_uv_vert_map_at_index(vmap, BM_elem_index_get(l->v));
while (vlist_iter) {
- if (vlist_iter->separate)
+ if (vlist_iter->separate) {
start_vlist = vlist_iter;
+ }
- if (efa_index == vlist_iter->poly_index)
+ if (efa_index == vlist_iter->poly_index) {
break;
+ }
vlist_iter = vlist_iter->next;
}
@@ -3139,8 +3208,9 @@ static void uv_select_flush_from_tag_sticky_loc_internal(Scene *scene,
vlist_iter = start_vlist;
while (vlist_iter) {
- if (vlist_iter != start_vlist && vlist_iter->separate)
+ if (vlist_iter != start_vlist && vlist_iter->separate) {
break;
+ }
if (efa_index != vlist_iter->poly_index) {
BMLoop *l_other;
@@ -3415,8 +3485,9 @@ static int uv_box_select_exec(bContext *C, wmOperator *op)
BM_mesh_elem_hflag_disable_all(em->bm, BM_VERT, BM_ELEM_TAG, false);
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!uvedit_face_visible_test(scene, obedit, ima, efa))
+ if (!uvedit_face_visible_test(scene, obedit, ima, efa)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
@@ -3826,8 +3897,9 @@ static int uv_snap_cursor_exec(bContext *C, wmOperator *op)
}
}
- if (!changed)
+ if (!changed) {
return OPERATOR_CANCELLED;
+ }
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_IMAGE, sima);
@@ -3875,8 +3947,9 @@ static bool uv_snap_uvs_to_cursor(Scene *scene, Image *ima, Object *obedit, cons
const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!uvedit_face_visible_test(scene, obedit, ima, efa))
+ if (!uvedit_face_visible_test(scene, obedit, ima, efa)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) {
@@ -3902,8 +3975,9 @@ static bool uv_snap_uvs_offset(Scene *scene, Image *ima, Object *obedit, const f
const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!uvedit_face_visible_test(scene, obedit, ima, efa))
+ if (!uvedit_face_visible_test(scene, obedit, ima, efa)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) {
@@ -3991,8 +4065,9 @@ static bool uv_snap_uvs_to_pixels(SpaceImage *sima, Scene *scene, Object *obedit
h = (float)height;
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!uvedit_face_visible_test(scene, obedit, ima, efa))
+ if (!uvedit_face_visible_test(scene, obedit, ima, efa)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) {
@@ -4329,8 +4404,9 @@ static int uv_hide_exec(bContext *C, wmOperator *op)
}
}
}
- if (!swap)
+ if (!swap) {
uvedit_face_select_disable(scene, em, efa, cd_loop_uv_offset);
+ }
}
}
else if (em->selectmode == SCE_SELECT_FACE) {
@@ -4345,8 +4421,9 @@ static int uv_hide_exec(bContext *C, wmOperator *op)
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
if (UV_SEL_TEST(luv, !swap)) {
BM_vert_select_set(em->bm, l->v, false);
- if (!swap)
+ if (!swap) {
luv->flag &= ~MLOOPUV_VERTSEL;
+ }
}
}
}
@@ -4354,8 +4431,9 @@ static int uv_hide_exec(bContext *C, wmOperator *op)
}
/* flush vertex selection changes */
- if (em->selectmode != SCE_SELECT_FACE)
+ if (em->selectmode != SCE_SELECT_FACE) {
EDBM_selectmode_flush_ex(em, SCE_SELECT_VERTEX | SCE_SELECT_EDGE);
+ }
BM_select_history_validate(em->bm);
@@ -4539,8 +4617,9 @@ static int uv_set_2d_cursor_exec(bContext *C, wmOperator *op)
{
SpaceImage *sima = CTX_wm_space_image(C);
- if (!sima)
+ if (!sima) {
return OPERATOR_CANCELLED;
+ }
RNA_float_get_array(op->ptr, "location", sima->cursor);
@@ -4650,20 +4729,23 @@ static int uv_seams_from_islands_exec(bContext *C, wmOperator *op)
UvMapVert *mv2cache = NULL, *mv2sep = NULL;
mvinit1 = vmap->vert[BM_elem_index_get(editedge->v1)];
- if (mark_seams)
+ if (mark_seams) {
BM_elem_flag_disable(editedge, BM_ELEM_SEAM);
+ }
for (mv1 = mvinit1; mv1 && !faces_separated; mv1 = mv1->next) {
- if (mv1->separate && commonFaces)
+ if (mv1->separate && commonFaces) {
v1coincident = 0;
+ }
separated2 = 0;
efa1 = BM_face_at_index(bm, mv1->poly_index);
mvinit2 = vmap->vert[BM_elem_index_get(editedge->v2)];
for (mv2 = mvinit2; mv2; mv2 = mv2->next) {
- if (mv2->separate)
+ if (mv2->separate) {
mv2sep = mv2;
+ }
efa2 = BM_face_at_index(bm, mv2->poly_index);
if (efa1 == efa2) {
@@ -4674,11 +4756,13 @@ static int uv_seams_from_islands_exec(bContext *C, wmOperator *op)
/* flag seam unless proved to be coincident with previous hit */
separated2 = 1;
for (mviter = mv2cache; mviter; mviter = mviter->next) {
- if (mviter->separate && mviter != mv2cache)
+ if (mviter->separate && mviter != mv2cache) {
break;
+ }
/* coincident with previous hit, do not flag seam */
- if (mviter == mv2)
+ if (mviter == mv2) {
separated2 = 0;
+ }
}
}
/* First hit case, store the hit in the cache */
@@ -4687,8 +4771,9 @@ static int uv_seams_from_islands_exec(bContext *C, wmOperator *op)
commonFaces = 1;
}
}
- else
+ else {
separated1 = 1;
+ }
if (separated1 || separated2) {
faces_separated = 1;
@@ -4699,10 +4784,12 @@ static int uv_seams_from_islands_exec(bContext *C, wmOperator *op)
}
if (faces_separated) {
- if (mark_seams)
+ if (mark_seams) {
BM_elem_flag_enable(editedge, BM_ELEM_SEAM);
- if (mark_sharp)
+ }
+ if (mark_sharp) {
BM_elem_flag_disable(editedge, BM_ELEM_SMOOTH);
+ }
}
}
diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.c b/source/blender/editors/uvedit/uvedit_parametrizer.c
index 913aacec4c8..10b2df48f2f 100644
--- a/source/blender/editors/uvedit/uvedit_parametrizer.c
+++ b/source/blender/editors/uvedit/uvedit_parametrizer.c
@@ -255,8 +255,9 @@ static PHash *phash_new(PHashLink **list, int sizehint)
ph->cursize_id = 0;
ph->list = list;
- while (PHashSizes[ph->cursize_id] < sizehint)
+ while (PHashSizes[ph->cursize_id] < sizehint) {
ph->cursize_id++;
+ }
ph->cursize = PHashSizes[ph->cursize_id];
ph->buckets = (PHashLink **)MEM_callocN(ph->cursize * sizeof(*ph->buckets), "PHashBuckets");
@@ -316,11 +317,14 @@ static PHashLink *phash_lookup(PHash *ph, PHashKey key)
PHashLink *link;
uintptr_t hash = PHASH_hash(ph, key);
- for (link = ph->buckets[hash]; link; link = link->next)
- if (link->key == key)
+ for (link = ph->buckets[hash]; link; link = link->next) {
+ if (link->key == key) {
return link;
- else if (PHASH_hash(ph, link->key) != hash)
+ }
+ else if (PHASH_hash(ph, link->key) != hash) {
return NULL;
+ }
+ }
return link;
}
@@ -329,11 +333,14 @@ static PHashLink *phash_next(PHash *ph, PHashKey key, PHashLink *link)
{
uintptr_t hash = PHASH_hash(ph, key);
- for (link = link->next; link; link = link->next)
- if (link->key == key)
+ for (link = link->next; link; link = link->next) {
+ if (link->key == key) {
return link;
- else if (PHASH_hash(ph, link->key) != hash)
+ }
+ else if (PHASH_hash(ph, link->key) != hash) {
return NULL;
+ }
+ }
return link;
}
@@ -362,12 +369,15 @@ static float p_vec_angle(float *v1, float *v2, float *v3)
{
float dot = p_vec_angle_cos(v1, v2, v3);
- if (dot <= -1.0f)
+ if (dot <= -1.0f) {
return (float)M_PI;
- else if (dot >= 1.0f)
+ }
+ else if (dot >= 1.0f) {
return 0.0f;
- else
+ }
+ else {
return acosf(dot);
+ }
}
static float p_vec2_angle(float *v1, float *v2, float *v3)
@@ -523,8 +533,9 @@ static PBool p_intersect_line_2d_dir(float *v1, float *dir1, float *v2, float *d
div = dir2[0] * dir1[1] - dir2[1] * dir1[0];
- if (div == 0.0f)
+ if (div == 0.0f) {
return P_FALSE;
+ }
lmbda = ((v1[1] - v2[1]) * dir1[0] - (v1[0] - v2[0]) * dir1[1]) / div;
isect[0] = v1[0] + lmbda * dir2[0];
@@ -645,8 +656,9 @@ static void p_vert_load_pin_select_uvs(PHandle *handle, PVert *v)
e = v->edge;
do {
if (e->orig_uv) {
- if (e->flag & PEDGE_SELECT)
+ if (e->flag & PEDGE_SELECT) {
v->flag |= PVERT_SELECT;
+ }
if (e->flag & PEDGE_PIN) {
pinuv[0] += e->orig_uv[0] * handle->aspx;
@@ -765,10 +777,12 @@ static PVert *p_vert_lookup(PHandle *handle, PHashKey key, const float co[3], PE
{
PVert *v = (PVert *)phash_lookup(handle->hash_verts, key);
- if (v)
+ if (v) {
return v;
- else
+ }
+ else {
return p_vert_add(handle, key, co, e);
+ }
}
static PVert *p_vert_copy(PChart *chart, PVert *v)
@@ -791,10 +805,12 @@ static PEdge *p_edge_lookup(PHandle *handle, PHashKey *vkeys)
PEdge *e = (PEdge *)phash_lookup(handle->hash_edges, key);
while (e) {
- if ((e->vert->u.key == vkeys[0]) && (e->next->vert->u.key == vkeys[1]))
+ if ((e->vert->u.key == vkeys[0]) && (e->next->vert->u.key == vkeys[1])) {
return e;
- else if ((e->vert->u.key == vkeys[1]) && (e->next->vert->u.key == vkeys[0]))
+ }
+ else if ((e->vert->u.key == vkeys[1]) && (e->next->vert->u.key == vkeys[0])) {
return e;
+ }
e = (PEdge *)phash_next(handle->hash_edges, key, (PHashLink *)e);
}
@@ -811,12 +827,14 @@ static int p_face_exists(ParamHandle *phandle, ParamKey *pvkeys, int i1, int i2,
while (e) {
if ((e->vert->u.key == vkeys[i1]) && (e->next->vert->u.key == vkeys[i2])) {
- if (e->next->next->vert->u.key == vkeys[i3])
+ if (e->next->next->vert->u.key == vkeys[i3]) {
return P_TRUE;
+ }
}
else if ((e->vert->u.key == vkeys[i2]) && (e->next->vert->u.key == vkeys[i1])) {
- if (e->next->next->vert->u.key == vkeys[i3])
+ if (e->next->next->vert->u.key == vkeys[i3]) {
return P_TRUE;
+ }
}
e = (PEdge *)phash_next(handle->hash_edges, key, (PHashLink *)e);
@@ -881,8 +899,9 @@ static PBool p_edge_has_pair(PHandle *handle, PEdge *e, PEdge **pair, PBool impl
PHashKey key1 = e->vert->u.key;
PHashKey key2 = e->next->vert->u.key;
- if (e->flag & PEDGE_SEAM)
+ if (e->flag & PEDGE_SEAM) {
return P_FALSE;
+ }
key = PHASH_edge(key1, key2);
pe = (PEdge *)phash_lookup(handle->hash_edges, key);
@@ -925,8 +944,9 @@ static PBool p_edge_connect_pair(PHandle *handle, PEdge *e, PEdge ***stack, PBoo
PEdge *pair = NULL;
if (!e->pair && p_edge_has_pair(handle, e, &pair, impl)) {
- if (e->vert == pair->vert)
+ if (e->vert == pair->vert) {
p_face_flip(pair->face);
+ }
e->pair = pair;
pair->pair = e;
@@ -952,8 +972,9 @@ static int p_connect_pairs(PHandle *handle, PBool impl)
/* connect pairs, count edges, set vertex-edge pointer to a pairless edge */
for (first = chart->faces; first; first = first->nextlink) {
- if (first->flag & PFACE_CONNECTED)
+ if (first->flag & PFACE_CONNECTED) {
continue;
+ }
*stack = first->edge;
stack++;
@@ -970,12 +991,15 @@ static int p_connect_pairs(PHandle *handle, PBool impl)
/* assign verts to charts so we can sort them later */
f->u.chart = ncharts;
- if (!p_edge_connect_pair(handle, e, &stack, impl))
+ if (!p_edge_connect_pair(handle, e, &stack, impl)) {
e->vert->edge = e;
- if (!p_edge_connect_pair(handle, e1, &stack, impl))
+ }
+ if (!p_edge_connect_pair(handle, e1, &stack, impl)) {
e1->vert->edge = e1;
- if (!p_edge_connect_pair(handle, e2, &stack, impl))
+ }
+ if (!p_edge_connect_pair(handle, e2, &stack, impl)) {
e2->vert->edge = e2;
+ }
}
ncharts++;
@@ -996,18 +1020,21 @@ static void p_split_vert(PChart *chart, PEdge *e)
chart->flag |= PCHART_HAS_PINS;
}
- if (e->flag & PEDGE_VERTEX_SPLIT)
+ if (e->flag & PEDGE_VERTEX_SPLIT) {
return;
+ }
/* rewind to start */
lastwe = e;
- for (we = p_wheel_edge_prev(e); we && (we != e); we = p_wheel_edge_prev(we))
+ for (we = p_wheel_edge_prev(e); we && (we != e); we = p_wheel_edge_prev(we)) {
lastwe = we;
+ }
/* go over all edges in wheel */
for (we = lastwe; we; we = p_wheel_edge_next(we)) {
- if (we->flag & PEDGE_VERTEX_SPLIT)
+ if (we->flag & PEDGE_VERTEX_SPLIT) {
break;
+ }
we->flag |= PEDGE_VERTEX_SPLIT;
@@ -1046,8 +1073,9 @@ static PChart **p_split_charts(PHandle *handle, PChart *chart, int ncharts)
PFace *f, *nextf;
int i;
- for (i = 0; i < ncharts; i++)
+ for (i = 0; i < ncharts; i++) {
charts[i] = p_chart_new(handle);
+ }
f = chart->faces;
while (f) {
@@ -1133,21 +1161,27 @@ static PFace *p_face_add_construct(PHandle *handle,
e3->orig_uv = uv[i3];
if (pin) {
- if (pin[i1])
+ if (pin[i1]) {
e1->flag |= PEDGE_PIN;
- if (pin[i2])
+ }
+ if (pin[i2]) {
e2->flag |= PEDGE_PIN;
- if (pin[i3])
+ }
+ if (pin[i3]) {
e3->flag |= PEDGE_PIN;
+ }
}
if (select) {
- if (select[i1])
+ if (select[i1]) {
e1->flag |= PEDGE_SELECT;
- if (select[i2])
+ }
+ if (select[i2]) {
e2->flag |= PEDGE_SELECT;
- if (select[i3])
+ }
+ if (select[i3]) {
e3->flag |= PEDGE_SELECT;
+ }
}
/* insert into hash */
@@ -1205,12 +1239,14 @@ static PBool p_quad_split_direction(PHandle *handle, float **co, PHashKey *vkeys
* triangles, resulting in two identical triangles. for example in
* suzanne's nose. */
if (dir) {
- if (p_face_exists(handle, vkeys, 0, 1, 2) || p_face_exists(handle, vkeys, 0, 2, 3))
+ if (p_face_exists(handle, vkeys, 0, 1, 2) || p_face_exists(handle, vkeys, 0, 2, 3)) {
return !dir;
+ }
}
else {
- if (p_face_exists(handle, vkeys, 0, 1, 3) || p_face_exists(handle, vkeys, 1, 2, 3))
+ if (p_face_exists(handle, vkeys, 0, 1, 3) || p_face_exists(handle, vkeys, 1, 2, 3)) {
return !dir;
+ }
}
return dir;
@@ -1223,17 +1259,21 @@ static void p_chart_boundaries(PChart *chart, int *nboundaries, PEdge **outer)
PEdge *e, *be;
float len, maxlen = -1.0;
- if (nboundaries)
+ if (nboundaries) {
*nboundaries = 0;
- if (outer)
+ }
+ if (outer) {
*outer = NULL;
+ }
for (e = chart->edges; e; e = e->nextlink) {
- if (e->pair || (e->flag & PEDGE_DONE))
+ if (e->pair || (e->flag & PEDGE_DONE)) {
continue;
+ }
- if (nboundaries)
+ if (nboundaries) {
(*nboundaries)++;
+ }
len = 0.0f;
@@ -1250,8 +1290,9 @@ static void p_chart_boundaries(PChart *chart, int *nboundaries, PEdge **outer)
}
}
- for (e = chart->edges; e; e = e->nextlink)
+ for (e = chart->edges; e; e = e->nextlink) {
e->flag &= ~PEDGE_DONE;
+ }
}
static float p_edge_boundary_angle(PEdge *e)
@@ -1364,8 +1405,9 @@ static void p_chart_fill_boundaries(PChart *chart, PEdge *outer)
for (e = chart->edges; e; e = e->nextlink) {
/* enext = e->nextlink; - as yet unused */
- if (e->pair || (e->flag & PEDGE_FILLED))
+ if (e->pair || (e->flag & PEDGE_FILLED)) {
continue;
+ }
nedges = 0;
be = e;
@@ -1375,8 +1417,9 @@ static void p_chart_fill_boundaries(PChart *chart, PEdge *outer)
nedges++;
} while (be != e);
- if (e != outer)
+ if (e != outer) {
p_chart_fill_boundary(chart, e, nedges);
+ }
}
}
@@ -2350,8 +2393,9 @@ static void p_abf_setup_system(PAbfSystem *sys)
sys->bstar = (float *)MEM_mallocN(sizeof(float) * sys->nfaces, "ABFbstar");
sys->dstar = (float *)MEM_mallocN(sizeof(float) * sys->nfaces, "ABFdstar");
- for (i = 0; i < sys->ninterior; i++)
+ for (i = 0; i < sys->ninterior; i++) {
sys->lambdaLength[i] = 1.0;
+ }
sys->minangle = 1.0 * M_PI / 180.0;
sys->maxangle = (float)M_PI - sys->minangle;
@@ -2404,16 +2448,18 @@ static float p_abf_compute_sin_product(PAbfSystem *sys, PVert *v, int aid)
sin1 *= sys->cosine[e1->u.id];
sin2 = 0.0;
}
- else
+ else {
sin1 *= sys->sine[e1->u.id];
+ }
if (aid == e2->u.id) {
/* see above */
sin1 = 0.0;
sin2 *= sys->cosine[e2->u.id];
}
- else
+ else {
sin2 *= sys->sine[e2->u.id];
+ }
e = e->next->next->pair;
} while (e && (e != v->edge));
@@ -2504,8 +2550,9 @@ static PBool p_abf_matrix_invert(PAbfSystem *sys, PChart *chart)
context = EIG_linear_solver_new(0, nvar, 1);
- for (i = 0; i < nvar; i++)
+ for (i = 0; i < nvar; i++) {
EIG_linear_solver_right_hand_side_add(context, 0, i, sys->bInterior[i]);
+ }
for (f = chart->faces; f; f = f->nextlink) {
float wi1, wi2, wi3, b, si, beta[3], j2[3][3], W[3][3];
@@ -2615,29 +2662,37 @@ static PBool p_abf_matrix_invert(PAbfSystem *sys, PChart *chart)
for (i = 0; i < 3; i++) {
int r = vid[i];
- if (r == -1)
+ if (r == -1) {
continue;
+ }
for (j = 0; j < 6; j++) {
int c = vid[j];
- if (c == -1)
+ if (c == -1) {
continue;
+ }
- if (i == 0)
+ if (i == 0) {
EIG_linear_solver_matrix_add(context, r, c, j2[0][i] * row1[j]);
- else
+ }
+ else {
EIG_linear_solver_matrix_add(context, r + ninterior, c, j2[0][i] * row1[j]);
+ }
- if (i == 1)
+ if (i == 1) {
EIG_linear_solver_matrix_add(context, r, c, j2[1][i] * row2[j]);
- else
+ }
+ else {
EIG_linear_solver_matrix_add(context, r + ninterior, c, j2[1][i] * row2[j]);
+ }
- if (i == 2)
+ if (i == 2) {
EIG_linear_solver_matrix_add(context, r, c, j2[2][i] * row3[j]);
- else
+ }
+ else {
EIG_linear_solver_matrix_add(context, r + ninterior, c, j2[2][i] * row3[j]);
+ }
}
}
}
@@ -2693,10 +2748,12 @@ static PBool p_abf_matrix_invert(PAbfSystem *sys, PChart *chart)
/* clamp */
e = f->edge;
do {
- if (sys->alpha[e->u.id] > (float)M_PI)
+ if (sys->alpha[e->u.id] > (float)M_PI) {
sys->alpha[e->u.id] = (float)M_PI;
- else if (sys->alpha[e->u.id] < 0.0f)
+ }
+ else if (sys->alpha[e->u.id] < 0.0f) {
sys->alpha[e->u.id] = 0.0f;
+ }
} while (e != f->edge);
}
@@ -2728,8 +2785,9 @@ static PBool p_chart_abf_solve(PChart *chart)
v->flag |= PVERT_INTERIOR;
v->u.id = sys.ninterior++;
}
- else
+ else {
v->flag &= ~PVERT_INTERIOR;
+ }
}
for (f = chart->faces; f; f = f->nextlink) {
@@ -2755,18 +2813,24 @@ static PBool p_chart_abf_solve(PChart *chart)
e3 = e2->next;
p_face_angles(f, &a1, &a2, &a3);
- if (a1 < sys.minangle)
+ if (a1 < sys.minangle) {
a1 = sys.minangle;
- else if (a1 > sys.maxangle)
+ }
+ else if (a1 > sys.maxangle) {
a1 = sys.maxangle;
- if (a2 < sys.minangle)
+ }
+ if (a2 < sys.minangle) {
a2 = sys.minangle;
- else if (a2 > sys.maxangle)
+ }
+ else if (a2 > sys.maxangle) {
a2 = sys.maxangle;
- if (a3 < sys.minangle)
+ }
+ if (a3 < sys.minangle) {
a3 = sys.minangle;
- else if (a3 > sys.maxangle)
+ }
+ else if (a3 > sys.maxangle) {
a3 = sys.maxangle;
+ }
sys.alpha[e1->u.id] = sys.beta[e1->u.id] = a1;
sys.alpha[e2->u.id] = sys.beta[e2->u.id] = a2;
@@ -2808,8 +2872,9 @@ static PBool p_chart_abf_solve(PChart *chart)
/* lastnorm = norm; */ /* UNUSED */
- if (norm < limit)
+ if (norm < limit) {
break;
+ }
if (!p_abf_matrix_invert(&sys, chart)) {
param_warning("ABF failed to invert matrix");
@@ -2906,12 +2971,14 @@ static PBool p_chart_symmetry_pins(PChart *chart, PEdge *outer, PVert **pin1, PV
if ((be->vert->flag & PVERT_SPLIT) ||
(lastbe->vert->flag & nextbe->vert->flag & PVERT_SPLIT)) {
if (!cure) {
- if (be == outer)
+ if (be == outer) {
firste1 = be;
+ }
cure = be;
}
- else
+ else {
curlen += p_edge_length(lastbe);
+ }
}
else if (cure) {
if (curlen > maxlen) {
@@ -2944,8 +3011,9 @@ static PBool p_chart_symmetry_pins(PChart *chart, PEdge *outer, PVert **pin1, PV
}
}
- if (!maxe1 || !maxe2 || (maxlen < 0.5f * totlen))
+ if (!maxe1 || !maxe2 || (maxlen < 0.5f * totlen)) {
return P_FALSE;
+ }
/* find pin1 in the split vertices */
be1 = maxe1;
@@ -3054,12 +3122,14 @@ static void p_chart_lscm_begin(PChart *chart, PBool live, PBool abf)
for (v = chart->verts; v; v = v->nextlink) {
if (v->flag & PVERT_PIN) {
npins++;
- if (v->flag & PVERT_SELECT)
+ if (v->flag & PVERT_SELECT) {
select = P_TRUE;
+ }
}
- if (!(v->flag & PVERT_SELECT))
+ if (!(v->flag & PVERT_SELECT)) {
deselect = P_TRUE;
+ }
}
if ((live && (!select || !deselect)) || (npins == 1)) {
@@ -3072,8 +3142,9 @@ static void p_chart_lscm_begin(PChart *chart, PBool live, PBool abf)
#endif
if (abf) {
- if (!p_chart_abf_solve(chart))
+ if (!p_chart_abf_solve(chart)) {
param_warning("ABF solving failed: falling back to LSCM.\n");
+ }
}
if (npins <= 1) {
@@ -3091,8 +3162,9 @@ static void p_chart_lscm_begin(PChart *chart, PBool live, PBool abf)
chart->u.lscm.pin2 = pin2;
}
- for (v = chart->verts; v; v = v->nextlink)
+ for (v = chart->verts; v; v = v->nextlink) {
v->u.id = id++;
+ }
chart->u.lscm.context = EIG_linear_least_squares_solver_new(
2 * chart->nfaces, 2 * chart->nverts, 1);
@@ -3113,9 +3185,11 @@ static PBool p_chart_lscm_solve(PHandle *handle, PChart *chart)
/* TODO: make loading pins work for simplify/complexify. */
#endif
- for (v = chart->verts; v; v = v->nextlink)
- if (v->flag & PVERT_PIN)
+ for (v = chart->verts; v; v = v->nextlink) {
+ if (v->flag & PVERT_PIN) {
p_vert_load_pin_select_uvs(handle, v); /* reload for live */
+ }
+ }
if (chart->u.lscm.pin1) {
EIG_linear_solver_variable_lock(context, 2 * pin1->u.id);
@@ -3152,10 +3226,12 @@ static PBool p_chart_lscm_solve(PHandle *handle, PChart *chart)
if ((v1->flag & PVERT_PIN) && (v2->flag & PVERT_PIN) && (v3->flag & PVERT_PIN)) {
float area = p_face_uv_area_signed(f);
- if (area > 0.0f)
+ if (area > 0.0f) {
area_pinned_up += area;
- else
+ }
+ else {
area_pinned_down -= area;
+ }
}
}
@@ -3176,8 +3252,9 @@ static PBool p_chart_lscm_solve(PHandle *handle, PChart *chart)
a2 = *(alpha++);
a3 = *(alpha++);
}
- else
+ else {
p_face_angles(f, &a1, &a2, &a3);
+ }
if (flip_faces) {
SWAP(float, a2, a3);
@@ -3240,8 +3317,9 @@ static PBool p_chart_lscm_solve(PHandle *handle, PChart *chart)
static void p_chart_lscm_end(PChart *chart)
{
- if (chart->u.lscm.context)
+ if (chart->u.lscm.context) {
EIG_linear_solver_delete(chart->u.lscm.context);
+ }
if (chart->u.lscm.abf_alpha) {
MEM_freeN(chart->u.lscm.abf_alpha);
@@ -3261,11 +3339,14 @@ static void p_stretch_pin_boundary(PChart *chart)
{
PVert *v;
- for (v = chart->verts; v; v = v->nextlink)
- if (v->edge->pair == NULL)
+ for (v = chart->verts; v; v = v->nextlink) {
+ if (v->edge->pair == NULL) {
v->flag |= PVERT_PIN;
- else
+ }
+ else {
v->flag &= ~PVERT_PIN;
+ }
+ }
}
static float p_face_stretch(PFace *f)
@@ -3278,8 +3359,9 @@ static float p_face_stretch(PFace *f)
area = p_face_uv_area_signed(f);
- if (area <= 0.0f) /* flipped face -> infinite stretch */
+ if (area <= 0.0f) { /* flipped face -> infinite stretch */
return 1e10f;
+ }
w = 1.0f / (2.0f * area);
@@ -3315,8 +3397,9 @@ static float p_face_stretch(PFace *f)
c = dot_v3v3(Pt, Pt);
T = sqrtf(0.5f * (a + c));
- if (f->flag & PFACE_FILLED)
+ if (f->flag & PFACE_FILLED) {
T *= 0.2f;
+ }
return T;
}
@@ -3343,8 +3426,9 @@ static void p_chart_stretch_minimize(PChart *chart, RNG *rng)
float orig_uv[2], dir[2], random_angle, trusted_radius;
for (v = chart->verts; v; v = v->nextlink) {
- if ((v->flag & PVERT_PIN) || !(v->flag & PVERT_SELECT))
+ if ((v->flag & PVERT_PIN) || !(v->flag & PVERT_SELECT)) {
continue;
+ }
orig_stretch = p_stretch_compute_vertex(v);
orig_uv[0] = v->uv[0];
@@ -3394,8 +3478,9 @@ static void p_chart_stretch_minimize(PChart *chart, RNG *rng)
}
/* no luck, stretch has increased, reset to old values */
- if (stretch >= orig_stretch)
+ if (stretch >= orig_stretch) {
copy_v2_v2(v->uv, orig_uv);
+ }
}
}
@@ -3406,18 +3491,23 @@ static int p_compare_geometric_uv(const void *a, const void *b)
const PVert *v1 = *(const PVert *const *)a;
const PVert *v2 = *(const PVert *const *)b;
- if (v1->uv[0] < v2->uv[0])
+ if (v1->uv[0] < v2->uv[0]) {
return -1;
+ }
else if (v1->uv[0] == v2->uv[0]) {
- if (v1->uv[1] < v2->uv[1])
+ if (v1->uv[1] < v2->uv[1]) {
return -1;
- else if (v1->uv[1] == v2->uv[1])
+ }
+ else if (v1->uv[1] == v2->uv[1]) {
return 0;
- else
+ }
+ else {
return 1;
+ }
}
- else
+ else {
return 1;
+ }
}
static PBool p_chart_convex_hull(PChart *chart, PVert ***verts, int *nverts, int *right)
@@ -3431,8 +3521,9 @@ static PBool p_chart_convex_hull(PChart *chart, PVert ***verts, int *nverts, int
p_chart_boundaries(chart, NULL, &be);
- if (!be)
+ if (!be) {
return P_FALSE;
+ }
e = be;
do {
@@ -3455,10 +3546,12 @@ static PBool p_chart_convex_hull(PChart *chart, PVert ***verts, int *nverts, int
ulen = llen = 0;
for (p = points, i = 0; i < npoints; i++, p++) {
- while ((ulen > 1) && (p_area_signed(U[ulen - 2]->uv, (*p)->uv, U[ulen - 1]->uv) <= 0))
+ while ((ulen > 1) && (p_area_signed(U[ulen - 2]->uv, (*p)->uv, U[ulen - 1]->uv) <= 0)) {
ulen--;
- while ((llen > 1) && (p_area_signed(L[llen - 2]->uv, (*p)->uv, L[llen - 1]->uv) >= 0))
+ }
+ while ((llen > 1) && (p_area_signed(L[llen - 2]->uv, (*p)->uv, L[llen - 1]->uv) >= 0)) {
llen--;
+ }
U[ulen] = *p;
ulen++;
@@ -3467,12 +3560,14 @@ static PBool p_chart_convex_hull(PChart *chart, PVert ***verts, int *nverts, int
}
npoints = 0;
- for (p = points, i = 0; i < ulen; i++, p++, npoints++)
+ for (p = points, i = 0; i < ulen; i++, p++, npoints++) {
*p = U[i];
+ }
/* the first and last point in L are left out, since they are also in U */
- for (i = llen - 2; i > 0; i--, p++, npoints++)
+ for (i = llen - 2; i > 0; i--, p++, npoints++) {
*p = L[i];
+ }
*verts = points;
*nverts = npoints;
@@ -3494,14 +3589,17 @@ static float p_rectangle_area(float *p1, float *dir, float *p2, float *p3, float
orthodir[0] = dir[1];
orthodir[1] = -dir[0];
- if (!p_intersect_line_2d_dir(p1, dir, p2, orthodir, corner1))
+ if (!p_intersect_line_2d_dir(p1, dir, p2, orthodir, corner1)) {
return 1e10;
+ }
- if (!p_intersect_line_2d_dir(p1, dir, p4, orthodir, corner2))
+ if (!p_intersect_line_2d_dir(p1, dir, p4, orthodir, corner2)) {
return 1e10;
+ }
- if (!p_intersect_line_2d_dir(p3, dir, p4, orthodir, corner3))
+ if (!p_intersect_line_2d_dir(p3, dir, p4, orthodir, corner3)) {
return 1e10;
+ }
return len_v2v2(corner1, corner2) * len_v2v2(corner2, corner3);
}
@@ -3517,8 +3615,9 @@ static float p_chart_minimum_area_angle(PChart *chart)
PVert **points, *p1, *p2, *p3, *p4, *p1n;
/* compute convex hull */
- if (!p_chart_convex_hull(chart, &points, &npoints, &right))
+ if (!p_chart_convex_hull(chart, &points, &npoints, &right)) {
return 0.0;
+ }
/* find left/top/right/bottom points, and compute angle for each point */
angles = MEM_mallocN(sizeof(float) * npoints, "PMinAreaAngles");
@@ -3577,11 +3676,12 @@ static float p_chart_minimum_area_angle(PChart *chart)
i_min = 0;
mina = 1e10;
- for (i = 0; i < 4; i++)
+ for (i = 0; i < 4; i++) {
if (a[i] < mina) {
mina = a[i];
i_min = i;
}
+ }
rotated += mina;
nextidx = (idx[i_min] + 1) % npoints;
@@ -3618,8 +3718,9 @@ static float p_chart_minimum_area_angle(PChart *chart)
}
/* try keeping rotation as small as possible */
- if (minangle > (float)(M_PI / 4))
+ if (minangle > (float)(M_PI / 4)) {
minangle -= (float)(M_PI / 2.0);
+ }
MEM_freeN(angles);
MEM_freeN(points);
@@ -3712,8 +3813,9 @@ static SmoothNode *p_node_new(
node->tri = tri;
node->ntri = ntri;
- if (ntri <= 10 || depth >= 15)
+ if (ntri <= 10 || depth >= 15) {
return node;
+ }
t1 = MEM_mallocN(sizeof(*t1) * ntri, "PNodeTri1");
t2 = MEM_mallocN(sizeof(*t2) * ntri, "PNodeTri1");
@@ -3761,12 +3863,15 @@ static SmoothNode *p_node_new(
static void p_node_delete(SmoothNode *node)
{
- if (node->c1)
+ if (node->c1) {
p_node_delete(node->c1);
- if (node->c2)
+ }
+ if (node->c2) {
p_node_delete(node->c2);
- if (node->tri)
+ }
+ if (node->tri) {
MEM_freeN(node->tri);
+ }
}
static PBool p_node_intersect(SmoothNode *node, float co[2])
@@ -3774,17 +3879,21 @@ static PBool p_node_intersect(SmoothNode *node, float co[2])
int i;
if (node->tri) {
- for (i = 0; i < node->ntri; i++)
- if (p_triangle_inside(node->tri[i], co))
+ for (i = 0; i < node->ntri; i++) {
+ if (p_triangle_inside(node->tri[i], co)) {
return P_TRUE;
+ }
+ }
return P_FALSE;
}
else {
- if (co[node->axis] < node->split)
+ if (co[node->axis] < node->split) {
return p_node_intersect(node->c1, co);
- else
+ }
+ else {
return p_node_intersect(node->c2, co);
+ }
}
}
@@ -3795,12 +3904,15 @@ static int p_compare_float(const void *a_, const void *b_)
const float a = *(const float *)a_;
const float b = *(const float *)b_;
- if (a < b)
+ if (a < b) {
return -1;
- else if (a == b)
+ }
+ else if (a == b) {
return 0;
- else
+ }
+ else {
return 1;
+ }
}
static float p_smooth_median_edge_length(PChart *chart)
@@ -3811,8 +3923,9 @@ static float p_smooth_median_edge_length(PChart *chart)
int i;
/* ok, so i'm lazy */
- for (i = 0, e = chart->edges; e; e = e->nextlink, i++)
+ for (i = 0, e = chart->edges; e; e = e->nextlink, i++) {
lengths[i] = p_edge_length(e);
+ }
qsort(lengths, i, sizeof(float), p_compare_float);
@@ -3845,14 +3958,16 @@ static void p_smooth(PChart *chart)
SmoothNode *root;
MemArena *arena;
- if (nedges == 0)
+ if (nedges == 0) {
return;
+ }
p_chart_uv_bbox(chart, minv, maxv);
median = p_smooth_median_edge_length(chart) * 0.10f;
- if (median == 0.0f)
+ if (median == 0.0f) {
return;
+ }
invmedian = 1.0f / median;
@@ -3905,8 +4020,9 @@ static void p_smooth(PChart *chart)
gridx = gridx * 2 + 1;
gridy = gridy * 2 + 1;
- if ((gridx <= 2) || (gridy <= 2))
+ if ((gridx <= 2) || (gridy <= 2)) {
return;
+ }
edgesx = gridx - 1;
edgesy = gridy - 1;
@@ -3922,20 +4038,27 @@ static void p_smooth(PChart *chart)
vedges = MEM_mallocN(sizeof(float) * esize, "PSmoothVEdges");
if (!nodes || !nodesx || !nodesy || !oldnodesx || !oldnodesy || !hedges || !vedges) {
- if (nodes)
+ if (nodes) {
MEM_freeN(nodes);
- if (nodesx)
+ }
+ if (nodesx) {
MEM_freeN(nodesx);
- if (nodesy)
+ }
+ if (nodesy) {
MEM_freeN(nodesy);
- if (oldnodesx)
+ }
+ if (oldnodesx) {
MEM_freeN(oldnodesx);
- if (oldnodesy)
+ }
+ if (oldnodesy) {
MEM_freeN(oldnodesy);
- if (hedges)
+ }
+ if (hedges) {
MEM_freeN(hedges);
- if (vedges)
+ }
+ if (vedges) {
MEM_freeN(vedges);
+ }
// printf("Not enough memory for area smoothing grid");
return;
@@ -4062,12 +4185,14 @@ static void p_smooth(PChart *chart)
}
}
- if (d < dlimit)
+ if (d < dlimit) {
break;
+ }
}
- if (moved < climit)
+ if (moved < climit) {
break;
+ }
}
MEM_freeN(oldnodesx);
@@ -4084,10 +4209,12 @@ static void p_smooth(PChart *chart)
MEM_freeN(nodesx);
MEM_freeN(nodesy);
- if (triangles)
+ if (triangles) {
MEM_freeN(triangles);
- if (tri)
+ }
+ if (tri) {
MEM_freeN(tri);
+ }
// printf("Not enough memory for area smoothing grid");
return;
@@ -4149,9 +4276,11 @@ static void p_smooth(PChart *chart)
arena = BLI_memarena_new(MEM_SIZE_OPTIMAL(1 << 16), "param smooth arena");
root = p_node_new(arena, tri, esize * 2, minv, maxv, 0);
- for (v = chart->verts; v; v = v->nextlink)
- if (!p_node_intersect(root, v->uv))
+ for (v = chart->verts; v; v = v->nextlink) {
+ if (!p_node_intersect(root, v->uv)) {
param_warning("area smoothing error: couldn't find mapping triangle\n");
+ }
+ }
p_node_delete(root);
BLI_memarena_free(arena);
@@ -4197,11 +4326,13 @@ void param_delete(ParamHandle *handle)
param_assert((phandle->state == PHANDLE_STATE_ALLOCATED) ||
(phandle->state == PHANDLE_STATE_CONSTRUCTED));
- for (i = 0; i < phandle->ncharts; i++)
+ for (i = 0; i < phandle->ncharts; i++) {
p_chart_delete(phandle->charts[i]);
+ }
- if (phandle->charts)
+ if (phandle->charts) {
MEM_freeN(phandle->charts);
+ }
if (phandle->construction_chart) {
p_chart_delete(phandle->construction_chart);
@@ -4323,8 +4454,9 @@ void param_edge_set_seam(ParamHandle *handle, ParamKey *vkeys)
param_assert(phandle->state == PHANDLE_STATE_ALLOCATED);
e = p_edge_lookup(phandle, vkeys);
- if (e)
+ if (e) {
e->flag |= PEDGE_SEAM;
+ }
}
void param_construct_end(ParamHandle *handle, ParamBool fill, ParamBool impl)
@@ -4361,11 +4493,13 @@ void param_construct_end(ParamHandle *handle, ParamBool fill, ParamBool impl)
phandle->charts[j] = chart;
j++;
- if (fill && (nboundaries > 1))
+ if (fill && (nboundaries > 1)) {
p_chart_fill_boundaries(chart, outer);
+ }
- for (v = chart->verts; v; v = v->nextlink)
+ for (v = chart->verts; v; v = v->nextlink) {
p_vert_load_pin_select_uvs(handle, v);
+ }
}
phandle->ncharts = j;
@@ -4383,8 +4517,9 @@ void param_lscm_begin(ParamHandle *handle, ParamBool live, ParamBool abf)
phandle->state = PHANDLE_STATE_LSCM;
for (i = 0; i < phandle->ncharts; i++) {
- for (f = phandle->charts[i]->faces; f; f = f->nextlink)
+ for (f = phandle->charts[i]->faces; f; f = f->nextlink) {
p_face_backup_uvs(f);
+ }
p_chart_lscm_begin(phandle->charts[i], (PBool)live, (PBool)abf);
}
}
@@ -4404,11 +4539,13 @@ void param_lscm_solve(ParamHandle *handle)
if (chart->u.lscm.context) {
result = p_chart_lscm_solve(phandle, chart);
- if (result && !(chart->flag & PCHART_HAS_PINS))
+ if (result && !(chart->flag & PCHART_HAS_PINS)) {
p_chart_rotate_minimum_area(chart);
+ }
- if (!result || (chart->u.lscm.pin1))
+ if (!result || (chart->u.lscm.pin1)) {
p_chart_lscm_end(chart);
+ }
}
}
}
@@ -4447,8 +4584,9 @@ void param_stretch_begin(ParamHandle *handle)
for (i = 0; i < phandle->ncharts; i++) {
chart = phandle->charts[i];
- for (v = chart->verts; v; v = v->nextlink)
+ for (v = chart->verts; v; v = v->nextlink) {
v->flag &= ~PVERT_PIN; /* don't use user-defined pins */
+ }
p_stretch_pin_boundary(chart);
@@ -4503,8 +4641,9 @@ void param_smooth_area(ParamHandle *handle)
PChart *chart = phandle->charts[i];
PVert *v;
- for (v = chart->verts; v; v = v->nextlink)
+ for (v = chart->verts; v; v = v->nextlink) {
v->flag &= ~PVERT_PIN;
+ }
p_smooth(chart);
}
@@ -4557,16 +4696,18 @@ void param_pack(ParamHandle *handle, float margin, bool do_rotate, bool ignore_p
PHandle *phandle = (PHandle *)handle;
- if (phandle->ncharts == 0)
+ if (phandle->ncharts == 0) {
return;
+ }
/* this could be its own function */
if (do_rotate) {
param_pack_rotate(handle, ignore_pinned);
}
- if (phandle->aspx != phandle->aspy)
+ if (phandle->aspx != phandle->aspy) {
param_scale(handle, 1.0f / phandle->aspx, 1.0f / phandle->aspy);
+ }
/* we may not use all these boxes */
boxarray = MEM_mallocN(phandle->ncharts * sizeof(BoxPack), "BoxPack box");
@@ -4592,8 +4733,9 @@ void param_pack(ParamHandle *handle, float margin, bool do_rotate, bool ignore_p
box->h = chart->u.pack.size[1] + trans[1];
box->index = i; /* warning this index skips PCHART_HAS_PINS boxes */
- if (margin > 0.0f)
+ if (margin > 0.0f) {
area += (double)sqrtf(box->w * box->h);
+ }
}
if (margin > 0.0f) {
@@ -4622,10 +4764,12 @@ void param_pack(ParamHandle *handle, float margin, bool do_rotate, bool ignore_p
BLI_box_pack_2d(boxarray, phandle->ncharts - unpacked, &tot_width, &tot_height);
- if (tot_height > tot_width)
+ if (tot_height > tot_width) {
scale = 1.0f / tot_height;
- else
+ }
+ else {
scale = 1.0f / tot_width;
+ }
for (i = 0; i < phandle->ncharts - unpacked; i++) {
box = boxarray + i;
@@ -4638,8 +4782,9 @@ void param_pack(ParamHandle *handle, float margin, bool do_rotate, bool ignore_p
}
MEM_freeN(boxarray);
- if (phandle->aspx != phandle->aspy)
+ if (phandle->aspx != phandle->aspy) {
param_scale(handle, phandle->aspx, phandle->aspy);
+ }
}
void param_average(ParamHandle *handle, bool ignore_pinned)
@@ -4651,8 +4796,9 @@ void param_average(ParamHandle *handle, bool ignore_pinned)
float minv[2], maxv[2], trans[2];
PHandle *phandle = (PHandle *)handle;
- if (phandle->ncharts == 0)
+ if (phandle->ncharts == 0) {
return;
+ }
for (i = 0; i < phandle->ncharts; i++) {
PFace *f;
@@ -4729,13 +4875,16 @@ void param_flush(ParamHandle *handle)
for (i = 0; i < phandle->ncharts; i++) {
chart = phandle->charts[i];
- if ((phandle->state == PHANDLE_STATE_LSCM) && !chart->u.lscm.context)
+ if ((phandle->state == PHANDLE_STATE_LSCM) && !chart->u.lscm.context) {
continue;
+ }
- if (phandle->blend == 0.0f)
+ if (phandle->blend == 0.0f) {
p_flush_uvs(phandle, chart);
- else
+ }
+ else {
p_flush_uvs_blend(phandle, chart, phandle->blend);
+ }
}
}
@@ -4749,7 +4898,8 @@ void param_flush_restore(ParamHandle *handle)
for (i = 0; i < phandle->ncharts; i++) {
chart = phandle->charts[i];
- for (f = chart->faces; f; f = f->nextlink)
+ for (f = chart->faces; f; f = f->nextlink) {
p_face_restore_uvs(f);
+ }
}
}
diff --git a/source/blender/editors/uvedit/uvedit_smart_stitch.c b/source/blender/editors/uvedit/uvedit_smart_stitch.c
index fcb557473fd..b938f963d9a 100644
--- a/source/blender/editors/uvedit/uvedit_smart_stitch.c
+++ b/source/blender/editors/uvedit/uvedit_smart_stitch.c
@@ -466,11 +466,13 @@ static void stitch_calculate_island_snapping(StitchState *state,
float rotation_mat[2][2];
/* check to avoid divide by 0 */
- if (island_stitch_data[i].num_rot_elements > 1)
+ if (island_stitch_data[i].num_rot_elements > 1) {
island_stitch_data[i].rotation /= island_stitch_data[i].num_rot_elements;
+ }
- if (island_stitch_data[i].num_rot_elements_neg > 1)
+ if (island_stitch_data[i].num_rot_elements_neg > 1) {
island_stitch_data[i].rotation_neg /= island_stitch_data[i].num_rot_elements_neg;
+ }
if (island_stitch_data[i].numOfElements > 1) {
island_stitch_data[i].medianPoint[0] /= island_stitch_data[i].numOfElements;
@@ -609,8 +611,9 @@ static void stitch_island_calculate_vert_rotation(UvElement *element,
int rot_elem = 0, rot_elem_neg = 0;
BMLoop *l;
- if (element->island == ssc->static_island && !ssc->midpoints)
+ if (element->island == ssc->static_island && !ssc->midpoints) {
return;
+ }
l = element->l;
@@ -625,8 +628,9 @@ static void stitch_island_calculate_vert_rotation(UvElement *element,
float normal[2];
/* only calculate rotation against static island uv verts */
- if (!ssc->midpoints && element_iter->island != ssc->static_island)
+ if (!ssc->midpoints && element_iter->island != ssc->static_island) {
continue;
+ }
index_tmp1 = element_iter - state->element_map->buf;
index_tmp1 = state->map[index_tmp1];
@@ -717,8 +721,9 @@ static void stitch_uv_edge_generate_linked_edges(GHash *edge_hash, StitchState *
for (i = 0; i < state->total_separate_edges; i++) {
UvEdge *edge = edges + i;
- if (edge->first)
+ if (edge->first) {
continue;
+ }
/* only boundary edges can be stitched. Yes. Sorry about that :p */
if (edge->flag & STITCH_BOUNDARY) {
@@ -736,10 +741,12 @@ static void stitch_uv_edge_generate_linked_edges(GHash *edge_hash, StitchState *
UvElement *iter2 = NULL;
/* check to see if other vertex of edge belongs to same vertex as */
- if (BM_elem_index_get(iter1->l->next->v) == elemindex2)
+ if (BM_elem_index_get(iter1->l->next->v) == elemindex2) {
iter2 = BM_uv_element_get(element_map, iter1->l->f, iter1->l->next);
- else if (BM_elem_index_get(iter1->l->prev->v) == elemindex2)
+ }
+ else if (BM_elem_index_get(iter1->l->prev->v) == elemindex2) {
iter2 = BM_uv_element_get(element_map, iter1->l->f, iter1->l->prev);
+ }
if (iter2) {
int index1 = map[iter1 - first_element];
@@ -852,8 +859,9 @@ static void stitch_setup_face_preview_for_uv_group(UvElement *element,
StitchPreviewer *preview = state->stitch_preview;
/* static island does not change so returning immediately */
- if (ssc->snap_islands && !ssc->midpoints && ssc->static_island == element->island)
+ if (ssc->snap_islands && !ssc->midpoints && ssc->static_island == element->island) {
return;
+ }
if (ssc->snap_islands) {
island_stitch_data[element->island].addedForPreview = 1;
@@ -892,8 +900,9 @@ static void stitch_validate_uv_stitchability(UvElement *element,
for (; element_iter; element_iter = element_iter->next) {
if (element_iter->separate) {
- if (element_iter == element)
+ if (element_iter == element) {
continue;
+ }
if (stitch_check_uvs_state_stitchable(element, element_iter, ssc, state)) {
if ((element_iter->island == ssc->static_island) ||
(element->island == ssc->static_island)) {
@@ -930,8 +939,9 @@ static void stitch_validate_edge_stitchability(UvEdge *edge,
UvEdge *edge_iter = edge->first;
for (; edge_iter; edge_iter = edge_iter->next) {
- if (edge_iter == edge)
+ if (edge_iter == edge) {
continue;
+ }
if (stitch_check_edges_state_stitchable(edge, edge_iter, ssc, state)) {
if ((edge_iter->element->island == ssc->static_island) ||
(edge->element->island == ssc->static_island)) {
@@ -1029,8 +1039,9 @@ static int stitch_process_data(StitchStateContainer *ssc,
/* cleanup previous preview */
stitch_preview_delete(state->stitch_preview);
preview = state->stitch_preview = stitch_preview_init();
- if (preview == NULL)
+ if (preview == NULL) {
return 0;
+ }
preview_position = MEM_mallocN(bm->totface * sizeof(*preview_position),
"stitch_face_preview_position");
@@ -1314,8 +1325,9 @@ static int stitch_process_data(StitchStateContainer *ssc,
copy_v2_v2(final_position[i].uv, luv->uv);
final_position[i].count = 1;
- if (ssc->snap_islands && element->island == ssc->static_island && !stitch_midpoints)
+ if (ssc->snap_islands && element->island == ssc->static_island && !stitch_midpoints) {
continue;
+ }
element_iter = state->element_map->vert[BM_elem_index_get(l->v)];
@@ -1364,8 +1376,10 @@ static int stitch_process_data(StitchStateContainer *ssc,
state->uvs[edge->uv1]->flag |= STITCH_STITCHABLE;
state->uvs[edge->uv2]->flag |= STITCH_STITCHABLE;
- if (ssc->snap_islands && edge->element->island == ssc->static_island && !stitch_midpoints)
+ if (ssc->snap_islands && edge->element->island == ssc->static_island &&
+ !stitch_midpoints) {
continue;
+ }
for (edge_iter = edge->first; edge_iter; edge_iter = edge_iter->next) {
if (stitch_check_edges_state_stitchable(edge, edge_iter, ssc, state)) {
@@ -1587,8 +1601,9 @@ static void stitch_select_edge(UvEdge *edge, StitchState *state, int always_sele
for (eiter = edge->first; eiter; eiter = eiter->next) {
if (eiter->flag & STITCH_SELECTED) {
int i;
- if (always_select)
+ if (always_select) {
continue;
+ }
eiter->flag &= ~STITCH_SELECTED;
for (i = 0; i < state->selection_size; i++) {
@@ -1622,8 +1637,9 @@ static void stitch_select_uv(UvElement *element, StitchState *state, int always_
/* only separators go to selection */
if (element_iter->flag & STITCH_SELECTED) {
int i;
- if (always_select)
+ if (always_select) {
continue;
+ }
element_iter->flag &= ~STITCH_SELECTED;
for (i = 0; i < state->selection_size; i++) {
@@ -1660,8 +1676,9 @@ static void stitch_set_selection_mode(StitchState *state, const char from_stitch
UvElement *element1 = state->uvs[edge->uv1];
UvElement *element2 = state->uvs[edge->uv2];
- if ((element1->flag & STITCH_SELECTED) && (element2->flag & STITCH_SELECTED))
+ if ((element1->flag & STITCH_SELECTED) && (element2->flag & STITCH_SELECTED)) {
stitch_select_edge(edge, state, true);
+ }
}
/* unselect selected uvelements */
@@ -1770,8 +1787,9 @@ static void stitch_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void *ar
/* Preview Polys */
if (stitch_preview->preview_polys) {
- for (int i = 0; i < stitch_preview->num_polys; i++)
+ for (int i = 0; i < stitch_preview->num_polys; i++) {
num_line += stitch_preview->uvs_per_polygon[i];
+ }
num_tri = num_line - 2 * stitch_preview->num_polys;
@@ -2237,8 +2255,9 @@ static bool goto_next_island(StitchStateContainer *ssc)
static int stitch_init_all(bContext *C, wmOperator *op)
{
ARegion *ar = CTX_wm_region(C);
- if (!ar)
+ if (!ar) {
return 0;
+ }
Scene *scene = CTX_data_scene(C);
ToolSettings *ts = scene->toolsettings;
@@ -2260,10 +2279,12 @@ static int stitch_init_all(bContext *C, wmOperator *op)
}
else {
if (ts->uv_flag & UV_SYNC_SELECTION) {
- if (ts->selectmode & SCE_SELECT_VERTEX)
+ if (ts->selectmode & SCE_SELECT_VERTEX) {
ssc->mode = STITCH_VERT;
- else
+ }
+ else {
ssc->mode = STITCH_EDGE;
+ }
}
else {
if (ts->uv_selectmode & UV_SELECT_VERTEX) {
@@ -2385,8 +2406,9 @@ static int stitch_init_all(bContext *C, wmOperator *op)
static int stitch_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
- if (!stitch_init_all(C, op))
+ if (!stitch_init_all(C, op)) {
return OPERATOR_CANCELLED;
+ }
WM_event_add_modal_handler(C, op);
@@ -2469,8 +2491,9 @@ static void stitch_exit(bContext *C, wmOperator *op, int finished)
MEM_freeN(objs_selection_count);
}
- if (sa)
+ if (sa) {
ED_workspace_status_text(C, NULL);
+ }
ED_region_draw_cb_exit(CTX_wm_region(C)->type, ssc->draw_handle);
@@ -2504,8 +2527,9 @@ static int stitch_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
- if (!stitch_init_all(C, op))
+ if (!stitch_init_all(C, op)) {
return OPERATOR_CANCELLED;
+ }
if (stitch_process_data_all((StitchStateContainer *)op->customdata, scene, 1)) {
stitch_exit(C, op, 1);
return OPERATOR_FINISHED;
diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
index 92f7873d5c1..85393925802 100644
--- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c
+++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
@@ -84,10 +84,12 @@ static void modifier_unwrap_state(Object *obedit, Scene *scene, bool *r_use_subs
/* subsurf will take the modifier settings only if modifier is first or right after mirror */
if (subsurf) {
- if (md && md->type == eModifierType_Subsurf)
+ if (md && md->type == eModifierType_Subsurf) {
subsurf = true;
- else
+ }
+ else {
subsurf = false;
+ }
}
*r_use_subsurf = subsurf;
@@ -105,14 +107,17 @@ static bool ED_uvedit_ensure_uvs(bContext *C, Scene *UNUSED(scene), Object *obed
SpaceImage *sima;
int cd_loop_uv_offset;
- if (ED_uvedit_test(obedit))
+ if (ED_uvedit_test(obedit)) {
return 1;
+ }
- if (em && em->bm->totface && !CustomData_has_layer(&em->bm->ldata, CD_MLOOPUV))
+ if (em && em->bm->totface && !CustomData_has_layer(&em->bm->ldata, CD_MLOOPUV)) {
ED_mesh_uv_texture_add(obedit->data, NULL, true, true);
+ }
- if (!ED_uvedit_test(obedit))
+ if (!ED_uvedit_test(obedit)) {
return 0;
+ }
cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
@@ -129,10 +134,12 @@ static bool ED_uvedit_ensure_uvs(bContext *C, Scene *UNUSED(scene), Object *obed
ima = sima->image;
if (ima) {
- if (ima->type == IMA_TYPE_R_RESULT || ima->type == IMA_TYPE_COMPOSITE)
+ if (ima->type == IMA_TYPE_R_RESULT || ima->type == IMA_TYPE_COMPOSITE) {
ima = NULL;
- else
+ }
+ else {
break;
+ }
}
}
}
@@ -176,19 +183,23 @@ static bool uvedit_have_selection(Scene *scene, BMEditMesh *em, const UnwrapOpti
* so we can cancel the operator early */
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
if (scene->toolsettings->uv_flag & UV_SYNC_SELECTION) {
- if (BM_elem_flag_test(efa, BM_ELEM_HIDDEN))
+ if (BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) {
continue;
+ }
}
- else if (!BM_elem_flag_test(efa, BM_ELEM_SELECT))
+ else if (!BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
- if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset))
+ if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) {
break;
+ }
}
- if (options->topology_from_uvs && !l)
+ if (options->topology_from_uvs && !l) {
continue;
+ }
return true;
}
@@ -286,8 +297,9 @@ static ParamHandle *construct_param_handle(Scene *scene,
ED_uvedit_get_aspect(scene, ob, bm, &aspx, &aspy);
- if (aspx != aspy)
+ if (aspx != aspy) {
param_aspect_ratio(handle, aspx, aspy);
+ }
}
/* we need the vert indices */
@@ -432,8 +444,9 @@ static void texface_from_original_index(BMFace *efa,
*pin = 0;
*select = 1;
- if (index == ORIGINDEX_NONE)
+ if (index == ORIGINDEX_NONE) {
return;
+ }
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
if (BM_elem_index_get(l->v) == index) {
@@ -495,8 +508,9 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene,
ED_uvedit_get_aspect(scene, ob, em->bm, &aspx, &aspy);
- if (aspx != aspy)
+ if (aspx != aspy) {
param_aspect_ratio(handle, aspx, aspy);
+ }
}
/* number of subdivisions to perform */
@@ -531,8 +545,9 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene,
BM_mesh_elem_table_ensure(em->bm, BM_EDGE | BM_FACE);
/* map subsurfed faces to original editFaces */
- for (i = 0; i < numOfFaces; i++)
+ for (i = 0; i < numOfFaces; i++) {
faceMap[i] = BM_face_at_index(em->bm, origPolyIndices[i]);
+ }
edgeMap = MEM_mallocN(numOfEdges * sizeof(BMEdge *), "unwrap_edit_edge_map");
@@ -553,8 +568,9 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene,
BMFace *origFace = faceMap[i];
if (scene->toolsettings->uv_flag & UV_SYNC_SELECTION) {
- if (BM_elem_flag_test(origFace, BM_ELEM_HIDDEN))
+ if (BM_elem_flag_test(origFace, BM_ELEM_HIDDEN)) {
continue;
+ }
}
else {
if (BM_elem_flag_test(origFace, BM_ELEM_HIDDEN) ||
@@ -678,8 +694,9 @@ static bool minimize_stretch_init(bContext *C, wmOperator *op)
ms->lasttime = PIL_check_seconds_timer();
param_stretch_begin(ms->handle);
- if (ms->blend != 0.0f)
+ if (ms->blend != 0.0f) {
param_stretch_blend(ms->handle, ms->blend);
+ }
op->customdata = ms;
@@ -738,13 +755,16 @@ static void minimize_stretch_exit(bContext *C, wmOperator *op, bool cancel)
ED_area_status_text(sa, NULL);
ED_workspace_status_text(C, NULL);
- if (ms->timer)
+ if (ms->timer) {
WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), ms->timer);
+ }
- if (cancel)
+ if (cancel) {
param_flush_restore(ms->handle);
- else
+ }
+ else {
param_flush(ms->handle);
+ }
param_stretch_end(ms->handle);
param_delete(ms->handle);
@@ -770,12 +790,14 @@ static int minimize_stretch_exec(bContext *C, wmOperator *op)
{
int i, iterations;
- if (!minimize_stretch_init(C, op))
+ if (!minimize_stretch_init(C, op)) {
return OPERATOR_CANCELLED;
+ }
iterations = RNA_int_get(op->ptr, "iterations");
- for (i = 0; i < iterations; i++)
+ for (i = 0; i < iterations; i++) {
minimize_stretch_iteration(C, op, false);
+ }
minimize_stretch_exit(C, op, false);
return OPERATOR_FINISHED;
@@ -785,8 +807,9 @@ static int minimize_stretch_invoke(bContext *C, wmOperator *op, const wmEvent *U
{
MinStretch *ms;
- if (!minimize_stretch_init(C, op))
+ if (!minimize_stretch_init(C, op)) {
return OPERATOR_CANCELLED;
+ }
minimize_stretch_iteration(C, op, true);
@@ -964,10 +987,12 @@ static int pack_islands_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- if (RNA_struct_property_is_set(op->ptr, "margin"))
+ if (RNA_struct_property_is_set(op->ptr, "margin")) {
scene->toolsettings->uvcalc_margin = RNA_float_get(op->ptr, "margin");
- else
+ }
+ else {
RNA_float_set(op->ptr, "margin", scene->toolsettings->uvcalc_margin);
+ }
uvedit_pack_islands_multi(scene, objects, objects_len, &options, rotate, ignore_pinned);
@@ -1081,10 +1106,12 @@ void ED_uvedit_live_unwrap_begin(Scene *scene, Object *obedit)
.correct_aspect = (scene->toolsettings->uvcalc_flag & UVCALC_NO_ASPECT_CORRECT) == 0,
};
- if (use_subsurf)
+ if (use_subsurf) {
handle = construct_param_handle_subsurfed(scene, obedit, em, &options);
- else
+ }
+ else {
handle = construct_param_handle(scene, obedit, em->bm, &options);
+ }
param_lscm_begin(handle, PARAM_TRUE, abf);
@@ -1119,8 +1146,9 @@ void ED_uvedit_live_unwrap_end(short cancel)
if (g_live_unwrap.handles) {
for (int i = 0; i < g_live_unwrap.len; i++) {
param_lscm_end(g_live_unwrap.handles[i]);
- if (cancel)
+ if (cancel) {
param_flush_restore(g_live_unwrap.handles[i]);
+ }
param_delete(g_live_unwrap.handles[i]);
}
MEM_freeN(g_live_unwrap.handles);
@@ -1232,10 +1260,12 @@ static void uv_map_rotation_matrix_ex(float result[4][4],
float sideangle = 0.0f, upangle = 0.0f;
/* get rotation of the current view matrix */
- if (rv3d)
+ if (rv3d) {
copy_m4_m4(viewmatrix, rv3d->viewmat);
- else
+ }
+ else {
unit_m4(viewmatrix);
+ }
/* but shifting */
copy_v4_fl(viewmatrix[3], 0.0f);
@@ -1300,17 +1330,21 @@ static void uv_map_transform(bContext *C, wmOperator *op, float rotmat[4][4])
}
else {
upangledeg = 0.0f;
- if (align == POLAR_ZY)
+ if (align == POLAR_ZY) {
sideangledeg = 0.0f;
- else
+ }
+ else {
sideangledeg = 90.0f;
+ }
}
/* be compatible to the "old" sphere/cylinder mode */
- if (direction == ALIGN_TO_OBJECT)
+ if (direction == ALIGN_TO_OBJECT) {
unit_m4(rotmat);
- else
+ }
+ else {
uv_map_rotation_matrix(rotmat, rv3d, obedit, upangledeg, sideangledeg, radius);
+ }
}
static void uv_transform_properties(wmOperatorType *ot, int radius)
@@ -1343,7 +1377,7 @@ static void uv_transform_properties(wmOperatorType *ot, int radius)
VIEW_ON_EQUATOR,
"Align",
"How to determine rotation around the pole");
- if (radius)
+ if (radius) {
RNA_def_float(ot->srna,
"radius",
1.0f,
@@ -1353,6 +1387,7 @@ static void uv_transform_properties(wmOperatorType *ot, int radius)
"Radius of the sphere or cylinder",
0.0001f,
100.0f);
+ }
}
static void correct_uv_aspect(Scene *scene, Object *ob, BMEditMesh *em)
@@ -1367,15 +1402,17 @@ static void correct_uv_aspect(Scene *scene, Object *ob, BMEditMesh *em)
ED_uvedit_get_aspect(scene, ob, em->bm, &aspx, &aspy);
- if (aspx == aspy)
+ if (aspx == aspy) {
return;
+ }
if (aspx > aspy) {
scale = aspy / aspx;
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!BM_elem_flag_test(efa, BM_ELEM_SELECT))
+ if (!BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
@@ -1387,8 +1424,9 @@ static void correct_uv_aspect(Scene *scene, Object *ob, BMEditMesh *em)
scale = aspx / aspy;
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!BM_elem_flag_test(efa, BM_ELEM_SELECT))
+ if (!BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
@@ -1442,14 +1480,16 @@ static void uv_map_clip_correct_multi(Scene *scene,
const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
/* correct for image aspect ratio */
- if (correct_aspect)
+ if (correct_aspect) {
correct_uv_aspect(scene, ob, em);
+ }
if (scale_to_bounds) {
/* find uv limits */
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!BM_elem_flag_test(efa, BM_ELEM_SELECT))
+ if (!BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
@@ -1460,8 +1500,9 @@ static void uv_map_clip_correct_multi(Scene *scene,
else if (clip_to_bounds) {
/* clipping and wrapping */
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!BM_elem_flag_test(efa, BM_ELEM_SELECT))
+ if (!BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
@@ -1477,10 +1518,12 @@ static void uv_map_clip_correct_multi(Scene *scene,
dx = (max[0] - min[0]);
dy = (max[1] - min[1]);
- if (dx > 0.0f)
+ if (dx > 0.0f) {
dx = 1.0f / dx;
- if (dy > 0.0f)
+ }
+ if (dy > 0.0f) {
dy = 1.0f / dy;
+ }
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *ob = objects[ob_index];
@@ -1489,8 +1532,9 @@ static void uv_map_clip_correct_multi(Scene *scene,
const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!BM_elem_flag_test(efa, BM_ELEM_SELECT))
+ if (!BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
@@ -1522,10 +1566,12 @@ static void uvedit_unwrap(Scene *scene, Object *obedit, const UnwrapOptions *opt
modifier_unwrap_state(obedit, scene, &use_subsurf);
ParamHandle *handle;
- if (use_subsurf)
+ if (use_subsurf) {
handle = construct_param_handle_subsurfed(scene, obedit, em, options);
- else
+ }
+ else {
handle = construct_param_handle(scene, obedit, em->bm, options);
+ }
param_lscm_begin(handle, PARAM_FALSE, scene->toolsettings->unwrapper == 0);
param_lscm_solve(handle);
@@ -1655,31 +1701,41 @@ static int unwrap_exec(bContext *C, wmOperator *op)
}
/* remember last method for live unwrap */
- if (RNA_struct_property_is_set(op->ptr, "method"))
+ if (RNA_struct_property_is_set(op->ptr, "method")) {
scene->toolsettings->unwrapper = method;
- else
+ }
+ else {
RNA_enum_set(op->ptr, "method", scene->toolsettings->unwrapper);
+ }
/* remember packing margin */
- if (RNA_struct_property_is_set(op->ptr, "margin"))
+ if (RNA_struct_property_is_set(op->ptr, "margin")) {
scene->toolsettings->uvcalc_margin = RNA_float_get(op->ptr, "margin");
- else
+ }
+ else {
RNA_float_set(op->ptr, "margin", scene->toolsettings->uvcalc_margin);
+ }
- if (options.fill_holes)
+ if (options.fill_holes) {
scene->toolsettings->uvcalc_flag |= UVCALC_FILLHOLES;
- else
+ }
+ else {
scene->toolsettings->uvcalc_flag &= ~UVCALC_FILLHOLES;
+ }
- if (options.correct_aspect)
+ if (options.correct_aspect) {
scene->toolsettings->uvcalc_flag &= ~UVCALC_NO_ASPECT_CORRECT;
- else
+ }
+ else {
scene->toolsettings->uvcalc_flag |= UVCALC_NO_ASPECT_CORRECT;
+ }
- if (use_subsurf)
+ if (use_subsurf) {
scene->toolsettings->uvcalc_flag |= UVCALC_USESUBSURF;
- else
+ }
+ else {
scene->toolsettings->uvcalc_flag &= ~UVCALC_USESUBSURF;
+ }
/* execute unwrap */
uvedit_unwrap_multi(scene, objects, objects_len, &options);
@@ -1748,11 +1804,13 @@ static int uv_from_view_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSE
PropertyRNA *prop;
prop = RNA_struct_find_property(op->ptr, "camera_bounds");
- if (!RNA_property_is_set(op->ptr, prop))
+ if (!RNA_property_is_set(op->ptr, prop)) {
RNA_property_boolean_set(op->ptr, prop, (camera != NULL));
+ }
prop = RNA_struct_find_property(op->ptr, "correct_aspect");
- if (!RNA_property_is_set(op->ptr, prop))
+ if (!RNA_property_is_set(op->ptr, prop)) {
RNA_property_boolean_set(op->ptr, prop, (camera == NULL));
+ }
return uv_from_view_exec(C, op);
}
@@ -1808,8 +1866,9 @@ static int uv_from_view_exec(bContext *C, wmOperator *op)
uv_map_rotation_matrix_ex(rotmat, rv3d, obedit, 90.0f, 0.0f, 1.0f, objects_pos_offset);
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!BM_elem_flag_test(efa, BM_ELEM_SELECT))
+ if (!BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
@@ -1828,8 +1887,9 @@ static int uv_from_view_exec(bContext *C, wmOperator *op)
if (uci) {
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!BM_elem_flag_test(efa, BM_ELEM_SELECT))
+ if (!BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
@@ -1845,8 +1905,9 @@ static int uv_from_view_exec(bContext *C, wmOperator *op)
copy_m4_m4(rotmat, obedit->obmat);
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!BM_elem_flag_test(efa, BM_ELEM_SELECT))
+ if (!BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
@@ -1886,8 +1947,9 @@ static bool uv_from_view_poll(bContext *C)
{
RegionView3D *rv3d = CTX_wm_region_view3d(C);
- if (!ED_operator_uvmap(C))
+ if (!ED_operator_uvmap(C)) {
return 0;
+ }
return (rv3d != NULL);
}
@@ -1980,8 +2042,9 @@ static void uv_sphere_project(float target[2],
map_to_sphere(&target[0], &target[1], pv[0], pv[1], pv[2]);
/* split line is always zero */
- if (target[0] >= 1.0f)
+ if (target[0] >= 1.0f) {
target[0] -= 1.0f;
+ }
}
static void uv_map_mirror(BMEditMesh *em, BMFace *efa)
@@ -2001,15 +2064,18 @@ static void uv_map_mirror(BMEditMesh *em, BMFace *efa)
}
mi = 0;
- for (i = 1; i < efa->len; i++)
- if (uvs[i][0] > uvs[mi][0])
+ for (i = 1; i < efa->len; i++) {
+ if (uvs[i][0] > uvs[mi][0]) {
mi = i;
+ }
+ }
for (i = 0; i < efa->len; i++) {
if (i != mi) {
dx = uvs[mi][0] - uvs[i][0];
- if (dx > 0.5f)
+ if (dx > 0.5f) {
uvs[i][0] += 1.0f;
+ }
}
}
}
@@ -2047,8 +2113,9 @@ static int sphere_project_exec(bContext *C, wmOperator *op)
uv_map_transform_center(scene, v3d, obedit, em, center, NULL);
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!BM_elem_flag_test(efa, BM_ELEM_SELECT))
+ if (!BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
@@ -2102,8 +2169,9 @@ static void uv_cylinder_project(float target[2],
map_to_tube(&target[0], &target[1], pv[0], pv[1], pv[2]);
/* split line is always zero */
- if (target[0] >= 1.0f)
+ if (target[0] >= 1.0f) {
target[0] -= 1.0f;
+ }
}
static int cylinder_project_exec(bContext *C, wmOperator *op)
@@ -2139,8 +2207,9 @@ static int cylinder_project_exec(bContext *C, wmOperator *op)
uv_map_transform_center(scene, v3d, obedit, em, center, NULL);
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!BM_elem_flag_test(efa, BM_ELEM_SELECT))
+ if (!BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
continue;
+ }
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
@@ -2209,8 +2278,9 @@ static void uvedit_unwrap_cube_project(BMesh *bm,
BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) {
/* tf = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY); */ /* UNUSED */
- if (use_select && !BM_elem_flag_test(efa, BM_ELEM_SELECT))
+ if (use_select && !BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
continue;
+ }
axis_dominant_v3(&cox, &coy, efa->no);
@@ -2340,6 +2410,7 @@ void ED_uvedit_add_simple_uvs(Main *bmain, Scene *scene, Object *ob)
BM_mesh_bm_to_me(bmain, bm, me, (&(struct BMeshToMeshParams){0}));
BM_mesh_free(bm);
- if (sync_selection)
+ if (sync_selection) {
scene->toolsettings->uv_flag |= UV_SYNC_SELECTION;
+ }
}