From 51ce503cb24de6fa928555359acce77beed8995e Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Thu, 30 Nov 2006 21:40:11 +0000 Subject: [PATCH] Armature Proxy bugfix: when adding constraints or bones, the proxy sync didn't keep in mind the pose channels could change order... Note the disabled code in readfile.c; will be finished later. It's for debugging library dependencies. --- source/blender/blenkernel/intern/armature.c | 4 +- source/blender/blenloader/intern/readfile.c | 116 +++++++++++++++++++- 2 files changed, 112 insertions(+), 8 deletions(-) diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 9268f593970..5c979e199e5 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -984,9 +984,9 @@ static void pose_proxy_synchronize(Object *ob, Object *from, int layer_protected rest_pose(frompose); pchan= pose->chanbase.first; - pchanp= frompose->chanbase.first; - for(; pchan && pchanp; pchan= pchan->next, pchanp= pchanp->next) { + for(; pchan; pchan= pchan->next) { if(pchan->bone->layer & layer_protected) { + pchanp= get_pose_channel(frompose, pchan->name); /* copy posechannel to temp, but restore important pointers */ pchanw= *pchanp; diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index fda5f20d9ef..35613713855 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -1722,8 +1722,9 @@ static void lib_link_pose(FileData *fd, Object *ob, bPose *pose) if (!pose || !arm) return; - /* always rebuild to match lib changes */ - rebuild= (ob->id.lib==NULL && arm->id.lib); + + /* always rebuild to match proxy or lib changes */ + rebuild= ob->proxy || (ob->id.lib==NULL && arm->id.lib); for (pchan = pose->chanbase.first; pchan; pchan=pchan->next) { lib_link_constraints(fd, (ID *)ob, &pchan->constraints); @@ -3730,6 +3731,99 @@ static void direct_link_screen(FileData *fd, bScreen *sc) } } +/* ********** READ LIBRARY: facility to build a tree to see dependencies *************** */ + +typedef struct LibLink { + struct LibLink *prev, *next; + Main *lib; + ListBase tree; +} LibLink; + +static int library_add_dependency(LibLink *llink, Main *from, Main *to) +{ + LibLink *lc; + + if(llink->lib==from) { + for(lc= llink->tree.first; lc; lc= lc->next) + if(lc->lib==to) + break; + if(lc) + return; + + lc= MEM_callocN(sizeof(LibLink), "lib link"); + BLI_addtail(&llink->tree, lc); + lc->lib= to; + + if(from && from->curlib) printf("Added from %s to %s \n", from->curlib->name, to->curlib->name); + else printf("Added to %s\n", to->curlib->name); + + return 1; + } + else { + for(lc= llink->tree.first; lc; lc= lc->next) + if(library_add_dependency(lc, from, to)) + return 1; + } + if(from) printf("not added from %s to %s \n", from->curlib->name, to->curlib->name); + else printf("not added to %s\n", to->curlib->name); + return 0; +} + +static void library_print_dependency(LibLink *llink, int level) +{ + LibLink *lc; + + for(lc= llink->tree.first; lc; lc= lc->next) { + int a; + for(a=0; alib->curlib->name); + library_print_dependency(lc, level+1); + } +} + +static void library_free_dependency(LibLink *llink, int level) +{ + LibLink *lc, *next; + + for(lc= llink->tree.first; lc; lc= next) { + next= lc->next; + library_free_dependency(lc, 1); + } + if(level) + MEM_freeN(llink); +} + + +static void library_do_dependency(char mode, Main *from, Main *to) +{ + static int doit= 0; + static LibLink llink; + + return; // temporary disabled + + if(mode=='s') { /* start */ + memset(&llink, 0, sizeof(LibLink)); + llink.lib= from; + doit= 1; + return; + } + + if(doit==0) return; + + if(mode=='e') { /* end */ + library_print_dependency(&llink, 1); + library_free_dependency(&llink, 0); + doit= 0; + return; + } + if(mode=='a') { + library_add_dependency(&llink, from, to); + } +} + + + /* ********** READ LIBRARY *************** */ @@ -3764,6 +3858,8 @@ static void direct_link_library(FileData *fd, Library *lib, Main *main) newmain= MEM_callocN(sizeof(Main), "directlink"); BLI_addtail(&fd->mainlist, newmain); newmain->curlib= lib; + + library_do_dependency('a', main, newmain); } static void lib_link_library(FileData *fd, Main *main) @@ -6227,6 +6323,9 @@ BlendFileData *blo_read_file_internal(FileData *fd, BlendReadError *error_r) bfd->main->versionfile= fd->fileversion; + /* facility to print depsgraph */ + library_do_dependency('s', bfd->main, NULL); + while(bhead) { switch(bhead->code) { case GLOB: @@ -6275,9 +6374,11 @@ BlendFileData *blo_read_file_internal(FileData *fd, BlendReadError *error_r) link_global(fd, bfd, fg); /* as last */ /* removed here: check for existance of curscreen/scene, moved to kernel setup_app */ - MEM_freeN(fg); + /* facility to print depsgraph */ + library_do_dependency('e', NULL, NULL); + return bfd; } @@ -6339,13 +6440,16 @@ static void expand_doit(FileData *fd, Main *mainvar, void *old) // BHEAD+DATA dependancy Library *lib= (Library *)(bheadlib+1); /* we read the lib->name directly from the bhead, potential danger (64 bits?) */ - mainvar= blo_find_main(&fd->mainlist, lib->name, fd->filename); + Main *main= blo_find_main(&fd->mainlist, lib->name, fd->filename); - id= is_yet_read(mainvar, bhead); + id= is_yet_read(main, bhead); if(id==0) { - read_libblock(fd, mainvar, bhead, LIB_READ+LIB_INDIRECT, NULL); + read_libblock(fd, main, bhead, LIB_READ+LIB_INDIRECT, NULL); if(G.f & G_DEBUG) printf("expand_doit: other lib %s\n", lib->name); + + /* for outliner dependency only */ + library_do_dependency('a', mainvar, main); } else { //oldnewmap_insert(fd->libmap, bhead->old, id, 1);