diff --git a/source/blender/editors/animation/keyframes_draw.c b/source/blender/editors/animation/keyframes_draw.c index 3f8f8dc1e84..662f038fd6e 100644 --- a/source/blender/editors/animation/keyframes_draw.c +++ b/source/blender/editors/animation/keyframes_draw.c @@ -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); diff --git a/source/blender/editors/armature/poseSlide.c b/source/blender/editors/armature/poseSlide.c index 680cd4b6430..6fdcb1039f1 100644 --- a/source/blender/editors/armature/poseSlide.c +++ b/source/blender/editors/armature/poseSlide.c @@ -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 diff --git a/source/blender/editors/include/ED_keyframes_draw.h b/source/blender/editors/include/ED_keyframes_draw.h index 544c5c4a1ef..3c1bb814c82 100644 --- a/source/blender/editors/include/ED_keyframes_draw.h +++ b/source/blender/editors/include/ED_keyframes_draw.h @@ -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 */