Merging r38220 through r38236 from trunk into soc-2011-tomato
authorSergey Sharybin <sergey.vfx@gmail.com>
Fri, 8 Jul 2011 17:40:29 +0000 (17:40 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Fri, 8 Jul 2011 17:40:29 +0000 (17:40 +0000)
1  2 
source/blender/blenloader/intern/readfile.c
source/blender/blenloader/intern/writefile.c
source/blender/editors/transform/transform_conversions.c

index 6ff24a418fabdb951cd28d910043617e280aeb97,2402106306e9c3bf5ecffcd610c4a110689f66c3..d705c6bebfd7381cfb7d56fb332f4394ca16ca1f
@@@ -88,7 -88,6 +88,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"
  
@@@ -1033,8 -1032,6 +1033,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)
@@@ -1110,13 -1107,6 +1110,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 */
  {
@@@ -1245,38 -1235,6 +1245,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->ibuf_cache)
 +                      oldnewmap_insert(fd->movieclipmap, clip->ibuf_cache, clip->ibuf_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->ibuf_cache= newmclipadr(fd, clip->ibuf_cache);
 +      }
 +}
 +
 +
  /* undo file support: add all library pointers in lookup */
  void blo_add_library_pointer_map(ListBase *mainlist, FileData *fd)
  {
@@@ -4700,7 -4658,6 +4700,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 ***************** */
@@@ -4853,7 -4810,6 +4853,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);
                                        else if(sl->spacetype==SPACE_FILE) {
                                                SpaceFile *sfile= (SpaceFile *)sl;
                                                sfile->files= NULL;
-                                               sfile->params= NULL;
                                                sfile->op= NULL;
                                                sfile->layout= NULL;
                                                sfile->folders_prev= NULL;
                                                
                                                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);
 +                                      }
                                }
                                sa= sa->next;
                        }
@@@ -5071,7 -5021,6 +5070,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);
 +                              }
                        }
                        sa= sa->next;
                }
@@@ -5504,7 -5448,7 +5503,7 @@@ static void direct_link_screen(FileDat
                                sfile->files= NULL;
                                sfile->layout= NULL;
                                sfile->op= NULL;
-                               sfile->params= NULL;
+                               sfile->params= newdataadr(fd, sfile->params);
                        }
                }
                
@@@ -5660,53 -5604,6 +5659,53 @@@ 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->ibuf_cache= newmclipadr(fd, clip->ibuf_cache);
 +      else clip->ibuf_cache= NULL;
 +
 +      clip->adt= newdataadr(fd, clip->adt);
 +      direct_link_animdata(fd, clip->adt);
 +
 +      tracking->camera.reconstructed= newdataadr(fd, tracking->camera.reconstructed);
 +
 +      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;
 +}
 +
 +static void lib_link_movieclip(FileData *fd, Main *main)
 +{
 +      MovieClip *clip;
 +
 +      clip= main->movieclip.first;
 +      while(clip) {
 +              if(clip->id.flag & LIB_NEEDLINK) {
 +                      if(clip->adt) lib_link_animdata(fd, &clip->id, clip->adt);
 +
 +                      clip->id.flag -= LIB_NEEDLINK;
 +              }
 +              clip= clip->id.next;
 +      }
 +}
 +
  /* ************** GENERAL & MAIN ******************** */
  
  
@@@ -5740,7 -5637,6 +5739,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";
        
@@@ -5907,9 -5803,6 +5906,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*/
@@@ -11787,23 -11680,7 +11786,23 @@@ static void do_versions(FileData *fd, L
        /* put compatibility code here until next subversion bump */
  
        {
 -      
 +              bScreen *sc;
 +
 +              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;
 +                                              }
 +                                      }
 +                              }
 +                      }
 +              }
        }
        
        /* WATCH IT!!!: pointers from libdata have not been converted yet here! */
@@@ -11849,7 -11726,6 +11848,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 */
  
