Commit: fb70ee0bb5b21ed6dc03d1de6ef138da58113ffe
Author: Campbell Barton
Date:   Mon Nov 12 09:56:33 2018 +1100
Branches: blender2.8
https://developer.blender.org/rBfb70ee0bb5b21ed6dc03d1de6ef138da58113ffe

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').

===================================================================

M       source/blender/blenkernel/BKE_brush.h
M       source/blender/blenkernel/intern/brush.c
M       source/blender/blenloader/intern/versioning_280.c
M       source/blender/draw/engines/gpencil/gpencil_draw_utils.c
M       source/blender/editors/gpencil/drawgpencil.c
M       source/blender/editors/gpencil/gpencil_brush.c
M       source/blender/editors/gpencil/gpencil_fill.c
M       source/blender/editors/gpencil/gpencil_ops.c
M       source/blender/editors/gpencil/gpencil_paint.c
M       source/blender/editors/gpencil/gpencil_primitive.c
M       source/blender/editors/gpencil/gpencil_utils.c
M       source/blender/editors/screen/screen_context.c
M       source/blender/makesdna/DNA_scene_types.h
M       source/blender/makesrna/intern/rna_sculpt_paint.c

===================================================================

diff --git a/source/blender/blenkernel/BKE_brush.h 
b/source/blender/blenkernel/BKE_brush.h
index 1a341d0208b..864d7d06438 100644
--- a/source/blender/blenkernel/BKE_brush.h
+++ b/source/blender/blenkernel/BKE_brush.h
@@ -61,7 +61,6 @@ void BKE_brush_free(struct Brush *brush);
 void BKE_brush_sculpt_reset(struct Brush *brush);
 void BKE_brush_gpencil_presets(struct bContext *C);
 void BKE_brush_update_material(struct Main *bmain, struct Material *ma, struct 
Brush *exclude_brush);
-struct Brush *BKE_brush_getactive_gpencil(struct ToolSettings *ts);
 
 /* image icon function */
 struct ImBuf *get_brush_icon(struct Brush *brush);
diff --git a/source/blender/blenkernel/intern/brush.c 
b/source/blender/blenkernel/intern/brush.c
index 286ba5f7902..62c72a4fa58 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -535,18 +535,6 @@ void BKE_brush_update_material(Main *bmain, Material *ma, 
Brush *exclude_brush)
        }
 }
 
-/* get the active gp-brush for editing */
-Brush *BKE_brush_getactive_gpencil(ToolSettings *ts)
-{
-       /* error checking */
-       if (ELEM(NULL, ts, ts->gp_paint)) {
-               return NULL;
-       }
-       Paint *paint = &ts->gp_paint->paint;
-
-       return paint->brush;
-}
-
 struct Brush *BKE_brush_first_search(struct Main *bmain, const eObjectMode 
ob_mode)
 {
        Brush *brush;
diff --git a/source/blender/blenloader/intern/versioning_280.c 
b/source/blender/blenloader/intern/versioning_280.c
index fc873e3a3a1..a72304a6d92 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -1098,7 +1098,7 @@ void blo_do_versions_280(FileData *fd, Library 
*UNUSED(lib), Main *bmain)
                                        ToolSettings *ts = scene->toolsettings;
                                        /* sculpt brushes */
                                        GP_BrushEdit_Settings *gset = 
&ts->gp_sculpt;
-                                       for (int i = 0; i < 
TOT_GP_EDITBRUSH_TYPES; ++i) {
+                                       for (int i = 0; i < 
GP_EDITBRUSH_TYPE_MAX; ++i) {
                                                gp_brush = &gset->brush[i];
                                                gp_brush->flag |= 
GP_EDITBRUSH_FLAG_ENABLE_CURSOR;
                                                
copy_v3_v3(gp_brush->curcolor_add, curcolor_add);
diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c 
b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
index 79ad855108e..ae62e61c5c1 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
@@ -33,6 +33,7 @@
 #include "BKE_gpencil_modifier.h"
 #include "BKE_image.h"
 #include "BKE_material.h"
+#include "BKE_paint.h"
 
 #include "ED_gpencil.h"
 #include "ED_view3d.h"
@@ -921,7 +922,7 @@ void DRW_gpencil_populate_buffer_strokes(GPENCIL_e_data 
*e_data, void *vedata, T
 {
        GPENCIL_PassList *psl = ((GPENCIL_Data *)vedata)->psl;
        GPENCIL_StorageList *stl = ((GPENCIL_Data *)vedata)->stl;
-       Brush *brush = BKE_brush_getactive_gpencil(ts);
+       Brush *brush = BKE_paint_brush(&ts->gp_paint->paint);
        bGPdata *gpd_eval = ob->data;
        /* need the original to avoid cow overhead while drawing */
        bGPdata *gpd = (bGPdata *)DEG_get_original_id(&gpd_eval->id);
diff --git a/source/blender/editors/gpencil/drawgpencil.c 
b/source/blender/editors/gpencil/drawgpencil.c
index e160c7e05a1..03589bb69ae 100644
--- a/source/blender/editors/gpencil/drawgpencil.c
+++ b/source/blender/editors/gpencil/drawgpencil.c
@@ -1679,12 +1679,11 @@ static void gp_draw_data_all(
         int cfra, int dflag, const char UNUSED(spacetype))
 {
        bGPdata *gpd_source = NULL;
-       ToolSettings *ts = NULL;
        Brush *brush = NULL;
        Object *ob = OBACT(view_layer);
        if (scene) {
-               ts = scene->toolsettings;
-               brush = BKE_brush_getactive_gpencil(ts);
+               ToolSettings *ts = scene->toolsettings;
+               brush = BKE_paint_brush(&ts->gp_paint->paint);
 
                if (gpd_source) {
                        if (brush != NULL) {
@@ -1827,7 +1826,7 @@ void ED_gpencil_draw_view3d_object(wmWindowManager *wm, 
Scene *scene, Depsgraph
 
        /* draw it! */
        ToolSettings *ts = scene->toolsettings;
-       Brush *brush = BKE_brush_getactive_gpencil(ts);
+       Brush *brush = BKE_paint_brush(&ts->gp_paint->paint);
        if (brush != NULL) {
                gp_draw_data(rv3d, brush, 1.0f, ob, gpd,
                        offsx, offsy, winx, winy, CFRA, dflag);
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_

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to