Merging r38818 through r39198 from trunk into vgroup_modifiers.
authorBastien Montagne <montagne29@wanadoo.fr>
Mon, 8 Aug 2011 21:28:51 +0000 (21:28 +0000)
committerBastien Montagne <montagne29@wanadoo.fr>
Mon, 8 Aug 2011 21:28:51 +0000 (21:28 +0000)
1  2 
source/blender/blenloader/intern/readfile.c
source/blender/blenloader/intern/writefile.c
source/blender/makesrna/RNA_access.h

index ce4a5d217599af783b4ce8e5530a4ec1f315b8de,bd12677485c2063bf23887dfe7457e3ebb403782..4c024c9ee20113afbfda2517a75fb19275edda0a
@@@ -3162,7 -3162,7 +3162,7 @@@ static void lib_link_particlesettings(F
                        if(part->effector_weights)
                                part->effector_weights->group = newlibadr(fd, part->id.lib, part->effector_weights->group);
  
-                       if(part->dupliweights.first) {
+                       if(part->dupliweights.first && part->dup_group) {
                                int index_ok = 0;
                                /* check for old files without indices (all indexes 0) */
                                dw = part->dupliweights.first;
                                                dw->ob = newlibadr(fd, part->id.lib, dw->ob);
                                }
                        }
+                       else {
+                               part->dupliweights.first = part->dupliweights.last = NULL;
+                       }
  
                        if(part->boids) {
                                BoidState *state = part->boids->states.first;
@@@ -4154,13 -4157,6 +4157,13 @@@ static void direct_link_modifiers(FileD
                        if(tmd->curfalloff)
                                direct_link_curvemapping(fd, tmd->curfalloff);
                }
 +              else if (md->type==eModifierType_WeightVGEdit) {
 +                      WeightVGEditModifierData *wmd = (WeightVGEditModifierData*) md;
 +
 +                      wmd->cmap_curve = newdataadr(fd, wmd->cmap_curve);
 +                      if(wmd->cmap_curve)
 +                              direct_link_curvemapping(fd, wmd->cmap_curve);
 +              }
        }
  }
  
