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:
Diffstat (limited to 'source/blender/editors/transform/transform_generics.c')
-rw-r--r--source/blender/editors/transform/transform_generics.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c
index 98f6d50bc36..0ff9f92db4e 100644
--- a/source/blender/editors/transform/transform_generics.c
+++ b/source/blender/editors/transform/transform_generics.c
@@ -532,19 +532,37 @@ static void recalcData_nla(TransInfo *t)
/* handle auto-snapping */
switch (snla->autosnap) {
case SACTSNAP_FRAME: /* snap to nearest frame */
+ {
tdn->h1[0] = floorf(tdn->h1[0] + 0.5f);
tdn->h2[0] = floorf(tdn->h2[0] + 0.5f);
break;
-
+ }
+
case SACTSNAP_SECOND: /* snap to nearest second */
- tdn->h1[0] = (float)(floor(((double)tdn->h1[0] / secf) + 0.5) * secf);
- tdn->h2[0] = (float)(floor(((double)tdn->h2[0] / secf) + 0.5) * secf);
+ {
+ /* This case behaves differently from the rest, since lengths of strips
+ * may not be multiples of a second. If we just naively resize adjust
+ * the handles, things may not work correctly. Instead, we only snap
+ * the first handle, and move the other to fit.
+ *
+ * FIXME: we do run into problems here when user attempts to negatively
+ * scale the strip, as it then just compresses down and refuses
+ * to expand out the other end.
+ */
+ float h1_new = (float)(floor(((double)tdn->h1[0] / secf) + 0.5) * secf);
+ float delta = h1_new - tdn->h1[0];
+
+ tdn->h1[0] = h1_new;
+ tdn->h2[0] += delta;
break;
+ }
case SACTSNAP_MARKER: /* snap to nearest marker */
+ {
tdn->h1[0] = (float)ED_markers_find_nearest_marker_time(&t->scene->markers, tdn->h1[0]);
tdn->h2[0] = (float)ED_markers_find_nearest_marker_time(&t->scene->markers, tdn->h2[0]);
break;
+ }
}
/* Use RNA to write the values to ensure that constraints on these are obeyed