Revision: 17286
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=17286
Author:   aligorith
Date:     2008-11-02 13:12:03 +0100 (Sun, 02 Nov 2008)

Log Message:
-----------
AnimSys2: Assorted IPO-code housekeeping

* Cleaned up more of the IPO-code. There's still a LOT of messy code lying 
around that needs attention

* Restored the double recalculation for curve handles when inserting keyframes, 
in light of some comments I discovered in messy code

* 'Alpha' sliders are now available when setting the colour of curve handles to 
help differentiate them from the keyframes. 

* Silenced compiler warnings in transform code due to changes in types for 
BezTriple vars

Modified Paths:
--------------
    branches/animsys2/source/blender/include/transform.h
    branches/animsys2/source/blender/src/editipo.c
    branches/animsys2/source/blender/src/keyframing.c
    branches/animsys2/source/blender/src/space.c

Modified: branches/animsys2/source/blender/include/transform.h
===================================================================
--- branches/animsys2/source/blender/include/transform.h        2008-11-02 
11:01:45 UTC (rev 17285)
+++ branches/animsys2/source/blender/include/transform.h        2008-11-02 
12:12:03 UTC (rev 17286)
@@ -138,8 +138,8 @@
 
 /* we need to store 2 handles for each transdata incase the other handle wasnt 
selected */
 typedef struct TransDataCurveHandleFlags {
-       short ih1, ih2;
-       short *h1, *h2;
+       char ih1, ih2;
+       char *h1, *h2;
 } TransDataCurveHandleFlags;
 
 

Modified: branches/animsys2/source/blender/src/editipo.c
===================================================================
--- branches/animsys2/source/blender/src/editipo.c      2008-11-02 11:01:45 UTC 
(rev 17285)
+++ branches/animsys2/source/blender/src/editipo.c      2008-11-02 12:12:03 UTC 
(rev 17286)
@@ -1265,15 +1265,15 @@
 
 /* ****************** EditIpo ************************ */
 
+/* bad globals only really used here! */
 int totipo_edit=0, totipo_sel=0, totipo_curve=0, totipo_vis=0, totipo_vert=0, 
