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

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSybren A. Stüvel <sybren@blender.org>2020-07-03 15:38:26 +0300
committerSybren A. Stüvel <sybren@blender.org>2020-07-03 15:48:38 +0300
commit9dce2c9d1432d2798854b909e6262fbfb94ce3c7 (patch)
tree863025e2198da67fab539b16c107b9569a1fb14c /source/blender
parent20869065b86263f72e469df17354bd6631be3712 (diff)
Cleanup: Editors/GPencil, Clang-Tidy else-after-return fixes
This addresses warnings from Clang-Tidy's `readability-else-after-return` rule in the `source/blender/editors/gpencil` module. No functional changes.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/editors/gpencil/annotate_paint.c93
-rw-r--r--source/blender/editors/gpencil/gpencil_data.c18
-rw-r--r--source/blender/editors/gpencil/gpencil_edit.c24
-rw-r--r--source/blender/editors/gpencil/gpencil_fill.c16
-rw-r--r--source/blender/editors/gpencil/gpencil_interpolate.c10
-rw-r--r--source/blender/editors/gpencil/gpencil_merge.c3
-rw-r--r--source/blender/editors/gpencil/gpencil_ops.c7
-rw-r--r--source/blender/editors/gpencil/gpencil_paint.c109
-rw-r--r--source/blender/editors/gpencil/gpencil_primitive.c19
-rw-r--r--source/blender/editors/gpencil/gpencil_sculpt_paint.c6
-rw-r--r--source/blender/editors/gpencil/gpencil_select.c16
-rw-r--r--source/blender/editors/gpencil/gpencil_utils.c55
12 files changed, 155 insertions, 221 deletions
diff --git a/source/blender/editors/gpencil/annotate_paint.c b/source/blender/editors/gpencil/annotate_paint.c
index 9d80a75b959..6f700f6c4b8 100644
--- a/source/blender/editors/gpencil/annotate_paint.c
+++ b/source/blender/editors/gpencil/annotate_paint.c
@@ -233,9 +233,7 @@ static bool annotation_draw_poll(bContext *C)
if (ED_gpencil_session_active() == 0) {
return true;
}
- else {
- CTX_wm_operator_poll_msg_set(C, "Annotation operator is already active");
- }
+ CTX_wm_operator_poll_msg_set(C, "Annotation operator is already active");
}
else {
CTX_wm_operator_poll_msg_set(C, "Failed to find Annotation data to draw into");
@@ -281,40 +279,39 @@ static bool annotation_stroke_filtermval(tGPsdata *p, const float mval[2], float
/* if buffer is empty, just let this go through (i.e. so that dots will work) */
if (p->gpd->runtime.sbuffer_used == 0) {
return true;
-
- /* 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
- */
}
+
+ /* 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
+ */
+
/* If lazy mouse, check minimum distance. */
- else if (p->flags & GP_PAINTFLAG_USE_STABILIZER_TEMP) {
+ if (p->flags & GP_PAINTFLAG_USE_STABILIZER_TEMP) {
if ((dx * dx + dy * dy) > (p->stabilizer_radius * p->stabilizer_radius)) {
return true;
}
- else {
- /* If the mouse is moving within the radius of the last move,
- * don't update the mouse position. This allows sharp turns. */
- copy_v2_v2(p->mval, p->mvalo);
- return false;
- }
- }
- else if ((dx > MIN_MANHATTEN_PX) && (dy > MIN_MANHATTEN_PX)) {
- return true;
- /* 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.
- */
+ /* If the mouse is moving within the radius of the last move,
+ * don't update the mouse position. This allows sharp turns. */
+ copy_v2_v2(p->mval, p->mvalo);
+ return false;
}
- else if ((dx * dx + dy * dy) > MIN_EUCLIDEAN_PX * MIN_EUCLIDEAN_PX) {
- return true;
- /* mouse 'didn't move' */
+ if ((dx > MIN_MANHATTEN_PX) && (dy > MIN_MANHATTEN_PX)) {
+ return true;
}
- else {
- return false;
+
+ /* 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.
+ */
+ if ((dx * dx + dy * dy) > MIN_EUCLIDEAN_PX * MIN_EUCLIDEAN_PX) {
+ return true;
}
+
+ /* mouse 'didn't move' */
+ return false;
}
/* convert screen-coordinates to buffer-coordinates */
@@ -594,7 +591,8 @@ static short annotation_stroke_addpoint(tGPsdata *p,
/* can keep carrying on this way :) */
return GP_STROKEADD_NORMAL;
}
- else if (p->paintmode == GP_PAINTMODE_DRAW) { /* normal drawing */
+
+ if (p->paintmode == GP_PAINTMODE_DRAW) { /* normal drawing */
/* check if still room in buffer or add more */
gpd->runtime.sbuffer = ED_gpencil_sbuffer_ensure(
gpd->runtime.sbuffer, &gpd->runtime.sbuffer_size, &gpd->runtime.sbuffer_used, false);
@@ -624,7 +622,8 @@ static short annotation_stroke_addpoint(tGPsdata *p,
return GP_STROKEADD_NORMAL;
}
- else if (p->paintmode == GP_PAINTMODE_DRAW_POLY) {
+
+ if (p->paintmode == GP_PAINTMODE_DRAW_POLY) {
/* get pointer to destination point */
pt = (tGPspoint *)gpd->runtime.sbuffer;
@@ -1083,9 +1082,7 @@ static float view3d_point_depth(const RegionView3D *rv3d, const float co[3])
if (rv3d->is_persp) {
return ED_view3d_calc_zfac(rv3d, co, NULL);
}
- else {
- return -dot_v3v3(rv3d->viewinv[2], co);
- }
+ return -dot_v3v3(rv3d->viewinv[2], co);
}
/* only erase stroke points that are visible (3d view) */
@@ -1412,17 +1409,16 @@ static bool annotation_session_initdata(bContext *C, tGPsdata *p)
}
return 0;
}
- else {
- /* if no existing GPencil block exists, add one */
- if (*gpd_ptr == NULL) {
- bGPdata *gpd = BKE_gpencil_data_addnew(bmain, "Annotations");
- *gpd_ptr = gpd;
- /* mark datablock as being used for annotations */
- gpd->flag |= GP_DATA_ANNOTATIONS;
- }
- p->gpd = *gpd_ptr;
+ /* if no existing GPencil block exists, add one */
+ if (*gpd_ptr == NULL) {
+ bGPdata *gpd = BKE_gpencil_data_addnew(bmain, "Annotations");
+ *gpd_ptr = gpd;
+
+ /* mark datablock as being used for annotations */
+ gpd->flag |= GP_DATA_ANNOTATIONS;
}
+ p->gpd = *gpd_ptr;
if (ED_gpencil_session_active() == 0) {
/* initialize undo stack,
@@ -1570,9 +1566,8 @@ static void annotation_paint_initstroke(tGPsdata *p,
}
return;
}
- else {
- p->gpf->flag |= GP_FRAME_PAINT;
- }
+
+ p->gpf->flag |= GP_FRAME_PAINT;
}
/* set 'eraser' for this stroke if using eraser */
@@ -2200,9 +2195,8 @@ static int annotation_draw_exec(bContext *C, wmOperator *op)
/* printf("\tGP - no valid data\n"); */
return OPERATOR_CANCELLED;
}
- else {
- p = op->customdata;
- }
+
+ p = op->customdata;
/* printf("\tGP - Start redrawing stroke\n"); */
@@ -2285,9 +2279,8 @@ static int annotation_draw_invoke(bContext *C, wmOperator *op, const wmEvent *ev
}
return OPERATOR_CANCELLED;
}
- else {
- p = op->customdata;
- }
+
+ p = op->customdata;
/* if empty erase capture and finish */
if (p->status == GP_STATUS_CAPTURE) {
diff --git a/source/blender/editors/gpencil/gpencil_data.c b/source/blender/editors/gpencil/gpencil_data.c
index 44b866d81d7..96b0296a7de 100644
--- a/source/blender/editors/gpencil/gpencil_data.c
+++ b/source/blender/editors/gpencil/gpencil_data.c
@@ -176,13 +176,11 @@ static int gpencil_data_unlink_exec(bContext *C, wmOperator *op)
BKE_report(op->reports, RPT_ERROR, "Nowhere for grease pencil data to go");
return OPERATOR_CANCELLED;
}
- else {
- /* just unlink datablock now, decreasing its user count */
- bGPdata *gpd = (*gpd_ptr);
+ /* just unlink datablock now, decreasing its user count */
+ bGPdata *gpd = (*gpd_ptr);
- id_us_min(&gpd->id);
- *gpd_ptr = NULL;
- }
+ id_us_min(&gpd->id);
+ *gpd_ptr = NULL;
/* notifiers */
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
@@ -1125,9 +1123,7 @@ static int gpencil_isolate_layer_exec(bContext *C, wmOperator *op)
if (gpl == layer) {
continue;
}
- else {
- gpl->flag |= flags;
- }
+ gpl->flag |= flags;
}
}
else {
@@ -2913,9 +2909,7 @@ static int gpencil_material_isolate_exec(bContext *C, wmOperator *op)
if (gp_style == active_color) {
continue;
}
- else {
- gp_style->flag |= flags;
- }
+ gp_style->flag |= flags;
DEG_id_tag_update(&ma->id, ID_RECALC_COPY_ON_WRITE);
}
}
diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c
index 78e2812fdef..f8010edfcdd 100644
--- a/source/blender/editors/gpencil/gpencil_edit.c
+++ b/source/blender/editors/gpencil/gpencil_edit.c
@@ -1490,13 +1490,15 @@ static int gpencil_strokes_paste_exec(bContext *C, wmOperator *op)
BKE_report(op->reports, RPT_ERROR, "Operator not supported in multiframe edition");
return OPERATOR_CANCELLED;
}
- else if (BLI_listbase_is_empty(&gpencil_strokes_copypastebuf)) {
+
+ if (BLI_listbase_is_empty(&gpencil_strokes_copypastebuf)) {
BKE_report(op->reports,
RPT_ERROR,
"No strokes to paste, select and copy some points before trying again");
return OPERATOR_CANCELLED;
}
- else if (gpl == NULL) {
+
+ if (gpl == NULL) {
/* no active layer - let's just create one */
gpl = BKE_gpencil_layer_addnew(gpd, DATA_("GP_Layer"), true);
}
@@ -1955,10 +1957,8 @@ static int gpencil_actframe_delete_all_exec(bContext *C, wmOperator *op)
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
return OPERATOR_FINISHED;
}
- else {
- BKE_report(op->reports, RPT_ERROR, "No active frame(s) to delete");
- return OPERATOR_CANCELLED;
- }
+ BKE_report(op->reports, RPT_ERROR, "No active frame(s) to delete");
+ return OPERATOR_CANCELLED;
}
void GPENCIL_OT_active_frames_delete_all(wmOperatorType *ot)
@@ -2050,9 +2050,7 @@ static int gpencil_delete_selected_strokes(bContext *C)
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
return OPERATOR_FINISHED;
}
- else {
- return OPERATOR_CANCELLED;
- }
+ return OPERATOR_CANCELLED;
}
/* ----------------------------------- */
@@ -2268,9 +2266,7 @@ static int gpencil_dissolve_selected_points(bContext *C, eGP_DissolveMode mode)
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
return OPERATOR_FINISHED;
}
- else {
- return OPERATOR_CANCELLED;
- }
+ return OPERATOR_CANCELLED;
}
/* ----------------------------------- */
@@ -2583,9 +2579,7 @@ static int gpencil_delete_selected_points(bContext *C)
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
return OPERATOR_FINISHED;
}
- else {
- return OPERATOR_CANCELLED;
- }
+ return OPERATOR_CANCELLED;
}
/* simple wrapper to external call */
diff --git a/source/blender/editors/gpencil/gpencil_fill.c b/source/blender/editors/gpencil/gpencil_fill.c
index 35bd44b88f9..8c901da100d 100644
--- a/source/blender/editors/gpencil/gpencil_fill.c
+++ b/source/blender/editors/gpencil/gpencil_fill.c
@@ -1199,15 +1199,12 @@ static bool gpencil_fill_poll(bContext *C)
return true;
}
- else {
- CTX_wm_operator_poll_msg_set(C, "Active region not valid for filling operator");
- return false;
- }
- }
- else {
- CTX_wm_operator_poll_msg_set(C, "Active region not set");
+ CTX_wm_operator_poll_msg_set(C, "Active region not valid for filling operator");
return false;
}
+
+ CTX_wm_operator_poll_msg_set(C, "Active region not set");
+ return false;
}
/* Allocate memory and initialize values */
@@ -1388,9 +1385,8 @@ static int gpencil_fill_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSE
}
return OPERATOR_CANCELLED;
}
- else {
- tgpf = op->customdata;
- }
+
+ tgpf = op->customdata;
/* Enable custom drawing handlers to show help lines */
if (tgpf->flag & GP_BRUSH_FILL_SHOW_HELPLINES) {
diff --git a/source/blender/editors/gpencil/gpencil_interpolate.c b/source/blender/editors/gpencil/gpencil_interpolate.c
index 5e653187edb..179f621205b 100644
--- a/source/blender/editors/gpencil/gpencil_interpolate.c
+++ b/source/blender/editors/gpencil/gpencil_interpolate.c
@@ -558,9 +558,7 @@ static int gpencil_interpolate_invoke(bContext *C, wmOperator *op, const wmEvent
}
return OPERATOR_CANCELLED;
}
- else {
- tgpi = op->customdata;
- }
+ tgpi = op->customdata;
/* set cursor to indicate modal */
WM_cursor_modal_set(win, WM_CURSOR_EW_SCROLL);
@@ -687,10 +685,8 @@ static int gpencil_interpolate_modal(bContext *C, wmOperator *op, const wmEvent
break;
}
- else {
- /* unhandled event - allow to pass through */
- return OPERATOR_RUNNING_MODAL | OPERATOR_PASS_THROUGH;
- }
+ /* unhandled event - allow to pass through */
+ return OPERATOR_RUNNING_MODAL | OPERATOR_PASS_THROUGH;
}
}
diff --git a/source/blender/editors/gpencil/gpencil_merge.c b/source/blender/editors/gpencil/gpencil_merge.c
index cf806e68837..53dbc1620d0 100644
--- a/source/blender/editors/gpencil/gpencil_merge.c
+++ b/source/blender/editors/gpencil/gpencil_merge.c
@@ -73,7 +73,8 @@ static int gpencil_sort_points(const void *a1, const void *a2)
if (ps1->factor < ps2->factor) {
return -1;
}
- else if (ps1->factor > ps2->factor) {
+
+ if (ps1->factor > ps2->factor) {
return 1;
}
diff --git a/source/blender/editors/gpencil/gpencil_ops.c b/source/blender/editors/gpencil/gpencil_ops.c
index e645668ef1c..efee05f7da3 100644
--- a/source/blender/editors/gpencil/gpencil_ops.c
+++ b/source/blender/editors/gpencil/gpencil_ops.c
@@ -184,10 +184,9 @@ static bool gpencil_stroke_sculptmode_poll(bContext *C)
if (area->spacetype != SPACE_VIEW3D) {
return ((gpd) && (gpd->flag & GP_DATA_STROKE_EDITMODE));
}
- else {
- if ((ob) && (ob->type == OB_GPENCIL)) {
- return GPENCIL_SCULPT_MODE(gpd);
- }
+
+ if ((ob) && (ob->type == OB_GPENCIL)) {
+ return GPENCIL_SCULPT_MODE(gpd);
}
return 0;
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index 95133244dfb..d3ff7f8a4d2 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -332,10 +332,9 @@ static bool gpencil_draw_poll(bContext *C)
return true;
}
- else {
- CTX_wm_operator_poll_msg_set(C, "Active region not set");
- return false;
- }
+
+ CTX_wm_operator_poll_msg_set(C, "Active region not set");
+ return false;
}
/* check if projecting strokes into 3d-geometry in the 3D-View */
@@ -375,38 +374,33 @@ static bool gpencil_stroke_filtermval(tGPsdata *p, const float mval[2], float mv
return true;
}
/* if lazy mouse, check minimum distance */
- else if (GPENCIL_LAZY_MODE(brush, p->shift)) {
+ if (GPENCIL_LAZY_MODE(brush, p->shift)) {
brush->gpencil_settings->flag |= GP_BRUSH_STABILIZE_MOUSE_TEMP;
if ((dx * dx + dy * dy) > (brush->smooth_stroke_radius * brush->smooth_stroke_radius)) {
return true;
}
- else {
- /* If the mouse is moving within the radius of the last move,
- * don't update the mouse position. This allows sharp turns. */
- copy_v2_v2(p->mval, p->mvalo);
- return false;
- }
+
+ /* If the mouse is moving within the radius of the last move,
+ * don't update the mouse position. This allows sharp turns. */
+ copy_v2_v2(p->mval, p->mvalo);
+ return false;
}
/* 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)) {
+ if ((dx > MIN_MANHATTEN_PX) && (dy > MIN_MANHATTEN_PX)) {
return true;
-
- /* 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) {
+ /* 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.
+ */
+ if ((dx * dx + dy * dy) > MIN_EUCLIDEAN_PX * MIN_EUCLIDEAN_PX) {
return true;
-
- /* mouse 'didn't move' */
- }
- else {
- return false;
}
+ /* mouse 'didn't move' */
+ return false;
}
/* reproject stroke to plane locked to axis in 3d cursor location */
@@ -816,7 +810,8 @@ static short gpencil_stroke_addpoint(tGPsdata *p,
/* can keep carrying on this way :) */
return GP_STROKEADD_NORMAL;
}
- else if (p->paintmode == GP_PAINTMODE_DRAW) { /* normal drawing */
+
+ if (p->paintmode == GP_PAINTMODE_DRAW) { /* normal drawing */
/* check if still room in buffer or add more */
gpd->runtime.sbuffer = ED_gpencil_sbuffer_ensure(
gpd->runtime.sbuffer, &gpd->runtime.sbuffer_size, &gpd->runtime.sbuffer_used, false);
@@ -955,10 +950,8 @@ static void gpencil_stroke_newfrombuffer(tGPsdata *p)
if (ptc->pressure > 0.001f) {
break;
}
- else {
- gpd->runtime.sbuffer_used = last_i - 1;
- CLAMP_MIN(gpd->runtime.sbuffer_used, 1);
- }
+ gpd->runtime.sbuffer_used = last_i - 1;
+ CLAMP_MIN(gpd->runtime.sbuffer_used, 1);
last_i--;
}
@@ -1303,9 +1296,7 @@ static float view3d_point_depth(const RegionView3D *rv3d, const float co[3])
if (rv3d->is_persp) {
return ED_view3d_calc_zfac(rv3d, co, NULL);
}
- else {
- return -dot_v3v3(rv3d->viewinv[2], co);
- }
+ return -dot_v3v3(rv3d->viewinv[2], co);
}
/* only erase stroke points that are visible */
@@ -1697,7 +1688,7 @@ static void gpencil_stroke_doeraser(tGPsdata *p)
if (BKE_gpencil_layer_is_editable(gpl) == false) {
continue;
}
- else if (gpf == NULL) {
+ if (gpf == NULL) {
continue;
}
/* calculate difference matrix */
@@ -1777,19 +1768,18 @@ static Brush *gpencil_get_default_eraser(Main *bmain, ToolSettings *ts)
return brush_dft;
}
/* create a new soft eraser brush */
- else {
- brush_dft = BKE_brush_add_gpencil(bmain, ts, "Soft Eraser", OB_MODE_PAINT_GPENCIL);
- brush_dft->size = 30.0f;
- brush_dft->gpencil_settings->flag |= GP_BRUSH_DEFAULT_ERASER;
- brush_dft->gpencil_settings->icon_id = GP_BRUSH_ICON_ERASE_SOFT;
- brush_dft->gpencil_tool = GPAINT_TOOL_ERASE;
- brush_dft->gpencil_settings->eraser_mode = GP_BRUSH_ERASER_SOFT;
- /* reset current brush */
- BKE_paint_brush_set(paint, brush_prev);
+ brush_dft = BKE_brush_add_gpencil(bmain, ts, "Soft Eraser", OB_MODE_PAINT_GPENCIL);
+ brush_dft->size = 30.0f;
+ brush_dft->gpencil_settings->flag |= GP_BRUSH_DEFAULT_ERASER;
+ brush_dft->gpencil_settings->icon_id = GP_BRUSH_ICON_ERASE_SOFT;
+ brush_dft->gpencil_tool = GPAINT_TOOL_ERASE;
+ brush_dft->gpencil_settings->eraser_mode = GP_BRUSH_ERASER_SOFT;
- return brush_dft;
- }
+ /* reset current brush */
+ BKE_paint_brush_set(paint, brush_prev);
+
+ return brush_dft;
}
/* helper to set default eraser and disable others */
@@ -1959,13 +1949,12 @@ static bool gpencil_session_initdata(bContext *C, wmOperator *op, tGPsdata *p)
}
return 0;
}
- else {
- /* if no existing GPencil block exists, add one */
- if (*gpd_ptr == NULL) {
- *gpd_ptr = BKE_gpencil_data_addnew(bmain, "GPencil");
- }
- p->gpd = *gpd_ptr;
+
+ /* if no existing GPencil block exists, add one */
+ if (*gpd_ptr == NULL) {
+ *gpd_ptr = BKE_gpencil_data_addnew(bmain, "GPencil");
}
+ p->gpd = *gpd_ptr;
/* clear out buffer (stored in gp-data), in case something contaminated it */
gpencil_session_validatebuffer(p);
@@ -2152,9 +2141,7 @@ static void gpencil_paint_initstroke(tGPsdata *p,
}
return;
}
- else {
- p->gpf->flag |= GP_FRAME_PAINT;
- }
+ p->gpf->flag |= GP_FRAME_PAINT;
}
/* set 'eraser' for this stroke if using eraser */
@@ -2524,11 +2511,8 @@ static float gpencil_snap_to_grid_fl(float v, const float offset, const float sp
v -= offset;
v = roundf((v + spacing * 0.5f) / spacing) * spacing;
v += offset;
- return v;
- }
- else {
- return v;
}
+ return v;
}
/* Helper to snap value to grid */
@@ -2957,9 +2941,8 @@ static int gpencil_draw_exec(bContext *C, wmOperator *op)
MEM_SAFE_FREE(op->customdata);
return OPERATOR_CANCELLED;
}
- else {
- p = op->customdata;
- }
+
+ p = op->customdata;
/* loop over the stroke RNA elements recorded (i.e. progress of mouse movement),
* setting the relevant values in context at each step, then applying
@@ -3161,9 +3144,9 @@ static int gpencil_draw_invoke(bContext *C, wmOperator *op, const wmEvent *event
}
return OPERATOR_CANCELLED;
}
- else {
- p = op->customdata;
- }
+
+ p = op->customdata;
+
/* Init random settings. */
ED_gpencil_init_random_settings(p->brush, event->mval, &p->random_settings);
diff --git a/source/blender/editors/gpencil/gpencil_primitive.c b/source/blender/editors/gpencil/gpencil_primitive.c
index 632c3a24638..f206f5c832a 100644
--- a/source/blender/editors/gpencil/gpencil_primitive.c
+++ b/source/blender/editors/gpencil/gpencil_primitive.c
@@ -1598,7 +1598,8 @@ static int gpencil_primitive_modal(bContext *C, wmOperator *op, const wmEvent *e
copy_v2_v2(tgpi->mvalo, tgpi->mval);
return OPERATOR_RUNNING_MODAL;
}
- else if (tgpi->flag == IN_POLYLINE) {
+
+ if (tgpi->flag == IN_POLYLINE) {
switch (event->type) {
@@ -1688,7 +1689,8 @@ static int gpencil_primitive_modal(bContext *C, wmOperator *op, const wmEvent *e
copy_v2_v2(tgpi->mvalo, tgpi->mval);
return OPERATOR_RUNNING_MODAL;
}
- else if (tgpi->flag == IN_BRUSH_SIZE) {
+
+ if (tgpi->flag == IN_BRUSH_SIZE) {
switch (event->type) {
case MOUSEMOVE:
gpencil_primitive_size(tgpi, false);
@@ -1711,7 +1713,8 @@ static int gpencil_primitive_modal(bContext *C, wmOperator *op, const wmEvent *e
copy_v2_v2(tgpi->mvalo, tgpi->mval);
return OPERATOR_RUNNING_MODAL;
}
- else if (tgpi->flag == IN_BRUSH_STRENGTH) {
+
+ if (tgpi->flag == IN_BRUSH_STRENGTH) {
switch (event->type) {
case MOUSEMOVE:
gpencil_primitive_strength(tgpi, false);
@@ -1734,7 +1737,8 @@ static int gpencil_primitive_modal(bContext *C, wmOperator *op, const wmEvent *e
copy_v2_v2(tgpi->mvalo, tgpi->mval);
return OPERATOR_RUNNING_MODAL;
}
- else if (!ELEM(tgpi->flag, IDLE) && !ELEM(tgpi->type, GP_STROKE_POLYLINE)) {
+
+ if (!ELEM(tgpi->flag, IDLE) && !ELEM(tgpi->type, GP_STROKE_POLYLINE)) {
gpencil_primitive_edit_event_handling(C, op, win, event, tgpi);
}
@@ -1938,10 +1942,9 @@ static int gpencil_primitive_modal(bContext *C, wmOperator *op, const wmEvent *e
break;
}
- else {
- /* unhandled event - allow to pass through */
- return OPERATOR_RUNNING_MODAL | OPERATOR_PASS_THROUGH;
- }
+
+ /* unhandled event - allow to pass through */
+ return OPERATOR_RUNNING_MODAL | OPERATOR_PASS_THROUGH;
}
}
diff --git a/source/blender/editors/gpencil/gpencil_sculpt_paint.c b/source/blender/editors/gpencil/gpencil_sculpt_paint.c
index d0adcea25c1..20eeab65623 100644
--- a/source/blender/editors/gpencil/gpencil_sculpt_paint.c
+++ b/source/blender/editors/gpencil/gpencil_sculpt_paint.c
@@ -1229,10 +1229,8 @@ static bool gpencil_sculpt_brush_init(bContext *C, wmOperator *op)
op->customdata = NULL;
return false;
}
- else {
- /* initialise customdata */
- gpencil_brush_clone_init(C, gso);
- }
+ /* initialise customdata */
+ gpencil_brush_clone_init(C, gso);
break;
}
diff --git a/source/blender/editors/gpencil/gpencil_select.c b/source/blender/editors/gpencil/gpencil_select.c
index ea6f53d24bb..dcba8f16ee9 100644
--- a/source/blender/editors/gpencil/gpencil_select.c
+++ b/source/blender/editors/gpencil/gpencil_select.c
@@ -74,15 +74,13 @@ static int gpencil_select_mode_from_sculpt(eGP_Sculpt_SelectMaskFlag mode)
if (mode & GP_SCULPT_MASK_SELECTMODE_POINT) {
return GP_SELECTMODE_POINT;
}
- else if (mode & GP_SCULPT_MASK_SELECTMODE_STROKE) {
+ if (mode & GP_SCULPT_MASK_SELECTMODE_STROKE) {
return GP_SELECTMODE_STROKE;
}
- else if (mode & GP_SCULPT_MASK_SELECTMODE_SEGMENT) {
+ if (mode & GP_SCULPT_MASK_SELECTMODE_SEGMENT) {
return GP_SELECTMODE_SEGMENT;
}
- else {
- return GP_SELECTMODE_POINT;
- }
+ return GP_SELECTMODE_POINT;
}
/* Convert vertex mask mode to Select mode */
@@ -91,15 +89,13 @@ static int gpencil_select_mode_from_vertex(eGP_Sculpt_SelectMaskFlag mode)
if (mode & GP_VERTEX_MASK_SELECTMODE_POINT) {
return GP_SELECTMODE_POINT;
}
- else if (mode & GP_VERTEX_MASK_SELECTMODE_STROKE) {
+ if (mode & GP_VERTEX_MASK_SELECTMODE_STROKE) {
return GP_SELECTMODE_STROKE;
}
- else if (mode & GP_VERTEX_MASK_SELECTMODE_SEGMENT) {
+ if (mode & GP_VERTEX_MASK_SELECTMODE_SEGMENT) {
return GP_SELECTMODE_SEGMENT;
}
- else {
- return GP_SELECTMODE_POINT;
- }
+ return GP_SELECTMODE_POINT;
}
static bool gpencil_select_poll(bContext *C)
diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c
index 7f77999a17b..dd5e16a9d9b 100644
--- a/source/blender/editors/gpencil/gpencil_utils.c
+++ b/source/blender/editors/gpencil/gpencil_utils.c
@@ -117,11 +117,7 @@ bGPdata **ED_gpencil_data_get_pointers_direct(ScrArea *area, Object *ob, Pointer
}
return (bGPdata **)&ob->data;
}
- else {
- return NULL;
- }
-
- break;
+ return NULL;
}
default: /* Unsupported space. */
return NULL;
@@ -220,12 +216,10 @@ bGPdata **ED_annotation_data_get_pointers_direct(ID *screen_id,
}
return &track->gpd;
}
- else {
- if (r_ptr) {
- RNA_id_pointer_create(&clip->id, r_ptr);
- }
- return &clip->gpd;
+ if (r_ptr) {
+ RNA_id_pointer_create(&clip->id, r_ptr);
}
+ return &clip->gpd;
}
break;
}
@@ -344,10 +338,8 @@ bool ED_gpencil_has_keyframe_v3d(Scene *UNUSED(scene), Object *ob, int cfra)
// XXX: assumes that frame has been fetched already
return (gpl->actframe->framenum == cfra);
}
- else {
- /* XXX: disabled as could be too much of a penalty */
- /* return BKE_gpencil_layer_frame_find(gpl, cfra); */
- }
+ /* XXX: disabled as could be too much of a penalty */
+ /* return BKE_gpencil_layer_frame_find(gpl, cfra); */
}
}
@@ -390,9 +382,7 @@ bool gpencil_active_brush_poll(bContext *C)
if (paint) {
return (paint->brush != NULL);
}
- else {
- return false;
- }
+ return false;
}
/* ******************************************************** */
@@ -567,18 +557,16 @@ bool ED_gpencil_stroke_can_use_direct(const ScrArea *area, const bGPDstroke *gps
/* 3D strokes - only in 3D view */
return ((area->spacetype == SPACE_VIEW3D) || (area->spacetype == SPACE_PROPERTIES));
}
- else if (gps->flag & GP_STROKE_2DIMAGE) {
+ if (gps->flag & GP_STROKE_2DIMAGE) {
/* Special "image" strokes - only in Image Editor */
return (area->spacetype == SPACE_IMAGE);
}
- else if (gps->flag & GP_STROKE_2DSPACE) {
+ if (gps->flag & GP_STROKE_2DSPACE) {
/* 2D strokes (dataspace) - for any 2D view (i.e. everything other than 3D view) */
return (area->spacetype != SPACE_VIEW3D);
}
- else {
- /* view aligned - anything goes */
- return true;
- }
+ /* view aligned - anything goes */
+ return true;
}
/* Check whether given stroke can be edited in the current context */
@@ -932,11 +920,8 @@ bool gpencil_point_xy_to_3d(const GP_SpaceConversion *gsc,
return true;
}
- else {
- zero_v3(r_out);
-
- return false;
- }
+ zero_v3(r_out);
+ return false;
}
/**
@@ -1759,12 +1744,10 @@ static bool gpencil_check_cursor_region(bContext *C, int mval_i[2])
if ((region) && (region->regiontype != RGN_TYPE_WINDOW)) {
return false;
}
- else if (region) {
+ if (region) {
return BLI_rcti_isect_pt_v(&region->winrct, mval_i);
}
- else {
- return false;
- }
+ return false;
}
/* draw eraser cursor */
@@ -2529,15 +2512,13 @@ int ED_gpencil_select_stroke_segment(bGPDlayer *gpl,
if ((hit_a) && (hit_b)) {
return 3;
}
- else if (hit_a) {
+ if (hit_a) {
return 1;
}
- else if (hit_b) {
+ if (hit_b) {
return 2;
}
- else {
- return 0;
- }
+ return 0;
}
void ED_gpencil_select_toggle_all(bContext *C, int action)