[Bf-blender-cvs] [f013e3de81d] master: VSE: Speed Effect layout updates

Germano Cavalcante noreply at git.blender.org
Thu Jul 22 22:54:25 CEST 2021


Commit: f013e3de81dad88fdcc9b907f4804e84938d9561
Author: Germano Cavalcante
Date:   Thu Jul 1 15:03:14 2021 -0300
Branches: master
https://developer.blender.org/rBf013e3de81dad88fdcc9b907f4804e84938d9561

VSE: Speed Effect layout updates

**Changes:**
- New enums correspond to 4 modes: `Stretch`, `Multiply`, `Frame Number` and `Length`.
- "`Multiply Factor`" has been removed;
- Value corresponding to "`use as speed`" enabled is now the value appended to the `Multiply` enum;
- Value corresponding to "`use as speed`" disabled is now the value appended to the `Frame Number` enum;
- Value corresponding to "`Scale to Length`" enabled is now the value appended to the `Length` enum;
- Except `Stretch` each mode has now its respective control values.

Differential Revision: https://developer.blender.org/D11856

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

M	release/scripts/startup/bl_ui/space_sequencer.py
M	source/blender/blenloader/intern/versioning_300.c
M	source/blender/makesdna/DNA_sequence_types.h
M	source/blender/makesrna/intern/rna_sequencer.c
M	source/blender/sequencer/SEQ_effects.h
M	source/blender/sequencer/intern/effects.c

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

diff --git a/release/scripts/startup/bl_ui/space_sequencer.py b/release/scripts/startup/bl_ui/space_sequencer.py
index 55714e0b0a5..47b04f9cdbc 100644
--- a/release/scripts/startup/bl_ui/space_sequencer.py
+++ b/release/scripts/startup/bl_ui/space_sequencer.py
@@ -1156,14 +1156,19 @@ class SEQUENCER_PT_effect(SequencerButtonsPanel, Panel):
             flow.prop(strip, "use_only_boost")
 
         elif strip_type == 'SPEED':
-            layout.prop(strip, "use_default_fade", text="Stretch to Input Strip Length")
-            if not strip.use_default_fade:
-                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, "use_scale_to_length")
+            col = layout.column(align=True)
+            col.prop(strip, "speed_control", text="Speed Control")
+            if strip.speed_control == "MULTIPLY":
+                col.prop(strip, "speed_factor", text=" ")
+            elif strip.speed_control == "LENGTH":
+                col.prop(strip, "speed_length", text=" ")
+            elif strip.speed_control == "FRAME_NUMBER":
+                col.prop(strip, "speed_frame_number", text=" ")
+
+            row = layout.row(align=True)
+            row.enabled = strip.speed_control != "STRETCH"
+            row = layout.row(align=True, heading="Interpolation")
+            row.prop(strip, "use_frame_interpolate", text="")
 
         elif strip_type == 'TRANSFORM':
             col = layout.column()
@@ -1233,11 +1238,7 @@ class SEQUENCER_PT_effect(SequencerButtonsPanel, Panel):
             layout.prop(strip, "wrap_width", text="Wrap Width")
 
         col = layout.column(align=True)
-        if strip_type == 'SPEED':
-            col.prop(strip, "multiply_speed")
-            col.prop(strip, "use_frame_interpolate")
-
-        elif strip_type in {'CROSS', 'GAMMA_CROSS', 'WIPE', 'ALPHA_OVER', 'ALPHA_UNDER', 'OVER_DROP'}:
+        if strip_type in {'CROSS', 'GAMMA_CROSS', 'WIPE', 'ALPHA_OVER', 'ALPHA_UNDER', 'OVER_DROP'}:
             col.prop(strip, "use_default_fade", text="Default Fade")
             if not strip.use_default_fade:
                 col.prop(strip, "effect_fader", text="Effect Fader")
diff --git a/source/blender/blenloader/intern/versioning_300.c b/source/blender/blenloader/intern/versioning_300.c
index 927580e3e18..4dcb7414bb4 100644
--- a/source/blender/blenloader/intern/versioning_300.c
+++ b/source/blender/blenloader/intern/versioning_300.c
@@ -29,6 +29,7 @@
 #include "DNA_armature_types.h"
 #include "DNA_brush_types.h"
 #include "DNA_collection_types.h"
+#include "DNA_curve_types.h"
 #include "DNA_genfile.h"
 #include "DNA_listBase.h"
 #include "DNA_material_types.h"
