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 122 Lines • ▼ Show 20 Lines | |||||
| #include "BKE_depsgraph.h" | #include "BKE_depsgraph.h" | ||||
| #include "BKE_effect.h" | #include "BKE_effect.h" | ||||
| #include "BKE_fcurve.h" | #include "BKE_fcurve.h" | ||||
| #include "BKE_global.h" // for G | #include "BKE_global.h" // for G | ||||
| #include "BKE_group.h" | #include "BKE_group.h" | ||||
| #include "BKE_library.h" // for which_libbase | #include "BKE_library.h" // for which_libbase | ||||
| #include "BKE_library_idmap.h" | #include "BKE_library_idmap.h" | ||||
| #include "BKE_library_query.h" | #include "BKE_library_query.h" | ||||
| #include "BKE_localview.h" | |||||
| #include "BKE_idcode.h" | #include "BKE_idcode.h" | ||||
| #include "BKE_material.h" | #include "BKE_material.h" | ||||
| #include "BKE_main.h" // for Main | #include "BKE_main.h" // for Main | ||||
| #include "BKE_mesh.h" // for ME_ defines (patching) | #include "BKE_mesh.h" // for ME_ defines (patching) | ||||
| #include "BKE_modifier.h" | #include "BKE_modifier.h" | ||||
| #include "BKE_multires.h" | #include "BKE_multires.h" | ||||
| #include "BKE_node.h" // for tree type defines | #include "BKE_node.h" // for tree type defines | ||||
| #include "BKE_object.h" | #include "BKE_object.h" | ||||
| ▲ Show 20 Lines • Show All 6,149 Lines • ▼ Show 20 Lines | if (sc->id.tag & LIB_TAG_NEED_LINK) { | ||||
| BLI_addtail(&v3d->bgpicbase, bgpic); | BLI_addtail(&v3d->bgpicbase, bgpic); | ||||
| v3d->bgpic = NULL; | v3d->bgpic = NULL; | ||||
| } | } | ||||
| for (bgpic = v3d->bgpicbase.first; bgpic; bgpic = bgpic->next) { | for (bgpic = v3d->bgpicbase.first; bgpic; bgpic = bgpic->next) { | ||||
| bgpic->ima = newlibadr_us(fd, sc->id.lib, bgpic->ima); | bgpic->ima = newlibadr_us(fd, sc->id.lib, bgpic->ima); | ||||
| bgpic->clip = newlibadr_us(fd, sc->id.lib, bgpic->clip); | bgpic->clip = newlibadr_us(fd, sc->id.lib, bgpic->clip); | ||||
| } | } | ||||
| /* old localview data */ | |||||
| if (v3d->localvd) { | if (v3d->localvd) { | ||||
| v3d->localvd->camera = newlibadr(fd, sc->id.lib, v3d->localvd->camera); | 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); | |||||
| } | |||||
| } | } | ||||
| else if (sl->spacetype == SPACE_IPO) { | else if (sl->spacetype == SPACE_IPO) { | ||||
| SpaceIpo *sipo = (SpaceIpo *)sl; | SpaceIpo *sipo = (SpaceIpo *)sl; | ||||
| bDopeSheet *ads = sipo->ads; | bDopeSheet *ads = sipo->ads; | ||||
| if (ads) { | if (ads) { | ||||
| ads->source = newlibadr(fd, sc->id.lib, ads->source); | ads->source = newlibadr(fd, sc->id.lib, ads->source); | ||||
| ads->filter_grp = newlibadr(fd, sc->id.lib, ads->filter_grp); | ads->filter_grp = newlibadr(fd, sc->id.lib, ads->filter_grp); | ||||
| ▲ Show 20 Lines • Show All 294 Lines • ▼ Show 20 Lines | for (sa = sc->areabase.first; sa; sa = sa->next) { | ||||
| for (bgpic= v3d->bgpicbase.first; bgpic; bgpic= bgpic->next) { | for (bgpic= v3d->bgpicbase.first; bgpic; bgpic= bgpic->next) { | ||||
| if ((bgpic->ima = restore_pointer_by_name(id_map, (ID *)bgpic->ima, USER_IGNORE))) { | if ((bgpic->ima = restore_pointer_by_name(id_map, (ID *)bgpic->ima, USER_IGNORE))) { | ||||
| id_us_plus((ID *)bgpic->ima); | id_us_plus((ID *)bgpic->ima); | ||||
| } | } | ||||
| if ((bgpic->clip = restore_pointer_by_name(id_map, (ID *)bgpic->clip, USER_IGNORE))) { | if ((bgpic->clip = restore_pointer_by_name(id_map, (ID *)bgpic->clip, USER_IGNORE))) { | ||||
| id_us_plus((ID *)bgpic->clip); | id_us_plus((ID *)bgpic->clip); | ||||
| } | } | ||||
| } | } | ||||
| /* old localview data */ | |||||
| if (v3d->localvd) { | if (v3d->localvd) { | ||||
| v3d->localvd->camera = sc->scene->camera; | |||||
| } | |||||
| /* new localview data */ | |||||
| if (v3d->localviewd) { | |||||
| /*Base *base;*/ | /*Base *base;*/ | ||||
| v3d->localvd->camera = sc->scene->camera; | v3d->localviewd->camera = sc->scene->camera; | ||||
| /* localview can become invalid during undo/redo steps, so we exit it when no could be found */ | /* localview can become invalid during undo/redo steps, so we exit it when no could be found */ | ||||
| #if 0 /* XXX regionlocalview ? */ | #if 0 /* XXX regionlocalview ? */ | ||||
| for (base= sc->scene->base.first; base; base= base->next) { | for (base= sc->scene->base.first; base; base= base->next) { | ||||
| if (base->lay & v3d->lay) break; | if (base->lay & v3d->lay) break; | ||||
| } | } | ||||
| if (base==NULL) { | if (base==NULL) { | ||||
| v3d->lay= v3d->localvd->lay; | v3d->lay= v3d->localvd->lay; | ||||
| v3d->layact= v3d->localvd->layact; | v3d->layact= v3d->localvd->layact; | ||||
| ▲ Show 20 Lines • Show All 243 Lines • ▼ Show 20 Lines | if (spacetype == SPACE_EMPTY) { | ||||
| ar->regiondata = NULL; | ar->regiondata = NULL; | ||||
| } | } | ||||
| else { | else { | ||||
| ar->regiondata = newdataadr(fd, ar->regiondata); | ar->regiondata = newdataadr(fd, ar->regiondata); | ||||
| if (ar->regiondata) { | if (ar->regiondata) { | ||||
| if (spacetype == SPACE_VIEW3D) { | if (spacetype == SPACE_VIEW3D) { | ||||
| RegionView3D *rv3d = ar->regiondata; | RegionView3D *rv3d = ar->regiondata; | ||||
| /* old localview data */ | |||||
| rv3d->localvd = newdataadr(fd, rv3d->localvd); | rv3d->localvd = newdataadr(fd, rv3d->localvd); | ||||
| /* new localview data */ | |||||
| rv3d->localviewd = newdataadr(fd, rv3d->localviewd); | |||||
| rv3d->clipbb = newdataadr(fd, rv3d->clipbb); | rv3d->clipbb = newdataadr(fd, rv3d->clipbb); | ||||
| rv3d->depths = NULL; | rv3d->depths = NULL; | ||||
| rv3d->gpuoffscreen = NULL; | rv3d->gpuoffscreen = NULL; | ||||
| rv3d->render_engine = NULL; | rv3d->render_engine = NULL; | ||||
| rv3d->sms = NULL; | rv3d->sms = NULL; | ||||
| rv3d->smooth_timer = NULL; | rv3d->smooth_timer = NULL; | ||||
| rv3d->compositor = NULL; | rv3d->compositor = NULL; | ||||
| ▲ Show 20 Lines • Show All 138 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); | ||||
| } | } | ||||
| /* old localview data */ | |||||
| v3d->localvd = newdataadr(fd, v3d->localvd); | 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_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 2,720 Lines • ▼ Show 20 Lines | if ((ob->id.tag & LIB_TAG_INDIRECT) && (ob->id.tag & LIB_TAG_PRE_EXISTING) == 0) { | ||||
| if (do_it) { | if (do_it) { | ||||
| base = MEM_callocN(sizeof(Base), __func__); | base = MEM_callocN(sizeof(Base), __func__); | ||||
| BLI_addtail(&scene->base, base); | BLI_addtail(&scene->base, base); | ||||
| if (active_lay) { | if (active_lay) { | ||||
| ob->lay = active_lay; | ob->lay = active_lay; | ||||
| } | } | ||||
| /* Add to localview (only if FILE_ACTIVELAY, this is how it was | |||||
| * done when local view was using Object.lay bitfield) */ | |||||
| if (v3d && (flag & FILE_ACTIVELAY)) { | |||||
| /* function checks if v3d is in local view */ | |||||
| BKE_localview_object_assign(v3d, ob); | |||||
| } | |||||
| base->lay = ob->lay; | base->lay = ob->lay; | ||||
| base->object = ob; | base->object = ob; | ||||
| base->flag = ob->flag; | base->flag = ob->flag; | ||||
| CLAMP_MIN(ob->id.us, 0); | CLAMP_MIN(ob->id.us, 0); | ||||
| id_us_plus_no_lib((ID *)ob); | id_us_plus_no_lib((ID *)ob); | ||||
| Show All 17 Lines | for (group = mainvar->group.first; group; group = group->id.next) { | ||||
| if (group->id.tag & LIB_TAG_DOIT) { | if (group->id.tag & LIB_TAG_DOIT) { | ||||
| /* any indirect group should not have been tagged */ | /* any indirect group should not have been tagged */ | ||||
| BLI_assert((group->id.tag & LIB_TAG_INDIRECT) == 0); | BLI_assert((group->id.tag & LIB_TAG_INDIRECT) == 0); | ||||
| /* BKE_object_add(...) messes with the selection */ | /* BKE_object_add(...) messes with the selection */ | ||||
| ob = BKE_object_add_only_object(mainvar, OB_EMPTY, group->id.name + 2); | ob = BKE_object_add_only_object(mainvar, OB_EMPTY, group->id.name + 2); | ||||
| ob->type = OB_EMPTY; | ob->type = OB_EMPTY; | ||||
| ob->lay = active_lay; | ob->lay = active_lay; | ||||
| if (v3d) { | |||||
| /* Add to localview (function checks if v3d is in local view) */ | |||||
| BKE_localview_object_assign(v3d, ob); | |||||
| } | |||||
| /* assign the base */ | /* assign the base */ | ||||
| base = BKE_scene_base_add(scene, ob); | base = BKE_scene_base_add(scene, ob); | ||||
| base->flag |= SELECT; | base->flag |= SELECT; | ||||
| base->object->flag = base->flag; | base->object->flag = base->flag; | ||||
| DAG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); | DAG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); | ||||
| scene->basact = base; | scene->basact = base; | ||||
| ▲ Show 20 Lines • Show All 81 Lines • ▼ Show 20 Lines | if (scene) { | ||||
| base = MEM_callocN(sizeof(Base), "app_nam_part"); | base = MEM_callocN(sizeof(Base), "app_nam_part"); | ||||
| BLI_addtail(&scene->base, base); | BLI_addtail(&scene->base, base); | ||||
| ob = (Object *)id; | ob = (Object *)id; | ||||
| /* link at active layer (view3d if available in context, else scene one */ | /* link at active layer (view3d if available in context, else scene one */ | ||||
| if (flag & FILE_ACTIVELAY) { | if (flag & FILE_ACTIVELAY) { | ||||
| ob->lay = BKE_screen_view3d_layer_active(v3d, scene); | ob->lay = BKE_screen_view3d_layer_active(v3d, scene); | ||||
| /* Add to localview (only if FILE_ACTIVELAY, this is how it was | |||||
| * done when local view was using Object.lay bitfield) */ | |||||
| if (v3d) { | |||||
| /* function checks if v3d is in local view */ | |||||
| BKE_localview_object_assign(v3d, ob); | |||||
| } | |||||
| } | } | ||||
| ob->mode = OB_MODE_OBJECT; | ob->mode = OB_MODE_OBJECT; | ||||
| base->lay = ob->lay; | base->lay = ob->lay; | ||||
| base->object = ob; | base->object = ob; | ||||
| base->flag = ob->flag; | base->flag = ob->flag; | ||||
| id_us_plus_no_lib((ID *)ob); | id_us_plus_no_lib((ID *)ob); | ||||
| ▲ Show 20 Lines • Show All 497 Lines • Show Last 20 Lines | |||||