@@@ -4730,6 -4726,8 +4733,8 @@@ static void direct_link_windowmanager(F
  
        wm->keyconfigs.first= wm->keyconfigs.last= NULL;
        wm->defaultconf= NULL;
+       wm->addonconf= NULL;
+       wm->userconf= NULL;
  
        wm->jobs.first= wm->jobs.last= NULL;
        wm->drags.first= wm->drags.last= NULL;
@@@ -11714,8 -11712,9 +11719,8 @@@ static void do_versions(FileData *fd, L
        /* put compatibility code here until next subversion bump */
  
        {
 -      
        }
 -      
 +
        /* 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! */
  
@@@ -11765,33 -11764,57 +11770,57 @@@ static void lib_link_all(FileData *fd, 
        lib_link_library(fd, main);             /* only init users */
  }
  
+ static void direct_link_keymapitem(FileData *fd, wmKeyMapItem *kmi)
+ {
+       kmi->properties= newdataadr(fd, kmi->properties);
+       if(kmi->properties)
+               IDP_DirectLinkProperty(kmi->properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
+       kmi->ptr= NULL;
+       kmi->flag &= ~KMI_UPDATE;
+ }
  
  static BHead *read_userdef(BlendFileData *bfd, FileData *fd, BHead *bhead)
  {
        UserDef *user;
        wmKeyMap *keymap;
        wmKeyMapItem *kmi;
+       wmKeyMapDiffItem *kmdi;
  
        bfd->user= user= read_struct(fd, bhead, "user def");
  
        /* read all data into fd->datamap */
        bhead= read_data_into_oldnewmap(fd, bhead, "user def");
  
+       if(user->keymaps.first) {
+               /* backwards compatibility */
+               user->user_keymaps= user->keymaps;
+               user->keymaps.first= user->keymaps.last= NULL;
+       }
        link_list(fd, &user->themes);
-       link_list(fd, &user->keymaps);
+       link_list(fd, &user->user_keymaps);
        link_list(fd, &user->addons);
  
-       for(keymap=user->keymaps.first; keymap; keymap=keymap->next) {
+       for(keymap=user->user_keymaps.first; keymap; keymap=keymap->next) {
                keymap->modal_items= NULL;
                keymap->poll= NULL;
+               keymap->flag &= ~KEYMAP_UPDATE;
  
+               link_list(fd, &keymap->diff_items);
                link_list(fd, &keymap->items);
-               for(kmi=keymap->items.first; kmi; kmi=kmi->next) {
-                       kmi->properties= newdataadr(fd, kmi->properties);
-                       if(kmi->properties)
-                               IDP_DirectLinkProperty(kmi->properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
-                       kmi->ptr= NULL;
+               
+               for(kmdi=keymap->diff_items.first; kmdi; kmdi=kmdi->next) {
+                       kmdi->remove_item= newdataadr(fd, kmdi->remove_item);
+                       kmdi->add_item= newdataadr(fd, kmdi->add_item);
+                       if(kmdi->remove_item)
+                               direct_link_keymapitem(fd, kmdi->remove_item);
+                       if(kmdi->add_item)
+                               direct_link_keymapitem(fd, kmdi->add_item);
                }
+               for(kmi=keymap->items.first; kmi; kmi=kmi->next)
+                       direct_link_keymapitem(fd, kmi);
        }
  
        // XXX
@@@ -12978,9 -13001,8 +13007,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);
+               /* 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);
+                               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 8658462c53ebd7c457c9df342b855ba62711d76f,7d65248c0e92ce4963438b210a9d0188bc25ef7e..8ad8ba121e7b2c2ead486dab946cbdc43ce77ae2
@@@ -717,11 -717,19 +717,19 @@@ static void write_renderinfo(WriteData 
        }
  }
  
+ static void write_keymapitem(WriteData *wd, wmKeyMapItem *kmi)
+ {
+       writestruct(wd, DATA, "wmKeyMapItem", 1, kmi);
+       if(kmi->properties)
+               IDP_WriteProperty(kmi->properties, wd);
+ }
  static void write_userdef(WriteData *wd)
  {
        bTheme *btheme;
        wmKeyMap *keymap;
        wmKeyMapItem *kmi;
+       wmKeyMapDiffItem *kmdi;
        bAddon *bext;
        uiStyle *style;
        
        for(btheme= U.themes.first; btheme; btheme=btheme->next)
                writestruct(wd, DATA, "bTheme", 1, btheme);
  
-       for(keymap= U.keymaps.first; keymap; keymap=keymap->next) {
+       for(keymap= U.user_keymaps.first; keymap; keymap=keymap->next) {
                writestruct(wd, DATA, "wmKeyMap", 1, keymap);
  
-               for(kmi=keymap->items.first; kmi; kmi=kmi->next) {
-                       writestruct(wd, DATA, "wmKeyMapItem", 1, kmi);
-                       if(kmi->properties)
-                               IDP_WriteProperty(kmi->properties, wd);
+               for(kmdi=keymap->diff_items.first; kmdi; kmdi=kmdi->next) {
+                       writestruct(wd, DATA, "wmKeyMapDiffItem", 1, kmdi);
+                       if(kmdi->remove_item)
+                               write_keymapitem(wd, kmdi->remove_item);
+                       if(kmdi->add_item)
+                               write_keymapitem(wd, kmdi->add_item);
                }
+               for(kmi=keymap->items.first; kmi; kmi=kmi->next)
+                       write_keymapitem(wd, kmi);
        }
  
        for(bext= U.addons.first; bext; bext=bext->next)
@@@ -1294,12 -1306,6 +1306,12 @@@ static void write_modifiers(WriteData *
                                write_curvemapping(wd, tmd->curfalloff);
                        }
                }
 +              else if (md->type==eModifierType_WeightVGEdit) {
 +                      WeightVGEditModifierData *wmd = (WeightVGEditModifierData*) md;
 +
 +                      if (wmd->cmap_curve)
 +                              write_curvemapping(wd, wmd->cmap_curve);
 +              }
        }
  }
  
index f0e196686e0249a05706ea57257dbc0ed09be357,0033a1ff437d0d4a89ac0036837aef4fb86474ce..e6f74b244a87783b0316198362c8e83f5419d3f7
@@@ -392,6 -392,7 +392,7 @@@ extern StructRNA RNA_Scene
  extern StructRNA RNA_SceneGameData;
  extern StructRNA RNA_SceneRenderLayer;
  extern StructRNA RNA_SceneSequence;
+ extern StructRNA RNA_SceneObjects;
  extern StructRNA RNA_Scopes;
  extern StructRNA RNA_Screen;
  extern StructRNA RNA_ScrewModifier;
@@@ -562,9 -563,6 +563,9 @@@ extern StructRNA RNA_VoxelData
  extern StructRNA RNA_VoxelDataTexture;
  extern StructRNA RNA_WarpModifier;
  extern StructRNA RNA_WaveModifier;
 +extern StructRNA RNA_WeightVGEditModifier;
 +extern StructRNA RNA_WeightVGMixModifier;
 +extern StructRNA RNA_WeightVGProximityModifier;
  extern StructRNA RNA_Window;
  extern StructRNA RNA_WindowManager;
  extern StructRNA RNA_WipeSequence;