[Bf-blender-cvs] [803f80c673f] greasepencil-object: Add UV rotation option to Smooth and Noise modifiers

Antonio Vazquez noreply at git.blender.org
Sat Feb 24 18:00:29 CET 2018


Commit: 803f80c673fd8c4794e354e7693113f476bb0553
Author: Antonio Vazquez
Date:   Sat Feb 24 18:00:07 2018 +0100
Branches: greasepencil-object
https://developer.blender.org/rB803f80c673fd8c4794e354e7693113f476bb0553

Add UV rotation option  to Smooth and Noise modifiers

To be consistent, the modifiers must work with UV rotation as the sculpt brushes do.

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

M	release/scripts/startup/bl_ui/properties_data_modifier.py
M	source/blender/makesdna/DNA_modifier_types.h
M	source/blender/makesrna/intern/rna_modifier.c
M	source/blender/modifiers/intern/MOD_gpencilnoise.c
M	source/blender/modifiers/intern/MOD_gpencilsmooth.c

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

diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py
index 89a7f112db0..76ecf48435d 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -1588,6 +1588,7 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
         row.prop(md, "affect_position", text="Position", icon='MESH_DATA', toggle=True)
         row.prop(md, "affect_strength", text="Strength", icon='COLOR', toggle=True)
         row.prop(md, "affect_thickness", text="Thickness", icon='LINE_DATA', toggle=True)
+        row.prop(md, "affect_uv", text="UV", icon='MOD_UVPROJECT', toggle=True)
 
     def GP_SMOOTH(self, layout, ob, md):
         gpd = ob.data
@@ -1618,6 +1619,7 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
         row.prop(md, "affect_position", text="Position", icon='MESH_DATA', toggle=True)
         row.prop(md, "affect_strength", text="Strength", icon='COLOR', toggle=True)
         row.prop(md, "affect_thickness", text="Thickness", icon='LINE_DATA', toggle=True)
+        row.prop(md, "affect_uv", text="UV", icon='MOD_UVPROJECT', toggle=True)
 
     def GP_SUBDIV(self, layout, ob, md):
         gpd = ob.data
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index 1726968ea03..49288e4ce00 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -1660,7 +1660,8 @@ typedef enum eGpencilNoise_Flag {
 	GP_NOISE_MOVE_EXTREME   = (1 << 5),
 	GP_NOISE_INVERSE_LAYER  = (1 << 6),
 	GP_NOISE_INVERSE_PASS   = (1 << 7),
-	GP_NOISE_INVERSE_VGROUP = (1 << 8)
+	GP_NOISE_INVERSE_VGROUP = (1 << 8),
+	GP_NOISE_MOD_UV         = (1 << 9),
 } eGpencilNoise_Flag;
 
 typedef struct GpencilSubdivModifierData {
@@ -1998,7 +1999,8 @@ typedef enum eGpencilSmooth_Flag {
 	GP_SMOOTH_MOD_THICKNESS = (1 << 2),
 	GP_SMOOTH_INVERSE_LAYER = (1 << 3),
 	GP_SMOOTH_INVERSE_PASS = (1 << 4),
-	GP_SMOOTH_INVERSE_VGROUP = (1 << 5)
+	GP_SMOOTH_INVERSE_VGROUP = (1 << 5),
+	GP_SMOOTH_MOD_UV         = (1 << 6),
 } eGpencilSmooth_Flag;
 
 #define MOD_MESHSEQ_READ_ALL \
diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index e9041b03b96..ad6ab4444ef 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -4960,6 +4960,11 @@ static void rna_def_modifier_gpencilnoise(BlenderRNA *brna)
 	RNA_def_property_ui_text(prop, "Affect Thickness", "The modifier affects the thickness of the point");
 	RNA_def_property_update(prop, 0, "rna_Modifier_update");
 
+	prop = RNA_def_property(srna, "affect_uv", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_NOISE_MOD_UV);
+	RNA_def_property_ui_text(prop, "Affect UV", "The modifier affects the UV rotation factor of the point");
+	RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
 	prop = RNA_def_property(srna, "full_stroke", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_NOISE_FULL_STROKE);
 	RNA_def_property_ui_text(prop, "Full Stroke", "The noise moves the stroke as a whole, not point by point");
@@ -5040,6 +5045,11 @@ static void rna_def_modifier_gpencilsmooth(BlenderRNA *brna)
 	RNA_def_property_ui_text(prop, "Affect Thickness", "The modifier affects the thickness of the point");
 	RNA_def_property_update(prop, 0, "rna_Modifier_update");
 	
+	prop = RNA_def_property(srna, "affect_uv", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_SMOOTH_MOD_UV);
+	RNA_def_property_ui_text(prop, "Affect UV", "The modifier affects the UV rotation factor of the point");
+	RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
 	prop = RNA_def_property(srna, "pass_index", PROP_INT, PROP_NONE);
 	RNA_def_property_int_sdna(prop, NULL, "pass_index");
 	RNA_def_property_range(prop, 0, 100);
diff --git a/source/blender/modifiers/intern/MOD_gpencilnoise.c b/source/blender/modifiers/intern/MOD_gpencilnoise.c
index 36c8b4c8e1b..85a8093d34f 100644
--- a/source/blender/modifiers/intern/MOD_gpencilnoise.c
+++ b/source/blender/modifiers/intern/MOD_gpencilnoise.c
@@ -206,6 +206,16 @@ static void deformStroke(ModifierData *md, const EvaluationContext *UNUSED(eval_
 			}
 			CLAMP_MIN(pt1->strength, GPENCIL_STRENGTH_MIN);
 		}
+		/* apply randomness to uv rotation */
+		if (mmd->flag & GP_NOISE_MOD_UV) {
+			if (vdir > 0.5f) {
+				pt1->uv_rot -= pt1->uv_rot * vran * mmd->factor;
+			}
+			else {
+				pt1->uv_rot += pt1->uv_rot * vran * mmd->factor;
+			}
+			CLAMP(pt1->uv_rot, -M_PI_2, M_PI_2);
+		}
 	}
 }
 
diff --git a/source/blender/modifiers/intern/MOD_gpencilsmooth.c b/source/blender/modifiers/intern/MOD_gpencilsmooth.c
index dacdce81bc9..6ec6bbf303f 100644
--- a/source/blender/modifiers/intern/MOD_gpencilsmooth.c
+++ b/source/blender/modifiers/intern/MOD_gpencilsmooth.c
@@ -101,6 +101,9 @@ static void deformStroke(ModifierData *md, const EvaluationContext *UNUSED(eval_
 						BKE_gp_smooth_stroke_thickness(gps, i, val);
 					}
 				}
+				if (mmd->flag & GP_SMOOTH_MOD_UV) {
+					BKE_gp_smooth_stroke_uv(gps, i, val);
+				}
 			}
 		}
 	}



More information about the Bf-blender-cvs mailing list