NLA SoC: Fixed bug with NLA-Transform
authorJoshua Leung <aligorith@gmail.com>
Tue, 7 Jul 2009 10:25:55 +0000 (10:25 +0000)
committerJoshua Leung <aligorith@gmail.com>
Tue, 7 Jul 2009 10:25:55 +0000 (10:25 +0000)
Strip-sorting code was buggy, as it was trying to access an invalid pointer, so the call to sort strips after transform was temporarily disabled in previous commits.

source/blender/blenkernel/intern/nla.c
source/blender/editors/transform/transform_conversions.c

index 851a0d7b5498c67c8d71584cc4f7b6346e11d0cd..4dce9aebe24b217c8426079bdbf4010baabf6de7 100644 (file)
@@ -546,26 +546,28 @@ short BKE_nlastrips_has_space (ListBase *strips, float start, float end)
 void BKE_nlastrips_sort_strips (ListBase *strips)
 {
        ListBase tmp = {NULL, NULL};
-       NlaStrip *strip, *sstrip;
+       NlaStrip *strip, *sstrip, *stripn;
        
        /* sanity checks */
        if ELEM(NULL, strips, strips->first)
                return;
-               
+       
        /* we simply perform insertion sort on this list, since it is assumed that per track,
         * there are only likely to be at most 5-10 strips
         */
-       for (strip= strips->first; strip; strip= strip->next) {
+       for (strip= strips->first; strip; strip= stripn) {
                short not_added = 1;
                
+               stripn= strip->next;
+               
                /* remove this strip from the list, and add it to the new list, searching from the end of 
                 * the list, assuming that the lists are in order 
                 */
                BLI_remlink(strips, strip);
                
-               for (sstrip= tmp.last; not_added && sstrip; sstrip= sstrip->prev) {
+               for (sstrip= tmp.last; sstrip; sstrip= sstrip->prev) {
                        /* check if add after */
-                       if (sstrip->end < strip->start) {
+                       if (sstrip->end <= strip->start) {
                                BLI_insertlinkafter(&tmp, sstrip, strip);
                                not_added= 0;
                                break;
index 53c8e08ee74252122f55769f6b6f62295a102579..0d19eeb913ee25e534b5dd9602183a937e88ab6a 100644 (file)
@@ -4836,8 +4836,7 @@ void special_aftertrans_update(TransInfo *t)
                                NlaTrack *nlt= (NlaTrack *)ale->data;
                                
                                /* make sure strips are in order again */
-                               // FIXME: this is buggy
-                               //BKE_nlatrack_sort_strips(nlt);
+                               BKE_nlatrack_sort_strips(nlt);
                                
                                /* remove the temp metas */
                                BKE_nlastrips_clear_metas(&nlt->strips, 0, 1);