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 1,784 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| /* only lib data */ | /* only lib data */ | ||||
| void *blo_do_versions_newlibadr(FileData *fd, const void *lib, const void *adr) | void *blo_do_versions_newlibadr(FileData *fd, const void *lib, const void *adr) | ||||
| { | { | ||||
| return newlibadr(fd, lib, adr); | return newlibadr(fd, lib, adr); | ||||
| } | } | ||||
| /* increases user number */ | /* increases user number */ | ||||
| static void *newlibadr_us(FileData *fd, const void *lib, const void *adr) | static void *newlibadr_us(FileData *fd, const void *lib, const void *adr) | ||||
| { | { | ||||
| ID *id = newlibadr(fd, lib, adr); | ID *id = newlibadr(fd, lib, adr); | ||||
| id_us_plus_no_lib(id); | id_us_plus_no_lib(id); | ||||
| return id; | return id; | ||||
| } | } | ||||
mont29: Note that that one is kept because used by deprecated pointers (IPO ones)... Not sure how… | |||||
brechtUnsubmitted Done Inline ActionsIf we do need this function still, probably best to rename this to something like newlibadr_us_deprecated and add a comment. brecht: If we do need this function still, probably best to rename this to something like… | |||||
mont29AuthorUnsubmitted Done Inline ActionsYeah, wouldn't mind removing it completely too, will try that then. mont29: Yeah, wouldn't mind removing it completely too, will try that then. | |||||
| /* increases user number */ | /* increases user number */ | ||||
| void *blo_do_versions_newlibadr_us(FileData *fd, const void *lib, const void *adr) | void *blo_do_versions_newlibadr_us(FileData *fd, const void *lib, const void *adr) | ||||
| { | { | ||||
| return newlibadr_us(fd, lib, adr); | return newlibadr_us(fd, lib, adr); | ||||
| } | } | ||||
| /* ensures real user */ | |||||
| static void *newlibadr_real_us(FileData *fd, const void *lib, const void *adr) | |||||
| { | |||||
| ID *id = newlibadr(fd, lib, adr); | |||||
| id_us_ensure_real(id); | |||||
| return id; | |||||
| } | |||||
| static void change_link_placeholder_to_real_ID_pointer_fd(FileData *fd, const void *old, void *new) | static void change_link_placeholder_to_real_ID_pointer_fd(FileData *fd, const void *old, void *new) | ||||
| { | { | ||||
| for (int i = 0; i < fd->libmap->nentries; i++) { | for (int i = 0; i < fd->libmap->nentries; i++) { | ||||
| OldNew *entry = &fd->libmap->entries[i]; | OldNew *entry = &fd->libmap->entries[i]; | ||||
| if (old == entry->newp && entry->nr == ID_LINK_PLACEHOLDER) { | if (old == entry->newp && entry->nr == ID_LINK_PLACEHOLDER) { | ||||
| entry->newp = new; | entry->newp = new; | ||||
| if (new) { | if (new) { | ||||
| ▲ Show 20 Lines • Show All 726 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| if (!prop) { | if (!prop) { | ||||
| return; | return; | ||||
| } | } | ||||
| switch (prop->type) { | switch (prop->type) { | ||||
| case IDP_ID: /* PointerProperty */ | case IDP_ID: /* PointerProperty */ | ||||
| { | { | ||||
| void *newaddr = newlibadr_us(fd, NULL, IDP_Id(prop)); | void *newaddr = newlibadr(fd, NULL, IDP_Id(prop)); | ||||
| if (IDP_Id(prop) && !newaddr && G.debug) { | if (IDP_Id(prop) && !newaddr && G.debug) { | ||||
| printf("Error while loading \"%s\". Data not found in file!\n", prop->name); | printf("Error while loading \"%s\". Data not found in file!\n", prop->name); | ||||
| } | } | ||||
| prop->data.pointer = newaddr; | prop->data.pointer = newaddr; | ||||
| break; | break; | ||||
| } | } | ||||
| case IDP_IDPARRAY: /* CollectionProperty */ | case IDP_IDPARRAY: /* CollectionProperty */ | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 75 Lines • ▼ Show 20 Lines | static void lib_link_id(FileData *fd, Main *bmain, ID *id) | ||||
| IDP_LibLinkProperty(id->properties, fd); | IDP_LibLinkProperty(id->properties, fd); | ||||
| AnimData *adt = BKE_animdata_from_id(id); | AnimData *adt = BKE_animdata_from_id(id); | ||||
| if (adt != NULL) { | if (adt != NULL) { | ||||
| lib_link_animdata(fd, id, adt); | lib_link_animdata(fd, id, adt); | ||||
| } | } | ||||
| if (id->override_library) { | if (id->override_library) { | ||||
| id->override_library->reference = newlibadr_us(fd, id->lib, id->override_library->reference); | id->override_library->reference = newlibadr(fd, id->lib, id->override_library->reference); | ||||
| id->override_library->storage = newlibadr_us(fd, id->lib, id->override_library->storage); | id->override_library->storage = newlibadr(fd, id->lib, id->override_library->storage); | ||||
| } | } | ||||
| lib_link_id_private_id(fd, bmain, id); | lib_link_id_private_id(fd, bmain, id); | ||||
| } | } | ||||
| static void direct_link_id_override_property_operation_cb(FileData *fd, void *data) | static void direct_link_id_override_property_operation_cb(FileData *fd, void *data) | ||||
| { | { | ||||
| IDOverrideLibraryPropertyOperation *opop = data; | IDOverrideLibraryPropertyOperation *opop = data; | ||||
| ▲ Show 20 Lines • Show All 117 Lines • ▼ Show 20 Lines | |||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Read ID: Brush | /** \name Read ID: Brush | ||||
| * \{ */ | * \{ */ | ||||
| /* library brush linking after fileread */ | /* library brush linking after fileread */ | ||||
| static void lib_link_brush(FileData *fd, Main *UNUSED(bmain), Brush *brush) | static void lib_link_brush(FileData *fd, Main *UNUSED(bmain), Brush *brush) | ||||
| { | { | ||||
| /* brush->(mask_)mtex.obj is ignored on purpose? */ | /* brush->(mask_)mtex.obj is ignored on purpose? */ | ||||
| brush->mtex.tex = newlibadr_us(fd, brush->id.lib, brush->mtex.tex); | brush->mtex.tex = newlibadr(fd, brush->id.lib, brush->mtex.tex); | ||||
| brush->mask_mtex.tex = newlibadr_us(fd, brush->id.lib, brush->mask_mtex.tex); | brush->mask_mtex.tex = newlibadr(fd, brush->id.lib, brush->mask_mtex.tex); | ||||
| brush->clone.image = newlibadr(fd, brush->id.lib, brush->clone.image); | brush->clone.image = newlibadr(fd, brush->id.lib, brush->clone.image); | ||||
| brush->toggle_brush = newlibadr(fd, brush->id.lib, brush->toggle_brush); | brush->toggle_brush = newlibadr(fd, brush->id.lib, brush->toggle_brush); | ||||
| brush->paint_curve = newlibadr_us(fd, brush->id.lib, brush->paint_curve); | brush->paint_curve = newlibadr(fd, brush->id.lib, brush->paint_curve); | ||||
| /* link default grease pencil palette */ | /* link default grease pencil palette */ | ||||
| if (brush->gpencil_settings != NULL) { | if (brush->gpencil_settings != NULL) { | ||||
| if (brush->gpencil_settings->flag & GP_BRUSH_MATERIAL_PINNED) { | if (brush->gpencil_settings->flag & GP_BRUSH_MATERIAL_PINNED) { | ||||
| brush->gpencil_settings->material = newlibadr_us( | brush->gpencil_settings->material = newlibadr( | ||||
| fd, brush->id.lib, brush->gpencil_settings->material); | fd, brush->id.lib, brush->gpencil_settings->material); | ||||
| if (!brush->gpencil_settings->material) { | if (!brush->gpencil_settings->material) { | ||||
| brush->gpencil_settings->flag &= ~GP_BRUSH_MATERIAL_PINNED; | brush->gpencil_settings->flag &= ~GP_BRUSH_MATERIAL_PINNED; | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| brush->gpencil_settings->material = NULL; | brush->gpencil_settings->material = NULL; | ||||
| ▲ Show 20 Lines • Show All 125 Lines • ▼ Show 20 Lines | |||||
| // XXX deprecated - old animation system | // XXX deprecated - old animation system | ||||
| static void lib_link_nlastrips(FileData *fd, ID *id, ListBase *striplist) | static void lib_link_nlastrips(FileData *fd, ID *id, ListBase *striplist) | ||||
| { | { | ||||
| bActionStrip *strip; | bActionStrip *strip; | ||||
| bActionModifier *amod; | bActionModifier *amod; | ||||
| for (strip = striplist->first; strip; strip = strip->next) { | for (strip = striplist->first; strip; strip = strip->next) { | ||||
| strip->object = newlibadr(fd, id->lib, strip->object); | strip->object = newlibadr(fd, id->lib, strip->object); | ||||
| strip->act = newlibadr_us(fd, id->lib, strip->act); | strip->act = newlibadr(fd, id->lib, strip->act); | ||||
| strip->ipo = newlibadr(fd, id->lib, strip->ipo); | strip->ipo = newlibadr(fd, id->lib, strip->ipo); | ||||
| for (amod = strip->modifiers.first; amod; amod = amod->next) { | for (amod = strip->modifiers.first; amod; amod = amod->next) { | ||||
| amod->ob = newlibadr(fd, id->lib, amod->ob); | amod->ob = newlibadr(fd, id->lib, amod->ob); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| // XXX deprecated - old animation system | // XXX deprecated - old animation system | ||||
| ▲ Show 20 Lines • Show All 228 Lines • ▼ Show 20 Lines | static void lib_link_nladata_strips(FileData *fd, ID *id, ListBase *list) | ||||
| for (strip = list->first; strip; strip = strip->next) { | for (strip = list->first; strip; strip = strip->next) { | ||||
| /* check strip's children */ | /* check strip's children */ | ||||
| lib_link_nladata_strips(fd, id, &strip->strips); | lib_link_nladata_strips(fd, id, &strip->strips); | ||||
| /* check strip's F-Curves */ | /* check strip's F-Curves */ | ||||
| lib_link_fcurves(fd, id, &strip->fcurves); | lib_link_fcurves(fd, id, &strip->fcurves); | ||||
| /* reassign the counted-reference to action */ | /* reassign the counted-reference to action */ | ||||
| strip->act = newlibadr_us(fd, id->lib, strip->act); | strip->act = newlibadr(fd, id->lib, strip->act); | ||||
| /* fix action id-root (i.e. if it comes from a pre 2.57 .blend file) */ | /* fix action id-root (i.e. if it comes from a pre 2.57 .blend file) */ | ||||
| if ((strip->act) && (strip->act->idroot == 0)) { | if ((strip->act) && (strip->act->idroot == 0)) { | ||||
| strip->act->idroot = GS(id->name); | strip->act->idroot = GS(id->name); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 80 Lines • ▼ Show 20 Lines | |||||
| static void lib_link_animdata(FileData *fd, ID *id, AnimData *adt) | static void lib_link_animdata(FileData *fd, ID *id, AnimData *adt) | ||||
| { | { | ||||
| if (adt == NULL) { | if (adt == NULL) { | ||||
| return; | return; | ||||
| } | } | ||||
| /* link action data */ | /* link action data */ | ||||
| adt->action = newlibadr_us(fd, id->lib, adt->action); | adt->action = newlibadr(fd, id->lib, adt->action); | ||||
| adt->tmpact = newlibadr_us(fd, id->lib, adt->tmpact); | adt->tmpact = newlibadr(fd, id->lib, adt->tmpact); | ||||
| /* fix action id-roots (i.e. if they come from a pre 2.57 .blend file) */ | /* fix action id-roots (i.e. if they come from a pre 2.57 .blend file) */ | ||||
| if ((adt->action) && (adt->action->idroot == 0)) { | if ((adt->action) && (adt->action->idroot == 0)) { | ||||
| adt->action->idroot = GS(id->name); | adt->action->idroot = GS(id->name); | ||||
| } | } | ||||
| if ((adt->tmpact) && (adt->tmpact->idroot == 0)) { | if ((adt->tmpact) && (adt->tmpact->idroot == 0)) { | ||||
| adt->tmpact->idroot = GS(id->name); | adt->tmpact->idroot = GS(id->name); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 69 Lines • ▼ Show 20 Lines | |||||
| static void lib_link_workspaces(FileData *fd, Main *bmain, WorkSpace *workspace) | static void lib_link_workspaces(FileData *fd, Main *bmain, WorkSpace *workspace) | ||||
| { | { | ||||
| ListBase *layouts = BKE_workspace_layouts_get(workspace); | ListBase *layouts = BKE_workspace_layouts_get(workspace); | ||||
| ID *id = (ID *)workspace; | ID *id = (ID *)workspace; | ||||
| id_us_ensure_real(id); | id_us_ensure_real(id); | ||||
| for (WorkSpaceLayout *layout = layouts->first, *layout_next; layout; layout = layout_next) { | for (WorkSpaceLayout *layout = layouts->first, *layout_next; layout; layout = layout_next) { | ||||
| layout->screen = newlibadr_us(fd, id->lib, layout->screen); | layout->screen = newlibadr(fd, id->lib, layout->screen); | ||||
| layout_next = layout->next; | layout_next = layout->next; | ||||
| if (layout->screen) { | if (layout->screen) { | ||||
| if (ID_IS_LINKED(id)) { | if (ID_IS_LINKED(id)) { | ||||
| layout->screen->winid = 0; | layout->screen->winid = 0; | ||||
| if (layout->screen->temp) { | if (layout->screen->temp) { | ||||
| /* delete temp layouts when appending */ | /* delete temp layouts when appending */ | ||||
| BKE_workspace_layout_remove(bmain, workspace, layout); | BKE_workspace_layout_remove(bmain, workspace, layout); | ||||
| ▲ Show 20 Lines • Show All 57 Lines • ▼ Show 20 Lines | |||||
| /** \name Read ID: Node Tree | /** \name Read ID: Node Tree | ||||
| * \{ */ | * \{ */ | ||||
| /* Single node tree (also used for material/scene trees), ntree is not NULL */ | /* Single node tree (also used for material/scene trees), ntree is not NULL */ | ||||
| static void lib_link_ntree(FileData *fd, Library *lib, bNodeTree *ntree) | static void lib_link_ntree(FileData *fd, Library *lib, bNodeTree *ntree) | ||||
| { | { | ||||
| ntree->id.lib = lib; | ntree->id.lib = lib; | ||||
| ntree->gpd = newlibadr_us(fd, lib, ntree->gpd); | ntree->gpd = newlibadr(fd, lib, ntree->gpd); | ||||
| for (bNode *node = ntree->nodes.first; node; node = node->next) { | for (bNode *node = ntree->nodes.first; node; node = node->next) { | ||||
| /* Link ID Properties -- and copy this comment EXACTLY for easy finding | /* Link ID Properties -- and copy this comment EXACTLY for easy finding | ||||
| * of library blocks that implement this.*/ | * of library blocks that implement this.*/ | ||||
| IDP_LibLinkProperty(node->prop, fd); | IDP_LibLinkProperty(node->prop, fd); | ||||
| node->id = newlibadr_us(fd, lib, node->id); | node->id = newlibadr(fd, lib, node->id); | ||||
| for (bNodeSocket *sock = node->inputs.first; sock; sock = sock->next) { | for (bNodeSocket *sock = node->inputs.first; sock; sock = sock->next) { | ||||
| IDP_LibLinkProperty(sock->prop, fd); | IDP_LibLinkProperty(sock->prop, fd); | ||||
| } | } | ||||
| for (bNodeSocket *sock = node->outputs.first; sock; sock = sock->next) { | for (bNodeSocket *sock = node->outputs.first; sock; sock = sock->next) { | ||||
| IDP_LibLinkProperty(sock->prop, fd); | IDP_LibLinkProperty(sock->prop, fd); | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 218 Lines • ▼ Show 20 Lines | static void lib_link_constraint_cb(bConstraint *UNUSED(con), | ||||
| bool is_reference, | bool is_reference, | ||||
| void *userdata) | void *userdata) | ||||
| { | { | ||||
| tConstraintLinkData *cld = (tConstraintLinkData *)userdata; | tConstraintLinkData *cld = (tConstraintLinkData *)userdata; | ||||
| /* for reference types, we need to increment the usercounts on load... */ | /* for reference types, we need to increment the usercounts on load... */ | ||||
| if (is_reference) { | if (is_reference) { | ||||
| /* reference type - with usercount */ | /* reference type - with usercount */ | ||||
| *idpoin = newlibadr_us(cld->fd, cld->id->lib, *idpoin); | *idpoin = newlibadr(cld->fd, cld->id->lib, *idpoin); | ||||
| } | } | ||||
| else { | else { | ||||
| /* target type - no usercount needed */ | /* target type - no usercount needed */ | ||||
| *idpoin = newlibadr(cld->fd, cld->id->lib, *idpoin); | *idpoin = newlibadr(cld->fd, cld->id->lib, *idpoin); | ||||
| } | } | ||||
| } | } | ||||
| static void lib_link_constraints(FileData *fd, ID *id, ListBase *conlist) | static void lib_link_constraints(FileData *fd, ID *id, ListBase *conlist) | ||||
| ▲ Show 20 Lines • Show All 115 Lines • ▼ Show 20 Lines | static void lib_link_pose(FileData *fd, Main *bmain, Object *ob, bPose *pose) | ||||
| for (bPoseChannel *pchan = pose->chanbase.first; pchan; pchan = pchan->next) { | for (bPoseChannel *pchan = pose->chanbase.first; pchan; pchan = pchan->next) { | ||||
| lib_link_constraints(fd, (ID *)ob, &pchan->constraints); | lib_link_constraints(fd, (ID *)ob, &pchan->constraints); | ||||
| pchan->bone = BKE_armature_find_bone_name(arm, pchan->name); | pchan->bone = BKE_armature_find_bone_name(arm, pchan->name); | ||||
| IDP_LibLinkProperty(pchan->prop, fd); | IDP_LibLinkProperty(pchan->prop, fd); | ||||
| pchan->custom = newlibadr_us(fd, arm->id.lib, pchan->custom); | pchan->custom = newlibadr(fd, arm->id.lib, pchan->custom); | ||||
| if (UNLIKELY(pchan->bone == NULL)) { | if (UNLIKELY(pchan->bone == NULL)) { | ||||
| rebuild = true; | rebuild = true; | ||||
| } | } | ||||
| else if ((ob->id.lib == NULL) && arm->id.lib) { | else if ((ob->id.lib == NULL) && arm->id.lib) { | ||||
| /* local pose selection copied to armature, bit hackish */ | /* local pose selection copied to armature, bit hackish */ | ||||
| pchan->bone->flag &= ~BONE_SELECTED; | pchan->bone->flag &= ~BONE_SELECTED; | ||||
| pchan->bone->flag |= pchan->selectflag; | pchan->bone->flag |= pchan->selectflag; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 74 Lines • ▼ Show 20 Lines | |||||
| static void lib_link_camera(FileData *fd, Main *UNUSED(bmain), Camera *ca) | static void lib_link_camera(FileData *fd, Main *UNUSED(bmain), Camera *ca) | ||||
| { | { | ||||
| ca->ipo = newlibadr_us(fd, ca->id.lib, ca->ipo); /* deprecated, for versioning */ | ca->ipo = newlibadr_us(fd, ca->id.lib, ca->ipo); /* deprecated, for versioning */ | ||||
| ca->dof_ob = newlibadr(fd, ca->id.lib, ca->dof_ob); /* deprecated, for versioning */ | ca->dof_ob = newlibadr(fd, ca->id.lib, ca->dof_ob); /* deprecated, for versioning */ | ||||
| ca->dof.focus_object = newlibadr(fd, ca->id.lib, ca->dof.focus_object); | ca->dof.focus_object = newlibadr(fd, ca->id.lib, ca->dof.focus_object); | ||||
| for (CameraBGImage *bgpic = ca->bg_images.first; bgpic; bgpic = bgpic->next) { | for (CameraBGImage *bgpic = ca->bg_images.first; bgpic; bgpic = bgpic->next) { | ||||
| bgpic->ima = newlibadr_us(fd, ca->id.lib, bgpic->ima); | bgpic->ima = newlibadr(fd, ca->id.lib, bgpic->ima); | ||||
| bgpic->clip = newlibadr_us(fd, ca->id.lib, bgpic->clip); | bgpic->clip = newlibadr(fd, ca->id.lib, bgpic->clip); | ||||
| } | } | ||||
| } | } | ||||
| static void direct_link_camera(FileData *fd, Camera *ca) | static void direct_link_camera(FileData *fd, Camera *ca) | ||||
| { | { | ||||
| ca->adt = newdataadr(fd, ca->adt); | ca->adt = newdataadr(fd, ca->adt); | ||||
| direct_link_animdata(fd, ca->adt); | direct_link_animdata(fd, ca->adt); | ||||
| ▲ Show 20 Lines • Show All 106 Lines • ▼ Show 20 Lines | |||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Read ID: Meta Ball | /** \name Read ID: Meta Ball | ||||
| * \{ */ | * \{ */ | ||||
| static void lib_link_mball(FileData *fd, Main *UNUSED(bmain), MetaBall *mb) | static void lib_link_mball(FileData *fd, Main *UNUSED(bmain), MetaBall *mb) | ||||
| { | { | ||||
| for (int a = 0; a < mb->totcol; a++) { | for (int a = 0; a < mb->totcol; a++) { | ||||
| mb->mat[a] = newlibadr_us(fd, mb->id.lib, mb->mat[a]); | mb->mat[a] = newlibadr(fd, mb->id.lib, mb->mat[a]); | ||||
| } | } | ||||
| mb->ipo = newlibadr_us(fd, mb->id.lib, mb->ipo); // XXX deprecated - old animation system | mb->ipo = newlibadr_us(fd, mb->id.lib, mb->ipo); // XXX deprecated - old animation system | ||||
| } | } | ||||
| static void direct_link_mball(FileData *fd, MetaBall *mb) | static void direct_link_mball(FileData *fd, MetaBall *mb) | ||||
| { | { | ||||
| mb->adt = newdataadr(fd, mb->adt); | mb->adt = newdataadr(fd, mb->adt); | ||||
| ▲ Show 20 Lines • Show All 174 Lines • ▼ Show 20 Lines | |||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Read ID: Curve | /** \name Read ID: Curve | ||||
| * \{ */ | * \{ */ | ||||
| static void lib_link_curve(FileData *fd, Main *UNUSED(bmain), Curve *cu) | static void lib_link_curve(FileData *fd, Main *UNUSED(bmain), Curve *cu) | ||||
| { | { | ||||
| for (int a = 0; a < cu->totcol; a++) { | for (int a = 0; a < cu->totcol; a++) { | ||||
| cu->mat[a] = newlibadr_us(fd, cu->id.lib, cu->mat[a]); | cu->mat[a] = newlibadr(fd, cu->id.lib, cu->mat[a]); | ||||
| } | } | ||||
| cu->bevobj = newlibadr(fd, cu->id.lib, cu->bevobj); | cu->bevobj = newlibadr(fd, cu->id.lib, cu->bevobj); | ||||
| cu->taperobj = newlibadr(fd, cu->id.lib, cu->taperobj); | cu->taperobj = newlibadr(fd, cu->id.lib, cu->taperobj); | ||||
| cu->textoncurve = newlibadr(fd, cu->id.lib, cu->textoncurve); | cu->textoncurve = newlibadr(fd, cu->id.lib, cu->textoncurve); | ||||
| cu->vfont = newlibadr_us(fd, cu->id.lib, cu->vfont); | cu->vfont = newlibadr(fd, cu->id.lib, cu->vfont); | ||||
| cu->vfontb = newlibadr_us(fd, cu->id.lib, cu->vfontb); | cu->vfontb = newlibadr(fd, cu->id.lib, cu->vfontb); | ||||
| cu->vfonti = newlibadr_us(fd, cu->id.lib, cu->vfonti); | cu->vfonti = newlibadr(fd, cu->id.lib, cu->vfonti); | ||||
| cu->vfontbi = newlibadr_us(fd, cu->id.lib, cu->vfontbi); | cu->vfontbi = newlibadr(fd, cu->id.lib, cu->vfontbi); | ||||
| cu->ipo = newlibadr_us(fd, cu->id.lib, cu->ipo); // XXX deprecated - old animation system | cu->ipo = newlibadr_us(fd, cu->id.lib, cu->ipo); // XXX deprecated - old animation system | ||||
| cu->key = newlibadr_us(fd, cu->id.lib, cu->key); | cu->key = newlibadr(fd, cu->id.lib, cu->key); | ||||
| } | } | ||||
| static void switch_endian_knots(Nurb *nu) | static void switch_endian_knots(Nurb *nu) | ||||
| { | { | ||||
| if (nu->knotsu) { | if (nu->knotsu) { | ||||
| BLI_endian_switch_float_array(nu->knotsu, KNOTSU(nu)); | BLI_endian_switch_float_array(nu->knotsu, KNOTSU(nu)); | ||||
| } | } | ||||
| if (nu->knotsv) { | if (nu->knotsv) { | ||||
| ▲ Show 20 Lines • Show All 64 Lines • ▼ Show 20 Lines | |||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Read ID: Texture | /** \name Read ID: Texture | ||||
| * \{ */ | * \{ */ | ||||
| static void lib_link_texture(FileData *fd, Main *UNUSED(bmain), Tex *tex) | static void lib_link_texture(FileData *fd, Main *UNUSED(bmain), Tex *tex) | ||||
| { | { | ||||
| tex->ima = newlibadr_us(fd, tex->id.lib, tex->ima); | tex->ima = newlibadr(fd, tex->id.lib, tex->ima); | ||||
| tex->ipo = newlibadr_us(fd, tex->id.lib, tex->ipo); // XXX deprecated - old animation system | tex->ipo = newlibadr_us(fd, tex->id.lib, tex->ipo); // XXX deprecated - old animation system | ||||
| } | } | ||||
| static void direct_link_texture(FileData *fd, Tex *tex) | static void direct_link_texture(FileData *fd, Tex *tex) | ||||
| { | { | ||||
| tex->adt = newdataadr(fd, tex->adt); | tex->adt = newdataadr(fd, tex->adt); | ||||
| direct_link_animdata(fd, tex->adt); | direct_link_animdata(fd, tex->adt); | ||||
| Show All 14 Lines | |||||
| static void lib_link_material(FileData *fd, Main *UNUSED(bmain), Material *ma) | static void lib_link_material(FileData *fd, Main *UNUSED(bmain), Material *ma) | ||||
| { | { | ||||
| ma->ipo = newlibadr_us(fd, ma->id.lib, ma->ipo); // XXX deprecated - old animation system | ma->ipo = newlibadr_us(fd, ma->id.lib, ma->ipo); // XXX deprecated - old animation system | ||||
| /* relink grease pencil settings */ | /* relink grease pencil settings */ | ||||
| if (ma->gp_style != NULL) { | if (ma->gp_style != NULL) { | ||||
| MaterialGPencilStyle *gp_style = ma->gp_style; | MaterialGPencilStyle *gp_style = ma->gp_style; | ||||
| if (gp_style->sima != NULL) { | if (gp_style->sima != NULL) { | ||||
| gp_style->sima = newlibadr_us(fd, ma->id.lib, gp_style->sima); | gp_style->sima = newlibadr(fd, ma->id.lib, gp_style->sima); | ||||
| } | } | ||||
| if (gp_style->ima != NULL) { | if (gp_style->ima != NULL) { | ||||
| gp_style->ima = newlibadr_us(fd, ma->id.lib, gp_style->ima); | gp_style->ima = newlibadr(fd, ma->id.lib, gp_style->ima); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static void direct_link_material(FileData *fd, Material *ma) | static void direct_link_material(FileData *fd, Material *ma) | ||||
| { | { | ||||
| ma->adt = newdataadr(fd, ma->adt); | ma->adt = newdataadr(fd, ma->adt); | ||||
| direct_link_animdata(fd, ma->adt); | direct_link_animdata(fd, ma->adt); | ||||
| ▲ Show 20 Lines • Show All 96 Lines • ▼ Show 20 Lines | else if (*ocache) { | ||||
| ptcaches->first = ptcaches->last = *ocache; | ptcaches->first = ptcaches->last = *ocache; | ||||
| } | } | ||||
| } | } | ||||
| static void lib_link_partdeflect(FileData *fd, ID *id, PartDeflect *pd) | static void lib_link_partdeflect(FileData *fd, ID *id, PartDeflect *pd) | ||||
| { | { | ||||
| if (pd && pd->tex) { | if (pd && pd->tex) { | ||||
| pd->tex = newlibadr_us(fd, id->lib, pd->tex); | pd->tex = newlibadr(fd, id->lib, pd->tex); | ||||
| } | } | ||||
| if (pd && pd->f_source) { | if (pd && pd->f_source) { | ||||
| pd->f_source = newlibadr(fd, id->lib, pd->f_source); | pd->f_source = newlibadr(fd, id->lib, pd->f_source); | ||||
| } | } | ||||
| } | } | ||||
| static void lib_link_particlesettings(FileData *fd, Main *UNUSED(bmain), ParticleSettings *part) | static void lib_link_particlesettings(FileData *fd, Main *UNUSED(bmain), ParticleSettings *part) | ||||
| { | { | ||||
| part->ipo = newlibadr_us(fd, part->id.lib, part->ipo); // XXX deprecated - old animation system | part->ipo = newlibadr_us(fd, part->id.lib, part->ipo); // XXX deprecated - old animation system | ||||
| part->instance_object = newlibadr(fd, part->id.lib, part->instance_object); | part->instance_object = newlibadr(fd, part->id.lib, part->instance_object); | ||||
| part->instance_collection = newlibadr_us(fd, part->id.lib, part->instance_collection); | part->instance_collection = newlibadr(fd, part->id.lib, part->instance_collection); | ||||
| part->force_group = newlibadr(fd, part->id.lib, part->force_group); | part->force_group = newlibadr(fd, part->id.lib, part->force_group); | ||||
| part->bb_ob = newlibadr(fd, part->id.lib, part->bb_ob); | part->bb_ob = newlibadr(fd, part->id.lib, part->bb_ob); | ||||
| part->collision_group = newlibadr(fd, part->id.lib, part->collision_group); | part->collision_group = newlibadr(fd, part->id.lib, part->collision_group); | ||||
| lib_link_partdeflect(fd, &part->id, part->pd); | lib_link_partdeflect(fd, &part->id, part->pd); | ||||
| lib_link_partdeflect(fd, &part->id, part->pd2); | lib_link_partdeflect(fd, &part->id, part->pd2); | ||||
| if (part->effector_weights) { | if (part->effector_weights) { | ||||
| Show All 33 Lines | for (; state; state = state->next) { | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| for (int a = 0; a < MAX_MTEX; a++) { | for (int a = 0; a < MAX_MTEX; a++) { | ||||
| MTex *mtex = part->mtex[a]; | MTex *mtex = part->mtex[a]; | ||||
| if (mtex) { | if (mtex) { | ||||
| mtex->tex = newlibadr_us(fd, part->id.lib, mtex->tex); | mtex->tex = newlibadr(fd, part->id.lib, mtex->tex); | ||||
| mtex->object = newlibadr(fd, part->id.lib, mtex->object); | mtex->object = newlibadr(fd, part->id.lib, mtex->object); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static void direct_link_partdeflect(PartDeflect *pd) | static void direct_link_partdeflect(PartDeflect *pd) | ||||
| { | { | ||||
| if (pd) { | if (pd) { | ||||
| ▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | |||||
| static void lib_link_particlesystems(FileData *fd, Object *ob, ID *id, ListBase *particles) | static void lib_link_particlesystems(FileData *fd, Object *ob, ID *id, ListBase *particles) | ||||
| { | { | ||||
| ParticleSystem *psys, *psysnext; | ParticleSystem *psys, *psysnext; | ||||
| for (psys = particles->first; psys; psys = psysnext) { | for (psys = particles->first; psys; psys = psysnext) { | ||||
| psysnext = psys->next; | psysnext = psys->next; | ||||
| psys->part = newlibadr_us(fd, id->lib, psys->part); | psys->part = newlibadr(fd, id->lib, psys->part); | ||||
| if (psys->part) { | if (psys->part) { | ||||
| ParticleTarget *pt = psys->targets.first; | ParticleTarget *pt = psys->targets.first; | ||||
| for (; pt; pt = pt->next) { | for (; pt; pt = pt->next) { | ||||
| pt->ob = newlibadr(fd, id->lib, pt->ob); | pt->ob = newlibadr(fd, id->lib, pt->ob); | ||||
| } | } | ||||
| psys->parent = newlibadr(fd, id->lib, psys->parent); | psys->parent = newlibadr(fd, id->lib, psys->parent); | ||||
| ▲ Show 20 Lines • Show All 115 Lines • ▼ Show 20 Lines | |||||
| /** \name Read ID: Mesh | /** \name Read ID: Mesh | ||||
| * \{ */ | * \{ */ | ||||
| static void lib_link_mesh(FileData *fd, Main *UNUSED(bmain), Mesh *me) | static void lib_link_mesh(FileData *fd, Main *UNUSED(bmain), Mesh *me) | ||||
| { | { | ||||
| /* this check added for python created meshes */ | /* this check added for python created meshes */ | ||||
| if (me->mat) { | if (me->mat) { | ||||
| for (int i = 0; i < me->totcol; i++) { | for (int i = 0; i < me->totcol; i++) { | ||||
| me->mat[i] = newlibadr_us(fd, me->id.lib, me->mat[i]); | me->mat[i] = newlibadr(fd, me->id.lib, me->mat[i]); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| me->totcol = 0; | me->totcol = 0; | ||||
| } | } | ||||
| me->ipo = newlibadr_us(fd, me->id.lib, me->ipo); // XXX: deprecated: old anim sys | me->ipo = newlibadr_us(fd, me->id.lib, me->ipo); // XXX: deprecated: old anim sys | ||||
| me->key = newlibadr_us(fd, me->id.lib, me->key); | me->key = newlibadr(fd, me->id.lib, me->key); | ||||
| me->texcomesh = newlibadr_us(fd, me->id.lib, me->texcomesh); | me->texcomesh = newlibadr(fd, me->id.lib, me->texcomesh); | ||||
| } | } | ||||
| static void direct_link_dverts(FileData *fd, int count, MDeformVert *mdverts) | static void direct_link_dverts(FileData *fd, int count, MDeformVert *mdverts) | ||||
| { | { | ||||
| int i; | int i; | ||||
| if (mdverts == NULL) { | if (mdverts == NULL) { | ||||
| return; | return; | ||||
| ▲ Show 20 Lines • Show All 200 Lines • ▼ Show 20 Lines | |||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Read ID: Lattice | /** \name Read ID: Lattice | ||||
| * \{ */ | * \{ */ | ||||
| static void lib_link_latt(FileData *fd, Main *UNUSED(bmain), Lattice *lt) | static void lib_link_latt(FileData *fd, Main *UNUSED(bmain), Lattice *lt) | ||||
| { | { | ||||
| lt->ipo = newlibadr_us(fd, lt->id.lib, lt->ipo); // XXX deprecated - old animation system | lt->ipo = newlibadr_us(fd, lt->id.lib, lt->ipo); // XXX deprecated - old animation system | ||||
| lt->key = newlibadr_us(fd, lt->id.lib, lt->key); | lt->key = newlibadr(fd, lt->id.lib, lt->key); | ||||
| } | } | ||||
| static void direct_link_latt(FileData *fd, Lattice *lt) | static void direct_link_latt(FileData *fd, Lattice *lt) | ||||
| { | { | ||||
| lt->def = newdataadr(fd, lt->def); | lt->def = newdataadr(fd, lt->def); | ||||
| lt->dvert = newdataadr(fd, lt->dvert); | lt->dvert = newdataadr(fd, lt->dvert); | ||||
| direct_link_dverts(fd, lt->pntsu * lt->pntsv * lt->pntsw, lt->dvert); | direct_link_dverts(fd, lt->pntsu * lt->pntsv * lt->pntsw, lt->dvert); | ||||
| ▲ Show 20 Lines • Show All 60 Lines • ▼ Show 20 Lines | |||||
| static void lib_link_object(FileData *fd, Main *bmain, Object *ob) | static void lib_link_object(FileData *fd, Main *bmain, Object *ob) | ||||
| { | { | ||||
| bool warn = false; | bool warn = false; | ||||
| int a; | int a; | ||||
| // XXX deprecated - old animation system <<< | // XXX deprecated - old animation system <<< | ||||
| ob->ipo = newlibadr_us(fd, ob->id.lib, ob->ipo); | ob->ipo = newlibadr_us(fd, ob->id.lib, ob->ipo); | ||||
| ob->action = newlibadr_us(fd, ob->id.lib, ob->action); | ob->action = newlibadr(fd, ob->id.lib, ob->action); | ||||
| // >>> XXX deprecated - old animation system | // >>> XXX deprecated - old animation system | ||||
| ob->parent = newlibadr(fd, ob->id.lib, ob->parent); | ob->parent = newlibadr(fd, ob->id.lib, ob->parent); | ||||
| ob->track = newlibadr(fd, ob->id.lib, ob->track); | ob->track = newlibadr(fd, ob->id.lib, ob->track); | ||||
| ob->poselib = newlibadr_us(fd, ob->id.lib, ob->poselib); | ob->poselib = newlibadr(fd, ob->id.lib, ob->poselib); | ||||
| /* 2.8x drops support for non-empty dupli instances. */ | /* 2.8x drops support for non-empty dupli instances. */ | ||||
| if (ob->type == OB_EMPTY) { | if (ob->type == OB_EMPTY) { | ||||
| ob->instance_collection = newlibadr_us(fd, ob->id.lib, ob->instance_collection); | ob->instance_collection = newlibadr(fd, ob->id.lib, ob->instance_collection); | ||||
| } | } | ||||
| else { | else { | ||||
| if (ob->instance_collection != NULL) { | if (ob->instance_collection != NULL) { | ||||
| ID *id = newlibadr(fd, ob->id.lib, ob->instance_collection); | ID *id = newlibadr(fd, ob->id.lib, ob->instance_collection); | ||||
| blo_reportf_wrap(fd->reports, | blo_reportf_wrap(fd->reports, | ||||
| RPT_WARNING, | RPT_WARNING, | ||||
| TIP_("Non-Empty object '%s' cannot duplicate collection '%s' " | TIP_("Non-Empty object '%s' cannot duplicate collection '%s' " | ||||
| "anymore in Blender 2.80, removed instancing"), | "anymore in Blender 2.80, removed instancing"), | ||||
| ob->id.name + 2, | ob->id.name + 2, | ||||
| id->name + 2); | id->name + 2); | ||||
| } | } | ||||
| ob->instance_collection = NULL; | ob->instance_collection = NULL; | ||||
| ob->transflag &= ~OB_DUPLICOLLECTION; | ob->transflag &= ~OB_DUPLICOLLECTION; | ||||
| } | } | ||||
| ob->proxy = newlibadr_us(fd, ob->id.lib, ob->proxy); | ob->proxy = newlibadr(fd, ob->id.lib, ob->proxy); | ||||
| if (ob->proxy) { | if (ob->proxy) { | ||||
| /* paranoia check, actually a proxy_from pointer should never be written... */ | /* paranoia check, actually a proxy_from pointer should never be written... */ | ||||
| if (ob->proxy->id.lib == NULL) { | if (ob->proxy->id.lib == NULL) { | ||||
| ob->proxy->proxy_from = NULL; | ob->proxy->proxy_from = NULL; | ||||
| ob->proxy = NULL; | ob->proxy = NULL; | ||||
| if (ob->id.lib) { | if (ob->id.lib) { | ||||
| printf("Proxy lost from object %s lib %s\n", ob->id.name + 2, ob->id.lib->name); | printf("Proxy lost from object %s lib %s\n", ob->id.name + 2, ob->id.lib->name); | ||||
| } | } | ||||
| else { | else { | ||||
| printf("Proxy lost from object %s lib <NONE>\n", ob->id.name + 2); | printf("Proxy lost from object %s lib <NONE>\n", ob->id.name + 2); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| /* this triggers object_update to always use a copy */ | /* this triggers object_update to always use a copy */ | ||||
| ob->proxy->proxy_from = ob; | ob->proxy->proxy_from = ob; | ||||
| } | } | ||||
| } | } | ||||
| ob->proxy_group = newlibadr(fd, ob->id.lib, ob->proxy_group); | ob->proxy_group = newlibadr(fd, ob->id.lib, ob->proxy_group); | ||||
| void *poin = ob->data; | void *poin = ob->data; | ||||
| ob->data = newlibadr_us(fd, ob->id.lib, ob->data); | ob->data = newlibadr(fd, ob->id.lib, ob->data); | ||||
| if (ob->data == NULL && poin != NULL) { | if (ob->data == NULL && poin != NULL) { | ||||
| if (ob->id.lib) { | if (ob->id.lib) { | ||||
| printf("Can't find obdata of %s lib %s\n", ob->id.name + 2, ob->id.lib->name); | printf("Can't find obdata of %s lib %s\n", ob->id.name + 2, ob->id.lib->name); | ||||
| } | } | ||||
| else { | else { | ||||
| printf("Object %s lost data.\n", ob->id.name + 2); | printf("Object %s lost data.\n", ob->id.name + 2); | ||||
| } | } | ||||
| Show All 12 Lines | |||||
| #else | #else | ||||
| MEM_freeN(ob->pose); | MEM_freeN(ob->pose); | ||||
| #endif | #endif | ||||
| ob->pose = NULL; | ob->pose = NULL; | ||||
| ob->mode &= ~OB_MODE_POSE; | ob->mode &= ~OB_MODE_POSE; | ||||
| } | } | ||||
| } | } | ||||
| for (a = 0; a < ob->totcol; a++) { | for (a = 0; a < ob->totcol; a++) { | ||||
| ob->mat[a] = newlibadr_us(fd, ob->id.lib, ob->mat[a]); | ob->mat[a] = newlibadr(fd, ob->id.lib, ob->mat[a]); | ||||
| } | } | ||||
| /* When the object is local and the data is library its possible | /* When the object is local and the data is library its possible | ||||
| * the material list size gets out of sync. [#22663] */ | * the material list size gets out of sync. [#22663] */ | ||||
| if (ob->data && ob->id.lib != ((ID *)ob->data)->lib) { | if (ob->data && ob->id.lib != ((ID *)ob->data)->lib) { | ||||
| const short *totcol_data = BKE_object_material_num(ob); | const short *totcol_data = BKE_object_material_num(ob); | ||||
| /* Only expand so as not to loose any object materials that might be set. */ | /* Only expand so as not to loose any object materials that might be set. */ | ||||
| if (totcol_data && (*totcol_data > ob->totcol)) { | if (totcol_data && (*totcol_data > ob->totcol)) { | ||||
| /* printf("'%s' %d -> %d\n", ob->id.name, ob->totcol, *totcol_data); */ | /* printf("'%s' %d -> %d\n", ob->id.name, ob->totcol, *totcol_data); */ | ||||
| BKE_material_resize_object(bmain, ob, *totcol_data, false); | BKE_material_resize_object(bmain, ob, *totcol_data, false); | ||||
| } | } | ||||
| } | } | ||||
| ob->gpd = newlibadr_us(fd, ob->id.lib, ob->gpd); | ob->gpd = newlibadr(fd, ob->id.lib, ob->gpd); | ||||
| /* if id.us==0 a new base will be created later on */ | /* if id.us==0 a new base will be created later on */ | ||||
| /* WARNING! Also check expand_object(), should reflect the stuff below. */ | /* WARNING! Also check expand_object(), should reflect the stuff below. */ | ||||
| lib_link_pose(fd, bmain, ob, ob->pose); | lib_link_pose(fd, bmain, ob, ob->pose); | ||||
| lib_link_constraints(fd, &ob->id, &ob->constraints); | lib_link_constraints(fd, &ob->id, &ob->constraints); | ||||
| // XXX deprecated - old animation system <<< | // XXX deprecated - old animation system <<< | ||||
| lib_link_constraint_channels(fd, &ob->id, &ob->constraintChannels); | lib_link_constraint_channels(fd, &ob->id, &ob->constraintChannels); | ||||
| lib_link_nlastrips(fd, &ob->id, &ob->nlastrips); | lib_link_nlastrips(fd, &ob->id, &ob->nlastrips); | ||||
| // >>> XXX deprecated - old animation system | // >>> XXX deprecated - old animation system | ||||
| for (PartEff *paf = ob->effect.first; paf; paf = paf->next) { | for (PartEff *paf = ob->effect.first; paf; paf = paf->next) { | ||||
| if (paf->type == EFF_PARTICLE) { | if (paf->type == EFF_PARTICLE) { | ||||
| paf->group = newlibadr_us(fd, ob->id.lib, paf->group); | paf->group = newlibadr(fd, ob->id.lib, paf->group); | ||||
| } | } | ||||
| } | } | ||||
| { | { | ||||
| FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType( | FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType( | ||||
| ob, eModifierType_Fluidsim); | ob, eModifierType_Fluidsim); | ||||
| if (fluidmd && fluidmd->fss) { | if (fluidmd && fluidmd->fss) { | ||||
| ▲ Show 20 Lines • Show All 942 Lines • ▼ Show 20 Lines | |||||
| static void lib_link_view_layer(FileData *fd, Library *lib, ViewLayer *view_layer) | static void lib_link_view_layer(FileData *fd, Library *lib, ViewLayer *view_layer) | ||||
| { | { | ||||
| for (FreestyleModuleConfig *fmc = view_layer->freestyle_config.modules.first; fmc; | for (FreestyleModuleConfig *fmc = view_layer->freestyle_config.modules.first; fmc; | ||||
| fmc = fmc->next) { | fmc = fmc->next) { | ||||
| fmc->script = newlibadr(fd, lib, fmc->script); | fmc->script = newlibadr(fd, lib, fmc->script); | ||||
| } | } | ||||
| for (FreestyleLineSet *fls = view_layer->freestyle_config.linesets.first; fls; fls = fls->next) { | for (FreestyleLineSet *fls = view_layer->freestyle_config.linesets.first; fls; fls = fls->next) { | ||||
| fls->linestyle = newlibadr_us(fd, lib, fls->linestyle); | fls->linestyle = newlibadr(fd, lib, fls->linestyle); | ||||
| fls->group = newlibadr_us(fd, lib, fls->group); | fls->group = newlibadr(fd, lib, fls->group); | ||||
| } | } | ||||
| for (Base *base = view_layer->object_bases.first, *base_next = NULL; base; base = base_next) { | for (Base *base = view_layer->object_bases.first, *base_next = NULL; base; base = base_next) { | ||||
| base_next = base->next; | base_next = base->next; | ||||
| /* we only bump the use count for the collection objects */ | /* we only bump the use count for the collection objects */ | ||||
| base->object = newlibadr(fd, lib, base->object); | base->object = newlibadr(fd, lib, base->object); | ||||
| if (base->object == NULL) { | if (base->object == NULL) { | ||||
| /* Free in case linked object got lost. */ | /* Free in case linked object got lost. */ | ||||
| BLI_freelinkN(&view_layer->object_bases, base); | BLI_freelinkN(&view_layer->object_bases, base); | ||||
| if (view_layer->basact == base) { | if (view_layer->basact == base) { | ||||
| view_layer->basact = NULL; | view_layer->basact = NULL; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| for (LayerCollection *layer_collection = view_layer->layer_collections.first; | for (LayerCollection *layer_collection = view_layer->layer_collections.first; | ||||
| layer_collection != NULL; | layer_collection != NULL; | ||||
| layer_collection = layer_collection->next) { | layer_collection = layer_collection->next) { | ||||
| lib_link_layer_collection(fd, lib, layer_collection, true); | lib_link_layer_collection(fd, lib, layer_collection, true); | ||||
| } | } | ||||
| view_layer->mat_override = newlibadr_us(fd, lib, view_layer->mat_override); | view_layer->mat_override = newlibadr(fd, lib, view_layer->mat_override); | ||||
| IDP_LibLinkProperty(view_layer->id_properties, fd); | IDP_LibLinkProperty(view_layer->id_properties, fd); | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Read ID: Collection | /** \name Read ID: Collection | ||||
| * \{ */ | * \{ */ | ||||
| #ifdef USE_COLLECTION_COMPAT_28 | #ifdef USE_COLLECTION_COMPAT_28 | ||||
| static void direct_link_scene_collection(FileData *fd, SceneCollection *sc) | static void direct_link_scene_collection(FileData *fd, SceneCollection *sc) | ||||
| { | { | ||||
| link_list(fd, &sc->objects); | link_list(fd, &sc->objects); | ||||
| link_list(fd, &sc->scene_collections); | link_list(fd, &sc->scene_collections); | ||||
| for (SceneCollection *nsc = sc->scene_collections.first; nsc; nsc = nsc->next) { | for (SceneCollection *nsc = sc->scene_collections.first; nsc; nsc = nsc->next) { | ||||
| direct_link_scene_collection(fd, nsc); | direct_link_scene_collection(fd, nsc); | ||||
| } | } | ||||
| } | } | ||||
| static void lib_link_scene_collection(FileData *fd, Library *lib, SceneCollection *sc) | static void lib_link_scene_collection(FileData *fd, Library *lib, SceneCollection *sc) | ||||
| { | { | ||||
| for (LinkData *link = sc->objects.first; link; link = link->next) { | for (LinkData *link = sc->objects.first; link; link = link->next) { | ||||
| link->data = newlibadr_us(fd, lib, link->data); | link->data = newlibadr(fd, lib, link->data); | ||||
| BLI_assert(link->data); | BLI_assert(link->data); | ||||
| } | } | ||||
| for (SceneCollection *nsc = sc->scene_collections.first; nsc; nsc = nsc->next) { | for (SceneCollection *nsc = sc->scene_collections.first; nsc; nsc = nsc->next) { | ||||
| lib_link_scene_collection(fd, lib, nsc); | lib_link_scene_collection(fd, lib, nsc); | ||||
| } | } | ||||
| } | } | ||||
| #endif | #endif | ||||
| Show All 23 Lines | #ifdef USE_COLLECTION_COMPAT_28 | ||||
| } | } | ||||
| #endif | #endif | ||||
| } | } | ||||
| static void lib_link_collection_data(FileData *fd, Library *lib, Collection *collection) | static void lib_link_collection_data(FileData *fd, Library *lib, Collection *collection) | ||||
| { | { | ||||
| for (CollectionObject *cob = collection->gobject.first, *cob_next = NULL; cob; cob = cob_next) { | for (CollectionObject *cob = collection->gobject.first, *cob_next = NULL; cob; cob = cob_next) { | ||||
| cob_next = cob->next; | cob_next = cob->next; | ||||
| cob->ob = newlibadr_us(fd, lib, cob->ob); | cob->ob = newlibadr(fd, lib, cob->ob); | ||||
| if (cob->ob == NULL) { | if (cob->ob == NULL) { | ||||
| BLI_freelinkN(&collection->gobject, cob); | BLI_freelinkN(&collection->gobject, cob); | ||||
| } | } | ||||
| } | } | ||||
| for (CollectionChild *child = collection->children.first; child != NULL; child = child->next) { | for (CollectionChild *child = collection->children.first; child != NULL; child = child->next) { | ||||
| child->collection = newlibadr_us(fd, lib, child->collection); | child->collection = newlibadr(fd, lib, child->collection); | ||||
| } | } | ||||
| BKE_collection_parent_relations_rebuild(collection); | BKE_collection_parent_relations_rebuild(collection); | ||||
| } | } | ||||
| static void lib_link_collection(FileData *fd, Main *UNUSED(bmain), Collection *collection) | static void lib_link_collection(FileData *fd, Main *UNUSED(bmain), Collection *collection) | ||||
| { | { | ||||
| #ifdef USE_COLLECTION_COMPAT_28 | #ifdef USE_COLLECTION_COMPAT_28 | ||||
| Show All 25 Lines | if (node->id == NULL && node->type == CMP_NODE_R_LAYERS) { | ||||
| node->id = &scene->id; | node->id = &scene->id; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static void link_paint(FileData *fd, Scene *sce, Paint *p) | static void link_paint(FileData *fd, Scene *sce, Paint *p) | ||||
| { | { | ||||
| if (p) { | if (p) { | ||||
| p->brush = newlibadr_us(fd, sce->id.lib, p->brush); | p->brush = newlibadr(fd, sce->id.lib, p->brush); | ||||
| for (int i = 0; i < p->tool_slots_len; i++) { | for (int i = 0; i < p->tool_slots_len; i++) { | ||||
| if (p->tool_slots[i].brush != NULL) { | if (p->tool_slots[i].brush != NULL) { | ||||
| p->tool_slots[i].brush = newlibadr_us(fd, sce->id.lib, p->tool_slots[i].brush); | p->tool_slots[i].brush = newlibadr(fd, sce->id.lib, p->tool_slots[i].brush); | ||||
| } | } | ||||
| } | } | ||||
| p->palette = newlibadr_us(fd, sce->id.lib, p->palette); | p->palette = newlibadr(fd, sce->id.lib, p->palette); | ||||
| p->paint_cursor = NULL; | p->paint_cursor = NULL; | ||||
| BKE_paint_runtime_init(sce->toolsettings, p); | BKE_paint_runtime_init(sce->toolsettings, p); | ||||
| } | } | ||||
| } | } | ||||
| static void lib_link_sequence_modifiers(FileData *fd, Scene *scene, ListBase *lb) | static void lib_link_sequence_modifiers(FileData *fd, Scene *scene, ListBase *lb) | ||||
| { | { | ||||
| SequenceModifierData *smd; | SequenceModifierData *smd; | ||||
| for (smd = lb->first; smd; smd = smd->next) { | for (smd = lb->first; smd; smd = smd->next) { | ||||
| if (smd->mask_id) { | if (smd->mask_id) { | ||||
| smd->mask_id = newlibadr_us(fd, scene->id.lib, smd->mask_id); | smd->mask_id = newlibadr(fd, scene->id.lib, smd->mask_id); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static void direct_link_lightcache_texture(FileData *fd, LightCacheTexture *lctex) | static void direct_link_lightcache_texture(FileData *fd, LightCacheTexture *lctex) | ||||
| { | { | ||||
| lctex->tex = NULL; | lctex->tex = NULL; | ||||
| ▲ Show 20 Lines • Show All 69 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| #endif | #endif | ||||
| static void lib_link_scene(FileData *fd, Main *UNUSED(bmain), Scene *sce) | static void lib_link_scene(FileData *fd, Main *UNUSED(bmain), Scene *sce) | ||||
| { | { | ||||
| lib_link_keyingsets(fd, &sce->id, &sce->keyingsets); | lib_link_keyingsets(fd, &sce->id, &sce->keyingsets); | ||||
| sce->camera = newlibadr(fd, sce->id.lib, sce->camera); | sce->camera = newlibadr(fd, sce->id.lib, sce->camera); | ||||
| sce->world = newlibadr_us(fd, sce->id.lib, sce->world); | sce->world = newlibadr(fd, sce->id.lib, sce->world); | ||||
| sce->set = newlibadr(fd, sce->id.lib, sce->set); | sce->set = newlibadr(fd, sce->id.lib, sce->set); | ||||
| sce->gpd = newlibadr_us(fd, sce->id.lib, sce->gpd); | sce->gpd = newlibadr(fd, sce->id.lib, sce->gpd); | ||||
| link_paint(fd, sce, &sce->toolsettings->imapaint.paint); | link_paint(fd, sce, &sce->toolsettings->imapaint.paint); | ||||
| if (sce->toolsettings->sculpt) { | if (sce->toolsettings->sculpt) { | ||||
| link_paint(fd, sce, &sce->toolsettings->sculpt->paint); | link_paint(fd, sce, &sce->toolsettings->sculpt->paint); | ||||
| } | } | ||||
| if (sce->toolsettings->vpaint) { | if (sce->toolsettings->vpaint) { | ||||
| link_paint(fd, sce, &sce->toolsettings->vpaint->paint); | link_paint(fd, sce, &sce->toolsettings->vpaint->paint); | ||||
| } | } | ||||
| if (sce->toolsettings->wpaint) { | if (sce->toolsettings->wpaint) { | ||||
| link_paint(fd, sce, &sce->toolsettings->wpaint->paint); | link_paint(fd, sce, &sce->toolsettings->wpaint->paint); | ||||
| } | } | ||||
| if (sce->toolsettings->uvsculpt) { | if (sce->toolsettings->uvsculpt) { | ||||
| link_paint(fd, sce, &sce->toolsettings->uvsculpt->paint); | link_paint(fd, sce, &sce->toolsettings->uvsculpt->paint); | ||||
| } | } | ||||
| if (sce->toolsettings->gp_paint) { | if (sce->toolsettings->gp_paint) { | ||||
| link_paint(fd, sce, &sce->toolsettings->gp_paint->paint); | link_paint(fd, sce, &sce->toolsettings->gp_paint->paint); | ||||
| } | } | ||||
| if (sce->toolsettings->sculpt) { | if (sce->toolsettings->sculpt) { | ||||
| sce->toolsettings->sculpt->gravity_object = newlibadr( | sce->toolsettings->sculpt->gravity_object = newlibadr( | ||||
| fd, sce->id.lib, sce->toolsettings->sculpt->gravity_object); | fd, sce->id.lib, sce->toolsettings->sculpt->gravity_object); | ||||
| } | } | ||||
| if (sce->toolsettings->imapaint.stencil) { | if (sce->toolsettings->imapaint.stencil) { | ||||
| sce->toolsettings->imapaint.stencil = newlibadr_us( | sce->toolsettings->imapaint.stencil = newlibadr( | ||||
| fd, sce->id.lib, sce->toolsettings->imapaint.stencil); | fd, sce->id.lib, sce->toolsettings->imapaint.stencil); | ||||
| } | } | ||||
| if (sce->toolsettings->imapaint.clone) { | if (sce->toolsettings->imapaint.clone) { | ||||
| sce->toolsettings->imapaint.clone = newlibadr_us( | sce->toolsettings->imapaint.clone = newlibadr( | ||||
| fd, sce->id.lib, sce->toolsettings->imapaint.clone); | fd, sce->id.lib, sce->toolsettings->imapaint.clone); | ||||
| } | } | ||||
| if (sce->toolsettings->imapaint.canvas) { | if (sce->toolsettings->imapaint.canvas) { | ||||
| sce->toolsettings->imapaint.canvas = newlibadr_us( | sce->toolsettings->imapaint.canvas = newlibadr( | ||||
| fd, sce->id.lib, sce->toolsettings->imapaint.canvas); | fd, sce->id.lib, sce->toolsettings->imapaint.canvas); | ||||
| } | } | ||||
| sce->toolsettings->particle.shape_object = newlibadr( | sce->toolsettings->particle.shape_object = newlibadr( | ||||
| fd, sce->id.lib, sce->toolsettings->particle.shape_object); | fd, sce->id.lib, sce->toolsettings->particle.shape_object); | ||||
| sce->toolsettings->gp_sculpt.guide.reference_object = newlibadr( | sce->toolsettings->gp_sculpt.guide.reference_object = newlibadr( | ||||
| fd, sce->id.lib, sce->toolsettings->gp_sculpt.guide.reference_object); | fd, sce->id.lib, sce->toolsettings->gp_sculpt.guide.reference_object); | ||||
| for (Base *base_legacy_next, *base_legacy = sce->base.first; base_legacy; | for (Base *base_legacy_next, *base_legacy = sce->base.first; base_legacy; | ||||
| base_legacy = base_legacy_next) { | base_legacy = base_legacy_next) { | ||||
| base_legacy_next = base_legacy->next; | base_legacy_next = base_legacy->next; | ||||
| base_legacy->object = newlibadr_us(fd, sce->id.lib, base_legacy->object); | base_legacy->object = newlibadr(fd, sce->id.lib, base_legacy->object); | ||||
| if (base_legacy->object == NULL) { | if (base_legacy->object == NULL) { | ||||
| blo_reportf_wrap( | blo_reportf_wrap( | ||||
| fd->reports, RPT_WARNING, TIP_("LIB: object lost from scene: '%s'"), sce->id.name + 2); | fd->reports, RPT_WARNING, TIP_("LIB: object lost from scene: '%s'"), sce->id.name + 2); | ||||
| BLI_remlink(&sce->base, base_legacy); | BLI_remlink(&sce->base, base_legacy); | ||||
| if (base_legacy == sce->basact) { | if (base_legacy == sce->basact) { | ||||
| sce->basact = NULL; | sce->basact = NULL; | ||||
| } | } | ||||
| Show All 9 Lines | if (seq->ipo) { | ||||
| seq->ipo = newlibadr_us(fd, sce->id.lib, seq->ipo); // XXX deprecated - old animation system | seq->ipo = newlibadr_us(fd, sce->id.lib, seq->ipo); // XXX deprecated - old animation system | ||||
| } | } | ||||
| seq->scene_sound = NULL; | seq->scene_sound = NULL; | ||||
| if (seq->scene) { | if (seq->scene) { | ||||
| seq->scene = newlibadr(fd, sce->id.lib, seq->scene); | seq->scene = newlibadr(fd, sce->id.lib, seq->scene); | ||||
| seq->scene_sound = NULL; | seq->scene_sound = NULL; | ||||
| } | } | ||||
| if (seq->clip) { | if (seq->clip) { | ||||
| seq->clip = newlibadr_us(fd, sce->id.lib, seq->clip); | seq->clip = newlibadr(fd, sce->id.lib, seq->clip); | ||||
| } | } | ||||
| if (seq->mask) { | if (seq->mask) { | ||||
| seq->mask = newlibadr_us(fd, sce->id.lib, seq->mask); | seq->mask = newlibadr(fd, sce->id.lib, seq->mask); | ||||
| } | } | ||||
| if (seq->scene_camera) { | if (seq->scene_camera) { | ||||
| seq->scene_camera = newlibadr(fd, sce->id.lib, seq->scene_camera); | seq->scene_camera = newlibadr(fd, sce->id.lib, seq->scene_camera); | ||||
| } | } | ||||
| if (seq->sound) { | if (seq->sound) { | ||||
| seq->scene_sound = NULL; | seq->scene_sound = NULL; | ||||
| if (seq->type == SEQ_TYPE_SOUND_HD) { | if (seq->type == SEQ_TYPE_SOUND_HD) { | ||||
| seq->type = SEQ_TYPE_SOUND_RAM; | seq->type = SEQ_TYPE_SOUND_RAM; | ||||
| } | } | ||||
| else { | else { | ||||
| seq->sound = newlibadr(fd, sce->id.lib, seq->sound); | seq->sound = newlibadr(fd, sce->id.lib, seq->sound); | ||||
| } | } | ||||
| if (seq->sound) { | if (seq->sound) { | ||||
| id_us_plus_no_lib((ID *)seq->sound); | id_us_plus_no_lib((ID *)seq->sound); | ||||
| seq->scene_sound = NULL; | seq->scene_sound = NULL; | ||||
| } | } | ||||
| } | } | ||||
| if (seq->type == SEQ_TYPE_TEXT) { | if (seq->type == SEQ_TYPE_TEXT) { | ||||
| TextVars *t = seq->effectdata; | TextVars *t = seq->effectdata; | ||||
| t->text_font = newlibadr_us(fd, sce->id.lib, t->text_font); | t->text_font = newlibadr(fd, sce->id.lib, t->text_font); | ||||
| } | } | ||||
| BLI_listbase_clear(&seq->anims); | BLI_listbase_clear(&seq->anims); | ||||
| lib_link_sequence_modifiers(fd, sce, &seq->modifiers); | lib_link_sequence_modifiers(fd, sce, &seq->modifiers); | ||||
| } | } | ||||
| SEQ_END; | SEQ_END; | ||||
| for (TimeMarker *marker = sce->markers.first; marker; marker = marker->next) { | for (TimeMarker *marker = sce->markers.first; marker; marker = marker->next) { | ||||
| Show All 16 Lines | if (sce->rigidbody_world) { | ||||
| } | } | ||||
| } | } | ||||
| if (sce->nodetree) { | if (sce->nodetree) { | ||||
| composite_patch(sce->nodetree, sce); | composite_patch(sce->nodetree, sce); | ||||
| } | } | ||||
| for (SceneRenderLayer *srl = sce->r.layers.first; srl; srl = srl->next) { | for (SceneRenderLayer *srl = sce->r.layers.first; srl; srl = srl->next) { | ||||
| srl->mat_override = newlibadr_us(fd, sce->id.lib, srl->mat_override); | srl->mat_override = newlibadr(fd, sce->id.lib, srl->mat_override); | ||||
| for (FreestyleModuleConfig *fmc = srl->freestyleConfig.modules.first; fmc; fmc = fmc->next) { | for (FreestyleModuleConfig *fmc = srl->freestyleConfig.modules.first; fmc; fmc = fmc->next) { | ||||
| fmc->script = newlibadr(fd, sce->id.lib, fmc->script); | fmc->script = newlibadr(fd, sce->id.lib, fmc->script); | ||||
| } | } | ||||
| for (FreestyleLineSet *fls = srl->freestyleConfig.linesets.first; fls; fls = fls->next) { | for (FreestyleLineSet *fls = srl->freestyleConfig.linesets.first; fls; fls = fls->next) { | ||||
| fls->linestyle = newlibadr_us(fd, sce->id.lib, fls->linestyle); | fls->linestyle = newlibadr(fd, sce->id.lib, fls->linestyle); | ||||
| fls->group = newlibadr_us(fd, sce->id.lib, fls->group); | fls->group = newlibadr(fd, sce->id.lib, fls->group); | ||||
| } | } | ||||
| } | } | ||||
| /* Motion Tracking */ | /* Motion Tracking */ | ||||
| sce->clip = newlibadr_us(fd, sce->id.lib, sce->clip); | sce->clip = newlibadr(fd, sce->id.lib, sce->clip); | ||||
| #ifdef USE_COLLECTION_COMPAT_28 | #ifdef USE_COLLECTION_COMPAT_28 | ||||
| if (sce->collection) { | if (sce->collection) { | ||||
| lib_link_scene_collection(fd, sce->id.lib, sce->collection); | lib_link_scene_collection(fd, sce->id.lib, sce->collection); | ||||
| } | } | ||||
| #endif | #endif | ||||
| for (ViewLayer *view_layer = sce->view_layers.first; view_layer; view_layer = view_layer->next) { | for (ViewLayer *view_layer = sce->view_layers.first; view_layer; view_layer = view_layer->next) { | ||||
| ▲ Show 20 Lines • Show All 422 Lines • ▼ Show 20 Lines | static void lib_link_gpencil(FileData *fd, Main *UNUSED(bmain), bGPdata *gpd) | ||||
| /* Layers */ | /* Layers */ | ||||
| for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) { | for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) { | ||||
| /* Layer -> Parent References */ | /* Layer -> Parent References */ | ||||
| gpl->parent = newlibadr(fd, gpd->id.lib, gpl->parent); | gpl->parent = newlibadr(fd, gpd->id.lib, gpl->parent); | ||||
| } | } | ||||
| /* materials */ | /* materials */ | ||||
| for (int a = 0; a < gpd->totcol; a++) { | for (int a = 0; a < gpd->totcol; a++) { | ||||
| gpd->mat[a] = newlibadr_us(fd, gpd->id.lib, gpd->mat[a]); | gpd->mat[a] = newlibadr(fd, gpd->id.lib, gpd->mat[a]); | ||||
| } | } | ||||
| } | } | ||||
| /* relinks grease-pencil data - used for direct_link and old file linkage */ | /* relinks grease-pencil data - used for direct_link and old file linkage */ | ||||
| static void direct_link_gpencil(FileData *fd, bGPdata *gpd) | static void direct_link_gpencil(FileData *fd, bGPdata *gpd) | ||||
| { | { | ||||
| bGPDlayer *gpl; | bGPDlayer *gpl; | ||||
| bGPDframe *gpf; | bGPDframe *gpf; | ||||
| ▲ Show 20 Lines • Show All 444 Lines • ▼ Show 20 Lines | switch (sl->spacetype) { | ||||
| } | } | ||||
| saction->action = newlibadr(fd, parent_id->lib, saction->action); | saction->action = newlibadr(fd, parent_id->lib, saction->action); | ||||
| break; | break; | ||||
| } | } | ||||
| case SPACE_IMAGE: { | case SPACE_IMAGE: { | ||||
| SpaceImage *sima = (SpaceImage *)sl; | SpaceImage *sima = (SpaceImage *)sl; | ||||
| sima->image = newlibadr_real_us(fd, parent_id->lib, sima->image); | sima->image = newlibadr(fd, parent_id->lib, sima->image); | ||||
| sima->mask_info.mask = newlibadr_real_us(fd, parent_id->lib, sima->mask_info.mask); | sima->mask_info.mask = newlibadr(fd, parent_id->lib, sima->mask_info.mask); | ||||
| /* NOTE: pre-2.5, this was local data not lib data, but now we need this as lib data | /* NOTE: pre-2.5, this was local data not lib data, but now we need this as lib data | ||||
| * so fingers crossed this works fine! | * so fingers crossed this works fine! | ||||
| */ | */ | ||||
| sima->gpd = newlibadr_us(fd, parent_id->lib, sima->gpd); | sima->gpd = newlibadr(fd, parent_id->lib, sima->gpd); | ||||
| break; | break; | ||||
| } | } | ||||
| case SPACE_SEQ: { | case SPACE_SEQ: { | ||||
| SpaceSeq *sseq = (SpaceSeq *)sl; | SpaceSeq *sseq = (SpaceSeq *)sl; | ||||
| /* NOTE: pre-2.5, this was local data not lib data, but now we need this as lib data | /* NOTE: pre-2.5, this was local data not lib data, but now we need this as lib data | ||||
| * so fingers crossed this works fine! | * so fingers crossed this works fine! | ||||
| */ | */ | ||||
| sseq->gpd = newlibadr_us(fd, parent_id->lib, sseq->gpd); | sseq->gpd = newlibadr(fd, parent_id->lib, sseq->gpd); | ||||
| break; | break; | ||||
| } | } | ||||
| case SPACE_NLA: { | case SPACE_NLA: { | ||||
| SpaceNla *snla = (SpaceNla *)sl; | SpaceNla *snla = (SpaceNla *)sl; | ||||
| bDopeSheet *ads = snla->ads; | bDopeSheet *ads = snla->ads; | ||||
| if (ads) { | if (ads) { | ||||
| ads->source = newlibadr(fd, parent_id->lib, ads->source); | ads->source = newlibadr(fd, parent_id->lib, ads->source); | ||||
| ▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | switch (sl->spacetype) { | ||||
| bNodeTreePath *path, *path_next; | bNodeTreePath *path, *path_next; | ||||
| bNodeTree *ntree; | bNodeTree *ntree; | ||||
| /* node tree can be stored locally in id too, link this first */ | /* node tree can be stored locally in id too, link this first */ | ||||
| snode->id = newlibadr(fd, parent_id->lib, snode->id); | snode->id = newlibadr(fd, parent_id->lib, snode->id); | ||||
| snode->from = newlibadr(fd, parent_id->lib, snode->from); | snode->from = newlibadr(fd, parent_id->lib, snode->from); | ||||
| ntree = snode->id ? ntreeFromID(snode->id) : NULL; | ntree = snode->id ? ntreeFromID(snode->id) : NULL; | ||||
| snode->nodetree = ntree ? ntree : newlibadr_us(fd, parent_id->lib, snode->nodetree); | snode->nodetree = ntree ? ntree : newlibadr(fd, parent_id->lib, snode->nodetree); | ||||
| for (path = snode->treepath.first; path; path = path->next) { | for (path = snode->treepath.first; path; path = path->next) { | ||||
| if (path == snode->treepath.first) { | if (path == snode->treepath.first) { | ||||
| /* first nodetree in path is same as snode->nodetree */ | /* first nodetree in path is same as snode->nodetree */ | ||||
| path->nodetree = snode->nodetree; | path->nodetree = snode->nodetree; | ||||
| } | } | ||||
| else { | else { | ||||
| path->nodetree = newlibadr_us(fd, parent_id->lib, path->nodetree); | path->nodetree = newlibadr(fd, parent_id->lib, path->nodetree); | ||||
| } | } | ||||
| if (!path->nodetree) { | if (!path->nodetree) { | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| /* remaining path entries are invalid, remove */ | /* remaining path entries are invalid, remove */ | ||||
| Show All 12 Lines | switch (sl->spacetype) { | ||||
| } | } | ||||
| else { | else { | ||||
| snode->edittree = NULL; | snode->edittree = NULL; | ||||
| } | } | ||||
| break; | break; | ||||
| } | } | ||||
| case SPACE_CLIP: { | case SPACE_CLIP: { | ||||
| SpaceClip *sclip = (SpaceClip *)sl; | SpaceClip *sclip = (SpaceClip *)sl; | ||||
| sclip->clip = newlibadr_real_us(fd, parent_id->lib, sclip->clip); | sclip->clip = newlibadr(fd, parent_id->lib, sclip->clip); | ||||
| sclip->mask_info.mask = newlibadr_real_us(fd, parent_id->lib, sclip->mask_info.mask); | sclip->mask_info.mask = newlibadr(fd, parent_id->lib, sclip->mask_info.mask); | ||||
| break; | break; | ||||
| } | } | ||||
| default: | default: | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 780 Lines • ▼ Show 20 Lines | |||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Read ID: Speaker | /** \name Read ID: Speaker | ||||
| * \{ */ | * \{ */ | ||||
| static void lib_link_speaker(FileData *fd, Main *UNUSED(bmain), Speaker *spk) | static void lib_link_speaker(FileData *fd, Main *UNUSED(bmain), Speaker *spk) | ||||
| { | { | ||||
| spk->sound = newlibadr_us(fd, spk->id.lib, spk->sound); | spk->sound = newlibadr(fd, spk->id.lib, spk->sound); | ||||
| } | } | ||||
| static void direct_link_speaker(FileData *fd, Speaker *spk) | static void direct_link_speaker(FileData *fd, Speaker *spk) | ||||
| { | { | ||||
| spk->adt = newdataadr(fd, spk->adt); | spk->adt = newdataadr(fd, spk->adt); | ||||
| direct_link_animdata(fd, spk->adt); | direct_link_animdata(fd, spk->adt); | ||||
| #if 0 | #if 0 | ||||
| ▲ Show 20 Lines • Show All 134 Lines • ▼ Show 20 Lines | static void direct_link_movieclip(FileData *fd, MovieClip *clip) | ||||
| } | } | ||||
| } | } | ||||
| static void lib_link_movieTracks(FileData *fd, MovieClip *clip, ListBase *tracksbase) | static void lib_link_movieTracks(FileData *fd, MovieClip *clip, ListBase *tracksbase) | ||||
| { | { | ||||
| MovieTrackingTrack *track; | MovieTrackingTrack *track; | ||||
| for (track = tracksbase->first; track; track = track->next) { | for (track = tracksbase->first; track; track = track->next) { | ||||
| track->gpd = newlibadr_us(fd, clip->id.lib, track->gpd); | track->gpd = newlibadr(fd, clip->id.lib, track->gpd); | ||||
| } | } | ||||
| } | } | ||||
| static void lib_link_moviePlaneTracks(FileData *fd, MovieClip *clip, ListBase *tracksbase) | static void lib_link_moviePlaneTracks(FileData *fd, MovieClip *clip, ListBase *tracksbase) | ||||
| { | { | ||||
| MovieTrackingPlaneTrack *plane_track; | MovieTrackingPlaneTrack *plane_track; | ||||
| for (plane_track = tracksbase->first; plane_track; plane_track = plane_track->next) { | for (plane_track = tracksbase->first; plane_track; plane_track = plane_track->next) { | ||||
| plane_track->image = newlibadr_us(fd, clip->id.lib, plane_track->image); | plane_track->image = newlibadr(fd, clip->id.lib, plane_track->image); | ||||
| } | } | ||||
| } | } | ||||
| static void lib_link_movieclip(FileData *fd, Main *UNUSED(bmain), MovieClip *clip) | static void lib_link_movieclip(FileData *fd, Main *UNUSED(bmain), MovieClip *clip) | ||||
| { | { | ||||
| MovieTracking *tracking = &clip->tracking; | MovieTracking *tracking = &clip->tracking; | ||||
| clip->gpd = newlibadr_us(fd, clip->id.lib, clip->gpd); | clip->gpd = newlibadr(fd, clip->id.lib, clip->gpd); | ||||
| lib_link_movieTracks(fd, clip, &tracking->tracks); | lib_link_movieTracks(fd, clip, &tracking->tracks); | ||||
| lib_link_moviePlaneTracks(fd, clip, &tracking->plane_tracks); | lib_link_moviePlaneTracks(fd, clip, &tracking->plane_tracks); | ||||
| for (MovieTrackingObject *object = tracking->objects.first; object; object = object->next) { | for (MovieTrackingObject *object = tracking->objects.first; object; object = object->next) { | ||||
| lib_link_movieTracks(fd, clip, &object->tracks); | lib_link_movieTracks(fd, clip, &object->tracks); | ||||
| lib_link_moviePlaneTracks(fd, clip, &object->plane_tracks); | lib_link_moviePlaneTracks(fd, clip, &object->plane_tracks); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 60 Lines • ▼ Show 20 Lines | for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) { | ||||
| masklay->act_spline = newdataadr(fd, masklay->act_spline); | masklay->act_spline = newdataadr(fd, masklay->act_spline); | ||||
| masklay->act_point = act_point_search; | masklay->act_point = act_point_search; | ||||
| } | } | ||||
| } | } | ||||
| static void lib_link_mask_parent(FileData *fd, Mask *mask, MaskParent *parent) | static void lib_link_mask_parent(FileData *fd, Mask *mask, MaskParent *parent) | ||||
| { | { | ||||
| parent->id = newlibadr_us(fd, mask->id.lib, parent->id); | parent->id = newlibadr(fd, mask->id.lib, parent->id); | ||||
| } | } | ||||
| static void lib_link_mask(FileData *fd, Main *UNUSED(bmain), Mask *mask) | static void lib_link_mask(FileData *fd, Main *UNUSED(bmain), Mask *mask) | ||||
| { | { | ||||
| for (MaskLayer *masklay = mask->masklayers.first; masklay; masklay = masklay->next) { | for (MaskLayer *masklay = mask->masklayers.first; masklay; masklay = masklay->next) { | ||||
| MaskSpline *spline; | MaskSpline *spline; | ||||
| spline = masklay->splines.first; | spline = masklay->splines.first; | ||||
| ▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | switch (m->type) { | ||||
| tm->target = newlibadr(fd, linestyle->id.lib, tm->target); | tm->target = newlibadr(fd, linestyle->id.lib, tm->target); | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| for (int a = 0; a < MAX_MTEX; a++) { | for (int a = 0; a < MAX_MTEX; a++) { | ||||
| MTex *mtex = linestyle->mtex[a]; | MTex *mtex = linestyle->mtex[a]; | ||||
| if (mtex) { | if (mtex) { | ||||
| mtex->tex = newlibadr_us(fd, linestyle->id.lib, mtex->tex); | mtex->tex = newlibadr(fd, linestyle->id.lib, mtex->tex); | ||||
| mtex->object = newlibadr(fd, linestyle->id.lib, mtex->object); | mtex->object = newlibadr(fd, linestyle->id.lib, mtex->object); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static void direct_link_linestyle_color_modifier(FileData *fd, LineStyleModifier *modifier) | static void direct_link_linestyle_color_modifier(FileData *fd, LineStyleModifier *modifier) | ||||
| { | { | ||||
| switch (modifier->type) { | switch (modifier->type) { | ||||
| ▲ Show 20 Lines • Show All 1,154 Lines • ▼ Show 20 Lines | if (fd->memfile == NULL) { | ||||
| /* Yep, second splitting... but this is a very cheap operation, so no big deal. */ | /* Yep, second splitting... but this is a very cheap operation, so no big deal. */ | ||||
| blo_split_main(&mainlist, bfd->main); | blo_split_main(&mainlist, bfd->main); | ||||
| for (Main *mainvar = mainlist.first; mainvar; mainvar = mainvar->next) { | for (Main *mainvar = mainlist.first; mainvar; mainvar = mainvar->next) { | ||||
| BLI_assert(mainvar->versionfile != 0); | BLI_assert(mainvar->versionfile != 0); | ||||
| do_versions_after_linking(mainvar, fd->reports); | do_versions_after_linking(mainvar, fd->reports); | ||||
| } | } | ||||
| blo_join_main(&mainlist); | blo_join_main(&mainlist); | ||||
| /* We cannot do that here in undo case, we play too much with IDs from different memory | |||||
| * realms, and Main database is in pretty bad state currently. */ | |||||
| /* Also, this does not take into account old, deprecated data, so we have to do it after | |||||
| * `do_versions_after_linking()`. */ | |||||
| BKE_main_id_refcount_recompute(bfd->main, false); | |||||
brechtUnsubmitted Done Inline ActionsThis comment is confusing, what can't we do here? Is this code supposed to be commented out? brecht: This comment is confusing, what can't we do here? Is this code supposed to be commented out? | |||||
mont29AuthorUnsubmitted Done Inline ActionsWe cannot call that BKE_main_id_refcount_recompute function here in undo case (i.e. when fd->memfile != NULL, because then bmain is not in its final state, some UI-related data-blocks are still to be properly swapped later in the code path. mont29: We cannot call that `BKE_main_id_refcount_recompute` function here in undo case (i.e. when `fd… | |||||
brechtUnsubmitted Done Inline ActionsAh ok, I was a bit confused by the wording. Maybe leave out the word "here" from that sentence. brecht: Ah ok, I was a bit confused by the wording. Maybe leave out the word "here" from that sentence. | |||||
| /* After all data has been read and versioned, uses LIB_TAG_NEW. */ | /* After all data has been read and versioned, uses LIB_TAG_NEW. */ | ||||
| ntreeUpdateAllNew(bfd->main); | ntreeUpdateAllNew(bfd->main); | ||||
| } | } | ||||
| placeholders_ensure_valid(bfd->main); | placeholders_ensure_valid(bfd->main); | ||||
| BKE_main_id_tag_all(bfd->main, LIB_TAG_NEW, false); | BKE_main_id_tag_all(bfd->main, LIB_TAG_NEW, false); | ||||
| ▲ Show 20 Lines • Show All 1,692 Lines • ▼ Show 20 Lines | for (mainvar = ((Main *)(*fd)->mainlist->first)->next; mainvar; mainvar = mainvar->next) { | ||||
| /* We need to split out IDs already existing, | /* We need to split out IDs already existing, | ||||
| * or they will go again through do_versions - bad, very bad! */ | * or they will go again through do_versions - bad, very bad! */ | ||||
| split_main_newid(mainvar, main_newid); | split_main_newid(mainvar, main_newid); | ||||
| do_versions_after_linking(main_newid, (*fd)->reports); | do_versions_after_linking(main_newid, (*fd)->reports); | ||||
| add_main_to_main(mainvar, main_newid); | add_main_to_main(mainvar, main_newid); | ||||
| } | } | ||||
| BKE_main_free(main_newid); | BKE_main_free(main_newid); | ||||
| blo_join_main((*fd)->mainlist); | blo_join_main((*fd)->mainlist); | ||||
| mainvar = (*fd)->mainlist->first; | mainvar = (*fd)->mainlist->first; | ||||
| MEM_freeN((*fd)->mainlist); | MEM_freeN((*fd)->mainlist); | ||||
| /* This does not take into account old, deprecated data, so we have to do it after | |||||
| * `do_versions_after_linking()`. */ | |||||
| BKE_main_id_refcount_recompute(mainvar, false); | |||||
| /* After all data has been read and versioned, uses LIB_TAG_NEW. */ | /* After all data has been read and versioned, uses LIB_TAG_NEW. */ | ||||
| ntreeUpdateAllNew(mainvar); | ntreeUpdateAllNew(mainvar); | ||||
| placeholders_ensure_valid(mainvar); | placeholders_ensure_valid(mainvar); | ||||
| BKE_main_id_tag_all(mainvar, LIB_TAG_NEW, false); | BKE_main_id_tag_all(mainvar, LIB_TAG_NEW, false); | ||||
| /* Make all relative paths, relative to the open blend file. */ | /* Make all relative paths, relative to the open blend file. */ | ||||
| ▲ Show 20 Lines • Show All 345 Lines • ▼ Show 20 Lines | if (mainptr->versionfile) { | ||||
| add_main_to_main(mainptr, main_newid); | add_main_to_main(mainptr, main_newid); | ||||
| } | } | ||||
| /* Lib linking. */ | /* Lib linking. */ | ||||
| if (mainptr->curlib->filedata) { | if (mainptr->curlib->filedata) { | ||||
| lib_link_all(mainptr->curlib->filedata, mainptr); | lib_link_all(mainptr->curlib->filedata, mainptr); | ||||
| } | } | ||||
| /* Note: No need to call `do_versions_after_linking()` or `BKE_main_id_refcount_recompute()` | |||||
| * here, as this function is only called for library 'subset' data handling, as part of either | |||||
| * full blendfile reading (`blo_read_file_internal()`), or libdata linking | |||||
| * (`library_link_end()`). */ | |||||
| /* Free file data we no longer need. */ | /* Free file data we no longer need. */ | ||||
| if (mainptr->curlib->filedata) { | if (mainptr->curlib->filedata) { | ||||
| blo_filedata_free(mainptr->curlib->filedata); | blo_filedata_free(mainptr->curlib->filedata); | ||||
| } | } | ||||
| mainptr->curlib->filedata = NULL; | mainptr->curlib->filedata = NULL; | ||||
| } | } | ||||
| BKE_main_free(main_newid); | BKE_main_free(main_newid); | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
Note that that one is kept because used by deprecated pointers (IPO ones)... Not sure how important those are currently.