[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [32191] trunk/blender: Cleanup of code and ui of sequencer speed effect.

Janne Karhu jhkarh at gmail.com
Wed Sep 29 15:38:43 CEST 2010


Revision: 32191
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=32191
Author:   jhk
Date:     2010-09-29 15:38:43 +0200 (Wed, 29 Sep 2010)

Log Message:
-----------
Cleanup of code and ui of sequencer speed effect.
* Sequence speed effect was functional in theory, but very difficult to actually use.
* Now the effect works as follows:
  - "Speed Factor" (formerly "speed fade") controls the current speed of the sequence (can be animated).
  - "Use as speed" (formerly "f-curve velocity") is now the default behavior so that the "speed effect" by default changes the "speed" of the sequence.
  - "Multiply Speed" (formerly "global speed") is a scale factor that's applied to the calculated frame (can't be animated).
  - Without animation "Speed Factor" and "Multiply Speed" work exactly the same (in this case "multiply speed" could perhaps be disabled in ui, but currently there's no easy way to check this).
  - If "Use as speed" is not checked the effect simply remaps the current frame to the given "Frame Number" (can be animated).
  - "Scale to length" (formerly "f-curve compress y")scales "Frame numbers" from 0.0-1.0 to the length of the target strip to allow easy animation.
* Tooltips added for all values and options.
* Code for frame blending was nowhere to be seen, so I commented the option out from ui.
* This should fix at least bugs #20979 and #21309.

Modified Paths:
--------------
    trunk/blender/release/scripts/ui/space_sequencer.py
    trunk/blender/source/blender/blenkernel/intern/seqeffects.c
    trunk/blender/source/blender/makesrna/intern/rna_sequencer.c

Modified: trunk/blender/release/scripts/ui/space_sequencer.py
===================================================================
--- trunk/blender/release/scripts/ui/space_sequencer.py	2010-09-29 12:46:26 UTC (rev 32190)
+++ trunk/blender/release/scripts/ui/space_sequencer.py	2010-09-29 13:38:43 UTC (rev 32191)
@@ -435,12 +435,15 @@
             row.prop(strip, "use_only_boost")
 
         elif strip.type == 'SPEED':
-            layout.prop(strip, "global_speed")
+            layout.prop(strip, "use_as_speed")
+            if strip.use_as_speed:
+                layout.prop(strip, "speed_factor")
+            else:
+                layout.prop(strip, "speed_factor", text="Frame number")
+                layout.prop(strip, "scale_to_length")
 
-            flow = layout.column_flow()
-            flow.prop(strip, "use_curve_velocity")
-            flow.prop(strip, "use_curve_compress_y")
-            flow.prop(strip, "use_frame_blend")
+            #doesn't work currently
+            #layout.prop(strip, "use_frame_blend")
 
         elif strip.type == 'TRANSFORM':
             self.draw_panel_transform(strip)
@@ -460,7 +463,7 @@
 
         col = layout.column(align=True)
         if strip.type == 'SPEED':
-            col.prop(strip, "speed_fader", text="Speed fader")
+            col.prop(strip, "multiply_speed")
         elif strip.type in ('CROSS', 'GAMMA_CROSS', 'PLUGIN', 'WIPE'):
                 col.prop(strip, "use_default_fade", "Default fade")
                 if not strip.use_default_fade:

Modified: trunk/blender/source/blender/blenkernel/intern/seqeffects.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/seqeffects.c	2010-09-29 12:46:26 UTC (rev 32190)
+++ trunk/blender/source/blender/blenkernel/intern/seqeffects.c	2010-09-29 13:38:43 UTC (rev 32191)
@@ -2873,7 +2873,7 @@
 	v = (SpeedControlVars *)seq->effectdata;
 	v->globalSpeed = 1.0;
 	v->frameMap = 0;
-	v->flags = 0;
+	v->flags |= SEQ_SPEED_INTEGRATE; /* should be default behavior */
 	v->length = 0;
 }
 
