[Bf-blender-cvs] [8d26705b3e4] blender2.8: GP: Add z-depth offset parameter

Antonioya noreply at git.blender.org
Wed Oct 3 10:55:31 CEST 2018


Commit: 8d26705b3e4e780145d43cfde0c1a2c302c425e0
Author: Antonioya
Date:   Wed Oct 3 10:55:07 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB8d26705b3e4e780145d43cfde0c1a2c302c425e0

GP: Add z-depth offset parameter

This parameter allows to define the percentage of offset of a stroke when uses surface mode.

Before, this was a fixed value, but for some artists' purposes, it's good to have the option to change it.

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

M	release/scripts/startup/bl_ui/properties_data_gpencil.py
M	source/blender/editors/gpencil/gpencil_paint.c
M	source/blender/makesdna/DNA_gpencil_types.h
M	source/blender/makesrna/intern/rna_gpencil.c

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

diff --git a/release/scripts/startup/bl_ui/properties_data_gpencil.py b/release/scripts/startup/bl_ui/properties_data_gpencil.py
index 5d3d29dbe24..3c9a30ff882 100644
--- a/release/scripts/startup/bl_ui/properties_data_gpencil.py
+++ b/release/scripts/startup/bl_ui/properties_data_gpencil.py
@@ -344,6 +344,7 @@ class DATA_PT_gpencil_display(DataButtonsPanel, Panel):
             layout.prop(gpd, "show_stroke_direction", text="Show Stroke Directions")
 
         layout.prop(gpd, "use_force_fill_recalc", text="Force Fill Update")
+        layout.prop(gpd, "zdepth_offset", text="Surface Offset")
 
 
 class DATA_PT_custom_props_gpencil(DataButtonsPanel, PropertyPanel, Panel):
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index 7b2a106b5cc..85479de7a77 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -371,12 +371,9 @@ static void gp_stroke_convertcoords(tGPsdata *p, const int mval[2], float out[3]
 	/* in 3d-space - pt->x/y/z are 3 side-by-side floats */
 	if (gpd->runtime.sbuffer_sflag & GP_STROKE_3DSPACE) {
 
-		/* add small offset to keep stroke over the surface.
-		 * This could be a UI parameter, but the value is too sensitive for
-		 * the user to use it and don't improve the result.
-		 */
-		if (depth) {
-			*depth *= 0.99998f;
+		/* add small offset to keep stroke over the surface */
+		if ((depth) && (gpd->zdepth_offset > 0.0f)) {
+			*depth *= (1.0f - gpd->zdepth_offset);
 		}
 
 		if (gpencil_project_check(p) && (ED_view3d_autodist_simple(p->ar, mval, out, 0, depth))) {
diff --git a/source/blender/makesdna/DNA_gpencil_types.h b/source/blender/makesdna/DNA_gpencil_types.h
index b1cf1f6db80..b533cb48886 100644
--- a/source/blender/makesdna/DNA_gpencil_types.h
+++ b/source/blender/makesdna/DNA_gpencil_types.h
@@ -354,7 +354,7 @@ typedef struct bGPdata {
 	float gcolor_prev[3];	    /* optional color for ghosts before the active frame */
 	float gcolor_next[3];	    /* optional color for ghosts after the active frame */
 
-	char pad[4];
+	float zdepth_offset;        /* offset for drawing over surfaces to keep strokes on top */
 	struct Material **mat;      /* materials array */
 	short totcol;               /* total materials */
 
diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c
index b0276eddac7..0cd738a9552 100644
--- a/source/blender/makesrna/intern/rna_gpencil.c
+++ b/source/blender/makesrna/intern/rna_gpencil.c
@@ -1404,6 +1404,14 @@ static void rna_def_gpencil_data(BlenderRNA *brna)
 	RNA_def_property_ui_text(prop, "Onion Opacity", "Change fade opacity of displayed onion frames");
 	RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
 
+	prop = RNA_def_property(srna, "zdepth_offset", PROP_FLOAT, PROP_NONE);
+	RNA_def_property_float_sdna(prop, NULL, "zdepth_offset");
+	RNA_def_property_range(prop, 0.0f, 1.0f);
+	RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.001, 5);
+	RNA_def_property_ui_text(prop, "Surface Offset",
+		"Offset amount when drawing in surface mode");
+	RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
+
 	/* API Functions */
 	func = RNA_def_function(srna, "clear", "rna_GPencil_clear");
 	RNA_def_function_ui_description(func, "Remove all the grease pencil data");



More information about the Bf-blender-cvs mailing list