diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2016-08-06 13:25:24 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2016-08-06 13:45:03 +0300 |
commit | 9843921288307be33fc39450586ff9ad226829a1 (patch) | |
tree | de6e0ddd71b48d036bf5525e62edf10a57d3238e /source/blender/blenloader/intern | |
parent | 4571fdde0ecfdebac6a9374364b05be74233aca5 (diff) | |
parent | 28c3bdf50bd62b510fdbd88a5dcb1c40f8726c20 (diff) |
Merge branch 'master' into blender2.8
Conflicts:
release/scripts/startup/bl_ui/properties_particle.py
release/scripts/startup/bl_ui/properties_physics_cloth.py
release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py
release/scripts/startup/bl_ui/properties_physics_softbody.py
source/blender/blenkernel/BKE_library.h
source/blender/blenkernel/BKE_particle.h
source/blender/blenkernel/intern/cloth.c
source/blender/blenkernel/intern/library.c
source/blender/blenkernel/intern/library_query.c
source/blender/blenkernel/intern/particle_system.c
source/blender/blenkernel/intern/scene.c
source/blender/blenkernel/intern/softbody.c
source/blender/blenloader/intern/readfile.c
source/blender/blenloader/intern/versioning_270.c
source/blender/editors/space_file/filesel.c
source/blender/editors/space_outliner/outliner_intern.h
source/blender/makesdna/DNA_ID.h
source/blender/makesdna/DNA_object_force.h
source/blender/makesdna/DNA_particle_types.h
source/blender/makesrna/intern/rna_particle.c
source/blender/makesrna/intern/rna_sculpt_paint.c
source/blender/makesrna/intern/rna_smoke.c
source/blender/makesrna/intern/rna_space.c
Diffstat (limited to 'source/blender/blenloader/intern')
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 115 | ||||
-rw-r--r-- | source/blender/blenloader/intern/versioning_270.c | 103 | ||||
-rw-r--r-- | source/blender/blenloader/intern/versioning_defaults.c | 5 | ||||
-rw-r--r-- | source/blender/blenloader/intern/writefile.c | 37 |
4 files changed, 234 insertions, 26 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 80597b844d9..cb67fe0dbed 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -59,6 +59,7 @@ #include "DNA_actuator_types.h" #include "DNA_brush_types.h" #include "DNA_camera_types.h" +#include "DNA_cachefile_types.h" #include "DNA_cloth_types.h" #include "DNA_controller_types.h" #include "DNA_constraint_types.h" @@ -114,6 +115,7 @@ #include "BKE_action.h" #include "BKE_armature.h" #include "BKE_brush.h" +#include "BKE_cachefile.h" #include "BKE_cloth.h" #include "BKE_constraint.h" #include "BKE_context.h" @@ -142,7 +144,7 @@ #include "BKE_sequencer.h" #include "BKE_outliner_treehash.h" #include "BKE_sound.h" - +#include "BKE_colortools.h" #include "NOD_common.h" #include "NOD_socket.h" @@ -2689,6 +2691,36 @@ static void direct_link_animdata(FileData *fd, AnimData *adt) adt->actstrip = newdataadr(fd, adt->actstrip); } +/* ************ READ CACHEFILES *************** */ + +static void lib_link_cachefiles(FileData *fd, Main *bmain) +{ + CacheFile *cache_file; + + /* only link ID pointers */ + for (cache_file = bmain->cachefiles.first; cache_file; cache_file = cache_file->id.next) { + if (cache_file->id.tag & LIB_TAG_NEED_LINK) { + cache_file->id.tag &= ~LIB_TAG_NEED_LINK; + } + + BLI_listbase_clear(&cache_file->object_paths); + cache_file->handle = NULL; + + if (cache_file->adt) { + lib_link_animdata(fd, &cache_file->id, cache_file->adt); + } + } +} + +static void direct_link_cachefile(FileData *fd, CacheFile *cache_file) +{ + cache_file->handle = NULL; + + /* relink animdata */ + cache_file->adt = newdataadr(fd, cache_file->adt); + direct_link_animdata(fd, cache_file->adt); +} + /* ************ READ MOTION PATHS *************** */ /* direct data for cache */ @@ -4554,8 +4586,11 @@ static void lib_link_object(FileData *fd, Main *main) if (ob->pd) lib_link_partdeflect(fd, &ob->id, ob->pd); - if (ob->soft) + if (ob->soft) { + ob->soft->collision_group = newlibadr(fd, ob->id.lib, ob->soft->collision_group); + ob->soft->effector_weights->group = newlibadr(fd, ob->id.lib, ob->soft->effector_weights->group); + } lib_link_modifiers(fd, ob); @@ -5488,6 +5523,22 @@ static void direct_link_scene(FileData *fd, Scene *sce) sce->toolsettings->wpaint->wpaint_prev = NULL; sce->toolsettings->wpaint->tot = 0; } + /* relink grease pencil drawing brushes */ + link_list(fd, &sce->toolsettings->gp_brushes); + for (bGPDbrush *brush = sce->toolsettings->gp_brushes.first; brush; brush = brush->next) { + brush->cur_sensitivity = newdataadr(fd, brush->cur_sensitivity); + if (brush->cur_sensitivity) { + direct_link_curvemapping(fd, brush->cur_sensitivity); + } + brush->cur_strength = newdataadr(fd, brush->cur_strength); + if (brush->cur_strength) { + direct_link_curvemapping(fd, brush->cur_strength); + } + brush->cur_jitter = newdataadr(fd, brush->cur_jitter); + if (brush->cur_jitter) { + direct_link_curvemapping(fd, brush->cur_jitter); + } + } } if (sce->ed) { @@ -5763,7 +5814,8 @@ static void direct_link_gpencil(FileData *fd, bGPdata *gpd) bGPDlayer *gpl; bGPDframe *gpf; bGPDstroke *gps; - + bGPDpalette *palette; + /* we must firstly have some grease-pencil data to link! */ if (gpd == NULL) return; @@ -5771,11 +5823,19 @@ static void direct_link_gpencil(FileData *fd, bGPdata *gpd) /* relink animdata */ gpd->adt = newdataadr(fd, gpd->adt); direct_link_animdata(fd, gpd->adt); - + + /* relink palettes */ + link_list(fd, &gpd->palettes); + for (palette = gpd->palettes.first; palette; palette = palette->next) { + link_list(fd, &palette->colors); + } + /* relink layers */ link_list(fd, &gpd->layers); for (gpl = gpd->layers.first; gpl; gpl = gpl->next) { + /* parent */ + gpl->parent = newlibadr(fd, gpd->id.lib, gpl->parent); /* relink frames */ link_list(fd, &gpl->frames); gpl->actframe = newdataadr(fd, gpl->actframe); @@ -5788,9 +5848,12 @@ static void direct_link_gpencil(FileData *fd, bGPdata *gpd) gps->points = newdataadr(fd, gps->points); /* the triangulation is not saved, so need to be recalculated */ - gps->flag |= GP_STROKE_RECALC_CACHES; gps->triangles = NULL; gps->tot_triangles = 0; + gps->flag |= GP_STROKE_RECALC_CACHES; + /* the color pointer is not saved, so need to be recalculated using the color name */ + gps->palcolor = NULL; + gps->flag |= GP_STROKE_RECALC_COLOR; } } } @@ -5947,10 +6010,8 @@ static void lib_link_screen(FileData *fd, Main *main) snode->id = newlibadr(fd, sc->id.lib, snode->id); snode->from = newlibadr(fd, sc->id.lib, snode->from); - if (snode->id) { - ntree = ntreeFromID(snode->id); - snode->nodetree = ntree ? ntree : newlibadr_us(fd, sc->id.lib, snode->nodetree); - } + ntree = snode->id ? ntreeFromID(snode->id) : NULL; + snode->nodetree = ntree ? ntree : newlibadr_us(fd, sc->id.lib, snode->nodetree); for (path = snode->treepath.first; path; path = path->next) { if (path == snode->treepath.first) { @@ -6329,11 +6390,8 @@ void blo_lib_link_screen_restore(Main *newmain, bScreen *curscreen, Scene *cursc snode->id = restore_pointer_by_name(id_map, snode->id, USER_REAL); snode->from = restore_pointer_by_name(id_map, snode->from, USER_IGNORE); - if (snode->id) { - ntree = ntreeFromID(snode->id); - snode->nodetree = ntree ? ntree : - restore_pointer_by_name(id_map, (ID *)snode->nodetree, USER_REAL); - } + ntree = snode->id ? ntreeFromID(snode->id) : NULL; + snode->nodetree = ntree ? ntree : restore_pointer_by_name(id_map, (ID *)snode->nodetree, USER_REAL); for (path = snode->treepath.first; path; path = path->next) { if (path == snode->treepath.first) { @@ -7497,6 +7555,7 @@ static const char *dataname(short id_code) case ID_MC: return "Data from MC"; case ID_MSK: return "Data from MSK"; case ID_LS: return "Data from LS"; + case ID_CF: return "Data from CF"; } return "Data from Lib Block"; @@ -7745,6 +7804,9 @@ static BHead *read_libblock(FileData *fd, Main *main, BHead *bhead, const short case ID_PC: direct_link_paint_curve(fd, (PaintCurve *)id); break; + case ID_CF: + direct_link_cachefile(fd, (CacheFile *)id); + break; } oldnewmap_free_unused(fd->datamap); @@ -7937,6 +7999,7 @@ static void lib_link_all(FileData *fd, Main *main) lib_link_mask(fd, main); lib_link_linestyle(fd, main); lib_link_gpencil(fd, main); + lib_link_cachefiles(fd, main); lib_link_mesh(fd, main); /* as last: tpage images with users at zero */ @@ -8797,7 +8860,7 @@ static void expand_object(FileData *fd, Main *mainvar, Object *ob) expand_doit(fd, mainvar, ob->proxy); if (ob->proxy_group) expand_doit(fd, mainvar, ob->proxy_group); - + for (sens = ob->sensors.first; sens; sens = sens->next) { if (sens->type == SENS_MESSAGE) { bMessageSensor *ms = sens->data; @@ -8876,8 +8939,18 @@ static void expand_object(FileData *fd, Main *mainvar, Object *ob) } } - if (ob->pd && ob->pd->tex) + if (ob->pd) { expand_doit(fd, mainvar, ob->pd->tex); + expand_doit(fd, mainvar, ob->pd->f_source); + } + + if (ob->soft) { + expand_doit(fd, mainvar, ob->soft->collision_group); + + if (ob->soft->effector_weights) { + expand_doit(fd, mainvar, ob->soft->effector_weights->group); + } + } if (ob->rigidbody_constraint) { expand_doit(fd, mainvar, ob->rigidbody_constraint->ob1); @@ -8977,6 +9050,13 @@ static void expand_camera(FileData *fd, Main *mainvar, Camera *ca) expand_animdata(fd, mainvar, ca->adt); } +static void expand_cachefile(FileData *fd, Main *mainvar, CacheFile *cache_file) +{ + if (cache_file->adt) { + expand_animdata(fd, mainvar, cache_file->adt); + } +} + static void expand_speaker(FileData *fd, Main *mainvar, Speaker *spk) { expand_doit(fd, mainvar, spk->sound); @@ -9169,6 +9249,9 @@ void BLO_expand_main(void *fdhandle, Main *mainvar) case ID_GD: expand_gpencil(fd, mainvar, (bGPdata *)id); break; + case ID_CF: + expand_cachefile(fd, mainvar, (CacheFile *)id); + break; } do_it = true; diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c index f67ce629a00..c102140acda 100644 --- a/source/blender/blenloader/intern/versioning_270.c +++ b/source/blender/blenloader/intern/versioning_270.c @@ -62,6 +62,7 @@ #include "BKE_scene.h" #include "BKE_sequencer.h" #include "BKE_screen.h" +#include "BKE_gpencil.h" #include "BLI_math.h" #include "BLI_listbase.h" @@ -993,15 +994,6 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) } if (!MAIN_VERSION_ATLEAST(main, 277, 1)) { - /* init grease pencil smooth level iterations */ - for (bGPdata *gpd = main->gpencil.first; gpd; gpd = gpd->id.next) { - for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) { - if (gpl->draw_smoothlvl == 0) { - gpl->draw_smoothlvl = 1; - } - } - } - for (bScreen *screen = main->screen.first; screen; screen = screen->id.next) { for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { @@ -1110,7 +1102,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) for (Camera *camera = main->camera.first; camera != NULL; camera = camera->id.next) { if (camera->stereo.pole_merge_angle_from == 0.0f && - camera->stereo.pole_merge_angle_to == 0.0f) + camera->stereo.pole_merge_angle_to == 0.0f) { camera->stereo.pole_merge_angle_from = DEG2RADF(60.0f); camera->stereo.pole_merge_angle_to = DEG2RADF(75.0f); @@ -1149,5 +1141,96 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) br->flag |= BRUSH_ACCUMULATE; } } + + if (!DNA_struct_elem_find(fd->filesdna, "ClothSimSettings", "float", "time_scale")) { + Object *ob; + ModifierData *md; + for (ob = main->object.first; ob; ob = ob->id.next) { + for (md = ob->modifiers.first; md; md = md->next) { + if (md->type == eModifierType_Cloth) { + ClothModifierData *clmd = (ClothModifierData *)md; + clmd->sim_parms->time_scale = 1.0f; + } + } + } + } } + + if (!MAIN_VERSION_ATLEAST(main, 277, 3)) { + /* ------- init of grease pencil initialization --------------- */ + if (!DNA_struct_elem_find(fd->filesdna, "bGPDstroke", "bGPDpalettecolor", "palcolor")) { + for (Scene *scene = main->scene.first; scene; scene = scene->id.next) { + ToolSettings *ts = scene->toolsettings; + /* initialize use position for sculpt brushes */ + ts->gp_sculpt.flag |= GP_BRUSHEDIT_FLAG_APPLY_POSITION; + /* initialize selected vertices alpha factor */ + ts->gp_sculpt.alpha = 1.0f; + + /* new strength sculpt brush */ + if (ts->gp_sculpt.brush[0].size >= 11) { + GP_BrushEdit_Settings *gset = &ts->gp_sculpt; + GP_EditBrush_Data *brush; + + brush = &gset->brush[GP_EDITBRUSH_TYPE_STRENGTH]; + brush->size = 25; + brush->strength = 0.5f; + brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF; + } + } + /* create a default grease pencil drawing brushes set */ + if (!BLI_listbase_is_empty(&main->gpencil)) { + for (Scene *scene = main->scene.first; scene; scene = scene->id.next) { + ToolSettings *ts = scene->toolsettings; + if (BLI_listbase_is_empty(&ts->gp_brushes)) { + BKE_gpencil_brush_init_presets(ts); + } + } + } + /* Convert Grease Pencil to new palettes/brushes + * Loop all strokes and create the palette and all colors + */ + for (bGPdata *gpd = main->gpencil.first; gpd; gpd = gpd->id.next) { + if (BLI_listbase_is_empty(&gpd->palettes)) { + /* create palette */ + bGPDpalette *palette = BKE_gpencil_palette_addnew(gpd, "GP_Palette", true); + for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) { + /* create color using layer name */ + bGPDpalettecolor *palcolor = BKE_gpencil_palettecolor_addnew(palette, gpl->info, true); + if (palcolor != NULL) { + /* set color attributes */ + copy_v4_v4(palcolor->color, gpl->color); + copy_v4_v4(palcolor->fill, gpl->fill); + palcolor->flag = gpl->flag; + /* set layer opacity to 1 */ + gpl->opacity = 1.0f; + /* set tint color */ + ARRAY_SET_ITEMS(gpl->tintcolor, 0.0f, 0.0f, 0.0f, 0.0f); + + for (bGPDframe *gpf = gpl->frames.first; gpf; gpf = gpf->next) { + for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) { + /* set stroke to palette and force recalculation */ + strcpy(gps->colorname, gpl->info); + gps->palcolor = NULL; + gps->flag |= GP_STROKE_RECALC_COLOR; + gps->thickness = gpl->thickness; + /* set alpha strength to 1 */ + for (int i = 0; i < gps->totpoints; i++) { + gps->points[i].strength = 1.0f; + } + + } + } + } + /* set thickness to 0 (now it is a factor to override stroke thickness) */ + gpl->thickness = 0.0f; + } + /* set first color as active */ + if (palette->colors.first) + BKE_gpencil_palettecolor_setactive(palette, palette->colors.first); + } + } + } + /* ------- end of grease pencil initialization --------------- */ + } + } diff --git a/source/blender/blenloader/intern/versioning_defaults.c b/source/blender/blenloader/intern/versioning_defaults.c index 5798b62b689..01ef5d6a606 100644 --- a/source/blender/blenloader/intern/versioning_defaults.c +++ b/source/blender/blenloader/intern/versioning_defaults.c @@ -108,6 +108,11 @@ void BLO_update_defaults_startup_blend(Main *bmain) brush->strength = 0.5f; brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF; + brush = &gset->brush[GP_EDITBRUSH_TYPE_STRENGTH]; + brush->size = 25; + brush->strength = 0.5f; + brush->flag = GP_EDITBRUSH_FLAG_USE_FALLOFF; + brush = &gset->brush[GP_EDITBRUSH_TYPE_GRAB]; brush->size = 50; brush->strength = 0.3f; diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index c9f4858e545..12389dc1e7f 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -107,6 +107,7 @@ #include "DNA_armature_types.h" #include "DNA_actuator_types.h" #include "DNA_brush_types.h" +#include "DNA_cachefile_types.h" #include "DNA_camera_types.h" #include "DNA_cloth_types.h" #include "DNA_constraint_types.h" @@ -2445,6 +2446,20 @@ static void write_scenes(WriteData *wd, ListBase *scebase) writestruct(wd, DATA, UvSculpt, 1, tos->uvsculpt); write_paint(wd, &tos->uvsculpt->paint); } + /* write grease-pencil drawing brushes to file */ + writelist(wd, DATA, bGPDbrush, &tos->gp_brushes); + for (bGPDbrush *brush = tos->gp_brushes.first; brush; brush = brush->next) { + if (brush->cur_sensitivity) { + write_curvemapping(wd, brush->cur_sensitivity); + } + if (brush->cur_strength) { + write_curvemapping(wd, brush->cur_strength); + } + if (brush->cur_jitter) { + write_curvemapping(wd, brush->cur_jitter); + } + } + write_paint(wd, &tos->imapaint.paint); @@ -2606,6 +2621,7 @@ static void write_gpencils(WriteData *wd, ListBase *lb) bGPDlayer *gpl; bGPDframe *gpf; bGPDstroke *gps; + bGPDpalette *palette; for (gpd = lb->first; gpd; gpd = gpd->id.next) { if (gpd->id.us > 0 || wd->current) { @@ -2632,6 +2648,11 @@ static void write_gpencils(WriteData *wd, ListBase *lb) } } } + /* write grease-pencil palettes */ + writelist(wd, DATA, bGPDpalette, &gpd->palettes); + for (palette = gpd->palettes.first; palette; palette = palette->next) { + writelist(wd, DATA, bGPDpalettecolor, &palette->colors); + } } } @@ -3633,6 +3654,21 @@ static void write_linestyles(WriteData *wd, ListBase *idbase) } } +static void write_cachefiles(WriteData *wd, ListBase *idbase) +{ + CacheFile *cache_file; + + for (cache_file = idbase->first; cache_file; cache_file = cache_file->id.next) { + if (cache_file->id.us > 0 || wd->current) { + writestruct(wd, ID_CF, CacheFile, 1, cache_file); + + if (cache_file->adt) { + write_animdata(wd, cache_file->adt); + } + } + } +} + /* Keep it last of write_foodata functions. */ static void write_libraries(WriteData *wd, Main *main) { @@ -3829,6 +3865,7 @@ static bool write_file_handle( write_paintcurves(wd, &mainvar->paintcurves); write_gpencils(wd, &mainvar->gpencil); write_linestyles(wd, &mainvar->linestyle); + write_cachefiles(wd, &mainvar->cachefiles); write_libraries(wd, mainvar->next); /* So changes above don't cause a 'DNA1' to be detected as changed on undo. */ |