Merge with trunk r39062
authorMiika Hamalainen <blender@miikah.org>
Fri, 5 Aug 2011 09:39:49 +0000 (09:39 +0000)
committerMiika Hamalainen <blender@miikah.org>
Fri, 5 Aug 2011 09:39:49 +0000 (09:39 +0000)
1  2 
source/blender/blenloader/intern/readfile.c
source/blender/makesdna/DNA_space_types.h

index 050ceda0bf437fe7b6c90d545a6933ce488737fb,44c8ca97be9d4d99373df0217024882d90225521..32b353508ece9ec34f5a1f6077ece99aeb8f05d4
@@@ -58,7 -58,6 +58,7 @@@
  #include "DNA_cloth_types.h"
  #include "DNA_controller_types.h"
  #include "DNA_constraint_types.h"
 +#include "DNA_dynamicpaint_types.h"
  #include "DNA_effect_types.h"
  #include "DNA_fileglobal_types.h"
  #include "DNA_genfile.h"
@@@ -4060,43 -4059,6 +4060,43 @@@ static void direct_link_modifiers(FileD
  
                        }
                }
 +              else if (md->type==eModifierType_DynamicPaint) {
 +                      DynamicPaintModifierData *pmd = (DynamicPaintModifierData*) md;
 +
 +                      if(pmd->canvas)
 +                      {
 +                              pmd->canvas = newdataadr(fd, pmd->canvas);
 +                              pmd->canvas->pmd = pmd;
 +                              pmd->canvas->dm = NULL;
 +                              pmd->canvas->ui_info[0] = '\0';
 +                              pmd->canvas->flags &= ~MOD_DPAINT_BAKING; /* just in case */
 +
 +                              if (pmd->canvas->surfaces.first) {
 +                                      DynamicPaintSurface *surface;
 +                                      link_list(fd, &pmd->canvas->surfaces);
 +
 +                                      for (surface=pmd->canvas->surfaces.first; surface; surface=surface->next) {
 +                                              surface->canvas = pmd->canvas;
 +                                              surface->data = NULL;
 +                                              direct_link_pointcache_list(fd, &(surface->ptcaches), &(surface->pointcache), 1);
 +
 +                                              if(!(surface->effector_weights = newdataadr(fd, surface->effector_weights)))
 +                                                      surface->effector_weights = BKE_add_effector_weights(NULL);
 +                                      }
 +                              }
 +                      }
 +                      if(pmd->brush)
 +                      {
 +                              if (pmd->brush) {
 +                                      pmd->brush = newdataadr(fd, pmd->brush);
 +                                      pmd->brush->pmd = pmd;
 +                                      pmd->brush->psys = newdataadr(fd, pmd->brush->psys);
 +                                      pmd->brush->paint_ramp = newdataadr(fd, pmd->brush->paint_ramp);
 +                                      pmd->brush->vel_ramp = newdataadr(fd, pmd->brush->vel_ramp);
 +                                      pmd->brush->dm = NULL;
 +                              }
 +                      }
 +              }
                else if (md->type==eModifierType_Collision) {
                        
                        CollisionModifierData *collmd = (CollisionModifierData*) md;
@@@ -11236,7 -11198,7 +11236,7 @@@ static void do_versions(FileData *fd, L
                                                /* enable all cache display */
                                                stime->cache_display |= TIME_CACHE_DISPLAY;
                                                stime->cache_display |= (TIME_CACHE_SOFTBODY|TIME_CACHE_PARTICLES);
 -                                              stime->cache_display |= (TIME_CACHE_CLOTH|TIME_CACHE_SMOKE);
 +                                              stime->cache_display |= (TIME_CACHE_CLOTH|TIME_CACHE_SMOKE|TIME_CACHE_DYNAMICPAINT);
                                        }
                                }
                        }
@@@ -13013,9 -12975,8 +13013,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);
  }
  
