[Bf-blender-cvs] [bf7e134a5b2] greasepencil-object: GPencil: Add a switch to enable Vertex Color
Antonio Vazquez
noreply at git.blender.org
Sun Nov 3 23:30:51 CET 2019
Commit: bf7e134a5b228a561cabf3ace294cb8900b06b1c
Author: Antonio Vazquez
Date: Sun Nov 3 23:30:42 2019 +0100
Branches: greasepencil-object
https://developer.blender.org/rBbf7e134a5b228a561cabf3ace294cb8900b06b1c
GPencil: Add a switch to enable Vertex Color
This is similar to Dynotopo, you can enable it or not.
===================================================================
M release/scripts/startup/bl_ui/space_view3d.py
M release/scripts/startup/bl_ui/space_view3d_toolbar.py
M source/blender/editors/gpencil/gpencil_paint.c
M source/blender/editors/gpencil/gpencil_primitive.c
M source/blender/makesdna/DNA_scene_types.h
M source/blender/makesrna/intern/rna_sculpt_paint.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index 97473ac0d40..b7e542f41c1 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -325,6 +325,8 @@ class _draw_tool_settings_context_mode:
def draw_color_selector():
ma = gp_settings.material
+ ts = context.tool_settings
+ settings = ts.gpencil_paint
row = layout.row(align=True)
if not gp_settings.use_material_pin:
ma = context.object.active_material
@@ -352,8 +354,11 @@ class _draw_tool_settings_context_mode:
gp_style = ma.grease_pencil
if gp_style.stroke_style != 'TEXTURE' or gp_style.use_stroke_pattern:
row.separator(factor=0.4)
- row.prop(brush, "color", text="")
- row.popover(
+ row.prop(settings, "use_vertex_color", text="")
+ sub_row = row.row(align=True)
+ sub_row.enabled = settings.use_vertex_color
+ sub_row.prop(brush, "color", text="")
+ sub_row.popover(
panel="TOPBAR_PT_gpencil_vertexcolor",
text="Vertex Color",
)
diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index d88c9fbb8b1..4ab08f97fc1 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -2038,6 +2038,9 @@ class VIEW3D_PT_tools_grease_pencil_brush_mixcolor(View3DPanel, Panel):
@classmethod
def poll(cls, context):
ob = context.object
+ ts = context.tool_settings
+ settings = ts.gpencil_paint
+
brush = context.tool_settings.gpencil_paint.brush
if context.area.type != 'PROPERTIES':
return False
@@ -2048,9 +2051,13 @@ class VIEW3D_PT_tools_grease_pencil_brush_mixcolor(View3DPanel, Panel):
if brush.gpencil_tool == 'TINT':
return True
+
if brush.gpencil_tool != 'DRAW':
return False
+ if brush.gpencil_tool == 'DRAW' and settings.use_vertex_color is False:
+ return False
+
gp_settings = brush.gpencil_settings
if gp_settings.use_material_pin is False:
if ob.active_material_index >= 0:
@@ -2099,7 +2106,9 @@ class VIEW3D_PT_tools_grease_pencil_brush_mix_palette(View3DPanel, Panel):
@classmethod
def poll(cls, context):
ob = context.object
- brush = context.tool_settings.gpencil_paint.brush
+ ts = context.tool_settings
+ settings = ts.gpencil_paint
+ brush = settings.brush
if ob is None or brush is None:
return False
@@ -2110,6 +2119,9 @@ class VIEW3D_PT_tools_grease_pencil_brush_mix_palette(View3DPanel, Panel):
if brush.gpencil_tool != 'DRAW':
return False
+ if brush.gpencil_tool == 'DRAW' and settings.use_vertex_color is False:
+ return False
+
gp_settings = brush.gpencil_settings
if gp_settings.use_material_pin is False:
if ob.active_material_index >= 0:
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index 1441b44b458..6f01d969695 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -1009,7 +1009,9 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
pt->time = ptc->time;
/* Point mix color. */
copy_v3_v3(pt->mix_color, brush->rgb);
- pt->mix_color[3] = brush->gpencil_settings->vertex_factor;
+ pt->mix_color[3] = (ts->gp_paint->flag & GPPAINT_FLAG_USE_VERTEXCOLOR) ?
+ brush->gpencil_settings->vertex_factor :
+ 0.0f;
pt++;
@@ -1043,7 +1045,9 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
pt->time = ptc->time;
/* Point mix color. */
copy_v3_v3(pt->mix_color, brush->rgb);
- pt->mix_color[3] = brush->gpencil_settings->vertex_factor;
+ pt->mix_color[3] = (ts->gp_paint->flag & GPPAINT_FLAG_USE_VERTEXCOLOR) ?
+ brush->gpencil_settings->vertex_factor :
+ 0.0f;
if ((ts->gpencil_flags & GP_TOOL_FLAG_CREATE_WEIGHTS) && (have_weight)) {
BKE_gpencil_dvert_ensure(gps);
@@ -1167,7 +1171,9 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
pt->uv_rot = ptc->uv_rot;
/* Point mix color. */
copy_v3_v3(pt->mix_color, brush->rgb);
- pt->mix_color[3] = brush->gpencil_settings->vertex_factor;
+ pt->mix_color[3] = (ts->gp_paint->flag & GPPAINT_FLAG_USE_VERTEXCOLOR) ?
+ brush->gpencil_settings->vertex_factor :
+ 0.0f;
if (dvert != NULL) {
dvert->totweight = 0;
@@ -1828,6 +1834,7 @@ static void gp_init_colors(tGPsdata *p)
{
bGPdata *gpd = p->gpd;
Brush *brush = p->brush;
+ ToolSettings *ts = p->scene->toolsettings;
MaterialGPencilStyle *gp_style = NULL;
@@ -1857,10 +1864,12 @@ static void gp_init_colors(tGPsdata *p)
gpd->runtime.bfill_style = gp_style->fill_style;
/* Apply the mix color to stroke. */
- interp_v3_v3v3(gpd->runtime.scolor,
- gpd->runtime.scolor,
- brush->rgb,
- brush->gpencil_settings->vertex_factor);
+ if (ts->gp_paint->flag & GPPAINT_FLAG_USE_VERTEXCOLOR) {
+ interp_v3_v3v3(gpd->runtime.scolor,
+ gpd->runtime.scolor,
+ brush->rgb,
+ brush->gpencil_settings->vertex_factor);
+ }
}
}
diff --git a/source/blender/editors/gpencil/gpencil_primitive.c b/source/blender/editors/gpencil/gpencil_primitive.c
index 3d517f06a32..353a4c96240 100644
--- a/source/blender/editors/gpencil/gpencil_primitive.c
+++ b/source/blender/editors/gpencil/gpencil_primitive.c
@@ -131,6 +131,7 @@ static void gp_init_colors(tGPDprimitive *p)
{
bGPdata *gpd = p->gpd;
Brush *brush = p->brush;
+ ToolSettings *ts = p->scene->toolsettings;
MaterialGPencilStyle *gp_style = NULL;
@@ -161,10 +162,12 @@ static void gp_init_colors(tGPDprimitive *p)
gpd->runtime.bfill_style = gp_style->fill_style;
/* Apply the mix color to stroke. */
- interp_v3_v3v3(gpd->runtime.scolor,
- gpd->runtime.scolor,
- brush->rgb,
- brush->gpencil_settings->vertex_factor);
+ if (ts->gp_paint->flag & GPPAINT_FLAG_USE_VERTEXCOLOR) {
+ interp_v3_v3v3(gpd->runtime.scolor,
+ gpd->runtime.scolor,
+ brush->rgb,
+ brush->gpencil_settings->vertex_factor);
+ }
}
}
@@ -1031,7 +1034,9 @@ static void gp_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi)
pt->uv_fac = tpt->uv_fac;
/* Point mix color. */
copy_v3_v3(pt->mix_color, brush->rgb);
- pt->mix_color[3] = brush->gpencil_settings->vertex_factor;
+ pt->mix_color[3] = (ts->gp_paint->flag & GPPAINT_FLAG_USE_VERTEXCOLOR) ?
+ brush->gpencil_settings->vertex_factor :
+ 0.0f;
if (gps->dvert != NULL) {
MDeformVert *dvert = &gps->dvert[i];
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index 4fb95d40a2d..9f6933a1ac7 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -984,8 +984,16 @@ typedef struct UvSculpt {
/* grease pencil drawing brushes */
typedef struct GpPaint {
Paint paint;
+ int flag;
+ char _pad_[4];
} GpPaint;
+/* GpPaint.flag */
+enum {
+ /* weight paint only */
+ GPPAINT_FLAG_USE_VERTEXCOLOR = (1 << 0),
+};
+
/* ------------------------------------------- */
/* Vertex Paint */
diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c
index 5a0dc5afec4..937bb669501 100644
--- a/source/blender/makesrna/intern/rna_sculpt_paint.c
+++ b/source/blender/makesrna/intern/rna_sculpt_paint.c
@@ -882,10 +882,18 @@ static void rna_def_uv_sculpt(BlenderRNA *brna)
static void rna_def_gp_paint(BlenderRNA *brna)
{
StructRNA *srna;
+ PropertyRNA *prop;
srna = RNA_def_struct(brna, "GpPaint", "Paint");
RNA_def_struct_path_func(srna, "rna_GpPaint_path");
RNA_def_struct_ui_text(srna, "Grease Pencil Paint", "");
+
+ /* Use vertex color */
+ prop = RNA_def_property(srna, "use_vertex_color", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", GPPAINT_FLAG_USE_VERTEXCOLOR);
+ RNA_def_property_ui_text(prop, "Use Vertex Color", "Use Vertex Color to manage colors");
+ RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
}
/* use for weight paint too */
More information about the Bf-blender-cvs
mailing list