Merging r39029 through r39049 from trunk into soc-2011-tomato
authorSergey Sharybin <sergey.vfx@gmail.com>
Fri, 5 Aug 2011 06:47:37 +0000 (06:47 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Fri, 5 Aug 2011 06:47:37 +0000 (06:47 +0000)
1  2 
source/blender/blenloader/intern/readfile.c
source/blender/windowmanager/intern/wm_operators.c

index c36657c7ffd63865b42477c6f73f2686d54e2b03,44c8ca97be9d4d99373df0217024882d90225521..4a1441cf1d57fd90794f64ae9bdaeb09e3f33be7
@@@ -89,7 -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"
  
@@@ -1034,8 -1033,6 +1034,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)
@@@ -1111,13 -1108,6 +1111,13 @@@ static void *newimaadr(FileData *fd, vo
        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 */
  {
@@@ -1246,38 -1236,6 +1246,38 @@@ void blo_end_image_pointer_map(FileDat
        }
  }
  
 +void blo_make_movieclip_pointer_map(FileData *fd, Main *oldmain)
 +{
 +      MovieClip *clip= oldmain->movieclip.first;
 +
 +      fd->movieclipmap= oldnewmap_new();
 +
 +      for(;clip; clip= clip->id.next) {
 +              if(clip->cache)
 +                      oldnewmap_insert(fd->movieclipmap, clip->cache, clip->cache, 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;
 +      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);
 +      }
 +}
 +
 +
  /* undo file support: add all library pointers in lookup */
  void blo_add_library_pointer_map(ListBase *mainlist, FileData *fd)
  {
@@@ -4732,7 -4690,6 +4732,7 @@@ static void direct_link_scene(FileData 
        if(sce->nodetree)
                direct_link_nodetree(fd, sce->nodetree);
        
 +      sce->clip= newlibadr_us(fd, sce->id.lib, sce->clip);
  }
  
  /* ************ READ WM ***************** */
@@@ -4885,7 -4842,6 +4885,7 @@@ static void lib_link_screen(FileData *f
  
                                                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);
                                                
                                                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;
                        }
@@@ -5105,7 -5053,6 +5105,7 @@@ void lib_link_screen_restore(Main *newm
                                        
                                        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;*/
                                                        snode->nodetree= ((Tex *)snode->id)->nodetree;
                                        }
                                }
 +                              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;
                }
@@@ -5696,51 -5636,6 +5696,51 @@@ static void lib_link_group(FileData *fd
        }
  }
  
 +/* ***************** 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;
 +
 +      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->last_sel= newdataadr(fd, clip->last_sel);
 +      if(clip->last_sel==NULL)
 +              clip->sel_type= MCLIP_SEL_NONE;
 +
 +      clip->anim= NULL;
 +      clip->tracking_context= NULL;
 +
 +      clip->tracking.stabilization.ok= 0;
 +      clip->tracking.stabilization.scaleibuf= NULL;
 +}
 +
 +static void lib_link_movieclip(FileData *UNUSED(fd), Main *main)
 +{
 +      MovieClip *clip;
 +
 +      clip= main->movieclip.first;
 +      while(clip) {
 +              if(clip->id.flag & LIB_NEEDLINK) {
 +                      clip->id.flag -= LIB_NEEDLINK;
 +              }
 +              clip= clip->id.next;
 +      }
 +}
 +
  /* ************** GENERAL & MAIN ******************** */
  
  
