[Bf-blender-cvs] [52722da1664] greasepencil-object: GPencil: New Vertex Opacity factor by Layer
Antonio Vazquez
noreply at git.blender.org
Sat Nov 23 11:46:19 CET 2019
Commit: 52722da16641b2670752dc89af344b292af6faef
Author: Antonio Vazquez
Date: Sat Nov 23 11:46:17 2019 +0100
Branches: greasepencil-object
https://developer.blender.org/rB52722da16641b2670752dc89af344b292af6faef
GPencil: New Vertex Opacity factor by Layer
This allows to define the opacity factor for each layer.
===================================================================
M release/scripts/startup/bl_ui/properties_data_gpencil.py
M source/blender/blenloader/intern/versioning_280.c
M source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
M source/blender/draw/engines/gpencil/gpencil_draw_utils.c
M source/blender/draw/engines/gpencil/gpencil_engine.h
M source/blender/makesdna/DNA_gpencil_types.h
M source/blender/makesrna/intern/rna_gpencil.c
M source/blender/makesrna/intern/rna_space.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/properties_data_gpencil.py b/release/scripts/startup/bl_ui/properties_data_gpencil.py
index e0a43a5fccc..3b4d4410d51 100644
--- a/release/scripts/startup/bl_ui/properties_data_gpencil.py
+++ b/release/scripts/startup/bl_ui/properties_data_gpencil.py
@@ -194,6 +194,10 @@ class DATA_PT_gpencil_layer_adjustments(LayerDataButtonsPanel, Panel):
col.prop(gpl, "tint_color")
col.prop(gpl, "tint_factor", text="Factor", slider=True)
+ # Vertex Paint Opacity
+ col = layout.row(align=True)
+ col.prop(gpl, "vertex_paint_opacity", text="Vertex Opacity")
+
# Offsets - Thickness
col = layout.row(align=True)
col.prop(gpl, "line_change", text="Stroke Thickness")
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index 90b08a04cff..948a6e69335 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -3997,5 +3997,16 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
}
+
+ /* Init default Vertex paint layer mix factor. */
+ {
+ if (!DNA_struct_elem_find(fd->filesdna, "bGPDlayer", "float", "vertex_paint_opacity")) {
+ for (bGPdata *gpd = bmain->gpencils.first; gpd; gpd = gpd->id.next) {
+ for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
+ gpl->vertex_paint_opacity = 1.0f;
+ }
+ }
+ }
+ }
}
}
diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
index 5db9e88a4c6..601b4d5aa6d 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
@@ -144,6 +144,7 @@ static void gpencil_elem_format_ensure(GpencilBatchCacheElem *be)
/* create batch geometry data for points stroke shader */
void gpencil_get_point_geom(GpencilBatchCacheElem *be,
+ bGPDlayer *gpl,
bGPDstroke *gps,
short thickness,
const float ink[4],
@@ -193,7 +194,8 @@ void gpencil_get_point_geom(GpencilBatchCacheElem *be,
if (!onion) {
float mixtint[3];
interp_v3_v3v3(mixtint, pt->mix_color, tintcolor, tintcolor[3]);
- interp_v3_v3v3(mix_color, ink, mixtint, pt->mix_color[3] * vpaint_mix);
+ interp_v3_v3v3(
+ mix_color, ink, mixtint, pt->mix_color[3] * vpaint_mix * gpl->vertex_paint_opacity);
}
/* If using vertex paint mask, attenuate not selected. */
if ((attenuate) && ((pt->flag & GP_SPOINT_SELECT) == 0)) {
@@ -250,6 +252,7 @@ void gpencil_get_point_geom(GpencilBatchCacheElem *be,
/* create batch geometry data for stroke shader */
void gpencil_get_stroke_geom(struct GpencilBatchCacheElem *be,
+ bGPDlayer *gpl,
bGPDstroke *gps,
short thickness,
const float ink[4],
@@ -296,7 +299,8 @@ void gpencil_get_stroke_geom(struct GpencilBatchCacheElem *be,
if (!onion) {
float mixtint[3];
interp_v3_v3v3(mixtint, pt->mix_color, tintcolor, tintcolor[3]);
- interp_v3_v3v3(mix_color, ink, mixtint, pt->mix_color[3] * vpaint_mix);
+ interp_v3_v3v3(
+ mix_color, ink, mixtint, pt->mix_color[3] * vpaint_mix * gpl->vertex_paint_opacity);
}
/* first point for adjacency (not drawn) */
diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
index fb87189101a..a5aaac70176 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
@@ -1005,7 +1005,10 @@ static void gpencil_add_fill_vertexdata(GpencilBatchCache *cache,
/* Apply the mix color of the fill and layer tint. */
float mixtint[3];
interp_v3_v3v3(mixtint, gps->mix_color_fill, tintcolor, tintcolor[3]);
- interp_v3_v3v3(tfill, tfill, mixtint, gps->mix_color_fill[3] * vpaint_mix);
+ interp_v3_v3v3(tfill,
+ tfill,
+ mixtint,
+ gps->mix_color_fill[3] * vpaint_mix * gpl->vertex_paint_opacity);
/* If using vertex paint mask, attenuate not selected. */
if ((attenuate) && ((gps->flag & GP_STROKE_SELECT) == 0)) {
tfill[3] *= GP_VERTEX_MASK_ATTENUATE;
@@ -1089,7 +1092,7 @@ static void gpencil_add_stroke_vertexdata(GpencilBatchCache *cache,
if ((gps->totpoints > 1) && (gp_style->mode == GP_STYLE_MODE_LINE)) {
/* create vertex data */
const int old_len = cache->b_stroke.vbo_len;
- gpencil_get_stroke_geom(&cache->b_stroke, gps, sthickness, ink, tintcolor, onion);
+ gpencil_get_stroke_geom(&cache->b_stroke, gpl, gps, sthickness, ink, tintcolor, onion);
/* add to list of groups */
if (old_len < cache->b_stroke.vbo_len) {
@@ -1108,7 +1111,7 @@ static void gpencil_add_stroke_vertexdata(GpencilBatchCache *cache,
/* create vertex data */
const int old_len = cache->b_point.vbo_len;
gpencil_get_point_geom(
- &cache->b_point, gps, sthickness, ink, tintcolor, alignment_mode, onion);
+ &cache->b_point, gpl, gps, sthickness, ink, tintcolor, alignment_mode, onion);
/* add to list of groups */
if (old_len < cache->b_point.vbo_len) {
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.h b/source/blender/draw/engines/gpencil/gpencil_engine.h
index d9daef28893..0be1f6abafe 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.h
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.h
@@ -424,6 +424,7 @@ void gpencil_multisample_ensure(struct GPENCIL_Data *vedata, int rect_w, int rec
/* create geometry functions */
void gpencil_get_point_geom(struct GpencilBatchCacheElem *be,
+ struct bGPDlayer *gpl,
struct bGPDstroke *gps,
short thickness,
const float ink[4],
@@ -431,6 +432,7 @@ void gpencil_get_point_geom(struct GpencilBatchCacheElem *be,
const int follow_mode,
const bool onion);
void gpencil_get_stroke_geom(struct GpencilBatchCacheElem *be,
+ struct bGPDlayer *gpl,
struct bGPDstroke *gps,
short thickness,
const float ink[4],
diff --git a/source/blender/makesdna/DNA_gpencil_types.h b/source/blender/makesdna/DNA_gpencil_types.h
index 2fcd0e18933..28c81357906 100644
--- a/source/blender/makesdna/DNA_gpencil_types.h
+++ b/source/blender/makesdna/DNA_gpencil_types.h
@@ -367,7 +367,8 @@ typedef struct bGPDlayer {
/** Blend modes. */
int blend_mode;
- char _pad[4];
+ /** Vertex Paint opacity by Layer. */
+ float vertex_paint_opacity;
/* annotation onion skin */
/**
diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c
index cb50f265dab..f45415047b3 100644
--- a/source/blender/makesrna/intern/rna_gpencil.c
+++ b/source/blender/makesrna/intern/rna_gpencil.c
@@ -1388,6 +1388,14 @@ static void rna_def_gpencil_layer(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Tint Factor", "Factor of tinting color");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
+ /* Vertex Paint opacity factor */
+ prop = RNA_def_property(srna, "vertex_paint_opacity", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "vertex_paint_opacity");
+ RNA_def_property_range(prop, 0.0f, 1.0f);
+ RNA_def_property_float_default(prop, 1.0f);
+ RNA_def_property_ui_text(prop, "Vertex Paint Opacity", "Vertex Paint mix factor");
+ RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
+
/* Line Thickness Change */
prop = RNA_def_property(srna, "line_change", PROP_INT, PROP_PIXEL);
RNA_def_property_int_sdna(prop, NULL, "line_change");
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index b3aa0949913..1529f88475a 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -3716,10 +3716,11 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna)
RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, "rna_GPencil_update");
- /* Paper opacity factor */
+ /* Vertex Paint opacity factor */
prop = RNA_def_property(srna, "gpencil_vertex_paint_opacity", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "overlay.gpencil_vertex_paint_opacity");
RNA_def_property_range(prop, 0.0f, 1.0f);
+ RNA_def_property_float_default(prop, 1.0f);
RNA_def_property_ui_text(prop, "Opacity", "Vertex Paint mix factor");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_GPencil_update");
}
More information about the Bf-blender-cvs
mailing list