totipo_vertsel=0, totipo_key=0, totipo_keysel=0;
 
 void get_status_editipo(void)
 {
        EditIpo *ei;
-       IpoKey *ik;
-       BezTriple *bezt;
        int a, b;
        
+       /* reset all globals first (bad globals!) */
        totipo_vis= 0;
        totipo_curve= 0;
        totipo_sel= 0;
@@ -1283,48 +1283,55 @@
        totipo_key= 0;
        totipo_keysel= 0;
        
-       if(G.sipo->ipo && G.sipo->ipo->id.lib) return;
+       /* sanity check - cannot edit lib-linked IPO */
+       if (G.sipo->ipo && G.sipo->ipo->id.lib) return;
        
+       /* sanity check - an editipo might not exist for some reason */
        ei= G.sipo->editipo;
-       if(ei==0) return;
-       for(a=0; a<G.sipo->totipo; a++) {
-               if( ei->flag & IPO_VISIBLE ) {
+       if (ei == NULL) return;
+       
+       for (a=0; a<G.sipo->totipo; a++, ei++) {
+               if (ei->flag & IPO_VISIBLE ) {
                        totipo_vis++;
-                       if(ei->flag & IPO_SELECT) totipo_sel++;
-                       if(ei->icu && ei->icu->totvert) totipo_curve++;
-                       if(G.sipo->showkey || (ei->flag & IPO_EDIT)) {
-                               
+                       if (ei->flag & IPO_SELECT) totipo_sel++;
+                       if (ei->icu && ei->icu->totvert) totipo_curve++;
+                       
+                       if ((G.sipo->showkey) || (ei->flag & IPO_EDIT)) {
                                /* if showkey: do count the vertices (for grab) 
*/
-                               if(G.sipo->showkey==0) totipo_edit++;
+                               if (G.sipo->showkey==0) totipo_edit++;
                                
-                               if(ei->icu) {
-                                       if(ei->icu->bezt) {
-                                               bezt= ei->icu->bezt;
-                                               b= ei->icu->totvert;
-                                               while(b--) {
-                                                       
if(ei->icu->ipo==IPO_BEZ) {
-                                                               if(bezt->f1 & 
SELECT) totipo_vertsel++;
-                                                               if(bezt->f3 & 
SELECT) totipo_vertsel++;
-                                                               totipo_vert+= 2;
-                                                       }
-                                                       if(bezt->f2 & SELECT) 
totipo_vertsel++;
-                                                       
+                               if (ei->icu && ei->icu->bezt) {
+                                       IpoCurve *icu= ei->icu;
+                                       BezTriple *bezt=icu->bezt, 
*prevbezt=NULL;
+                                       
+                                       for (b=0; b < icu->totvert; b++, 
prevbezt=bezt, bezt++) {
+                                               /* first handle only visible if 
previous segment had handles */
+                                               if ( (!prevbezt && 
(bezt->ipo==IPO_BEZ)) || (prevbezt && (prevbezt->ipo==IPO_BEZ)) ) {
+                                                       if(bezt->f1 & SELECT) 
totipo_vertsel++;
                                                        totipo_vert++;
-                                                       bezt++;
                                                }
+                                               
+                                               /* second handle only visible 
if this segment is bezier */
+                                               if (bezt->ipo == IPO_BEZ) {
+                                                       if (bezt->f3 & SELECT) 
totipo_vertsel++;
+                                                       totipo_vert++;
+                                               }
+                                               
+                                               /* keyframe itself is always 
visible */
+                                               if (bezt->f2 & SELECT) 
totipo_vertsel++;
+                                               totipo_vert++;
                                        }
                                }
                        }
                }
-               ei++;
        }
        
-       if(G.sipo->showkey) {
-               ik= G.sipo->ipokey.first;
-               while(ik) {
+       if (G.sipo->showkey) {
+               IpoKey *ik;
+               
+               for (ik= G.sipo->ipokey.first; ik; ik= ik->next) {
                        totipo_key++;
-                       if(ik->flag & 1) totipo_keysel++;
-                       ik= ik->next;
+                       if (ik->flag & SELECT) totipo_keysel++;
                }
        }
 }
@@ -1337,17 +1344,18 @@
        int a;
        
        ei= G.sipo->editipo;
-       if(ei) {
-               for(a=0; a<G.sipo->totipo; a++, ei++) {
-                       if(ei->icu) ei->icu->flag= ei->flag;
+       if (ei) {
+               for (a=0; a<G.sipo->totipo; a++, ei++) {
+                       if (ei->icu) 
+                               ei->icu->flag= ei->flag;
                }
        }
-       if(G.sipo->showkey) {
-               ik= G.sipo->ipokey.first;
-               while(ik) {
-                       for(a=0; a<G.sipo->totipo; a++) {
-                               if(ik->data[a]) {
-                                       if(ik->flag & 1) {
+       
+       if (G.sipo->showkey) {
+               for (ik= G.sipo->ipokey.first; ik; ik= ik->next) {
+                       for (a=0; a<G.sipo->totipo; a++) {
+                               if (ik->data[a]) {
+                                       if (ik->flag & SELECT) {
                                                BEZ_SEL(ik->data[a]);
                                        }
                                        else {
@@ -1355,7 +1363,6 @@
                                        }
                                }
                        }
-                       ik= ik->next;
                }
        }
 }
@@ -1367,7 +1374,7 @@
        int a; /*  , tot= 0, ok= 0; */
        
        /* after showkey immediately go to editing of selected points */
-       if(G.sipo->showkey) {
+       if (G.sipo->showkey) {
                G.sipo->showkey= 0;
                if(G.sipo->ipo) G.sipo->ipo->showkey= 0;
                ei= G.sipo->editipo;
@@ -1378,7 +1385,7 @@
        
        get_status_editipo();
        
-       if(G.sipo->ipo && G.sipo->ipo->id.lib) return;
+       if (G.sipo->ipo && G.sipo->ipo->id.lib) return;
        
        ei= G.sipo->editipo;
        for(a=0; a<G.sipo->totipo; a++, ei++) {         
@@ -2172,18 +2179,18 @@
                ei->flag |= IPO_SELECT|IPO_VISIBLE;
                ei->icu->flag= ei->flag;
                ei->icu->extrap= IPO_DIR;
-
+               
                do_ipo_buttons(B_IPOHOME);
        }
        else {
                ei= G.sipo->editipo;
                for(nr=0; nr<G.sipo->totipo; nr++, ei++) {
                        if (ISPOIN(ei, flag & IPO_VISIBLE, icu)) {
-                       
+                               
                                ok= 0;
                                if(G.sipo->showkey) ok= 1;
                                else if(ei->flag & IPO_SELECT) ok= 1;
-
+                               
                                if(ok) {
                                        /* count amount */
                                        if(event==1) tot= 1;
@@ -2195,8 +2202,7 @@
                                                        ik= ik->next;
                                                }
                                        }
-                                       if(tot) {
-                                       
+                                       if (tot) {
                                                /* correction for ob timeoffs */
                                                cfra= frame_to_float(CFRA);
                                                id= G.sipo->from;       
@@ -2230,16 +2236,14 @@
                                                }
                                                else {
                                                        fp= insertvals;
-                                                       ik= 
G.sipo->ipokey.first;
-                                                       while(ik) {
-                                                               if(ik->flag & 
1) {
+                                                       for (ik= 
G.sipo->ipokey.first; ik; ik= ik->next) {
+                                                               if (ik->flag & 
SELECT) {
                                                                        
calc_ipo(G.sipo->ipo, ik->val);
-
+                                                                       
                                                                        fp[0]= 
ik->val;
                                                                        fp[1]= 
ei->icu->curval;
                                                                        fp+= 2;
                                                                }
-                                                               ik= ik->next;
                                                        }
                                                }
                                                fp= insertvals;

Modified: branches/animsys2/source/blender/src/keyframing.c
===================================================================
--- branches/animsys2/source/blender/src/keyframing.c   2008-11-02 11:01:45 UTC 
(rev 17285)
+++ branches/animsys2/source/blender/src/keyframing.c   2008-11-02 12:12:03 UTC 
(rev 17286)
@@ -331,6 +331,12 @@
         */
        if (a < 0) return;
        
+       /* don't recalculate handles if fast is set
+        *      - this is a hack to make importers faster
+        *      - we may calculate twice (see editipo_changed(), due to 
autohandle needing two calculations)
+        */
+       if (!fast) calchandles_ipocurve(icu);
+       
        /* set handletype and interpolation */
        if (icu->totvert > 2) {
                BezTriple *bezt= (icu->bezt + a);
@@ -351,6 +357,12 @@
                }
                else
                        bezt->ipo= icu->ipo;
+                       
+               /* don't recalculate handles if fast is set
+                *      - this is a hack to make importers faster
+                *      - we may calculate twice (see editipo_changed(), due to 
autohandle needing two calculations)
+                */
+               if (!fast) calchandles_ipocurve(icu);
        }
        else {
                BezTriple *bezt= (icu->bezt + a);
@@ -358,13 +370,6 @@
                /* set interpolation directly from ipo-curve */
                bezt->ipo= icu->ipo;
        }
-       
-       /* don't recalculate handles if fast is set
-        *      - this is a hack to make importers faster
-        *      - in past handles were calculated twice... only once now at end 
should be sufficient! 
-        */
-       // TODO: importers should add to a bpoint array allocated once instead 
-       if (!fast) calchandles_ipocurve(icu);
 }
 
 /* ------------------- Get Data ------------------------ */

Modified: branches/animsys2/source/blender/src/space.c
===================================================================
--- branches/animsys2/source/blender/src/space.c        2008-11-02 11:01:45 UTC 
(rev 17285)
+++ branches/animsys2/source/blender/src/space.c        2008-11-02 12:12:03 UTC 
(rev 17286)
@@ -3579,7 +3579,7 @@
        }
        else {
                uiBlockBeginAlign(block);
-               if ELEM9(th_curcol, TH_PANEL, TH_LAMP, TH_FACE, TH_FACE_SELECT, 
TH_EDITMESH_ACTIVE, TH_MENU_BACK, TH_MENU_HILITE, TH_MENU_ITEM, TH_NODE) {
+               if ELEM11(th_curcol, TH_PANEL, TH_LAMP, TH_FACE, 
TH_FACE_SELECT, TH_EDITMESH_ACTIVE, TH_MENU_BACK, TH_MENU_HILITE, TH_MENU_ITEM, 
TH_NODE, TH_HANDLE_VERTEX_SELECT, TH_HANDLE_VERTEX) {
                        uiDefButC(block, NUMSLI, B_UPDATE_THEME,"A ",   
465,y3+25,200,20,  col+3, 0.0, 255.0, B_THEMECOL, 0, "");
                }
                uiDefButC(block, NUMSLI, B_UPDATE_THEME,"R ",   465,y3,200,20,  
col, 0.0, 255.0, B_THEMECOL, 0, "");


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

Reply via email to