From 3dbe1744402c2790d7854f09cf977bb275436479 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Mon, 22 Aug 2016 17:22:06 +0200 Subject: 2D stabilization: flip orientation of the scale parameter values > 1 will zoom in and values < 1 zoom out Rationale: the changed orientation is more natural from a user POV and doing it this way is also more consistent with the calculation of the other target_* parameters. Compatibility: This will break *.blend files saved with the previous version of this patch from the last days (test period). It will *not* break any old/migrated files: Previously, the DNA field "scale" was only used to cache autoscale. Only with the Stabilisator rework, "scale" becomes a first class persistent DNA field. There is migration code to init this field to 1.0 --- source/blender/blenkernel/intern/tracking_stabilize.c | 19 ++++++++++++------- source/blender/blenloader/intern/versioning_270.c | 19 ++++++++++--------- source/blender/makesrna/intern/rna_tracking.c | 8 ++++---- 3 files changed, 26 insertions(+), 20 deletions(-) diff --git a/source/blender/blenkernel/intern/tracking_stabilize.c b/source/blender/blenkernel/intern/tracking_stabilize.c index 0f047242f93..93addc47fe1 100644 --- a/source/blender/blenkernel/intern/tracking_stabilize.c +++ b/source/blender/blenkernel/intern/tracking_stabilize.c @@ -1020,13 +1020,13 @@ static void stabilization_calculate_data(StabContext *ctx, float *r_scale, float *r_angle) { - float target_pos[2]; + float target_pos[2], target_scale; float scaleinf = get_animated_scaleinf(ctx, framenr); - *r_scale = get_animated_target_scale(ctx,framenr); - if (ctx->stab->flag & TRACKING_STABILIZE_SCALE) { - *r_scale *= expf(scale_step * scaleinf); /* Averaged in log scale */ + *r_scale = expf(scale_step * scaleinf); /* Averaged in log scale */ + } else { + *r_scale = 1.0f; } mul_v2_fl(r_translation, get_animated_locinf(ctx, framenr)); @@ -1039,6 +1039,11 @@ static void stabilization_calculate_data(StabContext *ctx, get_animated_target_pos(ctx, framenr, target_pos); sub_v2_v2(r_translation, target_pos); *r_angle -= get_animated_target_rot(ctx,framenr); + target_scale = get_animated_target_scale(ctx,framenr); + if (target_scale != 0.0f) { + *r_scale /= target_scale; + /* target_scale is an expected/intended reference zoom value*/ + } /* Convert from relative to absolute coordinates, square pixels. */ r_translation[0] *= (float)size * aspect; @@ -1194,9 +1199,9 @@ static void stabilization_determine_safe_image_area(StabContext *ctx, J = G - E; K = G * F - E * H; - S = (dx * I + dy * J + K) / (-w * I - h * J); + S = (-w * I - h * J) / (dx * I + dy * J + K); - scale = min_ff(scale, S); + scale = max_ff(scale, S); } } } @@ -1205,7 +1210,7 @@ static void stabilization_determine_safe_image_area(StabContext *ctx, stab->scale = scale; if (stab->maxscale > 0.0f) { - stab->scale = max_ff(stab->scale, 1.0f / stab->maxscale); + stab->scale = min_ff(stab->scale, stab->maxscale); } } diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c index f6ac42c1941..1ef32d6f006 100644 --- a/source/blender/blenloader/intern/versioning_270.c +++ b/source/blender/blenloader/intern/versioning_270.c @@ -91,9 +91,6 @@ static void migrate_single_rot_stabilization_track_settings(MovieTrackingStabili } } stab->rot_track = NULL; /* this field is now ignored */ - - /* by default show the track lists expanded, to improve "discoverability" */ - stab->flag |= TRACKING_SHOW_STAB_TRACKS; } static void do_version_constraints_radians_degrees_270_1(ListBase *lb) @@ -1369,13 +1366,17 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) for (clip = main->movieclip.first; clip != NULL; clip = clip->id.next) { if (clip->tracking.stabilization.rot_track) { migrate_single_rot_stabilization_track_settings(&clip->tracking.stabilization); - if (!clip->tracking.stabilization.scale) { - /* ensure init. - * Was previously used for autoscale only, - * now used always (as "target scale") */ - clip->tracking.stabilization.scale = 1.0f; - } } + if (clip->tracking.stabilization.scale == 0.0f) { + /* ensure init. + * Was previously used for autoscale only, + * now used always (as "target scale") */ + clip->tracking.stabilization.scale = 1.0f; + } + /* by default show the track lists expanded, to improve "discoverability" */ + clip->tracking.stabilization.flag |= TRACKING_SHOW_STAB_TRACKS; + /* deprecated, not used anymore */ + clip->tracking.stabilization.ok = false; } } } diff --git a/source/blender/makesrna/intern/rna_tracking.c b/source/blender/makesrna/intern/rna_tracking.c index cbfebe5efc4..2d068bbab26 100644 --- a/source/blender/makesrna/intern/rna_tracking.c +++ b/source/blender/makesrna/intern/rna_tracking.c @@ -1768,7 +1768,7 @@ static void rna_def_trackingStabilization(BlenderRNA *brna) prop = RNA_def_property(srna, "target_rotation", PROP_FLOAT, PROP_ANGLE); RNA_def_property_float_sdna(prop, NULL, "target_rot"); RNA_def_property_range(prop, -FLT_MAX, FLT_MAX); - RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, 3); + RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 10.0f, 3); RNA_def_property_ui_text(prop, "Expected Rotation", "Rotation present on original shot, will be compensated (e.g. for deliberate tilting)"); RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, NULL); @@ -1776,9 +1776,9 @@ static void rna_def_trackingStabilization(BlenderRNA *brna) /* target scale */ prop = RNA_def_property(srna, "target_zoom", PROP_FLOAT, PROP_FACTOR); RNA_def_property_float_sdna(prop, NULL, "scale"); - RNA_def_property_range(prop, FLT_EPSILON, 100.0f); - RNA_def_property_ui_range(prop, 0.1f, 10.0f, 1, 3); /* increment in steps of 0.01. Show 3 digit after point */ - RNA_def_property_ui_text(prop, "Expected Zoom", + RNA_def_property_range(prop, FLT_EPSILON, FLT_MAX); + RNA_def_property_ui_range(prop, 0.01f, 10.0f, 0.001f, 3); /* increment in steps of 0.001. Show 3 digit after point */ + RNA_def_property_ui_text(prop, "Expected Scale", "Explicitly scale resulting frame to compensate zoom of original shot"); RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, "rna_tracking_flushUpdate"); -- cgit v1.2.3