diff options
Diffstat (limited to 'source/blender/blenloader/intern/readfile.c')
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 232 |
1 files changed, 217 insertions, 15 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 2711c072a8f..a870dcc2e94 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -89,6 +89,7 @@ #include "DNA_space_types.h" #include "DNA_vfont_types.h" #include "DNA_world_types.h" +#include "DNA_movieclip_types.h" #include "MEM_guardedalloc.h" @@ -130,6 +131,7 @@ #include "BKE_screen.h" #include "BKE_sequencer.h" #include "BKE_texture.h" // for open_plugin_tex +#include "BKE_tracking.h" #include "BKE_utildefines.h" // SWITCH_INT DATA ENDB DNA1 O_BINARY GLOB USER TEST REND #include "BKE_sound.h" @@ -1038,6 +1040,8 @@ void blo_freefiledata(FileData *fd) oldnewmap_free(fd->globmap); if (fd->imamap) oldnewmap_free(fd->imamap); + if (fd->movieclipmap) + oldnewmap_free(fd->movieclipmap); if (fd->libmap && !(fd->flags & FD_FLAGS_NOT_MY_LIBMAP)) oldnewmap_free(fd->libmap); if (fd->bheadmap) @@ -1113,6 +1117,13 @@ static void *newimaadr(FileData *fd, void *adr) /* used to restore image data a return NULL; } +static void *newmclipadr(FileData *fd, void *adr) /* used to restore movie clip data after undo */ +{ + if(fd->movieclipmap && adr) + return oldnewmap_lookup_and_inc(fd->movieclipmap, adr); + return NULL; +} + static void *newlibadr(FileData *fd, void *lib, void *adr) /* only lib data */ { @@ -1241,6 +1252,62 @@ void blo_end_image_pointer_map(FileData *fd, Main *oldmain) } } +void blo_make_movieclip_pointer_map(FileData *fd, Main *oldmain) +{ + MovieClip *clip= oldmain->movieclip.first; + Scene *sce= oldmain->scene.first; + + fd->movieclipmap= oldnewmap_new(); + + for(;clip; clip= clip->id.next) { + if(clip->cache) + oldnewmap_insert(fd->movieclipmap, clip->cache, clip->cache, 0); + + if(clip->tracking.camera.intrinsics) + oldnewmap_insert(fd->movieclipmap, clip->tracking.camera.intrinsics, clip->tracking.camera.intrinsics, 0); + } + + for(; sce; sce= sce->id.next) { + if(sce->nodetree) { + bNode *node; + for(node= sce->nodetree->nodes.first; node; node= node->next) + if(node->type==CMP_NODE_MOVIEDISTORTION) + oldnewmap_insert(fd->movieclipmap, node->storage, node->storage, 0); + } + } +} + +/* set old main movie clips caches to zero if it has been restored */ +/* this works because freeing old main only happens after this call */ +void blo_end_movieclip_pointer_map(FileData *fd, Main *oldmain) +{ + OldNew *entry= fd->movieclipmap->entries; + MovieClip *clip= oldmain->movieclip.first; + Scene *sce= oldmain->scene.first; + int i; + + /* used entries were restored, so we put them to zero */ + for (i=0; i<fd->movieclipmap->nentries; i++, entry++) { + if (entry->nr>0) + entry->newp= NULL; + } + + for(;clip; clip= clip->id.next) { + clip->cache= newmclipadr(fd, clip->cache); + clip->tracking.camera.intrinsics= newmclipadr(fd, clip->tracking.camera.intrinsics); + } + + for(; sce; sce= sce->id.next) { + if(sce->nodetree) { + bNode *node; + for(node= sce->nodetree->nodes.first; node; node= node->next) + if(node->type==CMP_NODE_MOVIEDISTORTION) + node->storage= newmclipadr(fd, node->storage); + } + } +} + + /* undo file support: add all library pointers in lookup */ void blo_add_library_pointer_map(ListBase *mainlist, FileData *fd) { @@ -2227,7 +2294,11 @@ static void direct_link_nodetree(FileData *fd, bNodeTree *ntree) link_list(fd, &node->inputs); link_list(fd, &node->outputs); - node->storage= newdataadr(fd, node->storage); + if(node->type == CMP_NODE_MOVIEDISTORTION) { + node->storage= newmclipadr(fd, node->storage); + } else + node->storage= newdataadr(fd, node->storage); + if(node->storage) { /* could be handlerized at some point */ if(ntree->type==NTREE_SHADER && (node->type==SH_NODE_CURVE_VEC || node->type==SH_NODE_CURVE_RGB)) @@ -3994,6 +4065,7 @@ static void direct_link_pose(FileData *fd, bPose *pose) direct_link_motionpath(fd, pchan->mpath); pchan->iktree.first= pchan->iktree.last= NULL; + pchan->siktree.first= pchan->siktree.last= NULL; /* incase this value changes in future, clamp else we get undefined behavior */ CLAMP(pchan->rotmode, ROT_MODE_MIN, ROT_MODE_MAX); @@ -4447,7 +4519,7 @@ static void direct_link_object(FileData *fd, Object *ob) * a hook we need to make sure it gets converted * and free'd, regardless of version. */ - VECCOPY(hmd->cent, hook->cent); + copy_v3_v3(hmd->cent, hook->cent); hmd->falloff = hook->falloff; hmd->force = hook->force; hmd->indexar = hook->indexar; @@ -4574,6 +4646,8 @@ static void lib_link_scene(FileData *fd, Main *main) marker->camera= newlibadr(fd, sce->id.lib, marker->camera); } } +#else + (void)marker; #endif if(sce->ed) @@ -4795,6 +4869,7 @@ static void direct_link_scene(FileData *fd, Scene *sce) if(sce->nodetree) direct_link_nodetree(fd, sce->nodetree); + sce->clip= newlibadr_us(fd, sce->id.lib, sce->clip); } /* ************ READ WM ***************** */ @@ -4949,6 +5024,7 @@ static void lib_link_screen(FileData *fd, Main *main) for(bgpic= v3d->bgpicbase.first; bgpic; bgpic= bgpic->next) { bgpic->ima= newlibadr_us(fd, sc->id.lib, bgpic->ima); + bgpic->clip= newlibadr_us(fd, sc->id.lib, bgpic->clip); } if(v3d->localvd) { v3d->localvd->camera= newlibadr(fd, sc->id.lib, v3d->localvd->camera); @@ -5071,6 +5147,14 @@ static void lib_link_screen(FileData *fd, Main *main) snode->linkdrag.first = snode->linkdrag.last = NULL; } + else if(sl->spacetype==SPACE_CLIP) { + SpaceClip *sclip= (SpaceClip *)sl; + + sclip->clip= newlibadr_us(fd, sc->id.lib, sclip->clip); + + sclip->scopes.track_preview = NULL; + sclip->scopes.ok = 0; + } } sa= sa->next; } @@ -5158,6 +5242,7 @@ void lib_link_screen_restore(Main *newmain, bScreen *curscreen, Scene *curscene) for(bgpic= v3d->bgpicbase.first; bgpic; bgpic= bgpic->next) { bgpic->ima= restore_pointer_by_name(newmain, (ID *)bgpic->ima, 1); + bgpic->clip= restore_pointer_by_name(newmain, (ID *)bgpic->clip, 1); } if(v3d->localvd) { /*Base *base;*/ @@ -5300,6 +5385,13 @@ void lib_link_screen_restore(Main *newmain, bScreen *curscreen, Scene *curscene) snode->nodetree= restore_pointer_by_name(newmain, &snode->nodetree->id, 1); } } + else if(sl->spacetype==SPACE_CLIP) { + SpaceClip *sclip= (SpaceClip *)sl; + + sclip->clip= restore_pointer_by_name(newmain, (ID *)sclip->clip, 1); + + sclip->scopes.ok = 0; + } } sa= sa->next; } @@ -5783,6 +5875,55 @@ static void lib_link_group(FileData *fd, Main *main) } } +/* ***************** READ MOVIECLIP *************** */ + +static void direct_link_movieclip(FileData *fd, MovieClip *clip) +{ + MovieTracking *tracking= &clip->tracking; + MovieTrackingTrack *track; + + if(fd->movieclipmap) clip->cache= newmclipadr(fd, clip->cache); + else clip->cache= NULL; + + if(fd->movieclipmap) clip->tracking.camera.intrinsics= newmclipadr(fd, clip->tracking.camera.intrinsics); + else clip->tracking.camera.intrinsics= NULL; + + tracking->reconstruction.cameras= newdataadr(fd, tracking->reconstruction.cameras); + + link_list(fd, &tracking->tracks); + + track= tracking->tracks.first; + while(track) { + track->markers= newdataadr(fd, track->markers); + + track= track->next; + } + + clip->tracking.act_track= newdataadr(fd, clip->tracking.act_track); + + clip->anim= NULL; + clip->tracking_context= NULL; + + clip->tracking.stabilization.ok= 0; + clip->tracking.stabilization.scaleibuf= NULL; + clip->tracking.stabilization.rot_track= newdataadr(fd, clip->tracking.stabilization.rot_track); +} + +static void lib_link_movieclip(FileData *fd, Main *main) +{ + MovieClip *clip; + + clip= main->movieclip.first; + while(clip) { + if(clip->id.flag & LIB_NEEDLINK) { + clip->gpd= newlibadr_us(fd, clip->id.lib, clip->gpd); + + clip->id.flag -= LIB_NEEDLINK; + } + clip= clip->id.next; + } +} + /* ************** GENERAL & MAIN ******************** */ @@ -5817,6 +5958,7 @@ static const char *dataname(short id_code) case ID_BR: return "Data from BR"; case ID_PA: return "Data from PA"; case ID_GD: return "Data from GD"; + case ID_MC: return "Data from MC"; } return "Data from Lib Block"; @@ -5986,6 +6128,9 @@ static BHead *read_libblock(FileData *fd, Main *main, BHead *bhead, int flag, ID case ID_GD: direct_link_gpencil(fd, (bGPdata *)id); break; + case ID_MC: + direct_link_movieclip(fd, (MovieClip *)id); + break; } /*link direct data of ID properties*/ @@ -7188,7 +7333,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main) while(ob) { if(ob->transflag & 1) { ob->transflag -= 1; - ob->ipoflag |= OB_OFFS_OB; + //ob->ipoflag |= OB_OFFS_OB; } ob= ob->id.next; } @@ -7219,7 +7364,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } ob= main->object.first; while(ob) { - ob->ipoflag |= OB_OFFS_PARENT; + //ob->ipoflag |= OB_OFFS_PARENT; if(ob->dt==0) ob->dt= OB_SOLID; ob= ob->id.next; } @@ -9640,7 +9785,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main) part->obfac = paf->obfac; part->randfac = paf->randfac * 25.0f; part->dampfac = paf->damp; - VECCOPY(part->acc, paf->force); + copy_v3_v3(part->acc, paf->force); /* flags */ if(paf->stype & PAF_VECT) { @@ -10691,7 +10836,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main) tot= MIN2(me->totvert, key->refkey->totelem); for(a=0; a<tot; a++, data+=3) - VECCOPY(me->mvert[a].co, data) + copy_v3_v3(me->mvert[a].co, data); } } @@ -10701,7 +10846,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main) tot= MIN2(lt->pntsu*lt->pntsv*lt->pntsw, key->refkey->totelem); for(a=0; a<tot; a++, data+=3) - VECCOPY(lt->def[a].vec, data) + copy_v3_v3(lt->def[a].vec, data); } } @@ -10714,9 +10859,9 @@ static void do_versions(FileData *fd, Library *lib, Main *main) BezTriple *bezt = nu->bezt; for(a=0; a<nu->pntsu; a++, bezt++) { - VECCOPY(bezt->vec[0], data); data+=3; - VECCOPY(bezt->vec[1], data); data+=3; - VECCOPY(bezt->vec[2], data); data+=3; + copy_v3_v3(bezt->vec[0], data); data+=3; + copy_v3_v3(bezt->vec[1], data); data+=3; + copy_v3_v3(bezt->vec[2], data); data+=3; bezt->alfa= *data; data++; } } @@ -10724,7 +10869,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main) BPoint *bp = nu->bp; for(a=0; a<nu->pntsu*nu->pntsv; a++, bp++) { - VECCOPY(bp->vec, data); data+=3; + copy_v3_v3(bp->vec, data); data+=3; bp->alfa= *data; data++; } } @@ -12154,7 +12299,6 @@ static void do_versions(FileData *fd, Library *lib, Main *main) ma= ma->id.next; } } - } if (main->versionfile < 260){ @@ -12190,7 +12334,6 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } } } - } if (main->versionfile < 260 || (main->versionfile == 260 && main->subversionfile < 1)){ @@ -12214,7 +12357,65 @@ static void do_versions(FileData *fd, Library *lib, Main *main) /* put compatibility code here until next subversion bump */ { - + { + bScreen *sc; + MovieClip *clip; + + for (sc= main->screen.first; sc; sc= sc->id.next) { + ScrArea *sa; + for (sa= sc->areabase.first; sa; sa= sa->next) { + SpaceLink *sl; + for (sl= sa->spacedata.first; sl; sl= sl->next) { + if(sl->spacetype==SPACE_VIEW3D) { + View3D *v3d= (View3D *)sl; + if(v3d->bundle_size==0.0f) { + v3d->bundle_size= 0.2f; + v3d->flag2 |= V3D_SHOW_RECONSTRUCTION; + } + else if(sl->spacetype==SPACE_CLIP) { + SpaceClip *sc= (SpaceClip *)sl; + if(sc->scopes.track_preview_height==0) + sc->scopes.track_preview_height= 120; + } + + if(v3d->bundle_drawtype==0) + v3d->bundle_drawtype= OB_PLAINAXES; + } + } + } + } + + for (clip= main->movieclip.first; clip; clip= clip->id.next) { + MovieTrackingTrack *track; + + if(clip->aspx<1.0f) { + clip->aspx= 1.0f; + clip->aspy= 1.0f; + } + + /* XXX: a bit hacky, probably include imbuf and use real constants are nicer */ + clip->proxy.build_tc_flag= 7; + if(clip->proxy.build_size_flag==0) + clip->proxy.build_size_flag= 1; + + if(clip->proxy.quality==0) + clip->proxy.quality= 90; + + if(clip->tracking.camera.pixel_aspect<0.01f) + clip->tracking.camera.pixel_aspect= 1.f; + + track= clip->tracking.tracks.first; + while(track) { + if(track->pyramid_levels==0) + track->pyramid_levels= 2; + + if(track->minimum_correlation==0.0f) + track->minimum_correlation= 0.75f; + + track= track->next; + } + } + } } /* WATCH IT!!!: pointers from libdata have not been converted yet here! */ @@ -12261,6 +12462,7 @@ static void lib_link_all(FileData *fd, Main *main) lib_link_nodetree(fd, main); /* has to be done after scene/materials, this will verify group nodes */ lib_link_brush(fd, main); lib_link_particlesettings(fd, main); + lib_link_movieclip(fd, main); lib_link_mesh(fd, main); /* as last: tpage images with users at zero */ @@ -13409,7 +13611,7 @@ static void give_base_to_groups(Main *mainvar, Scene *scene) ob->dup_group= group; ob->transflag |= OB_DUPLIGROUP; rename_id(&ob->id, group->id.name+2); - VECCOPY(ob->loc, scene->cursor); + copy_v3_v3(ob->loc, scene->cursor); } } } |