after transform if strips overlap, move the frame rather then the channel to fix.
authorCampbell Barton <ideasman42@gmail.com>
Thu, 22 Oct 2009 14:40:32 +0000 (14:40 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 22 Oct 2009 14:40:32 +0000 (14:40 +0000)
useful while snap isnt working. metastrips still need to be supported.

source/blender/blenkernel/BKE_sequence.h
source/blender/blenkernel/intern/sequence.c
source/blender/editors/transform/transform_conversions.c

index 55c9d978f26abcc6d6a21e9f80f303093776e743..fb3c282b0900b6646f0a94b95c46162944632643 100644 (file)
@@ -182,6 +182,7 @@ int check_single_seq(struct Sequence *seq);
 void fix_single_seq(struct Sequence *seq);
 int seq_test_overlap(struct ListBase * seqbasep, struct Sequence *test);
 int shuffle_seq(struct ListBase * seqbasep, struct Sequence *test);
+int shuffle_seq_time(ListBase * seqbasep);
 void free_imbuf_seq(struct ListBase * seqbasep, int check_mem_usage);
 
 void seq_update_sound(struct Sequence *seq);
index 20433e4a3b15a7847bd5837e04b2758e4fefba4d..48eb58687dac5bea9c27dd2af8f9b87bb8f70f51 100644 (file)
@@ -3341,18 +3341,25 @@ int seq_tx_test(Sequence * seq)
        return (seq->type < SEQ_EFFECT) || (get_sequence_effect_num_inputs(seq->type) == 0);
 }
 
+static int seq_overlap(Sequence *seq1, Sequence *seq2)
+{
+       if(seq1 != seq2)
+               if(seq1->machine==seq2->machine)
+                       if(((seq1->enddisp <= seq2->startdisp) || (seq1->startdisp >= seq2->enddisp))==0)
+                               return 1;
+
+       return 0;
+}
+
 int seq_test_overlap(ListBase * seqbasep, Sequence *test)
 {
        Sequence *seq;
 
        seq= seqbasep->first;
        while(seq) {
-               if(seq!=test) {
-                       if(test->machine==seq->machine) {
-                               if( (test->enddisp <= seq->startdisp) || (test->startdisp >= seq->enddisp) );
-                               else return 1;
-                       }
-               }
+               if(seq_overlap(test, seq))
+                       return 1;
+
                seq= seq->next;
        }
        return 0;
@@ -3410,6 +3417,76 @@ int shuffle_seq(ListBase * seqbasep, Sequence *test)
        }
 }
 
+static int shuffle_seq_time_offset_test(ListBase * seqbasep, char dir)
+{
+       int offset= 0;
+       Sequence *seq, *seq_other;
+
+       for(seq= seqbasep->first; seq; seq= seq->next) {
+               if(seq->tmp) {
+                       for(seq_other= seqbasep->first; seq_other; seq_other= seq_other->next) {
+                               if(seq_overlap(seq, seq_other)) {
+                                       if(dir=='L') {
+                                               offset= MIN2(offset, seq_other->startdisp - seq->enddisp);
+                                       }
+                                       else {
+                                               offset= MAX2(offset, seq_other->enddisp - seq->startdisp);
+                                       }
+                               }
+                       }
+               }
+       }
+       return offset;
+}
+
+static int shuffle_seq_time_offset(ListBase * seqbasep, char dir)
+{
+       int ofs= 0;
+       int tot_ofs= 0;
+       Sequence *seq;
+       while( (ofs= shuffle_seq_time_offset_test(seqbasep, dir)) ) {
+               for(seq= seqbasep->first; seq; seq= seq->next) {
+                       if(seq->tmp) {
+                               /* seq_test_overlap only tests display values */
+                               seq->startdisp +=       ofs;
+                               seq->enddisp +=         ofs;
+                       }
+               }
+
+               tot_ofs+= ofs;
+       }
+
+       for(seq= seqbasep->first; seq; seq= seq->next) {
+               if(seq->tmp)
+                       calc_sequence_disp(seq); /* corrects dummy startdisp/enddisp values */
+       }
+
+       return tot_ofs;
+}
+
+int shuffle_seq_time(ListBase * seqbasep)
+{
+       /* note: seq->tmp is used to tag strips to move */
+
+       Sequence *seq;
+
+       int offset_l = shuffle_seq_time_offset(seqbasep, 'L');
+       int offset_r = shuffle_seq_time_offset(seqbasep, 'R');
+       int offset = (-offset_l < offset_r) ?  offset_l:offset_r;
+
+       if(offset) {
+               for(seq= seqbasep->first; seq; seq= seq->next) {
+                       if(seq->tmp) {
+                               seq_translate(seq, offset);
+                               seq->flag &= ~SEQ_OVERLAP;
+                       }
+               }
+       }
+
+       return offset? 0:1;
+}
+
+
 void seq_update_sound(struct Sequence *seq)
 {
        if(seq->type == SEQ_SOUND)
index 71ce97b2d48f5531888dc7067eeed1fa99c877b2..cdfdcaffb0d429b5860a21a452f2f42c8babb2e6 100644 (file)
@@ -4039,7 +4039,6 @@ static int SeqToTransData_Recursive(TransInfo *t, ListBase *seqbase, TransData *
        return tot;
 }
 
-
 static void freeSeqData(TransInfo *t)
 {
        Editing *ed= seq_give_editing(t->scene, FALSE);
@@ -4058,16 +4057,50 @@ static void freeSeqData(TransInfo *t)
 
                if (!(t->state == TRANS_CANCEL)) {
 
+#if 0          // default 2.4 behavior
+
                        /* flush to 2d vector from internally used 3d vector */
                        for(a=0; a<t->total; a++, td++) {
-                               seq= ((TransDataSeq *)td->extra)->seq;
                                if ((seq != seq_prev) && (seq->depth==0) && (seq->flag & SEQ_OVERLAP)) {
+                               seq= ((TransDataSeq *)td->extra)->seq;
                                        shuffle_seq(seqbasep, seq);
                                }
 
                                seq_prev= seq;
                        }
 
+#else          // durian hack
+                       {
+                               int overlap= 0;
+
+                               for(a=0; a<t->total; a++, td++) {
+                                       seq_prev= NULL;
+                                       seq= ((TransDataSeq *)td->extra)->seq;
+                                       if ((seq != seq_prev) && (seq->depth==0) && (seq->flag & SEQ_OVERLAP)) {
+                                               overlap= 1;
+                                               break;
+                                       }
+                                       seq_prev= seq;
+                               }
+
+                               if(overlap) {
+                                       for(seq= seqbasep->first; seq; seq= seq->next)
+                                               seq->tmp= NULL;
+
+                                       td= t->data;
+                                       seq_prev= NULL;
+                                       for(a=0; a<t->total; a++, td++) {
+                                               seq= ((TransDataSeq *)td->extra)->seq;
+                                               if ((seq != seq_prev)) {
+                                                       seq->tmp= 1;
+                                               }
+                                       }
+
+                                       shuffle_seq_time(seqbasep);
+                               }
+                       }
+#endif
+
                        for(seq= seqbasep->first; seq; seq= seq->next) {
                                /* We might want to build a list of effects that need to be updated during transform */
                                if(seq->type & SEQ_EFFECT) {