[Bf-blender-cvs] [3ae44ff] temp_localview_split: Compatibility with old local view storage
Julian Eisel
noreply at git.blender.org
Wed Jul 27 01:08:02 CEST 2016
Commit: 3ae44ffa9a8f0dc66561e8abf57c721b96320aa6
Author: Julian Eisel
Date: Wed Jul 27 01:06:44 2016 +0200
Branches: temp_localview_split
https://developer.blender.org/rB3ae44ffa9a8f0dc66561e8abf57c721b96320aa6
Compatibility with old local view storage
Reading old .blends works just fine now.
===================================================================
M source/blender/blenloader/intern/readfile.c
M source/blender/blenloader/intern/versioning_270.c
===================================================================
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index f538087..db101f1 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -6245,6 +6245,11 @@ static void lib_link_screen(FileData *fd, Main *main)
bgpic->ima = newlibadr_us(fd, sc->id.lib, bgpic->ima);
bgpic->clip = newlibadr_us(fd, sc->id.lib, bgpic->clip);
}
+ /* old localview data */
+ if (v3d->localvd) {
+ v3d->localvd->camera = newlibadr(fd, sc->id.lib, v3d->localvd->camera);
+ }
+ /* new localview data */
if (v3d->localviewd) {
v3d->localviewd->camera = newlibadr(fd, sc->id.lib, v3d->localviewd->camera);
}
@@ -6565,6 +6570,9 @@ void blo_lib_link_screen_restore(Main *newmain, bScreen *curscreen, Scene *cursc
if (v3d->localviewd) {
/*Base *base;*/
+ /* old localview data */
+ v3d->localvd->camera = sc->scene->camera;
+ /* new localview data */
v3d->localviewd->camera = sc->scene->camera;
/* localview can become invalid during undo/redo steps, so we exit it when no could be found */
@@ -6829,7 +6837,11 @@ static void direct_link_region(FileData *fd, ARegion *ar, int spacetype)
if (spacetype == SPACE_VIEW3D) {
RegionView3D *rv3d = ar->regiondata;
+ /* old localview data */
+ rv3d->localvd = newdataadr(fd, rv3d->localvd);
+ /* new localview data */
rv3d->localviewd = newdataadr(fd, rv3d->localviewd);
+
rv3d->clipbb = newdataadr(fd, rv3d->clipbb);
rv3d->depths = NULL;
@@ -6984,7 +6996,12 @@ static bool direct_link_screen(FileData *fd, bScreen *sc)
v3d->gpd = newdataadr(fd, v3d->gpd);
direct_link_gpencil(fd, v3d->gpd);
}
+
+ /* old localview data */
+ v3d->localvd = newdataadr(fd, v3d->localvd);
+ /* new localview data */
v3d->localviewd = newdataadr(fd, v3d->localviewd);
+
BLI_listbase_clear(&v3d->afterdraw_transp);
BLI_listbase_clear(&v3d->afterdraw_xray);
BLI_listbase_clear(&v3d->afterdraw_xraytransp);
diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c
index ac2811a..004bc84 100644
--- a/source/blender/blenloader/intern/versioning_270.c
+++ b/source/blender/blenloader/intern/versioning_270.c
@@ -172,6 +172,45 @@ static void do_version_bones_super_bbone(ListBase *lb)
}
}
+static void do_version_localview_regiondata(RegionView3D *rv3d)
+{
+ RegionView3D *old_lvd = rv3d->localvd;
+ if (!old_lvd) {
+ return;
+ }
+
+ LocalViewRegionData *new_lvd = MEM_mallocN(sizeof(*rv3d->localviewd), __func__);
+ new_lvd->camzoom = old_lvd->camzoom;
+ new_lvd->persp = old_lvd->persp;
+ new_lvd->view = old_lvd->view;
+ new_lvd->dist = old_lvd->dist;
+ copy_qt_qt(new_lvd->viewquat, old_lvd->viewquat);
+ copy_v3_v3(new_lvd->ofs, old_lvd->ofs);
+
+ rv3d->localviewd = new_lvd;
+ /* remove old data */
+ MEM_freeN(rv3d->localvd);
+}
+
+static void do_version_localview_areadata(View3D *v3d)
+{
+ View3D *old_lvd = v3d->localvd;
+ if (!old_lvd) {
+ return;
+ }
+
+ LocalViewAreaData *new_lvd = MEM_mallocN(sizeof(*v3d->localviewd), __func__);
+ new_lvd->viewbits = 0; /* XXX */
+ new_lvd->near = old_lvd->near;
+ new_lvd->far = old_lvd->far;
+ new_lvd->drawtype = old_lvd->drawtype;
+ new_lvd->camera = old_lvd->camera;
+
+ v3d->localviewd = new_lvd;
+ /* remove old data */
+ MEM_freeN(v3d->localvd);
+}
+
void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
{
if (!MAIN_VERSION_ATLEAST(main, 270, 0)) {
@@ -1226,4 +1265,23 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
}
+
+ {
+ if (!DNA_struct_elem_find(fd->filesdna, "View3D", "LocalViewAreaData", "localviewd")) {
+ 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) {
+ if (sl->spacetype == SPACE_VIEW3D) {
+ do_version_localview_areadata((View3D *)sl);
+ for (ARegion *ar = sa->regionbase.first; ar; ar = ar->next) {
+ if (ar->regiontype == RGN_TYPE_WINDOW) {
+ do_version_localview_regiondata(ar->regiondata);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
}
More information about the Bf-blender-cvs
mailing list