diff options
author | Richard Antalik <richardantalik@gmail.com> | 2021-06-16 01:44:37 +0300 |
---|---|---|
committer | Richard Antalik <richardantalik@gmail.com> | 2021-06-16 01:44:37 +0300 |
commit | 4891da8ae22523c3ecb727f6f8be5647cbe0f51d (patch) | |
tree | 1a3c781da10178f6aedca10b407eff310505c054 /source/blender | |
parent | 1a5fa2b319e06ebbd2666987aa11240a371dcc09 (diff) |
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.
Another issue was that both X and Y offset animation was being corrected
by factor caluclated for X channel.
Reviewed By: sergey
Differential Revision: https://developer.blender.org/D11370
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenloader/intern/versioning_290.c | 53 |
1 files changed, 32 insertions, 21 deletions
diff --git a/source/blender/blenloader/intern/versioning_290.c b/source/blender/blenloader/intern/versioning_290.c index bd739452f8e..156b1f4198d 100644 --- a/source/blender/blenloader/intern/versioning_290.c +++ b/source/blender/blenloader/intern/versioning_290.c @@ -118,24 +118,38 @@ 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) + const int image_size, + const int scene_size) { if (scene->adt == NULL || scene->adt->action == NULL) { 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 - scene_size) / 2 + bezt->vec[0][1]; + bezt->vec[1][1] = (image_size - scene_size) / 2 + bezt->vec[1][1]; + bezt->vec[2][1] = (image_size - scene_size) / 2 + bezt->vec[2][1]; + } } } + 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, @@ -232,18 +246,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, scene->r.xsch); + 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, scene->r.ysch); + MEM_freeN(path); seq->flag &= ~use_transform_flag; seq->flag &= ~use_crop_flag; |