2.5 - Action Editor Transforms now work again
authorJoshua Leung <aligorith@gmail.com>
Mon, 29 Dec 2008 07:19:16 +0000 (07:19 +0000)
committerJoshua Leung <aligorith@gmail.com>
Mon, 29 Dec 2008 07:19:16 +0000 (07:19 +0000)
Note: there were some crashes that would occur if context was not reset everytime the modal callback was run. Probably there's something about the context info we need to be more careful about.

source/blender/editors/animation/anim_filter.c
source/blender/editors/space_action/action_ops.c
source/blender/editors/transform/transform.c
source/blender/editors/transform/transform_conversions.c
source/blender/editors/transform/transform_generics.c
source/blender/editors/transform/transform_ops.c

index 6283f2dd0c68d9de0314ad0b92a566cb48c86a85..f9eddd1c2a88cf0b8e165b93fc8c86fdebea6245 100644 (file)
@@ -224,24 +224,26 @@ short ANIM_animdata_get_context (const bContext *C, bAnimContext *ac)
        ac->obact= (scene && scene->basact)?  scene->basact->object : NULL;
        ac->sa= sa;
        ac->ar= ar;
-       ac->spacetype= sa->spacetype;
-       ac->regiontype= ar->regiontype;
+       ac->spacetype= (sa) ? sa->spacetype : 0;
+       ac->regiontype= (ar) ? ar->regiontype : 0;
        
        /* context depends on editor we are currently in */
