[Bf-blender-cvs] [33a62c42779] greasepencil-object: GPencil: Add option to Follow Drawing Path

Antonioya noreply at git.blender.org
Fri Apr 12 15:53:56 CEST 2019


Commit: 33a62c42779a1a4558982359ecd082a3c43c60ae
Author: Antonioya
Date:   Fri Apr 12 15:53:49 2019 +0200
Branches: greasepencil-object
https://developer.blender.org/rB33a62c42779a1a4558982359ecd082a3c43c60ae

GPencil: Add option to Follow Drawing Path

This option allows to enable or disable the automatic orientation of Dot and Box strokes.

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

M	release/scripts/startup/bl_ui/properties_material_gpencil.py
M	source/blender/draw/engines/gpencil/gpencil_draw_utils.c
M	source/blender/draw/engines/gpencil/gpencil_engine.h
M	source/blender/draw/engines/gpencil/shaders/gpencil_point_geom.glsl
M	source/blender/makesdna/DNA_material_types.h
M	source/blender/makesrna/intern/rna_material.c

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

diff --git a/release/scripts/startup/bl_ui/properties_material_gpencil.py b/release/scripts/startup/bl_ui/properties_material_gpencil.py
index 24ba786f7af..8cb59ceee5c 100644
--- a/release/scripts/startup/bl_ui/properties_material_gpencil.py
+++ b/release/scripts/startup/bl_ui/properties_material_gpencil.py
@@ -148,6 +148,9 @@ class MATERIAL_PT_gpencil_strokecolor(GPMaterialButtonsPanel, Panel):
             if gpcolor.stroke_style == 'SOLID' or gpcolor.use_stroke_pattern is True:
                 col.prop(gpcolor, "color", text="Color")
 
+            if gpcolor.mode in {'DOTS', 'BOX'}:
+                col.prop(gpcolor, "use_follow_path", text="Follow Drawing Path")
+
 
 class MATERIAL_PT_gpencil_fillcolor(GPMaterialButtonsPanel, Panel):
     bl_label = "Fill"
diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
index 1ed3ae74d9e..7affad54ee5 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
@@ -714,6 +714,11 @@ static DRWShadingGroup *DRW_gpencil_shgroup_point_create(
 		DRW_shgroup_uniform_int(grp, "xraymode", &stl->storage->xray, 1);
 	}
 
+	/* lock rotation of dots and boxes */
+	stl->shgroups[id].use_follow_path = (gp_style->flag & GP_STYLE_COLOR_LOCK_DOTS) ? 0 : 1;
+	DRW_shgroup_uniform_int(grp, "use_follow_path", &stl->shgroups[id].use_follow_path, 1);
+
+
 	/* image texture */
 	if ((gp_style) && (gp_style->stroke_style == GP_STYLE_STROKE_STYLE_TEXTURE) && (!onion)) {
 		ImBuf *ibuf;
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.h b/source/blender/draw/engines/gpencil/gpencil_engine.h
index 8ae48094153..0973877f65b 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.h
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.h
@@ -119,6 +119,7 @@ typedef struct GPENCIL_shgroup {
 	int caps_mode[2];
 	float obj_scale;
 	int xray_mode;
+	int use_follow_path;
 
 	float gradient_f;
 	float gradient_s[2];
diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_point_geom.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_point_geom.glsl
index 1e27d9545f5..32aaa057298 100644
--- a/source/blender/draw/engines/gpencil/shaders/gpencil_point_geom.glsl
+++ b/source/blender/draw/engines/gpencil/shaders/gpencil_point_geom.glsl
@@ -1,6 +1,7 @@
 uniform mat4 ModelViewProjectionMatrix;
 uniform vec2 Viewport;
 uniform int xraymode;
+uniform int use_follow_path;
 
 layout(points) in;
 layout(triangle_strip, max_vertices = 4) out;
@@ -18,6 +19,7 @@ out vec2 mTexCoord;
 
 #define M_PI        3.14159265358979323846  /* pi */
 #define M_2PI       6.28318530717958647692  /* 2*pi */
+#define FALSE       0
 
 /* project 3d point to 2d on screen space */
 vec2 toScreenSpace(vec4 vertex)
@@ -68,6 +70,10 @@ float getAngle(vec2 pt0, vec2 pt1)
 		return 0.0;
 	}	
 
+	if (use_follow_path == FALSE) {
+		return 0.0;
+	}
+
 	/* default horizontal line (x-axis) in screen space */
 	vec2 v0 = vec2(1.0, 0.0);
 	
diff --git a/source/blender/makesdna/DNA_material_types.h b/source/blender/makesdna/DNA_material_types.h
index 718ca4f3b7d..6b5aeeae8fa 100644
--- a/source/blender/makesdna/DNA_material_types.h
+++ b/source/blender/makesdna/DNA_material_types.h
@@ -121,6 +121,8 @@ typedef enum eMaterialGPencilStyle_Flag {
 	GP_STYLE_STROKE_SHOW = (1 << 8),
 	/* Fill  show main switch */
 	GP_STYLE_FILL_SHOW = (1 << 9),
+	/* Don't rotate dots/boxes */
+	GP_STYLE_COLOR_LOCK_DOTS = (1 << 10)
 } eMaterialGPencilStyle_Flag;
 
 typedef enum eMaterialGPencilStyle_Mode {
diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c
index 5445db78582..c733eeab1ac 100644
--- a/source/blender/makesrna/intern/rna_material.c
+++ b/source/blender/makesrna/intern/rna_material.c
@@ -585,6 +585,13 @@ static void rna_def_material_greasepencil(BlenderRNA *brna)
 	RNA_def_property_ui_text(prop, "Show Fill", "Show stroke fills of this material");
 	RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update");
 
+	/* keep Dots and Boxes aligned to screen and not to drawing path */
+	prop = RNA_def_property(srna, "use_follow_path", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GP_STYLE_COLOR_LOCK_DOTS);
+	RNA_def_property_ui_text(prop, "Follow Path",
+		"Keep Dots and Boxes aligned to drawing path");
+	RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_nopreview_update");
+
 	/* pass index for future compositing and editing tools */
 	prop = RNA_def_property(srna, "pass_index", PROP_INT, PROP_UNSIGNED);
 	RNA_def_property_int_sdna(prop, NULL, "index");



More information about the Bf-blender-cvs mailing list