Bugfix #22453: Jump to Next keyframe doesn't work on some frame
authorJoshua Leung <aligorith@gmail.com>
Tue, 8 Jun 2010 00:08:45 +0000 (00:08 +0000)
committerJoshua Leung <aligorith@gmail.com>
Tue, 8 Jun 2010 00:08:45 +0000 (00:08 +0000)
Jump to keyframe would get 'stuck' if it encountered a keyframe on "fraction" frames. Now, it will try multiple times until it finds one.

source/blender/editors/screen/screen_ops.c

index 56abff8..592f40d 100644 (file)
@@ -1571,6 +1571,7 @@ static int keyframe_jump_exec(bContext *C, wmOperator *op)
        ActKeyColumn *ak;
        float cfra= (scene)? (float)(CFRA) : 0.0f;
        short next= RNA_boolean_get(op->ptr, "next");
+       short done = 0;
        
        /* sanity checks */
        if (scene == NULL)
@@ -1589,15 +1590,27 @@ static int keyframe_jump_exec(bContext *C, wmOperator *op)
        BLI_dlrbTree_linkedlist_sync(&keys);
        
        /* find matching keyframe in the right direction */
-       if (next)
-               ak= (ActKeyColumn *)BLI_dlrbTree_search_next(&keys, compare_ak_cfraPtr, &cfra);
-       else
-               ak= (ActKeyColumn *)BLI_dlrbTree_search_prev(&keys, compare_ak_cfraPtr, &cfra);
+       do {
+               if (next)
+                       ak= (ActKeyColumn *)BLI_dlrbTree_search_next(&keys, compare_ak_cfraPtr, &cfra);
+               else
+                       ak= (ActKeyColumn *)BLI_dlrbTree_search_prev(&keys, compare_ak_cfraPtr, &cfra);
+               
+               if (ak) {
+                       if (CFRA != (int)ak->cfra) {
+                               /* this changes the frame, so set the frame and we're done */
+                               CFRA= (int)ak->cfra;
+                               done = 1;
+                       }
+                       else {
+                               /* make this the new starting point for the search */
+                               cfra = ak->cfra;
+                       }
+               }
+       } while ((ak != NULL) && (done == 0));
        
-       /* set the new frame (if keyframe found) */
-       if (ak) 
-               CFRA= (int)ak->cfra;
-       else
+       /* any success? */
+       if (done == 0)
                BKE_report(op->reports, RPT_INFO, "No more keyframes to jump to in this direction");
        
        /* free temp stuff */