diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-11-12 01:56:33 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-11-12 01:59:16 +0300 |
commit | fb70ee0bb5b21ed6dc03d1de6ef138da58113ffe (patch) | |
tree | f875903c87699880af52ffcc755e7d4e0bf02684 /source/blender/editors/gpencil/gpencil_brush.c | |
parent | 9c3e324a0d6cb28c9db58f644838032577b41764 (diff) |
Cleanup: minor gpencil changes
- Replace BKE_brush_getactive_gpencil -> BKE_paint_brush
(no need for per-paint-type brush access).
- Rename TOT_GP_EDITBRUSH_TYPES -> GP_EDITBRUSH_TYPE_MAX
(avoid sharing prefix w/ unrelated constants).
- Rename instances of `GP_EditBrush_Data` to 'gp_brush'
(`Brush` is typically called 'brush').
Diffstat (limited to 'source/blender/editors/gpencil/gpencil_brush.c')
-rw-r--r-- | source/blender/editors/gpencil/gpencil_brush.c | 78 |
1 files changed, 40 insertions, 38 deletions
diff --git a/source/blender/editors/gpencil/gpencil_brush.c b/source/blender/editors/gpencil/gpencil_brush.c index ba104a6d57e..8e2cc8fd143 100644 --- a/source/blender/editors/gpencil/gpencil_brush.c +++ b/source/blender/editors/gpencil/gpencil_brush.c @@ -108,7 +108,7 @@ typedef struct tGP_BrushEditData { /* Brush Settings */ GP_BrushEdit_Settings *settings; - GP_EditBrush_Data *brush; + GP_EditBrush_Data *gp_brush; eGP_EditBrush_Types brush_type; eGP_EditBrush_Flag flag; @@ -208,15 +208,15 @@ static GP_BrushEdit_Settings *gpsculpt_get_settings(Scene *scene) static GP_EditBrush_Data *gpsculpt_get_brush(Scene *scene, bool is_weight_mode) { GP_BrushEdit_Settings *gset = &scene->toolsettings->gp_sculpt; - GP_EditBrush_Data *brush = NULL; + GP_EditBrush_Data *gp_brush = NULL; if (is_weight_mode) { - brush = &gset->brush[gset->weighttype]; + gp_brush = &gset->brush[gset->weighttype]; } else { - brush = &gset->brush[gset->brushtype]; + gp_brush = &gset->brush[gset->brushtype]; } - return brush; + return gp_brush; } /* Brush Operations ------------------------------- */ @@ -225,7 +225,7 @@ static GP_EditBrush_Data *gpsculpt_get_brush(Scene *scene, bool is_weight_mode) static bool gp_brush_invert_check(tGP_BrushEditData *gso) { /* The basic setting is the brush's setting (from the panel) */ - bool invert = ((gso->brush->flag & GP_EDITBRUSH_FLAG_INVERT) != 0); + bool invert = ((gso->gp_brush->flag & GP_EDITBRUSH_FLAG_INVERT) != 0); /* During runtime, the user can hold down the Ctrl key to invert the basic behaviour */ if (gso->flag & GP_EDITBRUSH_FLAG_INVERT) { @@ -234,10 +234,10 @@ static bool gp_brush_invert_check(tGP_BrushEditData *gso) /* set temporary status */ if (invert) { - gso->brush->flag |= GP_EDITBRUSH_FLAG_TMP_INVERT; + gso->gp_brush->flag |= GP_EDITBRUSH_FLAG_TMP_INVERT; } else { - gso->brush->flag &= ~GP_EDITBRUSH_FLAG_TMP_INVERT; + gso->gp_brush->flag &= ~GP_EDITBRUSH_FLAG_TMP_INVERT; } return invert; @@ -246,18 +246,18 @@ static bool gp_brush_invert_check(tGP_BrushEditData *gso) /* Compute strength of effect */ static float gp_brush_influence_calc(tGP_BrushEditData *gso, const int radius, const int co[2]) { - GP_EditBrush_Data *brush = gso->brush; + GP_EditBrush_Data *gp_brush = gso->gp_brush; /* basic strength factor from brush settings */ - float influence = brush->strength; + float influence = gp_brush->strength; /* use pressure? */ - if (brush->flag & GP_EDITBRUSH_FLAG_USE_PRESSURE) { + if (gp_brush->flag & GP_EDITBRUSH_FLAG_USE_PRESSURE) { influence *= gso->pressure; } /* distance fading */ - if (brush->flag & GP_EDITBRUSH_FLAG_USE_FALLOFF) { + if (gp_brush->flag & GP_EDITBRUSH_FLAG_USE_FALLOFF) { float distance = (float)len_v2v2_int(gso->mval, co); float fac; @@ -288,7 +288,7 @@ static bool gp_brush_smooth_apply( tGP_BrushEditData *gso, bGPDstroke *gps, int pt_index, const int radius, const int co[2]) { - // GP_EditBrush_Data *brush = gso->brush; + // GP_EditBrush_Data *gp_brush = gso->brush; float inf = gp_brush_influence_calc(gso, radius, co); /* need one flag enabled by default */ if ((gso->settings->flag & @@ -1108,7 +1108,7 @@ static void gp_brush_clone_adjust(tGP_BrushEditData *gso) int i; for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) { - if (gso->brush->flag & GP_EDITBRUSH_FLAG_USE_FALLOFF) { + if (gso->gp_brush->flag & GP_EDITBRUSH_FLAG_USE_FALLOFF) { /* "Smudge" Effect when falloff is enabled */ float delta[3] = {0.0f}; int sco[2] = {0}; @@ -1116,7 +1116,7 @@ static void gp_brush_clone_adjust(tGP_BrushEditData *gso) /* compute influence on point */ gp_point_to_xy(&gso->gsc, gps, pt, &sco[0], &sco[1]); - influence = gp_brush_influence_calc(gso, gso->brush->size, sco); + influence = gp_brush_influence_calc(gso, gso->gp_brush->size, sco); /* adjust the amount of displacement to apply */ mul_v3_v3fl(delta, gso->dvec, influence); @@ -1209,7 +1209,7 @@ static bool gpsculpt_brush_init(bContext *C, wmOperator *op) gso->depsgraph = CTX_data_depsgraph(C); /* store state */ gso->settings = gpsculpt_get_settings(scene); - gso->brush = gpsculpt_get_brush(scene, is_weight_mode); + gso->gp_brush = gpsculpt_get_brush(scene, is_weight_mode); if (is_weight_mode) { gso->brush_type = gso->settings->weighttype; @@ -1231,7 +1231,7 @@ static bool gpsculpt_brush_init(bContext *C, wmOperator *op) /* some brushes cannot use pressure for radius */ if (ELEM(gso->brush_type, GP_EDITBRUSH_TYPE_GRAB, GP_EDITBRUSH_TYPE_CLONE)) { - gso->brush->flag &= ~GP_EDITBRUSH_FLAG_PRESSURE_RADIUS; + gso->gp_brush->flag &= ~GP_EDITBRUSH_FLAG_PRESSURE_RADIUS; } gso->scene = scene; @@ -1363,7 +1363,7 @@ static void gpsculpt_brush_exit(bContext *C, wmOperator *op) } /* disable temp invert flag */ - gso->brush->flag &= ~GP_EDITBRUSH_FLAG_TMP_INVERT; + gso->gp_brush->flag &= ~GP_EDITBRUSH_FLAG_TMP_INVERT; /* free operator data */ MEM_freeN(gso); @@ -1420,8 +1420,8 @@ static bool gpsculpt_brush_do_stroke( { GP_SpaceConversion *gsc = &gso->gsc; rcti *rect = &gso->brush_rect; - GP_EditBrush_Data *brush = gso->brush; - const int radius = (brush->flag & GP_EDITBRUSH_FLAG_PRESSURE_RADIUS) ? gso->brush->size * gso->pressure : gso->brush->size; + GP_EditBrush_Data *gp_brush = gso->gp_brush; + const int radius = (gp_brush->flag & GP_EDITBRUSH_FLAG_PRESSURE_RADIUS) ? gso->gp_brush->size * gso->pressure : gso->gp_brush->size; bGPDspoint *pt1, *pt2; int pc1[2] = {0}; @@ -1713,8 +1713,10 @@ static bool gpsculpt_brush_apply_standard(bContext *C, tGP_BrushEditData *gso) static void gpsculpt_brush_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) { tGP_BrushEditData *gso = op->customdata; - GP_EditBrush_Data *brush = gso->brush; - const int radius = (brush->flag & GP_EDITBRUSH_FLAG_PRESSURE_RADIUS) ? gso->brush->size * gso->pressure : gso->brush->size; + GP_EditBrush_Data *gp_brush = gso->gp_brush; + const int radius = ( + (gp_brush->flag & GP_EDITBRUSH_FLAG_PRESSURE_RADIUS) ? + gso->gp_brush->size * gso->pressure : gso->gp_brush->size); float mousef[2]; int mouse[2]; bool changed = false; @@ -1942,13 +1944,13 @@ static int gpsculpt_brush_modal(bContext *C, wmOperator *op, const wmEvent *even case PADPLUSKEY: if (event->shift) { /* increase strength */ - gso->brush->strength += 0.05f; - CLAMP_MAX(gso->brush->strength, 1.0f); + gso->gp_brush->strength += 0.05f; + CLAMP_MAX(gso->gp_brush->strength, 1.0f); } else { /* increase brush size */ - gso->brush->size += 3; - CLAMP_MAX(gso->brush->size, 300); + gso->gp_brush->size += 3; + CLAMP_MAX(gso->gp_brush->size, 300); } redraw_region = true; @@ -1959,13 +1961,13 @@ static int gpsculpt_brush_modal(bContext *C, wmOperator *op, const wmEvent *even case PADMINUS: if (event->shift) { /* decrease strength */ - gso->brush->strength -= 0.05f; - CLAMP_MIN(gso->brush->strength, 0.0f); + gso->gp_brush->strength -= 0.05f; + CLAMP_MIN(gso->gp_brush->strength, 0.0f); } else { /* decrease brush size */ - gso->brush->size -= 3; - CLAMP_MIN(gso->brush->size, 1); + gso->gp_brush->size -= 3; + CLAMP_MIN(gso->gp_brush->size, 1); } redraw_region = true; @@ -2033,13 +2035,13 @@ static int gpsculpt_brush_modal(bContext *C, wmOperator *op, const wmEvent *even case PADPLUSKEY: if (event->shift) { /* increase strength */ - gso->brush->strength += 0.05f; - CLAMP_MAX(gso->brush->strength, 1.0f); + gso->gp_brush->strength += 0.05f; + CLAMP_MAX(gso->gp_brush->strength, 1.0f); } else { /* increase brush size */ - gso->brush->size += 3; - CLAMP_MAX(gso->brush->size, 300); + gso->gp_brush->size += 3; + CLAMP_MAX(gso->gp_brush->size, 300); } redraw_region = true; @@ -2050,13 +2052,13 @@ static int gpsculpt_brush_modal(bContext *C, wmOperator *op, const wmEvent *even case PADMINUS: if (event->shift) { /* decrease strength */ - gso->brush->strength -= 0.05f; - CLAMP_MIN(gso->brush->strength, 0.0f); + gso->gp_brush->strength -= 0.05f; + CLAMP_MIN(gso->gp_brush->strength, 0.0f); } else { /* decrease brush size */ - gso->brush->size -= 3; - CLAMP_MIN(gso->brush->size, 1); + gso->gp_brush->size -= 3; + CLAMP_MIN(gso->gp_brush->size, 1); } redraw_region = true; |