From 4467c2633737de12b45cae1ff64bab80486b9447 Mon Sep 17 00:00:00 2001 From: Peter Schlaile Date: Mon, 5 Jun 2006 19:04:19 +0000 Subject: == Sequencer & IPOs == This code enables IPO-pinning for Sequence-strips again, by working around the missing libdata in blenloader/intern/readfile.c. Bad hack(tm). Maybe we find a way, to make Sequence-strips true libdata? It also fixes two places in IPO-editing where frame-locking wasn't handled. --- source/blender/blenloader/intern/readfile.c | 64 ++++++++++++++++++++++++++++- source/blender/src/editipo.c | 6 ++- source/blender/src/header_ipo.c | 4 +- 3 files changed, 69 insertions(+), 5 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index eb9410ce8de..6c6d9cdd033 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -2803,7 +2803,7 @@ static void direct_link_scene(FileData *fd, Scene *sce) } } END_SEQ - + /* link metastack, slight abuse of structs here, have to restore pointer to internal part in struct */ { Sequence temp; @@ -2857,6 +2857,67 @@ static void direct_link_scene(FileData *fd, Scene *sce) } +/* Nasty exception; IpoWindow stores a non-ID pointer in *from for sequence + strips... bad code warning! + + We work around it by retrieving the missing pointer from the corresponding + Sequence-structure. + + This is needed, to make Ipo-Pinning work for Sequence-Ipos... +*/ +static Sequence * find_sequence_from_ipo_helper(Main * main, Ipo * ipo) +{ + Editing *ed; + Sequence *seq; + + Scene * sce= main->scene.first; + while(sce) { + if(sce->ed) { + int found = 0; + + ed= sce->ed; + + WHILE_SEQ(&ed->seqbase) { + if (seq->ipo == ipo) { + found = 1; + break; + } + } + END_SEQ + if (found) { + break; + } + seq = NULL; + } + sce= sce->id.next; + } + return seq; +} + +static void lib_link_screen_sequence_ipos(Main *main) +{ + bScreen *sc; + ScrArea *sa; + + sc= main->screen.first; + while(sc) { + sa= sc->areabase.first; + while(sa) { + SpaceLink *sl; + for (sl= sa->spacedata.first; sl; sl= sl->next) { + if(sl->spacetype == SPACE_IPO) { + SpaceIpo *sipo= (SpaceIpo *)sl; + if(sipo->blocktype==ID_SEQ) { + sipo->from = (ID*) find_sequence_from_ipo_helper(main, sipo->ipo); + } + } + } + sa= sa->next; + } + sc= sc->id.next; + } +} + /* ************ READ SCREEN ***************** */ /* note: file read without screens option G_FILE_NO_UI; @@ -5444,6 +5505,7 @@ static void lib_link_all(FileData *fd, Main *main) lib_link_armature(fd, main); lib_link_action(fd, main); lib_link_vfont(fd, main); + lib_link_screen_sequence_ipos(main); lib_link_nodetree(fd, main); /* has to be done after scene/materials, this will verify group nodes */ lib_link_mesh(fd, main); /* as last: tpage images with users at zero */ diff --git a/source/blender/src/editipo.c b/source/blender/src/editipo.c index 74cd4cb8f1a..b3b43c0a348 100644 --- a/source/blender/src/editipo.c +++ b/source/blender/src/editipo.c @@ -2127,7 +2127,7 @@ void insertkey_editipo(void) else if(id && GS(id->name)==ID_SEQ) { Sequence *last_seq = get_last_seq(); /* editsequence.c */ - if(last_seq) { + if(last_seq && (last_seq->flag & SEQ_IPO_FRAME_LOCKED) == 0) { cfra= (float)(100.0*(cfra-last_seq->startdisp)/((float)(last_seq->enddisp-last_seq->startdisp))); } } @@ -3039,11 +3039,13 @@ void ipo_snap(short event) Sequence *seq; seq= (Sequence *)G.sipo->from; - if(seq) { + if(seq && (seq->flag & SEQ_IPO_FRAME_LOCKED) == 0) { dx= (float)(CFRA-seq->startdisp); dx= (float)(100.0*dx/((float)(seq->enddisp-seq->startdisp))); dx-= bezt->vec[1][0]; + } else { + dx= G.scene->r.framelen*CFRA - bezt->vec[1][0]; } } else dx= G.scene->r.framelen*CFRA - bezt->vec[1][0]; diff --git a/source/blender/src/header_ipo.c b/source/blender/src/header_ipo.c index 2c8f705b227..6effa4bdae3 100644 --- a/source/blender/src/header_ipo.c +++ b/source/blender/src/header_ipo.c @@ -1174,8 +1174,8 @@ void ipo_buttons(void) uiClearButLock(); - if(G.sipo->blocktype==ID_SEQ) - allow_pin= 0; + /* if(G.sipo->blocktype==ID_SEQ) + allow_pin= 0; */ xco= std_libbuttons(block, (short)(xco+1.5*XIC), 0, allow_pin, &G.sipo->pin, B_IPOBROWSE, ID_IP, G.sipo->blocktype, (ID*)G.sipo->ipo, G.sipo->from, &(G.sipo->menunr), B_IPOALONE, B_IPOLOCAL, B_IPODELETE, 0, B_KEEPDATA); -- cgit v1.2.3