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

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2019-01-15 00:47:04 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-01-15 02:36:52 +0300
commit8c3bd1eda1a2f35e28773f18c879f5f8f971b306 (patch)
tree989d8d12e7c7539ad2625329d7921971063de7a7 /source/blender/editors/gpencil
parentee0c2e9b870ced1d5ed720b8c4e160b7058f147c (diff)
Cleanup: style
Diffstat (limited to 'source/blender/editors/gpencil')
-rw-r--r--source/blender/editors/gpencil/gpencil_edit.c19
-rw-r--r--source/blender/editors/gpencil/gpencil_paint.c68
-rw-r--r--source/blender/editors/gpencil/gpencil_primitive.c66
-rw-r--r--source/blender/editors/gpencil/gpencil_select.c16
4 files changed, 90 insertions, 79 deletions
diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c
index 72f65ce8a37..5c6f7de9426 100644
--- a/source/blender/editors/gpencil/gpencil_edit.c
+++ b/source/blender/editors/gpencil/gpencil_edit.c
@@ -2545,14 +2545,21 @@ static int gp_stroke_caps_set_exec(bContext *C, wmOperator *op)
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))
+ if (!gp_style ||
+ (gp_style->flag & GP_STYLE_COLOR_HIDE) ||
+ (gp_style->flag & GP_STYLE_COLOR_LOCKED))
+ {
continue;
+ }
if ((type == GP_STROKE_CAPS_TOGGLE_BOTH) ||
- (type == GP_STROKE_CAPS_TOGGLE_START))
+ (type == GP_STROKE_CAPS_TOGGLE_START))
{
++gps->caps[0];
if (gps->caps[0] >= GP_STROKE_CAP_MAX) {
@@ -2560,7 +2567,7 @@ static int gp_stroke_caps_set_exec(bContext *C, wmOperator *op)
}
}
if ((type == GP_STROKE_CAPS_TOGGLE_BOTH) ||
- (type == GP_STROKE_CAPS_TOGGLE_END))
+ (type == GP_STROKE_CAPS_TOGGLE_END))
{
++gps->caps[1];
if (gps->caps[1] >= GP_STROKE_CAP_MAX) {
@@ -3851,7 +3858,7 @@ static void gpencil_cutter_dissolve(bGPDlayer *hit_layer, bGPDstroke *hit_stroke
/* if all points selected delete or only 2 points and 1 selected */
if (((totselect == 1) && (hit_stroke->totpoints == 2)) ||
- (hit_stroke->totpoints == totselect))
+ (hit_stroke->totpoints == totselect))
{
BLI_remlink(&hit_layer->actframe->strokes, hit_stroke);
BKE_gpencil_free_stroke(hit_stroke);
@@ -3950,7 +3957,7 @@ static int gpencil_cutter_lasso_select(
}
/* if mark all points inside lasso set to remove all stroke */
if ((tot_inside == oldtot) ||
- ((tot_inside == 1) && (oldtot == 2)))
+ ((tot_inside == 1) && (oldtot == 2)))
{
for (i = 0; i < gps->totpoints; i++) {
pt = &gps->points[i];
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index b138fa8a0d2..baf8ca41062 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -2628,10 +2628,12 @@ static void gp_rotate_v2_v2v2fl(float v[2], const float p[2], const float origin
/* Helper to snap value to grid */
static float gp_snap_to_grid_fl(float v, const float offset, const float spacing)
{
- if (spacing > 0.0f)
+ if (spacing > 0.0f) {
return roundf(v / spacing) * spacing + fmodf(offset, spacing);
- else
+ }
+ else {
return v;
+ }
}
static void UNUSED_FUNCTION(gp_snap_to_grid_v2)(float v[2], const float offset[2], const float spacing)
@@ -2666,7 +2668,8 @@ static void gp_origin_get(tGPsdata *p, float origin[2])
copy_v3_v3(location, guide->location);
}
else if (guide->reference_point == GP_GUIDE_REF_OBJECT &&
- guide->reference_object != NULL) {
+ guide->reference_object != NULL)
+ {
copy_v3_v3(location, guide->reference_object->loc);
}
else {
@@ -2762,7 +2765,7 @@ static void gpencil_draw_apply_event(bContext *C, wmOperator *op, const wmEvent
p->straight = 0;
/* save initial mouse */
- copy_v2_v2(p->mvali, p->mval);
+ copy_v2_v2(p->mvali, p->mval);
/* calculate once and store snapping distance and origin */
RegionView3D * rv3d = p->ar->regiondata;
@@ -2791,9 +2794,10 @@ static void gpencil_draw_apply_event(bContext *C, wmOperator *op, const wmEvent
* it requires direction which needs at least two points
*/
if (!ELEM(p->paintmode, GP_PAINTMODE_ERASER, GP_PAINTMODE_SET_CP) &&
- guide->use_guide &&
- guide->use_snapping &&
- (guide->type == GP_GUIDE_GRID)) {
+ guide->use_guide &&
+ guide->use_snapping &&
+ (guide->type == GP_GUIDE_GRID))
+ {
p->flags |= GP_PAINTFLAG_REQ_VECTOR;
}
}
@@ -2809,7 +2813,7 @@ static void gpencil_draw_apply_event(bContext *C, wmOperator *op, const wmEvent
/* create fake events */
float tmp[2];
float pt[2];
- copy_v2_v2(tmp, p->mval);
+ copy_v2_v2(tmp, p->mval);
sub_v2_v2v2(pt, p->mval, p->mvali);
gpencil_draw_apply_event(C, op, event, CTX_data_depsgraph(C), pt[0], pt[1]);
if (len_v2v2(p->mval, p->mvalo)) {
@@ -2820,8 +2824,9 @@ static void gpencil_draw_apply_event(bContext *C, wmOperator *op, const wmEvent
}
/* check if stroke is straight or guided */
- if ((p->paintmode != GP_PAINTMODE_ERASER)
- && ((p->straight) || (guide->use_guide))) {
+ if ((p->paintmode != GP_PAINTMODE_ERASER) &&
+ ((p->straight) || (guide->use_guide)))
+ {
/* guided stroke */
if (guide->use_guide) {
switch (guide->type) {
@@ -2836,12 +2841,11 @@ static void gpencil_draw_apply_event(bContext *C, wmOperator *op, const wmEvent
}
dist_ensure_v2_v2fl(p->mval, p->origin, distance);
+ break;
}
- break;
case GP_GUIDE_RADIAL:
{
- if (guide->use_snapping &&
- (guide->angle_snap > 0.0f)) {
+ if (guide->use_snapping && (guide->angle_snap > 0.0f)) {
float point[2];
float xy[2];
float angle;
@@ -2857,8 +2861,8 @@ static void gpencil_draw_apply_event(bContext *C, wmOperator *op, const wmEvent
else {
closest_to_line_v2(p->mval, p->mval, p->mvali, p->origin);
}
+ break;
}
- break;
case GP_GUIDE_PARALLEL:
{
float point[2];
@@ -2867,21 +2871,17 @@ static void gpencil_draw_apply_event(bContext *C, wmOperator *op, const wmEvent
unit[0] += 1.0f; /* start from horizontal */
gp_rotate_v2_v2v2fl(point, unit, p->mvali, guide->angle);
closest_to_line_v2(p->mval, p->mval, p->mvali, point);
-
- if (guide->use_snapping &&
- (guide->spacing > 0.0f)) {
+
+ if (guide->use_snapping && (guide->spacing > 0.0f)) {
gp_rotate_v2_v2v2fl(p->mval, p->mval, p->origin, -guide->angle);
p->mval[1] = gp_snap_to_grid_fl(p->mval[1] - p->half_spacing, p->origin[1], p->guide_spacing);
gp_rotate_v2_v2v2fl(p->mval, p->mval, p->origin, guide->angle);
}
-
+ break;
}
- break;
case GP_GUIDE_GRID:
{
- if (guide->use_snapping &&
- (guide->spacing > 0.0f)) {
-
+ if (guide->use_snapping && (guide->spacing > 0.0f)) {
float point[2];
float unit[2];
float angle;
@@ -2904,11 +2904,11 @@ static void gpencil_draw_apply_event(bContext *C, wmOperator *op, const wmEvent
else {
p->mval[0] = p->mvali[0]; /* replace x */
}
+ break;
}
- break;
}
}
- else if (p->straight == STROKE_HORIZONTAL) {
+ else if (p->straight == STROKE_HORIZONTAL) {
p->mval[1] = p->mvali[1]; /* replace y */
}
else {
@@ -3020,9 +3020,9 @@ static void gpencil_guide_event_handling(bContext *C, wmOperator *op, const wmEv
/* Enter or exit set center point mode */
if ((event->type == OKEY) && (event->val == KM_RELEASE)) {
if (p->paintmode == GP_PAINTMODE_DRAW && guide->reference_point != GP_GUIDE_REF_OBJECT) {
- add_notifier = true;
+ add_notifier = true;
p->paintmode = GP_PAINTMODE_SET_CP;
- ED_gpencil_toggle_brush_cursor(C, false, NULL);
+ ED_gpencil_toggle_brush_cursor(C, false, NULL);
}
}
/* Freehand mode, turn off speed guide */
@@ -3052,7 +3052,7 @@ static void gpencil_guide_event_handling(bContext *C, wmOperator *op, const wmEv
/* Line guides */
else if ((event->type == LKEY) && (event->val == KM_RELEASE)) {
add_notifier = true;
- guide->use_guide = true;
+ guide->use_guide = true;
if (event->ctrl) {
guide->angle = 0.0f;
guide->type = GP_GUIDE_PARALLEL;
@@ -3280,7 +3280,7 @@ static void gpencil_add_missing_events(bContext *C, wmOperator *op, const wmEven
if (input_samples == 0) {
return;
}
-
+
RegionView3D *rv3d = p->ar->regiondata;
float defaultpixsize = rv3d->pixsize * 1000.0f;
int samples = (GP_MAX_INPUT_SAMPLES - input_samples + 1);
@@ -3383,10 +3383,10 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event)
case RIGHTMOUSE:
{
if (ELEM(event->val, KM_RELEASE)) {
- drawmode = true;
+ drawmode = true;
}
+ break;
}
- break;
/* set */
case LEFTMOUSE:
{
@@ -3394,8 +3394,8 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event)
gp_origin_set(op, event->mval);
drawmode = true;
}
+ break;
}
- break;
}
if (drawmode) {
p->status = GP_STATUS_IDLING;
@@ -3698,7 +3698,7 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event)
switch (estate) {
case OPERATOR_FINISHED:
/* store stroke angle for parallel guide */
- if ((p->straight == 0) || (guide->use_guide && (guide->type == GP_GUIDE_CIRCULAR))){
+ if ((p->straight == 0) || (guide->use_guide && (guide->type == GP_GUIDE_CIRCULAR))) {
float xy[2];
sub_v2_v2v2(xy, p->mval, p->mvali);
float angle = atan2f(xy[1], xy[0]);
@@ -3770,7 +3770,7 @@ void GPENCIL_OT_draw(wmOperatorType *ot)
prop = RNA_def_boolean(ot->srna, "disable_fill", false, "No Fill Areas", "Disable fill to use stroke as fill boundary");
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
-
+
/* guides */
prop = RNA_def_float(ot->srna, "guide_last_angle", 0.0f, -10000.0f, 10000.0f, "Angle", "Speed guide angle", -10000.0f, 10000.0f);
prop = RNA_def_float_vector(ot->srna, "guide_origin", 3, NULL, -10000.0f, 10000.0f, "Origin", "Speed guide origin", -10000.0f, 10000.0f);
@@ -3792,7 +3792,7 @@ static int gpencil_guide_rotate(bContext *C, wmOperator *op)
else {
guide->angle = angle_compat_rad(angle, M_PI);
}
-
+
return OPERATOR_FINISHED;
}
diff --git a/source/blender/editors/gpencil/gpencil_primitive.c b/source/blender/editors/gpencil/gpencil_primitive.c
index d108b4b910e..8c92cf588cb 100644
--- a/source/blender/editors/gpencil/gpencil_primitive.c
+++ b/source/blender/editors/gpencil/gpencil_primitive.c
@@ -689,22 +689,22 @@ static void gp_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi)
if (tgpi->tot_edges > 1) {
switch (tgpi->type) {
- case GP_STROKE_BOX:
- gp_primitive_rectangle(tgpi, points2D);
- break;
- case GP_STROKE_LINE:
- gp_primitive_line(tgpi, points2D);
- break;
- case GP_STROKE_CIRCLE:
- gp_primitive_circle(tgpi, points2D);
- break;
- case GP_STROKE_ARC:
- gp_primitive_arc(tgpi, points2D);
- break;
- case GP_STROKE_CURVE:
- gp_primitive_bezier(tgpi, points2D);
- default:
- break;
+ case GP_STROKE_BOX:
+ gp_primitive_rectangle(tgpi, points2D);
+ break;
+ case GP_STROKE_LINE:
+ gp_primitive_line(tgpi, points2D);
+ break;
+ case GP_STROKE_CIRCLE:
+ gp_primitive_circle(tgpi, points2D);
+ break;
+ case GP_STROKE_ARC:
+ gp_primitive_arc(tgpi, points2D);
+ break;
+ case GP_STROKE_CURVE:
+ gp_primitive_bezier(tgpi, points2D);
+ default:
+ break;
}
}
@@ -1444,22 +1444,28 @@ static int gpencil_primitive_modal(bContext *C, wmOperator *op, const wmEvent *e
if (tgpi->flag == IN_MOVE) {
switch (event->type) {
- case MOUSEMOVE:
- gpencil_primitive_move(tgpi, false);
- gpencil_primitive_update(C, op, tgpi);
- break;
- case ESCKEY:
- case LEFTMOUSE:
- zero_v2(tgpi->move);
- tgpi->flag = IN_CURVE_EDIT;
- break;
- case RIGHTMOUSE:
- if (event->val == KM_RELEASE) {
- tgpi->flag = IN_CURVE_EDIT;
- gpencil_primitive_move(tgpi, true);
+ case MOUSEMOVE:
+ {
+ gpencil_primitive_move(tgpi, false);
gpencil_primitive_update(C, op, tgpi);
+ break;
+ }
+ case ESCKEY:
+ case LEFTMOUSE:
+ {
+ zero_v2(tgpi->move);
+ tgpi->flag = IN_CURVE_EDIT;
+ break;
+ }
+ case RIGHTMOUSE:
+ {
+ if (event->val == KM_RELEASE) {
+ tgpi->flag = IN_CURVE_EDIT;
+ gpencil_primitive_move(tgpi, true);
+ gpencil_primitive_update(C, op, tgpi);
+ }
+ break;
}
- break;
}
copy_v2_v2(tgpi->mvalo, tgpi->mval);
return OPERATOR_RUNNING_MODAL;
diff --git a/source/blender/editors/gpencil/gpencil_select.c b/source/blender/editors/gpencil/gpencil_select.c
index 1deeab641f4..fb5efb01f94 100644
--- a/source/blender/editors/gpencil/gpencil_select.c
+++ b/source/blender/editors/gpencil/gpencil_select.c
@@ -861,11 +861,11 @@ void GPENCIL_OT_select_less(wmOperatorType *ot)
* It would be great to de-duplicate the logic here sometime, but that can wait...
*/
static bool gp_stroke_do_circle_sel(
- bGPDlayer *gpl,
+ bGPDlayer *gpl,
bGPDstroke *gps, GP_SpaceConversion *gsc,
const int mx, const int my, const int radius,
const bool select, rcti *rect, float diff_mat[4][4], const int selectmode,
- const float scale)
+ const float scale)
{
bGPDspoint *pt1 = NULL;
bGPDspoint *pt2 = NULL;
@@ -1088,8 +1088,8 @@ static int gpencil_generic_select_exec(
(ts->gpencil_selectmode == GP_SELECTMODE_STROKE) &&
((gpd->flag & GP_DATA_STROKE_PAINTMODE) == 0));
const bool segmentmode = (
- (ts->gpencil_selectmode == GP_SELECTMODE_SEGMENT) &&
- ((gpd->flag & GP_DATA_STROKE_PAINTMODE) == 0));
+ (ts->gpencil_selectmode == GP_SELECTMODE_SEGMENT) &&
+ ((gpd->flag & GP_DATA_STROKE_PAINTMODE) == 0));
const eSelectOp sel_op = RNA_enum_get(op->ptr, "mode");
const float scale = ts->gp_sculpt.isect_threshold;
@@ -1143,9 +1143,7 @@ static int gpencil_generic_select_exec(
changed = true;
/* expand selection to segment */
- if ((sel_op_result != -1) &&
- (segmentmode))
- {
+ if ((sel_op_result != -1) && (segmentmode)) {
bool hit_select = (bool)(pt->flag & GP_SPOINT_SELECT);
float r_hita[3], r_hitb[3];
ED_gpencil_select_stroke_segment(
@@ -1491,8 +1489,8 @@ static int gpencil_select_exec(bContext *C, wmOperator *op)
float r_hita[3], r_hitb[3];
bool hit_select = (bool)(hit_point->flag & GP_SPOINT_SELECT);
ED_gpencil_select_stroke_segment(
- hit_layer, hit_stroke, hit_point, hit_select,
- false, scale, r_hita, r_hitb);
+ hit_layer, hit_stroke, hit_point, hit_select,
+ false, scale, r_hita, r_hitb);
}
}
else {