forked from bartvdbraak/blender
Reshuffled utility function to keyframe drawing API, removing some
duplicate code
This commit is contained in:
parent
eef811a095
commit
3b0a42f898
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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 */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user