Reshuffled utility function to keyframe drawing API, removing some
authorJoshua Leung <aligorith@gmail.com>
Thu, 24 Mar 2011 03:19:30 +0000 (03:19 +0000)
committerJoshua Leung <aligorith@gmail.com>
Thu, 24 Mar 2011 03:19:30 +0000 (03:19 +0000)
duplicate code

source/blender/editors/animation/keyframes_draw.c
source/blender/editors/armature/poseSlide.c
source/blender/editors/include/ED_keyframes_draw.h

index 3f8f8dc..662f038 100644 (file)
@@ -457,6 +457,33 @@ static void set_touched_actkeyblock (ActKeyBlock *ab)
        set_touched_actkeyblock(ab->right);
 }
 
+/* --------- */
+
+/* Checks if ActKeyBlock should exist... */
+short actkeyblock_is_valid (ActKeyBlock *ab, DLRBT_Tree *keys)
+{
+       ActKeyColumn *ak;
+       short startCurves, endCurves, totCurves;
+       
+       /* check that block is valid */
+       if (ab == NULL)
+               return 0;
+       
+       /* find out how many curves occur at each keyframe */
+       ak= (ActKeyColumn *)BLI_dlrbTree_search_exact(keys, compare_ak_cfraPtr, &ab->start);
+       startCurves = (ak)? ak->totcurve: 0;
+       
+       ak= (ActKeyColumn *)BLI_dlrbTree_search_exact(keys, compare_ak_cfraPtr, &ab->end);
+       endCurves = (ak)? ak->totcurve: 0;
+       
+       /* only draw keyblock if it appears in at all of the keyframes at lowest end */
+       if (!startCurves && !endCurves) 
+               return 0;
+       
+       totCurves = (startCurves>endCurves)? endCurves: startCurves;
+       return (ab->totcurve >= totCurves);
+}
+
 /* *************************** Keyframe Drawing *************************** */
 
 /* coordinates for diamond shape */
@@ -576,22 +603,7 @@ static void draw_keylist(View2D *v2d, DLRBT_Tree *keys, DLRBT_Tree *blocks, floa
        /* draw keyblocks */
        if (blocks) {
                for (ab= blocks->first; ab; ab= ab->next) {
-                       short startCurves, endCurves, totCurves;
-                       
-                       /* find out how many curves occur at each keyframe */
-                       ak= (ActKeyColumn *)BLI_dlrbTree_search_exact(keys, compare_ak_cfraPtr, &ab->start);
-                       startCurves = (ak)? ak->totcurve: 0;
-                       
-                       ak= (ActKeyColumn *)BLI_dlrbTree_search_exact(keys, compare_ak_cfraPtr, &ab->end);
-                       endCurves = (ak)? ak->totcurve: 0;
-                       
-                       /* only draw keyblock if it appears in at all of the keyframes at lowest end */
-                       if (!startCurves && !endCurves) 
-                               continue;
-                       else
-                               totCurves = (startCurves>endCurves)? endCurves: startCurves;
-                               
-                       if (ab->totcurve >= totCurves) {
+                       if (actkeyblock_is_valid(ab, keys)) {
                                /* draw block */
                                if (ab->sel)
                                        UI_ThemeColor4(TH_STRIP_SELECT);
index 680cd4b..6fdcb10 100644 (file)
@@ -874,34 +874,6 @@ typedef enum ePosePropagate_Termination {
 
 /* --------------------------------- */
 
-/* helper for pose_propagate_get_boneHoldEndFrame() 
- * Checks if ActKeyBlock should exist...
- */
-// TODO: move to keyframes drawing API...
-static short actkeyblock_is_valid (ActKeyBlock *ab, DLRBT_Tree *keys)
-{
-       ActKeyColumn *ak;
-       short startCurves, endCurves, totCurves;
-       
-       /* check that block is valid */
-       if (ab == NULL)
-               return 0;
-       
-       /* find out how many curves occur at each keyframe */
-       ak= (ActKeyColumn *)BLI_dlrbTree_search_exact(keys, compare_ak_cfraPtr, &ab->start);
-       startCurves = (ak)? ak->totcurve: 0;
-       
-       ak= (ActKeyColumn *)BLI_dlrbTree_search_exact(keys, compare_ak_cfraPtr, &ab->end);
-       endCurves = (ak)? ak->totcurve: 0;
-       
-       /* only draw keyblock if it appears in at all of the keyframes at lowest end */
-       if (!startCurves && !endCurves) 
-               return 0;
-       
-       totCurves = (startCurves>endCurves)? endCurves: startCurves;
-       return (ab->totcurve >= totCurves);
-}
-
 /* get frame on which the "hold" for the bone ends 
  * XXX: this may not really work that well if a bone moves on some channels and not others
  *             if this happens to be a major issue, scrap this, and just make this happen 
index 544c5c4..3c1bb81 100644 (file)
@@ -149,5 +149,8 @@ short compare_ak_cfraPtr(void *node, void *data);
 /* Comparator callback used for ActKeyBlocks and cframe float-value pointer */
 short compare_ab_cfraPtr(void *node, void *data);
 
+/* Checks if ActKeyBlock can be used (i.e. drawn/used to detect "holds") */
+short actkeyblock_is_valid(ActKeyBlock *ab, struct DLRBT_Tree *keys);
+
 #endif  /*  ED_KEYFRAMES_DRAW_H */