Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenloader/intern/readfile.c')
-rw-r--r--source/blender/blenloader/intern/readfile.c1787
1 files changed, 786 insertions, 1001 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index d7c8dbabcea..9a5f6ac6bbc 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -121,6 +121,7 @@
#include "BKE_colortools.h"
#include "BKE_constraint.h"
#include "BKE_curve.h"
+#include "BKE_curveprofile.h"
#include "BKE_effect.h"
#include "BKE_fcurve_driver.h"
#include "BKE_fluid.h"
@@ -261,10 +262,10 @@ static BHead *find_bhead_from_code_name(FileData *fd, const short idcode, const
static BHead *find_bhead_from_idname(FileData *fd, const char *idname);
#ifdef USE_COLLECTION_COMPAT_28
-static void expand_scene_collection(FileData *fd, Main *mainvar, SceneCollection *sc);
+static void expand_scene_collection(BlendExpander *expander, SceneCollection *sc);
#endif
static void direct_link_animdata(BlendDataReader *reader, AnimData *adt);
-static void lib_link_animdata(FileData *fd, ID *id, AnimData *adt);
+static void lib_link_animdata(BlendLibReader *reader, ID *id, AnimData *adt);
typedef struct BHeadN {
struct BHeadN *next, *prev;
@@ -313,7 +314,7 @@ void blo_reportf_wrap(ReportList *reports, ReportType type, const char *format,
/* for reporting linking messages */
static const char *library_parent_filepath(Library *lib)
{
- return lib->parent ? lib->parent->filepath : "<direct>";
+ return lib->parent ? lib->parent->filepath_abs : "<direct>";
}
/* -------------------------------------------------------------------- */
@@ -676,7 +677,7 @@ static Main *blo_find_main(FileData *fd, const char *filepath, const char *relab
// printf("blo_find_main: converted to %s\n", name1);
for (m = mainlist->first; m; m = m->next) {
- const char *libname = (m->curlib) ? m->curlib->filepath : m->name;
+ const char *libname = (m->curlib) ? m->curlib->filepath_abs : m->name;
if (BLI_path_cmp(name1, libname) == 0) {
if (G.debug & G_DEBUG) {
@@ -699,8 +700,8 @@ static Main *blo_find_main(FileData *fd, const char *filepath, const char *relab
/* Matches direct_link_library(). */
id_us_ensure_real(&lib->id);
- BLI_strncpy(lib->name, filepath, sizeof(lib->name));
- BLI_strncpy(lib->filepath, name1, sizeof(lib->filepath));
+ BLI_strncpy(lib->filepath, filepath, sizeof(lib->filepath));
+ BLI_strncpy(lib->filepath_abs, name1, sizeof(lib->filepath_abs));
m->curlib = lib;
@@ -2454,7 +2455,7 @@ static void link_glob_list(FileData *fd, ListBase *lb) /* for glob data */
* \{ */
static void IDP_DirectLinkProperty(IDProperty *prop, BlendDataReader *reader);
-static void IDP_LibLinkProperty(IDProperty *prop, FileData *fd);
+static void IDP_LibLinkProperty(IDProperty *prop, BlendLibReader *reader);
static void IDP_DirectLinkIDPArray(IDProperty *prop, BlendDataReader *reader)
{
@@ -2590,7 +2591,7 @@ static void _IDP_DirectLinkGroup_OrFree(IDProperty **prop,
}
}
-static void IDP_LibLinkProperty(IDProperty *prop, FileData *fd)
+static void IDP_LibLinkProperty(IDProperty *prop, BlendLibReader *reader)
{
if (!prop) {
return;
@@ -2599,7 +2600,7 @@ static void IDP_LibLinkProperty(IDProperty *prop, FileData *fd)
switch (prop->type) {
case IDP_ID: /* PointerProperty */
{
- void *newaddr = newlibadr(fd, NULL, IDP_Id(prop));
+ void *newaddr = BLO_read_get_new_id_address(reader, NULL, IDP_Id(prop));
if (IDP_Id(prop) && !newaddr && G.debug) {
printf("Error while loading \"%s\". Data not found in file!\n", prop->name);
}
@@ -2610,14 +2611,14 @@ static void IDP_LibLinkProperty(IDProperty *prop, FileData *fd)
{
IDProperty *idp_array = IDP_IDPArray(prop);
for (int i = 0; i < prop->len; i++) {
- IDP_LibLinkProperty(&(idp_array[i]), fd);
+ IDP_LibLinkProperty(&(idp_array[i]), reader);
}
break;
}
case IDP_GROUP: /* PointerProperty */
{
LISTBASE_FOREACH (IDProperty *, loop, &prop->data.group) {
- IDP_LibLinkProperty(loop, fd);
+ IDP_LibLinkProperty(loop, reader);
}
break;
}
@@ -2657,45 +2658,46 @@ static PreviewImage *direct_link_preview_image(BlendDataReader *reader, PreviewI
/** \name Read ID
* \{ */
-static void lib_link_id(FileData *fd, Main *bmain, ID *id);
-static void lib_link_nodetree(FileData *fd, Main *bmain, bNodeTree *ntree);
-static void lib_link_collection(FileData *fd, Main *bmain, Collection *collection);
+static void lib_link_id(BlendLibReader *reader, ID *id);
+static void lib_link_nodetree(BlendLibReader *reader, bNodeTree *ntree);
+static void lib_link_collection(BlendLibReader *reader, Collection *collection);
-static void lib_link_id_embedded_id(FileData *fd, Main *bmain, ID *id)
+static void lib_link_id_embedded_id(BlendLibReader *reader, ID *id)
{
+
/* Handle 'private IDs'. */
bNodeTree *nodetree = ntreeFromID(id);
if (nodetree != NULL) {
- lib_link_id(fd, bmain, &nodetree->id);
- lib_link_nodetree(fd, bmain, nodetree);
+ lib_link_id(reader, &nodetree->id);
+ lib_link_nodetree(reader, nodetree);
}
if (GS(id->name) == ID_SCE) {
Scene *scene = (Scene *)id;
if (scene->master_collection != NULL) {
- lib_link_id(fd, bmain, &scene->master_collection->id);
- lib_link_collection(fd, bmain, scene->master_collection);
+ lib_link_id(reader, &scene->master_collection->id);
+ lib_link_collection(reader, scene->master_collection);
}
}
}
-static void lib_link_id(FileData *fd, Main *bmain, ID *id)
+static void lib_link_id(BlendLibReader *reader, ID *id)
{
/* Note: WM IDProperties are never written to file, hence they should always be NULL here. */
BLI_assert((GS(id->name) != ID_WM) || id->properties == NULL);
- IDP_LibLinkProperty(id->properties, fd);
+ IDP_LibLinkProperty(id->properties, reader);
AnimData *adt = BKE_animdata_from_id(id);
if (adt != NULL) {
- lib_link_animdata(fd, id, adt);
+ lib_link_animdata(reader, id, adt);
}
if (id->override_library) {
- id->override_library->reference = newlibadr(fd, id->lib, id->override_library->reference);
- id->override_library->storage = newlibadr(fd, id->lib, id->override_library->storage);
+ BLO_read_id_address(reader, id->lib, &id->override_library->reference);
+ BLO_read_id_address(reader, id->lib, &id->override_library->storage);
}
- lib_link_id_embedded_id(fd, bmain, id);
+ lib_link_id_embedded_id(reader, id);
}
static void direct_link_id_override_property_operation_cb(BlendDataReader *reader, void *data)
@@ -2890,58 +2892,23 @@ static void direct_link_id_common(
/** \} */
/* -------------------------------------------------------------------- */
-/** \name Read CurveMapping
- * \{ */
-
-/* cuma itself has been read! */
-static void direct_link_curvemapping(BlendDataReader *reader, CurveMapping *cumap)
-{
- int a;
-
- /* flag seems to be able to hang? Maybe old files... not bad to clear anyway */
- cumap->flag &= ~CUMA_PREMULLED;
-
- for (a = 0; a < CM_TOT; a++) {
- BLO_read_data_address(reader, &cumap->cm[a].curve);
- cumap->cm[a].table = NULL;
- cumap->cm[a].premultable = NULL;
- }
-}
-
-/** \} */
-
-/* -------------------------------------------------------------------- */
-/** \name Read CurveProfile
- * \{ */
-
-static void direct_link_curveprofile(BlendDataReader *reader, CurveProfile *profile)
-{
- BLO_read_data_address(reader, &profile->path);
- profile->table = NULL;
- profile->segments = NULL;
-}
-
-/** \} */
-
-/* -------------------------------------------------------------------- */
/** \name Read ID: Brush
* \{ */
/* library brush linking after fileread */
-static void lib_link_brush(FileData *fd, Main *UNUSED(bmain), Brush *brush)
+static void lib_link_brush(BlendLibReader *reader, Brush *brush)
{
/* brush->(mask_)mtex.obj is ignored on purpose? */
- brush->mtex.tex = newlibadr(fd, brush->id.lib, brush->mtex.tex);
- brush->mask_mtex.tex = newlibadr(fd, brush->id.lib, brush->mask_mtex.tex);
- brush->clone.image = newlibadr(fd, brush->id.lib, brush->clone.image);
- brush->toggle_brush = newlibadr(fd, brush->id.lib, brush->toggle_brush);
- brush->paint_curve = newlibadr(fd, brush->id.lib, brush->paint_curve);
+ BLO_read_id_address(reader, brush->id.lib, &brush->mtex.tex);
+ BLO_read_id_address(reader, brush->id.lib, &brush->mask_mtex.tex);
+ BLO_read_id_address(reader, brush->id.lib, &brush->clone.image);
+ BLO_read_id_address(reader, brush->id.lib, &brush->toggle_brush);
+ BLO_read_id_address(reader, brush->id.lib, &brush->paint_curve);
/* link default grease pencil palette */
if (brush->gpencil_settings != NULL) {
if (brush->gpencil_settings->flag & GP_BRUSH_MATERIAL_PINNED) {
- brush->gpencil_settings->material = newlibadr(
- fd, brush->id.lib, brush->gpencil_settings->material);
+ BLO_read_id_address(reader, brush->id.lib, &brush->gpencil_settings->material);
if (!brush->gpencil_settings->material) {
brush->gpencil_settings->flag &= ~GP_BRUSH_MATERIAL_PINNED;
@@ -2963,7 +2930,7 @@ static void direct_link_brush(BlendDataReader *reader, Brush *brush)
BLO_read_data_address(reader, &brush->gradient);
if (brush->curve) {
- direct_link_curvemapping(reader, brush->curve);
+ BKE_curvemapping_blend_read(reader, brush->curve);
}
else {
BKE_brush_curve_preset(brush, CURVE_PRESET_SHARP);
@@ -2984,39 +2951,39 @@ static void direct_link_brush(BlendDataReader *reader, Brush *brush)
BLO_read_data_address(reader, &brush->gpencil_settings->curve_rand_value);
if (brush->gpencil_settings->curve_sensitivity) {
- direct_link_curvemapping(reader, brush->gpencil_settings->curve_sensitivity);
+ BKE_curvemapping_blend_read(reader, brush->gpencil_settings->curve_sensitivity);
}
if (brush->gpencil_settings->curve_strength) {
- direct_link_curvemapping(reader, brush->gpencil_settings->curve_strength);
+ BKE_curvemapping_blend_read(reader, brush->gpencil_settings->curve_strength);
}
if (brush->gpencil_settings->curve_jitter) {
- direct_link_curvemapping(reader, brush->gpencil_settings->curve_jitter);
+ BKE_curvemapping_blend_read(reader, brush->gpencil_settings->curve_jitter);
}
if (brush->gpencil_settings->curve_rand_pressure) {
- direct_link_curvemapping(reader, brush->gpencil_settings->curve_rand_pressure);
+ BKE_curvemapping_blend_read(reader, brush->gpencil_settings->curve_rand_pressure);
}
if (brush->gpencil_settings->curve_rand_strength) {
- direct_link_curvemapping(reader, brush->gpencil_settings->curve_rand_strength);
+ BKE_curvemapping_blend_read(reader, brush->gpencil_settings->curve_rand_strength);
}
if (brush->gpencil_settings->curve_rand_uv) {
- direct_link_curvemapping(reader, brush->gpencil_settings->curve_rand_uv);
+ BKE_curvemapping_blend_read(reader, brush->gpencil_settings->curve_rand_uv);
}
if (brush->gpencil_settings->curve_rand_hue) {
- direct_link_curvemapping(reader, brush->gpencil_settings->curve_rand_hue);
+ BKE_curvemapping_blend_read(reader, brush->gpencil_settings->curve_rand_hue);
}
if (brush->gpencil_settings->curve_rand_saturation) {
- direct_link_curvemapping(reader, brush->gpencil_settings->curve_rand_saturation);
+ BKE_curvemapping_blend_read(reader, brush->gpencil_settings->curve_rand_saturation);
}
if (brush->gpencil_settings->curve_rand_value) {
- direct_link_curvemapping(reader, brush->gpencil_settings->curve_rand_value);
+ BKE_curvemapping_blend_read(reader, brush->gpencil_settings->curve_rand_value);
}
}
@@ -3030,7 +2997,7 @@ static void direct_link_brush(BlendDataReader *reader, Brush *brush)
/** \name Read ID: Palette
* \{ */
-static void lib_link_palette(FileData *UNUSED(fd), Main *UNUSED(bmain), Palette *UNUSED(palette))
+static void lib_link_palette(BlendLibReader *UNUSED(reader), Palette *UNUSED(palette))
{
}
@@ -3041,7 +3008,7 @@ static void direct_link_palette(BlendDataReader *reader, Palette *palette)
BLO_read_list(reader, &palette->colors);
}
-static void lib_link_paint_curve(FileData *UNUSED(fd), Main *UNUSED(bmain), PaintCurve *UNUSED(pc))
+static void lib_link_paint_curve(BlendLibReader *UNUSED(reader), PaintCurve *UNUSED(pc))
{
}
@@ -3080,11 +3047,11 @@ static PackedFile *direct_link_packedfile(BlendDataReader *reader, PackedFile *o
* \{ */
// XXX deprecated - old animation system
-static void lib_link_ipo(FileData *fd, Main *UNUSED(bmain), Ipo *ipo)
+static void lib_link_ipo(BlendLibReader *reader, Ipo *ipo)
{
LISTBASE_FOREACH (IpoCurve *, icu, &ipo->curve) {
if (icu->driver) {
- icu->driver->ob = newlibadr(fd, ipo->id.lib, icu->driver->ob);
+ BLO_read_id_address(reader, ipo->id.lib, &icu->driver->ob);
}
}
}
@@ -3104,17 +3071,17 @@ static void direct_link_ipo(BlendDataReader *reader, Ipo *ipo)
}
// XXX deprecated - old animation system
-static void lib_link_nlastrips(FileData *fd, ID *id, ListBase *striplist)
+static void lib_link_nlastrips(BlendLibReader *reader, ID *id, ListBase *striplist)
{
bActionStrip *strip;
bActionModifier *amod;
for (strip = striplist->first; strip; strip = strip->next) {
- strip->object = newlibadr(fd, id->lib, strip->object);
- strip->act = newlibadr(fd, id->lib, strip->act);
- strip->ipo = newlibadr(fd, id->lib, strip->ipo);
+ BLO_read_id_address(reader, id->lib, &strip->object);
+ BLO_read_id_address(reader, id->lib, &strip->act);
+ BLO_read_id_address(reader, id->lib, &strip->ipo);
for (amod = strip->modifiers.first; amod; amod = amod->next) {
- amod->ob = newlibadr(fd, id->lib, amod->ob);
+ BLO_read_id_address(reader, id->lib, &amod->ob);
}
}
}
@@ -3132,12 +3099,12 @@ static void direct_link_nlastrips(BlendDataReader *reader, ListBase *strips)
}
// XXX deprecated - old animation system
-static void lib_link_constraint_channels(FileData *fd, ID *id, ListBase *chanbase)
+static void lib_link_constraint_channels(BlendLibReader *reader, ID *id, ListBase *chanbase)
{
bConstraintChannel *chan;
for (chan = chanbase->first; chan; chan = chan->next) {
- chan->ipo = newlibadr(fd, id->lib, chan->ipo);
+ BLO_read_id_address(reader, id->lib, &chan->ipo);
}
}
@@ -3147,7 +3114,7 @@ static void lib_link_constraint_channels(FileData *fd, ID *id, ListBase *chanbas
/** \name Read ID: Action
* \{ */
-static void lib_link_fmodifiers(FileData *fd, ID *id, ListBase *list)
+static void lib_link_fmodifiers(BlendLibReader *reader, ID *id, ListBase *list)
{
FModifier *fcm;
@@ -3156,7 +3123,7 @@ static void lib_link_fmodifiers(FileData *fd, ID *id, ListBase *list)
switch (fcm->type) {
case FMODIFIER_TYPE_PYTHON: {
FMod_Python *data = (FMod_Python *)fcm->data;
- data->script = newlibadr(fd, id->lib, data->script);
+ BLO_read_id_address(reader, id->lib, &data->script);
break;
}
@@ -3164,7 +3131,7 @@ static void lib_link_fmodifiers(FileData *fd, ID *id, ListBase *list)
}
}
-static void lib_link_fcurves(FileData *fd, ID *id, ListBase *list)
+static void lib_link_fcurves(BlendLibReader *reader, ID *id, ListBase *list)
{
FCurve *fcu;
@@ -3183,7 +3150,7 @@ static void lib_link_fcurves(FileData *fd, ID *id, ListBase *list)
DRIVER_TARGETS_LOOPER_BEGIN (dvar) {
/* only relink if still used */
if (tarIndex < dvar->num_targets) {
- dtar->id = newlibadr(fd, id->lib, dtar->id);
+ BLO_read_id_address(reader, id->lib, &dtar->id);
}
else {
dtar->id = NULL;
@@ -3194,7 +3161,7 @@ static void lib_link_fcurves(FileData *fd, ID *id, ListBase *list)
}
/* modifiers */
- lib_link_fmodifiers(fd, id, &fcu->modifiers);
+ lib_link_fmodifiers(reader, id, &fcu->modifiers);
}
}
@@ -3294,20 +3261,20 @@ static void direct_link_fcurves(BlendDataReader *reader, ListBase *list)
}
}
-static void lib_link_action(FileData *fd, Main *UNUSED(bmain), bAction *act)
+static void lib_link_action(BlendLibReader *reader, bAction *act)
{
// XXX deprecated - old animation system <<<
LISTBASE_FOREACH (bActionChannel *, chan, &act->chanbase) {
- chan->ipo = newlibadr(fd, act->id.lib, chan->ipo);
- lib_link_constraint_channels(fd, &act->id, &chan->constraintChannels);
+ BLO_read_id_address(reader, act->id.lib, &chan->ipo);
+ lib_link_constraint_channels(reader, &act->id, &chan->constraintChannels);
}
// >>> XXX deprecated - old animation system
- lib_link_fcurves(fd, &act->id, &act->curves);
+ lib_link_fcurves(reader, &act->id, &act->curves);
LISTBASE_FOREACH (TimeMarker *, marker, &act->markers) {
if (marker->camera) {
- marker->camera = newlibadr(fd, act->id.lib, marker->camera);
+ BLO_read_id_address(reader, act->id.lib, &marker->camera);
}
}
}
@@ -3338,29 +3305,29 @@ static void direct_link_action(BlendDataReader *reader, bAction *act)
}
}
-static void lib_link_nladata_strips(FileData *fd, ID *id, ListBase *list)
+static void lib_link_nladata_strips(BlendLibReader *reader, ID *id, ListBase *list)
{
NlaStrip *strip;
for (strip = list->first; strip; strip = strip->next) {
/* check strip's children */
- lib_link_nladata_strips(fd, id, &strip->strips);
+ lib_link_nladata_strips(reader, id, &strip->strips);
/* check strip's F-Curves */
- lib_link_fcurves(fd, id, &strip->fcurves);
+ lib_link_fcurves(reader, id, &strip->fcurves);
/* reassign the counted-reference to action */
- strip->act = newlibadr(fd, id->lib, strip->act);
+ BLO_read_id_address(reader, id->lib, &strip->act);
}
}
-static void lib_link_nladata(FileData *fd, ID *id, ListBase *list)
+static void lib_link_nladata(BlendLibReader *reader, ID *id, ListBase *list)
{
NlaTrack *nlt;
/* we only care about the NLA strips inside the tracks */
for (nlt = list->first; nlt; nlt = nlt->next) {
- lib_link_nladata_strips(fd, id, &nlt->strips);
+ lib_link_nladata_strips(reader, id, &nlt->strips);
}
}
@@ -3402,7 +3369,7 @@ static void direct_link_nladata(BlendDataReader *reader, ListBase *list)
/* ------- */
-static void lib_link_keyingsets(FileData *fd, ID *id, ListBase *list)
+static void lib_link_keyingsets(BlendLibReader *reader, ID *id, ListBase *list)
{
KeyingSet *ks;
KS_Path *ksp;
@@ -3410,7 +3377,7 @@ static void lib_link_keyingsets(FileData *fd, ID *id, ListBase *list)
/* here, we're only interested in the ID pointer stored in some of the paths */
for (ks = list->first; ks; ks = ks->next) {
for (ksp = ks->paths.first; ksp; ksp = ksp->next) {
- ksp->id = newlibadr(fd, id->lib, ksp->id);
+ BLO_read_id_address(reader, id->lib, &ksp->id);
}
}
}
@@ -3435,23 +3402,23 @@ static void direct_link_keyingsets(BlendDataReader *reader, ListBase *list)
/* ------- */
-static void lib_link_animdata(FileData *fd, ID *id, AnimData *adt)
+static void lib_link_animdata(BlendLibReader *reader, ID *id, AnimData *adt)
{
if (adt == NULL) {
return;
}
/* link action data */
- adt->action = newlibadr(fd, id->lib, adt->action);
- adt->tmpact = newlibadr(fd, id->lib, adt->tmpact);
+ BLO_read_id_address(reader, id->lib, &adt->action);
+ BLO_read_id_address(reader, id->lib, &adt->tmpact);
/* link drivers */
- lib_link_fcurves(fd, id, &adt->drivers);
+ lib_link_fcurves(reader, id, &adt->drivers);
/* overrides don't have lib-link for now, so no need to do anything */
/* link NLA-data */
- lib_link_nladata(fd, id, &adt->nla_tracks);
+ lib_link_nladata(reader, id, &adt->nla_tracks);
}
static void direct_link_animdata(BlendDataReader *reader, AnimData *adt)
@@ -3489,9 +3456,7 @@ static void direct_link_animdata(BlendDataReader *reader, AnimData *adt)
/** \name Read ID: CacheFiles
* \{ */
-static void lib_link_cachefiles(FileData *UNUSED(fd),
- Main *UNUSED(bmain),
- CacheFile *UNUSED(cache_file))
+static void lib_link_cachefiles(BlendLibReader *UNUSED(reader), CacheFile *UNUSED(cache_file))
{
}
@@ -3513,26 +3478,26 @@ static void direct_link_cachefile(BlendDataReader *reader, CacheFile *cache_file
/** \name Read ID: WorkSpace
* \{ */
-static void lib_link_workspaces(FileData *fd, Main *bmain, WorkSpace *workspace)
+static void lib_link_workspaces(BlendLibReader *reader, WorkSpace *workspace)
{
ID *id = (ID *)workspace;
LISTBASE_FOREACH_MUTABLE (WorkSpaceLayout *, layout, &workspace->layouts) {
- layout->screen = newlibadr(fd, id->lib, layout->screen);
+ BLO_read_id_address(reader, id->lib, &layout->screen);
if (layout->screen) {
if (ID_IS_LINKED(id)) {
layout->screen->winid = 0;
if (layout->screen->temp) {
/* delete temp layouts when appending */
- BKE_workspace_layout_remove(bmain, workspace, layout);
+ BKE_workspace_layout_remove(reader->main, workspace, layout);
}
}
}
else {
/* If we're reading a layout without screen stored, it's useless and we shouldn't keep it
* around. */
- BKE_workspace_layout_remove(bmain, workspace, layout);
+ BKE_workspace_layout_remove(reader->main, workspace, layout);
}
}
}
@@ -3569,10 +3534,13 @@ static void direct_link_workspace(BlendDataReader *reader, WorkSpace *workspace,
id_us_ensure_real(&workspace->id);
}
-static void lib_link_workspace_instance_hook(FileData *fd, WorkSpaceInstanceHook *hook, ID *id)
+static void lib_link_workspace_instance_hook(BlendLibReader *reader,
+ WorkSpaceInstanceHook *hook,
+ ID *id)
{
WorkSpace *workspace = BKE_workspace_active_get(hook);
- BKE_workspace_active_set(hook, newlibadr(fd, id->lib, workspace));
+ BLO_read_id_address(reader, id->lib, &workspace);
+ BKE_workspace_active_set(hook, workspace);
}
/** \} */
@@ -3581,19 +3549,19 @@ static void lib_link_workspace_instance_hook(FileData *fd, WorkSpaceInstanceHook
/** \name Read ID: Node Tree
* \{ */
-static void lib_link_node_socket(FileData *fd, Library *lib, bNodeSocket *sock)
+static void lib_link_node_socket(BlendLibReader *reader, Library *lib, bNodeSocket *sock)
{
- IDP_LibLinkProperty(sock->prop, fd);
+ IDP_LibLinkProperty(sock->prop, reader);
switch ((eNodeSocketDatatype)sock->type) {
case SOCK_OBJECT: {
bNodeSocketValueObject *default_value = sock->default_value;
- default_value->value = newlibadr(fd, lib, default_value->value);
+ BLO_read_id_address(reader, lib, &default_value->value);
break;
}
case SOCK_IMAGE: {
bNodeSocketValueImage *default_value = sock->default_value;
- default_value->value = newlibadr(fd, lib, default_value->value);
+ BLO_read_id_address(reader, lib, &default_value->value);
break;
}
case SOCK_FLOAT:
@@ -3613,33 +3581,33 @@ static void lib_link_node_socket(FileData *fd, Library *lib, bNodeSocket *sock)
}
}
-static void lib_link_node_sockets(FileData *fd, Library *lib, ListBase *sockets)
+static void lib_link_node_sockets(BlendLibReader *reader, Library *lib, ListBase *sockets)
{
LISTBASE_FOREACH (bNodeSocket *, sock, sockets) {
- lib_link_node_socket(fd, lib, sock);
+ lib_link_node_socket(reader, lib, sock);
}
}
/* Single node tree (also used for material/scene trees), ntree is not NULL */
-static void lib_link_ntree(FileData *fd, Library *lib, bNodeTree *ntree)
+static void lib_link_ntree(BlendLibReader *reader, Library *lib, bNodeTree *ntree)
{
ntree->id.lib = lib;
- ntree->gpd = newlibadr(fd, lib, ntree->gpd);
+ BLO_read_id_address(reader, lib, &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_LibLinkProperty(node->prop, fd);
+ IDP_LibLinkProperty(node->prop, reader);
- node->id = newlibadr(fd, lib, node->id);
+ BLO_read_id_address(reader, lib, &node->id);
- lib_link_node_sockets(fd, lib, &node->inputs);
- lib_link_node_sockets(fd, lib, &node->outputs);
+ lib_link_node_sockets(reader, lib, &node->inputs);
+ lib_link_node_sockets(reader, lib, &node->outputs);
}
- lib_link_node_sockets(fd, lib, &ntree->inputs);
- lib_link_node_sockets(fd, lib, &ntree->outputs);
+ lib_link_node_sockets(reader, lib, &ntree->inputs);
+ lib_link_node_sockets(reader, lib, &ntree->outputs);
/* Set node->typeinfo pointers. This is done in lib linking, after the
* first versioning that can change types still without functions that
@@ -3649,7 +3617,7 @@ static void lib_link_ntree(FileData *fd, Library *lib, bNodeTree *ntree)
/* For nodes with static socket layout, add/remove sockets as needed
* to match the static layout. */
- if (fd->memfile == NULL) {
+ if (reader->fd->memfile == NULL) {
LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
node_verify_socket_templates(ntree, node);
}
@@ -3657,9 +3625,9 @@ static void lib_link_ntree(FileData *fd, Library *lib, bNodeTree *ntree)
}
/* library ntree linking after fileread */
-static void lib_link_nodetree(FileData *fd, Main *UNUSED(bmain), bNodeTree *ntree)
+static void lib_link_nodetree(BlendLibReader *reader, bNodeTree *ntree)
{
- lib_link_ntree(fd, ntree->id.lib, ntree);
+ lib_link_ntree(reader, ntree->id.lib, ntree);
}
static void direct_link_node_socket(BlendDataReader *reader, bNodeSocket *sock)
@@ -3729,7 +3697,7 @@ static void direct_link_nodetree(BlendDataReader *reader, bNodeTree *ntree)
case CMP_NODE_HUECORRECT:
case TEX_NODE_CURVE_RGB:
case TEX_NODE_CURVE_TIME: {
- direct_link_curvemapping(reader, node->storage);
+ BKE_curvemapping_blend_read(reader, node->storage);
break;
}
case SH_NODE_SCRIPT: {
@@ -3845,7 +3813,7 @@ static void direct_link_nodetree(BlendDataReader *reader, bNodeTree *ntree)
/* temp struct used to transport needed info to lib_link_constraint_cb() */
typedef struct tConstraintLinkData {
- FileData *fd;
+ BlendLibReader *reader;
ID *id;
} tConstraintLinkData;
/* callback function used to relink constraint ID-links */
@@ -3855,10 +3823,10 @@ static void lib_link_constraint_cb(bConstraint *UNUSED(con),
void *userdata)
{
tConstraintLinkData *cld = (tConstraintLinkData *)userdata;
- *idpoin = newlibadr(cld->fd, cld->id->lib, *idpoin);
+ BLO_read_id_address(cld->reader, cld->id->lib, idpoin);
}
-static void lib_link_constraints(FileData *fd, ID *id, ListBase *conlist)
+static void lib_link_constraints(BlendLibReader *reader, ID *id, ListBase *conlist)
{
tConstraintLinkData cld;
bConstraint *con;
@@ -3871,7 +3839,7 @@ static void lib_link_constraints(FileData *fd, ID *id, ListBase *conlist)
con->type = CONSTRAINT_TYPE_NULL;
}
/* own ipo, all constraints have it */
- con->ipo = newlibadr(fd, id->lib, con->ipo); // XXX deprecated - old animation system
+ BLO_read_id_address(reader, id->lib, &con->ipo); // XXX deprecated - old animation system
/* If linking from a library, clear 'local' library override flag. */
if (id->lib != NULL) {
@@ -3880,7 +3848,7 @@ static void lib_link_constraints(FileData *fd, ID *id, ListBase *conlist)
}
/* relink all ID-blocks used by the constraints */
- cld.fd = fd;
+ cld.reader = reader;
cld.id = id;
BKE_constraints_id_loop(conlist, lib_link_constraint_cb, &cld);
@@ -3943,7 +3911,7 @@ static void direct_link_constraints(BlendDataReader *reader, ListBase *lb)
}
}
-static void lib_link_pose(FileData *fd, Main *bmain, Object *ob, bPose *pose)
+static void lib_link_pose(BlendLibReader *reader, Object *ob, bPose *pose)
{
bArmature *arm = ob->data;
@@ -3954,7 +3922,7 @@ static void lib_link_pose(FileData *fd, Main *bmain, Object *ob, bPose *pose)
/* always rebuild to match proxy or lib changes, but on Undo */
bool rebuild = false;
- if (fd->memfile == NULL) {
+ if (reader->fd->memfile == NULL) {
if (ob->proxy || ob->id.lib != arm->id.lib) {
rebuild = true;
}
@@ -3976,13 +3944,13 @@ static void lib_link_pose(FileData *fd, Main *bmain, Object *ob, bPose *pose)
}
LISTBASE_FOREACH (bPoseChannel *, pchan, &pose->chanbase) {
- lib_link_constraints(fd, (ID *)ob, &pchan->constraints);
+ lib_link_constraints(reader, (ID *)ob, &pchan->constraints);
pchan->bone = BKE_armature_find_bone_name(arm, pchan->name);
- IDP_LibLinkProperty(pchan->prop, fd);
+ IDP_LibLinkProperty(pchan->prop, reader);
- pchan->custom = newlibadr(fd, arm->id.lib, pchan->custom);
+ BLO_read_id_address(reader, arm->id.lib, &pchan->custom);
if (UNLIKELY(pchan->bone == NULL)) {
rebuild = true;
}
@@ -3995,24 +3963,24 @@ static void lib_link_pose(FileData *fd, Main *bmain, Object *ob, bPose *pose)
if (rebuild) {
DEG_id_tag_update_ex(
- bmain, &ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION);
- BKE_pose_tag_recalc(bmain, pose);
+ reader->main, &ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION);
+ BKE_pose_tag_recalc(reader->main, pose);
}
}
-static void lib_link_bones(FileData *fd, Bone *bone)
+static void lib_link_bones(BlendLibReader *reader, Bone *bone)
{
- IDP_LibLinkProperty(bone->prop, fd);
+ IDP_LibLinkProperty(bone->prop, reader);
LISTBASE_FOREACH (Bone *, curbone, &bone->childbase) {
- lib_link_bones(fd, curbone);
+ lib_link_bones(reader, curbone);
}
}
-static void lib_link_armature(FileData *fd, Main *UNUSED(bmain), bArmature *arm)
+static void lib_link_armature(BlendLibReader *reader, bArmature *arm)
{
LISTBASE_FOREACH (Bone *, curbone, &arm->bonebase) {
- lib_link_bones(fd, curbone);
+ lib_link_bones(reader, curbone);
}
}
@@ -4065,16 +4033,16 @@ static void direct_link_armature(BlendDataReader *reader, bArmature *arm)
/** \name Read ID: Camera
* \{ */
-static void lib_link_camera(FileData *fd, Main *UNUSED(bmain), Camera *ca)
+static void lib_link_camera(BlendLibReader *reader, Camera *ca)
{
- ca->ipo = newlibadr(fd, ca->id.lib, ca->ipo); /* deprecated, for versioning */
+ BLO_read_id_address(reader, ca->id.lib, &ca->ipo); /* deprecated, for versioning */
- ca->dof_ob = newlibadr(fd, ca->id.lib, ca->dof_ob); /* deprecated, for versioning */
- ca->dof.focus_object = newlibadr(fd, ca->id.lib, ca->dof.focus_object);
+ BLO_read_id_address(reader, ca->id.lib, &ca->dof_ob); /* deprecated, for versioning */
+ BLO_read_id_address(reader, ca->id.lib, &ca->dof.focus_object);
LISTBASE_FOREACH (CameraBGImage *, bgpic, &ca->bg_images) {
- bgpic->ima = newlibadr(fd, ca->id.lib, bgpic->ima);
- bgpic->clip = newlibadr(fd, ca->id.lib, bgpic->clip);
+ BLO_read_id_address(reader, ca->id.lib, &bgpic->ima);
+ BLO_read_id_address(reader, ca->id.lib, &bgpic->clip);
}
}
@@ -4097,9 +4065,9 @@ static void direct_link_camera(BlendDataReader *reader, Camera *ca)
/** \name Read ID: Light
* \{ */
-static void lib_link_light(FileData *fd, Main *UNUSED(bmain), Light *la)
+static void lib_link_light(BlendLibReader *reader, Light *la)
{
- la->ipo = newlibadr(fd, la->id.lib, la->ipo); // XXX deprecated - old animation system
+ BLO_read_id_address(reader, la->id.lib, &la->ipo); // XXX deprecated - old animation system
}
static void direct_link_light(BlendDataReader *reader, Light *la)
@@ -4109,7 +4077,7 @@ static void direct_link_light(BlendDataReader *reader, Light *la)
BLO_read_data_address(reader, &la->curfalloff);
if (la->curfalloff) {
- direct_link_curvemapping(reader, la->curfalloff);
+ BKE_curvemapping_blend_read(reader, la->curfalloff);
}
la->preview = direct_link_preview_image(reader, la->preview);
@@ -4131,12 +4099,12 @@ void blo_do_versions_key_uidgen(Key *key)
}
}
-static void lib_link_key(FileData *fd, Main *UNUSED(bmain), Key *key)
+static void lib_link_key(BlendLibReader *reader, Key *key)
{
BLI_assert((key->id.tag & LIB_TAG_EXTERN) == 0);
- key->ipo = newlibadr(fd, key->id.lib, key->ipo); // XXX deprecated - old animation system
- key->from = newlibadr(fd, key->id.lib, key->from);
+ BLO_read_id_address(reader, key->id.lib, &key->ipo); // XXX deprecated - old animation system
+ BLO_read_id_address(reader, key->id.lib, &key->from);
}
static void switch_endian_keyblock(Key *key, KeyBlock *kb)
@@ -4194,13 +4162,13 @@ static void direct_link_key(BlendDataReader *reader, Key *key)
/** \name Read ID: Meta Ball
* \{ */
-static void lib_link_mball(FileData *fd, Main *UNUSED(bmain), MetaBall *mb)
+static void lib_link_mball(BlendLibReader *reader, MetaBall *mb)
{
for (int a = 0; a < mb->totcol; a++) {
- mb->mat[a] = newlibadr(fd, mb->id.lib, mb->mat[a]);
+ BLO_read_id_address(reader, mb->id.lib, &mb->mat[a]);
}
- mb->ipo = newlibadr(fd, mb->id.lib, mb->ipo); // XXX deprecated - old animation system
+ BLO_read_id_address(reader, mb->id.lib, &mb->ipo); // XXX deprecated - old animation system
}
static void direct_link_mball(BlendDataReader *reader, MetaBall *mb)
@@ -4227,9 +4195,9 @@ static void direct_link_mball(BlendDataReader *reader, MetaBall *mb)
/** \name Read ID: World
* \{ */
-static void lib_link_world(FileData *fd, Main *UNUSED(bmain), World *wrld)
+static void lib_link_world(BlendLibReader *reader, World *wrld)
{
- wrld->ipo = newlibadr(fd, wrld->id.lib, wrld->ipo); // XXX deprecated - old animation system
+ BLO_read_id_address(reader, wrld->id.lib, &wrld->ipo); // XXX deprecated - old animation system
}
static void direct_link_world(BlendDataReader *reader, World *wrld)
@@ -4247,7 +4215,7 @@ static void direct_link_world(BlendDataReader *reader, World *wrld)
/** \name Read ID: VFont
* \{ */
-static void lib_link_vfont(FileData *UNUSED(fd), Main *UNUSED(bmain), VFont *UNUSED(vf))
+static void lib_link_vfont(BlendLibReader *UNUSED(reader), VFont *UNUSED(vf))
{
}
@@ -4264,7 +4232,7 @@ static void direct_link_vfont(BlendDataReader *reader, VFont *vf)
/** \name Read ID: Text
* \{ */
-static void lib_link_text(FileData *UNUSED(fd), Main *UNUSED(bmain), Text *UNUSED(text))
+static void lib_link_text(BlendLibReader *UNUSED(reader), Text *UNUSED(text))
{
}
@@ -4272,7 +4240,7 @@ static void direct_link_text(BlendDataReader *reader, Text *text)
{
TextLine *ln;
- BLO_read_data_address(reader, &text->name);
+ BLO_read_data_address(reader, &text->filepath);
text->compiled = NULL;
@@ -4309,7 +4277,7 @@ static void direct_link_text(BlendDataReader *reader, Text *text)
/** \name Read ID: Image
* \{ */
-static void lib_link_image(FileData *UNUSED(fd), Main *UNUSED(bmain), Image *UNUSED(ima))
+static void lib_link_image(BlendLibReader *UNUSED(reader), Image *UNUSED(ima))
{
}
@@ -4388,22 +4356,22 @@ static void direct_link_image(BlendDataReader *reader, Image *ima)
/** \name Read ID: Curve
* \{ */
-static void lib_link_curve(FileData *fd, Main *UNUSED(bmain), Curve *cu)
+static void lib_link_curve(BlendLibReader *reader, Curve *cu)
{
for (int a = 0; a < cu->totcol; a++) {
- cu->mat[a] = newlibadr(fd, cu->id.lib, cu->mat[a]);
+ BLO_read_id_address(reader, cu->id.lib, &cu->mat[a]);
}
- cu->bevobj = newlibadr(fd, cu->id.lib, cu->bevobj);
- cu->taperobj = newlibadr(fd, cu->id.lib, cu->taperobj);
- cu->textoncurve = newlibadr(fd, cu->id.lib, cu->textoncurve);
- cu->vfont = newlibadr(fd, cu->id.lib, cu->vfont);
- cu->vfontb = newlibadr(fd, cu->id.lib, cu->vfontb);
- cu->vfonti = newlibadr(fd, cu->id.lib, cu->vfonti);
- cu->vfontbi = newlibadr(fd, cu->id.lib, cu->vfontbi);
+ BLO_read_id_address(reader, cu->id.lib, &cu->bevobj);
+ BLO_read_id_address(reader, cu->id.lib, &cu->taperobj);
+ BLO_read_id_address(reader, cu->id.lib, &cu->textoncurve);
+ BLO_read_id_address(reader, cu->id.lib, &cu->vfont);
+ BLO_read_id_address(reader, cu->id.lib, &cu->vfontb);
+ BLO_read_id_address(reader, cu->id.lib, &cu->vfonti);
+ BLO_read_id_address(reader, cu->id.lib, &cu->vfontbi);
- cu->ipo = newlibadr(fd, cu->id.lib, cu->ipo); // XXX deprecated - old animation system
- cu->key = newlibadr(fd, cu->id.lib, cu->key);
+ BLO_read_id_address(reader, cu->id.lib, &cu->ipo); // XXX deprecated - old animation system
+ BLO_read_id_address(reader, cu->id.lib, &cu->key);
}
static void switch_endian_knots(Nurb *nu)
@@ -4482,10 +4450,10 @@ static void direct_link_curve(BlendDataReader *reader, Curve *cu)
/** \name Read ID: Texture
* \{ */
-static void lib_link_texture(FileData *fd, Main *UNUSED(bmain), Tex *tex)
+static void lib_link_texture(BlendLibReader *reader, Tex *tex)
{
- tex->ima = newlibadr(fd, tex->id.lib, tex->ima);
- tex->ipo = newlibadr(fd, tex->id.lib, tex->ipo); // XXX deprecated - old animation system
+ BLO_read_id_address(reader, tex->id.lib, &tex->ima);
+ BLO_read_id_address(reader, tex->id.lib, &tex->ipo); // XXX deprecated - old animation system
}
static void direct_link_texture(BlendDataReader *reader, Tex *tex)
@@ -4507,18 +4475,18 @@ static void direct_link_texture(BlendDataReader *reader, Tex *tex)
/** \name Read ID: Material
* \{ */
-static void lib_link_material(FileData *fd, Main *UNUSED(bmain), Material *ma)
+static void lib_link_material(BlendLibReader *reader, Material *ma)
{
- ma->ipo = newlibadr(fd, ma->id.lib, ma->ipo); // XXX deprecated - old animation system
+ BLO_read_id_address(reader, ma->id.lib, &ma->ipo); // XXX deprecated - old animation system
/* relink grease pencil settings */
if (ma->gp_style != NULL) {
MaterialGPencilStyle *gp_style = ma->gp_style;
if (gp_style->sima != NULL) {
- gp_style->sima = newlibadr(fd, ma->id.lib, gp_style->sima);
+ BLO_read_id_address(reader, ma->id.lib, &gp_style->sima);
}
if (gp_style->ima != NULL) {
- gp_style->ima = newlibadr(fd, ma->id.lib, gp_style->ima);
+ BLO_read_id_address(reader, ma->id.lib, &gp_style->ima);
}
}
}
@@ -4629,31 +4597,31 @@ static void direct_link_pointcache_list(BlendDataReader *reader,
}
}
-static void lib_link_partdeflect(FileData *fd, ID *id, PartDeflect *pd)
+static void lib_link_partdeflect(BlendLibReader *reader, ID *id, PartDeflect *pd)
{
if (pd && pd->tex) {
- pd->tex = newlibadr(fd, id->lib, pd->tex);
+ BLO_read_id_address(reader, id->lib, &pd->tex);
}
if (pd && pd->f_source) {
- pd->f_source = newlibadr(fd, id->lib, pd->f_source);
+ BLO_read_id_address(reader, id->lib, &pd->f_source);
}
}
-static void lib_link_particlesettings(FileData *fd, Main *UNUSED(bmain), ParticleSettings *part)
+static void lib_link_particlesettings(BlendLibReader *reader, ParticleSettings *part)
{
- part->ipo = newlibadr(fd, part->id.lib, part->ipo); // XXX deprecated - old animation system
+ BLO_read_id_address(reader, part->id.lib, &part->ipo); // XXX deprecated - old animation system
- part->instance_object = newlibadr(fd, part->id.lib, part->instance_object);
- part->instance_collection = newlibadr(fd, part->id.lib, part->instance_collection);
- part->force_group = newlibadr(fd, part->id.lib, part->force_group);
- part->bb_ob = newlibadr(fd, part->id.lib, part->bb_ob);
- part->collision_group = newlibadr(fd, part->id.lib, part->collision_group);
+ BLO_read_id_address(reader, part->id.lib, &part->instance_object);
+ BLO_read_id_address(reader, part->id.lib, &part->instance_collection);
+ BLO_read_id_address(reader, part->id.lib, &part->force_group);
+ BLO_read_id_address(reader, part->id.lib, &part->bb_ob);
+ BLO_read_id_address(reader, part->id.lib, &part->collision_group);
- lib_link_partdeflect(fd, &part->id, part->pd);
- lib_link_partdeflect(fd, &part->id, part->pd2);
+ lib_link_partdeflect(reader, &part->id, part->pd);
+ lib_link_partdeflect(reader, &part->id, part->pd2);
if (part->effector_weights) {
- part->effector_weights->group = newlibadr(fd, part->id.lib, part->effector_weights->group);
+ BLO_read_id_address(reader, part->id.lib, &part->effector_weights->group);
}
else {
part->effector_weights = BKE_effector_add_weights(part->force_group);
@@ -4661,7 +4629,7 @@ static void lib_link_particlesettings(FileData *fd, Main *UNUSED(bmain), Particl
if (part->instance_weights.first && part->instance_collection) {
LISTBASE_FOREACH (ParticleDupliWeight *, dw, &part->instance_weights) {
- dw->ob = newlibadr(fd, part->id.lib, dw->ob);
+ BLO_read_id_address(reader, part->id.lib, &dw->ob);
}
}
else {
@@ -4678,12 +4646,12 @@ static void lib_link_particlesettings(FileData *fd, Main *UNUSED(bmain), Particl
case eBoidRuleType_Goal:
case eBoidRuleType_Avoid: {
BoidRuleGoalAvoid *brga = (BoidRuleGoalAvoid *)rule;
- brga->ob = newlibadr(fd, part->id.lib, brga->ob);
+ BLO_read_id_address(reader, part->id.lib, &brga->ob);
break;
}
case eBoidRuleType_FollowLeader: {
BoidRuleFollowLeader *brfl = (BoidRuleFollowLeader *)rule;
- brfl->ob = newlibadr(fd, part->id.lib, brfl->ob);
+ BLO_read_id_address(reader, part->id.lib, &brfl->ob);
break;
}
}
@@ -4694,8 +4662,8 @@ static void lib_link_particlesettings(FileData *fd, Main *UNUSED(bmain), Particl
for (int a = 0; a < MAX_MTEX; a++) {
MTex *mtex = part->mtex[a];
if (mtex) {
- mtex->tex = newlibadr(fd, part->id.lib, mtex->tex);
- mtex->object = newlibadr(fd, part->id.lib, mtex->object);
+ BLO_read_id_address(reader, part->id.lib, &mtex->tex);
+ BLO_read_id_address(reader, part->id.lib, &mtex->object);
}
}
}
@@ -4721,15 +4689,15 @@ static void direct_link_particlesettings(BlendDataReader *reader, ParticleSettin
BLO_read_data_address(reader, &part->clumpcurve);
if (part->clumpcurve) {
- direct_link_curvemapping(reader, part->clumpcurve);
+ BKE_curvemapping_blend_read(reader, part->clumpcurve);
}
BLO_read_data_address(reader, &part->roughcurve);
if (part->roughcurve) {
- direct_link_curvemapping(reader, part->roughcurve);
+ BKE_curvemapping_blend_read(reader, part->roughcurve);
}
BLO_read_data_address(reader, &part->twistcurve);
if (part->twistcurve) {
- direct_link_curvemapping(reader, part->twistcurve);
+ BKE_curvemapping_blend_read(reader, part->twistcurve);
}
BLO_read_data_address(reader, &part->effector_weights);
@@ -4760,30 +4728,33 @@ static void direct_link_particlesettings(BlendDataReader *reader, ParticleSettin
CLAMP(part->trail_count, 1, 100000);
}
-static void lib_link_particlesystems(FileData *fd, Object *ob, ID *id, ListBase *particles)
+static void lib_link_particlesystems(BlendLibReader *reader,
+ Object *ob,
+ ID *id,
+ ListBase *particles)
{
ParticleSystem *psys, *psysnext;
for (psys = particles->first; psys; psys = psysnext) {
psysnext = psys->next;
- psys->part = newlibadr(fd, id->lib, psys->part);
+ BLO_read_id_address(reader, id->lib, &psys->part);
if (psys->part) {
ParticleTarget *pt = psys->targets.first;
for (; pt; pt = pt->next) {
- pt->ob = newlibadr(fd, id->lib, pt->ob);
+ BLO_read_id_address(reader, id->lib, &pt->ob);
}
- psys->parent = newlibadr(fd, id->lib, psys->parent);
- psys->target_ob = newlibadr(fd, id->lib, psys->target_ob);
+ BLO_read_id_address(reader, id->lib, &psys->parent);
+ BLO_read_id_address(reader, id->lib, &psys->target_ob);
if (psys->clmd) {
/* XXX - from reading existing code this seems correct but intended usage of
* pointcache /w cloth should be added in 'ParticleSystem' - campbell */
psys->clmd->point_cache = psys->pointcache;
psys->clmd->ptcaches.first = psys->clmd->ptcaches.last = NULL;
- psys->clmd->coll_parms->group = newlibadr(fd, id->lib, psys->clmd->coll_parms->group);
+ BLO_read_id_address(reader, id->lib, &psys->clmd->coll_parms->group);
psys->clmd->modifier.error = NULL;
}
}
@@ -4894,21 +4865,21 @@ static void direct_link_particlesystems(BlendDataReader *reader, ListBase *parti
/** \name Read ID: Mesh
* \{ */
-static void lib_link_mesh(FileData *fd, Main *UNUSED(bmain), Mesh *me)
+static void lib_link_mesh(BlendLibReader *reader, Mesh *me)
{
/* this check added for python created meshes */
if (me->mat) {
for (int i = 0; i < me->totcol; i++) {
- me->mat[i] = newlibadr(fd, me->id.lib, me->mat[i]);
+ BLO_read_id_address(reader, me->id.lib, &me->mat[i]);
}
}
else {
me->totcol = 0;
}
- me->ipo = newlibadr(fd, me->id.lib, me->ipo); // XXX: deprecated: old anim sys
- me->key = newlibadr(fd, me->id.lib, me->key);
- me->texcomesh = newlibadr(fd, me->id.lib, me->texcomesh);
+ BLO_read_id_address(reader, me->id.lib, &me->ipo); // XXX: deprecated: old anim sys
+ BLO_read_id_address(reader, me->id.lib, &me->key);
+ BLO_read_id_address(reader, me->id.lib, &me->texcomesh);
}
static void direct_link_dverts(BlendDataReader *reader, int count, MDeformVert *mdverts)
@@ -5123,10 +5094,10 @@ static void direct_link_mesh(BlendDataReader *reader, Mesh *mesh)
/** \name Read ID: Lattice
* \{ */
-static void lib_link_latt(FileData *fd, Main *UNUSED(bmain), Lattice *lt)
+static void lib_link_latt(BlendLibReader *reader, Lattice *lt)
{
- lt->ipo = newlibadr(fd, lt->id.lib, lt->ipo); // XXX deprecated - old animation system
- lt->key = newlibadr(fd, lt->id.lib, lt->key);
+ BLO_read_id_address(reader, lt->id.lib, &lt->ipo); // XXX deprecated - old animation system
+ BLO_read_id_address(reader, lt->id.lib, &lt->key);
}
static void direct_link_latt(BlendDataReader *reader, Lattice *lt)
@@ -5151,17 +5122,17 @@ static void direct_link_latt(BlendDataReader *reader, Lattice *lt)
static void lib_link_modifiers_common(void *userData, Object *ob, ID **idpoin, int cb_flag)
{
- FileData *fd = userData;
+ BlendLibReader *reader = userData;
- *idpoin = newlibadr(fd, ob->id.lib, *idpoin);
+ BLO_read_id_address(reader, ob->id.lib, idpoin);
if (*idpoin != NULL && (cb_flag & IDWALK_CB_USER) != 0) {
id_us_plus_no_lib(*idpoin);
}
}
-static void lib_link_modifiers(FileData *fd, Object *ob)
+static void lib_link_modifiers(BlendLibReader *reader, Object *ob)
{
- BKE_modifiers_foreach_ID_link(ob, lib_link_modifiers_common, fd);
+ BKE_modifiers_foreach_ID_link(ob, lib_link_modifiers_common, reader);
/* If linking from a library, clear 'local' library override flag. */
if (ob->id.lib != NULL) {
@@ -5171,9 +5142,9 @@ static void lib_link_modifiers(FileData *fd, Object *ob)
}
}
-static void lib_link_gpencil_modifiers(FileData *fd, Object *ob)
+static void lib_link_gpencil_modifiers(BlendLibReader *reader, Object *ob)
{
- BKE_gpencil_modifiers_foreach_ID_link(ob, lib_link_modifiers_common, fd);
+ BKE_gpencil_modifiers_foreach_ID_link(ob, lib_link_modifiers_common, reader);
/* If linking from a library, clear 'local' library override flag. */
if (ob->id.lib != NULL) {
@@ -5184,9 +5155,9 @@ static void lib_link_gpencil_modifiers(FileData *fd, Object *ob)
}
}
-static void lib_link_shaderfxs(FileData *fd, Object *ob)
+static void lib_link_shaderfxs(BlendLibReader *reader, Object *ob)
{
- BKE_shaderfx_foreach_ID_link(ob, lib_link_modifiers_common, fd);
+ BKE_shaderfx_foreach_ID_link(ob, lib_link_modifiers_common, reader);
/* If linking from a library, clear 'local' library override flag. */
if (ob->id.lib != NULL) {
@@ -5196,28 +5167,28 @@ static void lib_link_shaderfxs(FileData *fd, Object *ob)
}
}
-static void lib_link_object(FileData *fd, Main *bmain, Object *ob)
+static void lib_link_object(BlendLibReader *reader, Object *ob)
{
bool warn = false;
int a;
// XXX deprecated - old animation system <<<
- ob->ipo = newlibadr(fd, ob->id.lib, ob->ipo);
- ob->action = newlibadr(fd, ob->id.lib, ob->action);
+ BLO_read_id_address(reader, ob->id.lib, &ob->ipo);
+ BLO_read_id_address(reader, ob->id.lib, &ob->action);
// >>> XXX deprecated - old animation system
- ob->parent = newlibadr(fd, ob->id.lib, ob->parent);
- ob->track = newlibadr(fd, ob->id.lib, ob->track);
- ob->poselib = newlibadr(fd, ob->id.lib, ob->poselib);
+ BLO_read_id_address(reader, ob->id.lib, &ob->parent);
+ BLO_read_id_address(reader, ob->id.lib, &ob->track);
+ BLO_read_id_address(reader, ob->id.lib, &ob->poselib);
/* 2.8x drops support for non-empty dupli instances. */
if (ob->type == OB_EMPTY) {
- ob->instance_collection = newlibadr(fd, ob->id.lib, ob->instance_collection);
+ BLO_read_id_address(reader, ob->id.lib, &ob->instance_collection);
}
else {
if (ob->instance_collection != NULL) {
- ID *id = newlibadr(fd, ob->id.lib, ob->instance_collection);
- blo_reportf_wrap(fd->reports,
+ ID *id = BLO_read_get_new_id_address(reader, ob->id.lib, &ob->instance_collection->id);
+ blo_reportf_wrap(reader->fd->reports,
RPT_WARNING,
TIP_("Non-Empty object '%s' cannot duplicate collection '%s' "
"anymore in Blender 2.80, removed instancing"),
@@ -5228,7 +5199,7 @@ static void lib_link_object(FileData *fd, Main *bmain, Object *ob)
ob->transflag &= ~OB_DUPLICOLLECTION;
}
- ob->proxy = newlibadr(fd, ob->id.lib, ob->proxy);
+ BLO_read_id_address(reader, ob->id.lib, &ob->proxy);
if (ob->proxy) {
/* paranoia check, actually a proxy_from pointer should never be written... */
if (ob->proxy->id.lib == NULL) {
@@ -5236,7 +5207,7 @@ static void lib_link_object(FileData *fd, Main *bmain, Object *ob)
ob->proxy = NULL;
if (ob->id.lib) {
- printf("Proxy lost from object %s lib %s\n", ob->id.name + 2, ob->id.lib->name);
+ printf("Proxy lost from object %s lib %s\n", ob->id.name + 2, ob->id.lib->filepath);
}
else {
printf("Proxy lost from object %s lib <NONE>\n", ob->id.name + 2);
@@ -5247,14 +5218,14 @@ static void lib_link_object(FileData *fd, Main *bmain, Object *ob)
ob->proxy->proxy_from = ob;
}
}
- ob->proxy_group = newlibadr(fd, ob->id.lib, ob->proxy_group);
+ BLO_read_id_address(reader, ob->id.lib, &ob->proxy_group);
void *poin = ob->data;
- ob->data = newlibadr(fd, ob->id.lib, ob->data);
+ BLO_read_id_address(reader, ob->id.lib, &ob->data);
if (ob->data == NULL && poin != NULL) {
if (ob->id.lib) {
- printf("Can't find obdata of %s lib %s\n", ob->id.name + 2, ob->id.lib->name);
+ printf("Can't find obdata of %s lib %s\n", ob->id.name + 2, ob->id.lib->filepath);
}
else {
printf("Object %s lost data.\n", ob->id.name + 2);
@@ -5279,7 +5250,7 @@ static void lib_link_object(FileData *fd, Main *bmain, Object *ob)
}
}
for (a = 0; a < ob->totcol; a++) {
- ob->mat[a] = newlibadr(fd, ob->id.lib, ob->mat[a]);
+ BLO_read_id_address(reader, ob->id.lib, &ob->mat[a]);
}
/* When the object is local and the data is library its possible
@@ -5289,26 +5260,26 @@ static void lib_link_object(FileData *fd, Main *bmain, Object *ob)
/* Only expand so as not to loose any object materials that might be set. */
if (totcol_data && (*totcol_data > ob->totcol)) {
/* printf("'%s' %d -> %d\n", ob->id.name, ob->totcol, *totcol_data); */
- BKE_object_material_resize(bmain, ob, *totcol_data, false);
+ BKE_object_material_resize(reader->main, ob, *totcol_data, false);
}
}
- ob->gpd = newlibadr(fd, ob->id.lib, ob->gpd);
+ BLO_read_id_address(reader, ob->id.lib, &ob->gpd);
/* if id.us==0 a new base will be created later on */
/* WARNING! Also check expand_object(), should reflect the stuff below. */
- lib_link_pose(fd, bmain, ob, ob->pose);
- lib_link_constraints(fd, &ob->id, &ob->constraints);
+ lib_link_pose(reader, ob, ob->pose);
+ lib_link_constraints(reader, &ob->id, &ob->constraints);
// XXX deprecated - old animation system <<<
- lib_link_constraint_channels(fd, &ob->id, &ob->constraintChannels);
- lib_link_nlastrips(fd, &ob->id, &ob->nlastrips);
+ 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) {
- paf->group = newlibadr(fd, ob->id.lib, paf->group);
+ BLO_read_id_address(reader, ob->id.lib, &paf->group);
}
}
@@ -5317,8 +5288,8 @@ static void lib_link_object(FileData *fd, Main *bmain, Object *ob)
ob, eModifierType_Fluidsim);
if (fluidmd && fluidmd->fss) {
- fluidmd->fss->ipo = newlibadr(
- fd, ob->id.lib, fluidmd->fss->ipo); // XXX deprecated - old animation system
+ BLO_read_id_address(
+ reader, ob->id.lib, &fluidmd->fss->ipo); // XXX deprecated - old animation system
}
}
@@ -5340,30 +5311,29 @@ static void lib_link_object(FileData *fd, Main *bmain, Object *ob)
/* texture field */
if (ob->pd) {
- lib_link_partdeflect(fd, &ob->id, ob->pd);
+ lib_link_partdeflect(reader, &ob->id, ob->pd);
}
if (ob->soft) {
- ob->soft->collision_group = newlibadr(fd, ob->id.lib, ob->soft->collision_group);
+ BLO_read_id_address(reader, ob->id.lib, &ob->soft->collision_group);
- ob->soft->effector_weights->group = newlibadr(
- fd, ob->id.lib, ob->soft->effector_weights->group);
+ BLO_read_id_address(reader, ob->id.lib, &ob->soft->effector_weights->group);
}
- lib_link_particlesystems(fd, ob, &ob->id, &ob->particlesystem);
- lib_link_modifiers(fd, ob);
- lib_link_gpencil_modifiers(fd, ob);
- lib_link_shaderfxs(fd, ob);
+ lib_link_particlesystems(reader, ob, &ob->id, &ob->particlesystem);
+ lib_link_modifiers(reader, ob);
+ lib_link_gpencil_modifiers(reader, ob);
+ lib_link_shaderfxs(reader, ob);
if (ob->rigidbody_constraint) {
- ob->rigidbody_constraint->ob1 = newlibadr(fd, ob->id.lib, ob->rigidbody_constraint->ob1);
- ob->rigidbody_constraint->ob2 = newlibadr(fd, ob->id.lib, ob->rigidbody_constraint->ob2);
+ BLO_read_id_address(reader, ob->id.lib, &ob->rigidbody_constraint->ob1);
+ BLO_read_id_address(reader, ob->id.lib, &ob->rigidbody_constraint->ob2);
}
{
LodLevel *level;
for (level = ob->lodlevels.first; level; level = level->next) {
- level->source = newlibadr(fd, ob->id.lib, level->source);
+ BLO_read_id_address(reader, ob->id.lib, &level->source);
if (!level->source && level == ob->lodlevels.first) {
level->source = ob;
@@ -5372,7 +5342,7 @@ static void lib_link_object(FileData *fd, Main *bmain, Object *ob)
}
if (warn) {
- BKE_report(fd->reports, RPT_WARNING, "Warning in console");
+ BKE_report(reader->fd->reports, RPT_WARNING, "Warning in console");
}
}
@@ -5599,16 +5569,6 @@ static void direct_link_modifiers(BlendDataReader *reader, ListBase *lb, Object
if (is_allocated) {
/* All the fields has been properly allocated. */
}
- else if (md->type == eModifierType_Subsurf) {
- SubsurfModifierData *smd = (SubsurfModifierData *)md;
-
- smd->emCache = smd->mCache = NULL;
- }
- else if (md->type == eModifierType_Armature) {
- ArmatureModifierData *amd = (ArmatureModifierData *)md;
-
- amd->vert_coords_prev = NULL;
- }
else if (md->type == eModifierType_Cloth) {
ClothModifierData *clmd = (ClothModifierData *)md;
@@ -5748,148 +5708,6 @@ static void direct_link_modifiers(BlendDataReader *reader, ListBase *lb, Object
BLO_read_data_address(reader, &pmd->brush->vel_ramp);
}
}
- else if (md->type == eModifierType_Collision) {
- CollisionModifierData *collmd = (CollisionModifierData *)md;
-#if 0
- // TODO: CollisionModifier should use pointcache
- // + have proper reset events before enabling this
- collmd->x = newdataadr(fd, collmd->x);
- collmd->xnew = newdataadr(fd, collmd->xnew);
- collmd->mfaces = newdataadr(fd, collmd->mfaces);
-
- collmd->current_x = MEM_calloc_arrayN(collmd->numverts, sizeof(MVert), "current_x");
- collmd->current_xnew = MEM_calloc_arrayN(collmd->numverts, sizeof(MVert), "current_xnew");
- collmd->current_v = MEM_calloc_arrayN(collmd->numverts, sizeof(MVert), "current_v");
-#endif
-
- collmd->x = NULL;
- collmd->xnew = NULL;
- collmd->current_x = NULL;
- collmd->current_xnew = NULL;
- collmd->current_v = NULL;
- collmd->time_x = collmd->time_xnew = -1000;
- collmd->mvert_num = 0;
- collmd->tri_num = 0;
- collmd->is_static = false;
- collmd->bvhtree = NULL;
- collmd->tri = NULL;
- }
- else if (md->type == eModifierType_Surface) {
- SurfaceModifierData *surmd = (SurfaceModifierData *)md;
-
- surmd->mesh = NULL;
- surmd->bvhtree = NULL;
- surmd->x = NULL;
- surmd->v = NULL;
- surmd->numverts = 0;
- }
- else if (md->type == eModifierType_Hook) {
- HookModifierData *hmd = (HookModifierData *)md;
- BLO_read_int32_array(reader, hmd->totindex, &hmd->indexar);
-
- BLO_read_data_address(reader, &hmd->curfalloff);
- if (hmd->curfalloff) {
- direct_link_curvemapping(reader, hmd->curfalloff);
- }
- }
- else if (md->type == eModifierType_ParticleSystem) {
- ParticleSystemModifierData *psmd = (ParticleSystemModifierData *)md;
-
- psmd->mesh_final = NULL;
- psmd->mesh_original = NULL;
- BLO_read_data_address(reader, &psmd->psys);
- psmd->flag &= ~eParticleSystemFlag_psys_updated;
- psmd->flag |= eParticleSystemFlag_file_loaded;
- }
- else if (md->type == eModifierType_Explode) {
- ExplodeModifierData *psmd = (ExplodeModifierData *)md;
-
- psmd->facepa = NULL;
- }
- else if (md->type == eModifierType_MeshDeform) {
- MeshDeformModifierData *mmd = (MeshDeformModifierData *)md;
-
- BLO_read_data_address(reader, &mmd->bindinfluences);
- BLO_read_int32_array(reader, mmd->totvert + 1, &mmd->bindoffsets);
- BLO_read_float3_array(reader, mmd->totcagevert, &mmd->bindcagecos);
- BLO_read_data_address(reader, &mmd->dyngrid);
- BLO_read_data_address(reader, &mmd->dyninfluences);
- BLO_read_int32_array(reader, mmd->totvert, &mmd->dynverts);
-
- BLO_read_float_array(reader, mmd->totvert, &mmd->bindweights);
- BLO_read_float3_array(reader, mmd->totcagevert, &mmd->bindcos);
- }
- else if (md->type == eModifierType_Ocean) {
- OceanModifierData *omd = (OceanModifierData *)md;
- omd->oceancache = NULL;
- omd->ocean = NULL;
- }
- else if (md->type == eModifierType_Warp) {
- WarpModifierData *tmd = (WarpModifierData *)md;
-
- BLO_read_data_address(reader, &tmd->curfalloff);
- if (tmd->curfalloff) {
- direct_link_curvemapping(reader, tmd->curfalloff);
- }
- }
- else if (md->type == eModifierType_WeightVGEdit) {
- WeightVGEditModifierData *wmd = (WeightVGEditModifierData *)md;
-
- BLO_read_data_address(reader, &wmd->cmap_curve);
- if (wmd->cmap_curve) {
- direct_link_curvemapping(reader, wmd->cmap_curve);
- }
- }
- else if (md->type == eModifierType_CorrectiveSmooth) {
- CorrectiveSmoothModifierData *csmd = (CorrectiveSmoothModifierData *)md;
-
- if (csmd->bind_coords) {
- BLO_read_float3_array(reader, csmd->bind_coords_num, (float **)&csmd->bind_coords);
- }
-
- /* runtime only */
- csmd->delta_cache.deltas = NULL;
- csmd->delta_cache.totverts = 0;
- }
- else if (md->type == eModifierType_MeshSequenceCache) {
- MeshSeqCacheModifierData *msmcd = (MeshSeqCacheModifierData *)md;
- msmcd->reader = NULL;
- msmcd->reader_object_path[0] = '\0';
- }
- else if (md->type == eModifierType_SurfaceDeform) {
- SurfaceDeformModifierData *smd = (SurfaceDeformModifierData *)md;
-
- BLO_read_data_address(reader, &smd->verts);
-
- if (smd->verts) {
- for (int i = 0; i < smd->numverts; i++) {
- BLO_read_data_address(reader, &smd->verts[i].binds);
-
- if (smd->verts[i].binds) {
- for (int j = 0; j < smd->verts[i].numbinds; j++) {
- BLO_read_uint32_array(
- reader, smd->verts[i].binds[j].numverts, &smd->verts[i].binds[j].vert_inds);
-
- if (smd->verts[i].binds[j].mode == MOD_SDEF_MODE_CENTROID ||
- smd->verts[i].binds[j].mode == MOD_SDEF_MODE_LOOPTRI) {
- BLO_read_float3_array(reader, 1, &smd->verts[i].binds[j].vert_weights);
- }
- else {
- BLO_read_float_array(
- reader, smd->verts[i].binds[j].numverts, &smd->verts[i].binds[j].vert_weights);
- }
- }
- }
- }
- }
- }
- else if (md->type == eModifierType_Bevel) {
- BevelModifierData *bmd = (BevelModifierData *)md;
- BLO_read_data_address(reader, &bmd->custom_profile);
- if (bmd->custom_profile) {
- direct_link_curveprofile(reader, bmd->custom_profile);
- }
- }
if (mti->blendRead != NULL) {
mti->blendRead(reader, md);
@@ -5920,7 +5738,7 @@ static void direct_link_gpencil_modifiers(BlendDataReader *reader, ListBase *lb)
BLO_read_data_address(reader, &hmd->curfalloff);
if (hmd->curfalloff) {
- direct_link_curvemapping(reader, hmd->curfalloff);
+ BKE_curvemapping_blend_read(reader, hmd->curfalloff);
}
}
else if (md->type == eGpencilModifierType_Noise) {
@@ -5928,7 +5746,7 @@ static void direct_link_gpencil_modifiers(BlendDataReader *reader, ListBase *lb)
BLO_read_data_address(reader, &gpmd->curve_intensity);
if (gpmd->curve_intensity) {
- direct_link_curvemapping(reader, gpmd->curve_intensity);
+ BKE_curvemapping_blend_read(reader, gpmd->curve_intensity);
/* initialize the curve. Maybe this could be moved to modififer logic */
BKE_curvemapping_initialize(gpmd->curve_intensity);
}
@@ -5938,7 +5756,7 @@ static void direct_link_gpencil_modifiers(BlendDataReader *reader, ListBase *lb)
BLO_read_data_address(reader, &gpmd->curve_thickness);
if (gpmd->curve_thickness) {
- direct_link_curvemapping(reader, gpmd->curve_thickness);
+ BKE_curvemapping_blend_read(reader, gpmd->curve_thickness);
BKE_curvemapping_initialize(gpmd->curve_thickness);
}
}
@@ -5947,7 +5765,7 @@ static void direct_link_gpencil_modifiers(BlendDataReader *reader, ListBase *lb)
BLO_read_data_address(reader, &gpmd->colorband);
BLO_read_data_address(reader, &gpmd->curve_intensity);
if (gpmd->curve_intensity) {
- direct_link_curvemapping(reader, gpmd->curve_intensity);
+ BKE_curvemapping_blend_read(reader, gpmd->curve_intensity);
BKE_curvemapping_initialize(gpmd->curve_intensity);
}
}
@@ -5955,7 +5773,7 @@ static void direct_link_gpencil_modifiers(BlendDataReader *reader, ListBase *lb)
SmoothGpencilModifierData *gpmd = (SmoothGpencilModifierData *)md;
BLO_read_data_address(reader, &gpmd->curve_intensity);
if (gpmd->curve_intensity) {
- direct_link_curvemapping(reader, gpmd->curve_intensity);
+ BKE_curvemapping_blend_read(reader, gpmd->curve_intensity);
BKE_curvemapping_initialize(gpmd->curve_intensity);
}
}
@@ -5963,7 +5781,7 @@ static void direct_link_gpencil_modifiers(BlendDataReader *reader, ListBase *lb)
ColorGpencilModifierData *gpmd = (ColorGpencilModifierData *)md;
BLO_read_data_address(reader, &gpmd->curve_intensity);
if (gpmd->curve_intensity) {
- direct_link_curvemapping(reader, gpmd->curve_intensity);
+ BKE_curvemapping_blend_read(reader, gpmd->curve_intensity);
BKE_curvemapping_initialize(gpmd->curve_intensity);
}
}
@@ -5971,7 +5789,7 @@ static void direct_link_gpencil_modifiers(BlendDataReader *reader, ListBase *lb)
OpacityGpencilModifierData *gpmd = (OpacityGpencilModifierData *)md;
BLO_read_data_address(reader, &gpmd->curve_intensity);
if (gpmd->curve_intensity) {
- direct_link_curvemapping(reader, gpmd->curve_intensity);
+ BKE_curvemapping_blend_read(reader, gpmd->curve_intensity);
BKE_curvemapping_initialize(gpmd->curve_intensity);
}
}
@@ -6205,7 +6023,7 @@ static void direct_link_view_settings(BlendDataReader *reader,
BLO_read_data_address(reader, &view_settings->curve_mapping);
if (view_settings->curve_mapping) {
- direct_link_curvemapping(reader, view_settings->curve_mapping);
+ BKE_curvemapping_blend_read(reader, view_settings->curve_mapping);
}
}
@@ -6252,39 +6070,39 @@ static void direct_link_view_layer(BlendDataReader *reader, ViewLayer *view_laye
view_layer->object_bases_hash = NULL;
}
-static void lib_link_layer_collection(FileData *fd,
+static void lib_link_layer_collection(BlendLibReader *reader,
Library *lib,
LayerCollection *layer_collection,
bool master)
{
/* Master collection is not a real data-lock. */
if (!master) {
- layer_collection->collection = newlibadr(fd, lib, layer_collection->collection);
+ BLO_read_id_address(reader, lib, &layer_collection->collection);
}
for (LayerCollection *layer_collection_nested = layer_collection->layer_collections.first;
layer_collection_nested != NULL;
layer_collection_nested = layer_collection_nested->next) {
- lib_link_layer_collection(fd, lib, layer_collection_nested, false);
+ lib_link_layer_collection(reader, lib, layer_collection_nested, false);
}
}
-static void lib_link_view_layer(FileData *fd, Library *lib, ViewLayer *view_layer)
+static void lib_link_view_layer(BlendLibReader *reader, Library *lib, ViewLayer *view_layer)
{
LISTBASE_FOREACH (FreestyleModuleConfig *, fmc, &view_layer->freestyle_config.modules) {
- fmc->script = newlibadr(fd, lib, fmc->script);
+ BLO_read_id_address(reader, lib, &fmc->script);
}
LISTBASE_FOREACH (FreestyleLineSet *, fls, &view_layer->freestyle_config.linesets) {
- fls->linestyle = newlibadr(fd, lib, fls->linestyle);
- fls->group = newlibadr(fd, lib, fls->group);
+ BLO_read_id_address(reader, lib, &fls->linestyle);
+ BLO_read_id_address(reader, lib, &fls->group);
}
for (Base *base = view_layer->object_bases.first, *base_next = NULL; base; base = base_next) {
base_next = base->next;
/* we only bump the use count for the collection objects */
- base->object = newlibadr(fd, lib, base->object);
+ BLO_read_id_address(reader, lib, &base->object);
if (base->object == NULL) {
/* Free in case linked object got lost. */
@@ -6298,12 +6116,12 @@ static void lib_link_view_layer(FileData *fd, Library *lib, ViewLayer *view_laye
for (LayerCollection *layer_collection = view_layer->layer_collections.first;
layer_collection != NULL;
layer_collection = layer_collection->next) {
- lib_link_layer_collection(fd, lib, layer_collection, true);
+ lib_link_layer_collection(reader, lib, layer_collection, true);
}
- view_layer->mat_override = newlibadr(fd, lib, view_layer->mat_override);
+ BLO_read_id_address(reader, lib, &view_layer->mat_override);
- IDP_LibLinkProperty(view_layer->id_properties, fd);
+ IDP_LibLinkProperty(view_layer->id_properties, reader);
}
/** \} */
@@ -6323,15 +6141,15 @@ static void direct_link_scene_collection(BlendDataReader *reader, SceneCollectio
}
}
-static void lib_link_scene_collection(FileData *fd, Library *lib, SceneCollection *sc)
+static void lib_link_scene_collection(BlendLibReader *reader, Library *lib, SceneCollection *sc)
{
LISTBASE_FOREACH (LinkData *, link, &sc->objects) {
- link->data = newlibadr(fd, lib, link->data);
+ BLO_read_id_address(reader, lib, &link->data);
BLI_assert(link->data);
}
LISTBASE_FOREACH (SceneCollection *, nsc, &sc->scene_collections) {
- lib_link_scene_collection(fd, lib, nsc);
+ lib_link_scene_collection(reader, lib, nsc);
}
}
#endif
@@ -6362,11 +6180,11 @@ static void direct_link_collection(BlendDataReader *reader, Collection *collecti
#endif
}
-static void lib_link_collection_data(FileData *fd, Library *lib, Collection *collection)
+static void lib_link_collection_data(BlendLibReader *reader, Library *lib, Collection *collection)
{
for (CollectionObject *cob = collection->gobject.first, *cob_next = NULL; cob; cob = cob_next) {
cob_next = cob->next;
- cob->ob = newlibadr(fd, lib, cob->ob);
+ BLO_read_id_address(reader, lib, &cob->ob);
if (cob->ob == NULL) {
BLI_freelinkN(&collection->gobject, cob);
@@ -6374,23 +6192,23 @@ static void lib_link_collection_data(FileData *fd, Library *lib, Collection *col
}
for (CollectionChild *child = collection->children.first; child != NULL; child = child->next) {
- child->collection = newlibadr(fd, lib, child->collection);
+ BLO_read_id_address(reader, lib, &child->collection);
}
}
-static void lib_link_collection(FileData *fd, Main *UNUSED(bmain), Collection *collection)
+static void lib_link_collection(BlendLibReader *reader, Collection *collection)
{
#ifdef USE_COLLECTION_COMPAT_28
if (collection->collection) {
- lib_link_scene_collection(fd, collection->id.lib, collection->collection);
+ lib_link_scene_collection(reader, collection->id.lib, collection->collection);
}
if (collection->view_layer) {
- lib_link_view_layer(fd, collection->id.lib, collection->view_layer);
+ lib_link_view_layer(reader, collection->id.lib, collection->view_layer);
}
#endif
- lib_link_collection_data(fd, collection->id.lib, collection);
+ lib_link_collection_data(reader, collection->id.lib, collection);
}
/** \} */
@@ -6411,29 +6229,29 @@ static void composite_patch(bNodeTree *ntree, Scene *scene)
}
}
-static void link_paint(FileData *fd, Scene *sce, Paint *p)
+static void link_paint(BlendLibReader *reader, Scene *sce, Paint *p)
{
if (p) {
- p->brush = newlibadr(fd, sce->id.lib, p->brush);
+ BLO_read_id_address(reader, sce->id.lib, &p->brush);
for (int i = 0; i < p->tool_slots_len; i++) {
if (p->tool_slots[i].brush != NULL) {
- p->tool_slots[i].brush = newlibadr(fd, sce->id.lib, p->tool_slots[i].brush);
+ BLO_read_id_address(reader, sce->id.lib, &p->tool_slots[i].brush);
}
}
- p->palette = newlibadr(fd, sce->id.lib, p->palette);
+ BLO_read_id_address(reader, sce->id.lib, &p->palette);
p->paint_cursor = NULL;
BKE_paint_runtime_init(sce->toolsettings, p);
}
}
-static void lib_link_sequence_modifiers(FileData *fd, Scene *scene, ListBase *lb)
+static void lib_link_sequence_modifiers(BlendLibReader *reader, Scene *scene, ListBase *lb)
{
SequenceModifierData *smd;
for (smd = lb->first; smd; smd = smd->next) {
if (smd->mask_id) {
- smd->mask_id = newlibadr(fd, scene->id.lib, smd->mask_id);
+ BLO_read_id_address(reader, scene->id.lib, &smd->mask_id);
}
}
}
@@ -6514,76 +6332,72 @@ static bool scene_validate_setscene__liblink(Scene *sce, const int totscene)
}
#endif
-static void lib_link_scene(FileData *fd, Main *UNUSED(bmain), Scene *sce)
+static void lib_link_scene(BlendLibReader *reader, Scene *sce)
{
- lib_link_keyingsets(fd, &sce->id, &sce->keyingsets);
+ lib_link_keyingsets(reader, &sce->id, &sce->keyingsets);
- sce->camera = newlibadr(fd, sce->id.lib, sce->camera);
- sce->world = newlibadr(fd, sce->id.lib, sce->world);
- sce->set = newlibadr(fd, sce->id.lib, sce->set);
- sce->gpd = newlibadr(fd, sce->id.lib, sce->gpd);
+ BLO_read_id_address(reader, sce->id.lib, &sce->camera);
+ BLO_read_id_address(reader, sce->id.lib, &sce->world);
+ BLO_read_id_address(reader, sce->id.lib, &sce->set);
+ BLO_read_id_address(reader, sce->id.lib, &sce->gpd);
- link_paint(fd, sce, &sce->toolsettings->imapaint.paint);
+ link_paint(reader, sce, &sce->toolsettings->imapaint.paint);
if (sce->toolsettings->sculpt) {
- link_paint(fd, sce, &sce->toolsettings->sculpt->paint);
+ link_paint(reader, sce, &sce->toolsettings->sculpt->paint);
}
if (sce->toolsettings->vpaint) {
- link_paint(fd, sce, &sce->toolsettings->vpaint->paint);
+ link_paint(reader, sce, &sce->toolsettings->vpaint->paint);
}
if (sce->toolsettings->wpaint) {
- link_paint(fd, sce, &sce->toolsettings->wpaint->paint);
+ link_paint(reader, sce, &sce->toolsettings->wpaint->paint);
}
if (sce->toolsettings->uvsculpt) {
- link_paint(fd, sce, &sce->toolsettings->uvsculpt->paint);
+ link_paint(reader, sce, &sce->toolsettings->uvsculpt->paint);
}
if (sce->toolsettings->gp_paint) {
- link_paint(fd, sce, &sce->toolsettings->gp_paint->paint);
+ link_paint(reader, sce, &sce->toolsettings->gp_paint->paint);
}
if (sce->toolsettings->gp_vertexpaint) {
- link_paint(fd, sce, &sce->toolsettings->gp_vertexpaint->paint);
+ link_paint(reader, sce, &sce->toolsettings->gp_vertexpaint->paint);
}
if (sce->toolsettings->gp_sculptpaint) {
- link_paint(fd, sce, &sce->toolsettings->gp_sculptpaint->paint);
+ link_paint(reader, sce, &sce->toolsettings->gp_sculptpaint->paint);
}
if (sce->toolsettings->gp_weightpaint) {
- link_paint(fd, sce, &sce->toolsettings->gp_weightpaint->paint);
+ link_paint(reader, sce, &sce->toolsettings->gp_weightpaint->paint);
}
if (sce->toolsettings->sculpt) {
- sce->toolsettings->sculpt->gravity_object = newlibadr(
- fd, sce->id.lib, sce->toolsettings->sculpt->gravity_object);
+ BLO_read_id_address(reader, sce->id.lib, &sce->toolsettings->sculpt->gravity_object);
}
if (sce->toolsettings->imapaint.stencil) {
- sce->toolsettings->imapaint.stencil = newlibadr(
- fd, sce->id.lib, sce->toolsettings->imapaint.stencil);
+ BLO_read_id_address(reader, sce->id.lib, &sce->toolsettings->imapaint.stencil);
}
if (sce->toolsettings->imapaint.clone) {
- sce->toolsettings->imapaint.clone = newlibadr(
- fd, sce->id.lib, sce->toolsettings->imapaint.clone);
+ BLO_read_id_address(reader, sce->id.lib, &sce->toolsettings->imapaint.clone);
}
if (sce->toolsettings->imapaint.canvas) {
- sce->toolsettings->imapaint.canvas = newlibadr(
- fd, sce->id.lib, sce->toolsettings->imapaint.canvas);
+ BLO_read_id_address(reader, sce->id.lib, &sce->toolsettings->imapaint.canvas);
}
- sce->toolsettings->particle.shape_object = newlibadr(
- fd, sce->id.lib, sce->toolsettings->particle.shape_object);
+ BLO_read_id_address(reader, sce->id.lib, &sce->toolsettings->particle.shape_object);
- sce->toolsettings->gp_sculpt.guide.reference_object = newlibadr(
- fd, sce->id.lib, sce->toolsettings->gp_sculpt.guide.reference_object);
+ BLO_read_id_address(reader, sce->id.lib, &sce->toolsettings->gp_sculpt.guide.reference_object);
for (Base *base_legacy_next, *base_legacy = sce->base.first; base_legacy;
base_legacy = base_legacy_next) {
base_legacy_next = base_legacy->next;
- base_legacy->object = newlibadr(fd, sce->id.lib, base_legacy->object);
+ BLO_read_id_address(reader, sce->id.lib, &base_legacy->object);
if (base_legacy->object == NULL) {
- blo_reportf_wrap(
- fd->reports, RPT_WARNING, TIP_("LIB: object lost from scene: '%s'"), sce->id.name + 2);
+ blo_reportf_wrap(reader->fd->reports,
+ RPT_WARNING,
+ TIP_("LIB: object lost from scene: '%s'"),
+ sce->id.name + 2);
BLI_remlink(&sce->base, base_legacy);
if (base_legacy == sce->basact) {
sce->basact = NULL;
@@ -6594,24 +6408,25 @@ static void lib_link_scene(FileData *fd, Main *UNUSED(bmain), Scene *sce)
Sequence *seq;
SEQ_BEGIN (sce->ed, seq) {
- IDP_LibLinkProperty(seq->prop, fd);
+ IDP_LibLinkProperty(seq->prop, reader);
if (seq->ipo) {
- seq->ipo = newlibadr(fd, sce->id.lib, seq->ipo); // XXX deprecated - old animation system
+ BLO_read_id_address(
+ reader, sce->id.lib, &seq->ipo); // XXX deprecated - old animation system
}
seq->scene_sound = NULL;
if (seq->scene) {
- seq->scene = newlibadr(fd, sce->id.lib, seq->scene);
+ BLO_read_id_address(reader, sce->id.lib, &seq->scene);
seq->scene_sound = NULL;
}
if (seq->clip) {
- seq->clip = newlibadr(fd, sce->id.lib, seq->clip);
+ BLO_read_id_address(reader, sce->id.lib, &seq->clip);
}
if (seq->mask) {
- seq->mask = newlibadr(fd, sce->id.lib, seq->mask);
+ BLO_read_id_address(reader, sce->id.lib, &seq->mask);
}
if (seq->scene_camera) {
- seq->scene_camera = newlibadr(fd, sce->id.lib, seq->scene_camera);
+ BLO_read_id_address(reader, sce->id.lib, &seq->scene_camera);
}
if (seq->sound) {
seq->scene_sound = NULL;
@@ -6619,7 +6434,7 @@ static void lib_link_scene(FileData *fd, Main *UNUSED(bmain), Scene *sce)
seq->type = SEQ_TYPE_SOUND_RAM;
}
else {
- seq->sound = newlibadr(fd, sce->id.lib, seq->sound);
+ BLO_read_id_address(reader, sce->id.lib, &seq->sound);
}
if (seq->sound) {
id_us_plus_no_lib((ID *)seq->sound);
@@ -6628,17 +6443,17 @@ static void lib_link_scene(FileData *fd, Main *UNUSED(bmain), Scene *sce)
}
if (seq->type == SEQ_TYPE_TEXT) {
TextVars *t = seq->effectdata;
- t->text_font = newlibadr(fd, sce->id.lib, t->text_font);
+ BLO_read_id_address(reader, sce->id.lib, &t->text_font);
}
BLI_listbase_clear(&seq->anims);
- lib_link_sequence_modifiers(fd, sce, &seq->modifiers);
+ lib_link_sequence_modifiers(reader, sce, &seq->modifiers);
}
SEQ_END;
LISTBASE_FOREACH (TimeMarker *, marker, &sce->markers) {
if (marker->camera) {
- marker->camera = newlibadr(fd, sce->id.lib, marker->camera);
+ BLO_read_id_address(reader, sce->id.lib, &marker->camera);
}
}
@@ -6646,13 +6461,13 @@ static void lib_link_scene(FileData *fd, Main *UNUSED(bmain), Scene *sce)
if (sce->rigidbody_world) {
RigidBodyWorld *rbw = sce->rigidbody_world;
if (rbw->group) {
- rbw->group = newlibadr(fd, sce->id.lib, rbw->group);
+ BLO_read_id_address(reader, sce->id.lib, &rbw->group);
}
if (rbw->constraints) {
- rbw->constraints = newlibadr(fd, sce->id.lib, rbw->constraints);
+ BLO_read_id_address(reader, sce->id.lib, &rbw->constraints);
}
if (rbw->effector_weights) {
- rbw->effector_weights->group = newlibadr(fd, sce->id.lib, rbw->effector_weights->group);
+ BLO_read_id_address(reader, sce->id.lib, &rbw->effector_weights->group);
}
}
@@ -6661,30 +6476,30 @@ static void lib_link_scene(FileData *fd, Main *UNUSED(bmain), Scene *sce)
}
LISTBASE_FOREACH (SceneRenderLayer *, srl, &sce->r.layers) {
- srl->mat_override = newlibadr(fd, sce->id.lib, srl->mat_override);
+ BLO_read_id_address(reader, sce->id.lib, &srl->mat_override);
LISTBASE_FOREACH (FreestyleModuleConfig *, fmc, &srl->freestyleConfig.modules) {
- fmc->script = newlibadr(fd, sce->id.lib, fmc->script);
+ BLO_read_id_address(reader, sce->id.lib, &fmc->script);
}
LISTBASE_FOREACH (FreestyleLineSet *, fls, &srl->freestyleConfig.linesets) {
- fls->linestyle = newlibadr(fd, sce->id.lib, fls->linestyle);
- fls->group = newlibadr(fd, sce->id.lib, fls->group);
+ BLO_read_id_address(reader, sce->id.lib, &fls->linestyle);
+ BLO_read_id_address(reader, sce->id.lib, &fls->group);
}
}
/* Motion Tracking */
- sce->clip = newlibadr(fd, sce->id.lib, sce->clip);
+ BLO_read_id_address(reader, sce->id.lib, &sce->clip);
#ifdef USE_COLLECTION_COMPAT_28
if (sce->collection) {
- lib_link_scene_collection(fd, sce->id.lib, sce->collection);
+ lib_link_scene_collection(reader, sce->id.lib, sce->collection);
}
#endif
LISTBASE_FOREACH (ViewLayer *, view_layer, &sce->view_layers) {
- lib_link_view_layer(fd, sce->id.lib, view_layer);
+ lib_link_view_layer(reader, sce->id.lib, view_layer);
}
if (sce->r.bake.cage_object) {
- sce->r.bake.cage_object = newlibadr(fd, sce->id.lib, sce->r.bake.cage_object);
+ BLO_read_id_address(reader, sce->id.lib, &sce->r.bake.cage_object);
}
#ifdef USE_SETSCENE_CHECK
@@ -6734,7 +6549,7 @@ static void direct_link_paint(BlendDataReader *reader, const Scene *scene, Paint
BLO_read_data_address(reader, &p->cavity_curve);
if (p->cavity_curve) {
- direct_link_curvemapping(reader, p->cavity_curve);
+ BKE_curvemapping_blend_read(reader, p->cavity_curve);
}
else {
BKE_paint_cavity_curve_preset(p, CURVE_PRESET_LINE);
@@ -6776,12 +6591,12 @@ static void direct_link_sequence_modifiers(BlendDataReader *reader, ListBase *lb
if (smd->type == seqModifierType_Curves) {
CurvesModifierData *cmd = (CurvesModifierData *)smd;
- direct_link_curvemapping(reader, &cmd->curve_mapping);
+ BKE_curvemapping_blend_read(reader, &cmd->curve_mapping);
}
else if (smd->type == seqModifierType_HueCorrect) {
HueCorrectModifierData *hcmd = (HueCorrectModifierData *)smd;
- direct_link_curvemapping(reader, &hcmd->curve_mapping);
+ BKE_curvemapping_blend_read(reader, &hcmd->curve_mapping);
}
}
}
@@ -6844,23 +6659,23 @@ static void direct_link_scene(BlendDataReader *reader, Scene *sce)
/* relink grease pencil interpolation curves */
BLO_read_data_address(reader, &sce->toolsettings->gp_interpolate.custom_ipo);
if (sce->toolsettings->gp_interpolate.custom_ipo) {
- direct_link_curvemapping(reader, sce->toolsettings->gp_interpolate.custom_ipo);
+ BKE_curvemapping_blend_read(reader, sce->toolsettings->gp_interpolate.custom_ipo);
}
/* relink grease pencil multiframe falloff curve */
BLO_read_data_address(reader, &sce->toolsettings->gp_sculpt.cur_falloff);
if (sce->toolsettings->gp_sculpt.cur_falloff) {
- direct_link_curvemapping(reader, sce->toolsettings->gp_sculpt.cur_falloff);
+ BKE_curvemapping_blend_read(reader, sce->toolsettings->gp_sculpt.cur_falloff);
}
/* relink grease pencil primitive curve */
BLO_read_data_address(reader, &sce->toolsettings->gp_sculpt.cur_primitive);
if (sce->toolsettings->gp_sculpt.cur_primitive) {
- direct_link_curvemapping(reader, sce->toolsettings->gp_sculpt.cur_primitive);
+ BKE_curvemapping_blend_read(reader, sce->toolsettings->gp_sculpt.cur_primitive);
}
/* Relink toolsettings curve profile */
BLO_read_data_address(reader, &sce->toolsettings->custom_bevel_profile_preset);
if (sce->toolsettings->custom_bevel_profile_preset) {
- direct_link_curveprofile(reader, sce->toolsettings->custom_bevel_profile_preset);
+ BKE_curveprofile_blend_read(reader, sce->toolsettings->custom_bevel_profile_preset);
}
}
@@ -7059,7 +6874,7 @@ static void direct_link_scene(BlendDataReader *reader, Scene *sce)
sce->preview = direct_link_preview_image(reader, sce->preview);
- direct_link_curvemapping(reader, &sce->r.mblur_shutter_curve);
+ BKE_curvemapping_blend_read(reader, &sce->r.mblur_shutter_curve);
#ifdef USE_COLLECTION_COMPAT_28
/* this runs before the very first doversion */
@@ -7106,18 +6921,18 @@ static void direct_link_scene(BlendDataReader *reader, Scene *sce)
* \{ */
/* relink's grease pencil data's refs */
-static void lib_link_gpencil(FileData *fd, Main *UNUSED(bmain), bGPdata *gpd)
+static void lib_link_gpencil(BlendLibReader *reader, bGPdata *gpd)
{
/* Relink all data-lock linked by GP data-lock */
/* Layers */
LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
/* Layer -> Parent References */
- gpl->parent = newlibadr(fd, gpd->id.lib, gpl->parent);
+ BLO_read_id_address(reader, gpd->id.lib, &gpl->parent);
}
/* materials */
for (int a = 0; a < gpd->totcol; a++) {
- gpd->mat[a] = newlibadr(fd, gpd->id.lib, gpd->mat[a]);
+ BLO_read_id_address(reader, gpd->id.lib, &gpd->mat[a]);
}
}
@@ -7209,6 +7024,7 @@ static void direct_link_panel_list(BlendDataReader *reader, ListBase *lb)
panel->runtime_flag = 0;
panel->activedata = NULL;
panel->type = NULL;
+ panel->runtime.custom_data_ptr = NULL;
direct_link_panel_list(reader, &panel->children);
}
}
@@ -7524,9 +7340,9 @@ static void direct_link_area(BlendDataReader *reader, ScrArea *area)
BLO_read_data_address(reader, &area->v4);
}
-static void lib_link_area(FileData *fd, ID *parent_id, ScrArea *area)
+static void lib_link_area(BlendLibReader *reader, ID *parent_id, ScrArea *area)
{
- area->full = newlibadr(fd, parent_id->lib, area->full);
+ BLO_read_id_address(reader, parent_id->lib, &area->full);
memset(&area->runtime, 0x0, sizeof(area->runtime));
@@ -7535,11 +7351,11 @@ static void lib_link_area(FileData *fd, ID *parent_id, ScrArea *area)
case SPACE_VIEW3D: {
View3D *v3d = (View3D *)sl;
- v3d->camera = newlibadr(fd, parent_id->lib, v3d->camera);
- v3d->ob_center = newlibadr(fd, parent_id->lib, v3d->ob_center);
+ BLO_read_id_address(reader, parent_id->lib, &v3d->camera);
+ BLO_read_id_address(reader, parent_id->lib, &v3d->ob_center);
if (v3d->localvd) {
- v3d->localvd->camera = newlibadr(fd, parent_id->lib, v3d->localvd->camera);
+ BLO_read_id_address(reader, parent_id->lib, &v3d->localvd->camera);
}
break;
}
@@ -7548,14 +7364,14 @@ static void lib_link_area(FileData *fd, ID *parent_id, ScrArea *area)
bDopeSheet *ads = sipo->ads;
if (ads) {
- ads->source = newlibadr(fd, parent_id->lib, ads->source);
- ads->filter_grp = newlibadr(fd, parent_id->lib, ads->filter_grp);
+ BLO_read_id_address(reader, parent_id->lib, &ads->source);
+ BLO_read_id_address(reader, parent_id->lib, &ads->filter_grp);
}
break;
}
case SPACE_PROPERTIES: {
SpaceProperties *sbuts = (SpaceProperties *)sl;
- sbuts->pinid = newlibadr(fd, parent_id->lib, sbuts->pinid);
+ BLO_read_id_address(reader, parent_id->lib, &sbuts->pinid);
if (sbuts->pinid == NULL) {
sbuts->flag &= ~SB_PIN_CONTEXT;
}
@@ -7568,23 +7384,23 @@ static void lib_link_area(FileData *fd, ID *parent_id, ScrArea *area)
bDopeSheet *ads = &saction->ads;
if (ads) {
- ads->source = newlibadr(fd, parent_id->lib, ads->source);
- ads->filter_grp = newlibadr(fd, parent_id->lib, ads->filter_grp);
+ BLO_read_id_address(reader, parent_id->lib, &ads->source);
+ BLO_read_id_address(reader, parent_id->lib, &ads->filter_grp);
}
- saction->action = newlibadr(fd, parent_id->lib, saction->action);
+ BLO_read_id_address(reader, parent_id->lib, &saction->action);
break;
}
case SPACE_IMAGE: {
SpaceImage *sima = (SpaceImage *)sl;
- sima->image = newlibadr(fd, parent_id->lib, sima->image);
- sima->mask_info.mask = newlibadr(fd, parent_id->lib, sima->mask_info.mask);
+ BLO_read_id_address(reader, parent_id->lib, &sima->image);
+ BLO_read_id_address(reader, parent_id->lib, &sima->mask_info.mask);
/* NOTE: pre-2.5, this was local data not lib data, but now we need this as lib data
* so fingers crossed this works fine!
*/
- sima->gpd = newlibadr(fd, parent_id->lib, sima->gpd);
+ BLO_read_id_address(reader, parent_id->lib, &sima->gpd);
break;
}
case SPACE_SEQ: {
@@ -7593,7 +7409,7 @@ static void lib_link_area(FileData *fd, ID *parent_id, ScrArea *area)
/* 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!
*/
- sseq->gpd = newlibadr(fd, parent_id->lib, sseq->gpd);
+ BLO_read_id_address(reader, parent_id->lib, &sseq->gpd);
break;
}
case SPACE_NLA: {
@@ -7601,22 +7417,22 @@ static void lib_link_area(FileData *fd, ID *parent_id, ScrArea *area)
bDopeSheet *ads = snla->ads;
if (ads) {
- ads->source = newlibadr(fd, parent_id->lib, ads->source);
- ads->filter_grp = newlibadr(fd, parent_id->lib, ads->filter_grp);
+ BLO_read_id_address(reader, parent_id->lib, &ads->source);
+ BLO_read_id_address(reader, parent_id->lib, &ads->filter_grp);
}
break;
}
case SPACE_TEXT: {
SpaceText *st = (SpaceText *)sl;
- st->text = newlibadr(fd, parent_id->lib, st->text);
+ BLO_read_id_address(reader, parent_id->lib, &st->text);
break;
}
case SPACE_SCRIPT: {
SpaceScript *scpt = (SpaceScript *)sl;
/*scpt->script = NULL; - 2.45 set to null, better re-run the script */
if (scpt->script) {
- scpt->script = newlibadr(fd, parent_id->lib, scpt->script);
+ BLO_read_id_address(reader, parent_id->lib, &scpt->script);
if (scpt->script) {
SCRIPT_SET_NULL(scpt->script);
}
@@ -7625,7 +7441,7 @@ static void lib_link_area(FileData *fd, ID *parent_id, ScrArea *area)
}
case SPACE_OUTLINER: {
SpaceOutliner *so = (SpaceOutliner *)sl;
- so->search_tse.id = newlibadr(fd, NULL, so->search_tse.id);
+ BLO_read_id_address(reader, NULL, &so->search_tse.id);
if (so->treestore) {
TreeStoreElem *tselem;
@@ -7633,7 +7449,7 @@ static void lib_link_area(FileData *fd, ID *parent_id, ScrArea *area)
BLI_mempool_iternew(so->treestore, &iter);
while ((tselem = BLI_mempool_iterstep(&iter))) {
- tselem->id = newlibadr(fd, NULL, tselem->id);
+ BLO_read_id_address(reader, NULL, &tselem->id);
}
if (so->treehash) {
/* rebuild hash table, because it depends on ids too */
@@ -7645,14 +7461,18 @@ static void lib_link_area(FileData *fd, ID *parent_id, ScrArea *area)
case SPACE_NODE: {
SpaceNode *snode = (SpaceNode *)sl;
bNodeTreePath *path, *path_next;
- bNodeTree *ntree;
/* node tree can be stored locally in id too, link this first */
- snode->id = newlibadr(fd, parent_id->lib, snode->id);
- snode->from = newlibadr(fd, parent_id->lib, snode->from);
+ BLO_read_id_address(reader, parent_id->lib, &snode->id);
+ BLO_read_id_address(reader, parent_id->lib, &snode->from);
- ntree = snode->id ? ntreeFromID(snode->id) : NULL;
- snode->nodetree = ntree ? ntree : newlibadr(fd, parent_id->lib, snode->nodetree);
+ bNodeTree *ntree = snode->id ? ntreeFromID(snode->id) : NULL;
+ if (ntree) {
+ snode->nodetree = ntree;
+ }
+ else {
+ BLO_read_id_address(reader, parent_id->lib, &snode->nodetree);
+ }
for (path = snode->treepath.first; path; path = path->next) {
if (path == snode->treepath.first) {
@@ -7660,7 +7480,7 @@ static void lib_link_area(FileData *fd, ID *parent_id, ScrArea *area)
path->nodetree = snode->nodetree;
}
else {
- path->nodetree = newlibadr(fd, parent_id->lib, path->nodetree);
+ BLO_read_id_address(reader, parent_id->lib, &path->nodetree);
}
if (!path->nodetree) {
@@ -7689,8 +7509,8 @@ static void lib_link_area(FileData *fd, ID *parent_id, ScrArea *area)
}
case SPACE_CLIP: {
SpaceClip *sclip = (SpaceClip *)sl;
- sclip->clip = newlibadr(fd, parent_id->lib, sclip->clip);
- sclip->mask_info.mask = newlibadr(fd, parent_id->lib, sclip->mask_info.mask);
+ BLO_read_id_address(reader, parent_id->lib, &sclip->clip);
+ BLO_read_id_address(reader, parent_id->lib, &sclip->mask_info.mask);
break;
}
default:
@@ -7738,10 +7558,9 @@ static void direct_link_wm_xr_data(BlendDataReader *reader, wmXrData *xr_data)
direct_link_view3dshading(reader, &xr_data->session_settings.shading);
}
-static void lib_link_wm_xr_data(FileData *fd, ID *parent_id, wmXrData *xr_data)
+static void lib_link_wm_xr_data(BlendLibReader *reader, ID *parent_id, wmXrData *xr_data)
{
- xr_data->session_settings.base_pose_object = newlibadr(
- fd, parent_id->lib, xr_data->session_settings.base_pose_object);
+ BLO_read_id_address(reader, parent_id->lib, &xr_data->session_settings.base_pose_object);
}
/** \} */
@@ -7827,21 +7646,21 @@ static void direct_link_windowmanager(BlendDataReader *reader, wmWindowManager *
wm->is_interface_locked = 0;
}
-static void lib_link_windowmanager(FileData *fd, Main *UNUSED(bmain), wmWindowManager *wm)
+static void lib_link_windowmanager(BlendLibReader *reader, wmWindowManager *wm)
{
LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
if (win->workspace_hook) { /* NULL for old files */
- lib_link_workspace_instance_hook(fd, win->workspace_hook, &wm->id);
+ lib_link_workspace_instance_hook(reader, win->workspace_hook, &wm->id);
}
- win->scene = newlibadr(fd, wm->id.lib, win->scene);
+ BLO_read_id_address(reader, wm->id.lib, &win->scene);
/* deprecated, but needed for versioning (will be NULL'ed then) */
- win->screen = newlibadr(fd, NULL, win->screen);
+ BLO_read_id_address(reader, NULL, &win->screen);
LISTBASE_FOREACH (ScrArea *, area, &win->global_areas.areabase) {
- lib_link_area(fd, &wm->id, area);
+ lib_link_area(reader, &wm->id, area);
}
- lib_link_wm_xr_data(fd, &wm->id, &wm->xr);
+ lib_link_wm_xr_data(reader, &wm->id, &wm->xr);
}
}
@@ -7853,17 +7672,17 @@ static void lib_link_windowmanager(FileData *fd, Main *UNUSED(bmain), wmWindowMa
/* note: file read without screens option G_FILE_NO_UI;
* check lib pointers in call below */
-static void lib_link_screen(FileData *fd, Main *UNUSED(bmain), bScreen *screen)
+static void lib_link_screen(BlendLibReader *reader, bScreen *screen)
{
/* deprecated, but needed for versioning (will be NULL'ed then) */
- screen->scene = newlibadr(fd, screen->id.lib, screen->scene);
+ BLO_read_id_address(reader, screen->id.lib, &screen->scene);
screen->animtimer = NULL; /* saved in rare cases */
screen->tool_tip = NULL;
screen->scrubbing = false;
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
- lib_link_area(fd, &screen->id, area);
+ lib_link_area(reader, &screen->id, area);
}
}
@@ -8399,12 +8218,12 @@ static void direct_link_library(FileData *fd, Library *lib, Main *main)
/* check if the library was already read */
for (newmain = fd->mainlist->first; newmain; newmain = newmain->next) {
if (newmain->curlib) {
- if (BLI_path_cmp(newmain->curlib->filepath, lib->filepath) == 0) {
+ if (BLI_path_cmp(newmain->curlib->filepath_abs, lib->filepath_abs) == 0) {
blo_reportf_wrap(fd->reports,
RPT_WARNING,
TIP_("Library '%s', '%s' had multiple instances, save and reload!"),
- lib->name,
- lib->filepath);
+ lib->filepath,
+ lib->filepath_abs);
change_link_placeholder_to_real_ID_pointer(fd->mainlist, fd, lib, newmain->curlib);
/* change_link_placeholder_to_real_ID_pointer_fd(fd, lib, newmain->curlib); */
@@ -8426,12 +8245,12 @@ static void direct_link_library(FileData *fd, Library *lib, Main *main)
}
}
- /* make sure we have full path in lib->filepath */
- BLI_strncpy(lib->filepath, lib->name, sizeof(lib->name));
- BLI_path_normalize(fd->relabase, lib->filepath);
+ /* Make sure we have full path in lib->filepath_abs */
+ BLI_strncpy(lib->filepath_abs, lib->filepath, sizeof(lib->filepath));
+ BLI_path_normalize(fd->relabase, lib->filepath_abs);
- // printf("direct_link_library: name %s\n", lib->name);
// printf("direct_link_library: filepath %s\n", lib->filepath);
+ // printf("direct_link_library: filepath_abs %s\n", lib->filepath_abs);
BlendDataReader reader = {fd};
lib->packedfile = direct_link_packedfile(&reader, lib->packedfile);
@@ -8446,7 +8265,7 @@ static void direct_link_library(FileData *fd, Library *lib, Main *main)
id_us_ensure_real(&lib->id);
}
-static void lib_link_library(FileData *UNUSED(fd), Main *UNUSED(bmain), Library *UNUSED(lib))
+static void lib_link_library(BlendLibReader *UNUSED(reader), Library *UNUSED(lib))
{
}
@@ -8463,8 +8282,8 @@ static void fix_relpaths_library(const char *basepath, Main *main)
* it absolute. This can happen when appending an object with a relative
* link into an unsaved blend file. See [#27405].
* The remap relative option will make it relative again on save - campbell */
- if (BLI_path_is_rel(lib->name)) {
- BLI_strncpy(lib->name, lib->filepath, sizeof(lib->name));
+ if (BLI_path_is_rel(lib->filepath)) {
+ BLI_strncpy(lib->filepath, lib->filepath_abs, sizeof(lib->filepath));
}
}
}
@@ -8473,9 +8292,9 @@ static void fix_relpaths_library(const char *basepath, Main *main)
/* Libraries store both relative and abs paths, recreate relative paths,
* relative to the blend file since indirectly linked libs will be
* relative to their direct linked library. */
- if (BLI_path_is_rel(lib->name)) { /* if this is relative to begin with? */
- BLI_strncpy(lib->name, lib->filepath, sizeof(lib->name));
- BLI_path_rel(lib->name, basepath);
+ if (BLI_path_is_rel(lib->filepath)) { /* if this is relative to begin with? */
+ BLI_strncpy(lib->filepath, lib->filepath_abs, sizeof(lib->filepath));
+ BLI_path_rel(lib->filepath, basepath);
}
}
}
@@ -8487,9 +8306,9 @@ static void fix_relpaths_library(const char *basepath, Main *main)
/** \name Read ID: Light Probe
* \{ */
-static void lib_link_lightprobe(FileData *fd, Main *UNUSED(bmain), LightProbe *prb)
+static void lib_link_lightprobe(BlendLibReader *reader, LightProbe *prb)
{
- prb->visibility_grp = newlibadr(fd, prb->id.lib, prb->visibility_grp);
+ BLO_read_id_address(reader, prb->id.lib, &prb->visibility_grp);
}
static void direct_link_lightprobe(BlendDataReader *reader, LightProbe *prb)
@@ -8504,9 +8323,9 @@ static void direct_link_lightprobe(BlendDataReader *reader, LightProbe *prb)
/** \name Read ID: Speaker
* \{ */
-static void lib_link_speaker(FileData *fd, Main *UNUSED(bmain), Speaker *spk)
+static void lib_link_speaker(BlendLibReader *reader, Speaker *spk)
{
- spk->sound = newlibadr(fd, spk->id.lib, spk->sound);
+ BLO_read_id_address(reader, spk->id.lib, &spk->sound);
}
static void direct_link_speaker(BlendDataReader *reader, Speaker *spk)
@@ -8556,9 +8375,10 @@ static void direct_link_sound(BlendDataReader *reader, bSound *sound)
sound->newpackedfile = direct_link_packedfile(reader, sound->newpackedfile);
}
-static void lib_link_sound(FileData *fd, Main *UNUSED(bmain), bSound *sound)
+static void lib_link_sound(BlendLibReader *reader, bSound *sound)
{
- sound->ipo = newlibadr(fd, sound->id.lib, sound->ipo); // XXX deprecated - old animation system
+ BLO_read_id_address(
+ reader, sound->id.lib, &sound->ipo); // XXX deprecated - old animation system
}
/** \} */
@@ -8650,36 +8470,38 @@ static void direct_link_movieclip(BlendDataReader *reader, MovieClip *clip)
}
}
-static void lib_link_movieTracks(FileData *fd, MovieClip *clip, ListBase *tracksbase)
+static void lib_link_movieTracks(BlendLibReader *reader, MovieClip *clip, ListBase *tracksbase)
{
MovieTrackingTrack *track;
for (track = tracksbase->first; track; track = track->next) {
- track->gpd = newlibadr(fd, clip->id.lib, track->gpd);
+ BLO_read_id_address(reader, clip->id.lib, &track->gpd);
}
}
-static void lib_link_moviePlaneTracks(FileData *fd, MovieClip *clip, ListBase *tracksbase)
+static void lib_link_moviePlaneTracks(BlendLibReader *reader,
+ MovieClip *clip,
+ ListBase *tracksbase)
{
MovieTrackingPlaneTrack *plane_track;
for (plane_track = tracksbase->first; plane_track; plane_track = plane_track->next) {
- plane_track->image = newlibadr(fd, clip->id.lib, plane_track->image);
+ BLO_read_id_address(reader, clip->id.lib, &plane_track->image);
}
}
-static void lib_link_movieclip(FileData *fd, Main *UNUSED(bmain), MovieClip *clip)
+static void lib_link_movieclip(BlendLibReader *reader, MovieClip *clip)
{
MovieTracking *tracking = &clip->tracking;
- clip->gpd = newlibadr(fd, clip->id.lib, clip->gpd);
+ BLO_read_id_address(reader, clip->id.lib, &clip->gpd);
- lib_link_movieTracks(fd, clip, &tracking->tracks);
- lib_link_moviePlaneTracks(fd, clip, &tracking->plane_tracks);
+ lib_link_movieTracks(reader, clip, &tracking->tracks);
+ lib_link_moviePlaneTracks(reader, clip, &tracking->plane_tracks);
LISTBASE_FOREACH (MovieTrackingObject *, object, &tracking->objects) {
- lib_link_movieTracks(fd, clip, &object->tracks);
- lib_link_moviePlaneTracks(fd, clip, &object->plane_tracks);
+ lib_link_movieTracks(reader, clip, &object->tracks);
+ lib_link_moviePlaneTracks(reader, clip, &object->plane_tracks);
}
}
@@ -8747,12 +8569,12 @@ static void direct_link_mask(BlendDataReader *reader, Mask *mask)
}
}
-static void lib_link_mask_parent(FileData *fd, Mask *mask, MaskParent *parent)
+static void lib_link_mask_parent(BlendLibReader *reader, Mask *mask, MaskParent *parent)
{
- parent->id = newlibadr(fd, mask->id.lib, parent->id);
+ BLO_read_id_address(reader, mask->id.lib, &parent->id);
}
-static void lib_link_mask(FileData *fd, Main *UNUSED(bmain), Mask *mask)
+static void lib_link_mask(BlendLibReader *reader, Mask *mask)
{
LISTBASE_FOREACH (MaskLayer *, masklay, &mask->masklayers) {
MaskSpline *spline;
@@ -8764,10 +8586,10 @@ static void lib_link_mask(FileData *fd, Main *UNUSED(bmain), Mask *mask)
for (i = 0; i < spline->tot_point; i++) {
MaskSplinePoint *point = &spline->points[i];
- lib_link_mask_parent(fd, mask, &point->parent);
+ lib_link_mask_parent(reader, mask, &point->parent);
}
- lib_link_mask_parent(fd, mask, &spline->parent);
+ lib_link_mask_parent(reader, mask, &spline->parent);
spline = spline->next;
}
@@ -8780,7 +8602,7 @@ static void lib_link_mask(FileData *fd, Main *UNUSED(bmain), Mask *mask)
/** \name Read ID: Line Style
* \{ */
-static void lib_link_linestyle(FileData *fd, Main *UNUSED(bmain), FreestyleLineStyle *linestyle)
+static void lib_link_linestyle(BlendLibReader *reader, FreestyleLineStyle *linestyle)
{
LineStyleModifier *m;
@@ -8789,7 +8611,7 @@ static void lib_link_linestyle(FileData *fd, Main *UNUSED(bmain), FreestyleLineS
case LS_MODIFIER_DISTANCE_FROM_OBJECT: {
LineStyleColorModifier_DistanceFromObject *cm =
(LineStyleColorModifier_DistanceFromObject *)m;
- cm->target = newlibadr(fd, linestyle->id.lib, cm->target);
+ BLO_read_id_address(reader, linestyle->id.lib, &cm->target);
break;
}
}
@@ -8799,7 +8621,7 @@ static void lib_link_linestyle(FileData *fd, Main *UNUSED(bmain), FreestyleLineS
case LS_MODIFIER_DISTANCE_FROM_OBJECT: {
LineStyleAlphaModifier_DistanceFromObject *am =
(LineStyleAlphaModifier_DistanceFromObject *)m;
- am->target = newlibadr(fd, linestyle->id.lib, am->target);
+ BLO_read_id_address(reader, linestyle->id.lib, &am->target);
break;
}
}
@@ -8809,7 +8631,7 @@ static void lib_link_linestyle(FileData *fd, Main *UNUSED(bmain), FreestyleLineS
case LS_MODIFIER_DISTANCE_FROM_OBJECT: {
LineStyleThicknessModifier_DistanceFromObject *tm =
(LineStyleThicknessModifier_DistanceFromObject *)m;
- tm->target = newlibadr(fd, linestyle->id.lib, tm->target);
+ BLO_read_id_address(reader, linestyle->id.lib, &tm->target);
break;
}
}
@@ -8817,8 +8639,8 @@ static void lib_link_linestyle(FileData *fd, Main *UNUSED(bmain), FreestyleLineS
for (int a = 0; a < MAX_MTEX; a++) {
MTex *mtex = linestyle->mtex[a];
if (mtex) {
- mtex->tex = newlibadr(fd, linestyle->id.lib, mtex->tex);
- mtex->object = newlibadr(fd, linestyle->id.lib, mtex->object);
+ BLO_read_id_address(reader, linestyle->id.lib, &mtex->tex);
+ BLO_read_id_address(reader, linestyle->id.lib, &mtex->object);
}
}
}
@@ -8879,51 +8701,51 @@ static void direct_link_linestyle_alpha_modifier(BlendDataReader *reader,
case LS_MODIFIER_ALONG_STROKE: {
LineStyleAlphaModifier_AlongStroke *m = (LineStyleAlphaModifier_AlongStroke *)modifier;
BLO_read_data_address(reader, &m->curve);
- direct_link_curvemapping(reader, m->curve);
+ BKE_curvemapping_blend_read(reader, m->curve);
break;
}
case LS_MODIFIER_DISTANCE_FROM_CAMERA: {
LineStyleAlphaModifier_DistanceFromCamera *m = (LineStyleAlphaModifier_DistanceFromCamera *)
modifier;
BLO_read_data_address(reader, &m->curve);
- direct_link_curvemapping(reader, m->curve);
+ BKE_curvemapping_blend_read(reader, m->curve);
break;
}
case LS_MODIFIER_DISTANCE_FROM_OBJECT: {
LineStyleAlphaModifier_DistanceFromObject *m = (LineStyleAlphaModifier_DistanceFromObject *)
modifier;
BLO_read_data_address(reader, &m->curve);
- direct_link_curvemapping(reader, m->curve);
+ BKE_curvemapping_blend_read(reader, m->curve);
break;
}
case LS_MODIFIER_MATERIAL: {
LineStyleAlphaModifier_Material *m = (LineStyleAlphaModifier_Material *)modifier;
BLO_read_data_address(reader, &m->curve);
- direct_link_curvemapping(reader, m->curve);
+ BKE_curvemapping_blend_read(reader, m->curve);
break;
}
case LS_MODIFIER_TANGENT: {
LineStyleAlphaModifier_Tangent *m = (LineStyleAlphaModifier_Tangent *)modifier;
BLO_read_data_address(reader, &m->curve);
- direct_link_curvemapping(reader, m->curve);
+ BKE_curvemapping_blend_read(reader, m->curve);
break;
}
case LS_MODIFIER_NOISE: {
LineStyleAlphaModifier_Noise *m = (LineStyleAlphaModifier_Noise *)modifier;
BLO_read_data_address(reader, &m->curve);
- direct_link_curvemapping(reader, m->curve);
+ BKE_curvemapping_blend_read(reader, m->curve);
break;
}
case LS_MODIFIER_CREASE_ANGLE: {
LineStyleAlphaModifier_CreaseAngle *m = (LineStyleAlphaModifier_CreaseAngle *)modifier;
BLO_read_data_address(reader, &m->curve);
- direct_link_curvemapping(reader, m->curve);
+ BKE_curvemapping_blend_read(reader, m->curve);
break;
}
case LS_MODIFIER_CURVATURE_3D: {
LineStyleAlphaModifier_Curvature_3D *m = (LineStyleAlphaModifier_Curvature_3D *)modifier;
BLO_read_data_address(reader, &m->curve);
- direct_link_curvemapping(reader, m->curve);
+ BKE_curvemapping_blend_read(reader, m->curve);
break;
}
}
@@ -8937,47 +8759,47 @@ static void direct_link_linestyle_thickness_modifier(BlendDataReader *reader,
LineStyleThicknessModifier_AlongStroke *m = (LineStyleThicknessModifier_AlongStroke *)
modifier;
BLO_read_data_address(reader, &m->curve);
- direct_link_curvemapping(reader, m->curve);
+ BKE_curvemapping_blend_read(reader, m->curve);
break;
}
case LS_MODIFIER_DISTANCE_FROM_CAMERA: {
LineStyleThicknessModifier_DistanceFromCamera *m =
(LineStyleThicknessModifier_DistanceFromCamera *)modifier;
BLO_read_data_address(reader, &m->curve);
- direct_link_curvemapping(reader, m->curve);
+ BKE_curvemapping_blend_read(reader, m->curve);
break;
}
case LS_MODIFIER_DISTANCE_FROM_OBJECT: {
LineStyleThicknessModifier_DistanceFromObject *m =
(LineStyleThicknessModifier_DistanceFromObject *)modifier;
BLO_read_data_address(reader, &m->curve);
- direct_link_curvemapping(reader, m->curve);
+ BKE_curvemapping_blend_read(reader, m->curve);
break;
}
case LS_MODIFIER_MATERIAL: {
LineStyleThicknessModifier_Material *m = (LineStyleThicknessModifier_Material *)modifier;
BLO_read_data_address(reader, &m->curve);
- direct_link_curvemapping(reader, m->curve);
+ BKE_curvemapping_blend_read(reader, m->curve);
break;
}
case LS_MODIFIER_TANGENT: {
LineStyleThicknessModifier_Tangent *m = (LineStyleThicknessModifier_Tangent *)modifier;
BLO_read_data_address(reader, &m->curve);
- direct_link_curvemapping(reader, m->curve);
+ BKE_curvemapping_blend_read(reader, m->curve);
break;
}
case LS_MODIFIER_CREASE_ANGLE: {
LineStyleThicknessModifier_CreaseAngle *m = (LineStyleThicknessModifier_CreaseAngle *)
modifier;
BLO_read_data_address(reader, &m->curve);
- direct_link_curvemapping(reader, m->curve);
+ BKE_curvemapping_blend_read(reader, m->curve);
break;
}
case LS_MODIFIER_CURVATURE_3D: {
LineStyleThicknessModifier_Curvature_3D *m = (LineStyleThicknessModifier_Curvature_3D *)
modifier;
BLO_read_data_address(reader, &m->curve);
- direct_link_curvemapping(reader, m->curve);
+ BKE_curvemapping_blend_read(reader, m->curve);
break;
}
}
@@ -9022,10 +8844,10 @@ static void direct_link_linestyle(BlendDataReader *reader, FreestyleLineStyle *l
/** \name Read ID: Hair
* \{ */
-static void lib_link_hair(FileData *fd, Main *UNUSED(main), Hair *hair)
+static void lib_link_hair(BlendLibReader *reader, Hair *hair)
{
for (int a = 0; a < hair->totcol; a++) {
- hair->mat[a] = newlibadr(fd, hair->id.lib, hair->mat[a]);
+ BLO_read_id_address(reader, hair->id.lib, &hair->mat[a]);
}
}
@@ -9049,10 +8871,10 @@ static void direct_link_hair(BlendDataReader *reader, Hair *hair)
/** \name Read ID: Point Cloud
* \{ */
-static void lib_link_pointcloud(FileData *fd, Main *UNUSED(main), PointCloud *pointcloud)
+static void lib_link_pointcloud(BlendLibReader *reader, PointCloud *pointcloud)
{
for (int a = 0; a < pointcloud->totcol; a++) {
- pointcloud->mat[a] = newlibadr(fd, pointcloud->id.lib, pointcloud->mat[a]);
+ BLO_read_id_address(reader, pointcloud->id.lib, &pointcloud->mat[a]);
}
}
@@ -9075,10 +8897,10 @@ static void direct_link_pointcloud(BlendDataReader *reader, PointCloud *pointclo
/** \name Read ID: Volume
* \{ */
-static void lib_link_volume(FileData *fd, Main *UNUSED(main), Volume *volume)
+static void lib_link_volume(BlendLibReader *reader, Volume *volume)
{
for (int a = 0; a < volume->totcol; a++) {
- volume->mat[a] = newlibadr(fd, volume->id.lib, volume->mat[a]);
+ BLO_read_id_address(reader, volume->id.lib, &volume->mat[a]);
}
}
@@ -9104,9 +8926,7 @@ static void direct_link_volume(BlendDataReader *reader, Volume *volume)
/** \name Read ID: Simulation
* \{ */
-static void lib_link_simulation(FileData *UNUSED(fd),
- Main *UNUSED(main),
- Simulation *UNUSED(simulation))
+static void lib_link_simulation(BlendLibReader *UNUSED(reader), Simulation *UNUSED(simulation))
{
}
@@ -9491,7 +9311,7 @@ static bool read_libblock_undo_restore_linked(FileData *fd, Main *main, const ID
DEBUG_PRINTF("UNDO: restore linked datablock %s\n", id->name);
DEBUG_PRINTF(" from %s (%s): ",
main->curlib ? main->curlib->id.name : "<NULL>",
- main->curlib ? main->curlib->name : "<NULL>");
+ main->curlib ? main->curlib->filepath : "<NULL>");
ID *id_old = BKE_libblock_find_name(main, GS(id->name), id->name + 2);
if (id_old != NULL) {
@@ -9940,8 +9760,8 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
static void do_versions_after_linking(Main *main, ReportList *reports)
{
- // printf("%s for %s (%s), %d.%d\n", __func__, main->curlib ? main->curlib->name : main->name,
- // main->curlib ? "LIB" : "MAIN", main->versionfile, main->subversionfile);
+ // printf("%s for %s (%s), %d.%d\n", __func__, main->curlib ? main->curlib->filepath :
+ // main->name, main->curlib ? "LIB" : "MAIN", main->versionfile, main->subversionfile);
/* Don't allow versioning to create new data-blocks. */
main->is_locked_for_linking = true;
@@ -9966,6 +9786,8 @@ static void lib_link_all(FileData *fd, Main *bmain)
{
const bool do_partial_undo = (fd->skip_flags & BLO_READ_SKIP_UNDO_OLD_MAIN) == 0;
+ BlendLibReader reader = {fd, bmain};
+
ID *id;
FOREACH_MAIN_ID_BEGIN (bmain, id) {
if ((id->tag & LIB_TAG_NEED_LINK) == 0) {
@@ -9986,7 +9808,7 @@ static void lib_link_all(FileData *fd, Main *bmain)
continue;
}
- lib_link_id(fd, bmain, id);
+ lib_link_id(&reader, id);
/* Note: ID types are processed in reverse order as defined by INDEX_ID_XXX enums in DNA_ID.h.
* This ensures handling of most dependencies in proper order, as elsewhere in code.
@@ -9994,129 +9816,129 @@ static void lib_link_all(FileData *fd, Main *bmain)
* whether something is wrong then. */
switch (GS(id->name)) {
case ID_MSK:
- lib_link_mask(fd, bmain, (Mask *)id);
+ lib_link_mask(&reader, (Mask *)id);
break;
case ID_WM:
- lib_link_windowmanager(fd, bmain, (wmWindowManager *)id);
+ lib_link_windowmanager(&reader, (wmWindowManager *)id);
break;
case ID_WS:
/* Could we skip WS in undo case? */
- lib_link_workspaces(fd, bmain, (WorkSpace *)id);
+ lib_link_workspaces(&reader, (WorkSpace *)id);
break;
case ID_SCE:
- lib_link_scene(fd, bmain, (Scene *)id);
+ lib_link_scene(&reader, (Scene *)id);
break;
case ID_LS:
- lib_link_linestyle(fd, bmain, (FreestyleLineStyle *)id);
+ lib_link_linestyle(&reader, (FreestyleLineStyle *)id);
break;
case ID_OB:
- lib_link_object(fd, bmain, (Object *)id);
+ lib_link_object(&reader, (Object *)id);
break;
case ID_SCR:
/* DO NOT skip screens here,
* 3D viewport may contains pointers to other ID data (like bgpic)! See T41411. */
- lib_link_screen(fd, bmain, (bScreen *)id);
+ lib_link_screen(&reader, (bScreen *)id);
break;
case ID_MC:
- lib_link_movieclip(fd, bmain, (MovieClip *)id);
+ lib_link_movieclip(&reader, (MovieClip *)id);
break;
case ID_WO:
- lib_link_world(fd, bmain, (World *)id);
+ lib_link_world(&reader, (World *)id);
break;
case ID_LP:
- lib_link_lightprobe(fd, bmain, (LightProbe *)id);
+ lib_link_lightprobe(&reader, (LightProbe *)id);
break;
case ID_SPK:
- lib_link_speaker(fd, bmain, (Speaker *)id);
+ lib_link_speaker(&reader, (Speaker *)id);
break;
case ID_PA:
- lib_link_particlesettings(fd, bmain, (ParticleSettings *)id);
+ lib_link_particlesettings(&reader, (ParticleSettings *)id);
break;
case ID_PC:
- lib_link_paint_curve(fd, bmain, (PaintCurve *)id);
+ lib_link_paint_curve(&reader, (PaintCurve *)id);
break;
case ID_BR:
- lib_link_brush(fd, bmain, (Brush *)id);
+ lib_link_brush(&reader, (Brush *)id);
break;
case ID_GR:
- lib_link_collection(fd, bmain, (Collection *)id);
+ lib_link_collection(&reader, (Collection *)id);
break;
case ID_SO:
- lib_link_sound(fd, bmain, (bSound *)id);
+ lib_link_sound(&reader, (bSound *)id);
break;
case ID_TXT:
- lib_link_text(fd, bmain, (Text *)id);
+ lib_link_text(&reader, (Text *)id);
break;
case ID_CA:
- lib_link_camera(fd, bmain, (Camera *)id);
+ lib_link_camera(&reader, (Camera *)id);
break;
case ID_LA:
- lib_link_light(fd, bmain, (Light *)id);
+ lib_link_light(&reader, (Light *)id);
break;
case ID_LT:
- lib_link_latt(fd, bmain, (Lattice *)id);
+ lib_link_latt(&reader, (Lattice *)id);
break;
case ID_MB:
- lib_link_mball(fd, bmain, (MetaBall *)id);
+ lib_link_mball(&reader, (MetaBall *)id);
break;
case ID_CU:
- lib_link_curve(fd, bmain, (Curve *)id);
+ lib_link_curve(&reader, (Curve *)id);
break;
case ID_ME:
- lib_link_mesh(fd, bmain, (Mesh *)id);
+ lib_link_mesh(&reader, (Mesh *)id);
break;
case ID_CF:
- lib_link_cachefiles(fd, bmain, (CacheFile *)id);
+ lib_link_cachefiles(&reader, (CacheFile *)id);
break;
case ID_AR:
- lib_link_armature(fd, bmain, (bArmature *)id);
+ lib_link_armature(&reader, (bArmature *)id);
break;
case ID_VF:
- lib_link_vfont(fd, bmain, (VFont *)id);
+ lib_link_vfont(&reader, (VFont *)id);
break;
case ID_HA:
- lib_link_hair(fd, bmain, (Hair *)id);
+ lib_link_hair(&reader, (Hair *)id);
break;
case ID_PT:
- lib_link_pointcloud(fd, bmain, (PointCloud *)id);
+ lib_link_pointcloud(&reader, (PointCloud *)id);
break;
case ID_VO:
- lib_link_volume(fd, bmain, (Volume *)id);
+ lib_link_volume(&reader, (Volume *)id);
break;
case ID_MA:
- lib_link_material(fd, bmain, (Material *)id);
+ lib_link_material(&reader, (Material *)id);
break;
case ID_TE:
- lib_link_texture(fd, bmain, (Tex *)id);
+ lib_link_texture(&reader, (Tex *)id);
break;
case ID_IM:
- lib_link_image(fd, bmain, (Image *)id);
+ lib_link_image(&reader, (Image *)id);
break;
case ID_NT:
/* Has to be done after node users (scene/materials/...), this will verify group nodes. */
- lib_link_nodetree(fd, bmain, (bNodeTree *)id);
+ lib_link_nodetree(&reader, (bNodeTree *)id);
break;
case ID_GD:
- lib_link_gpencil(fd, bmain, (bGPdata *)id);
+ lib_link_gpencil(&reader, (bGPdata *)id);
break;
case ID_PAL:
- lib_link_palette(fd, bmain, (Palette *)id);
+ lib_link_palette(&reader, (Palette *)id);
break;
case ID_KE:
- lib_link_key(fd, bmain, (Key *)id);
+ lib_link_key(&reader, (Key *)id);
break;
case ID_AC:
- lib_link_action(fd, bmain, (bAction *)id);
+ lib_link_action(&reader, (bAction *)id);
break;
case ID_SIM:
- lib_link_simulation(fd, bmain, (Simulation *)id);
+ lib_link_simulation(&reader, (Simulation *)id);
break;
case ID_IP:
/* XXX deprecated... still needs to be maintained for version patches still. */
- lib_link_ipo(fd, bmain, (Ipo *)id);
+ lib_link_ipo(&reader, (Ipo *)id);
break;
case ID_LI:
- lib_link_library(fd, bmain, (Library *)id); /* Only init users. */
+ lib_link_library(&reader, (Library *)id); /* Only init users. */
break;
}
@@ -10591,7 +10413,7 @@ static void expand_doit_library(void *fdhandle, Main *mainvar, void *old)
}
Library *lib = read_struct(fd, bheadlib, "Library");
- Main *libmain = blo_find_main(fd, lib->name, fd->relabase);
+ Main *libmain = blo_find_main(fd, lib->filepath, fd->relabase);
if (libmain->curlib == NULL) {
const char *idname = blo_bhead_id_name(fd, bhead);
@@ -10600,7 +10422,7 @@ static void expand_doit_library(void *fdhandle, Main *mainvar, void *old)
RPT_WARNING,
TIP_("LIB: Data refers to main .blend file: '%s' from %s"),
idname,
- mainvar->curlib->filepath);
+ mainvar->curlib->filepath_abs);
return;
}
@@ -10611,7 +10433,7 @@ static void expand_doit_library(void *fdhandle, Main *mainvar, void *old)
* library it belongs to, so that it will be read later. */
read_libblock(fd, libmain, bhead, LIB_TAG_INDIRECT, false, NULL);
// commented because this can print way too much
- // if (G.debug & G_DEBUG) printf("expand_doit: other lib %s\n", lib->name);
+ // if (G.debug & G_DEBUG) printf("expand_doit: other lib %s\n", lib->filepath);
/* for outliner dependency only */
libmain->curlib->parent = mainvar->curlib;
@@ -10648,7 +10470,7 @@ static void expand_doit_library(void *fdhandle, Main *mainvar, void *old)
/* Commented because this can print way too much. */
#if 0
if (G.debug & G_DEBUG) {
- printf("expand_doit: already linked: %s lib: %s\n", id->name, lib->name);
+ printf("expand_doit: already linked: %s lib: %s\n", id->name, lib->filepath);
}
#endif
}
@@ -10686,26 +10508,26 @@ static void expand_doit_library(void *fdhandle, Main *mainvar, void *old)
static BLOExpandDoitCallback expand_doit;
// XXX deprecated - old animation system
-static void expand_ipo(FileData *fd, Main *mainvar, Ipo *ipo)
+static void expand_ipo(BlendExpander *expander, Ipo *ipo)
{
IpoCurve *icu;
for (icu = ipo->curve.first; icu; icu = icu->next) {
if (icu->driver) {
- expand_doit(fd, mainvar, icu->driver->ob);
+ BLO_expand(expander, icu->driver->ob);
}
}
}
// XXX deprecated - old animation system
-static void expand_constraint_channels(FileData *fd, Main *mainvar, ListBase *chanbase)
+static void expand_constraint_channels(BlendExpander *expander, ListBase *chanbase)
{
bConstraintChannel *chan;
for (chan = chanbase->first; chan; chan = chan->next) {
- expand_doit(fd, mainvar, chan->ipo);
+ BLO_expand(expander, chan->ipo);
}
}
-static void expand_fmodifiers(FileData *fd, Main *mainvar, ListBase *list)
+static void expand_fmodifiers(BlendExpander *expander, ListBase *list)
{
FModifier *fcm;
@@ -10715,7 +10537,7 @@ static void expand_fmodifiers(FileData *fd, Main *mainvar, ListBase *list)
case FMODIFIER_TYPE_PYTHON: {
FMod_Python *data = (FMod_Python *)fcm->data;
- expand_doit(fd, mainvar, data->script);
+ BLO_expand(expander, data->script);
break;
}
@@ -10723,7 +10545,7 @@ static void expand_fmodifiers(FileData *fd, Main *mainvar, ListBase *list)
}
}
-static void expand_fcurves(FileData *fd, Main *mainvar, ListBase *list)
+static void expand_fcurves(BlendExpander *expander, ListBase *list)
{
FCurve *fcu;
@@ -10736,54 +10558,54 @@ static void expand_fcurves(FileData *fd, Main *mainvar, ListBase *list)
for (dvar = driver->variables.first; dvar; dvar = dvar->next) {
DRIVER_TARGETS_LOOPER_BEGIN (dvar) {
// TODO: only expand those that are going to get used?
- expand_doit(fd, mainvar, dtar->id);
+ BLO_expand(expander, dtar->id);
}
DRIVER_TARGETS_LOOPER_END;
}
}
/* F-Curve Modifiers */
- expand_fmodifiers(fd, mainvar, &fcu->modifiers);
+ expand_fmodifiers(expander, &fcu->modifiers);
}
}
-static void expand_animdata_nlastrips(FileData *fd, Main *mainvar, ListBase *list)
+static void expand_animdata_nlastrips(BlendExpander *expander, ListBase *list)
{
NlaStrip *strip;
for (strip = list->first; strip; strip = strip->next) {
/* check child strips */
- expand_animdata_nlastrips(fd, mainvar, &strip->strips);
+ expand_animdata_nlastrips(expander, &strip->strips);
/* check F-Curves */
- expand_fcurves(fd, mainvar, &strip->fcurves);
+ expand_fcurves(expander, &strip->fcurves);
/* check F-Modifiers */
- expand_fmodifiers(fd, mainvar, &strip->modifiers);
+ expand_fmodifiers(expander, &strip->modifiers);
/* relink referenced action */
- expand_doit(fd, mainvar, strip->act);
+ BLO_expand(expander, strip->act);
}
}
-static void expand_animdata(FileData *fd, Main *mainvar, AnimData *adt)
+static void expand_animdata(BlendExpander *expander, AnimData *adt)
{
NlaTrack *nlt;
/* own action */
- expand_doit(fd, mainvar, adt->action);
- expand_doit(fd, mainvar, adt->tmpact);
+ BLO_expand(expander, adt->action);
+ BLO_expand(expander, adt->tmpact);
/* drivers - assume that these F-Curves have driver data to be in this list... */
- expand_fcurves(fd, mainvar, &adt->drivers);
+ expand_fcurves(expander, &adt->drivers);
/* nla-data - referenced actions */
for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) {
- expand_animdata_nlastrips(fd, mainvar, &nlt->strips);
+ expand_animdata_nlastrips(expander, &nlt->strips);
}
}
-static void expand_idprops(FileData *fd, Main *mainvar, IDProperty *prop)
+static void expand_idprops(BlendExpander *expander, IDProperty *prop)
{
if (!prop) {
return;
@@ -10791,84 +10613,84 @@ static void expand_idprops(FileData *fd, Main *mainvar, IDProperty *prop)
switch (prop->type) {
case IDP_ID:
- expand_doit(fd, mainvar, IDP_Id(prop));
+ BLO_expand(expander, IDP_Id(prop));
break;
case IDP_IDPARRAY: {
IDProperty *idp_array = IDP_IDPArray(prop);
for (int i = 0; i < prop->len; i++) {
- expand_idprops(fd, mainvar, &idp_array[i]);
+ expand_idprops(expander, &idp_array[i]);
}
break;
}
case IDP_GROUP:
LISTBASE_FOREACH (IDProperty *, loop, &prop->data.group) {
- expand_idprops(fd, mainvar, loop);
+ expand_idprops(expander, loop);
}
break;
}
}
-static void expand_id(FileData *fd, Main *mainvar, ID *id);
-static void expand_nodetree(FileData *fd, Main *mainvar, bNodeTree *ntree);
-static void expand_collection(FileData *fd, Main *mainvar, Collection *collection);
+static void expand_id(BlendExpander *expander, ID *id);
+static void expand_nodetree(BlendExpander *expander, bNodeTree *ntree);
+static void expand_collection(BlendExpander *expander, Collection *collection);
-static void expand_id_embedded_id(FileData *fd, Main *mainvar, ID *id)
+static void expand_id_embedded_id(BlendExpander *expander, ID *id)
{
/* Handle 'private IDs'. */
bNodeTree *nodetree = ntreeFromID(id);
if (nodetree != NULL) {
- expand_id(fd, mainvar, &nodetree->id);
- expand_nodetree(fd, mainvar, nodetree);
+ expand_id(expander, &nodetree->id);
+ expand_nodetree(expander, nodetree);
}
if (GS(id->name) == ID_SCE) {
Scene *scene = (Scene *)id;
if (scene->master_collection != NULL) {
- expand_id(fd, mainvar, &scene->master_collection->id);
- expand_collection(fd, mainvar, scene->master_collection);
+ expand_id(expander, &scene->master_collection->id);
+ expand_collection(expander, scene->master_collection);
}
}
}
-static void expand_id(FileData *fd, Main *mainvar, ID *id)
+static void expand_id(BlendExpander *expander, ID *id)
{
- expand_idprops(fd, mainvar, id->properties);
+ expand_idprops(expander, id->properties);
if (id->override_library) {
- expand_doit(fd, mainvar, id->override_library->reference);
- expand_doit(fd, mainvar, id->override_library->storage);
+ BLO_expand(expander, id->override_library->reference);
+ BLO_expand(expander, id->override_library->storage);
}
AnimData *adt = BKE_animdata_from_id(id);
if (adt != NULL) {
- expand_animdata(fd, mainvar, adt);
+ expand_animdata(expander, adt);
}
- expand_id_embedded_id(fd, mainvar, id);
+ expand_id_embedded_id(expander, id);
}
-static void expand_action(FileData *fd, Main *mainvar, bAction *act)
+static void expand_action(BlendExpander *expander, bAction *act)
{
bActionChannel *chan;
// XXX deprecated - old animation system --------------
for (chan = act->chanbase.first; chan; chan = chan->next) {
- expand_doit(fd, mainvar, chan->ipo);
- expand_constraint_channels(fd, mainvar, &chan->constraintChannels);
+ BLO_expand(expander, chan->ipo);
+ expand_constraint_channels(expander, &chan->constraintChannels);
}
// ---------------------------------------------------
/* F-Curves in Action */
- expand_fcurves(fd, mainvar, &act->curves);
+ expand_fcurves(expander, &act->curves);
LISTBASE_FOREACH (TimeMarker *, marker, &act->markers) {
if (marker->camera) {
- expand_doit(fd, mainvar, marker->camera);
+ BLO_expand(expander, marker->camera);
}
}
}
-static void expand_keyingsets(FileData *fd, Main *mainvar, ListBase *list)
+static void expand_keyingsets(BlendExpander *expander, ListBase *list)
{
KeyingSet *ks;
KS_Path *ksp;
@@ -10876,39 +10698,39 @@ static void expand_keyingsets(FileData *fd, Main *mainvar, ListBase *list)
/* expand the ID-pointers in KeyingSets's paths */
for (ks = list->first; ks; ks = ks->next) {
for (ksp = ks->paths.first; ksp; ksp = ksp->next) {
- expand_doit(fd, mainvar, ksp->id);
+ BLO_expand(expander, ksp->id);
}
}
}
-static void expand_particlesettings(FileData *fd, Main *mainvar, ParticleSettings *part)
+static void expand_particlesettings(BlendExpander *expander, ParticleSettings *part)
{
int a;
- expand_doit(fd, mainvar, part->instance_object);
- expand_doit(fd, mainvar, part->instance_collection);
- expand_doit(fd, mainvar, part->force_group);
- expand_doit(fd, mainvar, part->bb_ob);
- expand_doit(fd, mainvar, part->collision_group);
+ BLO_expand(expander, part->instance_object);
+ BLO_expand(expander, part->instance_collection);
+ BLO_expand(expander, part->force_group);
+ BLO_expand(expander, part->bb_ob);
+ BLO_expand(expander, part->collision_group);
for (a = 0; a < MAX_MTEX; a++) {
if (part->mtex[a]) {
- expand_doit(fd, mainvar, part->mtex[a]->tex);
- expand_doit(fd, mainvar, part->mtex[a]->object);
+ BLO_expand(expander, part->mtex[a]->tex);
+ BLO_expand(expander, part->mtex[a]->object);
}
}
if (part->effector_weights) {
- expand_doit(fd, mainvar, part->effector_weights->group);
+ BLO_expand(expander, part->effector_weights->group);
}
if (part->pd) {
- expand_doit(fd, mainvar, part->pd->tex);
- expand_doit(fd, mainvar, part->pd->f_source);
+ BLO_expand(expander, part->pd->tex);
+ BLO_expand(expander, part->pd->f_source);
}
if (part->pd2) {
- expand_doit(fd, mainvar, part->pd2->tex);
- expand_doit(fd, mainvar, part->pd2->f_source);
+ BLO_expand(expander, part->pd2->tex);
+ BLO_expand(expander, part->pd2->f_source);
}
if (part->boids) {
@@ -10919,58 +10741,58 @@ static void expand_particlesettings(FileData *fd, Main *mainvar, ParticleSetting
for (rule = state->rules.first; rule; rule = rule->next) {
if (rule->type == eBoidRuleType_Avoid) {
BoidRuleGoalAvoid *gabr = (BoidRuleGoalAvoid *)rule;
- expand_doit(fd, mainvar, gabr->ob);
+ BLO_expand(expander, gabr->ob);
}
else if (rule->type == eBoidRuleType_FollowLeader) {
BoidRuleFollowLeader *flbr = (BoidRuleFollowLeader *)rule;
- expand_doit(fd, mainvar, flbr->ob);
+ BLO_expand(expander, flbr->ob);
}
}
}
}
LISTBASE_FOREACH (ParticleDupliWeight *, dw, &part->instance_weights) {
- expand_doit(fd, mainvar, dw->ob);
+ BLO_expand(expander, dw->ob);
}
}
-static void expand_collection(FileData *fd, Main *mainvar, Collection *collection)
+static void expand_collection(BlendExpander *expander, Collection *collection)
{
LISTBASE_FOREACH (CollectionObject *, cob, &collection->gobject) {
- expand_doit(fd, mainvar, cob->ob);
+ BLO_expand(expander, cob->ob);
}
LISTBASE_FOREACH (CollectionChild *, child, &collection->children) {
- expand_doit(fd, mainvar, child->collection);
+ BLO_expand(expander, child->collection);
}
#ifdef USE_COLLECTION_COMPAT_28
if (collection->collection != NULL) {
- expand_scene_collection(fd, mainvar, collection->collection);
+ expand_scene_collection(expander, collection->collection);
}
#endif
}
-static void expand_key(FileData *fd, Main *mainvar, Key *key)
+static void expand_key(BlendExpander *expander, Key *key)
{
- expand_doit(fd, mainvar, key->ipo); // XXX deprecated - old animation system
+ BLO_expand(expander, key->ipo); // XXX deprecated - old animation system
}
-static void expand_node_socket(FileData *fd, Main *mainvar, bNodeSocket *sock)
+static void expand_node_socket(BlendExpander *expander, bNodeSocket *sock)
{
- expand_idprops(fd, mainvar, sock->prop);
+ expand_idprops(expander, sock->prop);
if (sock->default_value != NULL) {
switch ((eNodeSocketDatatype)sock->type) {
case SOCK_OBJECT: {
bNodeSocketValueObject *default_value = sock->default_value;
- expand_doit(fd, mainvar, default_value->value);
+ BLO_expand(expander, default_value->value);
break;
}
case SOCK_IMAGE: {
bNodeSocketValueImage *default_value = sock->default_value;
- expand_doit(fd, mainvar, default_value->value);
+ BLO_expand(expander, default_value->value);
break;
}
case SOCK_FLOAT:
@@ -10991,155 +10813,145 @@ static void expand_node_socket(FileData *fd, Main *mainvar, bNodeSocket *sock)
}
}
-static void expand_node_sockets(FileData *fd, Main *mainvar, ListBase *sockets)
+static void expand_node_sockets(BlendExpander *expander, ListBase *sockets)
{
LISTBASE_FOREACH (bNodeSocket *, sock, sockets) {
- expand_node_socket(fd, mainvar, sock);
+ expand_node_socket(expander, sock);
}
}
-static void expand_nodetree(FileData *fd, Main *mainvar, bNodeTree *ntree)
+static void expand_nodetree(BlendExpander *expander, bNodeTree *ntree)
{
bNode *node;
if (ntree->gpd) {
- expand_doit(fd, mainvar, ntree->gpd);
+ BLO_expand(expander, ntree->gpd);
}
for (node = ntree->nodes.first; node; node = node->next) {
if (node->id && node->type != CMP_NODE_R_LAYERS) {
- expand_doit(fd, mainvar, node->id);
+ BLO_expand(expander, node->id);
}
- expand_idprops(fd, mainvar, node->prop);
+ expand_idprops(expander, node->prop);
- expand_node_sockets(fd, mainvar, &node->inputs);
- expand_node_sockets(fd, mainvar, &node->outputs);
+ expand_node_sockets(expander, &node->inputs);
+ expand_node_sockets(expander, &node->outputs);
}
- expand_node_sockets(fd, mainvar, &ntree->inputs);
- expand_node_sockets(fd, mainvar, &ntree->outputs);
+ expand_node_sockets(expander, &ntree->inputs);
+ expand_node_sockets(expander, &ntree->outputs);
}
-static void expand_texture(FileData *fd, Main *mainvar, Tex *tex)
+static void expand_texture(BlendExpander *expander, Tex *tex)
{
- expand_doit(fd, mainvar, tex->ima);
- expand_doit(fd, mainvar, tex->ipo); // XXX deprecated - old animation system
+ BLO_expand(expander, tex->ima);
+ BLO_expand(expander, tex->ipo); // XXX deprecated - old animation system
}
-static void expand_brush(FileData *fd, Main *mainvar, Brush *brush)
+static void expand_brush(BlendExpander *expander, Brush *brush)
{
- expand_doit(fd, mainvar, brush->mtex.tex);
- expand_doit(fd, mainvar, brush->mask_mtex.tex);
- expand_doit(fd, mainvar, brush->clone.image);
- expand_doit(fd, mainvar, brush->paint_curve);
+ BLO_expand(expander, brush->mtex.tex);
+ BLO_expand(expander, brush->mask_mtex.tex);
+ BLO_expand(expander, brush->clone.image);
+ BLO_expand(expander, brush->paint_curve);
if (brush->gpencil_settings != NULL) {
- expand_doit(fd, mainvar, brush->gpencil_settings->material);
+ BLO_expand(expander, brush->gpencil_settings->material);
}
}
-static void expand_material(FileData *fd, Main *mainvar, Material *ma)
+static void expand_material(BlendExpander *expander, Material *ma)
{
- expand_doit(fd, mainvar, ma->ipo); // XXX deprecated - old animation system
+ BLO_expand(expander, ma->ipo); // XXX deprecated - old animation system
if (ma->gp_style) {
MaterialGPencilStyle *gp_style = ma->gp_style;
- expand_doit(fd, mainvar, gp_style->sima);
- expand_doit(fd, mainvar, gp_style->ima);
+ BLO_expand(expander, gp_style->sima);
+ BLO_expand(expander, gp_style->ima);
}
}
-static void expand_light(FileData *fd, Main *mainvar, Light *la)
+static void expand_light(BlendExpander *expander, Light *la)
{
- expand_doit(fd, mainvar, la->ipo); // XXX deprecated - old animation system
+ BLO_expand(expander, la->ipo); // XXX deprecated - old animation system
}
-static void expand_lattice(FileData *fd, Main *mainvar, Lattice *lt)
+static void expand_lattice(BlendExpander *expander, Lattice *lt)
{
- expand_doit(fd, mainvar, lt->ipo); // XXX deprecated - old animation system
- expand_doit(fd, mainvar, lt->key);
+ BLO_expand(expander, lt->ipo); // XXX deprecated - old animation system
+ BLO_expand(expander, lt->key);
}
-static void expand_world(FileData *fd, Main *mainvar, World *wrld)
+static void expand_world(BlendExpander *expander, World *wrld)
{
- expand_doit(fd, mainvar, wrld->ipo); // XXX deprecated - old animation system
+ BLO_expand(expander, wrld->ipo); // XXX deprecated - old animation system
}
-static void expand_mball(FileData *fd, Main *mainvar, MetaBall *mb)
+static void expand_mball(BlendExpander *expander, MetaBall *mb)
{
int a;
for (a = 0; a < mb->totcol; a++) {
- expand_doit(fd, mainvar, mb->mat[a]);
+ BLO_expand(expander, mb->mat[a]);
}
}
-static void expand_curve(FileData *fd, Main *mainvar, Curve *cu)
+static void expand_curve(BlendExpander *expander, Curve *cu)
{
int a;
for (a = 0; a < cu->totcol; a++) {
- expand_doit(fd, mainvar, cu->mat[a]);
+ BLO_expand(expander, cu->mat[a]);
}
- expand_doit(fd, mainvar, cu->vfont);
- expand_doit(fd, mainvar, cu->vfontb);
- expand_doit(fd, mainvar, cu->vfonti);
- expand_doit(fd, mainvar, cu->vfontbi);
- expand_doit(fd, mainvar, cu->key);
- expand_doit(fd, mainvar, cu->ipo); // XXX deprecated - old animation system
- expand_doit(fd, mainvar, cu->bevobj);
- expand_doit(fd, mainvar, cu->taperobj);
- expand_doit(fd, mainvar, cu->textoncurve);
+ BLO_expand(expander, cu->vfont);
+ BLO_expand(expander, cu->vfontb);
+ BLO_expand(expander, cu->vfonti);
+ BLO_expand(expander, cu->vfontbi);
+ BLO_expand(expander, cu->key);
+ BLO_expand(expander, cu->ipo); // XXX deprecated - old animation system
+ BLO_expand(expander, cu->bevobj);
+ BLO_expand(expander, cu->taperobj);
+ BLO_expand(expander, cu->textoncurve);
}
-static void expand_mesh(FileData *fd, Main *mainvar, Mesh *me)
+static void expand_mesh(BlendExpander *expander, Mesh *me)
{
int a;
for (a = 0; a < me->totcol; a++) {
- expand_doit(fd, mainvar, me->mat[a]);
+ BLO_expand(expander, me->mat[a]);
}
- expand_doit(fd, mainvar, me->key);
- expand_doit(fd, mainvar, me->texcomesh);
+ BLO_expand(expander, me->key);
+ BLO_expand(expander, me->texcomesh);
}
-/* temp struct used to transport needed info to expand_constraint_cb() */
-typedef struct tConstraintExpandData {
- FileData *fd;
- Main *mainvar;
-} tConstraintExpandData;
/* callback function used to expand constraint ID-links */
static void expand_constraint_cb(bConstraint *UNUSED(con),
ID **idpoin,
bool UNUSED(is_reference),
void *userdata)
{
- tConstraintExpandData *ced = (tConstraintExpandData *)userdata;
- expand_doit(ced->fd, ced->mainvar, *idpoin);
+ BlendExpander *expander = userdata;
+ BLO_expand(expander, *idpoin);
}
-static void expand_constraints(FileData *fd, Main *mainvar, ListBase *lb)
+static void expand_constraints(BlendExpander *expander, ListBase *lb)
{
- tConstraintExpandData ced;
bConstraint *curcon;
- /* relink all ID-blocks used by the constraints */
- ced.fd = fd;
- ced.mainvar = mainvar;
-
- BKE_constraints_id_loop(lb, expand_constraint_cb, &ced);
+ BKE_constraints_id_loop(lb, expand_constraint_cb, expander);
/* deprecated manual expansion stuff */
for (curcon = lb->first; curcon; curcon = curcon->next) {
if (curcon->ipo) {
- expand_doit(fd, mainvar, curcon->ipo); // XXX deprecated - old animation system
+ BLO_expand(expander, curcon->ipo); // XXX deprecated - old animation system
}
}
}
-static void expand_pose(FileData *fd, Main *mainvar, bPose *pose)
+static void expand_pose(BlendExpander *expander, bPose *pose)
{
bPoseChannel *chan;
@@ -11148,25 +10960,25 @@ static void expand_pose(FileData *fd, Main *mainvar, bPose *pose)
}
for (chan = pose->chanbase.first; chan; chan = chan->next) {
- expand_constraints(fd, mainvar, &chan->constraints);
- expand_idprops(fd, mainvar, chan->prop);
- expand_doit(fd, mainvar, chan->custom);
+ expand_constraints(expander, &chan->constraints);
+ expand_idprops(expander, chan->prop);
+ BLO_expand(expander, chan->custom);
}
}
-static void expand_bones(FileData *fd, Main *mainvar, Bone *bone)
+static void expand_bones(BlendExpander *expander, Bone *bone)
{
- expand_idprops(fd, mainvar, bone->prop);
+ expand_idprops(expander, bone->prop);
LISTBASE_FOREACH (Bone *, curBone, &bone->childbase) {
- expand_bones(fd, mainvar, curBone);
+ expand_bones(expander, curBone);
}
}
-static void expand_armature(FileData *fd, Main *mainvar, bArmature *arm)
+static void expand_armature(BlendExpander *expander, bArmature *arm)
{
LISTBASE_FOREACH (Bone *, curBone, &arm->bonebase) {
- expand_bones(fd, mainvar, curBone);
+ expand_bones(expander, curBone);
}
}
@@ -11175,298 +10987,268 @@ static void expand_object_expandModifiers(void *userData,
ID **idpoin,
int UNUSED(cb_flag))
{
- struct {
- FileData *fd;
- Main *mainvar;
- } *data = userData;
-
- FileData *fd = data->fd;
- Main *mainvar = data->mainvar;
-
- expand_doit(fd, mainvar, *idpoin);
+ BlendExpander *expander = userData;
+ BLO_expand(expander, *idpoin);
}
-static void expand_object(FileData *fd, Main *mainvar, Object *ob)
+static void expand_object(BlendExpander *expander, Object *ob)
{
ParticleSystem *psys;
bActionStrip *strip;
PartEff *paf;
int a;
- expand_doit(fd, mainvar, ob->data);
+ BLO_expand(expander, ob->data);
/* expand_object_expandModifier() */
if (ob->modifiers.first) {
- struct {
- FileData *fd;
- Main *mainvar;
- } data;
- data.fd = fd;
- data.mainvar = mainvar;
-
- BKE_modifiers_foreach_ID_link(ob, expand_object_expandModifiers, (void *)&data);
+ BKE_modifiers_foreach_ID_link(ob, expand_object_expandModifiers, expander);
}
/* expand_object_expandModifier() */
if (ob->greasepencil_modifiers.first) {
- struct {
- FileData *fd;
- Main *mainvar;
- } data;
- data.fd = fd;
- data.mainvar = mainvar;
-
- BKE_gpencil_modifiers_foreach_ID_link(ob, expand_object_expandModifiers, (void *)&data);
+ BKE_gpencil_modifiers_foreach_ID_link(ob, expand_object_expandModifiers, expander);
}
/* expand_object_expandShaderFx() */
if (ob->shader_fx.first) {
- struct {
- FileData *fd;
- Main *mainvar;
- } data;
- data.fd = fd;
- data.mainvar = mainvar;
-
- BKE_shaderfx_foreach_ID_link(ob, expand_object_expandModifiers, (void *)&data);
+ BKE_shaderfx_foreach_ID_link(ob, expand_object_expandModifiers, expander);
}
- expand_pose(fd, mainvar, ob->pose);
- expand_doit(fd, mainvar, ob->poselib);
- expand_constraints(fd, mainvar, &ob->constraints);
+ expand_pose(expander, ob->pose);
+ BLO_expand(expander, ob->poselib);
+ expand_constraints(expander, &ob->constraints);
- expand_doit(fd, mainvar, ob->gpd);
+ BLO_expand(expander, ob->gpd);
// XXX deprecated - old animation system (for version patching only)
- expand_doit(fd, mainvar, ob->ipo);
- expand_doit(fd, mainvar, ob->action);
+ BLO_expand(expander, ob->ipo);
+ BLO_expand(expander, ob->action);
- expand_constraint_channels(fd, mainvar, &ob->constraintChannels);
+ expand_constraint_channels(expander, &ob->constraintChannels);
for (strip = ob->nlastrips.first; strip; strip = strip->next) {
- expand_doit(fd, mainvar, strip->object);
- expand_doit(fd, mainvar, strip->act);
- expand_doit(fd, mainvar, strip->ipo);
+ BLO_expand(expander, strip->object);
+ BLO_expand(expander, strip->act);
+ BLO_expand(expander, strip->ipo);
}
// XXX deprecated - old animation system (for version patching only)
for (a = 0; a < ob->totcol; a++) {
- expand_doit(fd, mainvar, ob->mat[a]);
+ BLO_expand(expander, ob->mat[a]);
}
paf = blo_do_version_give_parteff_245(ob);
if (paf && paf->group) {
- expand_doit(fd, mainvar, paf->group);
+ BLO_expand(expander, paf->group);
}
if (ob->instance_collection) {
- expand_doit(fd, mainvar, ob->instance_collection);
+ BLO_expand(expander, ob->instance_collection);
}
if (ob->proxy) {
- expand_doit(fd, mainvar, ob->proxy);
+ BLO_expand(expander, ob->proxy);
}
if (ob->proxy_group) {
- expand_doit(fd, mainvar, ob->proxy_group);
+ BLO_expand(expander, ob->proxy_group);
}
for (psys = ob->particlesystem.first; psys; psys = psys->next) {
- expand_doit(fd, mainvar, psys->part);
+ BLO_expand(expander, psys->part);
}
if (ob->pd) {
- expand_doit(fd, mainvar, ob->pd->tex);
- expand_doit(fd, mainvar, ob->pd->f_source);
+ BLO_expand(expander, ob->pd->tex);
+ BLO_expand(expander, ob->pd->f_source);
}
if (ob->soft) {
- expand_doit(fd, mainvar, ob->soft->collision_group);
+ BLO_expand(expander, ob->soft->collision_group);
if (ob->soft->effector_weights) {
- expand_doit(fd, mainvar, ob->soft->effector_weights->group);
+ BLO_expand(expander, ob->soft->effector_weights->group);
}
}
if (ob->rigidbody_constraint) {
- expand_doit(fd, mainvar, ob->rigidbody_constraint->ob1);
- expand_doit(fd, mainvar, ob->rigidbody_constraint->ob2);
+ BLO_expand(expander, ob->rigidbody_constraint->ob1);
+ BLO_expand(expander, ob->rigidbody_constraint->ob2);
}
if (ob->currentlod) {
LodLevel *level;
for (level = ob->lodlevels.first; level; level = level->next) {
- expand_doit(fd, mainvar, level->source);
+ BLO_expand(expander, level->source);
}
}
}
#ifdef USE_COLLECTION_COMPAT_28
-static void expand_scene_collection(FileData *fd, Main *mainvar, SceneCollection *sc)
+static void expand_scene_collection(BlendExpander *expander, SceneCollection *sc)
{
LISTBASE_FOREACH (LinkData *, link, &sc->objects) {
- expand_doit(fd, mainvar, link->data);
+ BLO_expand(expander, link->data);
}
LISTBASE_FOREACH (SceneCollection *, nsc, &sc->scene_collections) {
- expand_scene_collection(fd, mainvar, nsc);
+ expand_scene_collection(expander, nsc);
}
}
#endif
-static void expand_scene(FileData *fd, Main *mainvar, Scene *sce)
+static void expand_scene(BlendExpander *expander, Scene *sce)
{
SceneRenderLayer *srl;
FreestyleModuleConfig *module;
FreestyleLineSet *lineset;
LISTBASE_FOREACH (Base *, base_legacy, &sce->base) {
- expand_doit(fd, mainvar, base_legacy->object);
+ BLO_expand(expander, base_legacy->object);
}
- expand_doit(fd, mainvar, sce->camera);
- expand_doit(fd, mainvar, sce->world);
+ BLO_expand(expander, sce->camera);
+ BLO_expand(expander, sce->world);
- expand_keyingsets(fd, mainvar, &sce->keyingsets);
+ expand_keyingsets(expander, &sce->keyingsets);
if (sce->set) {
- expand_doit(fd, mainvar, sce->set);
+ BLO_expand(expander, sce->set);
}
for (srl = sce->r.layers.first; srl; srl = srl->next) {
- expand_doit(fd, mainvar, srl->mat_override);
+ BLO_expand(expander, srl->mat_override);
for (module = srl->freestyleConfig.modules.first; module; module = module->next) {
if (module->script) {
- expand_doit(fd, mainvar, module->script);
+ BLO_expand(expander, module->script);
}
}
for (lineset = srl->freestyleConfig.linesets.first; lineset; lineset = lineset->next) {
if (lineset->group) {
- expand_doit(fd, mainvar, lineset->group);
+ BLO_expand(expander, lineset->group);
}
- expand_doit(fd, mainvar, lineset->linestyle);
+ BLO_expand(expander, lineset->linestyle);
}
}
LISTBASE_FOREACH (ViewLayer *, view_layer, &sce->view_layers) {
- expand_idprops(fd, mainvar, view_layer->id_properties);
+ expand_idprops(expander, view_layer->id_properties);
for (module = view_layer->freestyle_config.modules.first; module; module = module->next) {
if (module->script) {
- expand_doit(fd, mainvar, module->script);
+ BLO_expand(expander, module->script);
}
}
for (lineset = view_layer->freestyle_config.linesets.first; lineset; lineset = lineset->next) {
if (lineset->group) {
- expand_doit(fd, mainvar, lineset->group);
+ BLO_expand(expander, lineset->group);
}
- expand_doit(fd, mainvar, lineset->linestyle);
+ BLO_expand(expander, lineset->linestyle);
}
}
if (sce->gpd) {
- expand_doit(fd, mainvar, sce->gpd);
+ BLO_expand(expander, sce->gpd);
}
if (sce->ed) {
Sequence *seq;
SEQ_BEGIN (sce->ed, seq) {
- expand_idprops(fd, mainvar, seq->prop);
+ expand_idprops(expander, seq->prop);
if (seq->scene) {
- expand_doit(fd, mainvar, seq->scene);
+ BLO_expand(expander, seq->scene);
}
if (seq->scene_camera) {
- expand_doit(fd, mainvar, seq->scene_camera);
+ BLO_expand(expander, seq->scene_camera);
}
if (seq->clip) {
- expand_doit(fd, mainvar, seq->clip);
+ BLO_expand(expander, seq->clip);
}
if (seq->mask) {
- expand_doit(fd, mainvar, seq->mask);
+ BLO_expand(expander, seq->mask);
}
if (seq->sound) {
- expand_doit(fd, mainvar, seq->sound);
+ BLO_expand(expander, seq->sound);
}
if (seq->type == SEQ_TYPE_TEXT && seq->effectdata) {
TextVars *data = seq->effectdata;
- expand_doit(fd, mainvar, data->text_font);
+ BLO_expand(expander, data->text_font);
}
}
SEQ_END;
}
if (sce->rigidbody_world) {
- expand_doit(fd, mainvar, sce->rigidbody_world->group);
- expand_doit(fd, mainvar, sce->rigidbody_world->constraints);
+ BLO_expand(expander, sce->rigidbody_world->group);
+ BLO_expand(expander, sce->rigidbody_world->constraints);
}
LISTBASE_FOREACH (TimeMarker *, marker, &sce->markers) {
if (marker->camera) {
- expand_doit(fd, mainvar, marker->camera);
+ BLO_expand(expander, marker->camera);
}
}
- expand_doit(fd, mainvar, sce->clip);
+ BLO_expand(expander, sce->clip);
#ifdef USE_COLLECTION_COMPAT_28
if (sce->collection) {
- expand_scene_collection(fd, mainvar, sce->collection);
+ expand_scene_collection(expander, sce->collection);
}
#endif
if (sce->r.bake.cage_object) {
- expand_doit(fd, mainvar, sce->r.bake.cage_object);
+ BLO_expand(expander, sce->r.bake.cage_object);
}
}
-static void expand_camera(FileData *fd, Main *mainvar, Camera *ca)
+static void expand_camera(BlendExpander *expander, Camera *ca)
{
- expand_doit(fd, mainvar, ca->ipo); // XXX deprecated - old animation system
+ BLO_expand(expander, ca->ipo); // XXX deprecated - old animation system
LISTBASE_FOREACH (CameraBGImage *, bgpic, &ca->bg_images) {
if (bgpic->source == CAM_BGIMG_SOURCE_IMAGE) {
- expand_doit(fd, mainvar, bgpic->ima);
+ BLO_expand(expander, bgpic->ima);
}
else if (bgpic->source == CAM_BGIMG_SOURCE_MOVIE) {
- expand_doit(fd, mainvar, bgpic->ima);
+ BLO_expand(expander, bgpic->ima);
}
}
}
-static void expand_cachefile(FileData *UNUSED(fd),
- Main *UNUSED(mainvar),
- CacheFile *UNUSED(cache_file))
+static void expand_cachefile(BlendExpander *UNUSED(expander), CacheFile *UNUSED(cache_file))
{
}
-static void expand_speaker(FileData *fd, Main *mainvar, Speaker *spk)
+static void expand_speaker(BlendExpander *expander, Speaker *spk)
{
- expand_doit(fd, mainvar, spk->sound);
+ BLO_expand(expander, spk->sound);
}
-static void expand_sound(FileData *fd, Main *mainvar, bSound *snd)
+static void expand_sound(BlendExpander *expander, bSound *snd)
{
- expand_doit(fd, mainvar, snd->ipo); // XXX deprecated - old animation system
+ BLO_expand(expander, snd->ipo); // XXX deprecated - old animation system
}
-static void expand_lightprobe(FileData *UNUSED(fd), Main *UNUSED(mainvar), LightProbe *UNUSED(prb))
+static void expand_lightprobe(BlendExpander *UNUSED(expander), LightProbe *UNUSED(prb))
{
}
-static void expand_movieclip(FileData *UNUSED(fd), Main *UNUSED(mainvar), MovieClip *UNUSED(clip))
+static void expand_movieclip(BlendExpander *UNUSED(expander), MovieClip *UNUSED(clip))
{
}
-static void expand_mask_parent(FileData *fd, Main *mainvar, MaskParent *parent)
+static void expand_mask_parent(BlendExpander *expander, MaskParent *parent)
{
if (parent->id) {
- expand_doit(fd, mainvar, parent->id);
+ BLO_expand(expander, parent->id);
}
}
-static void expand_mask(FileData *fd, Main *mainvar, Mask *mask)
+static void expand_mask(BlendExpander *expander, Mask *mask)
{
MaskLayer *mask_layer;
@@ -11479,98 +11261,98 @@ static void expand_mask(FileData *fd, Main *mainvar, Mask *mask)
for (i = 0; i < spline->tot_point; i++) {
MaskSplinePoint *point = &spline->points[i];
- expand_mask_parent(fd, mainvar, &point->parent);
+ expand_mask_parent(expander, &point->parent);
}
- expand_mask_parent(fd, mainvar, &spline->parent);
+ expand_mask_parent(expander, &spline->parent);
}
}
}
-static void expand_linestyle(FileData *fd, Main *mainvar, FreestyleLineStyle *linestyle)
+static void expand_linestyle(BlendExpander *expander, FreestyleLineStyle *linestyle)
{
int a;
LineStyleModifier *m;
for (a = 0; a < MAX_MTEX; a++) {
if (linestyle->mtex[a]) {
- expand_doit(fd, mainvar, linestyle->mtex[a]->tex);
- expand_doit(fd, mainvar, linestyle->mtex[a]->object);
+ BLO_expand(expander, linestyle->mtex[a]->tex);
+ BLO_expand(expander, linestyle->mtex[a]->object);
}
}
for (m = linestyle->color_modifiers.first; m; m = m->next) {
if (m->type == LS_MODIFIER_DISTANCE_FROM_OBJECT) {
- expand_doit(fd, mainvar, ((LineStyleColorModifier_DistanceFromObject *)m)->target);
+ BLO_expand(expander, ((LineStyleColorModifier_DistanceFromObject *)m)->target);
}
}
for (m = linestyle->alpha_modifiers.first; m; m = m->next) {
if (m->type == LS_MODIFIER_DISTANCE_FROM_OBJECT) {
- expand_doit(fd, mainvar, ((LineStyleAlphaModifier_DistanceFromObject *)m)->target);
+ BLO_expand(expander, ((LineStyleAlphaModifier_DistanceFromObject *)m)->target);
}
}
for (m = linestyle->thickness_modifiers.first; m; m = m->next) {
if (m->type == LS_MODIFIER_DISTANCE_FROM_OBJECT) {
- expand_doit(fd, mainvar, ((LineStyleThicknessModifier_DistanceFromObject *)m)->target);
+ BLO_expand(expander, ((LineStyleThicknessModifier_DistanceFromObject *)m)->target);
}
}
}
-static void expand_gpencil(FileData *fd, Main *mainvar, bGPdata *gpd)
+static void expand_gpencil(BlendExpander *expander, bGPdata *gpd)
{
LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
- expand_doit(fd, mainvar, gpl->parent);
+ BLO_expand(expander, gpl->parent);
}
for (int a = 0; a < gpd->totcol; a++) {
- expand_doit(fd, mainvar, gpd->mat[a]);
+ BLO_expand(expander, gpd->mat[a]);
}
}
-static void expand_workspace(FileData *fd, Main *mainvar, WorkSpace *workspace)
+static void expand_workspace(BlendExpander *expander, WorkSpace *workspace)
{
LISTBASE_FOREACH (WorkSpaceLayout *, layout, &workspace->layouts) {
- expand_doit(fd, mainvar, BKE_workspace_layout_screen_get(layout));
+ BLO_expand(expander, BKE_workspace_layout_screen_get(layout));
}
}
-static void expand_hair(FileData *fd, Main *mainvar, Hair *hair)
+static void expand_hair(BlendExpander *expander, Hair *hair)
{
for (int a = 0; a < hair->totcol; a++) {
- expand_doit(fd, mainvar, hair->mat[a]);
+ BLO_expand(expander, hair->mat[a]);
}
if (hair->adt) {
- expand_animdata(fd, mainvar, hair->adt);
+ expand_animdata(expander, hair->adt);
}
}
-static void expand_pointcloud(FileData *fd, Main *mainvar, PointCloud *pointcloud)
+static void expand_pointcloud(BlendExpander *expander, PointCloud *pointcloud)
{
for (int a = 0; a < pointcloud->totcol; a++) {
- expand_doit(fd, mainvar, pointcloud->mat[a]);
+ BLO_expand(expander, pointcloud->mat[a]);
}
if (pointcloud->adt) {
- expand_animdata(fd, mainvar, pointcloud->adt);
+ expand_animdata(expander, pointcloud->adt);
}
}
-static void expand_volume(FileData *fd, Main *mainvar, Volume *volume)
+static void expand_volume(BlendExpander *expander, Volume *volume)
{
for (int a = 0; a < volume->totcol; a++) {
- expand_doit(fd, mainvar, volume->mat[a]);
+ BLO_expand(expander, volume->mat[a]);
}
if (volume->adt) {
- expand_animdata(fd, mainvar, volume->adt);
+ expand_animdata(expander, volume->adt);
}
}
-static void expand_simulation(FileData *fd, Main *mainvar, Simulation *simulation)
+static void expand_simulation(BlendExpander *expander, Simulation *simulation)
{
if (simulation->adt) {
- expand_animdata(fd, mainvar, simulation->adt);
+ expand_animdata(expander, simulation->adt);
}
}
@@ -11599,6 +11381,8 @@ void BLO_expand_main(void *fdhandle, Main *mainvar)
int a;
bool do_it = true;
+ BlendExpander expander = {fd, mainvar};
+
while (do_it) {
do_it = false;
@@ -11607,104 +11391,104 @@ void BLO_expand_main(void *fdhandle, Main *mainvar)
id = lbarray[a]->first;
while (id) {
if (id->tag & LIB_TAG_NEED_EXPAND) {
- expand_id(fd, mainvar, id);
+ expand_id(&expander, id);
switch (GS(id->name)) {
case ID_OB:
- expand_object(fd, mainvar, (Object *)id);
+ expand_object(&expander, (Object *)id);
break;
case ID_ME:
- expand_mesh(fd, mainvar, (Mesh *)id);
+ expand_mesh(&expander, (Mesh *)id);
break;
case ID_CU:
- expand_curve(fd, mainvar, (Curve *)id);
+ expand_curve(&expander, (Curve *)id);
break;
case ID_MB:
- expand_mball(fd, mainvar, (MetaBall *)id);
+ expand_mball(&expander, (MetaBall *)id);
break;
case ID_SCE:
- expand_scene(fd, mainvar, (Scene *)id);
+ expand_scene(&expander, (Scene *)id);
break;
case ID_MA:
- expand_material(fd, mainvar, (Material *)id);
+ expand_material(&expander, (Material *)id);
break;
case ID_TE:
- expand_texture(fd, mainvar, (Tex *)id);
+ expand_texture(&expander, (Tex *)id);
break;
case ID_WO:
- expand_world(fd, mainvar, (World *)id);
+ expand_world(&expander, (World *)id);
break;
case ID_LT:
- expand_lattice(fd, mainvar, (Lattice *)id);
+ expand_lattice(&expander, (Lattice *)id);
break;
case ID_LA:
- expand_light(fd, mainvar, (Light *)id);
+ expand_light(&expander, (Light *)id);
break;
case ID_KE:
- expand_key(fd, mainvar, (Key *)id);
+ expand_key(&expander, (Key *)id);
break;
case ID_CA:
- expand_camera(fd, mainvar, (Camera *)id);
+ expand_camera(&expander, (Camera *)id);
break;
case ID_SPK:
- expand_speaker(fd, mainvar, (Speaker *)id);
+ expand_speaker(&expander, (Speaker *)id);
break;
case ID_SO:
- expand_sound(fd, mainvar, (bSound *)id);
+ expand_sound(&expander, (bSound *)id);
break;
case ID_LP:
- expand_lightprobe(fd, mainvar, (LightProbe *)id);
+ expand_lightprobe(&expander, (LightProbe *)id);
break;
case ID_AR:
- expand_armature(fd, mainvar, (bArmature *)id);
+ expand_armature(&expander, (bArmature *)id);
break;
case ID_AC:
- expand_action(fd, mainvar, (bAction *)id); // XXX deprecated - old animation system
+ expand_action(&expander, (bAction *)id); // XXX deprecated - old animation system
break;
case ID_GR:
- expand_collection(fd, mainvar, (Collection *)id);
+ expand_collection(&expander, (Collection *)id);
break;
case ID_NT:
- expand_nodetree(fd, mainvar, (bNodeTree *)id);
+ expand_nodetree(&expander, (bNodeTree *)id);
break;
case ID_BR:
- expand_brush(fd, mainvar, (Brush *)id);
+ expand_brush(&expander, (Brush *)id);
break;
case ID_IP:
- expand_ipo(fd, mainvar, (Ipo *)id); // XXX deprecated - old animation system
+ expand_ipo(&expander, (Ipo *)id); // XXX deprecated - old animation system
break;
case ID_PA:
- expand_particlesettings(fd, mainvar, (ParticleSettings *)id);
+ expand_particlesettings(&expander, (ParticleSettings *)id);
break;
case ID_MC:
- expand_movieclip(fd, mainvar, (MovieClip *)id);
+ expand_movieclip(&expander, (MovieClip *)id);
break;
case ID_MSK:
- expand_mask(fd, mainvar, (Mask *)id);
+ expand_mask(&expander, (Mask *)id);
break;
case ID_LS:
- expand_linestyle(fd, mainvar, (FreestyleLineStyle *)id);
+ expand_linestyle(&expander, (FreestyleLineStyle *)id);
break;
case ID_GD:
- expand_gpencil(fd, mainvar, (bGPdata *)id);
+ expand_gpencil(&expander, (bGPdata *)id);
break;
case ID_CF:
- expand_cachefile(fd, mainvar, (CacheFile *)id);
+ expand_cachefile(&expander, (CacheFile *)id);
break;
case ID_WS:
- expand_workspace(fd, mainvar, (WorkSpace *)id);
+ expand_workspace(&expander, (WorkSpace *)id);
break;
case ID_HA:
- expand_hair(fd, mainvar, (Hair *)id);
+ expand_hair(&expander, (Hair *)id);
break;
case ID_PT:
- expand_pointcloud(fd, mainvar, (PointCloud *)id);
+ expand_pointcloud(&expander, (PointCloud *)id);
break;
case ID_VO:
- expand_volume(fd, mainvar, (Volume *)id);
+ expand_volume(&expander, (Volume *)id);
break;
case ID_SIM:
- expand_simulation(fd, mainvar, (Simulation *)id);
+ expand_simulation(&expander, (Simulation *)id);
break;
default:
break;
@@ -12052,10 +11836,6 @@ ID *BLO_library_link_named_part(Main *mainl,
* \param idcode: The kind of data-block to link.
* \param name: The name of the data-block (without the 2 char ID prefix).
* \param flag: Options for linking, used for instantiating.
- * \param scene: The scene in which to instantiate objects/collections
- * (if NULL, no instantiation is done).
- * \param v3d: The active 3D viewport.
- * (only to define active layers for instantiated objects & collections, can be NULL).
* \return the linked ID when found.
*/
ID *BLO_library_link_named_part_ex(
@@ -12094,13 +11874,13 @@ static Main *library_link_begin(Main *mainvar, FileData **fd, const char *filepa
}
/**
- * Initialize the BlendHandle for linking library data.
+ * Initialize the #BlendHandle for linking library data.
*
* \param mainvar: The current main database, e.g. #G_MAIN or #CTX_data_main(C).
* \param bh: A blender file handle as returned by
* #BLO_blendhandle_from_file or #BLO_blendhandle_from_memory.
- * \param filepath: Used for relative linking, copied to the \a lib->name.
- * \return the library Main, to be passed to #BLO_library_append_named_part as \a mainl.
+ * \param filepath: Used for relative linking, copied to the `lib->filepath`.
+ * \return the library #Main, to be passed to #BLO_library_link_named_part_ex as \a mainl.
*/
Main *BLO_library_link_begin(Main *mainvar, BlendHandle **bh, const char *filepath)
{
@@ -12134,7 +11914,12 @@ static void split_main_newid(Main *mainptr, Main *main_newid)
}
}
-/* scene and v3d may be NULL. */
+/**
+ * \param scene: The scene in which to instantiate objects/collections
+ * (if NULL, no instantiation is done).
+ * \param v3d: The active 3D viewport.
+ * (only to define active layers for instantiated objects & collections, can be NULL).
+ */
static void library_link_end(Main *mainl,
FileData **fd,
const short flag,
@@ -12160,10 +11945,10 @@ static void library_link_end(Main *mainl,
/* make the lib path relative if required */
if (flag & FILE_RELPATH) {
/* use the full path, this could have been read by other library even */
- BLI_strncpy(curlib->name, curlib->filepath, sizeof(curlib->name));
+ BLI_strncpy(curlib->filepath, curlib->filepath_abs, sizeof(curlib->filepath));
/* uses current .blend file as reference */
- BLI_path_rel(curlib->name, BKE_main_blendfile_path_from_global());
+ BLI_path_rel(curlib->filepath, BKE_main_blendfile_path_from_global());
}
blo_join_main((*fd)->mainlist);
@@ -12215,7 +12000,7 @@ static void library_link_end(Main *mainl,
/* Give a base to loose objects and collections.
* Only directly linked objects & collections are instantiated by
- * `BLO_library_link_named_part_ex()` & co,
+ * #BLO_library_link_named_part_ex & co,
* here we handle indirect ones and other possible edge-cases. */
if (scene) {
add_collections_to_scene(mainvar, bmain, scene, view_layer, v3d, curlib, flag);
@@ -12310,7 +12095,7 @@ static void read_library_linked_id(
"non-linkable data type"),
BKE_idtype_idcode_to_name(GS(id->name)),
id->name + 2,
- mainvar->curlib->filepath,
+ mainvar->curlib->filepath_abs,
library_parent_filepath(mainvar->curlib));
}
@@ -12328,7 +12113,7 @@ static void read_library_linked_id(
TIP_("LIB: %s: '%s' missing from '%s', parent '%s'"),
BKE_idtype_idcode_to_name(GS(id->name)),
id->name + 2,
- mainvar->curlib->filepath,
+ mainvar->curlib->filepath_abs,
library_parent_filepath(mainvar->curlib));
/* Generate a placeholder for this ID (simplified version of read_libblock actually...). */
@@ -12448,22 +12233,22 @@ static FileData *read_library_file_data(FileData *basefd,
blo_reportf_wrap(basefd->reports,
RPT_INFO,
TIP_("Read packed library: '%s', parent '%s'"),
- mainptr->curlib->name,
+ mainptr->curlib->filepath,
library_parent_filepath(mainptr->curlib));
fd = blo_filedata_from_memory(pf->data, pf->size, basefd->reports);
/* Needed for library_append and read_libraries. */
- BLI_strncpy(fd->relabase, mainptr->curlib->filepath, sizeof(fd->relabase));
+ BLI_strncpy(fd->relabase, mainptr->curlib->filepath_abs, sizeof(fd->relabase));
}
else {
/* Read file on disk. */
blo_reportf_wrap(basefd->reports,
RPT_INFO,
TIP_("Read library: '%s', '%s', parent '%s'"),
+ mainptr->curlib->filepath_abs,
mainptr->curlib->filepath,
- mainptr->curlib->name,
library_parent_filepath(mainptr->curlib));
- fd = blo_filedata_from_file(mainptr->curlib->filepath, basefd->reports);
+ fd = blo_filedata_from_file(mainptr->curlib->filepath_abs, basefd->reports);
}
if (fd) {
@@ -12500,7 +12285,7 @@ static FileData *read_library_file_data(FileData *basefd,
if (fd == NULL) {
blo_reportf_wrap(
- basefd->reports, RPT_WARNING, TIP_("Cannot find lib '%s'"), mainptr->curlib->filepath);
+ basefd->reports, RPT_WARNING, TIP_("Cannot find lib '%s'"), mainptr->curlib->filepath_abs);
}
return fd;
@@ -12532,7 +12317,7 @@ static void read_libraries(FileData *basefd, ListBase *mainlist)
#if 0
printf("Reading linked data-blocks from %s (%s)\n",
mainptr->curlib->id.name,
- mainptr->curlib->name);
+ mainptr->curlib->filepath);
#endif
/* Open file if it has not been done yet. */
@@ -12582,10 +12367,10 @@ static void read_libraries(FileData *basefd, ListBase *mainlist)
lib_link_all(mainptr->curlib->filedata, mainptr);
}
- /* Note: No need to call `do_versions_after_linking()` or `BKE_main_id_refcount_recompute()`
+ /* Note: No need to call #do_versions_after_linking() or #BKE_main_id_refcount_recompute()
* here, as this function is only called for library 'subset' data handling, as part of either
- * full blendfile reading (`blo_read_file_internal()`), or libdata linking
- * (`library_link_end()`). */
+ * full blendfile reading (#blo_read_file_internal()), or library-data linking
+ * (#library_link_end()). */
/* Free file data we no longer need. */
if (mainptr->curlib->filedata) {
@@ -12726,7 +12511,7 @@ void BLO_read_pointer_array(BlendDataReader *reader, void **ptr_p)
int file_pointer_size = fd->filesdna->pointer_size;
int current_pointer_size = fd->memsdna->pointer_size;
- /* Overallocation is fine, but might be better to pass the length as parameter. */
+ /* Over-allocation is fine, but might be better to pass the length as parameter. */
int array_size = MEM_allocN_len(orig_array) / file_pointer_size;
void *final_array = NULL;