@@ -41,6 +42,7 @@
 #include "BKE_asset.h"
 #include "BKE_collection.h"
 #include "BKE_deform.h"
+#include "BKE_fcurve.h"
 #include "BKE_fcurve_driver.h"
 #include "BKE_lib_id.h"
 #include "BKE_main.h"
@@ -49,11 +51,10 @@
 #include "BLO_readfile.h"
 #include "MEM_guardedalloc.h"
 #include "readfile.h"
-#include "versioning_common.h"
 
 #include "SEQ_sequencer.h"
 
-#include "MEM_guardedalloc.h"
+#include "RNA_access.h"
 
 #include "versioning_common.h"
 
@@ -113,6 +114,74 @@ static void move_vertex_group_names_to_object_data(Main *bmain)
   }
 }
 
+static void do_versions_sequencer_speed_effect_recursive(Scene *scene, const ListBase *seqbase)
+{
+  /* Old SpeedControlVars->flags. */
+#define SEQ_SPEED_INTEGRATE (1 << 0)
+#define SEQ_SPEED_COMPRESS_IPO_Y (1 << 2)
+
+  LISTBASE_FOREACH (Sequence *, seq, seqbase) {
+    if (seq->type == SEQ_TYPE_SPEED) {
+      SpeedControlVars *v = (SpeedControlVars *)seq->effectdata;
+      const char *substr = NULL;
+      float globalSpeed = v->globalSpeed;
+      if (seq->flag & SEQ_USE_EFFECT_DEFAULT_FADE) {
+        if (globalSpeed == 1.0f) {
+          v->speed_control_type = SEQ_SPEED_STRETCH;
+        }
+        else {
+          v->speed_control_type = SEQ_SPEED_MULTIPLY;
+          v->speed_fader = globalSpeed *
+                           ((float)seq->seq1->len /
+                            max_ff((float)(seq->seq1->enddisp - seq->seq1->start), 1.0f));
+        }
+      }
+      else if (v->flags & SEQ_SPEED_INTEGRATE) {
+        v->speed_control_type = SEQ_SPEED_MULTIPLY;
+        v->speed_fader = seq->speed_fader * globalSpeed;
+      }
+      else if (v->flags & SEQ_SPEED_COMPRESS_IPO_Y) {
+        globalSpeed *= 100.0f;
+        v->speed_control_type = SEQ_SPEED_LENGTH;
+        v->speed_fader_length = seq->speed_fader * globalSpeed;
+        substr = "speed_length";
+      }
+      else {
+        v->speed_control_type = SEQ_SPEED_FRAME_NUMBER;
+        v->speed_fader_frame_number = (int)(seq->speed_fader * globalSpeed);
+        substr = "speed_frame_number";
+      }
+
+      v->flags &= ~(SEQ_SPEED_INTEGRATE | SEQ_SPEED_COMPRESS_IPO_Y);
+
+      if (substr || globalSpeed != 1.0f) {
+        FCurve *fcu = id_data_find_fcurve(&scene->id, seq, &RNA_Sequence, "speed_factor", 0, NULL);
+        if (fcu) {
+          if (globalSpeed != 1.0f) {
+            for (int i = 0; i < fcu->totvert; i++) {
+              BezTriple *bezt = &fcu->bezt[i];
+              bezt->vec[0][1] *= globalSpeed;
+              bezt->vec[1][1] *= globalSpeed;
+              bezt->vec[2][1] *= globalSpeed;
+            }
+          }
+          if (substr) {
+            char *new_path = BLI_str_replaceN(fcu->rna_path, "speed_factor", substr);
+            MEM_freeN(fcu->rna_path);
+            fcu->rna_path = new_path;
+          }
+        }
+      }
+    }
+    else if (seq->type == SEQ_TYPE_META) {
+      do_versions_sequencer_speed_effect_recursive(scene, &seq->seqbase);
+    }
+  }
+
+#undef SEQ_SPEED_INTEGRATE
+#undef SEQ_SPEED_COMPRESS_IPO_Y
+}
+
 void do_versions_after_linking_300(Main *bmain, ReportList *UNUSED(reports))
 {
   if (MAIN_VERSION_ATLEAST(bmain, 300, 0) && !MAIN_VERSION_ATLEAST(bmain, 300, 1)) {
@@ -161,6 +230,14 @@ void do_versions_after_linking_300(Main *bmain, ReportList *UNUSED(reports))
     move_vertex_group_names_to_object_data(bmain);
   }
 
+  if (!MAIN_VERSION_ATLEAST(bmain, 300, 13)) {
+    LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
+      if (scene->ed != NULL) {
+        do_versions_sequencer_speed_effect_recursive(scene, &scene->ed->seqbase);
+      }
+    }
+  }
+
   /**
    * Versioning code until next subversion bump goes here.
    *
diff --git a/source/blender/makesdna/DNA_sequence_types.h b/source/blender/makesdna/DNA_sequence_types.h
index 55dc51e0632..af524ff4866 100644
--- a/source/blender/makesdna/DNA_sequence_types.h
+++ b/source/blender/makesdna/DNA_sequence_types.h
@@ -201,6 +201,7 @@ typedef struct Sequence {
   ListBase anims;
 
   float effect_fader;
+  /* DEPRECATED, only used for versioning. */
   float speed_fader;
 
   /* pointers for effects: */
