Merging with trunk up to r38631.
[blender.git] / source / blender / editors / transform / transform_conversions.c
index 0a5e290..b0488ef 100644 (file)
@@ -2486,6 +2486,7 @@ static short FrameOnMouseSide(char side, float frame, float cframe)
 static void createTransNlaData(bContext *C, TransInfo *t)
 {
        Scene *scene= t->scene;
+       SpaceNla *snla = NULL;
        TransData *td = NULL;
        TransDataNla *tdn = NULL;
        
@@ -2499,9 +2500,10 @@ static void createTransNlaData(bContext *C, TransInfo *t)
        /* determine what type of data we are operating on */
        if (ANIM_animdata_get_context(C, &ac) == 0)
                return;
+       snla = (SpaceNla *)ac.sl;
        
        /* filter data */
-       filter= (ANIMFILTER_VISIBLE | ANIMFILTER_NLATRACKS | ANIMFILTER_FOREDIT);
+       filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT);
        ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
        
        /* which side of the current frame should be allowed */
@@ -2584,7 +2586,7 @@ static void createTransNlaData(bContext *C, TransInfo *t)
                                                tdn->strip= strip;
                                                tdn->trackIndex= BLI_findindex(&adt->nla_tracks, nlt);
                                                
-                                               yval= (float)(tdn->trackIndex * NLACHANNEL_STEP);
+                                               yval= (float)(tdn->trackIndex * NLACHANNEL_STEP(snla));
                                                
                                                tdn->h1[0]= strip->start;
                                                tdn->h1[1]= yval;
@@ -2688,7 +2690,7 @@ static void createTransNlaData(bContext *C, TransInfo *t)
 static void posttrans_gpd_clean (bGPdata *gpd)
 {
        bGPDlayer *gpl;
-
+       
        for (gpl= gpd->layers.first; gpl; gpl= gpl->next) {
                ListBase sel_buffer = {NULL, NULL};
                bGPDframe *gpf, *gpfn;
@@ -2841,7 +2843,7 @@ static void posttrans_action_clean (bAnimContext *ac, bAction *act)
        int filter;
 
        /* filter data */
-       filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVESONLY);
+       filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/);
        ANIM_animdata_filter(ac, &anim_data, filter, act, ANIMCONT_ACTION);
 
        /* loop through relevant data, removing keyframes as appropriate
@@ -2849,7 +2851,7 @@ static void posttrans_action_clean (bAnimContext *ac, bAction *act)
         */
        for (ale= anim_data.first; ale; ale= ale->next) {
                AnimData *adt= ANIM_nla_mapping_get(ac, ale);
-
+               
                if (adt) {
                        ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1);
                        posttrans_fcurve_clean(ale->key_data);
@@ -3043,9 +3045,9 @@ static void createTransActionData(bContext *C, TransInfo *t)
        
        /* filter data */
        if (ac.datatype == ANIMCONT_GPENCIL)
-               filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT);
+               filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT);
        else
-               filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVESONLY);
+               filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/);
        ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
        
        /* which side of the current frame should be allowed */
@@ -3138,12 +3140,18 @@ static void createTransActionData(bContext *C, TransInfo *t)
                float min=999999999.0f, max=-999999999.0f;
                int i;
                
-               td= (t->data + 1);
-               for (i=1; i < count; i+=3, td+=3) {
+               td= t->data;
+               for (i=0; i < count; i++, td++) {
                        if (min > *(td->val)) min= *(td->val);
                        if (max < *(td->val)) max= *(td->val);
                }
                
+               if (min == max) {
+                       /* just use the current frame ranges */
+                       min = (float)PSFRA;
+                       max = (float)PEFRA;
+               }
+               
                /* minx/maxx values used by TimeSlide are stored as a
                 * calloced 2-float array in t->customData. This gets freed
                 * in postTrans (T_FREE_CUSTOMDATA).
@@ -3264,7 +3272,7 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
                return;
        
        /* filter data */
-       filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVESONLY | ANIMFILTER_CURVEVISIBLE);
+       filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVE_VISIBLE);
        ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
        
        /* which side of the current frame should be allowed */
@@ -4783,7 +4791,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
                if (ELEM(ac.datatype, ANIMCONT_DOPESHEET, ANIMCONT_SHAPEKEY)) {
                        ListBase anim_data = {NULL, NULL};
                        bAnimListElem *ale;
-                       short filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVESONLY);
+                       short filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/);
                        
                        /* get channels to work on */
                        ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
@@ -4850,7 +4858,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
                                // XXX: BAD! this get gpencil datablocks directly from main db...
                                // but that's how this currently works :/
                                for (gpd = G.main->gpencil.first; gpd; gpd = gpd->id.next) {
-                                       if (ID_REAL_USERS(gpd) > 1)
+                                       if (ID_REAL_USERS(gpd))
                                                posttrans_gpd_clean(gpd);
                                }
                        }
@@ -4878,7 +4886,8 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
                }
                
                /* make sure all F-Curves are set correctly */
-               ANIM_editkeyframes_refresh(&ac);
+               if (ac.datatype != ANIMCONT_GPENCIL)
+                       ANIM_editkeyframes_refresh(&ac);
                
                /* clear flag that was set for time-slide drawing */
                saction->flag &= ~SACTION_MOVING;
@@ -4895,7 +4904,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
                {
                        ListBase anim_data = {NULL, NULL};
                        bAnimListElem *ale;
-                       short filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVESONLY | ANIMFILTER_CURVEVISIBLE);
+                       short filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVE_VISIBLE);
                        
                        /* get channels to work on */
                        ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
@@ -4945,7 +4954,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
                {
                        ListBase anim_data = {NULL, NULL};
                        bAnimListElem *ale;
-                       short filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NLATRACKS);
+                       short filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT);
                        
                        /* get channels to work on */
                        ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);