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:
Diffstat (limited to 'source/blender/editors/gpencil')
-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
16 files changed, 663 insertions, 334 deletions
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;
}