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').
This commit is contained in:
Campbell Barton 2018-11-12 09:56:33 +11:00
parent 9c3e324a0d
commit fb70ee0bb5
14 changed files with 94 additions and 117 deletions

View File

@ -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);

View File

@ -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;

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -813,11 +813,10 @@ static void gpencil_points_from_stack(tGPDfill *tgpf)
/* create a grease pencil stroke using points in buffer */
static void gpencil_stroke_from_buffer(tGPDfill *tgpf)
{
ToolSettings *ts = tgpf->scene->toolsettings;
int cfra_eval = (int)DEG_get_ctime(tgpf->depsgraph);
const int cfra_eval = (int)DEG_get_ctime(tgpf->depsgraph);
Brush *brush;
brush = BKE_brush_getactive_gpencil(ts);
ToolSettings *ts = tgpf->scene->toolsettings;
Brush *brush = BKE_paint_brush(&ts->gp_paint->paint);
if (brush == NULL) {
return;
}
@ -1026,7 +1025,7 @@ static tGPDfill *gp_session_init_fill(bContext *C, wmOperator *UNUSED(op))
tgpf->depth_arr = NULL;
/* save filling parameters */
Brush *brush = BKE_brush_getactive_gpencil(ts);
Brush *brush = BKE_paint_brush(&ts->gp_paint->paint);
tgpf->flag = brush->gpencil_settings->flag;
tgpf->fill_leak = brush->gpencil_settings->fill_leak;
tgpf->fill_threshold = brush->gpencil_settings->fill_threshold;

View File

@ -37,6 +37,7 @@
#include "BKE_context.h"
#include "BKE_brush.h"
#include "BKE_gpencil.h"
#include "BKE_paint.h"
#include "DNA_brush_types.h"
#include "DNA_gpencil_types.h"
@ -88,7 +89,7 @@ static bool gp_stroke_paintmode_poll_with_tool(bContext *C, const char gpencil_t
/* TODO: limit this to mode, but review 2D editors */
bGPdata *gpd = CTX_data_gpencil_data(C);
ToolSettings *ts = CTX_data_tool_settings(C);
Brush *brush = BKE_brush_getactive_gpencil(ts);
Brush *brush = BKE_paint_brush(&ts->gp_paint->paint);
return ((gpd) && (gpd->flag & GP_DATA_STROKE_PAINTMODE) &&
(brush && brush->gpencil_settings) &&
WM_toolsystem_active_tool_is_brush(C) &&

View File

@ -1681,7 +1681,6 @@ static Brush *gp_get_default_eraser(Main *bmain, ToolSettings *ts)
/* initialize a drawing brush */
static void gp_init_drawing_brush(bContext *C, tGPsdata *p)
{
Brush *brush;
Scene *scene = CTX_data_scene(C);
ToolSettings *ts = CTX_data_tool_settings(C);
@ -1691,24 +1690,19 @@ static void gp_init_drawing_brush(bContext *C, tGPsdata *p)
if (paint->brush == NULL) {
/* create new brushes */
BKE_brush_gpencil_presets(C);
brush = BKE_brush_getactive_gpencil(ts);
}
else {
/* Use the current */
brush = BKE_brush_getactive_gpencil(ts);
}
/* be sure curves are initializated */
curvemapping_initialize(brush->gpencil_settings->curve_sensitivity);
curvemapping_initialize(brush->gpencil_settings->curve_strength);
curvemapping_initialize(brush->gpencil_settings->curve_jitter);
curvemapping_initialize(paint->brush->gpencil_settings->curve_sensitivity);
curvemapping_initialize(paint->brush->gpencil_settings->curve_strength);
curvemapping_initialize(paint->brush->gpencil_settings->curve_jitter);
/* assign to temp tGPsdata */
p->brush = brush;
if (brush->gpencil_tool != GPAINT_TOOL_ERASE) {
p->brush = paint->brush;
if (paint->brush->gpencil_tool != GPAINT_TOOL_ERASE) {
p->eraser = gp_get_default_eraser(p->bmain, ts);
}
else {
p->eraser = brush;
p->eraser = paint->brush;
}
/* use radius of eraser */
p->radius = (short)p->eraser->size;
@ -2313,7 +2307,7 @@ static int gpencil_draw_init(bContext *C, wmOperator *op, const wmEvent *event)
tGPsdata *p;
eGPencil_PaintModes paintmode = RNA_enum_get(op->ptr, "mode");
ToolSettings *ts = CTX_data_tool_settings(C);
Brush *brush = BKE_brush_getactive_gpencil(ts);
Brush *brush = BKE_paint_brush(&ts->gp_paint->paint);
/* if mode is draw and the brush is eraser, cancel */
if (paintmode != GP_PAINTMODE_ERASER) {

View File

@ -140,7 +140,6 @@ static void gp_primitive_set_initdata(bContext *C, tGPDprimitive *tgpi)
int cfra_eval = (int)DEG_get_ctime(depsgraph);
bGPDlayer *gpl = CTX_data_active_gpencil_layer(C);
Brush *brush;
/* if brush doesn't exist, create a new one */
Paint *paint = &ts->gp_paint->paint;
@ -148,13 +147,8 @@ static void gp_primitive_set_initdata(bContext *C, tGPDprimitive *tgpi)
if (paint->brush == NULL) {
/* create new brushes */
BKE_brush_gpencil_presets(C);
brush = BKE_brush_getactive_gpencil(ts);
}
else {
/* Use the current */
brush = BKE_brush_getactive_gpencil(ts);
}
tgpi->brush = brush;
tgpi->brush = paint->brush;
/* if layer doesn't exist, create a new one */
if (gpl == NULL) {

View File

@ -1510,17 +1510,17 @@ static void gp_brush_drawcursor(bContext *C, int x, int y, void *customdata)
GP_BrushEdit_Settings *gset = &scene->toolsettings->gp_sculpt;
bGPdata *gpd = ED_gpencil_data_get_active(C);
GP_EditBrush_Data *brush = NULL;
Brush *paintbrush = NULL;
GP_EditBrush_Data *gp_brush = NULL;
Brush *brush = NULL;
Material *ma = NULL;
MaterialGPencilStyle *gp_style = NULL;
int *last_mouse_position = customdata;
if ((gpd) && (gpd->flag & GP_DATA_STROKE_WEIGHTMODE)) {
brush = &gset->brush[gset->weighttype];
gp_brush = &gset->brush[gset->weighttype];
}
else {
brush = &gset->brush[gset->brushtype];
gp_brush = &gset->brush[gset->brushtype];
}
/* default radius and color */
@ -1536,51 +1536,51 @@ static void gp_brush_drawcursor(bContext *C, int x, int y, void *customdata)
/* for paint use paint brush size and color */
if (gpd->flag & GP_DATA_STROKE_PAINTMODE) {
paintbrush = BKE_brush_getactive_gpencil(scene->toolsettings);
brush = scene->toolsettings->gp_paint->paint.brush;
/* while drawing hide */
if ((gpd->runtime.sbuffer_size > 0) &&
(paintbrush) && ((paintbrush->gpencil_settings->flag & GP_BRUSH_STABILIZE_MOUSE) == 0) &&
((paintbrush->gpencil_settings->flag & GP_BRUSH_STABILIZE_MOUSE_TEMP) == 0))
(brush) && ((brush->gpencil_settings->flag & GP_BRUSH_STABILIZE_MOUSE) == 0) &&
((brush->gpencil_settings->flag & GP_BRUSH_STABILIZE_MOUSE_TEMP) == 0))
{
return;
}
if (paintbrush) {
if ((paintbrush->gpencil_settings->flag & GP_BRUSH_ENABLE_CURSOR) == 0) {
if (brush) {
if ((brush->gpencil_settings->flag & GP_BRUSH_ENABLE_CURSOR) == 0) {
return;
}
/* eraser has special shape and use a different shader program */
if (paintbrush->gpencil_tool == GPAINT_TOOL_ERASE) {
ED_gpencil_brush_draw_eraser(paintbrush, x, y);
if (brush->gpencil_tool == GPAINT_TOOL_ERASE) {
ED_gpencil_brush_draw_eraser(brush, x, y);
return;
}
/* get current drawing color */
ma = BKE_gpencil_get_material_from_brush(paintbrush);
ma = BKE_gpencil_get_material_from_brush(brush);
if (ma == NULL) {
BKE_gpencil_material_ensure(bmain, ob);
/* assign the first material to the brush */
ma = give_current_material(ob, 1);
paintbrush->gpencil_settings->material = ma;
brush->gpencil_settings->material = ma;
}
gp_style = ma->gp_style;
/* after some testing, display the size of the brush is not practical because
* is too disruptive and the size of cursor does not change with zoom factor.
* The decision was to use a fix size, instead of paintbrush->thickness value.
* The decision was to use a fix size, instead of brush->thickness value.
*/
if ((gp_style) && (GPENCIL_PAINT_MODE(gpd)) &&
((paintbrush->gpencil_settings->flag & GP_BRUSH_STABILIZE_MOUSE) == 0) &&
((paintbrush->gpencil_settings->flag & GP_BRUSH_STABILIZE_MOUSE_TEMP) == 0) &&
(paintbrush->gpencil_tool == GPAINT_TOOL_DRAW))
((brush->gpencil_settings->flag & GP_BRUSH_STABILIZE_MOUSE) == 0) &&
((brush->gpencil_settings->flag & GP_BRUSH_STABILIZE_MOUSE_TEMP) == 0) &&
(brush->gpencil_tool == GPAINT_TOOL_DRAW))
{
radius = 2.0f;
copy_v3_v3(color, gp_style->stroke_rgba);
}
else {
radius = 5.0f;
copy_v3_v3(color, paintbrush->add_col);
copy_v3_v3(color, brush->add_col);
}
}
else {
@ -1590,17 +1590,17 @@ static void gp_brush_drawcursor(bContext *C, int x, int y, void *customdata)
/* for sculpt use sculpt brush size */
if (GPENCIL_SCULPT_OR_WEIGHT_MODE(gpd)) {
if (brush) {
if ((brush->flag & GP_EDITBRUSH_FLAG_ENABLE_CURSOR) == 0) {
if (gp_brush) {
if ((gp_brush->flag & GP_EDITBRUSH_FLAG_ENABLE_CURSOR) == 0) {
return;
}
radius = brush->size;
if (brush->flag & (GP_EDITBRUSH_FLAG_INVERT | GP_EDITBRUSH_FLAG_TMP_INVERT)) {
copy_v3_v3(color, brush->curcolor_sub);
radius = gp_brush->size;
if (gp_brush->flag & (GP_EDITBRUSH_FLAG_INVERT | GP_EDITBRUSH_FLAG_TMP_INVERT)) {
copy_v3_v3(color, gp_brush->curcolor_sub);
}
else {
copy_v3_v3(color, brush->curcolor_add);
copy_v3_v3(color, gp_brush->curcolor_add);
}
}
}
@ -1616,9 +1616,9 @@ static void gp_brush_drawcursor(bContext *C, int x, int y, void *customdata)
/* Inner Ring: Color from UI panel */
immUniformColor4f(color[0], color[1], color[2], 0.8f);
if ((gp_style) && (GPENCIL_PAINT_MODE(gpd)) &&
((paintbrush->gpencil_settings->flag & GP_BRUSH_STABILIZE_MOUSE) == 0) &&
((paintbrush->gpencil_settings->flag & GP_BRUSH_STABILIZE_MOUSE_TEMP) == 0) &&
(paintbrush->gpencil_tool == GPAINT_TOOL_DRAW))
((brush->gpencil_settings->flag & GP_BRUSH_STABILIZE_MOUSE) == 0) &&
((brush->gpencil_settings->flag & GP_BRUSH_STABILIZE_MOUSE_TEMP) == 0) &&
(brush->gpencil_tool == GPAINT_TOOL_DRAW))
{
imm_draw_circle_fill_2d(pos, x, y, radius, 40);
}
@ -1636,12 +1636,12 @@ static void gp_brush_drawcursor(bContext *C, int x, int y, void *customdata)
/* Draw line for lazy mouse */
if ((last_mouse_position) &&
(paintbrush->gpencil_settings->flag & GP_BRUSH_STABILIZE_MOUSE_TEMP))
(brush->gpencil_settings->flag & GP_BRUSH_STABILIZE_MOUSE_TEMP))
{
glEnable(GL_LINE_SMOOTH);
glEnable(GL_BLEND);
copy_v3_v3(color, paintbrush->add_col);
copy_v3_v3(color, brush->add_col);
immUniformColor4f(color[0], color[1], color[2], 0.8f);
immBegin(GPU_PRIM_LINES, 2);
@ -1703,7 +1703,7 @@ static void gpencil_verify_brush_type(bContext *C, int newmode)
break;
case OB_MODE_GPENCIL_WEIGHT:
gset->flag |= GP_BRUSHEDIT_FLAG_WEIGHT_MODE;
if ((gset->weighttype < GP_EDITBRUSH_TYPE_WEIGHT) || (gset->weighttype >= TOT_GP_EDITBRUSH_TYPES)) {
if ((gset->weighttype < GP_EDITBRUSH_TYPE_WEIGHT) || (gset->weighttype >= GP_EDITBRUSH_TYPE_MAX)) {
gset->weighttype = GP_EDITBRUSH_TYPE_WEIGHT;
}
break;

View File

@ -542,7 +542,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
}
}
else if (CTX_data_equals(member, "active_gpencil_brush")) {
Brush *brush = BKE_brush_getactive_gpencil(scene->toolsettings);
Brush *brush = BKE_paint_brush(&scene->toolsettings->gp_paint->paint);
if (brush) {
CTX_data_pointer_set(result, &scene->id, &RNA_Brush, brush);

View File

@ -977,7 +977,7 @@ typedef enum eGP_EditBrush_Types {
/* add any weight paint brush below this value. Do no mix brushes */
/* !!! Update GP_EditBrush_Data brush[###]; below !!! */
TOT_GP_EDITBRUSH_TYPES
GP_EDITBRUSH_TYPE_MAX,
} eGP_EditBrush_Types;
/* GP_BrushEdit_Settings.lock_axis */
@ -1022,7 +1022,7 @@ typedef enum eGP_EditBrush_Flag {
/* GPencil Stroke Sculpting Settings */
typedef struct GP_BrushEdit_Settings {
GP_EditBrush_Data brush[12]; /* TOT_GP_EDITBRUSH_TYPES */
GP_EditBrush_Data brush[12]; /* GP_EDITBRUSH_TYPE_MAX */
void *paintcursor; /* runtime */
int brushtype; /* eGP_EditBrush_Types (sculpt) */

View File

@ -522,7 +522,7 @@ static PointerRNA rna_GPencilSculptSettings_brush_get(PointerRNA *ptr)
GP_EditBrush_Data *brush = NULL;
if ((gset) && (gset->flag & GP_BRUSHEDIT_FLAG_WEIGHT_MODE)) {
if ((gset->weighttype >= GP_EDITBRUSH_TYPE_WEIGHT) && (gset->weighttype < TOT_GP_EDITBRUSH_TYPES))
if ((gset->weighttype >= GP_EDITBRUSH_TYPE_WEIGHT) && (gset->weighttype < GP_EDITBRUSH_TYPE_MAX))
brush = &gset->brush[gset->weighttype];
}
else {