index d004cbb4647ba5e44a1542099f57a70b711c941a,ba4395ace9cb6c90cdd1f1c2aa33e8b37f931d90..6ce84e93f49c92ed32876965fc29cf6fbb130e31
@@@ -129,7 -129,6 +129,7 @@@ Any case: direct data is ALWAYS after t
  #include "DNA_vfont_types.h"
  #include "DNA_world_types.h"
  #include "DNA_windowmanager_types.h"
 +#include "DNA_movieclip_types.h"
  
  #include "MEM_guardedalloc.h" // MEM_freeN
  #include "BLI_blenlib.h"
@@@ -2104,7 -2103,11 +2104,11 @@@ static void write_screens(WriteData *wd
                                        writestruct(wd, DATA, "SpaceButs", 1, sl);
                                }
                                else if(sl->spacetype==SPACE_FILE) {
+                                       SpaceFile *sfile= (SpaceFile *)sl;
                                        writestruct(wd, DATA, "SpaceFile", 1, sl);
+                                       if(sfile->params)
+                                               writestruct(wd, DATA, "FileSelectParams", 1, sfile->params);
                                }
                                else if(sl->spacetype==SPACE_SEQ) {
                                        writestruct(wd, DATA, "SpaceSeq", 1, sl);
                                else if(sl->spacetype==SPACE_USERPREF) {
                                        writestruct(wd, DATA, "SpaceUserPref", 1, sl);
                                }
 +                              else if(sl->spacetype==SPACE_CLIP) {
 +                                      writestruct(wd, DATA, "SpaceClip", 1, sl);
 +                              }
  
                                sl= sl->next;
                        }
@@@ -2410,40 -2410,6 +2414,40 @@@ static void write_scripts(WriteData *wd
        }
  }
  
 +static void write_movieclips(WriteData *wd, ListBase *idbase)
 +{
 +      MovieClip *clip;
 +
 +      clip= idbase->first;
 +      while(clip) {
 +              if(clip->id.us>0 || wd->current) {
 +                      MovieTracking *tracking= &clip->tracking;
 +                      MovieTrackingTrack *track;
 +                      writestruct(wd, ID_MC, "MovieClip", 1, clip);
 +
 +                      if (clip->adt) write_animdata(wd, clip->adt);
 +
 +                      if(tracking->camera.reconnr)
 +                              writestruct(wd, DATA, "MovieReconstructedCamera", tracking->camera.reconnr, tracking->camera.reconstructed);
 +
 +                      track= tracking->tracks.first;
 +                      while(track) {
 +                              writestruct(wd, DATA, "MovieTrackingTrack", 1, track);
 +
 +                              if(track->markers)
 +                                      writestruct(wd, DATA, "MovieTrackingMarker", track->markersnr, track->markers);
 +
 +                              track= track->next;
 +                      }
 +              }
 +
 +              clip= clip->id.next;
 +      }
 +
 +      /* flush helps the compression for undo-save */
 +      mywrite(wd, MYWRITE_FLUSH, 0);
 +}
 +
  /* context is usually defined by WM, two cases where no WM is available:
   * - for forward compatibility, curscreen has to be saved
   * - for undofile, curscene needs to be saved */
@@@ -2520,7 -2486,6 +2524,7 @@@ static int write_file_handle(Main *main
                write_windowmanagers(wd, &mainvar->wm);
                write_screens  (wd, &mainvar->screen);
        }
 +      write_movieclips (wd, &mainvar->movieclip);
        write_scenes   (wd, &mainvar->scene);
        write_curves   (wd, &mainvar->curve);
        write_mballs   (wd, &mainvar->mball);
index 1c24f065d2623f8f7f0d5088c2ebed618694944d,de8eda78d6372db74ed25ab42af098807d134b55..24abb6a0bc25ab74533e25059e74f865bf773e36
@@@ -53,7 -53,6 +53,7 @@@
  #include "DNA_scene_types.h"
  #include "DNA_meshdata_types.h"
  #include "DNA_gpencil_types.h"
 +#include "DNA_movieclip_types.h"
  
  #include "MEM_guardedalloc.h"
  
