[Bf-blender-cvs] [7064efc58d0] temp-vse-fix-T88263: Fix T88263: Incorrect image offset from old file

Richard Antalik noreply at git.blender.org
Tue May 25 02:28:38 CEST 2021


Commit: 7064efc58d0ca84e04b823a40ba63bfc957b5fb2
Author: Richard Antalik
Date:   Mon May 24 07:15:18 2021 +0200
Branches: temp-vse-fix-T88263
https://developer.blender.org/rB7064efc58d0ca84e04b823a40ba63bfc957b5fb2

Fix T88263: Incorrect image offset from old file

Versioning code for converting strip offset property doesn't work, when
property was animated and disabled or when crop was used.

When offset property is animated and offset is enabled, animation is
converted to be used with new transform design. When offset is disabled,
animation is left untouched. New transform design doesn't have option
to disable offset, and therefore old unconverted animation is used
instead of converted static value.

Remove animation from propery if it was unused.

Maniphest Tasks: T88263

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

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

M	source/blender/blenloader/intern/versioning_290.c

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

diff --git a/source/blender/blenloader/intern/versioning_290.c b/source/blender/blenloader/intern/versioning_290.c
index 565e62158ff..e17de201741 100644
--- a/source/blender/blenloader/intern/versioning_290.c
+++ b/source/blender/blenloader/intern/versioning_290.c
@@ -117,7 +117,8 @@ static bool can_use_proxy(const Sequence *seq, int psize)
 }
 
 /* image_size is width or height depending what RNA property is converted - X or Y. */
-static void seq_convert_transform_animation(const Scene *scene,
+static void seq_convert_transform_animation(const Sequence *seq,
+                                            const Scene *scene,
                                             const char *path,
                                             const int image_size)
 {
@@ -125,16 +126,28 @@ static void seq_convert_transform_animation(const Scene *scene,
     return;
   }
 
-  FCurve *fcu = BKE_fcurve_find(&scene->adt->action->curves, path, 0);
-  if (fcu != NULL && !BKE_fcurve_is_empty(fcu)) {
-    BezTriple *bezt = fcu->bezt;
-    for (int i = 0; i < fcu->totvert; i++, bezt++) {
-      /* Same math as with old_image_center_*, but simplified. */
-      bezt->vec[0][1] = image_size / 2 + bezt->vec[0][1] - scene->r.xsch / 2;
-      bezt->vec[1][1] = image_size / 2 + bezt->vec[1][1] - scene->r.xsch / 2;
-      bezt->vec[2][1] = image_size / 2 + bezt->vec[2][1] - scene->r.xsch / 2;
+  /* Hardcoded legacy bit-flags which has been removed. */
+  const uint32_t use_transform_flag = (1 << 16);
+  const uint32_t use_crop_flag = (1 << 17);
+
+  /* Convert offset animation, but only if crop is not used. */
+  if ((seq->flag & use_transform_flag) != 0 && (seq->flag & use_crop_flag) == 0) {
+    FCurve *fcu = BKE_fcurve_find(&scene->adt->action->curves, path, 0);
+    if (fcu != NULL && !BKE_fcurve_is_empty(fcu)) {
+      BezTriple *bezt = fcu->bezt;
+      for (int i = 0; i < fcu->totvert; i++, bezt++) {
+        /* Same math as with old_image_center_*, but simplified. */
+        bezt->vec[0][1] = image_size / 2 + bezt->vec[0][1] - scene->r.xsch / 2;
+        bezt->vec[1][1] = image_size / 2 + bezt->vec[1][1] - scene->r.xsch / 2;
+        bezt->vec[2][1] = image_size / 2 + bezt->vec[2][1] - scene->r.xsch / 2;
+      }
     }
   }
+  else { /* Else, remove offset animation. */
+    FCurve *fcu = BKE_fcurve_find(&scene->adt->action->curves, path, 0);
+    BLI_remlink(&scene->adt->action->curves, fcu);
+    BKE_fcurve_free(fcu);
+  }
 }
 
 static void seq_convert_transform_crop(const Scene *scene,
@@ -231,18 +244,15 @@ static void seq_convert_transform_crop(const Scene *scene,
   t->xofs = old_image_center_x - scene->r.xsch / 2;
   t->yofs = old_image_center_y - scene->r.ysch / 2;
 
-  /* Convert offset animation, but only if crop is not used. */
-  if ((seq->flag & use_transform_flag) != 0 && (seq->flag & use_crop_flag) == 0) {
-    char name_esc[(sizeof(seq->name) - 2) * 2], *path;
-    BLI_str_escape(name_esc, seq->name + 2, sizeof(name_esc));
+  char name_esc[(sizeof(seq->name) - 2) * 2], *path;
+  BLI_str_escape(name_esc, seq->name + 2, sizeof(name_esc));
 
-    path = BLI_sprintfN("sequence_editor.sequences_all[\"%s\"].transform.offset_x", name_esc);
-    seq_convert_transform_animation(scene, path, image_size_x);
-    MEM_freeN(path);
-    path = BLI_sprintfN("sequence_editor.sequences_all[\"%s\"].transform.offset_y", name_esc);
-    seq_convert_transform_animation(scene, path, image_size_y);
-    MEM_freeN(path);
-  }
+  path = BLI_sprintfN("sequence_editor.sequences_all[\"%s\"].transform.offset_x", name_esc);
+  seq_convert_transform_animation(seq, scene, path, image_size_x);
+  MEM_freeN(path);
+  path = BLI_sprintfN("sequence_editor.sequences_all[\"%s\"].transform.offset_y", name_esc);
+  seq_convert_transform_animation(seq, scene, path, image_size_y);
+  MEM_freeN(path);
 
   seq->flag &= ~use_transform_flag;
   seq->flag &= ~use_crop_flag;



More information about the Bf-blender-cvs mailing list