[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [35737] trunk/blender/source/blender/ editors: Reshuffled utility function to keyframe drawing API, removing some

Joshua Leung aligorith at gmail.com
Thu Mar 24 04:19:32 CET 2011


Revision: 35737
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=35737
Author:   aligorith
Date:     2011-03-24 03:19:30 +0000 (Thu, 24 Mar 2011)
Log Message:
-----------
Reshuffled utility function to keyframe drawing API, removing some
duplicate code

Modified Paths:
--------------
    trunk/blender/source/blender/editors/animation/keyframes_draw.c
    trunk/blender/source/blender/editors/armature/poseSlide.c
    trunk/blender/source/blender/editors/include/ED_keyframes_draw.h

Modified: trunk/blender/source/blender/editors/animation/keyframes_draw.c
===================================================================
--- trunk/blender/source/blender/editors/animation/keyframes_draw.c	2011-03-24 03:02:34 UTC (rev 35736)
+++ trunk/blender/source/blender/editors/animation/keyframes_draw.c	2011-03-24 03:19:30 UTC (rev 35737)
@@ -457,6 +457,33 @@
 	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 @@
 	/* 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);

Modified: trunk/blender/source/blender/editors/armature/poseSlide.c
===================================================================
--- trunk/blender/source/blender/editors/armature/poseSlide.c	2011-03-24 03:02:34 UTC (rev 35736)
+++ trunk/blender/source/blender/editors/armature/poseSlide.c	2011-03-24 03:19:30 UTC (rev 35737)
@@ -874,34 +874,6 @@
 
 /* --------------------------------- */
 
-/* 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 

Modified: trunk/blender/source/blender/editors/include/ED_keyframes_draw.h
===================================================================
--- trunk/blender/source/blender/editors/include/ED_keyframes_draw.h	2011-03-24 03:02:34 UTC (rev 35736)
+++ trunk/blender/source/blender/editors/include/ED_keyframes_draw.h	2011-03-24 03:19:30 UTC (rev 35737)
@@ -149,5 +149,8 @@
 /* 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 */
 




More information about the Bf-blender-cvs mailing list