Merging r38390 through r38418 from trunk into soc-2011-tomato
authorSergey Sharybin <sergey.vfx@gmail.com>
Fri, 15 Jul 2011 20:22:01 +0000 (20:22 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Fri, 15 Jul 2011 20:22:01 +0000 (20:22 +0000)
1  2 
source/blender/blenloader/intern/readfile.c
source/blender/blenloader/intern/writefile.c
source/blenderplayer/CMakeLists.txt
source/creator/CMakeLists.txt

index a26ef101c1cbbfbfe93d46f83155b1f3f584cf0a,ab30d92f03e7d363e58763a86277578acca55afe..496b8e9ab070b4b615e5d95e26250d930d37371e
@@@ -75,6 -75,7 +75,7 @@@
  #include "DNA_node_types.h"
  #include "DNA_object_fluidsim.h" // NT
  #include "DNA_packedFile_types.h"
+ #include "DNA_particle_types.h"
  #include "DNA_property_types.h"
  #include "DNA_text_types.h"
  #include "DNA_view3d_types.h"
@@@ -88,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"
  
@@@ -1033,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)
@@@ -1110,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 */
  {
@@@ -1245,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->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)
  {
@@@ -3203,9 -3162,37 +3204,37 @@@ static void lib_link_particlesettings(F
                        if(part->effector_weights)
                                part->effector_weights->group = newlibadr(fd, part->id.lib, part->effector_weights->group);
  
-                       dw = part->dupliweights.first;
-                       for(; dw; dw=dw->next)
-                               dw->ob = newlibadr(fd, part->id.lib, dw->ob);
+                       if(part->dupliweights.first) {
+                               int index_ok = 0;
+                               /* check for old files without indices (all indexes 0) */
+                               dw = part->dupliweights.first;
+                               if(part->dupliweights.first == part->dupliweights.last) {
+                                       /* special case for only one object in the group */
+                                       index_ok = 1;
+                               }
+                               else { 
+                                       for(; dw; dw=dw->next) {
+                                               if(dw->index > 0) {
+                                                       index_ok = 1;
+                                                       break;
+                                               }
+                                       }
+                               }
+                               if(index_ok) {
+                                       /* if we have indexes, let's use them */
+                                       dw = part->dupliweights.first;
+                                       for(; dw; dw=dw->next) {
+                                               GroupObject *go = (GroupObject *)BLI_findlink(&part->dup_group->gobject, dw->index);
+                                               dw->ob = go ? go->ob : NULL;
+                                       }
+                               }
+                               else {
+                                       /* otherwise try to get objects from own library (won't work on library linked groups) */
+                                       for(; dw; dw=dw->next)
+                                               dw->ob = newlibadr(fd, part->id.lib, dw->ob);
+                               }
+                       }
  
                        if(part->boids) {
                                BoidState *state = part->boids->states.first;
@@@ -4700,7 -4687,6 +4729,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 -4839,6 +4882,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);
 +                                      }
                                }
                                sa= sa->next;
                        }
@@@ -5070,7 -5050,6 +5099,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;
                }
@@@ -5659,48 -5633,6 +5688,48 @@@ 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;
 +
 +      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 *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 ******************** */
  
  
@@@ -5734,7 -5666,6 +5763,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";
        
@@@ -5901,9 -5832,6 +5930,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*/
@@@ -11781,35 -11709,9 +11810,35 @@@ 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;
 +                                              }
 +                                      }
 +                              }
 +                      }
 +              }
        }
        
 +      {
 +              Camera *cam;
 +                      for(cam= main->camera.first; cam; cam= cam->id.next) {
 +                              if (cam->sensor_x < 0.01) {
 +                                      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! */
  
@@@ -11853,7 -11755,6 +11882,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 0ba4082686a95c09f5f544bfe670874860dfe8a7,bf86527b9d337ef9aa6df8ba7c784beb7a4cfb65..771f83221addc9adff18ed65f4cc6241692d11ac
@@@ -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"
@@@ -838,6 -837,7 +838,7 @@@ static void write_particlesettings(Writ
  {
        ParticleSettings *part;
        ParticleDupliWeight *dw;
+       GroupObject *go;
        int a;
  
        part= idbase->first;
                        writestruct(wd, DATA, "EffectorWeights", 1, part->effector_weights);
  
                        dw = part->dupliweights.first;
-                       for(; dw; dw=dw->next)
+                       for(; dw; dw=dw->next) {
+                               /* update indices */
+                               dw->index = 0;
+                               go = part->dup_group->gobject.first;
+                               while(go && go->ob != dw->ob) {
+                                       go=go->next;
+                                       dw->index++;
+                               }
                                writestruct(wd, DATA, "ParticleDupliWeight", 1, dw);
+                       }
  
                        if(part->boids && part->phystype == PART_PHYS_BOIDS) {
                                BoidState *state = part->boids->states.first;
@@@ -2180,9 -2188,6 +2189,9 @@@ static void write_screens(WriteData *wd
                                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;
                        }
@@@ -2414,38 -2419,6 +2423,38 @@@ 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(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 */
@@@ -2522,7 -2495,6 +2531,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 b501631ee2d5bab5009a122f7c02c325639fd53f,ddfdfc97bdc88f624d86ea154934e0e21d4c74ba..39f93846e912c860b905b94464af5d5d6282ea6c
@@@ -121,6 -121,7 +121,7 @@@ endif(
                bf_intern_guardedalloc 
                bf_intern_memutil 
                bf_python_ext
+               bf_python_mathutils
                bf_blenlib 
                bf_imbuf_cineon
                bf_imbuf_openexr 
                list(APPEND BLENDER_SORTED_LIBS extern_lzma)
        endif()
  
 +      if(WITH_LIBMV)
 +              list(APPEND BLENDER_SORTED_LIBS extern_libmv)
 +      endif()
 +
 +      list(APPEND BLENDER_SORTED_LIBS extern_colamd)
 +
        if(WITH_MOD_DECIMATE)
                list(APPEND BLENDER_SORTED_LIBS bf_intern_decimate)
        endif()
index 66dd6b53feb1ee51c20ccd08a820a8d5c023852a,43fec85b5bf6f28e64a15f7dc353e5465a43d640..c1f0560bc1cb9cb5f993b265c9cc5812a042fec7
@@@ -72,11 -72,6 +72,11 @@@ if(WITH_IMAGE_HDR
        add_definitions(-DWITH_HDR)
  endif()
  
 +if(WITH_LIBMV)
 +      blender_include_dirs(../../extern/libmv)
 +      add_definitions(-DWITH_LIBMV)
 +endif()
 +
  if(WITH_PYTHON)
        blender_include_dirs(../blender/python)
        add_definitions(-DWITH_PYTHON)
@@@ -749,7 -744,6 +749,7 @@@ endif(
                bf_editor_space_time
                bf_editor_space_userpref
                bf_editor_space_view3d
 +              bf_editor_space_clip
  
                bf_editor_text
                bf_editor_transform
                bf_intern_opennl
                bf_python
                bf_python_ext
+               bf_python_mathutils
                bf_ikplugin
                bf_modifiers
                bf_blenkernel
                bf_intern_smoke
                extern_minilzo
                extern_lzma
 +              extern_colamd
                ge_logic_ketsji
                ge_phys_common
                ge_logic
                bf_intern_mikktspace
        )
  
 +      if(WITH_LIBMV)
 +              list(APPEND BLENDER_SORTED_LIBS extern_libmv)
 +      endif()
 +
        if(WITH_MOD_CLOTH_ELTOPO)
                list(APPEND BLENDER_SORTED_LIBS extern_eltopo)
        endif()