@@ -335,12 +336,28 @@ typedef struct SolidColorVars {
 
 typedef struct SpeedControlVars {
   float *frameMap;
+  /* DEPRECATED, only used for versioning. */
   float globalSpeed;
+  /* DEPRECATED, only used for versioning. */
   int flags;
+
   int length;
   int lastValidFrame;
+  int speed_control_type;
+
+  float speed_fader;
+  float speed_fader_length;
+  float speed_fader_frame_number;
 } SpeedControlVars;
 
+/* SpeedControlVars.speed_control_type */
+enum {
+  SEQ_SPEED_STRETCH = 0,
+  SEQ_SPEED_MULTIPLY = 1,
+  SEQ_SPEED_LENGTH = 2,
+  SEQ_SPEED_FRAME_NUMBER = 3,
+};
+
 typedef struct GaussianBlurVars {
   float size_x;
   float size_y;
@@ -485,9 +502,9 @@ typedef struct SequencerScopes {
 #define SEQ_EDIT_PROXY_DIR_STORAGE 1
 
 /* SpeedControlVars->flags */
-#define SEQ_SPEED_INTEGRATE (1 << 0)
+#define SEQ_SPEED_UNUSED_2 (1 << 0) /* cleared */
 #define SEQ_SPEED_UNUSED_1 (1 << 1) /* cleared */
-#define SEQ_SPEED_COMPRESS_IPO_Y (1 << 2)
+#define SEQ_SPEED_UNUSED_3 (1 << 2) /* cleared */
 #define SEQ_SPEED_USE_INTERPOLATION (1 << 3)
 
 /* ***************** SEQUENCE ****************** */
diff --git a/source/blender/makesrna/intern/rna_sequencer.c b/source/blender/makesrna/intern/rna_sequencer.c
index b1f0b0d760f..9939e17d258 100644
--- a/source/blender/makesrna/intern/rna_sequencer.c
+++ b/source/blender/makesrna/intern/rna_sequencer.c
@@ -1921,16 +1921,6 @@ static void rna_def_sequence(BlenderRNA *brna)
   RNA_def_property_update(
       prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_invalidate_preprocessed_update");
 
-  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 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_invalidate_preprocessed_update");
-
   /* modifiers */
   prop = RNA_def_property(srna, "modifiers", PROP_COLLECTION, PROP_NONE);
   RNA_def_property_struct_type(prop, "SequenceModifier");
@@ -2787,24 +2777,48 @@ static void rna_def_speed_control(StructRNA *srna)
 
   RNA_def_struct_sdna_from(srna, "SpeedControlVars", "effectdata");
 
-  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, "Multiply Speed", "Multiply the resulting speed after the speed factor");
-  RNA_def_property_ui_range(prop, 0.0f, 100.0f, 1, -1);
+  static const EnumPropertyItem speed_control_items[] = {
+      {SEQ_SPEED_STRETCH,
+       "STRETCH",
+       0,
+       "Stretch",
+       "Adjust input playback speed, so its duration fits strip length"},
+      {SEQ_SPEED_MULTIPLY, "MULTIPLY", 0, "Multiply", "Multiply with the speed factor"},
+      {SEQ_SPEED_FRAME_NUMBER,
+       "FRAME_NUMBER",
+       0,
+       "Frame Number",
+       "Frame number of the input strip"},
+      {SEQ_SPEED_LENGTH, "LENGTH", 0, "Length", "Percentage of the input strip length"},
+      {0, NULL, 0, NULL, NULL},
+  };
+
+  prop = RNA_def_prop

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list