[Bf-blender-cvs] [92d7c9b71ed] greasepencil-object: More work on Noise modifier

Antonio Vazquez noreply at git.blender.org
Tue Jul 18 16:56:16 CEST 2017


Commit: 92d7c9b71ed029b0200a49f9b331f2e9ce1a4f77
Author: Antonio Vazquez
Date:   Tue Jul 18 16:56:05 2017 +0200
Branches: greasepencil-object
https://developer.blender.org/rB92d7c9b71ed029b0200a49f9b331f2e9ce1a4f77

More work on Noise modifier

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

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

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

diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py
index a589668915f..6e56461481d 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -1539,10 +1539,8 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
         row = col.row()
         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.prop(md, "full_stroke")
+        col.prop(md, "move_extreme")
 
         col = split.column()
         col.label("Layer:")
diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c
index 88f7a68be8a..d928cc3d249 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, vfull;
+	float shift, vran, vdir;
 	float normal[3];
 	float vec1[3], vec2[3];
 	Scene *scene = NULL;
@@ -1598,15 +1598,26 @@ void ED_gpencil_noise_modifier(GpencilNoiseModifierData *mmd, bGPDlayer *gpl, bG
 	sc_frame = (scene) ? CFRA : 0;
 
 	zero_v3(vec2);
-	vfull = BLI_frand();
 
 	/* calculate stroke normal*/
 	ED_gpencil_stroke_normal(gps, normal);
 
-	/* move points (starting in point 2) */
-	for (int i = 1; i < gps->totpoints - 1; i++) {
-		pt0 = &gps->points[i - 1];
-		pt1 = &gps->points[i];
+	/* move points */
+	for (int i = 0; i < gps->totpoints; i++) {
+		if (((i == 0) || (i == gps->totpoints - 1)) && ((mmd->flag & GP_NOISE_MOVE_EXTREME) == 0))
+		{
+			continue;
+		}
+
+		/* last point is special */
+		if (i == gps->totpoints) {
+			pt0 = &gps->points[i - 2];
+			pt1 = &gps->points[i - 1];
+		}
+		else {
+			pt0 = &gps->points[i - 1];
+			pt1 = &gps->points[i];
+		}
 		/* initial vector (p0 -> p1) */
 		sub_v3_v3v3(vec1, &pt1->x, &pt0->x);
 		vran = len_v3(vec1);
@@ -1618,21 +1629,22 @@ void ED_gpencil_noise_modifier(GpencilNoiseModifierData *mmd, bGPDlayer *gpl, bG
 			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) || (mmd->step == 1)) 
+				(sc_diff >= mmd->step)) 
 			{
 				vran = mmd->vrand1 = BLI_frand();
-				if (mmd->flag & GP_NOISE_FULL_STROKE) {
-					vdir = mmd->vrand2 = vfull;
-				}
-				else {
-					vdir = mmd->vrand2 = BLI_frand();
-				}
+				vdir = mmd->vrand2 = BLI_frand();
 				mmd->gp_frame = gpl->actframe->framenum;
 				mmd->scene_frame = sc_frame;
 			}
 			else {
 				vran = mmd->vrand1;
-				vdir = mmd->vrand2;
+				if (mmd->flag & GP_NOISE_FULL_STROKE) {
+					vdir = mmd->vrand2;
+				}
+				else {
+					int f = (mmd->vrand2 * 10.0f) + i;
+					vdir = f % 2;
+				}
 			}
 		}
 		else {
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index 0fc1697e3b3..1d3a50742f9 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -1634,6 +1634,7 @@ typedef enum eGpencilNoise_Flag {
 	GP_NOISE_MOD_STRENGTH   = (1 << 2),
 	GP_NOISE_MOD_THICKNESS  = (1 << 3),
 	GP_NOISE_FULL_STROKE    = (1 << 4),
+	GP_NOISE_MOVE_EXTREME   = (1 << 5),
 } eGpencilNoise_Flag;
 
 
diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index b75f9b12480..18d285ceb0a 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -4819,6 +4819,11 @@ static void rna_def_modifier_gpencilnoise(BlenderRNA *brna)
 	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, "move_extreme", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_NOISE_MOVE_EXTREME);
+	RNA_def_property_ui_text(prop, "Move Extremes", "The noise moves the stroke extreme points");
+	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);




More information about the Bf-blender-cvs mailing list