Revision: 17538
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=17538
Author:   aligorith
Date:     2008-11-23 01:08:35 +0100 (Sun, 23 Nov 2008)

Log Message:
-----------
AnimSys2: Auto-time-snapping for IPO Editor Transforms

Now the IPO-Editor has the Auto-snapping setting that the Action/NLA Editors 
have, which mean that the keyframes will always be snapped to the nearest 
frame. This means that keyframes can now be moved without having to constantly 
hold the shift/control keys.

Notes:
- Due to the difference in implementation, there is no "frame/second step" 
option here, but that was not too useful anyway.
- As there are values as well as times for keyframes, this frame snapping can 
only be turned on/off using the menu (and not any hotkeys)

Modified Paths:
--------------
    branches/animsys2/source/blender/makesdna/DNA_space_types.h
    branches/animsys2/source/blender/src/header_ipo.c
    branches/animsys2/source/blender/src/transform.c
    branches/animsys2/source/blender/src/transform_conversions.c
    branches/animsys2/source/blender/src/transform_generics.c

Modified: branches/animsys2/source/blender/makesdna/DNA_space_types.h
===================================================================
--- branches/animsys2/source/blender/makesdna/DNA_space_types.h 2008-11-22 
22:22:38 UTC (rev 17537)
+++ branches/animsys2/source/blender/makesdna/DNA_space_types.h 2008-11-23 
00:08:35 UTC (rev 17538)
@@ -98,7 +98,7 @@
        short butofs, channel;
        short showkey, blocktype;
        short menunr, lock;
-       int flag;
+       short flag, autosnap;
        float median[3];
        rctf tot;
 } SpaceIpo;

Modified: branches/animsys2/source/blender/src/header_ipo.c
===================================================================
--- branches/animsys2/source/blender/src/header_ipo.c   2008-11-22 22:22:38 UTC 
(rev 17537)
+++ branches/animsys2/source/blender/src/header_ipo.c   2008-11-23 00:08:35 UTC 
(rev 17538)
@@ -758,7 +758,7 @@
        uiDefIconTextBut(block, BUTM, 1, (G.sipo->flag & 
SIPO_NOHANDLES)?ICON_CHECKBOX_DEHLT:ICON_CHECKBOX_HLT, 
                                         "Show Handles|Ctrl H", 0, yco-=20, 
menuwidth, 19, NULL, 0.0, 0.0, 1, 16, "");
        uiDefIconTextBut(block, BUTM, 1, (G.sipo->flag & 
SIPO_NODRAWCFRANUM)?ICON_CHECKBOX_DEHLT:ICON_CHECKBOX_HLT, 
-                                        "Show Handles|Ctrl H", 0, yco-=20, 
menuwidth, 19, NULL, 0.0, 0.0, 1, 17, "");
+                                        "Show Current Frame Number|", 0, 
yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 17, "");
        
        uiDefBut(block, SEPR, 0, "",        0, yco-=6, menuwidth, 6, NULL, 0.0, 
0.0, 0, 0, "");
 
@@ -1393,9 +1393,24 @@
                uiDefIconBut(block, BUT, B_IPOPASTE, ICON_PASTEDOWN,    
xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "Pastes the curves from the buffer");
        }
        uiBlockEndAlign(block);
-       xco+=XIC/2;
+       xco+=(XIC*3/2);
        
        uiClearButLock();
