Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenloader/intern/readfile.c
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
| Show First 20 Lines • Show All 2,817 Lines • ▼ Show 20 Lines | |||||
| static void direct_link_workspace(FileData *fd, WorkSpace *workspace, const Main *main) | static void direct_link_workspace(FileData *fd, WorkSpace *workspace, const Main *main) | ||||
| { | { | ||||
| ID *workspace_id = (ID *)workspace; | ID *workspace_id = (ID *)workspace; | ||||
| ListBase *hook_layout_relations = BKE_workspace_hook_layout_relations_get(workspace); | ListBase *hook_layout_relations = BKE_workspace_hook_layout_relations_get(workspace); | ||||
| link_list(fd, BKE_workspace_layouts_get(workspace)); | link_list(fd, BKE_workspace_layouts_get(workspace)); | ||||
| link_list(fd, hook_layout_relations); | link_list(fd, hook_layout_relations); | ||||
| /* global, we need to update a pointer from this when reading screen too */ | |||||
| link_glob_list(fd, BKE_workspace_transform_orientations_get(workspace)); | |||||
| for (struct WorkSpaceDataRelation *relation = hook_layout_relations->first; | for (struct WorkSpaceDataRelation *relation = hook_layout_relations->first; | ||||
| relation; | relation; | ||||
| relation = (void *)((Link *)relation)->next) | relation = (void *)((Link *)relation)->next) | ||||
| { | { | ||||
| void *parent, *data; | void *parent, *data; | ||||
| BKE_workspace_relation_data_get(relation, &parent, &data); | BKE_workspace_relation_data_get(relation, &parent, &data); | ||||
| parent = newglobadr(fd, parent); /* data from window - need to access through global oldnew-map */ | parent = newglobadr(fd, parent); /* data from window - need to access through global oldnew-map */ | ||||
| data = newdataadr(fd, data); | data = newdataadr(fd, data); | ||||
| BKE_workspace_relation_data_set(relation, parent, data); | BKE_workspace_relation_data_set(relation, parent, data); | ||||
| } | } | ||||
| if (ID_IS_LINKED_DATABLOCK(workspace_id)) { | if (ID_IS_LINKED_DATABLOCK(workspace_id)) { | ||||
| /* Appending workspace so render layer is likely from a different scene. Unset | /* Appending workspace so render layer is likely from a different scene. Unset | ||||
| * now, when activating workspace later we set a valid one from current scene. */ | * now, when activating workspace later we set a valid one from current scene. */ | ||||
| BKE_workspace_render_layer_set(workspace, NULL); | BKE_workspace_render_layer_set(workspace, NULL); | ||||
| } | } | ||||
| /* Same issue/fix as in direct_link_scene_update_screen_data: Can't read workspace data | /* Same issue/fix as in direct_link_workspace_link_scene_data: Can't read workspace data | ||||
| * when reading windows, so have to update windows after/when reading workspaces. */ | * when reading windows, so have to update windows after/when reading workspaces. */ | ||||
| for (wmWindowManager *wm = main->wm.first; wm; wm = wm->id.next) { | for (wmWindowManager *wm = main->wm.first; wm; wm = wm->id.next) { | ||||
| for (wmWindow *win = wm->windows.first; win; win = win->next) { | for (wmWindow *win = wm->windows.first; win; win = win->next) { | ||||
| WorkSpaceLayout *act_layout = newdataadr(fd, BKE_workspace_active_layout_get(win->workspace_hook)); | WorkSpaceLayout *act_layout = newdataadr(fd, BKE_workspace_active_layout_get(win->workspace_hook)); | ||||
| if (act_layout) { | if (act_layout) { | ||||
| BKE_workspace_active_layout_set(win->workspace_hook, act_layout); | BKE_workspace_active_layout_set(win->workspace_hook, act_layout); | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 3,265 Lines • ▼ Show 20 Lines | for (LayerCollection *lc = lb->first; lc; lc = lc->next) { | ||||
| } | } | ||||
| lc->properties_evaluated = NULL; | lc->properties_evaluated = NULL; | ||||
| direct_link_layer_collections(fd, &lc->layer_collections); | direct_link_layer_collections(fd, &lc->layer_collections); | ||||
| } | } | ||||
| } | } | ||||
| /** | /** | ||||
| * bScreen data may use pointers to Scene data. We can't read this when reading screens | * Workspaces store a render layer pointer which can only be read after scene is read. | ||||
| * though, so we have to update screens when/after reading scenes. This function should | |||||
| * be called during Scene direct linking to update needed pointers within screen data | |||||
| * (as in everything visible in the window, not just bScreen). | |||||
| * | |||||
| * Maybe we could change read order so that screens are read after scene. But guess that | |||||
| * would be asking for trouble. Depending on the write/read order sounds ugly anyway, | |||||
| * Workspaces already depend on it... | |||||
| * -- Julian | |||||
| */ | */ | ||||
| static void direct_link_scene_update_screen_data( | static void direct_link_workspace_link_scene_data( | ||||
| FileData *fd, const Scene *scene, const ListBase *workspaces, const ListBase *screens) | FileData *fd, const Scene *scene, const ListBase *workspaces) | ||||
| { | { | ||||
| BKE_WORKSPACE_ITER_BEGIN (workspace, workspaces->first) { | BKE_WORKSPACE_ITER_BEGIN (workspace, workspaces->first) { | ||||
| SceneLayer *layer = newdataadr(fd, BKE_workspace_render_layer_get(workspace)); | SceneLayer *layer = newdataadr(fd, BKE_workspace_render_layer_get(workspace)); | ||||
| /* only set when layer is from the scene we read */ | /* only set when layer is from the scene we read */ | ||||
| if (layer && (BLI_findindex(&scene->render_layers, layer) != -1)) { | if (layer && (BLI_findindex(&scene->render_layers, layer) != -1)) { | ||||
| BKE_workspace_render_layer_set(workspace, layer); | BKE_workspace_render_layer_set(workspace, layer); | ||||
| } | } | ||||
| } BKE_WORKSPACE_ITER_END; | } BKE_WORKSPACE_ITER_END; | ||||
| for (bScreen *screen = screens->first; screen; screen = screen->id.next) { | |||||
| for (ScrArea *area = screen->areabase.first; area; area = area->next) { | |||||
| for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { | |||||
| if (sl->spacetype == SPACE_VIEW3D) { | |||||
| View3D *v3d = (View3D *)sl; | |||||
| if (v3d->custom_orientation) { | |||||
| v3d->custom_orientation = newdataadr(fd, v3d->custom_orientation); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| } | } | ||||
| static void direct_link_scene(FileData *fd, Scene *sce, Main *bmain) | static void direct_link_scene(FileData *fd, Scene *sce, Main *bmain) | ||||
| { | { | ||||
| Editing *ed; | Editing *ed; | ||||
| Sequence *seq; | Sequence *seq; | ||||
| MetaStack *ms; | MetaStack *ms; | ||||
| RigidBodyWorld *rbw; | RigidBodyWorld *rbw; | ||||
| ▲ Show 20 Lines • Show All 198 Lines • ▼ Show 20 Lines | if (sce->r.qtcodecdata) { | ||||
| sce->r.qtcodecdata->cdParms = newdataadr(fd, sce->r.qtcodecdata->cdParms); | sce->r.qtcodecdata->cdParms = newdataadr(fd, sce->r.qtcodecdata->cdParms); | ||||
| } | } | ||||
| if (sce->r.ffcodecdata.properties) { | if (sce->r.ffcodecdata.properties) { | ||||
| sce->r.ffcodecdata.properties = newdataadr(fd, sce->r.ffcodecdata.properties); | sce->r.ffcodecdata.properties = newdataadr(fd, sce->r.ffcodecdata.properties); | ||||
| IDP_DirectLinkGroup_OrFree(&sce->r.ffcodecdata.properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd); | IDP_DirectLinkGroup_OrFree(&sce->r.ffcodecdata.properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd); | ||||
| } | } | ||||
| link_list(fd, &(sce->markers)); | link_list(fd, &(sce->markers)); | ||||
| link_list(fd, &(sce->transform_spaces)); | |||||
| link_list(fd, &(sce->r.layers)); | link_list(fd, &(sce->r.layers)); | ||||
| link_list(fd, &(sce->r.views)); | link_list(fd, &(sce->r.views)); | ||||
| for (srl = sce->r.layers.first; srl; srl = srl->next) { | for (srl = sce->r.layers.first; srl; srl = srl->next) { | ||||
| srl->prop = newdataadr(fd, srl->prop); | srl->prop = newdataadr(fd, srl->prop); | ||||
| IDP_DirectLinkGroup_OrFree(&srl->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd); | IDP_DirectLinkGroup_OrFree(&srl->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 67 Lines • ▼ Show 20 Lines | static void direct_link_scene(FileData *fd, Scene *sce, Main *bmain) | ||||
| IDP_DirectLinkGroup_OrFree(&sce->collection_properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd); | IDP_DirectLinkGroup_OrFree(&sce->collection_properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd); | ||||
| sce->layer_properties = newdataadr(fd, sce->layer_properties); | sce->layer_properties = newdataadr(fd, sce->layer_properties); | ||||
| IDP_DirectLinkGroup_OrFree(&sce->layer_properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd); | IDP_DirectLinkGroup_OrFree(&sce->layer_properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd); | ||||
| BKE_layer_collection_engine_settings_validate_scene(sce); | BKE_layer_collection_engine_settings_validate_scene(sce); | ||||
| BKE_scene_layer_engine_settings_validate_scene(sce); | BKE_scene_layer_engine_settings_validate_scene(sce); | ||||
| direct_link_scene_update_screen_data(fd, sce, &bmain->workspaces, &bmain->screen); | direct_link_workspace_link_scene_data(fd, sce, &bmain->workspaces); | ||||
| } | } | ||||
| /* ************ READ WM ***************** */ | /* ************ READ WM ***************** */ | ||||
| static void direct_link_windowmanager(FileData *fd, wmWindowManager *wm) | static void direct_link_windowmanager(FileData *fd, wmWindowManager *wm) | ||||
| { | { | ||||
| wmWindow *win; | wmWindow *win; | ||||
| ▲ Show 20 Lines • Show All 975 Lines • ▼ Show 20 Lines | for (sl = sa->spacedata.first; sl; sl = sl->next) { | ||||
| for (bgpic = v3d->bgpicbase.first; bgpic; bgpic = bgpic->next) | for (bgpic = v3d->bgpicbase.first; bgpic; bgpic = bgpic->next) | ||||
| bgpic->iuser.ok = 1; | bgpic->iuser.ok = 1; | ||||
| if (v3d->gpd) { | if (v3d->gpd) { | ||||
| v3d->gpd = newdataadr(fd, v3d->gpd); | v3d->gpd = newdataadr(fd, v3d->gpd); | ||||
| direct_link_gpencil(fd, v3d->gpd); | direct_link_gpencil(fd, v3d->gpd); | ||||
| } | } | ||||
| v3d->localvd = newdataadr(fd, v3d->localvd); | v3d->localvd = newdataadr(fd, v3d->localvd); | ||||
| /* direct_link_workspace read this and inserted into global map - get new pointer from there */ | |||||
| v3d->custom_orientation = newglobadr(fd, v3d->custom_orientation); | |||||
| BLI_listbase_clear(&v3d->afterdraw_transp); | BLI_listbase_clear(&v3d->afterdraw_transp); | ||||
| BLI_listbase_clear(&v3d->afterdraw_xray); | BLI_listbase_clear(&v3d->afterdraw_xray); | ||||
| BLI_listbase_clear(&v3d->afterdraw_xraytransp); | BLI_listbase_clear(&v3d->afterdraw_xraytransp); | ||||
| v3d->properties_storage = NULL; | v3d->properties_storage = NULL; | ||||
| v3d->defmaterial = NULL; | v3d->defmaterial = NULL; | ||||
| /* render can be quite heavy, set to solid on load */ | /* render can be quite heavy, set to solid on load */ | ||||
| if (v3d->drawtype == OB_RENDER) | if (v3d->drawtype == OB_RENDER) | ||||
| ▲ Show 20 Lines • Show All 3,518 Lines • Show Last 20 Lines | |||||