[Bf-blender-cvs] [1db1e9f8169] greasepencil-object: Noise modifier move full stroke

Antonio Vazquez noreply at git.blender.org
Tue Jul 18 14:17:12 CEST 2017


Commit: 1db1e9f816916f901f37b40fd1b7dd11160fd09f
Author: Antonio Vazquez
Date:   Tue Jul 18 14:16:53 2017 +0200
Branches: greasepencil-object
https://developer.blender.org/rB1db1e9f816916f901f37b40fd1b7dd11160fd09f

Noise modifier move full stroke

Now it's possible to move points or full stroke

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

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

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

diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py
index 3374dc37590..a589668915f 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -1540,6 +1540,10 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
         row.enabled = md.random
         row.prop(md, "step")
 
+        row = col.row()
+        row.enabled = bool(md.step == 1 or md.random is False)
+        row.prop(md, "full_stroke")
+
         col = split.column()
         col.label("Layer:")
         col.prop_search(md, "layer", gpd, "layers", text="", icon="GREASEPENCIL")
diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c
index 56c99488379..27455d44c0d 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -1583,7 +1583,7 @@ static void ED_gpencil_stroke_normal(const bGPDstroke *gps, float r_normal[3])
 void ED_gpencil_noise_modifier(GpencilNoiseModifierData *mmd, bGPDlayer *gpl, bGPDstroke *gps)
 {
 	bGPDspoint *pt0, *pt1;
-	float shift, vran, vdir;
+	float shift, vran, vdir, vfull;
 	float normal[3];
 	float vec1[3], vec2[3];
 	Scene *scene = NULL;
@@ -1596,6 +1596,8 @@ void ED_gpencil_noise_modifier(GpencilNoiseModifierData *mmd, bGPDlayer *gpl, bG
 
 	scene = mmd->modifier.scene;
 	sc_frame = CFRA;
+	zero_v3(vec2);
+	vfull = BLI_frand();
 
 	/* calculate stroke normal*/
 	ED_gpencil_stroke_normal(gps, normal);
@@ -1614,9 +1616,16 @@ void ED_gpencil_noise_modifier(GpencilNoiseModifierData *mmd, bGPDlayer *gpl, bG
 		if (mmd->flag & GP_NOISE_USE_RANDOM) {
 			sc_diff = abs(mmd->scene_frame - sc_frame);
 			/* only recalc if the gp frame change or the number of scene frames is bigger than step */
-			if ((!gpl->actframe) || (mmd->gp_frame != gpl->actframe->framenum) || (sc_diff >= mmd->step)) {
+			if ((!gpl->actframe) || (mmd->gp_frame != gpl->actframe->framenum) || 
+				(sc_diff >= mmd->step) || (mmd->step == 1)) 
+			{
 				vran = mmd->vrand1 = BLI_frand();
-				vdir = mmd->vrand2 = BLI_frand();
+				if (mmd->flag & GP_NOISE_FULL_STROKE) {
+					vdir = mmd->vrand2 = vfull;
+				}
+				else {
+					vdir = mmd->vrand2 = BLI_frand();
+				}
 				mmd->gp_frame = gpl->actframe->framenum;
 				mmd->scene_frame = sc_frame;
 			}
@@ -1627,7 +1636,12 @@ void ED_gpencil_noise_modifier(GpencilNoiseModifierData *mmd, bGPDlayer *gpl, bG
 		}
 		else {
 			vran = 1.0f;
-			vdir = i % 2;
+			if (mmd->flag & GP_NOISE_FULL_STROKE) {
+				vdir = gps->totpoints % 2;
+			}
+			else {
+				vdir = i % 2;
+			}
 			mmd->gp_frame = -999999;
 		}
 
@@ -1650,7 +1664,7 @@ void ED_gpencil_noise_modifier(GpencilNoiseModifierData *mmd, bGPDlayer *gpl, bG
 				pt1->pressure -= pt1->pressure * vran * mmd->factor;
 			}
 			else {
-				pt1->pressure += pt1->pressure * vran * mmd->factor;;
+				pt1->pressure += pt1->pressure * vran * mmd->factor;
 			}
 			CLAMP_MIN(pt1->pressure, GPENCIL_STRENGTH_MIN);
 		}
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index f5cdfafea08..0fc1697e3b3 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -1633,6 +1633,7 @@ typedef enum eGpencilNoise_Flag {
 	GP_NOISE_MOD_LOCATION   = (1 << 1),
 	GP_NOISE_MOD_STRENGTH   = (1 << 2),
 	GP_NOISE_MOD_THICKNESS  = (1 << 3),
+	GP_NOISE_FULL_STROKE    = (1 << 4),
 } eGpencilNoise_Flag;
 
 
diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index 57ff93aef79..b75f9b12480 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -4814,6 +4814,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, "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");
+	RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
 	prop = RNA_def_property(srna, "passindex", PROP_INT, PROP_NONE);
 	RNA_def_property_int_sdna(prop, NULL, "passindex");
 	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 2f455b7157e..54c0d453d37 100644
--- a/source/blender/modifiers/intern/MOD_gpencilnoise.c
+++ b/source/blender/modifiers/intern/MOD_gpencilnoise.c
@@ -46,6 +46,7 @@ static void initData(ModifierData *md)
 	GpencilNoiseModifierData *gpmd = (GpencilNoiseModifierData *)md;
 	gpmd->passindex = 0;
 	gpmd->flag |= GP_NOISE_MOD_LOCATION;
+	gpmd->flag |= GP_NOISE_FULL_STROKE;
 	gpmd->factor = 0.5f;
 	gpmd->layername[0] = '\0';
 	gpmd->step = 1;




More information about the Bf-blender-cvs mailing list