[Bf-blender-cvs] [ac1adbc3f15] greasepencil-object: GPencil: New parameter for gradient

Antonioya noreply at git.blender.org
Tue Mar 19 14:07:35 CET 2019


Commit: ac1adbc3f159d43c7d849565bf0b567fb9d14383
Author: Antonioya
Date:   Mon Mar 18 09:03:29 2019 +0100
Branches: greasepencil-object
https://developer.blender.org/rBac1adbc3f159d43c7d849565bf0b567fb9d14383

GPencil: New parameter for gradient

Add new fields and initialize.

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

M	release/scripts/startup/bl_ui/space_view3d_toolbar.py
M	source/blender/blenloader/intern/versioning_280.c
M	source/blender/makesdna/DNA_brush_types.h
M	source/blender/makesdna/DNA_gpencil_types.h
M	source/blender/makesrna/intern/rna_brush.c
M	source/blender/makesrna/intern/rna_gpencil.c

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

diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index a37e54d40a8..6a1c32be88e 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -1545,6 +1545,8 @@ class VIEW3D_PT_tools_grease_pencil_brush_option(View3DPanel, Panel):
             col.prop(gp_settings, "angle", slider=True)
             col.prop(gp_settings, "angle_factor", text="Factor", slider=True)
             col.separator()
+            col.prop(gp_settings, "gradient_factor", slider=True)
+            col.prop(gp_settings, "gradient_shape")
 
 
 class VIEW3D_PT_tools_grease_pencil_brush_stabilizer(View3DPanel, Panel):
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index 986f35008bd..be1bfea540c 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -2920,5 +2920,31 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
 				part->draw_as = PART_DRAW_NOT;
 			}
 		}
+		/* init grease pencil brush gradients */
+		if (!DNA_struct_elem_find(fd->filesdna, "BrushGpencilSettings", "float", "gradient_f")) {
+			for (Brush *brush = bmain->brushes.first; brush; brush = brush->id.next) {
+				if (brush->gpencil_settings != NULL) {
+					BrushGpencilSettings *gp = brush->gpencil_settings;
+					gp->gradient_f = 1.0f;
+					gp->gradient_s[0] = 1.0f;
+					gp->gradient_s[1] = 1.0f;
+				}
+			}
+		}
+
+		/* init grease pencil stroke gradients */
+		if (!DNA_struct_elem_find(fd->filesdna, "bGPDstroke", "float", "gradient_f")) {
+			for (bGPdata *gpd = bmain->gpencils.first; gpd; gpd = gpd->id.next) {
+				for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
+					for (bGPDframe *gpf = gpl->frames.first; gpf; gpf = gpf->next) {
+						for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
+							gps->gradient_f = 1.0f;
+							gps->gradient_s[0] = 1.0f;
+							gps->gradient_s[1] = 1.0f;
+						}
+					}
+				}
+			}
+		}
 	}
 }
diff --git a/source/blender/makesdna/DNA_brush_types.h b/source/blender/makesdna/DNA_brush_types.h
index 4bfbb3655af..9aa6ff8c1c8 100644
--- a/source/blender/makesdna/DNA_brush_types.h
+++ b/source/blender/makesdna/DNA_brush_types.h
@@ -111,6 +111,12 @@ typedef struct BrushGpencilSettings {
 	/** Internal grease pencil drawing flags. */
 	int flag;
 
+	/** gradient control along y for color */
+	float gradient_f;
+	/** factor xy of shape for dots gradients */
+	float gradient_s[2];
+	char _pad_2[4];
+
 	struct CurveMapping *curve_sensitivity;
 	struct CurveMapping *curve_strength;
 	struct CurveMapping *curve_jitter;
diff --git a/source/blender/makesdna/DNA_gpencil_types.h b/source/blender/makesdna/DNA_gpencil_types.h
index bd17d4e57dc..363c1dd504d 100644
--- a/source/blender/makesdna/DNA_gpencil_types.h
+++ b/source/blender/makesdna/DNA_gpencil_types.h
@@ -199,6 +199,12 @@ typedef struct bGPDstroke {
 	/** Caps mode for each stroke extreme */
 	short caps[2];
 
+	/** gradient control along y for color */
+	float gradient_f;
+	/** factor xy of shape for dots gradients */
+	float gradient_s[2];
+	char _pad_3[4];
+
 	/** Vertex weight data. */
 	struct MDeformVert *dvert;
 
diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c
index 86ac8d3bae6..6bfa8f84e02 100644
--- a/source/blender/makesrna/intern/rna_brush.c
+++ b/source/blender/makesrna/intern/rna_brush.c
@@ -1186,6 +1186,25 @@ static void rna_def_gpencil_options(BlenderRNA *brna)
 	RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
 	RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
 
+	/* gradient control along y */
+	prop = RNA_def_property(srna, "gradient_factor", PROP_FLOAT, PROP_FACTOR);
+	RNA_def_property_float_sdna(prop, NULL, "gradient_f");
+	RNA_def_property_range(prop, 0.01f, 1.0f);
+	RNA_def_property_float_default(prop, 1.0f);
+	RNA_def_property_ui_text(
+		prop, "Gradient Factor",
+		"Amount of gradient along section of stroke (set to 1 for full solid)");
+	RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+
+	/* gradient shape ratio */
+	prop = RNA_def_property(srna, "gradient_shape", PROP_FLOAT, PROP_XYZ);
+	RNA_def_property_float_sdna(prop, NULL, "gradient_s");
+	RNA_def_property_array(prop, 2);
+	RNA_def_property_range(prop, 0.01f, 1.0f);
+	RNA_def_property_float_default(prop, 1.0f);
+	RNA_def_property_ui_text(prop, "Aspect Ratio", "");
+	RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+
 	prop = RNA_def_property(srna, "input_samples", PROP_INT, PROP_NONE);
 	RNA_def_property_int_sdna(prop, NULL, "input_samples");
 	RNA_def_property_range(prop, 0, GP_MAX_INPUT_SAMPLES);
diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c
index 7c8a79a7563..7f042fc5c8a 100644
--- a/source/blender/makesrna/intern/rna_gpencil.c
+++ b/source/blender/makesrna/intern/rna_gpencil.c
@@ -998,6 +998,24 @@ static void rna_def_gpencil_stroke(BlenderRNA *brna)
 	RNA_def_property_ui_text(prop, "Thickness", "Thickness of stroke (in pixels)");
 	RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
 
+	/* gradient control along y */
+	prop = RNA_def_property(srna, "gradient_factor", PROP_FLOAT, PROP_FACTOR);
+	RNA_def_property_float_sdna(prop, NULL, "gradient_f");
+	RNA_def_property_range(prop, 0.01f, 1.0f);
+	RNA_def_property_float_default(prop, 1.0f);
+	RNA_def_property_ui_text(prop, "Gradient Factor",
+		"Amount of gradient along section of stroke");
+	RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+	RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
+
+	/* gradient shape ratio */
+	prop = RNA_def_property(srna, "gradient_shape", PROP_FLOAT, PROP_XYZ);
+	RNA_def_property_float_sdna(prop, NULL, "gradient_s");
+	RNA_def_property_array(prop, 2);
+	RNA_def_property_range(prop, 0.01f, 1.0f);
+	RNA_def_property_float_default(prop, 1.0f);
+	RNA_def_property_ui_text(prop, "Aspect Ratio", "");
+	RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
 }
 
 static void rna_def_gpencil_strokes_api(BlenderRNA *brna, PropertyRNA *cprop)



More information about the Bf-blender-cvs mailing list