Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Antalik <richardantalik@gmail.com>2020-12-16 22:34:26 +0300
committerRichard Antalik <richardantalik@gmail.com>2020-12-16 22:38:28 +0300
commit571362642201a743168cdf4c827a59c09c40414b (patch)
tree51993f00ca98efb733e558c881dd0178fb7c0f8f /source/blender/blenloader
parent9d152263837f0ac5e790e0b12d3b3cfed31bed0f (diff)
VSE: Improve motion-picture workflow
This commit resolves problem introduced in e1665c3d3190 - it was difficult to import media at their original resolution. This is done by using original resolution as reference for scale. All crop and strip transform values and their animation is converted form old files. To make both workflows easy to use, sequencer tool settings have been created with preset for preffered scaling method. This setting is in sequencer timeline header and add image or movie strip operator properties. Two new operators have been added: `sequencer.strip_transform_fit` operator with 3 options: Scale To Fit, Scale to Fill and Stretch To Fill. Operator can fail if strip image or video is not loaded currently, this case should be either sanitized or data loaded on demand. `sequencer.strip_transform_clear` operator with 4 options: Clear position, scale, rotation and all (previous 3 options combined). Reviewed By: sergey, fsiddi Differential Revision: https://developer.blender.org/D9582
Diffstat (limited to 'source/blender/blenloader')
-rw-r--r--source/blender/blenloader/intern/versioning_290.c182
1 files changed, 146 insertions, 36 deletions
diff --git a/source/blender/blenloader/intern/versioning_290.c b/source/blender/blenloader/intern/versioning_290.c
index 49e1b057b39..753cc861982 100644
--- a/source/blender/blenloader/intern/versioning_290.c
+++ b/source/blender/blenloader/intern/versioning_290.c
@@ -74,6 +74,29 @@
/* Make preferences read-only, use versioning_userdef.c. */
#define U (*((const UserDef *)&U))
+static eSpaceSeq_Proxy_RenderSize get_sequencer_render_size(Main *bmain)
+{
+ eSpaceSeq_Proxy_RenderSize render_size = 100;
+
+ for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
+ LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
+ LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
+ switch (sl->spacetype) {
+ case SPACE_SEQ: {
+ SpaceSeq *sseq = (SpaceSeq *)sl;
+ if (sseq->mainb == SEQ_DRAW_IMG_IMBUF) {
+ render_size = sseq->render_size;
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return render_size;
+}
+
/* image_size is width or height depending what RNA property is converted - X or Y. */
static void seq_convert_transform_animation(const Scene *scene,
const char *path,
@@ -212,6 +235,90 @@ static void seq_convert_transform_crop_lb(const Scene *scene,
}
}
+static void seq_convert_transform_animation_2(const Scene *scene,
+ const char *path,
+ const float scale_to_fit_factor)
+{
+ 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[1][1] *= scale_to_fit_factor;
+ }
+ }
+}
+
+static void seq_convert_transform_crop_2(const Scene *scene,
+ Sequence *seq,
+ const eSpaceSeq_Proxy_RenderSize render_size)
+{
+ const StripElem *s_elem = SEQ_render_give_stripelem(seq, seq->start);
+ if (s_elem == NULL) {
+ return;
+ }
+
+ StripCrop *c = seq->strip->crop;
+ StripTransform *t = seq->strip->transform;
+ int image_size_x = s_elem->orig_width;
+ int image_size_y = s_elem->orig_height;
+
+ if (SEQ_can_use_proxy(seq, SEQ_rendersize_to_proxysize(render_size))) {
+ image_size_x /= SEQ_rendersize_to_scale_factor(render_size);
+ image_size_y /= SEQ_rendersize_to_scale_factor(render_size);
+ }
+
+ /* Calculate scale factor, so image fits in preview area with original aspect ratio. */
+ const float scale_to_fit_factor = MIN2((float)scene->r.xsch / (float)image_size_x,
+ (float)scene->r.ysch / (float)image_size_y);
+ t->scale_x *= scale_to_fit_factor;
+ t->scale_y *= scale_to_fit_factor;
+ c->top /= scale_to_fit_factor;
+ c->bottom /= scale_to_fit_factor;
+ c->left /= scale_to_fit_factor;
+ c->right /= scale_to_fit_factor;
+
+ 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_2(scene, path, scale_to_fit_factor);
+ MEM_freeN(path);
+ path = BLI_sprintfN("sequence_editor.sequences_all[\"%s\"].transform.offset_y", name_esc);
+ seq_convert_transform_animation_2(scene, path, scale_to_fit_factor);
+ MEM_freeN(path);
+ path = BLI_sprintfN("sequence_editor.sequences_all[\"%s\"].crop.min_x", name_esc);
+ seq_convert_transform_animation_2(scene, path, 1 / scale_to_fit_factor);
+ MEM_freeN(path);
+ path = BLI_sprintfN("sequence_editor.sequences_all[\"%s\"].crop.max_x", name_esc);
+ seq_convert_transform_animation_2(scene, path, 1 / scale_to_fit_factor);
+ MEM_freeN(path);
+ path = BLI_sprintfN("sequence_editor.sequences_all[\"%s\"].crop.min_y", name_esc);
+ seq_convert_transform_animation_2(scene, path, 1 / scale_to_fit_factor);
+ MEM_freeN(path);
+ path = BLI_sprintfN("sequence_editor.sequences_all[\"%s\"].crop.max_x", name_esc);
+ seq_convert_transform_animation_2(scene, path, 1 / scale_to_fit_factor);
+ MEM_freeN(path);
+}
+
+static void seq_convert_transform_crop_lb_2(const Scene *scene,
+ const ListBase *lb,
+ const eSpaceSeq_Proxy_RenderSize render_size)
+{
+
+ LISTBASE_FOREACH (Sequence *, seq, lb) {
+ if (seq->type != SEQ_TYPE_SOUND_RAM) {
+ seq_convert_transform_crop_2(scene, seq, render_size);
+ }
+ if (seq->type == SEQ_TYPE_META) {
+ seq_convert_transform_crop_lb_2(scene, &seq->seqbase, render_size);
+ }
+ }
+}
+
void do_versions_after_linking_290(Main *bmain, ReportList *UNUSED(reports))
{
if (!MAIN_VERSION_ATLEAST(bmain, 290, 1)) {
@@ -441,25 +548,35 @@ void do_versions_after_linking_290(Main *bmain, ReportList *UNUSED(reports))
if (!MAIN_VERSION_ATLEAST(bmain, 292, 2)) {
- eSpaceSeq_Proxy_RenderSize render_size = 100;
+ eSpaceSeq_Proxy_RenderSize render_size = get_sequencer_render_size(bmain);
- for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
- LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
- LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
- switch (sl->spacetype) {
- case SPACE_SEQ: {
- SpaceSeq *sseq = (SpaceSeq *)sl;
- render_size = sseq->render_size;
- break;
- }
- }
- }
+ LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
+ if (scene->ed != NULL) {
+ seq_convert_transform_crop_lb(scene, &scene->ed->seqbase, render_size);
}
}
+ }
+ if (!MAIN_VERSION_ATLEAST(bmain, 292, 8)) {
+ /* Systematically rebuild posebones to ensure consistent ordering matching the one of bones in
+ * Armature obdata. */
+ LISTBASE_FOREACH (Object *, ob, &bmain->objects) {
+ if (ob->type == OB_ARMATURE) {
+ BKE_pose_rebuild(bmain, ob, ob->data, true);
+ }
+ }
+
+ /* Wet Paint Radius Factor */
+ for (Brush *br = bmain->brushes.first; br; br = br->id.next) {
+ if (br->ob_mode & OB_MODE_SCULPT && br->wet_paint_radius_factor == 0.0f) {
+ br->wet_paint_radius_factor = 1.0f;
+ }
+ }
+
+ eSpaceSeq_Proxy_RenderSize render_size = get_sequencer_render_size(bmain);
LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
if (scene->ed != NULL) {
- seq_convert_transform_crop_lb(scene, &scene->ed->seqbase, render_size);
+ seq_convert_transform_crop_lb_2(scene, &scene->ed->seqbase, render_size);
}
}
}
@@ -476,21 +593,6 @@ void do_versions_after_linking_290(Main *bmain, ReportList *UNUSED(reports))
*/
{
/* Keep this block, even when empty. */
-
- /* Systematically rebuild posebones to ensure consistent ordering matching the one of bones in
- * Armature obdata. */
- LISTBASE_FOREACH (Object *, ob, &bmain->objects) {
- if (ob->type == OB_ARMATURE) {
- BKE_pose_rebuild(bmain, ob, ob->data, true);
- }
- }
- }
-
- /* Wet Paint Radius Factor */
- for (Brush *br = bmain->brushes.first; br; br = br->id.next) {
- if (br->ob_mode & OB_MODE_SCULPT && br->wet_paint_radius_factor == 0.0f) {
- br->wet_paint_radius_factor = 1.0f;
- }
}
}
@@ -1305,6 +1407,22 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
+ if (!MAIN_VERSION_ATLEAST(bmain, 292, 8)) {
+ LISTBASE_FOREACH (bNodeTree *, ntree, &bmain->nodetrees) {
+ LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
+ if (STREQ(node->idname, "GeometryNodeRandomAttribute")) {
+ STRNCPY(node->idname, "GeometryNodeAttributeRandomize");
+ }
+ }
+ }
+
+ LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
+ if (scene->ed != NULL) {
+ scene->toolsettings->sequencer_tool_settings = SEQ_tool_settings_init();
+ }
+ }
+ }
+
/**
* Versioning code until next subversion bump goes here.
*
@@ -1316,13 +1434,5 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
*/
{
/* Keep this block, even when empty. */
-
- LISTBASE_FOREACH (bNodeTree *, ntree, &bmain->nodetrees) {
- LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
- if (STREQ(node->idname, "GeometryNodeRandomAttribute")) {
- STRNCPY(node->idname, "GeometryNodeAttributeRandomize");
- }
- }
- }
}
}