@@@ -5774,7 -5669,6 +5774,7 @@@ static const char *dataname(short id_co
                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";
        
@@@ -5941,9 -5835,6 +5941,9 @@@ static BHead *read_libblock(FileData *f
                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*/
@@@ -11819,50 -11710,9 +11819,50 @@@ static void do_versions(FileData *fd, L
        /* put compatibility code here until next subversion bump */
  
        {
 -      
 +              bScreen *sc;
 +              Camera *cam;
 +              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.1f;
 +                                                      v3d->flag2 |= V3D_SHOW_RECONSTRUCTION;
 +                                              }
 +
 +                                              if(v3d->bundle_drawtype==0)
 +                                                      v3d->bundle_drawtype= OB_EMPTY_SPHERE;
 +                                      }
 +                                      else if(sl->spacetype==SPACE_CLIP) {
 +                                              SpaceClip *sclip= (SpaceClip *)sl;
 +                                              if(sclip->scopes.track_preview_height==0)
 +                                                      sclip->scopes.track_preview_height= 120;
 +                                      }
 +                              }
 +                      }
 +              }
 +
 +              for (clip= main->movieclip.first; clip; clip= clip->id.next) {
 +                      if(clip->aspx<1.0f) {
 +                              clip->aspx= 1.0f;
 +                              clip->aspy= 1.0f;
 +                      }
 +              }
 +
 +              for(cam= main->camera.first; cam; cam= cam->id.next) {
 +                      if (cam->sensor_x < 0.01f) {
 +                              cam->sensor_x = 32.f;
 +                              cam->sensor_y = 18.f;
 +                      }
 +              }
        }
 -      
 +
        /* WATCH IT!!!: pointers from libdata have not been converted yet here! */
        /* WATCH IT 2!: Userdef struct init has to be in editors/interface/resources.c! */
  
@@@ -11906,7 -11756,6 +11906,7 @@@ static void lib_link_all(FileData *fd, 
        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 */
  
@@@ -13126,9 -12975,8 +13126,8 @@@ static void append_id_part(FileData *fd
  
  /* common routine to append/link something from a library */
  
- static Main* library_append_begin(const bContext *C, FileData **fd, const char *filepath)
+ static Main* library_append_begin(Main *mainvar, FileData **fd, const char *filepath)
  {
-       Main *mainvar= CTX_data_main(C);
        Main *mainl;
  
        /* make mains */
        return mainl;
  }
  
- Main* BLO_library_append_begin(const bContext *C, BlendHandle** bh, const char *filepath)
+ Main* BLO_library_append_begin(Main *mainvar, BlendHandle** bh, const char *filepath)
  {
        FileData *fd= (FileData*)(*bh);
-       return library_append_begin(C, &fd, filepath);
+       return library_append_begin(mainvar, &fd, filepath);
  }
  
  
index 2c337e7c7f7b9e6c8c02965c64d01cc7fd7288aa,7238cede2ccdbcb22e346649aa0c75f61ade9605..d3138f33ad74c94422635ea77ee6a4f5b489cadb
@@@ -1621,7 -1621,6 +1621,6 @@@ static int wm_link_append_exec(bContex
        int idcode, totfiles=0;
        short flag;
  
-       name[0] = '\0';
        RNA_string_get(op->ptr, "filename", name);
        RNA_string_get(op->ptr, "directory", dir);
  
        flag_all_listbases_ids(LIB_PRE_EXISTING, 1);
  
        /* here appending/linking starts */
-       mainl = BLO_library_append_begin(C, &bh, libname);
+       mainl = BLO_library_append_begin(bmain, &bh, libname);
        if(totfiles == 0) {
                BLO_library_append_named_part_ex(C, mainl, &bh, name, idcode, flag);
        }
@@@ -3560,7 -3559,6 +3559,7 @@@ static void gesture_circle_modal_keymap
        /* assign map to operators */
        WM_modalkeymap_assign(keymap, "VIEW3D_OT_select_circle");
        WM_modalkeymap_assign(keymap, "UV_OT_circle_select");
 +      WM_modalkeymap_assign(keymap, "CLIP_OT_select_circle");
  
  }
  
@@@ -3640,7 -3638,6 +3639,7 @@@ static void gesture_border_modal_keymap
        WM_modalkeymap_assign(keymap, "SEQUENCER_OT_select_border");
        WM_modalkeymap_assign(keymap, "SEQUENCER_OT_view_ghost_border");
        WM_modalkeymap_assign(keymap, "UV_OT_select_border");
 +      WM_modalkeymap_assign(keymap, "CLIP_OT_select_border");
        WM_modalkeymap_assign(keymap, "VIEW2D_OT_zoom_border");
        WM_modalkeymap_assign(keymap, "VIEW3D_OT_clip_border");
        WM_modalkeymap_assign(keymap, "VIEW3D_OT_render_border");