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:
authorJoshua Leung <aligorith@gmail.com>2014-04-24 18:52:27 +0400
committerJoshua Leung <aligorith@gmail.com>2014-04-24 19:14:03 +0400
commit9f4ad8014c91f74f01374aa7eb11fc3e4a6b9160 (patch)
tree6e3a1775afb398f81eeaabdef7ed2b4d8c3a2caf /source/blender/editors/transform/transform_generics.c
parent8b24d0a2e9e20f77b5caf57531760a6baffac40c (diff)
AutoSnap Bugfixes: NLA Editor - Nearest Second behaviour tweak
The previous behaviour for nearest second meant that transforming the strips often caused their lengths to change (sometimes drastically), since strip lengths aren't always uniformly x-seconds long. Now, it only snaps the start frame value, and adjusts the end of the strip to follow. This works well for most cases, apart from negatively scaling the strip, where it will get "stuck" as a 0.001 frame long strip (and the viewport drawing will be a bit weird during this time). Nevertheless, negative scaling of strips isn't something that's exactly recommended.
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