[Bf-blender-cvs] [78783b3e168] greasepencil-refactor: GPencil: Test modifiers Tint and Hue/Saturation to use material if the Vertex color is not active.
Antonio Vazquez
noreply at git.blender.org
Sun Jan 19 17:20:32 CET 2020
Commit: 78783b3e1685b0fc47a3cd34c9feff7ffd2dda85
Author: Antonio Vazquez
Date: Sun Jan 19 17:20:24 2020 +0100
Branches: greasepencil-refactor
https://developer.blender.org/rB78783b3e1685b0fc47a3cd34c9feff7ffd2dda85
GPencil: Test modifiers Tint and Hue/Saturation to use material if the Vertex color is not active.
===================================================================
M source/blender/gpencil_modifiers/intern/MOD_gpencilcolor.c
M source/blender/gpencil_modifiers/intern/MOD_gpenciltint.c
===================================================================
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilcolor.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilcolor.c
index 63c1067c0f2..a43b0a3d660 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilcolor.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilcolor.c
@@ -92,9 +92,18 @@ static void deformStroke(GpencilModifierData *md,
factor[1] -= 1.0f;
factor[2] -= 1.0f;
+ MaterialGPencilStyle *gp_style = BKE_material_gpencil_settings_get(ob, gps->mat_nr + 1);
+
/* Apply to Vertex Color. */
/* Fill */
if (mmd->modify_color != GP_MODIFY_COLOR_STROKE) {
+ /* If not using Vertex Color, use the material color. */
+ if ((gp_style != NULL) && (gps->vert_color_fill[3] == 0.0f) &&
+ (gp_style->fill_rgba[3] > 0.0f)) {
+ copy_v4_v4(gps->vert_color_fill, gp_style->fill_rgba);
+ gps->vert_color_fill[3] = 1.0f;
+ }
+
rgb_to_hsv_v(gps->vert_color_fill, hsv);
add_v3_v3(hsv, factor);
CLAMP3(hsv, 0.0f, 1.0f);
@@ -103,8 +112,15 @@ static void deformStroke(GpencilModifierData *md,
/* Stroke */
if (mmd->modify_color != GP_MODIFY_COLOR_FILL) {
+
for (int i = 0; i < gps->totpoints; i++) {
bGPDspoint *pt = &gps->points[i];
+ /* If not using Vertex Color, use the material color. */
+ if ((gp_style != NULL) && (pt->vert_color[3] == 0.0f) && (gp_style->stroke_rgba[3] > 0.0f)) {
+ copy_v4_v4(pt->vert_color, gp_style->stroke_rgba);
+ pt->vert_color[3] = 1.0f;
+ }
+
rgb_to_hsv_v(pt->vert_color, hsv);
add_v3_v3(hsv, factor);
CLAMP3(hsv, 0.0f, 1.0f);
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpenciltint.c b/source/blender/gpencil_modifiers/intern/MOD_gpenciltint.c
index 0dff2f7b089..646e210395c 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpenciltint.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpenciltint.c
@@ -84,6 +84,8 @@ static void deformStroke(GpencilModifierData *md,
return;
}
+ MaterialGPencilStyle *gp_style = BKE_material_gpencil_settings_get(ob, gps->mat_nr + 1);
+
/* if factor > 1.0, affect the strength of the stroke */
if (mmd->factor > 1.0f) {
for (int i = 0; i < gps->totpoints; i++) {
@@ -98,6 +100,13 @@ static void deformStroke(GpencilModifierData *md,
CLAMP(mixfac, 0.0, 1.0f);
/* Fill */
if (mmd->modify_color != GP_MODIFY_COLOR_STROKE) {
+ /* If not using Vertex Color, use the material color. */
+ if ((gp_style != NULL) && (gps->vert_color_fill[3] == 0.0f) &&
+ (gp_style->fill_rgba[3] > 0.0f)) {
+ copy_v4_v4(gps->vert_color_fill, gp_style->fill_rgba);
+ gps->vert_color_fill[3] = 1.0f;
+ }
+
interp_v3_v3v3(gps->vert_color_fill, gps->vert_color_fill, mmd->rgb, mixfac);
}
@@ -105,6 +114,12 @@ static void deformStroke(GpencilModifierData *md,
if (mmd->modify_color != GP_MODIFY_COLOR_FILL) {
for (int i = 0; i < gps->totpoints; i++) {
bGPDspoint *pt = &gps->points[i];
+ /* If not using Vertex Color, use the material color. */
+ if ((gp_style != NULL) && (pt->vert_color[3] == 0.0f) && (gp_style->stroke_rgba[3] > 0.0f)) {
+ copy_v4_v4(pt->vert_color, gp_style->stroke_rgba);
+ pt->vert_color[3] = 1.0f;
+ }
+
interp_v3_v3v3(pt->vert_color, pt->vert_color, mmd->rgb, mixfac);
}
}
More information about the Bf-blender-cvs
mailing list