- static void append_do_cursor(Scene *scene, Library *curlib, short flag)
- {
-       Base *centerbase;
-       Object *ob;
-       float *curs, centerloc[3], vec[3], min[3], max[3];
-       int count= 0;
-       /* when not linking (appending)... */
-       if(flag & FILE_LINK) 
-               return;
-       /* we're not appending at cursor */
-       if((flag & FILE_ATCURSOR) == 0) 
-               return;
-       
-       /* find the center of everything appended */
-       INIT_MINMAX(min, max);
-       centerbase= (scene->base.first);
-       while(centerbase) {
-               if(centerbase->object->id.lib==curlib && centerbase->object->parent==NULL) {
-                       VECCOPY(vec, centerbase->object->loc);
-                       DO_MINMAX(vec, min, max);
-                       count++;
-               }
-               centerbase= centerbase->next;
-       }
-       /* we haven't found any objects to move to cursor */
-       if(!count) 
-               return;
-       
-       /* move from the center of the appended objects to cursor */
-       mid_v3_v3v3(centerloc, min, max);
-       curs = scene->cursor;
-       VECSUB(centerloc,curs,centerloc);
-       
-       /* now translate the center of the objects */
-       centerbase= (scene->base.first);
-       while(centerbase) {
-               if(centerbase->object->id.lib==curlib && centerbase->object->parent==NULL) {
-                       ob= centerbase->object;
-                       ob->loc[0] += centerloc[0];
-                       ob->loc[1] += centerloc[1];
-                       ob->loc[2] += centerloc[2];
-               }
-               centerbase= centerbase->next;
-       }
- }
  
+ /* Context == NULL signifies not to do any scene manipulation */
  static void library_append_end(const bContext *C, Main *mainl, FileData **fd, int idcode, short flag)
  {
        Main *mainvar;
-       Scene *scene= CTX_data_scene(C);
        Library *curlib;
  
        /* make main consistent */
        lib_verify_nodetree(mainvar, FALSE);
        fix_relpaths_library(G.main->name, mainvar); /* make all relative paths, relative to the open blend file */
  
-       /* give a base to loose objects. If group append, do it for objects too */
-       if(scene) {
-               const short is_link= (flag & FILE_LINK) != 0;
-               if(idcode==ID_SCE) {
-                       /* dont instance anything when linking in scenes, assume the scene its self instances the data */
-               }
-               else {
-                       give_base_to_objects(mainvar, scene, curlib, idcode, is_link);
+       if(C) {
+               Scene *scene= CTX_data_scene(C);
  
-                       if (flag & FILE_GROUP_INSTANCE) {
-                               give_base_to_groups(mainvar, scene);
+               /* give a base to loose objects. If group append, do it for objects too */
+               if(scene) {
+                       const short is_link= (flag & FILE_LINK) != 0;
+                       if(idcode==ID_SCE) {
+                               /* dont instance anything when linking in scenes, assume the scene its self instances the data */
+                       }
+                       else {
+                               give_base_to_objects(mainvar, scene, curlib, idcode, is_link);
+                               if (flag & FILE_GROUP_INSTANCE) {
+                                       give_base_to_groups(mainvar, scene);
+                               }
                        }
                }
-       }
-       else {
-               printf("library_append_end, scene is NULL (objects wont get bases)\n");
+               else {
+                       printf("library_append_end, scene is NULL (objects wont get bases)\n");
+               }
        }
        /* has been removed... erm, why? s..ton) */
        /* 20040907: looks like they are give base already in append_named_part(); -Nathan L */
                blo_freefiledata( *fd );
                *fd = NULL;
        }       
-       append_do_cursor(scene, curlib, flag);
  }
  
  void BLO_library_append_end(const bContext *C, struct Main *mainl, BlendHandle** bh, int idcode, short flag)
index 588ecfe3e37d9b4b18611f9adb3ce678c2fca9b7,1549bd717485beb8a0b731489af7523371a2c465..7baa8f24df40242cfb271b8913ed4a4d036236db
@@@ -703,7 -703,7 +703,7 @@@ enum FileSortTypeE 
  #define FILE_HIDE_DOT         (1<<3)
  #define FILE_AUTOSELECT               (1<<4)
  #define FILE_ACTIVELAY                (1<<5)
- #define FILE_ATCURSOR         (1<<6)
+ /* #define FILE_ATCURSOR      (1<<6) */ /* deprecated */
  #define FILE_DIRSEL_ONLY      (1<<7)
  #define FILE_FILTER                   (1<<8)
  #define FILE_BOOKMARKS                (1<<9)
@@@ -903,7 -903,6 +903,7 @@@ enum 
  #define TIME_CACHE_PARTICLES  4
  #define TIME_CACHE_CLOTH              8
  #define TIME_CACHE_SMOKE              16
 +#define TIME_CACHE_DYNAMICPAINT       32
  
  /* sseq->mainb */
  #define SEQ_DRAW_SEQUENCE         0