[Bf-blender-cvs] [5cf987c] master: Patch T38282/D295: Add a time offset to the FCurve Noise Modifier

Bassam Kurdali noreply at git.blender.org
Mon Feb 10 04:27:02 CET 2014


Commit: 5cf987cff8276625735c789f18c9f77c507b70b0
Author: Bassam Kurdali
Date:   Mon Feb 10 15:23:01 2014 +1300
https://developer.blender.org/rB5cf987cff8276625735c789f18c9f77c507b70b0

Patch T38282/D295: Add a time offset to the FCurve Noise Modifier

FCurve Noise Modifer now has an extra float property which offsets the noise in time.
This is useful for creating follow through in procedurally animated noise.

For example, if you've used a noise modifier on a parent bone to add additional movement,
a quick and easy way to add overlapping motion is to create copies of that modifier on
its children, and then offset the time those curves play at. See this in action at:
http://youtu.be/Ph6fk_z_k3k

Reviewed By: Joshua Leung

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

M	source/blender/blenkernel/intern/fmodifier.c
M	source/blender/editors/animation/fmodifier_ui.c
M	source/blender/makesdna/DNA_anim_types.h
M	source/blender/makesrna/intern/rna_fcurve.c

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

diff --git a/source/blender/blenkernel/intern/fmodifier.c b/source/blender/blenkernel/intern/fmodifier.c
index 6c98808..bcbc557 100644
--- a/source/blender/blenkernel/intern/fmodifier.c
+++ b/source/blender/blenkernel/intern/fmodifier.c
@@ -785,6 +785,7 @@ static void fcm_noise_new_data(void *mdata)
 	data->size = 1.0f;
 	data->strength = 1.0f;
 	data->phase = 1.0f;
+	data->offset = 0.0f;
 	data->depth = 0;
 	data->modification = FCM_NOISE_MODIF_REPLACE;
 }
@@ -798,7 +799,7 @@ static void fcm_noise_evaluate(FCurve *UNUSED(fcu), FModifier *fcm, float *cvalu
 	 *	- 0.1 is passed as the 'z' value, otherwise evaluation fails for size = phase = 1
 	 *	  with evaltime being an integer (which happens when evaluating on frame by frame basis)
 	 */
-	noise = BLI_turbulence(data->size, evaltime, data->phase, 0.1f, data->depth);
+	noise = BLI_turbulence(data->size, evaltime - data->offset, data->phase, 0.1f, data->depth);
 	
 	/* combine the noise with existing motion data */
 	switch (data->modification) {
diff --git a/source/blender/editors/animation/fmodifier_ui.c b/source/blender/editors/animation/fmodifier_ui.c
index 5ceca47..75ea133 100644
--- a/source/blender/editors/animation/fmodifier_ui.c
+++ b/source/blender/editors/animation/fmodifier_ui.c
@@ -320,6 +320,7 @@ static void draw_modifier__noise(uiLayout *layout, ID *id, FModifier *fcm, short
 	col = uiLayoutColumn(split, FALSE);
 	uiItemR(col, &ptr, "scale", 0, NULL, ICON_NONE);
 	uiItemR(col, &ptr, "strength", 0, NULL, ICON_NONE);
+	uiItemR(col, &ptr, "offset", 0, NULL, ICON_NONE);
 	
 	/* col 2 */
 	col = uiLayoutColumn(split, FALSE);
diff --git a/source/blender/makesdna/DNA_anim_types.h b/source/blender/makesdna/DNA_anim_types.h
index 6f5c925..8c04c41 100644
--- a/source/blender/makesdna/DNA_anim_types.h
+++ b/source/blender/makesdna/DNA_anim_types.h
@@ -228,7 +228,7 @@ typedef struct FMod_Noise {
 	float size;
 	float strength;
 	float phase;
-	float pad;
+	float offset;
 	
 	short depth;
 	short modification;
diff --git a/source/blender/makesrna/intern/rna_fcurve.c b/source/blender/makesrna/intern/rna_fcurve.c
index 071309d..3f7a00d 100644
--- a/source/blender/makesrna/intern/rna_fcurve.c
+++ b/source/blender/makesrna/intern/rna_fcurve.c
@@ -1174,6 +1174,11 @@ static void rna_def_fmodifier_noise(BlenderRNA *brna)
 	RNA_def_property_float_sdna(prop, NULL, "phase");
 	RNA_def_property_ui_text(prop, "Phase", "A random seed for the noise effect");
 	RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
+
+	prop = RNA_def_property(srna, "offset", PROP_FLOAT, PROP_NONE);
+	RNA_def_property_float_sdna(prop, NULL, "offset");
+	RNA_def_property_ui_text(prop, "Offset", "Time offset for the noise effect");
+	RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
 	
 	prop = RNA_def_property(srna, "depth", PROP_INT, PROP_UNSIGNED);
 	RNA_def_property_int_sdna(prop, NULL, "depth");




More information about the Bf-blender-cvs mailing list