Revision: 21426
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21426
Author:   aligorith
Date:     2009-07-08 14:30:09 +0200 (Wed, 08 Jul 2009)

Log Message:
-----------
NLA SoC: Little optimisation + Drawing bugfix

* Text labels on NLA-Strips should now draw properly for most short-strips now. 
Previously, the padding on the text was a bit too extreme, so for very short 
strips (less than 4 frames or so), the text was often pushed down into the 
bottom-right corner of view.

* Optimised the keyframe-highlighting code for buttons a bit. Replaced the 
custom linear-search with the binary-search used when inserting keyframes (and 
for the 3d-view keyframe-indicator). There should be some theoretical 
improvements due to this at least... 

Modified Paths:
--------------
    branches/soc-2009-aligorith/source/blender/blenkernel/BKE_fcurve.h
    branches/soc-2009-aligorith/source/blender/blenkernel/intern/fcurve.c
    branches/soc-2009-aligorith/source/blender/editors/animation/keyframing.c
    branches/soc-2009-aligorith/source/blender/editors/include/ED_keyframing.h
    
branches/soc-2009-aligorith/source/blender/editors/interface/interface_anim.c
    branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_draw.c

Modified: branches/soc-2009-aligorith/source/blender/blenkernel/BKE_fcurve.h
===================================================================
--- branches/soc-2009-aligorith/source/blender/blenkernel/BKE_fcurve.h  
2009-07-08 11:55:11 UTC (rev 21425)
+++ branches/soc-2009-aligorith/source/blender/blenkernel/BKE_fcurve.h  
2009-07-08 12:30:09 UTC (rev 21426)
@@ -153,9 +153,6 @@
 /* find matching F-Curve in the given list of F-Curves */
 struct FCurve *list_find_fcurve(ListBase *list, const char rna_path[], const 
int array_index);
 
-/* test if there is a keyframe at cfra */
-short on_keyframe_fcurve(struct FCurve *fcu, float cfra);
-
 /* get the time extents for F-Curve */
 void calc_fcurve_range(struct FCurve *fcu, float *min, float *max);
 

Modified: branches/soc-2009-aligorith/source/blender/blenkernel/intern/fcurve.c
===================================================================
--- branches/soc-2009-aligorith/source/blender/blenkernel/intern/fcurve.c       
2009-07-08 11:55:11 UTC (rev 21425)
+++ branches/soc-2009-aligorith/source/blender/blenkernel/intern/fcurve.c       
2009-07-08 12:30:09 UTC (rev 21426)
@@ -200,20 +200,6 @@
        return NULL;
 }
 