@@@ -77,8 -76,6 +77,8 @@@
  #include "BKE_bmesh.h"
  #include "BKE_scene.h"
  #include "BKE_report.h"
 +#include "BKE_tracking.h"
 +#include "BKE_movieclip.h"
  
  
  #include "ED_anim_api.h"
@@@ -92,7 -89,6 +92,7 @@@
  #include "ED_mesh.h"
  #include "ED_types.h"
  #include "ED_uvedit.h"
 +#include "ED_clip.h"
  #include "ED_curve.h" /* for ED_curve_editnurbs */
  #include "ED_util.h"  /* for crazyspace correction */
  
@@@ -4762,9 -4758,6 +4762,9 @@@ void special_aftertrans_update(bContex
        else if (t->spacetype == SPACE_NODE) {
                /* pass */
        }
 +      else if (t->spacetype == SPACE_CLIP) {
 +              /* pass */
 +      }
        else if (t->spacetype == SPACE_ACTION) {
                SpaceAction *saction= (SpaceAction *)t->sa->spacedata.first;
                bAnimContext ac;
  
                /* automatic inserting of keys and unkeyed tagging - only if transform wasn't cancelled (or TFM_DUMMY) */
                if (!cancelled && (t->mode != TFM_DUMMY)) {
+                       /* set BONE_TRANSFORM flags, they get changed by manipulator draw */
+                       count_set_pose_transflags(&t->mode, t->around, ob);
                        autokeyframe_pose_cb_func(C, t->scene, (View3D *)t->view, ob, t->mode, targetless_ik);
                        DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
                }
@@@ -5207,157 -5202,6 +5209,157 @@@ static void createTransNodeData(bContex
        CTX_DATA_END
  }
  
 +/* *** CLIP EDITOR *** */
 +
 +static void markerToTransDataInit(TransData *td, TransData2D *td2d, float *loc, float *rel)
 +{
 +      td2d->loc[0] = loc[0]; /* hold original location */
 +      td2d->loc[1] = loc[1];
 +      td2d->loc[2] = 0.0f;
 +
 +      if(rel) {       /* XXX: could it be nicer? */
 +              td2d->loc[0]+= rel[0];
 +              td2d->loc[1]+= rel[1];
 +
 +              td->extra= rel;
 +      }
 +
 +      td2d->loc2d = loc; /* current location */
 +
 +      td->flag = 0;
 +      td->loc = td2d->loc;
 +      VECCOPY(td->center, td->loc);
 +      VECCOPY(td->iloc, td->loc);
 +
 +      memset(td->axismtx, 0, sizeof(td->axismtx));
 +      td->axismtx[2][2] = 1.0f;
 +
 +      td->ext= NULL; td->val= NULL;
 +
 +      td->flag |= TD_SELECTED;
 +      td->dist= 0.0;
 +
 +      unit_m3(td->mtx);
 +      unit_m3(td->smtx);
 +}
 +
 +static void trackToTransData(SpaceClip *sc, TransData *td, TransData2D *td2d, MovieTrackingTrack *track)
 +{
 +      MovieTrackingMarker *marker= BKE_tracking_ensure_marker(track, sc->user.framenr);
 +
 +      if((marker->flag&MARKER_DISABLED)==0) {
 +              if(track->flag&SELECT)
 +                      markerToTransDataInit(td++, td2d++, marker->pos, NULL);
 +
 +              if(track->pat_flag&SELECT) {
 +                      markerToTransDataInit(td++, td2d++, track->pat_min, marker->pos);
 +                      markerToTransDataInit(td++, td2d++, track->pat_max, marker->pos);
 +              }
 +      }
 +
 +      if(track->search_flag&SELECT) {
 +              if(marker->flag&MARKER_DISABLED) {
 +                      markerToTransDataInit(td++, td2d++, marker->pos, NULL);
 +
 +                      markerToTransDataInit(td++, td2d++, track->pat_min, marker->pos);
 +                      markerToTransDataInit(td++, td2d++, track->pat_max, marker->pos);
 +              }
 +
 +              markerToTransDataInit(td++, td2d++, track->search_min, marker->pos);
 +              markerToTransDataInit(td++, td2d++, track->search_max, marker->pos);
 +      }
 +}
 +
 +static void createTransTrackingData(bContext *C, TransInfo *t)
 +{
 +      TransData *td;
 +      TransData2D *td2d;
 +      SpaceClip *sc = CTX_wm_space_clip(C);
 +      MovieClip *clip = ED_space_clip(sc);
 +      MovieTrackingTrack *track;
 +      MovieTrackingMarker *marker;
 +      int framenr = sc->user.framenr;
 +
 +      if(clip && !BKE_movieclip_has_frame(clip, &sc->user)) {
 +              t->total = 0;
 +              return;
 +      }
 +
 +      /* count */
 +      t->total = 0;
 +
 +      track = clip->tracking.tracks.first;
 +      while(track) {
 +              if(TRACK_SELECTED(track)) {
 +                      marker= BKE_tracking_get_marker(track, framenr);
 +
 +                      if(marker) {
 +                              if((marker->flag&MARKER_DISABLED)==0) {
 +                                      if(track->flag&SELECT) t->total++;
 +                                      if(track->pat_flag&SELECT) t->total+= 2;
 +                              }
 +
 +                              if(track->search_flag&SELECT) {
 +                                      t->total+= 2;
 +
 +                                      if(marker->flag&MARKER_DISABLED)
 +                                              t->total+= 3;
 +                              }
 +                      }
 +              }
 +
 +              track = track->next;
 +      }
 +
 +      td = t->data = MEM_callocN(t->total*sizeof(TransData), "TransTracking TransData");
 +      td2d = t->data2d = MEM_callocN(t->total*sizeof(TransData2D), "TransTracking TransData2D");
 +
 +      /* create actual data */
 +      track = clip->tracking.tracks.first;
 +      while(track) {
 +              if(TRACK_SELECTED(track)) {
 +                      marker= BKE_tracking_get_marker(track, framenr);
 +
 +                      if(marker) {
 +                              trackToTransData(sc, td, td2d, track);
 +
 +                              if((marker->flag&MARKER_DISABLED)==0) {
 +                                      if(track->flag&SELECT) {td++; td2d++;}
 +                                      if(track->pat_flag&SELECT) {td+= 2; td2d+= 2;}
 +                              }
 +
 +                              if(track->search_flag&SELECT) {
 +                                      td+= 2;
 +                                      td2d+= 2;
 +
 +                                      if(marker->flag&MARKER_DISABLED) {
 +                                              td+= 3;
 +                                              td2d+= 3;
 +                                      }
 +                              };
 +                      }
 +              }
 +
 +              track = track->next;
 +      }
 +}
 +
 +void flushTransTracking(TransInfo *t)
 +{
 +      TransData *td;
 +      TransData2D *td2d;
 +      int a;
 +
 +      /* flush to 2d vector from internally used 3d vector */
 +      for(a=0, td= t->data, td2d= t->data2d; a<t->total; a++, td2d++, td++) {
 +              td2d->loc2d[0] = td2d->loc[0];
 +              td2d->loc2d[1] = td2d->loc[1];
 +
 +              if(td->extra)
 +                      sub_v2_v2(td2d->loc2d, td->extra);
 +      }
 +}
 +
  void createTransData(bContext *C, TransInfo *t)
  {
        Scene *scene = t->scene;
                        sort_trans_data_dist(t);
                }
        }
 +      else if (t->spacetype == SPACE_CLIP) {
 +              t->flag |= T_POINTS|T_2D_EDIT;
 +              createTransTrackingData(C, t);
 +      }
        else if (t->obedit) {
                t->ext = NULL;
                if (t->obedit->type == OB_MESH) {