WIP: Readfile: replace blend_read_lib/blend_read_expand by foreach_id #105666

Closed
Bastien Montagne wants to merge 1 commits from mont29:tmp-readfile-liblink into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
92 changed files with 229 additions and 1470 deletions

View File

@ -391,7 +391,7 @@ void BKE_pose_blend_write(struct BlendWriter *writer, struct bPose *pose, struct
void BKE_pose_blend_read_data(struct BlendDataReader *reader,
struct ID *id_owner,
struct bPose *pose) ATTR_NONNULL(1, 2);
void BKE_pose_blend_read_lib(struct BlendLibReader *reader, struct Object *ob, struct bPose *pose)
void BKE_pose_blend_read_after_liblink(struct BlendLibReader *reader, struct Object *ob, struct bPose *pose)
ATTR_NONNULL(1, 2);
/* `action_mirror.cc` */

View File

@ -131,9 +131,6 @@ void BKE_animdata_merge_copy(struct Main *bmain,
void BKE_animdata_blend_write(struct BlendWriter *writer, struct ID *id);
void BKE_animdata_blend_read_data(struct BlendDataReader *reader, struct ID *id);
void BKE_animdata_blend_read_lib(struct BlendLibReader *reader,
struct ID *id,
struct AnimData *adt);
#ifdef __cplusplus
}

View File

@ -102,9 +102,6 @@ void BKE_keyingsets_free(struct ListBase *list);
void BKE_keyingsets_blend_write(struct BlendWriter *writer, struct ListBase *list);
void BKE_keyingsets_blend_read_data(struct BlendDataReader *reader, struct ListBase *list);
void BKE_keyingsets_blend_read_lib(struct BlendLibReader *reader,
struct ID *id,
struct ListBase *list);
/* ************************************* */
/* Path Fixing API */

View File

@ -316,7 +316,6 @@ void BKE_collection_blend_write_nolib(struct BlendWriter *writer, struct Collect
void BKE_collection_blend_read_data(struct BlendDataReader *reader,
struct Collection *collection,
struct ID *owner_id);
void BKE_collection_blend_read_lib(struct BlendLibReader *reader, struct Collection *collection);
/* Iteration callbacks. */

View File

@ -371,9 +371,6 @@ void BKE_constraint_blend_write(struct BlendWriter *writer, struct ListBase *con
void BKE_constraint_blend_read_data(struct BlendDataReader *reader,
struct ID *id_owner,
struct ListBase *lb);
void BKE_constraint_blend_read_lib(struct BlendLibReader *reader,
struct ID *id,
struct ListBase *conlist);
#ifdef __cplusplus
}

View File

@ -635,15 +635,9 @@ void BKE_fmodifiers_blend_write(struct BlendWriter *writer, struct ListBase *fmo
void BKE_fmodifiers_blend_read_data(struct BlendDataReader *reader,
ListBase *fmodifiers,
struct FCurve *curve);
void BKE_fmodifiers_blend_read_lib(struct BlendLibReader *reader,
struct ID *id,
struct ListBase *fmodifiers);
void BKE_fcurve_blend_write(struct BlendWriter *writer, struct ListBase *fcurves);
void BKE_fcurve_blend_read_data(struct BlendDataReader *reader, struct ListBase *fcurves);
void BKE_fcurve_blend_read_lib(struct BlendLibReader *reader,
struct ID *id,
struct ListBase *fcurves);
#ifdef __cplusplus
}

View File

@ -454,7 +454,6 @@ void BKE_gpencil_modifier_blend_write(struct BlendWriter *writer, struct ListBas
void BKE_gpencil_modifier_blend_read_data(struct BlendDataReader *reader,
struct ListBase *lb,
struct Object *ob);
void BKE_gpencil_modifier_blend_read_lib(struct BlendLibReader *reader, struct Object *ob);
#ifdef __cplusplus
}

View File

@ -314,7 +314,6 @@ void IDP_BlendReadData_impl(struct BlendDataReader *reader,
struct IDProperty **prop,
const char *caller_func_id);
#define IDP_BlendDataRead(reader, prop) IDP_BlendReadData_impl(reader, prop, __func__)
void IDP_BlendReadLib(struct BlendLibReader *reader, struct ID *self_id, struct IDProperty *prop);
typedef enum eIDPropertyUIDataType {
/** Other properties types that don't support RNA UI data. */

View File

@ -100,7 +100,7 @@ typedef void (*IDTypeBlendWriteFunction)(struct BlendWriter *writer,
struct ID *id,
const void *id_address);
typedef void (*IDTypeBlendReadDataFunction)(struct BlendDataReader *reader, struct ID *id);
typedef void (*IDTypeBlendReadLibFunction)(struct BlendLibReader *reader, struct ID *id);
typedef void (*IDTypeBlendReadAfterLiblinkFunction)(struct BlendLibReader *reader, struct ID *id);
typedef void (*IDTypeBlendReadUndoPreserve)(struct BlendLibReader *reader,
struct ID *id_new,
@ -205,9 +205,12 @@ typedef struct IDTypeInfo {
IDTypeBlendReadDataFunction blend_read_data;
/**
* Update pointers to other id data blocks.
* Used to do some validation and/or complex processing on the ID after it has been fully read
* and its ID pointers have been updated to valid values (lib linking process).
*
* Note that this is still called _before_ the `do_versions_after_linking` versionning code.
*/
IDTypeBlendReadLibFunction blend_read_lib;
IDTypeBlendReadAfterLiblinkFunction blend_read_after_liblink;
/**
* Allow an ID type to preserve some of its data across (memfile) undo steps.

View File

@ -272,7 +272,7 @@ void BKE_view_layer_blend_write(struct BlendWriter *writer,
const struct Scene *scene,
struct ViewLayer *view_layer);
void BKE_view_layer_blend_read_data(struct BlendDataReader *reader, struct ViewLayer *view_layer);
void BKE_view_layer_blend_read_lib(struct BlendLibReader *reader,
void BKE_view_layer_blend_read_after_liblink(struct BlendLibReader *reader,
struct ID *self_id,
struct ViewLayer *view_layer);

View File

@ -624,7 +624,6 @@ void BKE_modifier_blend_write(struct BlendWriter *writer,
void BKE_modifier_blend_read_data(struct BlendDataReader *reader,
struct ListBase *lb,
struct Object *ob);
void BKE_modifier_blend_read_lib(struct BlendLibReader *reader, struct Object *ob);
#ifdef __cplusplus
}

View File

@ -487,7 +487,6 @@ void BKE_nla_blend_write(struct BlendWriter *writer, struct ListBase *tracks);
void BKE_nla_blend_read_data(struct BlendDataReader *reader,
struct ID *id_owner,
struct ListBase *tracks);
void BKE_nla_blend_read_lib(struct BlendLibReader *reader, struct ID *id, struct ListBase *tracks);
#ifdef __cplusplus
}

View File

@ -56,7 +56,6 @@ void ntreeLocalMerge(Main *bmain, bNodeTree *localtree, bNodeTree *ntree);
* \note `ntree` itself has been read!
*/
void ntreeBlendReadData(BlendDataReader *reader, ID *owner_id, bNodeTree *ntree);
void ntreeBlendReadLib(BlendLibReader *reader, bNodeTree *ntree);
/* -------------------------------------------------------------------- */
/** \name Node Tree Interface

View File

@ -709,11 +709,6 @@ void BKE_object_to_curve_clear(struct Object *object);
void BKE_object_check_uuids_unique_and_report(const struct Object *object);
void BKE_object_modifiers_lib_link_common(void *user_data,
struct Object *ob,
struct ID **idpoin,
int cb_flag);
/**
* Return the last subsurf modifier of an object, this does not check whether modifiers on top of
* it are disabled. Return NULL if no such modifier is found.

View File

@ -261,7 +261,6 @@ Brush *BKE_paint_toolslots_brush_get(Paint *paint, int slot_index);
void BKE_paint_blend_write(BlendWriter *writer, Paint *paint);
void BKE_paint_blend_read_data(BlendDataReader *reader, const Scene *scene, Paint *paint);
void BKE_paint_blend_read_lib(BlendLibReader *reader, Scene *scene, Paint *paint);
#define SCULPT_FACE_SET_NONE 0

View File

@ -698,13 +698,10 @@ extern void (*BKE_particle_batch_cache_free_cb)(struct ParticleSystem *psys);
void BKE_particle_partdeflect_blend_read_data(struct BlendDataReader *reader,
struct PartDeflect *pd);
void BKE_particle_partdeflect_blend_read_lib(struct BlendLibReader *reader,
struct ID *id,
struct PartDeflect *pd);
void BKE_particle_system_blend_write(struct BlendWriter *writer, struct ListBase *particles);
void BKE_particle_system_blend_read_data(struct BlendDataReader *reader,
struct ListBase *particles);
void BKE_particle_system_blend_read_lib(struct BlendLibReader *reader,
void BKE_particle_system_blend_read_after_liblink(struct BlendLibReader *reader,
struct Object *ob,
struct ID *id,
struct ListBase *particles);

View File

@ -124,9 +124,9 @@ typedef struct SpaceType {
/**
* Update pointers to other id data blocks.
*/
void (*blend_read_lib)(struct BlendLibReader *reader,
struct ID *parent_id,
struct SpaceLink *space_link);
void (*blend_read_after_liblink)(struct BlendLibReader *reader,
struct ID *parent_id,
struct SpaceLink *space_link);
/**
* Write all structs that should be saved in a .blend file.
@ -629,9 +629,15 @@ bool BKE_screen_area_map_blend_read_data(struct BlendDataReader *reader,
* For the saved 2.50 files without `regiondata`.
*/
void BKE_screen_view3d_do_versions_250(struct View3D *v3d, ListBase *regions);
void BKE_screen_area_blend_read_lib(struct BlendLibReader *reader,
struct ID *parent_id,
struct ScrArea *area);
/**
* Called after lib linking process is done, to perform some validation on the read data, or some
* complex specific reading process that requires the data to be fully read and ID pointers to be
* valid.
*/
void BKE_screen_area_blend_read_after_liblink(struct BlendLibReader *reader,
struct ID *parent_id,
struct ScrArea *area);
/**
* Cannot use #IDTypeInfo callback yet, because of the return value.
*/

View File

@ -184,7 +184,6 @@ void BKE_shaderfx_blend_write(struct BlendWriter *writer, struct ListBase *fxbas
void BKE_shaderfx_blend_read_data(struct BlendDataReader *reader,
struct ListBase *lb,
struct Object *ob);
void BKE_shaderfx_blend_read_lib(struct BlendLibReader *reader, struct Object *ob);
#ifdef __cplusplus
}

View File

@ -41,9 +41,6 @@ void BKE_viewer_path_copy(ViewerPath *dst, const ViewerPath *src);
bool BKE_viewer_path_equal(const ViewerPath *a, const ViewerPath *b);
void BKE_viewer_path_blend_write(struct BlendWriter *writer, const ViewerPath *viewer_path);
void BKE_viewer_path_blend_read_data(struct BlendDataReader *reader, ViewerPath *viewer_path);
void BKE_viewer_path_blend_read_lib(struct BlendLibReader *reader,
struct ID *self_id,
ViewerPath *viewer_path);
void BKE_viewer_path_foreach_id(struct LibraryForeachIDData *data, ViewerPath *viewer_path);
void BKE_viewer_path_id_remap(ViewerPath *viewer_path, const struct IDRemapper *mappings);

View File

@ -236,33 +236,6 @@ static void action_blend_read_data(BlendDataReader *reader, ID *id)
BKE_previewimg_blend_read(reader, act->preview);
}
static void blend_read_lib_constraint_channels(BlendLibReader *reader, ID *id, ListBase *chanbase)
{
LISTBASE_FOREACH (bConstraintChannel *, chan, chanbase) {
BLO_read_id_address(reader, id, &chan->ipo);
}
}
static void action_blend_read_lib(BlendLibReader *reader, ID *id)
{
bAction *act = (bAction *)id;
/* XXX deprecated - old animation system <<< */
LISTBASE_FOREACH (bActionChannel *, chan, &act->chanbase) {
BLO_read_id_address(reader, id, &chan->ipo);
blend_read_lib_constraint_channels(reader, &act->id, &chan->constraintChannels);
}
/* >>> XXX deprecated - old animation system */
BKE_fcurve_blend_read_lib(reader, id, &act->curves);
LISTBASE_FOREACH (TimeMarker *, marker, &act->markers) {
if (marker->camera) {
BLO_read_id_address(reader, id, &marker->camera);
}
}
}
static IDProperty *action_asset_type_property(const bAction *action)
{
const bool is_single_frame = BKE_action_has_single_frame(action);
@ -309,7 +282,7 @@ IDTypeInfo IDType_ID_AC = {
/*blend_write*/ action_blend_write,
/*blend_read_data*/ action_blend_read_data,
/*blend_read_lib*/ action_blend_read_lib,
/*blend_read_after_liblink*/ nullptr,
/*blend_read_undo_preserve*/ nullptr,
@ -1899,7 +1872,7 @@ void BKE_pose_blend_read_data(BlendDataReader *reader, ID *id_owner, bPose *pose
}
}
void BKE_pose_blend_read_lib(BlendLibReader *reader, Object *ob, bPose *pose)
void BKE_pose_blend_read_after_liblink(BlendLibReader *reader, Object *ob, bPose *pose)
{
bArmature *arm = static_cast<bArmature *>(ob->data);
@ -1917,13 +1890,8 @@ void BKE_pose_blend_read_lib(BlendLibReader *reader, Object *ob, bPose *pose)
}
LISTBASE_FOREACH (bPoseChannel *, pchan, &pose->chanbase) {
BKE_constraint_blend_read_lib(reader, (ID *)ob, &pchan->constraints);
pchan->bone = BKE_armature_find_bone_name(arm, pchan->name);
IDP_BlendReadLib(reader, &ob->id, pchan->prop);
BLO_read_id_address(reader, &ob->id, &pchan->custom);
if (UNLIKELY(pchan->bone == nullptr)) {
rebuild = true;
}

View File

@ -1499,22 +1499,3 @@ void BKE_animdata_blend_read_data(BlendDataReader *reader, ID *id)
BLO_read_data_address(reader, &adt->act_track);
BLO_read_data_address(reader, &adt->actstrip);
}
void BKE_animdata_blend_read_lib(BlendLibReader *reader, ID *id, AnimData *adt)
{
if (adt == nullptr) {
return;
}
/* link action data */
BLO_read_id_address(reader, id, &adt->action);
BLO_read_id_address(reader, id, &adt->tmpact);
/* link drivers */
BKE_fcurve_blend_read_lib(reader, id, &adt->drivers);
/* overrides don't have lib-link for now, so no need to do anything */
/* link NLA-data */
BKE_nla_blend_read_lib(reader, id, &adt->nla_tracks);
}

View File

@ -321,15 +321,6 @@ void BKE_keyingsets_blend_read_data(BlendDataReader *reader, ListBase *list)
}
}
void BKE_keyingsets_blend_read_lib(BlendLibReader *reader, ID *id, ListBase *list)
{
LISTBASE_FOREACH (KeyingSet *, ks, list) {
LISTBASE_FOREACH (KS_Path *, ksp, &ks->paths) {
BLO_read_id_address(reader, id, &ksp->id);
}
}
}
/* ***************************************** */
/* Evaluation Data-Setting Backend */

View File

@ -262,23 +262,6 @@ static void armature_blend_read_data(BlendDataReader *reader, ID *id)
BKE_armature_bone_hash_make(arm);
}
static void lib_link_bones(BlendLibReader *reader, ID *self_id, Bone *bone)
{
IDP_BlendReadLib(reader, self_id, bone->prop);
LISTBASE_FOREACH (Bone *, curbone, &bone->childbase) {
lib_link_bones(reader, self_id, curbone);
}
}
static void armature_blend_read_lib(BlendLibReader *reader, ID *id)
{
bArmature *arm = (bArmature *)id;
LISTBASE_FOREACH (Bone *, curbone, &arm->bonebase) {
lib_link_bones(reader, id, curbone);
}
}
IDTypeInfo IDType_ID_AR = {
/*id_code*/ ID_AR,
/*id_filter*/ FILTER_ID_AR,
@ -301,7 +284,7 @@ IDTypeInfo IDType_ID_AR = {
/*blend_write*/ armature_blend_write,
/*blend_read_data*/ armature_blend_read_data,
/*blend_read_lib*/ armature_blend_read_lib,
/*blend_read_after_liblink*/ nullptr,
/*blend_read_undo_preserve*/ nullptr,

View File

@ -359,22 +359,13 @@ static void brush_blend_read_data(BlendDataReader *reader, ID *id)
brush->icon_imbuf = nullptr;
}
static void brush_blend_read_lib(BlendLibReader *reader, ID *id)
static void brush_blend_read_after_liblink(BlendLibReader * /*reader*/, ID *id)
{
Brush *brush = (Brush *)id;
Brush *brush = reinterpret_cast<Brush *>(id);
/* brush->(mask_)mtex.obj is ignored on purpose? */
BLO_read_id_address(reader, id, &brush->mtex.tex);
BLO_read_id_address(reader, id, &brush->mask_mtex.tex);
BLO_read_id_address(reader, id, &brush->clone.image);
BLO_read_id_address(reader, id, &brush->toggle_brush);
BLO_read_id_address(reader, id, &brush->paint_curve);
/* link default grease pencil palette */
/* Update brush settings depending on availability of other IDs. */
if (brush->gpencil_settings != nullptr) {
if (brush->gpencil_settings->flag & GP_BRUSH_MATERIAL_PINNED) {
BLO_read_id_address(reader, id, &brush->gpencil_settings->material);
if (!brush->gpencil_settings->material) {
brush->gpencil_settings->flag &= ~GP_BRUSH_MATERIAL_PINNED;
}
@ -382,7 +373,6 @@ static void brush_blend_read_lib(BlendLibReader *reader, ID *id)
else {
brush->gpencil_settings->material = nullptr;
}
BLO_read_id_address(reader, id, &brush->gpencil_settings->material_alt);
}
}
@ -441,7 +431,7 @@ IDTypeInfo IDType_ID_BR = {
/*blend_write*/ brush_blend_write,
/*blend_read_data*/ brush_blend_read_data,
/*blend_read_lib*/ brush_blend_read_lib,
/*blend_read_after_liblink*/ brush_blend_read_after_liblink,
/*blend_read_undo_preserve*/ brush_undo_preserve,

View File

@ -144,7 +144,7 @@ IDTypeInfo IDType_ID_CF = {
/*blend_write*/ cache_file_blend_write,
/*blend_read_data*/ cache_file_blend_read_data,
/*blend_read_lib*/ nullptr,
/*blend_read_after_liblink*/ nullptr,
/*blend_read_undo_preserve*/ nullptr,

View File

@ -230,20 +230,6 @@ static void camera_blend_read_data(BlendDataReader *reader, ID *id)
}
}
static void camera_blend_read_lib(BlendLibReader *reader, ID *id)
{
Camera *ca = (Camera *)id;
BLO_read_id_address(reader, id, &ca->ipo); /* deprecated, for versioning */
BLO_read_id_address(reader, id, &ca->dof_ob); /* deprecated, for versioning */
BLO_read_id_address(reader, id, &ca->dof.focus_object);
LISTBASE_FOREACH (CameraBGImage *, bgpic, &ca->bg_images) {
BLO_read_id_address(reader, id, &bgpic->ima);
BLO_read_id_address(reader, id, &bgpic->clip);
}
}
IDTypeInfo IDType_ID_CA = {
/*id_code*/ ID_CA,
/*id_filter*/ FILTER_ID_CA,
@ -266,7 +252,7 @@ IDTypeInfo IDType_ID_CA = {
/*blend_write*/ camera_blend_write,
/*blend_read_data*/ camera_blend_read_data,
/*blend_read_lib*/ camera_blend_read_lib,
/*blend_read_after_liblink*/ nullptr,
/*blend_read_undo_preserve*/ nullptr,

View File

@ -304,31 +304,23 @@ static void collection_blend_read_data(BlendDataReader *reader, ID *id)
BKE_collection_blend_read_data(reader, collection, nullptr);
}
static void lib_link_collection_data(BlendLibReader *reader, ID *self_id, Collection *collection)
static void collection_blend_read_after_liblink(BlendLibReader * /*reader*/, ID *id)
{
Collection *collection = reinterpret_cast<Collection *>(id);
/* Sanity check over Collection/Object data. */
BLI_assert(collection->runtime.gobject_hash == nullptr);
LISTBASE_FOREACH_MUTABLE (CollectionObject *, cob, &collection->gobject) {
BLO_read_id_address(reader, self_id, &cob->ob);
if (cob->ob == nullptr) {
BLI_freelinkN(&collection->gobject, cob);
}
}
LISTBASE_FOREACH (CollectionChild *, child, &collection->children) {
BLO_read_id_address(reader, self_id, &child->collection);
}
}
void BKE_collection_blend_read_lib(BlendLibReader *reader, Collection *collection)
{
lib_link_collection_data(reader, &collection->id, collection);
}
static void collection_blend_read_lib(BlendLibReader *reader, ID *id)
{
Collection *collection = (Collection *)id;
BKE_collection_blend_read_lib(reader, collection);
/* foreach_id code called by generic lib_link process has most likely set this flag, however it
* is not needed during readfile process since the runtime data is affects are not yet built, so
* just clear it here. */
BLI_assert(collection->runtime.gobject_hash == nullptr);
collection->runtime.tag &= ~COLLECTION_TAG_COLLECTION_OBJECT_DIRTY;
}
IDTypeInfo IDType_ID_GR = {
@ -353,7 +345,7 @@ IDTypeInfo IDType_ID_GR = {
/*blend_write*/ collection_blend_write,
/*blend_read_data*/ collection_blend_read_data,
/*blend_read_lib*/ collection_blend_read_lib,
/*blend_read_after_liblink*/ collection_blend_read_after_liblink,
/*blend_read_undo_preserve*/ nullptr,
@ -1864,7 +1856,7 @@ void BKE_main_collections_parent_relations_rebuild(Main *bmain)
}
/* We may have parent chains outside of scene's master_collection context? At least, readfile's
* lib_link_collection_data() seems to assume that, so do the same here. */
* #collection_blend_read_after_liblink() seems to assume that, so do the same here. */
LISTBASE_FOREACH (Collection *, collection, &bmain->collections) {
if (collection->runtime.tag & COLLECTION_TAG_RELATION_REBUILD) {
/* NOTE: we do not have easy access to 'which collections is root' info in that case, which

View File

@ -6562,35 +6562,3 @@ void BKE_constraint_blend_read_data(BlendDataReader *reader, ID *id_owner, ListB
}
}
}
/* temp struct used to transport needed info to lib_link_constraint_cb() */
struct tConstraintLinkData {
BlendLibReader *reader;
ID *id;
};
/* callback function used to relink constraint ID-links */
static void lib_link_constraint_cb(bConstraint * /*con*/,
ID **idpoin,
bool /*is_reference*/,
void *userdata)
{
tConstraintLinkData *cld = (tConstraintLinkData *)userdata;
BLO_read_id_address(cld->reader, cld->id, idpoin);
}
void BKE_constraint_blend_read_lib(BlendLibReader *reader, ID *id, ListBase *conlist)
{
tConstraintLinkData cld;
/* legacy fixes */
LISTBASE_FOREACH (bConstraint *, con, conlist) {
/* own ipo, all constraints have it */
BLO_read_id_address(reader, id, &con->ipo); /* XXX deprecated - old animation system */
}
/* relink all ID-blocks used by the constraints */
cld.reader = reader;
cld.id = id;
BKE_constraints_id_loop(conlist, lib_link_constraint_cb, IDWALK_NOP, &cld);
}

View File

@ -272,25 +272,6 @@ static void curve_blend_read_data(BlendDataReader *reader, ID *id)
}
}
static void curve_blend_read_lib(BlendLibReader *reader, ID *id)
{
Curve *cu = (Curve *)id;
for (int a = 0; a < cu->totcol; a++) {
BLO_read_id_address(reader, id, &cu->mat[a]);
}
BLO_read_id_address(reader, id, &cu->bevobj);
BLO_read_id_address(reader, id, &cu->taperobj);
BLO_read_id_address(reader, id, &cu->textoncurve);
BLO_read_id_address(reader, id, &cu->vfont);
BLO_read_id_address(reader, id, &cu->vfontb);
BLO_read_id_address(reader, id, &cu->vfonti);
BLO_read_id_address(reader, id, &cu->vfontbi);
BLO_read_id_address(reader, id, &cu->ipo); /* XXX deprecated - old animation system */
BLO_read_id_address(reader, id, &cu->key);
}
IDTypeInfo IDType_ID_CU_LEGACY = {
/*id_code*/ ID_CU_LEGACY,
/*id_filter*/ FILTER_ID_CU_LEGACY,
@ -313,7 +294,7 @@ IDTypeInfo IDType_ID_CU_LEGACY = {
/*blend_write*/ curve_blend_write,
/*blend_read_data*/ curve_blend_read_data,
/*blend_read_lib*/ curve_blend_read_lib,
/*blend_read_after_liblink*/ nullptr,
/*blend_read_undo_preserve*/ nullptr,

View File

@ -130,15 +130,6 @@ static void curves_blend_read_data(BlendDataReader *reader, ID *id)
BLO_read_pointer_array(reader, (void **)&curves->mat);
}
static void curves_blend_read_lib(BlendLibReader *reader, ID *id)
{
Curves *curves = (Curves *)id;
for (int a = 0; a < curves->totcol; a++) {
BLO_read_id_address(reader, id, &curves->mat[a]);
}
BLO_read_id_address(reader, id, &curves->surface);
}
IDTypeInfo IDType_ID_CV = {
/*id_code*/ ID_CV,
/*id_filter*/ FILTER_ID_CV,
@ -161,7 +152,7 @@ IDTypeInfo IDType_ID_CV = {
/*blend_write*/ curves_blend_write,
/*blend_read_data*/ curves_blend_read_data,
/*blend_read_lib*/ curves_blend_read_lib,
/*blend_read_after_liblink*/ nullptr,
/*blend_read_undo_preserve*/ nullptr,

View File

@ -2507,20 +2507,6 @@ void BKE_fmodifiers_blend_read_data(BlendDataReader *reader, ListBase *fmodifier
}
}
void BKE_fmodifiers_blend_read_lib(BlendLibReader *reader, ID *id, ListBase *fmodifiers)
{
LISTBASE_FOREACH (FModifier *, fcm, fmodifiers) {
/* data for specific modifiers */
switch (fcm->type) {
case FMODIFIER_TYPE_PYTHON: {
FMod_Python *data = (FMod_Python *)fcm->data;
BLO_read_id_address(reader, id, &data->script);
break;
}
}
}
}
void BKE_fcurve_blend_write(BlendWriter *writer, ListBase *fcurves)
{
BLO_write_struct_list(writer, FCurve, fcurves);
@ -2616,28 +2602,4 @@ void BKE_fcurve_blend_read_data(BlendDataReader *reader, ListBase *fcurves)
}
}
void BKE_fcurve_blend_read_lib(BlendLibReader *reader, ID *id, ListBase *fcurves)
{
if (fcurves == nullptr) {
return;
}
/* relink ID-block references... */
LISTBASE_FOREACH (FCurve *, fcu, fcurves) {
/* driver data */
if (fcu->driver) {
ChannelDriver *driver = fcu->driver;
LISTBASE_FOREACH (DriverVar *, dvar, &driver->variables) {
DRIVER_TARGETS_LOOPER_BEGIN (dvar) {
BLO_read_id_address(reader, id, &dtar->id);
}
DRIVER_TARGETS_LOOPER_END;
}
}
/* modifiers */
BKE_fmodifiers_blend_read_lib(reader, id, &fcu->modifiers);
}
}
/** \} */

View File

@ -262,23 +262,6 @@ static void greasepencil_blend_read_data(BlendDataReader *reader, ID *id)
BKE_gpencil_blend_read_data(reader, gpd);
}
static void greasepencil_blend_read_lib(BlendLibReader *reader, ID *id)
{
bGPdata *gpd = (bGPdata *)id;
/* Relink all data-block linked by GP data-block. */
/* Layers */
LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
/* Layer -> Parent References */
BLO_read_id_address(reader, id, &gpl->parent);
}
/* materials */
for (int a = 0; a < gpd->totcol; a++) {
BLO_read_id_address(reader, id, &gpd->mat[a]);
}
}
IDTypeInfo IDType_ID_GD_LEGACY = {
/*id_code*/ ID_GD_LEGACY,
/*id_filter*/ FILTER_ID_GD_LEGACY,
@ -301,7 +284,7 @@ IDTypeInfo IDType_ID_GD_LEGACY = {
/*blend_write*/ greasepencil_blend_write,
/*blend_read_data*/ greasepencil_blend_read_data,
/*blend_read_lib*/ greasepencil_blend_read_lib,
/*blend_read_after_liblink*/ nullptr,
/*blend_read_undo_preserve*/ nullptr,

View File

@ -1034,8 +1034,3 @@ void BKE_gpencil_modifier_blend_read_data(BlendDataReader *reader, ListBase *lb,
}
}
}
void BKE_gpencil_modifier_blend_read_lib(BlendLibReader *reader, Object *ob)
{
BKE_gpencil_modifiers_foreach_ID_link(ob, BKE_object_modifiers_lib_link_common, reader);
}

View File

@ -192,22 +192,6 @@ static void grease_pencil_blend_read_data(BlendDataReader *reader, ID *id)
grease_pencil->runtime = MEM_new<blender::bke::GreasePencilRuntime>(__func__);
}
static void grease_pencil_blend_read_lib(BlendLibReader *reader, ID *id)
{
GreasePencil *grease_pencil = reinterpret_cast<GreasePencil *>(id);
for (int i = 0; i < grease_pencil->material_array_num; i++) {
BLO_read_id_address(reader, id, &grease_pencil->material_array[i]);
}
for (int i = 0; i < grease_pencil->drawing_array_num; i++) {
GreasePencilDrawingBase *drawing_base = grease_pencil->drawing_array[i];
if (drawing_base->type == GP_DRAWING_REFERENCE) {
GreasePencilDrawingReference *drawing_reference =
reinterpret_cast<GreasePencilDrawingReference *>(drawing_base);
BLO_read_id_address(reader, id, &drawing_reference->id_reference);
}
}
}
IDTypeInfo IDType_ID_GP = {
/*id_code*/ ID_GP,
/*id_filter*/ FILTER_ID_GP,
@ -230,7 +214,7 @@ IDTypeInfo IDType_ID_GP = {
/*blend_write*/ grease_pencil_blend_write,
/*blend_read_data*/ grease_pencil_blend_read_data,
/*blend_read_lib*/ grease_pencil_blend_read_lib,
/*blend_read_after_liblink*/ nullptr,
/*blend_read_undo_preserve*/ nullptr,

View File

@ -1478,43 +1478,6 @@ void IDP_BlendReadData_impl(BlendDataReader *reader, IDProperty **prop, const ch
}
}
void IDP_BlendReadLib(BlendLibReader *reader, ID *self_id, IDProperty *prop)
{
if (!prop) {
return;
}
switch (prop->type) {
case IDP_ID: /* PointerProperty */
{
void *newaddr = BLO_read_get_new_id_address(
reader, self_id, ID_IS_LINKED(self_id), IDP_Id(prop));
if (IDP_Id(prop) && !newaddr && G.debug) {
printf("Error while loading \"%s\". Data not found in file!\n", prop->name);
}
prop->data.pointer = newaddr;
break;
}
case IDP_IDPARRAY: /* CollectionProperty */
{
IDProperty *idp_array = IDP_IDPArray(prop);
for (int i = 0; i < prop->len; i++) {
IDP_BlendReadLib(reader, self_id, &(idp_array[i]));
}
break;
}
case IDP_GROUP: /* PointerProperty */
{
LISTBASE_FOREACH (IDProperty *, loop, &prop->data.group) {
IDP_BlendReadLib(reader, self_id, loop);
}
break;
}
default:
break; /* Nothing to do for other IDProps. */
}
}
eIDPropertyUIDataType IDP_ui_data_type(const IDProperty *prop)
{
if (prop->type == IDP_STRING) {

View File

@ -419,9 +419,10 @@ static void image_blend_read_data(BlendDataReader *reader, ID *id)
image_runtime_reset(ima);
}
static void image_blend_read_lib(BlendLibReader * /*reader*/, ID *id)
static void image_blend_read_after_liblink(BlendLibReader * /*reader*/, ID *id)
{
Image *ima = (Image *)id;
Image *ima = reinterpret_cast<Image *>(id);
/* Images have some kind of 'main' cache, when null we should also clear all others. */
/* Needs to be done *after* cache pointers are restored (call to
* `foreach_cache`/`blo_cache_storage_entry_restore_in_new`), easier for now to do it in
@ -455,7 +456,7 @@ constexpr IDTypeInfo get_type_info()
info.blend_write = image_blend_write;
info.blend_read_data = image_blend_read_data;
info.blend_read_lib = image_blend_read_lib;
info.blend_read_after_liblink = image_blend_read_after_liblink;
info.blend_read_undo_preserve = nullptr;

View File

@ -154,17 +154,6 @@ static void ipo_blend_read_data(BlendDataReader *reader, ID *id)
}
}
static void ipo_blend_read_lib(BlendLibReader *reader, ID *id)
{
Ipo *ipo = (Ipo *)id;
LISTBASE_FOREACH (IpoCurve *, icu, &ipo->curve) {
if (icu->driver) {
BLO_read_id_address(reader, id, &icu->driver->ob);
}
}
}
IDTypeInfo IDType_ID_IP = {
/*id_code*/ ID_IP,
/*id_filter*/ 0,
@ -187,7 +176,7 @@ IDTypeInfo IDType_ID_IP = {
/*blend_write*/ nullptr,
/*blend_read_data*/ ipo_blend_read_data,
/*blend_read_lib*/ ipo_blend_read_lib,
/*blend_read_after_liblink*/ nullptr,
/*blend_read_undo_preserve*/ nullptr,

View File

@ -179,13 +179,11 @@ static void shapekey_blend_read_data(BlendDataReader *reader, ID *id)
}
}
static void shapekey_blend_read_lib(BlendLibReader *reader, ID *id)
static void shapekey_blend_read_after_liblink(BlendLibReader * /*reader*/, ID *id)
{
Key *key = (Key *)id;
BLI_assert((key->id.tag & LIB_TAG_EXTERN) == 0);
BLO_read_id_address(reader, id, &key->ipo); /* XXX deprecated - old animation system */
BLO_read_id_address(reader, id, &key->from);
/* ShapeKeys should always only be linked indirectly through their user ID (mesh, Curve etc.), or
* be fully local data. */
BLI_assert((id->tag & LIB_TAG_EXTERN) == 0);
}
IDTypeInfo IDType_ID_KE = {
@ -212,7 +210,7 @@ IDTypeInfo IDType_ID_KE = {
/*blend_write*/ shapekey_blend_write,
/*blend_read_data*/ shapekey_blend_read_data,
/*blend_read_lib*/ shapekey_blend_read_lib,
/*blend_read_after_liblink*/ shapekey_blend_read_after_liblink,
/*blend_read_undo_preserve*/ nullptr,

View File

@ -159,13 +159,6 @@ static void lattice_blend_read_data(BlendDataReader *reader, ID *id)
lt->batch_cache = nullptr;
}
static void lattice_blend_read_lib(BlendLibReader *reader, ID *id)
{
Lattice *lt = (Lattice *)id;
BLO_read_id_address(reader, id, &lt->ipo); // XXX deprecated - old animation system
BLO_read_id_address(reader, id, &lt->key);
}
IDTypeInfo IDType_ID_LT = {
/*id_code*/ ID_LT,
/*id_filter*/ FILTER_ID_LT,
@ -188,7 +181,7 @@ IDTypeInfo IDType_ID_LT = {
/*blend_write*/ lattice_blend_write,
/*blend_read_data*/ lattice_blend_read_data,
/*blend_read_lib*/ lattice_blend_read_lib,
/*blend_read_after_liblink*/ nullptr,
/*blend_read_undo_preserve*/ nullptr,

View File

@ -2434,37 +2434,11 @@ void BKE_view_layer_blend_read_data(BlendDataReader *reader, ViewLayer *view_lay
view_layer->object_bases_hash = nullptr;
}
static void lib_link_layer_collection(BlendLibReader *reader,
ID *self_id,
LayerCollection *layer_collection,
const bool master)
void BKE_view_layer_blend_read_after_liblink(BlendLibReader * /*reader*/,
ID * /*self_id*/,
ViewLayer *view_layer)
{
/* Master collection is not a real data-block. */
if (!master) {
BLO_read_id_address(reader, self_id, &layer_collection->collection);
}
LISTBASE_FOREACH (
LayerCollection *, layer_collection_nested, &layer_collection->layer_collections) {
lib_link_layer_collection(reader, self_id, layer_collection_nested, false);
}
}
void BKE_view_layer_blend_read_lib(BlendLibReader *reader, ID *self_id, ViewLayer *view_layer)
{
LISTBASE_FOREACH (FreestyleModuleConfig *, fmc, &view_layer->freestyle_config.modules) {
BLO_read_id_address(reader, self_id, &fmc->script);
}
LISTBASE_FOREACH (FreestyleLineSet *, fls, &view_layer->freestyle_config.linesets) {
BLO_read_id_address(reader, self_id, &fls->linestyle);
BLO_read_id_address(reader, self_id, &fls->group);
}
LISTBASE_FOREACH_MUTABLE (Base *, base, &view_layer->object_bases) {
/* we only bump the use count for the collection objects */
BLO_read_id_address(reader, self_id, &base->object);
if (base->object == nullptr) {
/* Free in case linked object got lost. */
BLI_freelinkN(&view_layer->object_bases, base);
@ -2473,14 +2447,6 @@ void BKE_view_layer_blend_read_lib(BlendLibReader *reader, ID *self_id, ViewLaye
}
}
}
LISTBASE_FOREACH (LayerCollection *, layer_collection, &view_layer->layer_collections) {
lib_link_layer_collection(reader, self_id, layer_collection, true);
}
BLO_read_id_address(reader, self_id, &view_layer->mat_override);
IDP_BlendReadLib(reader, self_id, view_layer->id_properties);
}
/** \} */

View File

@ -100,7 +100,7 @@ IDTypeInfo IDType_ID_LINK_PLACEHOLDER = {
/*blend_write*/ nullptr,
/*blend_read_data*/ nullptr,
/*blend_read_lib*/ nullptr,
/*blend_read_after_liblink*/ nullptr,
/*blend_read_undo_preserve*/ nullptr,

View File

@ -104,7 +104,7 @@ IDTypeInfo IDType_ID_LI = {
/*blend_write*/ nullptr,
/*blend_read_data*/ library_blend_read_data,
/*blend_read_lib*/ nullptr,
/*blend_read_after_liblink*/ nullptr,
/*blend_read_undo_preserve*/ nullptr,

View File

@ -154,12 +154,6 @@ static void light_blend_read_data(BlendDataReader *reader, ID *id)
BKE_previewimg_blend_read(reader, la->preview);
}
static void light_blend_read_lib(BlendLibReader *reader, ID *id)
{
Light *la = (Light *)id;
BLO_read_id_address(reader, id, &la->ipo); // XXX deprecated - old animation system
}
IDTypeInfo IDType_ID_LA = {
/*id_code*/ ID_LA,
/*id_filter*/ FILTER_ID_LA,
@ -182,7 +176,7 @@ IDTypeInfo IDType_ID_LA = {
/*blend_write*/ light_blend_write,
/*blend_read_data*/ light_blend_read_data,
/*blend_read_lib*/ light_blend_read_lib,
/*blend_read_after_liblink*/ nullptr,
/*blend_read_undo_preserve*/ nullptr,

View File

@ -52,12 +52,6 @@ static void lightprobe_blend_write(BlendWriter *writer, ID *id, const void *id_a
BKE_id_blend_write(writer, &prb->id);
}
static void lightprobe_blend_read_lib(BlendLibReader *reader, ID *id)
{
LightProbe *prb = (LightProbe *)id;
BLO_read_id_address(reader, &prb->id, &prb->visibility_grp);
}
IDTypeInfo IDType_ID_LP = {
/*id_code*/ ID_LP,
/*id_filter*/ FILTER_ID_LP,
@ -80,7 +74,7 @@ IDTypeInfo IDType_ID_LP = {
/*blend_write*/ lightprobe_blend_write,
/*blend_read_data*/ nullptr,
/*blend_read_lib*/ lightprobe_blend_read_lib,
/*blend_read_after_liblink*/ nullptr,
/*blend_read_undo_preserve*/ nullptr,

View File

@ -641,49 +641,6 @@ static void linestyle_blend_read_data(BlendDataReader *reader, ID *id)
}
}
static void linestyle_blend_read_lib(BlendLibReader *reader, ID *id)
{
FreestyleLineStyle *linestyle = (FreestyleLineStyle *)id;
LISTBASE_FOREACH (LineStyleModifier *, m, &linestyle->color_modifiers) {
switch (m->type) {
case LS_MODIFIER_DISTANCE_FROM_OBJECT: {
LineStyleColorModifier_DistanceFromObject *cm =
(LineStyleColorModifier_DistanceFromObject *)m;
BLO_read_id_address(reader, id, &cm->target);
break;
}
}
}
LISTBASE_FOREACH (LineStyleModifier *, m, &linestyle->alpha_modifiers) {
switch (m->type) {
case LS_MODIFIER_DISTANCE_FROM_OBJECT: {
LineStyleAlphaModifier_DistanceFromObject *am =
(LineStyleAlphaModifier_DistanceFromObject *)m;
BLO_read_id_address(reader, id, &am->target);
break;
}
}
}
LISTBASE_FOREACH (LineStyleModifier *, m, &linestyle->thickness_modifiers) {
switch (m->type) {
case LS_MODIFIER_DISTANCE_FROM_OBJECT: {
LineStyleThicknessModifier_DistanceFromObject *tm =
(LineStyleThicknessModifier_DistanceFromObject *)m;
BLO_read_id_address(reader, id, &tm->target);
break;
}
}
}
for (int a = 0; a < MAX_MTEX; a++) {
MTex *mtex = linestyle->mtex[a];
if (mtex) {
BLO_read_id_address(reader, id, &mtex->tex);
BLO_read_id_address(reader, id, &mtex->object);
}
}
}
IDTypeInfo IDType_ID_LS = {
/*id_code*/ ID_LS,
/*id_filter*/ FILTER_ID_LS,
@ -706,7 +663,7 @@ IDTypeInfo IDType_ID_LS = {
/*blend_write*/ linestyle_blend_write,
/*blend_read_data*/ linestyle_blend_read_data,
/*blend_read_lib*/ linestyle_blend_read_lib,
/*blend_read_after_liblink*/ nullptr,
/*blend_read_undo_preserve*/ nullptr,

View File

@ -181,30 +181,6 @@ static void mask_blend_read_data(BlendDataReader *reader, ID *id)
}
}
static void lib_link_mask_parent(BlendLibReader *reader, Mask *mask, MaskParent *parent)
{
BLO_read_id_address(reader, &mask->id, &parent->id);
}
static void mask_blend_read_lib(BlendLibReader *reader, ID *id)
{
Mask *mask = (Mask *)id;
LISTBASE_FOREACH (MaskLayer *, masklay, &mask->masklayers) {
MaskSpline *spline = static_cast<MaskSpline *>(masklay->splines.first);
while (spline) {
for (int i = 0; i < spline->tot_point; i++) {
MaskSplinePoint *point = &spline->points[i];
lib_link_mask_parent(reader, mask, &point->parent);
}
lib_link_mask_parent(reader, mask, &spline->parent);
spline = spline->next;
}
}
}
IDTypeInfo IDType_ID_MSK = {
/*id_code*/ ID_MSK,
/*id_filter*/ FILTER_ID_MSK,
@ -227,7 +203,7 @@ IDTypeInfo IDType_ID_MSK = {
/*blend_write*/ mask_blend_write,
/*blend_read_data*/ mask_blend_read_data,
/*blend_read_lib*/ mask_blend_read_lib,
/*blend_read_after_liblink*/ nullptr,
/*blend_read_undo_preserve*/ nullptr,

View File

@ -226,23 +226,6 @@ static void material_blend_read_data(BlendDataReader *reader, ID *id)
BLO_read_data_address(reader, &ma->gp_style);
}
static void material_blend_read_lib(BlendLibReader *reader, ID *id)
{
Material *ma = (Material *)id;
BLO_read_id_address(reader, id, &ma->ipo); /* XXX deprecated - old animation system */
/* relink grease pencil settings */
if (ma->gp_style != nullptr) {
MaterialGPencilStyle *gp_style = ma->gp_style;
if (gp_style->sima != nullptr) {
BLO_read_id_address(reader, id, &gp_style->sima);
}
if (gp_style->ima != nullptr) {
BLO_read_id_address(reader, id, &gp_style->ima);
}
}
}
IDTypeInfo IDType_ID_MA = {
/*id_code*/ ID_MA,
/*id_filter*/ FILTER_ID_MA,
@ -265,7 +248,7 @@ IDTypeInfo IDType_ID_MA = {
/*blend_write*/ material_blend_write,
/*blend_read_data*/ material_blend_read_data,
/*blend_read_lib*/ material_blend_read_lib,
/*blend_read_after_liblink*/ nullptr,
/*blend_read_undo_preserve*/ nullptr,

View File

@ -141,16 +141,6 @@ static void metaball_blend_read_data(BlendDataReader *reader, ID *id)
mb->lastelem = nullptr;
}
static void metaball_blend_read_lib(BlendLibReader *reader, ID *id)
{
MetaBall *mb = (MetaBall *)id;
for (int a = 0; a < mb->totcol; a++) {
BLO_read_id_address(reader, id, &mb->mat[a]);
}
BLO_read_id_address(reader, id, &mb->ipo); // XXX deprecated - old animation system
}
IDTypeInfo IDType_ID_MB = {
/*id_code*/ ID_MB,
/*id_filter*/ FILTER_ID_MB,
@ -173,7 +163,7 @@ IDTypeInfo IDType_ID_MB = {
/*blend_write*/ metaball_blend_write,
/*blend_read_data*/ metaball_blend_read_data,
/*blend_read_lib*/ metaball_blend_read_lib,
/*blend_read_after_liblink*/ nullptr,
/*blend_read_undo_preserve*/ nullptr,

View File

@ -359,18 +359,6 @@ static void mesh_blend_read_data(BlendDataReader *reader, ID *id)
}
}
static void mesh_blend_read_lib(BlendLibReader *reader, ID *id)
{
Mesh *me = reinterpret_cast<Mesh *>(id);
for (int i = 0; i < me->totcol; i++) {
BLO_read_id_address(reader, id, &me->mat[i]);
}
BLO_read_id_address(reader, id, &me->ipo); // XXX: deprecated: old anim sys
BLO_read_id_address(reader, id, &me->key);
BLO_read_id_address(reader, id, &me->texcomesh);
}
IDTypeInfo IDType_ID_ME = {
/*id_code*/ ID_ME,
/*id_filter*/ FILTER_ID_ME,
@ -393,7 +381,7 @@ IDTypeInfo IDType_ID_ME = {
/*blend_write*/ mesh_blend_write,
/*blend_read_data*/ mesh_blend_read_data,
/*blend_read_lib*/ mesh_blend_read_lib,
/*blend_read_after_liblink*/ nullptr,
/*blend_read_undo_preserve*/ nullptr,

View File

@ -1515,11 +1515,6 @@ void BKE_modifier_blend_read_data(BlendDataReader *reader, ListBase *lb, Object
}
}
void BKE_modifier_blend_read_lib(BlendLibReader *reader, Object *ob)
{
BKE_modifiers_foreach_ID_link(ob, BKE_object_modifiers_lib_link_common, reader);
}
namespace blender::bke {
using Clock = std::chrono::high_resolution_clock;

View File

@ -277,35 +277,6 @@ static void movieclip_blend_read_data(BlendDataReader *reader, ID *id)
}
}
static void lib_link_movieTracks(BlendLibReader *reader, MovieClip *clip, ListBase *tracksbase)
{
LISTBASE_FOREACH (MovieTrackingTrack *, track, tracksbase) {
BLO_read_id_address(reader, &clip->id, &track->gpd);
}
}
static void lib_link_moviePlaneTracks(BlendLibReader *reader,
MovieClip *clip,
ListBase *tracksbase)
{
LISTBASE_FOREACH (MovieTrackingPlaneTrack *, plane_track, tracksbase) {
BLO_read_id_address(reader, &clip->id, &plane_track->image);
}
}
static void movieclip_blend_read_lib(BlendLibReader *reader, ID *id)
{
MovieClip *clip = (MovieClip *)id;
MovieTracking *tracking = &clip->tracking;
BLO_read_id_address(reader, id, &clip->gpd);
LISTBASE_FOREACH (MovieTrackingObject *, object, &tracking->objects) {
lib_link_movieTracks(reader, clip, &object->tracks);
lib_link_moviePlaneTracks(reader, clip, &object->plane_tracks);
}
}
IDTypeInfo IDType_ID_MC = {
/*id_code*/ ID_MC,
/*id_filter*/ FILTER_ID_MC,
@ -328,7 +299,7 @@ IDTypeInfo IDType_ID_MC = {
/*blend_write*/ movieclip_blend_write,
/*blend_read_data*/ movieclip_blend_read_data,
/*blend_read_lib*/ movieclip_blend_read_lib,
/*blend_read_after_liblink*/ nullptr,
/*blend_read_undo_preserve*/ nullptr,

View File

@ -2357,20 +2357,6 @@ static void blend_data_read_nla_strips(BlendDataReader *reader, ListBase *strips
}
}
static void blend_lib_read_nla_strips(BlendLibReader *reader, ID *id, ListBase *strips)
{
LISTBASE_FOREACH (NlaStrip *, strip, strips) {
/* check strip's children */
blend_lib_read_nla_strips(reader, id, &strip->strips);
/* check strip's F-Curves */
BKE_fcurve_blend_read_lib(reader, id, &strip->fcurves);
/* reassign the counted-reference to action */
BLO_read_id_address(reader, id, &strip->act);
}
}
void BKE_nla_blend_write(BlendWriter *writer, ListBase *tracks)
{
/* write all the tracks */
@ -2398,11 +2384,3 @@ void BKE_nla_blend_read_data(BlendDataReader *reader, ID *id_owner, ListBase *tr
blend_data_read_nla_strips(reader, &nlt->strips);
}
}
void BKE_nla_blend_read_lib(BlendLibReader *reader, ID *id, ListBase *tracks)
{
/* we only care about the NLA strips inside the tracks */
LISTBASE_FOREACH (NlaTrack *, nlt, tracks) {
blend_lib_read_nla_strips(reader, id, &nlt->strips);
}
}

View File

@ -946,81 +946,9 @@ static void ntree_blend_read_data(BlendDataReader *reader, ID *id)
ntreeBlendReadData(reader, nullptr, ntree);
}
static void lib_link_node_socket(BlendLibReader *reader, ID *self_id, bNodeSocket *sock)
static void ntree_blend_read_after_liblink(BlendLibReader *reader, ID *id)
{
IDP_BlendReadLib(reader, self_id, sock->prop);
/* This can happen for all socket types when a file is saved in an older version of Blender than
* it was originally created in (#86298). Some socket types still require a default value. The
* default value of those sockets will be created in `ntreeSetTypes`. */
if (sock->default_value == nullptr) {
return;
}
switch (eNodeSocketDatatype(sock->type)) {
case SOCK_OBJECT: {
BLO_read_id_address(
reader, self_id, &sock->default_value_typed<bNodeSocketValueObject>()->value);
break;
}
case SOCK_IMAGE: {
BLO_read_id_address(
reader, self_id, &sock->default_value_typed<bNodeSocketValueImage>()->value);
break;
}
case SOCK_COLLECTION: {
BLO_read_id_address(
reader, self_id, &sock->default_value_typed<bNodeSocketValueCollection>()->value);
break;
}
case SOCK_TEXTURE: {
BLO_read_id_address(
reader, self_id, &sock->default_value_typed<bNodeSocketValueTexture>()->value);
break;
}
case SOCK_MATERIAL: {
BLO_read_id_address(
reader, self_id, &sock->default_value_typed<bNodeSocketValueMaterial>()->value);
break;
}
case SOCK_FLOAT:
case SOCK_VECTOR:
case SOCK_RGBA:
case SOCK_BOOLEAN:
case SOCK_ROTATION:
case SOCK_INT:
case SOCK_STRING:
case SOCK_CUSTOM:
case SOCK_SHADER:
case SOCK_GEOMETRY:
break;
}
}
static void lib_link_node_sockets(BlendLibReader *reader, ID *self_id, ListBase *sockets)
{
LISTBASE_FOREACH (bNodeSocket *, sock, sockets) {
lib_link_node_socket(reader, self_id, sock);
}
}
void ntreeBlendReadLib(BlendLibReader *reader, bNodeTree *ntree)
{
BLO_read_id_address(reader, &ntree->id, &ntree->gpd);
LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
/* Link ID Properties -- and copy this comment EXACTLY for easy finding
* of library blocks that implement this. */
IDP_BlendReadLib(reader, &ntree->id, node->prop);
BLO_read_id_address(reader, &ntree->id, &node->id);
lib_link_node_sockets(reader, &ntree->id, &node->inputs);
lib_link_node_sockets(reader, &ntree->id, &node->outputs);
}
lib_link_node_sockets(reader, &ntree->id, &ntree->inputs);
lib_link_node_sockets(reader, &ntree->id, &ntree->outputs);
bNodeTree *ntree = reinterpret_cast<bNodeTree *>(id);
/* Set `node->typeinfo` pointers. This is done in lib linking, after the
* first versioning that can change types still without functions that
@ -1041,12 +969,6 @@ void ntreeBlendReadLib(BlendLibReader *reader, bNodeTree *ntree)
}
}
static void ntree_blend_read_lib(BlendLibReader *reader, ID *id)
{
bNodeTree *ntree = reinterpret_cast<bNodeTree *>(id);
ntreeBlendReadLib(reader, ntree);
}
static void node_tree_asset_pre_save(void *asset_ptr, AssetMetaData *asset_data)
{
bNodeTree &node_tree = *static_cast<bNodeTree *>(asset_ptr);
@ -1099,7 +1021,7 @@ IDTypeInfo IDType_ID_NT = {
/*blend_write*/ blender::bke::ntree_blend_write,
/*blend_read_data*/ blender::bke::ntree_blend_read_data,
/*blend_read_lib*/ blender::bke::ntree_blend_read_lib,
/*blend_read_after_liblink*/ blender::bke::ntree_blend_read_after_liblink,
/*blend_read_undo_preserve*/ nullptr,

View File

@ -327,55 +327,6 @@ static void socket_data_read_data(BlendDataReader *reader, bNodeTreeInterfaceSoc
/** \} */
/* -------------------------------------------------------------------- */
/** \name Read ID Pointer Data
* \{ */
template<typename T>
void socket_data_read_lib_impl(BlendLibReader * /*reader*/, ID * /*id*/, T & /*data*/)
{
}
template<>
void socket_data_read_lib_impl(BlendLibReader *reader, ID *id, bNodeSocketValueObject &data)
{
BLI_assert(id != nullptr);
BLO_read_id_address(reader, id, &data.value);
}
template<>
void socket_data_read_lib_impl(BlendLibReader *reader, ID *id, bNodeSocketValueImage &data)
{
BLI_assert(id != nullptr);
BLO_read_id_address(reader, id, &data.value);
}
template<>
void socket_data_read_lib_impl(BlendLibReader *reader, ID *id, bNodeSocketValueCollection &data)
{
BLI_assert(id != nullptr);
BLO_read_id_address(reader, id, &data.value);
}
template<>
void socket_data_read_lib_impl(BlendLibReader *reader, ID *id, bNodeSocketValueTexture &data)
{
BLI_assert(id != nullptr);
BLO_read_id_address(reader, id, &data.value);
}
template<>
void socket_data_read_lib_impl(BlendLibReader *reader, ID *id, bNodeSocketValueMaterial &data)
{
BLI_assert(id != nullptr);
BLO_read_id_address(reader, id, &data.value);
}
static void socket_data_read_lib(BlendLibReader *reader, ID *id, bNodeTreeInterfaceSocket &socket)
{
socket_data_to_static_type_tag(socket.socket_type, [&](auto type_tag) {
using SocketDataType = typename decltype(type_tag)::type;
socket_data_read_lib_impl(reader, id, get_socket_data_as<SocketDataType>(socket));
});
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name Callback per ID Pointer
* \{ */
@ -569,25 +520,6 @@ static void item_read_data(BlendDataReader *reader, bNodeTreeInterfaceItem &item
}
}
static void item_read_lib(BlendLibReader *reader, ID *id, bNodeTreeInterfaceItem &item)
{
switch (item.item_type) {
case NODE_INTERFACE_SOCKET: {
bNodeTreeInterfaceSocket &socket = reinterpret_cast<bNodeTreeInterfaceSocket &>(item);
IDP_BlendReadLib(reader, id, socket.properties);
socket_types::socket_data_read_lib(reader, id, socket);
break;
}
case NODE_INTERFACE_PANEL: {
bNodeTreeInterfacePanel &panel = reinterpret_cast<bNodeTreeInterfacePanel &>(item);
for (bNodeTreeInterfaceItem *item : panel.items()) {
item_read_lib(reader, id, *item);
}
break;
}
}
}
static void item_foreach_id(LibraryForeachIDData *data, bNodeTreeInterfaceItem &item)
{
switch (item.item_type) {
@ -1036,11 +968,6 @@ void bNodeTreeInterface::read_data(BlendDataReader *reader)
item_types::item_read_data(reader, this->root_panel.item);
}
void bNodeTreeInterface::read_lib(BlendLibReader *reader, ID *id)
{
item_types::item_read_lib(reader, id, this->root_panel.item);
}
bNodeTreeInterfaceItem *bNodeTreeInterface::active_item()
{
bNodeTreeInterfaceItem *active = nullptr;

View File

@ -884,56 +884,14 @@ static void object_blend_read_data(BlendDataReader *reader, ID *id)
}
}
/* XXX deprecated - old animation system */
static void lib_link_nlastrips(BlendLibReader *reader, ID *id, ListBase *striplist)
static void object_blend_read_after_liblink(BlendLibReader *reader, ID *id)
{
LISTBASE_FOREACH (bActionStrip *, strip, striplist) {
BLO_read_id_address(reader, id, &strip->object);
BLO_read_id_address(reader, id, &strip->act);
BLO_read_id_address(reader, id, &strip->ipo);
LISTBASE_FOREACH (bActionModifier *, amod, &strip->modifiers) {
BLO_read_id_address(reader, id, &amod->ob);
}
}
}
/* XXX deprecated - old animation system */
static void lib_link_constraint_channels(BlendLibReader *reader, ID *id, ListBase *chanbase)
{
LISTBASE_FOREACH (bConstraintChannel *, chan, chanbase) {
BLO_read_id_address(reader, id, &chan->ipo);
}
}
static void object_blend_read_lib(BlendLibReader *reader, ID *id)
{
Object *ob = (Object *)id;
Object *ob = reinterpret_cast<Object *>(id);
Main *bmain = BLO_read_lib_get_main(reader);
BlendFileReadReport *reports = BLO_read_lib_reports(reader);
/* XXX deprecated - old animation system <<< */
BLO_read_id_address(reader, id, &ob->ipo);
BLO_read_id_address(reader, id, &ob->action);
/* >>> XXX deprecated - old animation system */
BLO_read_id_address(reader, id, &ob->parent);
BLO_read_id_address(reader, id, &ob->track);
/* XXX deprecated - old pose library, deprecated in Blender 3.5. */
BLO_read_id_address(reader, id, &ob->poselib);
BLO_read_id_address(reader, id, &ob->instance_collection);
/* XXX deprecated - old proxy system. <<< */
BLO_read_id_address(reader, id, &ob->proxy);
BLO_read_id_address(reader, id, &ob->proxy_group);
/* >>> XXX deprecated - old proxy system . */
void *poin = ob->data;
BLO_read_id_address(reader, id, &ob->data);
if (ob->data == nullptr && poin != nullptr) {
if (ob->data == nullptr && ob->type != OB_EMPTY) {
ob->type = OB_EMPTY;
if (ob->pose) {
@ -942,6 +900,10 @@ static void object_blend_read_lib(BlendLibReader *reader, ID *id)
* which are not always valid, so for now free directly and suffer
* some leaked memory rather than crashing immediately
* while bad this _is_ an exceptional case - campbell */
/* FIXME Since this code is now executed after _all_ ID pointers have been lib-linked, it
* should be safe to do it properly now. Further more, since user count of IDs is not done in
* readcode anymore, `BKE_pose_free_ex(ob->pose, false)` could be called instead, avoiding
* any access to other IDs altogether - Bastien. */
#if 0
BKE_pose_free(ob->pose);
#else
@ -963,70 +925,18 @@ static void object_blend_read_lib(BlendLibReader *reader, ID *id)
}
reports->count.missing_obdata++;
}
for (int a = 0; a < ob->totcol; a++) {
BLO_read_id_address(reader, id, &ob->mat[a]);
}
/* When the object is local and the data is library its possible
* the material list size gets out of sync. #22663. */
if (ob->data && ob->id.lib != ((ID *)ob->data)->lib) {
BKE_object_materials_test(bmain, ob, (ID *)ob->data);
if (ob->data && ob->id.lib != static_cast<ID *>(ob->data)->lib) {
BKE_object_materials_test(bmain, ob, static_cast<ID *>(ob->data));
}
BLO_read_id_address(reader, id, &ob->gpd);
/* Performs quite extensive rebuilding & validation of object-level Pose data from the Armature
* obdata. */
BKE_pose_blend_read_after_liblink(reader, ob, ob->pose);
/* if id.us==0 a new base will be created later on */
/* WARNING! Also check expand_object(), should reflect the stuff below. */
BKE_pose_blend_read_lib(reader, ob, ob->pose);
BKE_constraint_blend_read_lib(reader, &ob->id, &ob->constraints);
/* XXX deprecated - old animation system <<< */
lib_link_constraint_channels(reader, &ob->id, &ob->constraintChannels);
lib_link_nlastrips(reader, &ob->id, &ob->nlastrips);
/* >>> XXX deprecated - old animation system */
LISTBASE_FOREACH (PartEff *, paf, &ob->effect) {
if (paf->type == EFF_PARTICLE) {
BLO_read_id_address(reader, id, &paf->group);
}
}
{
FluidsimModifierData *fluidmd = (FluidsimModifierData *)BKE_modifiers_findby_type(
ob, eModifierType_Fluidsim);
if (fluidmd && fluidmd->fss) {
/* XXX: deprecated - old animation system. */
BLO_read_id_address(reader, id, &fluidmd->fss->ipo);
}
}
/* texture field */
if (ob->pd) {
BKE_particle_partdeflect_blend_read_lib(reader, &ob->id, ob->pd);
}
if (ob->soft) {
BLO_read_id_address(reader, id, &ob->soft->collision_group);
BLO_read_id_address(reader, id, &ob->soft->effector_weights->group);
}
BKE_particle_system_blend_read_lib(reader, ob, &ob->id, &ob->particlesystem);
BKE_modifier_blend_read_lib(reader, ob);
BKE_gpencil_modifier_blend_read_lib(reader, ob);
BKE_shaderfx_blend_read_lib(reader, ob);
if (ob->rigidbody_constraint) {
BLO_read_id_address(reader, id, &ob->rigidbody_constraint->ob1);
BLO_read_id_address(reader, id, &ob->rigidbody_constraint->ob2);
}
if (ob->light_linking) {
BLO_read_id_address(reader, id, &ob->light_linking->receiver_collection);
BLO_read_id_address(reader, id, &ob->light_linking->blocker_collection);
}
BKE_particle_system_blend_read_after_liblink(reader, ob, &ob->id, &ob->particlesystem);
}
PartEff *BKE_object_do_version_give_parteff_245(Object *ob)
@ -1165,7 +1075,7 @@ IDTypeInfo IDType_ID_OB = {
/*blend_write*/ object_blend_write,
/*blend_read_data*/ object_blend_read_data,
/*blend_read_lib*/ object_blend_read_lib,
/*blend_read_after_liblink*/ object_blend_read_after_liblink,
/*blend_read_undo_preserve*/ nullptr,
@ -5547,16 +5457,6 @@ void BKE_object_check_uuids_unique_and_report(const Object *object)
BKE_modifier_check_uuids_unique_and_report(object);
}
void BKE_object_modifiers_lib_link_common(void *user_data, Object *ob, ID **idpoin, int cb_flag)
{
BlendLibReader *reader = (BlendLibReader *)user_data;
BLO_read_id_address(reader, &ob->id, idpoin);
if (*idpoin != nullptr && (cb_flag & IDWALK_CB_USER) != 0) {
id_us_plus_no_lib(*idpoin);
}
}
SubsurfModifierData *BKE_object_get_last_subsurf_modifier(const Object *ob)
{
ModifierData *md = (ModifierData *)(ob->modifiers.last);

View File

@ -160,7 +160,7 @@ IDTypeInfo IDType_ID_PAL = {
/*blend_write*/ palette_blend_write,
/*blend_read_data*/ palette_blend_read_data,
/*blend_read_lib*/ nullptr,
/*blend_read_after_liblink*/ nullptr,
/*blend_read_undo_preserve*/ palette_undo_preserve,
@ -227,7 +227,7 @@ IDTypeInfo IDType_ID_PC = {
/*blend_write*/ paint_curve_blend_write,
/*blend_read_data*/ paint_curve_blend_read_data,
/*blend_read_lib*/ nullptr,
/*blend_read_after_liblink*/ nullptr,
/*blend_read_undo_preserve*/ nullptr,
@ -1277,19 +1277,6 @@ void BKE_paint_blend_read_data(BlendDataReader *reader, const Scene *scene, Pain
BKE_paint_runtime_init(scene->toolsettings, p);
}
void BKE_paint_blend_read_lib(BlendLibReader *reader, Scene *sce, Paint *p)
{
if (p) {
BLO_read_id_address(reader, &sce->id, &p->brush);
for (int i = 0; i < p->tool_slots_len; i++) {
if (p->tool_slots[i].brush != nullptr) {
BLO_read_id_address(reader, &sce->id, &p->tool_slots[i].brush);
}
}
BLO_read_id_address(reader, &sce->id, &p->palette);
}
}
bool paint_is_grid_face_hidden(const uint *grid_hidden, int gridsize, int x, int y)
{
/* Skip face if any of its corners are hidden. */

View File

@ -367,72 +367,13 @@ static void particle_settings_blend_read_data(BlendDataReader *reader, ID *id)
CLAMP(part->trail_count, 1, 100000);
}
void BKE_particle_partdeflect_blend_read_lib(BlendLibReader *reader, ID *id, PartDeflect *pd)
static void particle_settings_blend_read_after_liblink(BlendLibReader * /*reader*/, ID *id)
{
if (pd && pd->tex) {
BLO_read_id_address(reader, id, &pd->tex);
}
if (pd && pd->f_source) {
BLO_read_id_address(reader, id, &pd->f_source);
}
}
ParticleSettings *part = reinterpret_cast<ParticleSettings *>(id);
static void particle_settings_blend_read_lib(BlendLibReader *reader, ID *id)
{
ParticleSettings *part = (ParticleSettings *)id;
/* XXX: deprecated - old animation system. */
BLO_read_id_address(reader, id, &part->ipo);
BLO_read_id_address(reader, id, &part->instance_object);
BLO_read_id_address(reader, id, &part->instance_collection);
BLO_read_id_address(reader, id, &part->force_group);
BLO_read_id_address(reader, id, &part->bb_ob);
BLO_read_id_address(reader, id, &part->collision_group);
BKE_particle_partdeflect_blend_read_lib(reader, id, part->pd);
BKE_particle_partdeflect_blend_read_lib(reader, id, part->pd2);
if (part->effector_weights) {
BLO_read_id_address(reader, id, &part->effector_weights->group);
}
if (part->instance_weights.first && part->instance_collection) {
LISTBASE_FOREACH (ParticleDupliWeight *, dw, &part->instance_weights) {
BLO_read_id_address(reader, id, &dw->ob);
}
}
else {
if (part->instance_weights.first && !part->instance_collection) {
BLI_freelistN(&part->instance_weights);
}
if (part->boids) {
LISTBASE_FOREACH (BoidState *, state, &part->boids->states) {
LISTBASE_FOREACH (BoidRule *, rule, &state->rules) {
switch (rule->type) {
case eBoidRuleType_Goal:
case eBoidRuleType_Avoid: {
BoidRuleGoalAvoid *brga = (BoidRuleGoalAvoid *)rule;
BLO_read_id_address(reader, id, &brga->ob);
break;
}
case eBoidRuleType_FollowLeader: {
BoidRuleFollowLeader *brfl = (BoidRuleFollowLeader *)rule;
BLO_read_id_address(reader, id, &brfl->ob);
break;
}
}
}
}
}
for (int a = 0; a < MAX_MTEX; a++) {
MTex *mtex = part->mtex[a];
if (mtex) {
BLO_read_id_address(reader, id, &mtex->tex);
BLO_read_id_address(reader, id, &mtex->object);
}
}
}
IDTypeInfo IDType_ID_PA = {
@ -457,7 +398,7 @@ IDTypeInfo IDType_ID_PA = {
/*blend_write*/ particle_settings_blend_write,
/*blend_read_data*/ particle_settings_blend_read_data,
/*blend_read_lib*/ particle_settings_blend_read_lib,
/*blend_read_after_liblink*/ particle_settings_blend_read_after_liblink,
/*blend_read_undo_preserve*/ nullptr,
@ -5487,28 +5428,18 @@ void BKE_particle_system_blend_read_data(BlendDataReader *reader, ListBase *part
}
}
void BKE_particle_system_blend_read_lib(BlendLibReader *reader,
void BKE_particle_system_blend_read_after_liblink(BlendLibReader * /*reader*/,
Object *ob,
ID *id,
ID * /*id*/,
ListBase *particles)
{
LISTBASE_FOREACH_MUTABLE (ParticleSystem *, psys, particles) {
BLO_read_id_address(reader, id, &psys->part);
if (psys->part) {
LISTBASE_FOREACH (ParticleTarget *, pt, &psys->targets) {
BLO_read_id_address(reader, id, &pt->ob);
}
BLO_read_id_address(reader, id, &psys->parent);
BLO_read_id_address(reader, id, &psys->target_ob);
if (psys->clmd) {
/* XXX(@ideasman42): from reading existing code this seems correct but intended usage
* of point-cache with cloth should be added in #ParticleSystem. */
psys->clmd->point_cache = psys->pointcache;
psys->clmd->ptcaches.first = psys->clmd->ptcaches.last = nullptr;
BLO_read_id_address(reader, id, &psys->clmd->coll_parms->group);
psys->clmd->modifier.error = nullptr;
}
}

View File

@ -141,14 +141,6 @@ static void pointcloud_blend_read_data(BlendDataReader *reader, ID *id)
pointcloud->runtime = new blender::bke::PointCloudRuntime();
}
static void pointcloud_blend_read_lib(BlendLibReader *reader, ID *id)
{
PointCloud *pointcloud = (PointCloud *)id;
for (int a = 0; a < pointcloud->totcol; a++) {
BLO_read_id_address(reader, id, &pointcloud->mat[a]);
}
}
IDTypeInfo IDType_ID_PT = {
/*id_code*/ ID_PT,
/*id_filter*/ FILTER_ID_PT,
@ -171,7 +163,7 @@ IDTypeInfo IDType_ID_PT = {
/*blend_write*/ pointcloud_blend_write,
/*blend_read_data*/ pointcloud_blend_read_data,
/*blend_read_lib*/ pointcloud_blend_read_lib,
/*blend_read_after_liblink*/ nullptr,
/*blend_read_undo_preserve*/ nullptr,

View File

@ -1532,69 +1532,11 @@ static void scene_blend_read_data(BlendDataReader *reader, ID *id)
}
/* patch for missing scene IDs, can't be in do-versions */
static void scene_blend_read_lib(BlendLibReader *reader, ID *id)
static void scene_blend_read_after_liblink(BlendLibReader *reader, ID *id)
{
Scene *sce = (Scene *)id;
BKE_keyingsets_blend_read_lib(reader, &sce->id, &sce->keyingsets);
BLO_read_id_address(reader, id, &sce->camera);
BLO_read_id_address(reader, id, &sce->world);
BLO_read_id_address(reader, id, &sce->set);
BLO_read_id_address(reader, id, &sce->gpd);
BKE_paint_blend_read_lib(reader, sce, &sce->toolsettings->imapaint.paint);
if (sce->toolsettings->sculpt) {
BKE_paint_blend_read_lib(reader, sce, &sce->toolsettings->sculpt->paint);
}
if (sce->toolsettings->vpaint) {
BKE_paint_blend_read_lib(reader, sce, &sce->toolsettings->vpaint->paint);
}
if (sce->toolsettings->wpaint) {
BKE_paint_blend_read_lib(reader, sce, &sce->toolsettings->wpaint->paint);
}
if (sce->toolsettings->uvsculpt) {
BKE_paint_blend_read_lib(reader, sce, &sce->toolsettings->uvsculpt->paint);
}
if (sce->toolsettings->gp_paint) {
BKE_paint_blend_read_lib(reader, sce, &sce->toolsettings->gp_paint->paint);
}
if (sce->toolsettings->gp_vertexpaint) {
BKE_paint_blend_read_lib(reader, sce, &sce->toolsettings->gp_vertexpaint->paint);
}
if (sce->toolsettings->gp_sculptpaint) {
BKE_paint_blend_read_lib(reader, sce, &sce->toolsettings->gp_sculptpaint->paint);
}
if (sce->toolsettings->gp_weightpaint) {
BKE_paint_blend_read_lib(reader, sce, &sce->toolsettings->gp_weightpaint->paint);
}
if (sce->toolsettings->curves_sculpt) {
BKE_paint_blend_read_lib(reader, sce, &sce->toolsettings->curves_sculpt->paint);
}
if (sce->toolsettings->sculpt) {
BLO_read_id_address(reader, id, &sce->toolsettings->sculpt->gravity_object);
}
if (sce->toolsettings->imapaint.stencil) {
BLO_read_id_address(reader, id, &sce->toolsettings->imapaint.stencil);
}
if (sce->toolsettings->imapaint.clone) {
BLO_read_id_address(reader, id, &sce->toolsettings->imapaint.clone);
}
if (sce->toolsettings->imapaint.canvas) {
BLO_read_id_address(reader, id, &sce->toolsettings->imapaint.canvas);
}
BLO_read_id_address(reader, id, &sce->toolsettings->particle.shape_object);
BLO_read_id_address(reader, id, &sce->toolsettings->gp_sculpt.guide.reference_object);
Scene *sce = reinterpret_cast<Scene *>(id);
LISTBASE_FOREACH_MUTABLE (Base *, base_legacy, &sce->base) {
BLO_read_id_address(reader, id, &base_legacy->object);
if (base_legacy->object == nullptr) {
BLO_reportf_wrap(BLO_read_lib_reports(reader),
RPT_WARNING,
@ -1608,51 +1550,8 @@ static void scene_blend_read_lib(BlendLibReader *reader, ID *id)
}
}
if (sce->ed) {
SEQ_blend_read_lib(reader, sce, &sce->ed->seqbase);
}
LISTBASE_FOREACH (TimeMarker *, marker, &sce->markers) {
IDP_BlendReadLib(reader, id, marker->prop);
if (marker->camera) {
BLO_read_id_address(reader, id, &marker->camera);
}
}
/* rigidbody world relies on its linked collections */
if (sce->rigidbody_world) {
RigidBodyWorld *rbw = sce->rigidbody_world;
if (rbw->group) {
BLO_read_id_address(reader, id, &rbw->group);
}
if (rbw->constraints) {
BLO_read_id_address(reader, id, &rbw->constraints);
}
if (rbw->effector_weights) {
BLO_read_id_address(reader, id, &rbw->effector_weights->group);
}
}
LISTBASE_FOREACH (SceneRenderLayer *, srl, &sce->r.layers) {
BLO_read_id_address(reader, id, &srl->mat_override);
LISTBASE_FOREACH (FreestyleModuleConfig *, fmc, &srl->freestyleConfig.modules) {
BLO_read_id_address(reader, id, &fmc->script);
}
LISTBASE_FOREACH (FreestyleLineSet *, fls, &srl->freestyleConfig.linesets) {
BLO_read_id_address(reader, id, &fls->linestyle);
BLO_read_id_address(reader, id, &fls->group);
}
}
/* Motion Tracking */
BLO_read_id_address(reader, id, &sce->clip);
LISTBASE_FOREACH (ViewLayer *, view_layer, &sce->view_layers) {
BKE_view_layer_blend_read_lib(reader, id, view_layer);
}
if (sce->r.bake.cage_object) {
BLO_read_id_address(reader, id, &sce->r.bake.cage_object);
BKE_view_layer_blend_read_after_liblink(reader, id, view_layer);
}
#ifdef USE_SETSCENE_CHECK
@ -1717,7 +1616,7 @@ constexpr IDTypeInfo get_type_info()
info.blend_write = scene_blend_write;
info.blend_read_data = scene_blend_read_data;
info.blend_read_lib = scene_blend_read_lib;
info.blend_read_after_liblink = scene_blend_read_after_liblink;
info.blend_read_undo_preserve = scene_undo_preserve;

View File

@ -149,14 +149,12 @@ bool BKE_screen_blend_read_data(BlendDataReader *reader, bScreen *screen)
/* NOTE: file read without screens option G_FILE_NO_UI;
* check lib pointers in call below */
static void screen_blend_read_lib(BlendLibReader *reader, ID *id)
static void screen_blend_read_after_liblink(BlendLibReader *reader, ID *id)
{
bScreen *screen = (bScreen *)id;
/* deprecated, but needed for versioning (will be nullptr'ed then) */
BLO_read_id_address(reader, id, &screen->scene);
bScreen *screen = reinterpret_cast<bScreen *>(id);
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
BKE_screen_area_blend_read_lib(reader, &screen->id, area);
BKE_screen_area_blend_read_after_liblink(reader, &screen->id, area);
}
}
@ -184,7 +182,7 @@ IDTypeInfo IDType_ID_SCR = {
/*blend_write*/ screen_blend_write,
/* Cannot be used yet, because #direct_link_screen has a return value. */
/*blend_read_data*/ nullptr,
/*blend_read_lib*/ screen_blend_read_lib,
/*blend_read_after_liblink*/ screen_blend_read_after_liblink,
/*blend_read_undo_preserve*/ nullptr,
@ -1278,15 +1276,13 @@ bool BKE_screen_area_map_blend_read_data(BlendDataReader *reader, ScrAreaMap *ar
return true;
}
void BKE_screen_area_blend_read_lib(BlendLibReader *reader, ID *parent_id, ScrArea *area)
void BKE_screen_area_blend_read_after_liblink(BlendLibReader *reader, ID *parent_id, ScrArea *area)
{
BLO_read_id_address(reader, parent_id, &area->full);
LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
SpaceType *space_type = BKE_spacetype_from_id(sl->spacetype);
if (space_type && space_type->blend_read_lib) {
space_type->blend_read_lib(reader, parent_id, sl);
if (space_type && space_type->blend_read_after_liblink) {
space_type->blend_read_after_liblink(reader, parent_id, sl);
}
}
}

View File

@ -300,8 +300,3 @@ void BKE_shaderfx_blend_read_data(BlendDataReader *reader, ListBase *lb, Object
}
}
}
void BKE_shaderfx_blend_read_lib(BlendLibReader *reader, Object *ob)
{
BKE_shaderfx_foreach_ID_link(ob, BKE_object_modifiers_lib_link_common, reader);
}

View File

@ -189,13 +189,6 @@ static void sound_blend_read_data(BlendDataReader *reader, ID *id)
BKE_packedfile_blend_read(reader, &sound->newpackedfile);
}
static void sound_blend_read_lib(BlendLibReader *reader, ID *id)
{
bSound *sound = (bSound *)id;
/* XXX: deprecated - old animation system. */
BLO_read_id_address(reader, id, &sound->ipo);
}
IDTypeInfo IDType_ID_SO = {
/*id_code*/ ID_SO,
/*id_filter*/ FILTER_ID_SO,
@ -219,7 +212,7 @@ IDTypeInfo IDType_ID_SO = {
/*blend_write*/ sound_blend_write,
/*blend_read_data*/ sound_blend_read_data,
/*blend_read_lib*/ sound_blend_read_lib,
/*blend_read_after_liblink*/ nullptr,
/*blend_read_undo_preserve*/ nullptr,

View File

@ -51,12 +51,6 @@ static void speaker_blend_write(BlendWriter *writer, ID *id, const void *id_addr
BKE_id_blend_write(writer, &spk->id);
}
static void speaker_blend_read_lib(BlendLibReader *reader, ID *id)
{
Speaker *spk = (Speaker *)id;
BLO_read_id_address(reader, id, &spk->sound);
}
IDTypeInfo IDType_ID_SPK = {
/*id_code*/ ID_SPK,
/*id_filter*/ FILTER_ID_SPK,
@ -79,7 +73,7 @@ IDTypeInfo IDType_ID_SPK = {
/*blend_write*/ speaker_blend_write,
/*blend_read_data*/ nullptr,
/*blend_read_lib*/ speaker_blend_read_lib,
/*blend_read_after_liblink*/ nullptr,
/*blend_read_undo_preserve*/ nullptr,

View File

@ -247,7 +247,7 @@ IDTypeInfo IDType_ID_TXT = {
/*blend_write*/ text_blend_write,
/*blend_read_data*/ text_blend_read_data,
/*blend_read_lib*/ nullptr,
/*blend_read_after_liblink*/ nullptr,
/*blend_read_undo_preserve*/ nullptr,

View File

@ -194,13 +194,6 @@ static void texture_blend_read_data(BlendDataReader *reader, ID *id)
tex->iuser.scene = nullptr;
}
static void texture_blend_read_lib(BlendLibReader *reader, ID *id)
{
Tex *tex = (Tex *)id;
BLO_read_id_address(reader, id, &tex->ima);
BLO_read_id_address(reader, id, &tex->ipo); /* XXX deprecated - old animation system */
}
IDTypeInfo IDType_ID_TE = {
/*id_code*/ ID_TE,
/*id_filter*/ FILTER_ID_TE,
@ -223,7 +216,7 @@ IDTypeInfo IDType_ID_TE = {
/*blend_write*/ texture_blend_write,
/*blend_read_data*/ texture_blend_read_data,
/*blend_read_lib*/ texture_blend_read_lib,
/*blend_read_after_liblink*/ nullptr,
/*blend_read_undo_preserve*/ nullptr,

View File

@ -176,7 +176,7 @@ IDTypeInfo IDType_ID_VF = {
/*blend_write*/ vfont_blend_write,
/*blend_read_data*/ vfont_blend_read_data,
/*blend_read_lib*/ nullptr,
/*blend_read_after_liblink*/ nullptr,
/*blend_read_undo_preserve*/ nullptr,

View File

@ -120,26 +120,6 @@ void BKE_viewer_path_blend_read_data(BlendDataReader *reader, ViewerPath *viewer
}
}
void BKE_viewer_path_blend_read_lib(BlendLibReader *reader, ID *self_id, ViewerPath *viewer_path)
{
LISTBASE_FOREACH (ViewerPathElem *, elem, &viewer_path->path) {
switch (ViewerPathElemType(elem->type)) {
case VIEWER_PATH_ELEM_TYPE_ID: {
auto *typed_elem = reinterpret_cast<IDViewerPathElem *>(elem);
BLO_read_id_address(reader, self_id, &typed_elem->id);
break;
}
case VIEWER_PATH_ELEM_TYPE_MODIFIER:
case VIEWER_PATH_ELEM_TYPE_GROUP_NODE:
case VIEWER_PATH_ELEM_TYPE_SIMULATION_ZONE:
case VIEWER_PATH_ELEM_TYPE_VIEWER_NODE:
case VIEWER_PATH_ELEM_TYPE_REPEAT_ZONE: {
break;
}
}
}
}
void BKE_viewer_path_foreach_id(LibraryForeachIDData *data, ViewerPath *viewer_path)
{
LISTBASE_FOREACH (ViewerPathElem *, elem, &viewer_path->path) {

View File

@ -623,17 +623,14 @@ static void volume_blend_read_data(BlendDataReader *reader, ID *id)
BLO_read_pointer_array(reader, (void **)&volume->mat);
}
static void volume_blend_read_lib(BlendLibReader *reader, ID *id)
static void volume_blend_read_after_liblink(BlendLibReader * /*reader*/, ID *id)
{
Volume *volume = (Volume *)id;
Volume *volume = reinterpret_cast<Volume *>(id);
/* Needs to be done *after* cache pointers are restored (call to
* `foreach_cache`/`blo_cache_storage_entry_restore_in_new`), easier for now to do it in
* lib_link... */
BKE_volume_init_grids(volume);
for (int a = 0; a < volume->totcol; a++) {
BLO_read_id_address(reader, id, &volume->mat[a]);
}
}
IDTypeInfo IDType_ID_VO = {
@ -658,7 +655,7 @@ IDTypeInfo IDType_ID_VO = {
/*blend_write*/ volume_blend_write,
/*blend_read_data*/ volume_blend_read_data,
/*blend_read_lib*/ volume_blend_read_lib,
/*blend_read_after_liblink*/ volume_blend_read_after_liblink,
/*blend_read_undo_preserve*/ nullptr,

View File

@ -133,13 +133,11 @@ static void workspace_blend_read_data(BlendDataReader *reader, ID *id)
BKE_viewer_path_blend_read_data(reader, &workspace->viewer_path);
}
static void workspace_blend_read_lib(BlendLibReader *reader, ID *id)
static void workspace_blend_read_after_liblink(BlendLibReader *reader, ID *id)
{
WorkSpace *workspace = (WorkSpace *)id;
WorkSpace *workspace = reinterpret_cast<WorkSpace *>(id);
Main *bmain = BLO_read_lib_get_main(reader);
BLO_read_id_address(reader, id, &workspace->pin_scene);
/* Restore proper 'parent' pointers to relevant data, and clean up unused/invalid entries. */
LISTBASE_FOREACH_MUTABLE (WorkSpaceDataRelation *, relation, &workspace->hook_layout_relations) {
relation->parent = nullptr;
@ -156,8 +154,6 @@ static void workspace_blend_read_lib(BlendLibReader *reader, ID *id)
}
LISTBASE_FOREACH_MUTABLE (WorkSpaceLayout *, layout, &workspace->layouts) {
BLO_read_id_address(reader, id, &layout->screen);
if (layout->screen) {
if (ID_IS_LINKED(id)) {
layout->screen->winid = 0;
@ -173,8 +169,6 @@ static void workspace_blend_read_lib(BlendLibReader *reader, ID *id)
BKE_workspace_layout_remove(bmain, workspace, layout);
}
}
BKE_viewer_path_blend_read_lib(reader, id, &workspace->viewer_path);
}
IDTypeInfo IDType_ID_WS = {
@ -200,7 +194,7 @@ IDTypeInfo IDType_ID_WS = {
/*blend_write*/ workspace_blend_write,
/*blend_read_data*/ workspace_blend_read_data,
/*blend_read_lib*/ workspace_blend_read_lib,
/*blend_read_after_liblink*/ workspace_blend_read_after_liblink,
/*blend_read_undo_preserve*/ nullptr,

View File

@ -175,12 +175,6 @@ static void world_blend_read_data(BlendDataReader *reader, ID *id)
BLO_read_data_address(reader, &wrld->lightgroup);
}
static void world_blend_read_lib(BlendLibReader *reader, ID *id)
{
World *wrld = (World *)id;
BLO_read_id_address(reader, id, &wrld->ipo); /* XXX deprecated, old animation system */
}
IDTypeInfo IDType_ID_WO = {
/*id_code*/ ID_WO,
/*id_filter*/ FILTER_ID_WO,
@ -203,7 +197,7 @@ IDTypeInfo IDType_ID_WO = {
/*blend_write*/ world_blend_write,
/*blend_read_data*/ world_blend_read_data,
/*blend_read_lib*/ world_blend_read_lib,
/*blend_read_after_liblink*/ nullptr,
/*blend_read_undo_preserve*/ nullptr,

View File

@ -42,6 +42,7 @@ typedef struct BlendLibReader BlendLibReader;
typedef struct BlendWriter BlendWriter;
struct BlendFileReadReport;
struct LibraryIDLinkCallbackData;
struct Main;
/* -------------------------------------------------------------------- */
@ -262,6 +263,7 @@ bool BLO_read_data_is_undo(BlendDataReader *reader);
void BLO_read_data_globmap_add(BlendDataReader *reader, void *oldaddr, void *newaddr);
void BLO_read_glob_list(BlendDataReader *reader, struct ListBase *list);
struct BlendFileReadReport *BLO_read_data_reports(BlendDataReader *reader);
struct Library *BLO_read_data_current_library(BlendDataReader *reader);
/** \} */
@ -286,10 +288,6 @@ struct ID *BLO_read_get_new_id_address(BlendLibReader *reader,
const bool do_linked_only,
struct ID *id) ATTR_NONNULL(2);
#define BLO_read_id_address(reader, self_id, id_ptr_p) \
*((void **)id_ptr_p) = (void *)BLO_read_get_new_id_address( \
(reader), (self_id), (self_id) && ID_IS_LINKED(self_id), (ID *)*(id_ptr_p))
/**
* Search for the new address of the ID for the given `session_uuid`.
*

View File

@ -1880,52 +1880,63 @@ static void link_glob_list(FileData *fd, ListBase *lb) /* for glob data */
/** \name Read ID
* \{ */
static void lib_link_id(BlendLibReader *reader, ID *id);
static void after_liblink_id_process(BlendLibReader *reader, ID *id);
static void lib_link_id_embedded_id(BlendLibReader *reader, ID *id)
static void after_liblink_id_embedded_id_process(BlendLibReader *reader, ID *id)
{
/* Handle 'private IDs'. */
bNodeTree *nodetree = ntreeFromID(id);
if (nodetree != nullptr) {
lib_link_id(reader, &nodetree->id);
blender::bke::ntreeBlendReadLib(reader, nodetree);
after_liblink_id_process(reader, &nodetree->id);
if (nodetree->owner_id == nullptr) {
CLOG_WARN(&LOG,
"NULL owner_id pointer for embedded NodeTree of %s, should never happen",
id->name);
nodetree->owner_id = id;
}
else if (nodetree->owner_id != id) {
CLOG_WARN(&LOG,
"Inconsistent owner_id pointer for embedded NodeTree of %s, should never happen",
id->name);
nodetree->owner_id = id;
}
}
if (GS(id->name) == ID_SCE) {
Scene *scene = (Scene *)id;
if (scene->master_collection != nullptr) {
lib_link_id(reader, &scene->master_collection->id);
BKE_collection_blend_read_lib(reader, scene->master_collection);
after_liblink_id_process(reader, &scene->master_collection->id);
if (scene->master_collection->runtime.owner_id == nullptr) {
CLOG_WARN(&LOG,
"NULL owner_id pointer for embedded Scene Collection of %s, should never happen",
id->name);
scene->master_collection->runtime.owner_id = id;
}
else if (scene->master_collection->runtime.owner_id != id) {
CLOG_WARN(&LOG,
"Inconsistent owner_id pointer for embedded Scene Collection of %s, should "
"never happen",
id->name);
scene->master_collection->runtime.owner_id = id;
}
}
}
}
static void lib_link_id(BlendLibReader *reader, ID *id)
static void after_liblink_id_process(BlendLibReader *reader, ID *id)
{
/* NOTE: WM IDProperties are never written to file, hence they should always be nullptr here. */
BLI_assert((GS(id->name) != ID_WM) || id->properties == nullptr);
IDP_BlendReadLib(reader, id, id->properties);
AnimData *adt = BKE_animdata_from_id(id);
if (adt != nullptr) {
BKE_animdata_blend_read_lib(reader, id, adt);
after_liblink_id_embedded_id_process(reader, id);
const IDTypeInfo *id_type = BKE_idtype_get_info_from_id(id);
if (id_type->blend_read_after_liblink != nullptr) {
id_type->blend_read_after_liblink(reader, id);
}
if (id->override_library) {
BLO_read_id_address(reader, id, &id->override_library->reference);
BLO_read_id_address(reader, id, &id->override_library->storage);
BLO_read_id_address(reader, id, &id->override_library->hierarchy_root);
LISTBASE_FOREACH (IDOverrideLibraryProperty *, op, &id->override_library->properties) {
LISTBASE_FOREACH (IDOverrideLibraryPropertyOperation *, opop, &op->operations) {
BLO_read_id_address(reader, id, &opop->subitem_reference_id);
BLO_read_id_address(reader, id, &opop->subitem_local_id);
}
}
}
lib_link_id_embedded_id(reader, id);
}
static void direct_link_id_override_property_operation_cb(BlendDataReader *reader, void *data)
@ -2291,8 +2302,6 @@ static void direct_link_library(FileData *fd, Library *lib, Main *main)
id_us_ensure_real(&lib->id);
}
static void lib_link_library(BlendLibReader * /*reader*/, Library * /*lib*/) {}
/* Always call this once you have loaded new library data to set the relative paths correctly
* in relation to the blend file. */
static void fix_relpaths_library(const char *basepath, Main *main)
@ -3258,6 +3267,34 @@ static void do_versions_after_linking(FileData *fd, Main *main)
/** \name Read Library Data Block (all)
* \{ */
static int lib_link_cb(struct LibraryIDLinkCallbackData *cb_data)
{
/* Embedded IDs are not known by lib_link code, so they would be remapped to `nullptr`. But there
* is no need to process them anyway, asthey are already handled during the 'read_data' phase.
*
* NOTE: Some external non-owning pointers to embedded IDs (like the nodetree pointers of the
* Node editor) will not be detected as embedded ones though at 'lib_link' stage (because their
* source data cannot be accessed). This is handled on a case-by-case basis in 'after_lib_link'
* validation code. */
if (cb_data->cb_flag & (IDWALK_CB_EMBEDDED | IDWALK_CB_EMBEDDED_NOT_OWNING)) {
return IDWALK_RET_NOP;
}
/* Explicitely requested to be ignored during readfile processing. Means the read_data code
* already handled this pointer. Typically, the 'owner_id' pointer of an embedded ID. */
if (cb_data->cb_flag & IDWALK_CB_READFILE_IGNORE) {
return IDWALK_RET_NOP;
}
BlendLibReader *reader = static_cast<BlendLibReader *>(cb_data->user_data);
ID **id_ptr = cb_data->id_pointer;
ID *owner_id = cb_data->owner_id;
*id_ptr = BLO_read_get_new_id_address(reader, owner_id, ID_IS_LINKED(owner_id), *id_ptr);
return IDWALK_RET_NOP;
}
static void lib_link_all(FileData *fd, Main *bmain)
{
BlendLibReader reader = {fd, bmain};
@ -3287,15 +3324,13 @@ static void lib_link_all(FileData *fd, Main *bmain)
}
if ((id->tag & LIB_TAG_NEED_LINK) != 0) {
lib_link_id(&reader, id);
/* Not all original pointer values can be considered as valid.
* Handling of DNA deprecated data should never be needed in undo case. */
const int flag = IDWALK_NO_ORIG_POINTERS_ACCESS | IDWALK_INCLUDE_UI |
((fd->flags & FD_FLAGS_IS_MEMFILE) ? 0 : IDWALK_DO_DEPRECATED_POINTERS);
BKE_library_foreach_ID_link(nullptr, id, lib_link_cb, &reader, flag);
if (id_type->blend_read_lib != nullptr) {
id_type->blend_read_lib(&reader, id);
}
if (GS(id->name) == ID_LI) {
lib_link_library(&reader, (Library *)id); /* Only init users. */
}
after_liblink_id_process(&reader, id);
id->tag &= ~LIB_TAG_NEED_LINK;
}

View File

@ -863,19 +863,6 @@ static void action_space_blend_read_data(BlendDataReader * /*reader*/, SpaceLink
memset(&saction->runtime, 0x0, sizeof(saction->runtime));
}
static void action_space_blend_read_lib(BlendLibReader *reader, ID *parent_id, SpaceLink *sl)
{
SpaceAction *saction = (SpaceAction *)sl;
bDopeSheet *ads = &saction->ads;
if (ads) {
BLO_read_id_address(reader, parent_id, &ads->source);
BLO_read_id_address(reader, parent_id, &ads->filter_grp);
}
BLO_read_id_address(reader, parent_id, &saction->action);
}
static void action_space_blend_write(BlendWriter *writer, SpaceLink *sl)
{
BLO_write_struct(writer, SpaceAction, sl);
@ -909,7 +896,7 @@ void ED_spacetype_action()
st->space_subtype_get = action_space_subtype_get;
st->space_subtype_set = action_space_subtype_set;
st->blend_read_data = action_space_blend_read_data;
st->blend_read_lib = action_space_blend_read_lib;
st->blend_read_after_liblink = nullptr;
st->blend_write = action_space_blend_write;
/* regions: main window */

View File

@ -945,10 +945,12 @@ static void buttons_space_blend_read_data(BlendDataReader * /*reader*/, SpaceLin
sbuts->runtime = nullptr;
}
static void buttons_space_blend_read_lib(BlendLibReader *reader, ID *parent_id, SpaceLink *sl)
static void buttons_space_blend_read_after_liblink(BlendLibReader * /*reader*/,
ID * /*parent_id*/,
SpaceLink *sl)
{
SpaceProperties *sbuts = (SpaceProperties *)sl;
BLO_read_id_address(reader, parent_id, &sbuts->pinid);
SpaceProperties *sbuts = reinterpret_cast<SpaceProperties *>(sl);
if (sbuts->pinid == nullptr) {
sbuts->flag &= ~SB_PIN_CONTEXT;
}
@ -984,7 +986,7 @@ void ED_spacetype_buttons()
st->id_remap = buttons_id_remap;
st->foreach_id = buttons_foreach_id;
st->blend_read_data = buttons_space_blend_read_data;
st->blend_read_lib = buttons_space_blend_read_lib;
st->blend_read_after_liblink = buttons_space_blend_read_after_liblink;
st->blend_write = buttons_space_blend_write;
/* regions: main window */

View File

@ -1186,13 +1186,6 @@ static void clip_space_blend_read_data(BlendDataReader * /*reader*/, SpaceLink *
sclip->scopes.ok = 0;
}
static void clip_space_blend_read_lib(BlendLibReader *reader, ID *parent_id, SpaceLink *sl)
{
SpaceClip *sclip = (SpaceClip *)sl;
BLO_read_id_address(reader, parent_id, &sclip->clip);
BLO_read_id_address(reader, parent_id, &sclip->mask_info.mask);
}
static void clip_space_blend_write(BlendWriter *writer, SpaceLink *sl)
{
BLO_write_struct(writer, SpaceClip, sl);
@ -1226,7 +1219,7 @@ void ED_spacetype_clip()
st->id_remap = clip_id_remap;
st->foreach_id = clip_foreach_id;
st->blend_read_data = clip_space_blend_read_data;
st->blend_read_lib = clip_space_blend_read_lib;
st->blend_read_after_liblink = nullptr;
st->blend_write = clip_space_blend_write;
/* regions: main window */

View File

@ -883,11 +883,12 @@ static void file_space_blend_read_data(BlendDataReader *reader, SpaceLink *sl)
}
}
static void file_space_blend_read_lib(BlendLibReader * /*reader*/,
static void file_space_blend_read_after_liblink(BlendLibReader * /*reader*/,
ID * /*parent_id*/,
SpaceLink *sl)
{
SpaceFile *sfile = (SpaceFile *)sl;
SpaceFile *sfile = reinterpret_cast<SpaceFile *>(sl);
sfile->tags |= FILE_TAG_REBUILD_MAIN_FILES;
}
@ -929,7 +930,7 @@ void ED_spacetype_file()
st->id_remap = file_id_remap;
st->foreach_id = file_foreach_id;
st->blend_read_data = file_space_blend_read_data;
st->blend_read_lib = file_space_blend_read_lib;
st->blend_read_after_liblink = file_space_blend_read_after_liblink;
st->blend_write = file_space_blend_write;
/* regions: main window */

View File

@ -863,17 +863,6 @@ static void graph_space_blend_read_data(BlendDataReader *reader, SpaceLink *sl)
memset(&sipo->runtime, 0x0, sizeof(sipo->runtime));
}
static void graph_space_blend_read_lib(BlendLibReader *reader, ID *parent_id, SpaceLink *sl)
{
SpaceGraph *sipo = (SpaceGraph *)sl;
bDopeSheet *ads = sipo->ads;
if (ads) {
BLO_read_id_address(reader, parent_id, &ads->source);
BLO_read_id_address(reader, parent_id, &ads->filter_grp);
}
}
static void graph_space_blend_write(BlendWriter *writer, SpaceLink *sl)
{
SpaceGraph *sipo = (SpaceGraph *)sl;
@ -913,7 +902,7 @@ void ED_spacetype_ipo()
st->space_subtype_get = graph_space_subtype_get;
st->space_subtype_set = graph_space_subtype_set;
st->blend_read_data = graph_space_blend_read_data;
st->blend_read_lib = graph_space_blend_read_lib;
st->blend_read_after_liblink = nullptr;
st->blend_write = graph_space_blend_write;
/* regions: main window */

View File

@ -1073,19 +1073,6 @@ static void image_space_blend_read_data(BlendDataReader * /*reader*/, SpaceLink
#endif
}
static void image_space_blend_read_lib(BlendLibReader *reader, ID *parent_id, SpaceLink *sl)
{
SpaceImage *sima = (SpaceImage *)sl;
BLO_read_id_address(reader, parent_id, &sima->image);
BLO_read_id_address(reader, parent_id, &sima->mask_info.mask);
/* 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!
*/
BLO_read_id_address(reader, parent_id, &sima->gpd);
}
static void image_space_blend_write(BlendWriter *writer, SpaceLink *sl)
{
BLO_write_struct(writer, SpaceImage, sl);
@ -1118,7 +1105,7 @@ void ED_spacetype_image()
st->space_subtype_get = image_space_subtype_get;
st->space_subtype_set = image_space_subtype_set;
st->blend_read_data = image_space_blend_read_data;
st->blend_read_lib = image_space_blend_read_lib;
st->blend_read_after_liblink = nullptr;
st->blend_write = image_space_blend_write;
/* regions: main window */

View File

@ -590,17 +590,6 @@ static void nla_space_blend_read_data(BlendDataReader *reader, SpaceLink *sl)
BLO_read_data_address(reader, &snla->ads);
}
static void nla_space_blend_read_lib(BlendLibReader *reader, ID *parent_id, SpaceLink *sl)
{
SpaceNla *snla = reinterpret_cast<SpaceNla *>(sl);
bDopeSheet *ads = snla->ads;
if (ads) {
BLO_read_id_address(reader, parent_id, &ads->source);
BLO_read_id_address(reader, parent_id, &ads->filter_grp);
}
}
static void nla_space_blend_write(BlendWriter *writer, SpaceLink *sl)
{
SpaceNla *snla = reinterpret_cast<SpaceNla *>(sl);
@ -629,7 +618,7 @@ void ED_spacetype_nla()
st->id_remap = nla_id_remap;
st->foreach_id = nla_foreach_id;
st->blend_read_data = nla_space_blend_read_data;
st->blend_read_lib = nla_space_blend_read_lib;
st->blend_read_after_liblink = nullptr;
st->blend_write = nla_space_blend_write;
/* regions: main window */

View File

@ -1167,57 +1167,6 @@ static void node_space_blend_read_data(BlendDataReader *reader, SpaceLink *sl)
snode->runtime = nullptr;
}
static void node_space_blend_read_lib(BlendLibReader *reader, ID *parent_id, SpaceLink *sl)
{
SpaceNode *snode = (SpaceNode *)sl;
/* node tree can be stored locally in id too, link this first */
BLO_read_id_address(reader, parent_id, &snode->id);
BLO_read_id_address(reader, parent_id, &snode->from);
bNodeTree *ntree = snode->id ? ntreeFromID(snode->id) : nullptr;
if (ntree) {
snode->nodetree = ntree;
}
else {
BLO_read_id_address(reader, parent_id, &snode->nodetree);
}
bNodeTreePath *path;
for (path = static_cast<bNodeTreePath *>(snode->treepath.first); path; path = path->next) {
if (path == snode->treepath.first) {
/* first nodetree in path is same as snode->nodetree */
path->nodetree = snode->nodetree;
}
else {
BLO_read_id_address(reader, parent_id, &path->nodetree);
}
if (!path->nodetree) {
break;
}
}
/* remaining path entries are invalid, remove */
bNodeTreePath *path_next;
for (; path; path = path_next) {
path_next = path->next;
BLI_remlink(&snode->treepath, path);
MEM_freeN(path);
}
/* edittree is just the last in the path,
* set this directly since the path may have been shortened above */
if (snode->treepath.last) {
path = static_cast<bNodeTreePath *>(snode->treepath.last);
snode->edittree = path->nodetree;
}
else {
snode->edittree = nullptr;
}
}
static void node_space_blend_write(BlendWriter *writer, SpaceLink *sl)
{
SpaceNode *snode = (SpaceNode *)sl;
@ -1258,7 +1207,7 @@ void ED_spacetype_node()
st->space_subtype_get = node_space_subtype_get;
st->space_subtype_set = node_space_subtype_set;
st->blend_read_data = node_space_blend_read_data;
st->blend_read_lib = node_space_blend_read_lib;
st->blend_read_after_liblink = nullptr;
st->blend_write = node_space_blend_write;
/* regions: main window */

View File

@ -513,9 +513,11 @@ static void outliner_space_blend_read_data(BlendDataReader *reader, SpaceLink *s
space_outliner->runtime = nullptr;
}
static void outliner_space_blend_read_lib(BlendLibReader *reader, ID *parent_id, SpaceLink *sl)
static void outliner_space_blend_read_after_liblink(BlendLibReader * /*reader*/,
ID * /*parent_id*/,
SpaceLink *sl)
{
SpaceOutliner *space_outliner = (SpaceOutliner *)sl;
SpaceOutliner *space_outliner = reinterpret_cast<SpaceOutliner *>(sl);
if (space_outliner->treestore) {
TreeStoreElem *tselem;
@ -523,10 +525,7 @@ static void outliner_space_blend_read_lib(BlendLibReader *reader, ID *parent_id,
BLI_mempool_iternew(space_outliner->treestore, &iter);
while ((tselem = static_cast<TreeStoreElem *>(BLI_mempool_iterstep(&iter)))) {
if (TSE_IS_REAL_ID(tselem)) {
BLO_read_id_address(reader, parent_id, &tselem->id);
}
else {
if (!TSE_IS_REAL_ID(tselem)) {
tselem->id = nullptr;
}
}
@ -620,7 +619,7 @@ void ED_spacetype_outliner()
st->deactivate = outliner_deactivate;
st->context = outliner_context;
st->blend_read_data = outliner_space_blend_read_data;
st->blend_read_lib = outliner_space_blend_read_lib;
st->blend_read_after_liblink = outliner_space_blend_read_after_liblink;
st->blend_write = outliner_space_blend_write;
/* regions: main window */

View File

@ -154,15 +154,15 @@ static void script_foreach_id(SpaceLink *space_link, LibraryForeachIDData *data)
BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, scpt->script, IDWALK_CB_NOP);
}
static void script_space_blend_read_lib(BlendLibReader *reader, ID *parent_id, SpaceLink *sl)
static void script_space_blend_read_after_liblink(BlendLibReader * /*reader*/,
ID * /*parent_id*/,
SpaceLink *sl)
{
SpaceScript *scpt = (SpaceScript *)sl;
SpaceScript *scpt = reinterpret_cast<SpaceScript *>(sl);
/*scpt->script = nullptr; - 2.45 set to null, better re-run the script */
if (scpt->script) {
BLO_read_id_address(reader, parent_id, &scpt->script);
if (scpt->script) {
SCRIPT_SET_NULL(scpt->script);
}
SCRIPT_SET_NULL(scpt->script);
}
}
@ -188,7 +188,7 @@ void ED_spacetype_script()
st->operatortypes = script_operatortypes;
st->keymap = script_keymap;
st->foreach_id = script_foreach_id;
st->blend_read_lib = script_space_blend_read_lib;
st->blend_read_after_liblink = script_space_blend_read_after_liblink;
st->blend_write = script_space_blend_write;
/* regions: main window */

View File

@ -985,16 +985,6 @@ static void sequencer_space_blend_read_data(BlendDataReader * /*reader*/, SpaceL
memset(&sseq->runtime, 0x0, sizeof(sseq->runtime));
}
static void sequencer_space_blend_read_lib(BlendLibReader *reader, ID *parent_id, SpaceLink *sl)
{
SpaceSeq *sseq = (SpaceSeq *)sl;
/* 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!
*/
BLO_read_id_address(reader, parent_id, &sseq->gpd);
}
static void sequencer_space_blend_write(BlendWriter *writer, SpaceLink *sl)
{
BLO_write_struct(writer, SpaceSeq, sl);
@ -1022,7 +1012,7 @@ void ED_spacetype_sequencer()
st->id_remap = sequencer_id_remap;
st->foreach_id = sequencer_foreach_id;
st->blend_read_data = sequencer_space_blend_read_data;
st->blend_read_lib = sequencer_space_blend_read_lib;
st->blend_read_after_liblink = nullptr;
st->blend_write = sequencer_space_blend_write;
/* Create regions: */

View File

@ -683,12 +683,6 @@ static void spreadsheet_blend_read_data(BlendDataReader *reader, SpaceLink *sl)
BKE_viewer_path_blend_read_data(reader, &sspreadsheet->viewer_path);
}
static void spreadsheet_blend_read_lib(BlendLibReader *reader, ID *parent_id, SpaceLink *sl)
{
SpaceSpreadsheet *sspreadsheet = (SpaceSpreadsheet *)sl;
BKE_viewer_path_blend_read_lib(reader, parent_id, &sspreadsheet->viewer_path);
}
static void spreadsheet_blend_write(BlendWriter *writer, SpaceLink *sl)
{
BLO_write_struct(writer, SpaceSpreadsheet, sl);
@ -729,7 +723,7 @@ void ED_spacetype_spreadsheet()
st->id_remap = spreadsheet_id_remap;
st->foreach_id = spreadsheet_foreach_id;
st->blend_read_data = spreadsheet_blend_read_data;
st->blend_read_lib = spreadsheet_blend_read_lib;
st->blend_read_after_liblink = nullptr;
st->blend_write = spreadsheet_blend_write;
/* regions: main window */

View File

@ -409,12 +409,6 @@ static void text_space_blend_read_data(BlendDataReader * /*reader*/, SpaceLink *
memset(&st->runtime, 0x0, sizeof(st->runtime));
}
static void text_space_blend_read_lib(BlendLibReader *reader, ID *parent_id, SpaceLink *sl)
{
SpaceText *st = (SpaceText *)sl;
BLO_read_id_address(reader, parent_id, &st->text);
}
static void text_space_blend_write(BlendWriter *writer, SpaceLink *sl)
{
BLO_write_struct(writer, SpaceText, sl);
@ -442,7 +436,7 @@ void ED_spacetype_text()
st->id_remap = text_id_remap;
st->foreach_id = text_foreach_id;
st->blend_read_data = text_space_blend_read_data;
st->blend_read_lib = text_space_blend_read_lib;
st->blend_read_after_liblink = nullptr;
st->blend_write = text_space_blend_write;
/* regions: main window */

View File

@ -2130,20 +2130,6 @@ static void view3d_space_blend_read_data(BlendDataReader *reader, SpaceLink *sl)
BKE_viewer_path_blend_read_data(reader, &v3d->viewer_path);
}
static void view3d_space_blend_read_lib(BlendLibReader *reader, ID *parent_id, SpaceLink *sl)
{
View3D *v3d = (View3D *)sl;
BLO_read_id_address(reader, parent_id, &v3d->camera);
BLO_read_id_address(reader, parent_id, &v3d->ob_center);
if (v3d->localvd) {
BLO_read_id_address(reader, parent_id, &v3d->localvd->camera);
}
BKE_viewer_path_blend_read_lib(reader, parent_id, &v3d->viewer_path);
}
static void view3d_space_blend_write(BlendWriter *writer, SpaceLink *sl)
{
View3D *v3d = (View3D *)sl;
@ -2181,7 +2167,7 @@ void ED_spacetype_view3d()
st->id_remap = view3d_id_remap;
st->foreach_id = view3d_foreach_id;
st->blend_read_data = view3d_space_blend_read_data;
st->blend_read_lib = view3d_space_blend_read_lib;
st->blend_read_after_liblink = nullptr;
st->blend_write = view3d_space_blend_write;
/* regions: main window */

View File

@ -210,7 +210,6 @@ typedef struct bNodeTreeInterface {
/** Read/write blend file data. */
void write(BlendWriter *writer);
void read_data(BlendDataReader *reader);
void read_lib(BlendLibReader *reader, ID *id);
bNodeTreeInterfaceItem *active_item();
const bNodeTreeInterfaceItem *active_item() const;

View File

@ -64,9 +64,6 @@ int SEQ_sequence_supports_modifiers(struct Sequence *seq);
void SEQ_modifier_blend_write(struct BlendWriter *writer, struct ListBase *modbase);
void SEQ_modifier_blend_read_data(struct BlendDataReader *reader, struct ListBase *lb);
void SEQ_modifier_blend_read_lib(struct BlendLibReader *reader,
struct Scene *scene,
struct ListBase *lb);
#ifdef __cplusplus
}

View File

@ -106,10 +106,6 @@ bool SEQ_valid_strip_channel(struct Sequence *seq);
void SEQ_blend_write(struct BlendWriter *writer, struct ListBase *seqbase);
void SEQ_blend_read(struct BlendDataReader *reader, struct ListBase *seqbase);
void SEQ_blend_read_lib(struct BlendLibReader *reader,
struct Scene *scene,
struct ListBase *seqbase);
void SEQ_doversion_250_sound_proxy_update(struct Main *bmain, struct Editing *ed);
/* Depsgraph update function. */

View File

@ -1614,13 +1614,4 @@ void SEQ_modifier_blend_read_data(BlendDataReader *reader, ListBase *lb)
}
}
void SEQ_modifier_blend_read_lib(BlendLibReader *reader, Scene *scene, ListBase *lb)
{
LISTBASE_FOREACH (SequenceModifierData *, smd, lb) {
if (smd->mask_id) {
BLO_read_id_address(reader, &scene->id, &smd->mask_id);
}
}
}
/** \} */

View File

@ -856,54 +856,6 @@ void SEQ_blend_read(BlendDataReader *reader, ListBase *seqbase)
SEQ_for_each_callback(seqbase, seq_read_data_cb, reader);
}
struct Read_lib_data {
BlendLibReader *reader;
Scene *scene;
};
static bool seq_read_lib_cb(Sequence *seq, void *user_data)
{
Read_lib_data *data = (Read_lib_data *)user_data;
BlendLibReader *reader = data->reader;
Scene *sce = data->scene;
IDP_BlendReadLib(reader, &sce->id, seq->prop);
if (seq->ipo) {
/* XXX: deprecated - old animation system. */
BLO_read_id_address(reader, &sce->id, &seq->ipo);
}
if (seq->scene) {
BLO_read_id_address(reader, &sce->id, &seq->scene);
}
if (seq->clip) {
BLO_read_id_address(reader, &sce->id, &seq->clip);
}
if (seq->mask) {
BLO_read_id_address(reader, &sce->id, &seq->mask);
}
if (seq->scene_camera) {
BLO_read_id_address(reader, &sce->id, &seq->scene_camera);
}
if (seq->sound) {
BLO_read_id_address(reader, &sce->id, &seq->sound);
}
if (seq->type == SEQ_TYPE_TEXT) {
TextVars *t = static_cast<TextVars *>(seq->effectdata);
BLO_read_id_address(reader, &sce->id, &t->text_font);
}
SEQ_modifier_blend_read_lib(reader, sce, &seq->modifiers);
return true;
}
void SEQ_blend_read_lib(BlendLibReader *reader, Scene *scene, ListBase *seqbase)
{
Read_lib_data data = {reader, scene};
SEQ_for_each_callback(seqbase, seq_read_lib_cb, &data);
}
static bool seq_doversion_250_sound_proxy_update_cb(Sequence *seq, void *user_data)
{
Main *bmain = static_cast<Main *>(user_data);

View File

@ -228,43 +228,14 @@ static void window_manager_blend_read_data(BlendDataReader *reader, ID *id)
wm->is_interface_locked = 0;
}
static void lib_link_wm_xr_data(BlendLibReader *reader, ID *parent_id, wmXrData *xr_data)
static void window_manager_blend_read_after_liblink(BlendLibReader *reader, ID *id)
{
BLO_read_id_address(reader, parent_id, &xr_data->session_settings.base_pose_object);
}
static void lib_link_workspace_instance_hook(BlendLibReader *reader,
WorkSpaceInstanceHook *hook,
ID *id)
{
WorkSpace *workspace = BKE_workspace_active_get(hook);
BLO_read_id_address(reader, id, &workspace);
BKE_workspace_active_set(hook, workspace);
}
static void window_manager_blend_read_lib(BlendLibReader *reader, ID *id)
{
wmWindowManager *wm = (wmWindowManager *)id;
wmWindowManager *wm = reinterpret_cast<wmWindowManager *>(id);
LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
if (win->workspace_hook) { /* nullptr for old files */
lib_link_workspace_instance_hook(reader, win->workspace_hook, id);
}
BLO_read_id_address(reader, id, &win->scene);
/* deprecated, but needed for versioning (will be nullptr'ed then) */
BLO_read_id_address(reader, id, &win->screen);
/* The unpinned scene is a UI->Scene-data pointer, and should be nullptr'ed on linking (like
* WorkSpace.pin_scene). But the WindowManager ID (owning the window) is never linked. */
BLI_assert(!ID_IS_LINKED(id));
BLO_read_id_address(reader, id, &win->unpinned_scene);
LISTBASE_FOREACH (ScrArea *, area, &win->global_areas.areabase) {
BKE_screen_area_blend_read_lib(reader, id, area);
BKE_screen_area_blend_read_after_liblink(reader, id, area);
}
lib_link_wm_xr_data(reader, id, &wm->xr);
}
}
@ -291,7 +262,7 @@ IDTypeInfo IDType_ID_WM = {
/*blend_write*/ window_manager_blend_write,
/*blend_read_data*/ window_manager_blend_read_data,
/*blend_read_lib*/ window_manager_blend_read_lib,
/*blend_read_after_liblink*/ window_manager_blend_read_after_liblink,
/*blend_read_undo_preserve*/ nullptr,