-       switch (sa->spacetype) {
-               case SPACE_ACTION:
-               {
-                       SpaceAction *saction= (SpaceAction *)CTX_wm_space_data(C);
-                       ok= actedit_get_context(C, ac, saction);
-               }
-                       break;
-                       
-               case SPACE_IPO:
-               {
-                       SpaceIpo *sipo= (SpaceIpo *)CTX_wm_space_data(C);
-                       ok= ipoedit_get_context(C, ac, sipo);
+       if (sa) {
+               switch (sa->spacetype) {
+                       case SPACE_ACTION:
+                       {
+                               SpaceAction *saction= (SpaceAction *)CTX_wm_space_data(C);
+                               ok= actedit_get_context(C, ac, saction);
+                       }
+                               break;
+                               
+                       case SPACE_IPO:
+                       {
+                               SpaceIpo *sipo= (SpaceIpo *)CTX_wm_space_data(C);
+                               ok= ipoedit_get_context(C, ac, sipo);
+                       }
+                               break;
                }
-                       break;
        }
        
        /* check if there's any valid data */
index cd9be252fa8e646492caddd44afb180b3c1c4d3a..d09a08af0b64f35d90d617be19c5933f6d107140 100644 (file)
@@ -46,6 +46,8 @@
 #include "UI_interface.h"
 #include "UI_view2d.h"
 
+#include "BIF_transform.h"
+
 #include "action_intern.h"
 
 #include "RNA_access.h"
@@ -82,7 +84,7 @@ void action_operatortypes(void)
 
 /* ************************** registration - keymaps **********************************/
 
-static void action_keymap_keyframes (ListBase *keymap)
+static void action_keymap_keyframes (wmWindowManager *wm, ListBase *keymap)
 {
        /* action_select.c - selection tools */
                /* click-select */
@@ -124,6 +126,9 @@ static void action_keymap_keyframes (ListBase *keymap)
        
        WM_keymap_add_item(keymap, "ACT_OT_keyframes_delete", XKEY, KM_PRESS, 0, 0);
        WM_keymap_add_item(keymap, "ACT_OT_keyframes_delete", DELKEY, KM_PRESS, 0, 0);
+       
+       /* transform system */
+       transform_keymap_for_space(wm, keymap, SPACE_ACTION);
 }
 
 /* --------------- */
@@ -137,6 +142,6 @@ void action_keymap(wmWindowManager *wm)
        
        /* keyframes */
        keymap= WM_keymap_listbase(wm, "Action_Keys", SPACE_ACTION, 0);
-       action_keymap_keyframes(keymap);
+       action_keymap_keyframes(wm, keymap);
 }
 
index 6a11297ff1fb91751f799fe034bd19ab288c05f6..c21e3d14feced7552f8d322a383238b50a668fe3 100644 (file)
@@ -469,7 +469,7 @@ static void viewRedrawForce(TransInfo *t)
                ED_area_tag_redraw(t->sa);
        }
        else if (t->spacetype == SPACE_ACTION) {
-               SpaceAction *saction= (SpaceAction *)CTX_wm_space_data(t->context);
+               SpaceAction *saction= (SpaceAction *)t->sa->spacedata.first;
                
                // TRANSFORM_FIX_ME
                if (saction->lock) {
@@ -4263,7 +4263,7 @@ static short getAnimEdit_SnapMode(TransInfo *t)
        
        /* currently, some of these are only for the action editor */
        if (t->spacetype == SPACE_ACTION) {
-               SpaceAction *saction= (SpaceAction *)CTX_wm_space_data(t->context);
+               SpaceAction *saction= (SpaceAction *)t->sa->spacedata.first;
                
                if (saction) {
                        switch (saction->autosnap) {
@@ -4290,7 +4290,7 @@ static short getAnimEdit_SnapMode(TransInfo *t)
                }
        }
        else if (t->spacetype == SPACE_NLA) {
-               SpaceNla *snla= (SpaceNla *)CTX_wm_space_data(t->context);
+               SpaceNla *snla= (SpaceNla *)t->sa->spacedata.first;
                
                if (snla) {
                        switch (snla->autosnap) {
@@ -4340,12 +4340,12 @@ static short getAnimEdit_DrawTime(TransInfo *t)
        
        /* currently, some of these are only for the action editor */
        if (t->spacetype == SPACE_ACTION) {
-               SpaceAction *saction= (SpaceAction *)CTX_wm_space_data(t->context);
+               SpaceAction *saction= (SpaceAction *)t->sa->spacedata.first;
                
                drawtime = (saction->flag & SACTION_DRAWTIME)? 1 : 0;
        }
        else if (t->spacetype == SPACE_NLA) {
-               SpaceNla *snla= (SpaceNla *)CTX_wm_space_data(t->context);
+               SpaceNla *snla= (SpaceNla *)t->sa->spacedata.first;
                
                drawtime = (snla->flag & SNLA_DRAWTIME)? 1 : 0;
        }
@@ -4548,7 +4548,7 @@ void initTimeSlide(TransInfo *t)
 {
        /* this tool is only really available in the Action Editor... */
        if (t->spacetype == SPACE_ACTION) {
-               SpaceAction *saction= (SpaceAction *)CTX_wm_space_data(t->context);
+               SpaceAction *saction= (SpaceAction *)t->sa->spacedata.first;
                
                /* set flag for drawing stuff */
                saction->flag |= SACTION_MOVING;
@@ -4576,9 +4576,9 @@ static void headerTimeSlide(TransInfo *t, float sval, char *str)
                outputNumInput(&(t->num), tvec);
        }
        else {
-               const float minx= *((float *)(t->customData));
-               const float maxx= *((float *)(t->customData) + 1);
-               const float cval= t->fac;
+               float minx= *((float *)(t->customData));
+               float maxx= *((float *)(t->customData) + 1);
+               float cval= t->fac;
                float val;
                        
                val= 2.0f*(cval-sval) / (maxx-minx);
@@ -4598,17 +4598,11 @@ static void applyTimeSlide(TransInfo *t, float sval)
        float minx= *((float *)(t->customData));
        float maxx= *((float *)(t->customData) + 1);
        
-       
        /* set value for drawing black line */
        if (t->spacetype == SPACE_ACTION) {
-               SpaceAction *saction= (SpaceAction *)CTX_wm_space_data(t->context);
+               SpaceAction *saction= (SpaceAction *)t->sa->spacedata.first;
                float cvalf = t->fac;
-
-#if 0 // TRANSFORM_FIX_ME              
-               if (NLA_ACTION_SCALED)
-                       cvalf= get_action_frame(OBACT, cvalf);
-#endif
-                       
+               
                saction->timeslide= cvalf;
        }
        
@@ -4658,7 +4652,7 @@ int TimeSlide(TransInfo *t, short mval[2])
        t->fac= cval[0];
        
        /* handle numeric-input stuff */
-       t->vec[0] = 2.0*(cval[0]-sval[0]) / (maxx-minx);
+       t->vec[0] = 2.0f*(cval[0]-sval[0]) / (maxx-minx);
        applyNumInput(&t->num, &t->vec[0]);
        t->fac = (maxx-minx) * t->vec[0] / 2.0 + sval[0];
        
index a430b490584e2e024ee513554f6f628edde5d2bd..36deae8b98e054354a8677fad5fbc97f52f4a50b 100644 (file)
@@ -3973,7 +3973,7 @@ void special_aftertrans_update(TransInfo *t)
        }
        
        if (t->spacetype == SPACE_ACTION) {
-               SpaceAction *saction= (SpaceAction *)CTX_wm_space_data(t->context);
+               SpaceAction *saction= (SpaceAction *)t->sa->spacedata.first;
                Scene *scene= NULL;
                bAnimContext ac;
                
@@ -3984,8 +3984,8 @@ void special_aftertrans_update(TransInfo *t)
                }
                
                /* get pointers to useful data */
-               ob = OBACT;
                scene= ac.scene;
+               ob = OBACT;
                
                if (ac.datatype == ANIMCONT_DOPESHEET) {
                        ListBase anim_data = {NULL, NULL};
index 54fac3e5120aa5af2475912bdaec2f0772cd06bc..8b0f46daebdd0dca48fa49fb08b0eb46afeb3cf6 100644 (file)
@@ -730,7 +730,7 @@ void initTransInfo (bContext *C, TransInfo *t, wmEvent *event)
        }
        else if(t->spacetype==SPACE_IMAGE)
        {
-               View2D *v2d = sa->spacedata.first;
+               View2D *v2d = sa->spacedata.first; // XXX no!
 
                t->view = v2d;
 
@@ -738,7 +738,8 @@ void initTransInfo (bContext *C, TransInfo *t, wmEvent *event)
        }
        else
        {
-               t->view = NULL;
+               // XXX for now, get View2D  from the active region
+               t->view = &ar->v2d;
                
                t->around = V3D_CENTER;
        }
index b2a865074fdd2a18f75ff39efb0254b09a0b6c22..4ecb9358cc706652acf9cbf0fc18af7cb5b6ffd1 100644 (file)
@@ -62,7 +62,11 @@ static void transformops_data(bContext *C, wmOperator *op, wmEvent *event)
 static int transform_modal(bContext *C, wmOperator *op, wmEvent *event)
 {
        TransInfo *t = op->customdata;
-
+       
+       /* need to set context here, otherwise we get crashes with things that use context */
+       // XXX this seems quite hackish - Aligorith
+       t->context= C;
+       
        transformEvent(t, event);
        
        transformApply(t);