@@ -2936,9 +2936,8 @@
 }
 void sequence_effect_speed_rebuild_map(Scene *scene, Sequence * seq, int force)
 {
-	float ctime, div;
 	int cfra;
-	float fallback_fac;
+	float fallback_fac = 1.0f;
 	SpeedControlVars * v = (SpeedControlVars *)seq->effectdata;
 	FCurve *fcu= NULL;
 
@@ -2955,7 +2954,7 @@
 
 	/* XXX - new in 2.5x. should we use the animation system this way?
 	 * The fcurve is needed because many frames need evaluating at once - campbell */
-	fcu= id_data_find_fcurve(&scene->id, seq, &RNA_Sequence, "speed_fader", 0);
+	fcu= id_data_find_fcurve(&scene->id, seq, &RNA_Sequence, "speed_factor", 0);
 
 
 	if (!v->frameMap || v->length != seq->len) {
@@ -2966,17 +2965,12 @@
 		v->frameMap = MEM_callocN(sizeof(float) * v->length, 
 					  "speedcontrol frameMap");
 	}
-
-	fallback_fac = 1.0;
 	
-	/* if there is no fcurve, try to make retiming easy by stretching the
-	   strip */
-	if (!fcu && seq->seq1->enddisp != seq->seq1->start && seq->seq1->len != 0) {
-		fallback_fac = (float) seq->seq1->len / 
-			(float) (seq->seq1->enddisp - seq->seq1->start);
-	}
+	/* if there is no fcurve, use value as simple multiplier */
+	if (!fcu)
+		fallback_fac = seq->speed_fader; /* same as speed_factor in rna*/
 
-	if ((v->flags & SEQ_SPEED_INTEGRATE) != 0) {
+	if (v->flags & SEQ_SPEED_INTEGRATE) {
 		float cursor = 0;
 		float facf;
 
@@ -2985,10 +2979,7 @@
 
 		for (cfra = 1; cfra < v->length; cfra++) {
 			if(fcu) {
-				ctime = seq->startdisp + cfra;
-				div = 1.0;
-				
-				facf = evaluate_fcurve(fcu, ctime/div);
+				facf = evaluate_fcurve(fcu, seq->startdisp + cfra);
 			} else {
 				facf = fallback_fac;
 			}
@@ -3010,19 +3001,16 @@
 		for (cfra = 0; cfra < v->length; cfra++) {
 
 			if(fcu) {
-				ctime = seq->startdisp + cfra;
-				div = 1.0;
-				
-				facf = evaluate_fcurve(fcu, ctime / div);
-				if (v->flags & SEQ_SPEED_COMPRESS_IPO_Y) {
-					facf *= v->length;
-				}
+				facf = evaluate_fcurve(fcu, seq->startdisp + cfra);
+			} else {
+				facf = fallback_fac;
 			}
-			
-			if (!fcu) {
-				facf = (float) cfra * fallback_fac;
+
+			if (v->flags & SEQ_SPEED_COMPRESS_IPO_Y) {
+				facf *= v->length;
 			}
 			facf *= v->globalSpeed;
+			
 			if (facf >= seq->seq1->len) {
 				facf = seq->seq1->len - 1;
 			} else {

Modified: trunk/blender/source/blender/makesrna/intern/rna_sequencer.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_sequencer.c	2010-09-29 12:46:26 UTC (rev 32190)
+++ trunk/blender/source/blender/makesrna/intern/rna_sequencer.c	2010-09-29 13:38:43 UTC (rev 32191)
@@ -980,9 +980,9 @@
 	RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update");
 	
 
-	prop= RNA_def_property(srna, "speed_fader", PROP_FLOAT, PROP_NONE);
+	prop= RNA_def_property(srna, "speed_factor", PROP_FLOAT, PROP_NONE);
 	RNA_def_property_float_sdna(prop, NULL, "speed_fader");
-	RNA_def_property_ui_text(prop, "Speed effect fader position", "");
+	RNA_def_property_ui_text(prop, "Speed factor", "Multiply the current speed of the sequence with this number or remap current frame to this frame");
 	RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update");
 
 	RNA_api_sequence_strip(srna);
@@ -1535,16 +1535,16 @@
 	RNA_def_struct_ui_text(srna, "SpeedControl Sequence", "Sequence strip to control the speed of other strips");
 	RNA_def_struct_sdna_from(srna, "SpeedControlVars", "effectdata");
 	
-	prop= RNA_def_property(srna, "global_speed", PROP_FLOAT, PROP_UNSIGNED);
+	prop= RNA_def_property(srna, "multiply_speed", PROP_FLOAT, PROP_UNSIGNED);
 	RNA_def_property_float_sdna(prop, NULL, "globalSpeed");
 	RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); /* seq->facf0 is used to animate this */
-	RNA_def_property_ui_text(prop, "Global Speed", "");
+	RNA_def_property_ui_text(prop, "Multiply Speed", "Multiply the resulting speed after the speed factor");
 	RNA_def_property_ui_range(prop, 0.0f, 100.0f, 1, 0);
 	RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update");
 	
-	prop= RNA_def_property(srna, "use_curve_velocity", PROP_BOOLEAN, PROP_NONE);
+	prop= RNA_def_property(srna, "use_as_speed", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "flags", SEQ_SPEED_INTEGRATE);
-	RNA_def_property_ui_text(prop, "F-Curve Velocity", "Interpret the F-Curve value as a velocity instead of a frame number");
+	RNA_def_property_ui_text(prop, "Use as speed", "Interpret the value as speed instead of a frame number");
 	RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update");
 
 	prop= RNA_def_property(srna, "use_frame_blend", PROP_BOOLEAN, PROP_NONE);
@@ -1552,9 +1552,9 @@
 	RNA_def_property_ui_text(prop, "Frame Blending", "Blend two frames into the target for a smoother result");
 	RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update");
 
-	prop= RNA_def_property(srna, "use_curve_compress_y", PROP_BOOLEAN, PROP_NONE);
+	prop= RNA_def_property(srna, "scale_to_length", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "flags", SEQ_SPEED_COMPRESS_IPO_Y);
-	RNA_def_property_ui_text(prop, "F-Curve Compress Y", "Scale F-Curve value to get the target frame number, F-Curve value runs from 0.0 to 1.0");
+	RNA_def_property_ui_text(prop, "Scale to length", "Scale values from 0.0 to 1.0 to target sequence length");
 	RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update");
 }
 





More information about the Bf-blender-cvs mailing list