[Bf-blender-cvs] [cecd4fe2548] blender2.8: Merge branch 'master' into blender2.8
Campbell Barton
noreply at git.blender.org
Mon Dec 10 02:44:53 CET 2018
Commit: cecd4fe2548c57d3ef11010e039410b793b675dd
Author: Campbell Barton
Date: Mon Dec 10 12:44:24 2018 +1100
Branches: blender2.8
https://developer.blender.org/rBcecd4fe2548c57d3ef11010e039410b793b675dd
Merge branch 'master' into blender2.8
===================================================================
===================================================================
diff --cc source/blender/blenloader/intern/readfile.c
index e88f75205c7,ddbe855d03e..6e0a14ff469
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@@ -6525,666 -6270,6 +6525,666 @@@ static void direct_link_scene(FileData
sce->preview = direct_link_preview_image(fd, sce->preview);
direct_link_curvemapping(fd, &sce->r.mblur_shutter_curve);
+
+#ifdef USE_COLLECTION_COMPAT_28
+ /* this runs before the very first doversion */
+ if (sce->collection) {
+ sce->collection = newdataadr(fd, sce->collection);
+ direct_link_scene_collection(fd, sce->collection);
+ }
+#endif
+
+ if (sce->master_collection) {
+ sce->master_collection = newdataadr(fd, sce->master_collection);
+ direct_link_collection(fd, sce->master_collection);
+ /* Needed because this is an ID outside of Main. */
+ sce->master_collection->id.py_instance = NULL;
+ }
+
+ /* insert into global old-new map for reading without UI (link_global accesses it again) */
+ link_glob_list(fd, &sce->view_layers);
+ for (view_layer = sce->view_layers.first; view_layer; view_layer = view_layer->next) {
+ direct_link_view_layer(fd, view_layer);
+ }
+
+ if (fd->memfile) {
+ /* If it's undo try to recover the cache. */
+ if (fd->scenemap) sce->eevee.light_cache = newsceadr(fd, sce->eevee.light_cache);
+ else sce->eevee.light_cache = NULL;
+ }
+ else {
+ /* else try to read the cache from file. */
+ sce->eevee.light_cache = newdataadr(fd, sce->eevee.light_cache);
+ if (sce->eevee.light_cache) {
+ direct_link_lightcache(fd, sce->eevee.light_cache);
+ }
+ }
+
+ sce->layer_properties = newdataadr(fd, sce->layer_properties);
+ IDP_DirectLinkGroup_OrFree(&sce->layer_properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
+}
+
+/* ****************** READ GREASE PENCIL ***************** */
+
+/* relink's grease pencil data's refs */
+static void lib_link_gpencil(FileData *fd, Main *main)
+{
+ /* Relink all datablock linked by GP datablock */
+ for (bGPdata *gpd = main->gpencil.first; gpd; gpd = gpd->id.next) {
+ if (gpd->id.tag & LIB_TAG_NEED_LINK) {
+ /* Layers */
+ for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
+ /* Layer -> Parent References */
+ gpl->parent = newlibadr(fd, gpd->id.lib, gpl->parent);
+ }
+
+ /* Datablock Stuff */
+ IDP_LibLinkProperty(gpd->id.properties, fd);
+ lib_link_animdata(fd, &gpd->id, gpd->adt);
+
+ /* materials */
+ for (int a = 0; a < gpd->totcol; a++) {
+ gpd->mat[a] = newlibadr_us(fd, gpd->id.lib, gpd->mat[a]);
+ }
+
+ gpd->id.tag &= ~LIB_TAG_NEED_LINK;
+ }
+ }
+}
+
+/* relinks grease-pencil data - used for direct_link and old file linkage */
+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;
+
+ /* relink animdata */
+ gpd->adt = newdataadr(fd, gpd->adt);
+ direct_link_animdata(fd, gpd->adt);
+
+ /* relink palettes (old palettes deprecated, only to convert old files) */
+ link_list(fd, &gpd->palettes);
+ if (gpd->palettes.first != NULL) {
+ for (palette = gpd->palettes.first; palette; palette = palette->next) {
+ link_list(fd, &palette->colors);
+ }
+ }
+
+ /* materials */
+ gpd->mat = newdataadr(fd, gpd->mat);
+ test_pointer_array(fd, (void **)&gpd->mat);
+
+ /* relink layers */
+ link_list(fd, &gpd->layers);
+
+ for (gpl = gpd->layers.first; gpl; gpl = gpl->next) {
+ /* relink frames */
+ link_list(fd, &gpl->frames);
+
+ gpl->actframe = newdataadr(fd, gpl->actframe);
+
+ gpl->runtime.icon_id = 0;
+
+ for (gpf = gpl->frames.first; gpf; gpf = gpf->next) {
+ /* relink strokes (and their points) */
+ link_list(fd, &gpf->strokes);
+
+ for (gps = gpf->strokes.first; gps; gps = gps->next) {
+ /* relink stroke points array */
+ gps->points = newdataadr(fd, gps->points);
+
+ /* relink weight data */
+ if (gps->dvert) {
+ gps->dvert = newdataadr(fd, gps->dvert);
+ direct_link_dverts(fd, gps->totpoints, gps->dvert);
+ }
+
+ /* the triangulation is not saved, so need to be recalculated */
+ gps->triangles = NULL;
+ gps->tot_triangles = 0;
+ gps->flag |= GP_STROKE_RECALC_CACHES;
+ }
+ }
+ }
+}
+
+/* *********** READ AREA **************** */
+
+static void direct_link_panel_list(FileData *fd, ListBase *lb)
+{
+ link_list(fd, lb);
+
+ for (Panel *pa = lb->first; pa; pa = pa->next) {
+ pa->paneltab = newdataadr(fd, pa->paneltab);
+ pa->runtime_flag = 0;
+ pa->activedata = NULL;
+ pa->type = NULL;
+ direct_link_panel_list(fd, &pa->children);
+ }
+}
+
+static void direct_link_region(FileData *fd, ARegion *ar, int spacetype)
+{
+ uiList *ui_list;
+
+ direct_link_panel_list(fd, &ar->panels);
+
+ link_list(fd, &ar->panels_category_active);
+
+ link_list(fd, &ar->ui_lists);
+
+ for (ui_list = ar->ui_lists.first; ui_list; ui_list = ui_list->next) {
+ ui_list->type = NULL;
+ ui_list->dyn_data = NULL;
+ ui_list->properties = newdataadr(fd, ui_list->properties);
+ IDP_DirectLinkGroup_OrFree(&ui_list->properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
+ }
+
+ link_list(fd, &ar->ui_previews);
+
+ if (spacetype == SPACE_EMPTY) {
+ /* unkown space type, don't leak regiondata */
+ ar->regiondata = NULL;
+ }
+ else if (ar->flag & RGN_FLAG_TEMP_REGIONDATA) {
+ /* Runtime data, don't use. */
+ ar->regiondata = NULL;
+ }
+ else {
+ ar->regiondata = newdataadr(fd, ar->regiondata);
+ if (ar->regiondata) {
+ if (spacetype == SPACE_VIEW3D) {
+ RegionView3D *rv3d = ar->regiondata;
+
+ rv3d->localvd = newdataadr(fd, rv3d->localvd);
+ rv3d->clipbb = newdataadr(fd, rv3d->clipbb);
+
+ rv3d->depths = NULL;
+ rv3d->gpuoffscreen = NULL;
+ rv3d->render_engine = NULL;
+ rv3d->sms = NULL;
+ rv3d->smooth_timer = NULL;
+ }
+ }
+ }
+
+ ar->v2d.tab_offset = NULL;
+ ar->v2d.tab_num = 0;
+ ar->v2d.tab_cur = 0;
+ ar->v2d.sms = NULL;
+ ar->v2d.alpha_hor = ar->v2d.alpha_vert = 255; /* visible by default */
+ BLI_listbase_clear(&ar->panels_category);
+ BLI_listbase_clear(&ar->handlers);
+ BLI_listbase_clear(&ar->uiblocks);
+ ar->headerstr = NULL;
+ ar->visible = 0;
+ ar->type = NULL;
+ ar->do_draw = 0;
+ ar->gizmo_map = NULL;
+ ar->regiontimer = NULL;
+ ar->draw_buffer = NULL;
+ memset(&ar->drawrct, 0, sizeof(ar->drawrct));
+}
+
+static void direct_link_area(FileData *fd, ScrArea *area)
+{
+ SpaceLink *sl;
+ ARegion *ar;
+
+ link_list(fd, &(area->spacedata));
+ link_list(fd, &(area->regionbase));
+
+ BLI_listbase_clear(&area->handlers);
+ area->type = NULL; /* spacetype callbacks */
+ area->butspacetype = SPACE_EMPTY; /* Should always be unset so that rna_Area_type_get works correctly */
+ area->region_active_win = -1;
+
+ area->flag &= ~AREA_FLAG_ACTIVE_TOOL_UPDATE;
+
+ area->global = newdataadr(fd, area->global);
+
+ /* if we do not have the spacetype registered we cannot
+ * free it, so don't allocate any new memory for such spacetypes. */
+ if (!BKE_spacetype_exists(area->spacetype)) {
+ area->butspacetype = area->spacetype; /* Hint for versioning code to replace deprecated space types. */
+ area->spacetype = SPACE_EMPTY;
+ }
+
+ for (ar = area->regionbase.first; ar; ar = ar->next) {
+ direct_link_region(fd, ar, area->spacetype);
+ }
+
+ /* accident can happen when read/save new file with older version */
+ /* 2.50: we now always add spacedata for info */
+ if (area->spacedata.first == NULL) {
+ SpaceInfo *sinfo = MEM_callocN(sizeof(SpaceInfo), "spaceinfo");
+ area->spacetype = sinfo->spacetype = SPACE_INFO;
+ BLI_addtail(&area->spacedata, sinfo);
+ }
+ /* add local view3d too */
+ else if (area->spacetype == SPACE_VIEW3D) {
+ blo_do_versions_view3d_split_250(area->spacedata.first, &area->regionbase);
+ }
+
+ for (sl = area->spacedata.first; sl; sl = sl->next) {
+ link_list(fd, &(sl->regionbase));
+
+ /* if we do not have the spacetype registered we cannot
+ * free it, so don't allocate any new memory for such spacetypes. */
+ if (!BKE_spacetype_exists(sl->spacetype))
+ sl->spacetype = SPACE_EMPTY;
+
+ for (ar = sl->regionbase.first; ar; ar = ar->next)
+ direct_link_region(fd, ar, sl->spacetype);
+
+ if (sl->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = (View3D *)sl;
+
+ v3d->flag |= V3D_INVALID_BACKBUF;
+
+ if (v3d->gpd) {
+ v3d->gpd = newdataadr(fd, v3d->gpd);
+ direct_link_gpencil(fd, v3d->gpd);
+ }
+ v3d->localvd = newdataadr(fd, v3d->localvd);
+ v3d->properties_storage = NULL;
+
+ /* render can be quite heavy, set to solid on load */
+ if (v3d->shading.type == OB_RENDER) {
+ v3d->shading.type = OB_SOLID;
+ }
+ v3d->shading.prev_type = OB_SOLID;
+
+ if (v3d->fx_settings.dof)
+ v3d->fx_settings.dof = newdataadr(fd, v3d->fx_settings.dof);
+ if (v3d->fx_settings.ssao)
+ v3d->fx_settings.ssao = newdataadr(fd, v3d->fx_settings.ssao);
+
+ blo_do_versions_view3d_split_250(v3d, &sl->regionbase);
+ }
+ else if (sl->spacetype == SPACE_IPO) {
+ SpaceIpo *sipo = (SpaceIpo *)sl;
+
+ sipo->ads = newdataadr(fd, sipo->ads);
- BLI_listbase_clear(&sipo->ghostCurves);
++ BLI_listbase_clear(&sipo->runtime.ghost_curves);
+ }
+ else if (sl->spacetype == SPACE_NLA) {
+ SpaceNla *snla = (SpaceNla *)sl;
+
+ snla->ads = newdataadr(fd, snla->ads);
+ }
+ else if (sl->spacetype == SPACE_OUTLINER) {
+ SpaceOops *soops = (SpaceOops *)sl;
+
+ /* use newdataadr_no_us and do not free old memory avoiding double
+ * frees and use of freed memory. this could happen because of a
+ * bug fixed in revision 58959 where the treestore memory address
+ * was not unique */
+ TreeStore *ts = newdataadr_no_us(fd, soops->treestore);
+ soops->treestore = NULL;
+ if (ts) {
+ TreeStoreElem *elems = newdataadr_no_us(fd, ts->data);
+
+ soops->treestore = BLI_mempool_create(sizeof(TreeStoreElem), ts->usedelem,
+ 512, BLI_MEMPOOL_ALLOW_ITER)
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list