[Bf-blender-cvs] [e80fbf8] master: More AutoSnap Bugfixes: Time Stepping in Graph Editor

Joshua Leung noreply at git.blender.org
Thu Apr 24 17:14:54 CEST 2014


Commit: e80fbf8674c0913de6e5b747a8ff4d41c0d7cf46
Author: Joshua Leung
Date:   Fri Apr 25 02:17:12 2014 +1200
https://developer.blender.org/rBe80fbf8674c0913de6e5b747a8ff4d41c0d7cf46

More AutoSnap Bugfixes: Time Stepping in Graph Editor

* Frame Step now works correctly and as expected
* Second Step kindof works, but the handles are not well behaved.

===================================================================

M	source/blender/editors/transform/transform_conversions.c

===================================================================

diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c
index 5e5dd00..8830b02 100644
--- a/source/blender/editors/transform/transform_conversions.c
+++ b/source/blender/editors/transform/transform_conversions.c
@@ -4129,6 +4129,28 @@ void flushTransGraphData(TransInfo *t)
 			td2d->loc2d[0] = BKE_nla_tweakedit_remap(adt, td2d->loc[0], NLATIME_CONVERT_UNMAP);
 		else
 			td2d->loc2d[0] = td2d->loc[0];
+			
+		/* Time-stepping auto-snapping modes don't get applied for Graph Editor transforms,
+		 * as these use the generic transform modes which don't account for this sort of thing.
+		 * These ones aren't affected by NLA mapping, so we do this after the conversion...
+		 *
+		 * NOTE: We also have to apply to td->loc, as that's what the handle-adjustment step below looks
+		 *       to, otherwise we get "swimming handles"
+		 */
+		if ((td->flag & TD_NOTIMESNAP) == 0 && ELEM(sipo->autosnap, SACTSNAP_STEP, SACTSNAP_TSTEP)) {
+			switch (sipo->autosnap) {
+				case SACTSNAP_STEP: /* frame step */
+					td2d->loc2d[0] = floor((double)td2d->loc[0] + 0.5);
+					td->loc[0]     = floor((double)td->loc[0] + 0.5);
+					break;
+				
+				case SACTSNAP_TSTEP: /* second step */
+					/* XXX: the handle behaviour in this case is still not quite right... */
+					td2d->loc[0] = floor(((double)td2d->loc[0] / secf) + 0.5) * secf;
+					td->loc[0]   = floor(((double)td->loc[0] / secf) + 0.5) * secf;
+					break;
+			}
+		}
 		
 		/* if int-values only, truncate to integers */
 		if (td->flag & TD_INTVALUES)




More information about the Bf-blender-cvs mailing list