+       
+       /* AUTOSNAP */
+       if (G.sipo->flag & SIPO_DRAWTIME) {
+               uiDefButS(block, MENU, B_REDR,
+                               "Auto-Snap Keyframes %t|No Time-Snap 
%x0|Nearest Second %x2|Nearest Marker %x3", 
+                               xco,0,90,YIC, &G.sipo->autosnap, 0, 1, 0, 0, 
+                               "Auto-snapping mode for keyframe times when 
transforming");
+       }
+       else {
+               uiDefButS(block, MENU, B_REDR, 
+                               "Auto-Snap Keyframes %t|No Time-Snap 
%x0|Nearest Frame %x2|Nearest Marker %x3", 
+                               xco,0,90,YIC, &G.sipo->autosnap, 0, 1, 0, 0, 
+                               "Auto-snapping mode for keyframe times when 
transforming");
+       }
+       xco+=(70 + (XIC/2));
 
        /* ZOOMBORDER */
        uiDefIconBut(block, BUT, B_IPOBORDER, ICON_BORDERMOVE,  
xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "Zooms view to area (Shift B)");

Modified: branches/animsys2/source/blender/src/transform.c
===================================================================
--- branches/animsys2/source/blender/src/transform.c    2008-11-22 22:22:38 UTC 
(rev 17537)
+++ branches/animsys2/source/blender/src/transform.c    2008-11-23 00:08:35 UTC 
(rev 17538)
@@ -4294,12 +4294,15 @@
        short drawtime;
        
        /* currently, some of these are only for the action editor */
-       if (t->spacetype == SPACE_ACTION && G.saction) {
+       if ((t->spacetype == SPACE_ACTION) && (G.saction)) {
                drawtime = (G.saction->flag & SACTION_DRAWTIME)? 1 : 0;
        }
-       else if (t->spacetype == SPACE_NLA && G.snla) {
+       else if ((t->spacetype == SPACE_NLA) && (G.snla)) {
                drawtime = (G.snla->flag & SNLA_DRAWTIME)? 1 : 0;
        }
+       else if ((t->spacetype == SPACE_IPO) && (G.sipo)) {
+               drawtime = (G.sipo->flag & SIPO_DRAWTIME)? 1 : 0;
+       }
        else {
                drawtime = 0;
        }

Modified: branches/animsys2/source/blender/src/transform_conversions.c
===================================================================
--- branches/animsys2/source/blender/src/transform_conversions.c        
2008-11-22 22:22:38 UTC (rev 17537)
+++ branches/animsys2/source/blender/src/transform_conversions.c        
2008-11-23 00:08:35 UTC (rev 17538)
@@ -124,6 +124,7 @@
 #include "BSE_editipo.h"
 #include "BSE_editipo_types.h"
 #include "BSE_editaction_types.h"
+#include "BSE_time.h"
 
 #include "BDR_drawaction.h"            // list of keyframes in action
 #include "BDR_editobject.h"            // reset_slowparents()
@@ -2507,6 +2508,17 @@
        
        /* flush to 2d vector from internally used 3d vector */
        for (a=0, td= t->data2d; a<t->total; a++, td++) {
+               /* handle snapping for time values - we should still be in 
NLA-scaled timespace */
+               switch (G.sipo->autosnap) {
+                       case SACTSNAP_FRAME: /* snap to nearest frame */
+                               td->loc[0]= (float)( floor(td->loc[0]+0.5f) );
+                               break;
+                               
+                       case SACTSNAP_MARKER: /* snap to nearest marker */
+                               td->loc[0]= 
(float)find_nearest_marker_time(td->loc[0]);
+                               break;
+               }
+               
                /* we need to unapply the nla-scaling from the time in some 
situations */
                if (NLA_IPO_SCALED)
                        td->loc2d[0]= get_action_frame(OBACT, td->loc[0]);
@@ -4275,11 +4287,14 @@
        else if (t->spacetype == SPACE_IPO) {
                t->flag |= T_POINTS|T_2D_EDIT;
                createTransIpoData(t); 
+               
+#if 0
                if (t->data && (t->flag & T_PROP_EDIT)) {
                        sort_trans_data(t);     // makes selected become first 
in array
                        set_prop_dist(t, 1);
                        sort_trans_data_dist(t);
                }
+#endif
        }
        else if (G.obedit) {
                t->ext = NULL;

Modified: branches/animsys2/source/blender/src/transform_generics.c
===================================================================
--- branches/animsys2/source/blender/src/transform_generics.c   2008-11-22 
22:22:38 UTC (rev 17537)
+++ branches/animsys2/source/blender/src/transform_generics.c   2008-11-23 
00:08:35 UTC (rev 17538)
@@ -477,7 +477,6 @@
                                /* if we're not actively adjusting roll (i.e. 
not using 'Bone Roll' tool), 
                                 * we need to adjust the roll of the bone so 
that is doesn't randomly move change on the user
                                 */
-                               // TODO: do we need a setting to turn this 
on/off someday?
                                if (t->mode != TFM_BONE_ROLL) {
                                        /* calculate roll of bone whose tip is 
selected
                                         *      - normal bones should have tip 
selected if bone is selected


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

Reply via email to