-short on_keyframe_fcurve(FCurve *fcu, float cfra)
-{
-       BezTriple *bezt;
-       unsigned i;
-
-       bezt= fcu->bezt;
-       for (i=0; i<fcu->totvert; i++, bezt++) {
-               if (IS_EQ(bezt->vec[1][0], cfra))
-                       return 1;
-       }
-       
-       return 0;
-}
-
 /* Calculate the extents of F-Curve's data */
 void calc_fcurve_bounds (FCurve *fcu, float *xmin, float *xmax, float *ymin, 
float *ymax)
 {

Modified: 
branches/soc-2009-aligorith/source/blender/editors/animation/keyframing.c
===================================================================
--- branches/soc-2009-aligorith/source/blender/editors/animation/keyframing.c   
2009-07-08 11:55:11 UTC (rev 21425)
+++ branches/soc-2009-aligorith/source/blender/editors/animation/keyframing.c   
2009-07-08 12:30:09 UTC (rev 21426)
@@ -1430,6 +1430,31 @@
 
 /* --------------- API/Per-Datablock Handling ------------------- */
 
+/* Checks if some F-Curve has a keyframe for a given frame */
+short fcurve_frame_has_keyframe (FCurve *fcu, float frame, short filter)
+{
+       /* quick sanity check */
+       if (fcu == NULL)
+               return 0;
+       
+       /* we either include all regardless of muting, or only non-muted  */
+       if ((filter & ANIMFILTER_KEYS_MUTED) || (fcu->flag & FCURVE_MUTED)==0) {
+               short replace = -1;
+               int i = binarysearch_bezt_index(fcu->bezt, frame, fcu->totvert, 
&replace);
+               
+               /* binarysearch_bezt_index will set replace to be 0 or 1
+                *      - obviously, 1 represents a match
+                */
+               if (replace) {                  
+                       /* sanity check: 'i' may in rare cases exceed arraylen 
*/
+                       if ((i >= 0) && (i < fcu->totvert))
+                               return 1;
+               }
+       }
+       
+       return 0;
+}
+
 /* Checks whether an Action has a keyframe for a given frame 
  * Since we're only concerned whether a keyframe exists, we can simply loop 
until a match is found...
  */
@@ -1451,20 +1476,8 @@
        for (fcu= act->curves.first; fcu; fcu= fcu->next) {
                /* only check if there are keyframes (currently only of type 
BezTriple) */
                if (fcu->bezt && fcu->totvert) {
-                       /* we either include all regardless of muting, or only 
non-muted  */
-                       if ((filter & ANIMFILTER_KEYS_MUTED) || (fcu->flag & 
FCURVE_MUTED)==0) {
-                               short replace = -1;
-                               int i = binarysearch_bezt_index(fcu->bezt, 
frame, fcu->totvert, &replace);
-                               
-                               /* binarysearch_bezt_index will set replace to 
be 0 or 1
-                                *      - obviously, 1 represents a match
-                                */
-                               if (replace) {                  
-                                       /* sanity check: 'i' may in rare cases 
exceed arraylen */
-                                       if ((i >= 0) && (i < fcu->totvert))
-                                               return 1;
-                               }
-                       }
+                       if (fcurve_frame_has_keyframe(fcu, frame, filter))
+                               return 1;
                }
        }
        

Modified: 
branches/soc-2009-aligorith/source/blender/editors/include/ED_keyframing.h
===================================================================
--- branches/soc-2009-aligorith/source/blender/editors/include/ED_keyframing.h  
2009-07-08 11:55:11 UTC (rev 21425)
+++ branches/soc-2009-aligorith/source/blender/editors/include/ED_keyframing.h  
2009-07-08 12:30:09 UTC (rev 21426)
@@ -199,6 +199,11 @@
 
 /* ************ Keyframe Checking ******************** */
 
+/* Lesser Keyframe Checking API call:
+ *     - Used for the buttons to check for keyframes...
+ */
+short fcurve_frame_has_keyframe(struct FCurve *fcu, float frame, short filter);
+
 /* Main Keyframe Checking API call:
  * Checks whether a keyframe exists for the given ID-block one the given frame.
  *  - It is recommended to call this method over the other keyframe-checkers 
directly,

Modified: 
branches/soc-2009-aligorith/source/blender/editors/interface/interface_anim.c
===================================================================
--- 
branches/soc-2009-aligorith/source/blender/editors/interface/interface_anim.c   
    2009-07-08 11:55:11 UTC (rev 21425)
+++ 
branches/soc-2009-aligorith/source/blender/editors/interface/interface_anim.c   
    2009-07-08 12:30:09 UTC (rev 21426)
@@ -18,6 +18,8 @@
 #include "RNA_access.h"
 #include "RNA_types.h"
 
+#include "ED_keyframing.h"
+
 #include "UI_interface.h"
 
 #include "WM_api.h"
@@ -47,7 +49,7 @@
                                                if (fcu) {
                                                        but->flag |= 
UI_BUT_ANIMATED;
                                                        
-                                                       if 
(on_keyframe_fcurve(fcu, cfra))
+                                                       if 
(fcurve_frame_has_keyframe(fcu, cfra, 0))
                                                                but->flag |= 
UI_BUT_ANIMATED_KEY;
                                                }
                                        }

Modified: 
branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_draw.c
===================================================================
--- branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_draw.c     
2009-07-08 11:55:11 UTC (rev 21425)
+++ branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_draw.c     
2009-07-08 12:30:09 UTC (rev 21426)
@@ -291,6 +291,9 @@
        gl_round_box_shade(GL_POLYGON, strip->start, yminc, strip->end, ymaxc, 
0.0, 0.5, 0.1);
        
        
+       /* draw influence 'curve' */
+       // TODO:
+       
        /* draw strip outline 
         *      - color used here is to indicate active vs non-active
         */
@@ -378,11 +381,9 @@
                
                case NLASTRIP_TYPE_CLIP:        /* Action-Clip (default) */
                default:
-                       if (strip->act)
-                               sprintf(str, "%d | Act: %s | %.2f %s %.2f", 
-                                       index, strip->act->id.name+2, 
strip->start, dir, strip->end);
-                       else
-                               sprintf(str, "%d | Act: <NONE>", index); // 
xxx... need a better format?
+                       sprintf(str, "%d | Act: %s | %.2f %s %.2f", 
+                               index, 
((strip->act)?strip->act->id.name+2:"<NONE>"), 
+                               strip->start, dir, strip->end);
                        break;
        }
        
@@ -396,9 +397,9 @@
         *      - padding of 2 'units' on either side
         */
        // TODO: make this centered?
-       rect.xmin= strip->start + 2;
+       rect.xmin= strip->start + 0.5f;
        rect.ymin= yminc;
-       rect.xmax= strip->end - 2;
+       rect.xmax= strip->end - 0.5f;
        rect.ymax= ymaxc;
        
        /* add this string to the cache of texts to draw*/


_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to