At last... this merge should finally do the trick!
[blender.git] / source / blender / editors / transform / transform.c
index f115bb9a0681ec94427f37382c846bf4fd066376..ded6edbbb0e278ad656ac731224c63b1648543a7 100644 (file)
@@ -1137,7 +1137,7 @@ void drawTransform(const struct bContext *C, struct ARegion *ar, void *arg)
 
 void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
 {
-       Scene *sce = CTX_data_scene(C);
+       ToolSettings *ts = CTX_data_tool_settings(C);
        int constraint_axis[3] = {0, 0, 0};
        int proportional = 0;
 
@@ -1198,8 +1198,8 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
        // XXX If modal, save settings back in scene
        if (t->flag & T_MODAL)
        {
-               sce->prop_mode = t->prop_mode;
-               sce->proportional = proportional;
+               ts->prop_mode = t->prop_mode;
+               ts->proportional = proportional;
 
                if(t->spacetype == SPACE_VIEW3D)
                {
@@ -2362,7 +2362,7 @@ static void ElementResize(TransInfo *t, TransData *td, float mat[3][3]) {
                }
                else if (t->flag & T_EDIT) {
                        
-                       if(t->around==V3D_LOCAL && (t->scene->selectmode & SCE_SELECT_FACE)) {
+                       if(t->around==V3D_LOCAL && (t->settings->selectmode & SCE_SELECT_FACE)) {
                                VECCOPY(center, td->center);
                        }
                        else {
@@ -2663,7 +2663,7 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short
                }
                else {
                        /* !TODO! Make this if not rely on G */
-                       if(around==V3D_LOCAL && (t->scene->selectmode & SCE_SELECT_FACE)) {
+                       if(around==V3D_LOCAL && (t->settings->selectmode & SCE_SELECT_FACE)) {
                                center = td->center;
                        }
                }
@@ -3129,7 +3129,7 @@ static void headerTranslation(TransInfo *t, float vec[3], char *str) {
                sprintf(distvec, "%.4f", dist);
                
        if(t->flag & T_AUTOIK) {
-               short chainlen= t->scene->toolsettings->autoik_chainlen;
+               short chainlen= t->settings->autoik_chainlen;
                
                if(chainlen)
                        sprintf(autoik, "AutoIK-Len: %d", chainlen);
@@ -4254,7 +4254,7 @@ int Align(TransInfo *t, short mval[2])
                        VECCOPY(t->center, td->center);
                }
                else {
-                       if(t->scene->selectmode & SCE_SELECT_FACE) {
+                       if(t->settings->selectmode & SCE_SELECT_FACE) {
                                VECCOPY(t->center, td->center);
                        }
                }
@@ -4470,10 +4470,11 @@ static void applyTimeTranslate(TransInfo *t, float sval)
        
        /* it doesn't matter whether we apply to t->data or t->data2d, but t->data2d is more convenient */
        for (i = 0 ; i < t->total; i++, td++) {
-               /* it is assumed that td->ob is a pointer to the object,
+               /* it is assumed that td->extra is a pointer to the AnimData,
                 * whose active action is where this keyframe comes from 
+                * (this is only valid when not in NLA)
                 */
-               AnimData *adt= td->extra;
+               AnimData *adt= (t->spacetype != SPACE_NLA) ? td->extra : NULL;
                
                /* check if any need to apply nla-mapping */
                if (adt) {
@@ -4606,8 +4607,9 @@ static void applyTimeSlide(TransInfo *t, float sval)
        for (i = 0 ; i < t->total; i++, td++) {
                /* it is assumed that td->extra is a pointer to the AnimData,
                 * whose active action is where this keyframe comes from 
+                * (this is only valid when not in NLA)
                 */
-               AnimData *adt= td->extra;
+               AnimData *adt= (t->spacetype != SPACE_NLA) ? td->extra : NULL;
                float cval = t->values[0];
                
                /* apply NLA-mapping to necessary values */
@@ -4709,8 +4711,9 @@ static void applyTimeScale(TransInfo *t) {
        for (i = 0 ; i < t->total; i++, td++) {
                /* it is assumed that td->extra is a pointer to the AnimData,
                 * whose active action is where this keyframe comes from 
+                * (this is only valid when not in NLA)
                 */
-               AnimData *adt= td->extra;
+               AnimData *adt= (t->spacetype != SPACE_NLA) ? td->extra : NULL;
                float startx= CFRA;
                float fac= t->values[0];
                
@@ -4745,18 +4748,6 @@ int TimeScale(TransInfo *t, short mval[2])
        sval= t->imval[0];
        cval= mval[0];
        
-       // XXX ewww... we need a better factor!
-#if 0 // TRANSFORM_FIX_ME              
-       switch (t->spacetype) {
-               case SPACE_ACTION:
-                       width= ACTWIDTH;
-                       break;
-               case SPACE_NLA:
-                       width= NLAWIDTH;
-                       break;
-       }
-#endif
-       
        /* calculate scaling factor */
        startx= sval-(width/2+(t->ar->winx)/2);
        deltax= cval-(width/2+(t->ar->winx)/2);