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.c405
1 files changed, 262 insertions, 143 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 5511a27eba9..d3c391a1595 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -86,6 +86,7 @@
#include "DNA_sdna_types.h"
#include "DNA_sequence_types.h"
#include "DNA_shader_fx_types.h"
+#include "DNA_simulation_types.h"
#include "DNA_sound_types.h"
#include "DNA_space_types.h"
#include "DNA_speaker_types.h"
@@ -117,7 +118,7 @@
#include "BKE_constraint.h"
#include "BKE_curve.h"
#include "BKE_effect.h"
-#include "BKE_fcurve.h"
+#include "BKE_fcurve_driver.h"
#include "BKE_fluid.h"
#include "BKE_global.h" // for G
#include "BKE_gpencil_modifier.h"
@@ -146,6 +147,7 @@
#include "BKE_screen.h"
#include "BKE_sequencer.h"
#include "BKE_shader_fx.h"
+#include "BKE_simulation.h"
#include "BKE_sound.h"
#include "BKE_volume.h"
#include "BKE_workspace.h"
@@ -689,7 +691,7 @@ static Main *blo_find_main(FileData *fd, const char *filepath, const char *relab
/* Important, consistency with main ID reading code from read_libblock(). */
lib->id.us = ID_FAKE_USERS(lib);
- /* Matches lib_link_library(). */
+ /* Matches direct_link_library(). */
id_us_ensure_real(&lib->id);
BLI_strncpy(lib->name, filepath, sizeof(lib->name));
@@ -3026,6 +3028,19 @@ static void direct_link_brush(FileData *fd, Brush *brush)
brush->gpencil_settings->curve_strength);
brush->gpencil_settings->curve_jitter = newdataadr(fd, brush->gpencil_settings->curve_jitter);
+ brush->gpencil_settings->curve_rand_pressure = newdataadr(
+ fd, brush->gpencil_settings->curve_rand_pressure);
+ brush->gpencil_settings->curve_rand_strength = newdataadr(
+ fd, brush->gpencil_settings->curve_rand_strength);
+ brush->gpencil_settings->curve_rand_uv = newdataadr(fd,
+ brush->gpencil_settings->curve_rand_uv);
+ brush->gpencil_settings->curve_rand_hue = newdataadr(fd,
+ brush->gpencil_settings->curve_rand_hue);
+ brush->gpencil_settings->curve_rand_saturation = newdataadr(
+ fd, brush->gpencil_settings->curve_rand_saturation);
+ brush->gpencil_settings->curve_rand_value = newdataadr(
+ fd, brush->gpencil_settings->curve_rand_value);
+
if (brush->gpencil_settings->curve_sensitivity) {
direct_link_curvemapping(fd, brush->gpencil_settings->curve_sensitivity);
}
@@ -3037,6 +3052,30 @@ static void direct_link_brush(FileData *fd, Brush *brush)
if (brush->gpencil_settings->curve_jitter) {
direct_link_curvemapping(fd, brush->gpencil_settings->curve_jitter);
}
+
+ if (brush->gpencil_settings->curve_rand_pressure) {
+ direct_link_curvemapping(fd, brush->gpencil_settings->curve_rand_pressure);
+ }
+
+ if (brush->gpencil_settings->curve_rand_strength) {
+ direct_link_curvemapping(fd, brush->gpencil_settings->curve_rand_strength);
+ }
+
+ if (brush->gpencil_settings->curve_rand_uv) {
+ direct_link_curvemapping(fd, brush->gpencil_settings->curve_rand_uv);
+ }
+
+ if (brush->gpencil_settings->curve_rand_hue) {
+ direct_link_curvemapping(fd, brush->gpencil_settings->curve_rand_hue);
+ }
+
+ if (brush->gpencil_settings->curve_rand_saturation) {
+ direct_link_curvemapping(fd, brush->gpencil_settings->curve_rand_saturation);
+ }
+
+ if (brush->gpencil_settings->curve_rand_value) {
+ direct_link_curvemapping(fd, brush->gpencil_settings->curve_rand_value);
+ }
}
brush->preview = NULL;
@@ -3376,11 +3415,6 @@ static void lib_link_nladata_strips(FileData *fd, ID *id, ListBase *list)
/* reassign the counted-reference to action */
strip->act = newlibadr(fd, id->lib, strip->act);
-
- /* fix action id-root (i.e. if it comes from a pre 2.57 .blend file) */
- if ((strip->act) && (strip->act->idroot == 0)) {
- strip->act->idroot = GS(id->name);
- }
}
}
@@ -3475,14 +3509,6 @@ static void lib_link_animdata(FileData *fd, ID *id, AnimData *adt)
adt->action = newlibadr(fd, id->lib, adt->action);
adt->tmpact = newlibadr(fd, id->lib, adt->tmpact);
- /* fix action id-roots (i.e. if they come from a pre 2.57 .blend file) */
- if ((adt->action) && (adt->action->idroot == 0)) {
- adt->action->idroot = GS(id->name);
- }
- if ((adt->tmpact) && (adt->tmpact->idroot == 0)) {
- adt->tmpact->idroot = GS(id->name);
- }
-
/* link drivers */
lib_link_fcurves(fd, id, &adt->drivers);
@@ -3553,15 +3579,11 @@ static void direct_link_cachefile(FileData *fd, CacheFile *cache_file)
static void lib_link_workspaces(FileData *fd, Main *bmain, WorkSpace *workspace)
{
- ListBase *layouts = BKE_workspace_layouts_get(workspace);
ID *id = (ID *)workspace;
- id_us_ensure_real(id);
-
- for (WorkSpaceLayout *layout = layouts->first, *layout_next; layout; layout = layout_next) {
+ LISTBASE_FOREACH_MUTABLE (WorkSpaceLayout *, layout, &workspace->layouts) {
layout->screen = newlibadr(fd, id->lib, layout->screen);
- layout_next = layout->next;
if (layout->screen) {
if (ID_IS_LINKED(id)) {
layout->screen->winid = 0;
@@ -3581,16 +3603,14 @@ static void lib_link_workspaces(FileData *fd, Main *bmain, WorkSpace *workspace)
static void direct_link_workspace(FileData *fd, WorkSpace *workspace, const Main *main)
{
- link_list(fd, BKE_workspace_layouts_get(workspace));
+ link_list(fd, &workspace->layouts);
link_list(fd, &workspace->hook_layout_relations);
link_list(fd, &workspace->owner_ids);
link_list(fd, &workspace->tools);
LISTBASE_FOREACH (WorkSpaceDataRelation *, relation, &workspace->hook_layout_relations) {
-
/* data from window - need to access through global oldnew-map */
relation->parent = newglobadr(fd, relation->parent);
-
relation->value = newdataadr(fd, relation->value);
}
@@ -3598,11 +3618,7 @@ static void direct_link_workspace(FileData *fd, WorkSpace *workspace, const Main
* when reading windows, so have to update windows after/when reading workspaces. */
for (wmWindowManager *wm = main->wm.first; wm; wm = wm->id.next) {
LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
- WorkSpaceLayout *act_layout = newdataadr(
- fd, BKE_workspace_active_layout_get(win->workspace_hook));
- if (act_layout) {
- BKE_workspace_active_layout_set(win->workspace_hook, act_layout);
- }
+ win->workspace_hook->act_layout = newdataadr(fd, win->workspace_hook->act_layout);
}
}
@@ -3613,6 +3629,8 @@ static void direct_link_workspace(FileData *fd, WorkSpace *workspace, const Main
}
workspace->status_text = NULL;
+
+ id_us_ensure_real(&workspace->id);
}
static void lib_link_workspace_instance_hook(FileData *fd, WorkSpaceInstanceHook *hook, ID *id)
@@ -3627,6 +3645,45 @@ 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)
+{
+ IDP_LibLinkProperty(sock->prop, fd);
+
+ switch ((eNodeSocketDatatype)sock->type) {
+ case SOCK_OBJECT: {
+ bNodeSocketValueObject *default_value = sock->default_value;
+ default_value->value = newlibadr(fd, lib, default_value->value);
+ break;
+ }
+ case SOCK_IMAGE: {
+ bNodeSocketValueImage *default_value = sock->default_value;
+ default_value->value = newlibadr(fd, lib, default_value->value);
+ break;
+ }
+ case SOCK_FLOAT:
+ case SOCK_VECTOR:
+ case SOCK_RGBA:
+ case SOCK_BOOLEAN:
+ case SOCK_INT:
+ case SOCK_STRING:
+ case __SOCK_MESH:
+ case SOCK_CUSTOM:
+ case SOCK_SHADER:
+ case SOCK_EMITTERS:
+ case SOCK_EVENTS:
+ case SOCK_FORCES:
+ case SOCK_CONTROL_FLOW:
+ break;
+ }
+}
+
+static void lib_link_node_sockets(FileData *fd, Library *lib, ListBase *sockets)
+{
+ LISTBASE_FOREACH (bNodeSocket *, sock, sockets) {
+ lib_link_node_socket(fd, 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)
{
@@ -3641,20 +3698,12 @@ static void lib_link_ntree(FileData *fd, Library *lib, bNodeTree *ntree)
node->id = newlibadr(fd, lib, node->id);
- LISTBASE_FOREACH (bNodeSocket *, sock, &node->inputs) {
- IDP_LibLinkProperty(sock->prop, fd);
- }
- LISTBASE_FOREACH (bNodeSocket *, sock, &node->outputs) {
- IDP_LibLinkProperty(sock->prop, fd);
- }
+ lib_link_node_sockets(fd, lib, &node->inputs);
+ lib_link_node_sockets(fd, lib, &node->outputs);
}
- LISTBASE_FOREACH (bNodeSocket *, sock, &ntree->inputs) {
- IDP_LibLinkProperty(sock->prop, fd);
- }
- LISTBASE_FOREACH (bNodeSocket *, sock, &ntree->outputs) {
- IDP_LibLinkProperty(sock->prop, fd);
- }
+ lib_link_node_sockets(fd, lib, &ntree->inputs);
+ lib_link_node_sockets(fd, 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
@@ -3827,23 +3876,23 @@ static void direct_link_nodetree(FileData *fd, bNodeTree *ntree)
}
#if 0
- if (ntree->previews) {
- bNodeInstanceHash* new_previews = BKE_node_instance_hash_new("node previews");
- bNodeInstanceHashIterator iter;
-
- NODE_INSTANCE_HASH_ITER(iter, ntree->previews) {
- bNodePreview* preview = BKE_node_instance_hash_iterator_get_value(&iter);
- if (preview) {
- bNodePreview* new_preview = newimaadr(fd, preview);
- if (new_preview) {
- bNodeInstanceKey key = BKE_node_instance_hash_iterator_get_key(&iter);
- BKE_node_instance_hash_insert(new_previews, key, new_preview);
- }
- }
- }
- BKE_node_instance_hash_free(ntree->previews, NULL);
- ntree->previews = new_previews;
- }
+ if (ntree->previews) {
+ bNodeInstanceHash* new_previews = BKE_node_instance_hash_new("node previews");
+ bNodeInstanceHashIterator iter;
+
+ NODE_INSTANCE_HASH_ITER(iter, ntree->previews) {
+ bNodePreview* preview = BKE_node_instance_hash_iterator_get_value(&iter);
+ if (preview) {
+ bNodePreview* new_preview = newimaadr(fd, preview);
+ if (new_preview) {
+ bNodeInstanceKey key = BKE_node_instance_hash_iterator_get_key(&iter);
+ BKE_node_instance_hash_insert(new_previews, key, new_preview);
+ }
+ }
+ }
+ BKE_node_instance_hash_free(ntree->previews, NULL);
+ ntree->previews = new_previews;
+ }
#else
/* XXX TODO */
ntree->previews = NULL;
@@ -4293,10 +4342,10 @@ static void direct_link_text(FileData *fd, Text *text)
text->compiled = NULL;
#if 0
- if (text->flags & TXT_ISEXT) {
- BKE_text_reload(text);
- }
- /* else { */
+ if (text->flags & TXT_ISEXT) {
+ BKE_text_reload(text);
+ }
+ /* else { */
#endif
link_list(fd, &text->lines);
@@ -4806,7 +4855,7 @@ static void lib_link_particlesystems(FileData *fd, Object *ob, ID *id, ListBase
/* particle modifier must be removed before particle system */
ParticleSystemModifierData *psmd = psys_get_modifier(ob, psys);
BLI_remlink(&ob->modifiers, psmd);
- modifier_free((ModifierData *)psmd);
+ BKE_modifier_free((ModifierData *)psmd);
BLI_remlink(particles, psys);
MEM_freeN(psys);
@@ -5175,7 +5224,7 @@ static void lib_link_modifiers_common(void *userData, Object *ob, ID **idpoin, i
static void lib_link_modifiers(FileData *fd, Object *ob)
{
- modifiers_foreachIDLink(ob, lib_link_modifiers_common, fd);
+ BKE_modifiers_foreach_ID_link(ob, lib_link_modifiers_common, fd);
/* If linking from a library, clear 'local' library override flag. */
if (ob->id.lib != NULL) {
@@ -5187,7 +5236,7 @@ static void lib_link_modifiers(FileData *fd, Object *ob)
static void lib_link_gpencil_modifiers(FileData *fd, Object *ob)
{
- BKE_gpencil_modifiers_foreachIDLink(ob, lib_link_modifiers_common, fd);
+ BKE_gpencil_modifiers_foreach_ID_link(ob, lib_link_modifiers_common, fd);
/* If linking from a library, clear 'local' library override flag. */
if (ob->id.lib != NULL) {
@@ -5200,7 +5249,7 @@ static void lib_link_gpencil_modifiers(FileData *fd, Object *ob)
static void lib_link_shaderfxs(FileData *fd, Object *ob)
{
- BKE_shaderfx_foreachIDLink(ob, lib_link_modifiers_common, fd);
+ BKE_shaderfx_foreach_ID_link(ob, lib_link_modifiers_common, fd);
/* If linking from a library, clear 'local' library override flag. */
if (ob->id.lib != NULL) {
@@ -5284,7 +5333,7 @@ static void lib_link_object(FileData *fd, Main *bmain, Object *ob)
* some leaked memory rather then crashing immediately
* while bad this _is_ an exceptional case - campbell */
#if 0
- BKE_pose_free(ob->pose);
+ BKE_pose_free(ob->pose);
#else
MEM_freeN(ob->pose);
#endif
@@ -5327,7 +5376,7 @@ static void lib_link_object(FileData *fd, Main *bmain, Object *ob)
}
{
- FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType(
+ FluidsimModifierData *fluidmd = (FluidsimModifierData *)BKE_modifiers_findby_type(
ob, eModifierType_Fluidsim);
if (fluidmd && fluidmd->fss) {
@@ -5337,7 +5386,8 @@ static void lib_link_object(FileData *fd, Main *bmain, Object *ob)
}
{
- FluidModifierData *mmd = (FluidModifierData *)modifiers_findByType(ob, eModifierType_Fluid);
+ FluidModifierData *mmd = (FluidModifierData *)BKE_modifiers_findby_type(ob,
+ eModifierType_Fluid);
if (mmd && (mmd->type == MOD_FLUID_TYPE_DOMAIN) && mmd->domain) {
/* Flag for refreshing the simulation after loading */
@@ -5479,7 +5529,7 @@ static ModifierData *modifier_replace_with_fluid(FileData *fd,
ListBase *modifiers,
ModifierData *old_modifier_data)
{
- ModifierData *new_modifier_data = modifier_new(eModifierType_Fluid);
+ ModifierData *new_modifier_data = BKE_modifier_new(eModifierType_Fluid);
FluidModifierData *fluid_modifier_data = (FluidModifierData *)new_modifier_data;
if (old_modifier_data->type == eModifierType_Fluidsim) {
@@ -5602,7 +5652,7 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb, Object *ob)
is_allocated = true;
}
/* if modifiers disappear, or for upward compatibility */
- if (NULL == modifierType_getInfo(md->type)) {
+ if (NULL == BKE_modifier_get_info(md->type)) {
md->type = eModifierType_None;
}
@@ -5760,15 +5810,15 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb, Object *ob)
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");
+ // 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;
@@ -5956,7 +6006,7 @@ static void direct_link_gpencil_modifiers(FileData *fd, ListBase *lb)
md->error = NULL;
/* if modifiers disappear, or for upward compatibility */
- if (NULL == BKE_gpencil_modifierType_getInfo(md->type)) {
+ if (NULL == BKE_gpencil_modifier_get_info(md->type)) {
md->type = eModifierType_None;
}
@@ -6037,7 +6087,7 @@ static void direct_link_shaderfxs(FileData *fd, ListBase *lb)
fx->error = NULL;
/* if shader disappear, or for upward compatibility */
- if (NULL == BKE_shaderfxType_getInfo(fx->type)) {
+ if (NULL == BKE_shaderfx_get_info(fx->type)) {
fx->type = eShaderFxType_None;
}
}
@@ -6100,7 +6150,7 @@ static void direct_link_object(FileData *fd, Object *ob)
if (paf->type == EFF_WAVE) {
WaveEff *wav = (WaveEff *)paf;
PartEff *next = paf->next;
- WaveModifierData *wmd = (WaveModifierData *)modifier_new(eModifierType_Wave);
+ WaveModifierData *wmd = (WaveModifierData *)BKE_modifier_new(eModifierType_Wave);
wmd->damp = wav->damp;
wmd->flag = wav->flag;
@@ -6124,7 +6174,7 @@ static void direct_link_object(FileData *fd, Object *ob)
if (paf->type == EFF_BUILD) {
BuildEff *baf = (BuildEff *)paf;
PartEff *next = paf->next;
- BuildModifierData *bmd = (BuildModifierData *)modifier_new(eModifierType_Build);
+ BuildModifierData *bmd = (BuildModifierData *)BKE_modifier_new(eModifierType_Build);
bmd->start = baf->sfra;
bmd->length = baf->len;
@@ -6201,7 +6251,7 @@ static void direct_link_object(FileData *fd, Object *ob)
link_list(fd, &ob->hooks);
while (ob->hooks.first) {
ObHook *hook = ob->hooks.first;
- HookModifierData *hmd = (HookModifierData *)modifier_new(eModifierType_Hook);
+ HookModifierData *hmd = (HookModifierData *)BKE_modifier_new(eModifierType_Hook);
hook->indexar = newdataadr(fd, hook->indexar);
if (fd->flags & FD_FLAGS_SWITCH_ENDIAN) {
@@ -6223,7 +6273,7 @@ static void direct_link_object(FileData *fd, Object *ob)
BLI_addhead(&ob->modifiers, hmd);
BLI_remlink(&ob->hooks, hook);
- modifier_unique_name(&ob->modifiers, (ModifierData *)hmd);
+ BKE_modifier_unique_name(&ob->modifiers, (ModifierData *)hmd);
MEM_freeN(hook);
}
@@ -7474,10 +7524,10 @@ static void direct_link_area(FileData *fd, ScrArea *area)
* so sacrifice a few old files for now to avoid crashes with new files!
* committed: r28002 */
#if 0
- sima->gpd = newdataadr(fd, sima->gpd);
- if (sima->gpd) {
- direct_link_gpencil(fd, sima->gpd);
- }
+ sima->gpd = newdataadr(fd, sima->gpd);
+ if (sima->gpd) {
+ direct_link_gpencil(fd, sima->gpd);
+ }
#endif
}
else if (sl->spacetype == SPACE_NODE) {
@@ -7508,10 +7558,10 @@ static void direct_link_area(FileData *fd, ScrArea *area)
* simple return NULL here (sergey)
*/
#if 0
- if (sseq->gpd) {
- sseq->gpd = newdataadr(fd, sseq->gpd);
- direct_link_gpencil(fd, sseq->gpd);
- }
+ if (sseq->gpd) {
+ sseq->gpd = newdataadr(fd, sseq->gpd);
+ direct_link_gpencil(fd, sseq->gpd);
+ }
#endif
sseq->scopes.reference_ibuf = NULL;
sseq->scopes.zebra_ibuf = NULL;
@@ -8198,11 +8248,11 @@ static void lib_link_workspace_layout_restore(struct IDNameLib_Map *id_map,
sima->iuser.scene = NULL;
#if 0
- /* Those are allocated and freed by space code, no need to handle them here. */
- MEM_SAFE_FREE(sima->scopes.waveform_1);
- MEM_SAFE_FREE(sima->scopes.waveform_2);
- MEM_SAFE_FREE(sima->scopes.waveform_3);
- MEM_SAFE_FREE(sima->scopes.vecscope);
+ /* Those are allocated and freed by space code, no need to handle them here. */
+ MEM_SAFE_FREE(sima->scopes.waveform_1);
+ MEM_SAFE_FREE(sima->scopes.waveform_2);
+ MEM_SAFE_FREE(sima->scopes.waveform_3);
+ MEM_SAFE_FREE(sima->scopes.vecscope);
#endif
sima->scopes.ok = 0;
@@ -8353,9 +8403,7 @@ void blo_lib_link_restore(Main *oldmain,
for (WorkSpace *workspace = newmain->workspaces.first; workspace;
workspace = workspace->id.next) {
- ListBase *layouts = BKE_workspace_layouts_get(workspace);
-
- LISTBASE_FOREACH (WorkSpaceLayout *, layout, layouts) {
+ LISTBASE_FOREACH (WorkSpaceLayout *, layout, &workspace->layouts) {
lib_link_workspace_layout_restore(id_map, newmain, layout);
}
}
@@ -8503,11 +8551,12 @@ static void direct_link_library(FileData *fd, Library *lib, Main *main)
newmain->curlib = lib;
lib->parent = NULL;
+
+ id_us_ensure_real(&lib->id);
}
-static void lib_link_library(FileData *UNUSED(fd), Main *UNUSED(bmain), Library *lib)
+static void lib_link_library(FileData *UNUSED(fd), Main *UNUSED(bmain), Library *UNUSED(lib))
{
- id_us_ensure_real(&lib->id);
}
/* Always call this once you have loaded new library data to set the relative paths correctly
@@ -8575,8 +8624,8 @@ static void direct_link_speaker(FileData *fd, Speaker *spk)
direct_link_animdata(fd, spk->adt);
#if 0
- spk->sound = newdataadr(fd, spk->sound);
- direct_link_sound(fd, spk->sound);
+ spk->sound = newdataadr(fd, spk->sound);
+ direct_link_sound(fd, spk->sound);
#endif
}
@@ -9160,6 +9209,24 @@ static void direct_link_volume(FileData *fd, Volume *volume)
/** \} */
/* -------------------------------------------------------------------- */
+/** \name Read ID: Simulation
+ * \{ */
+
+static void lib_link_simulation(FileData *UNUSED(fd),
+ Main *UNUSED(main),
+ Simulation *UNUSED(simulation))
+{
+}
+
+static void direct_link_simulation(FileData *fd, Simulation *simulation)
+{
+ simulation->adt = newdataadr(fd, simulation->adt);
+ direct_link_animdata(fd, simulation->adt);
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
/** \name Read Library Data Block
* \{ */
@@ -9277,6 +9344,8 @@ static const char *dataname(short id_code)
return "Data from PT";
case ID_VO:
return "Data from VO";
+ case ID_SIM:
+ return "Data from SIM";
}
return "Data from Lib Block";
}
@@ -9414,6 +9483,9 @@ static bool direct_link_id(FileData *fd, Main *main, const int tag, ID *id, ID *
case ID_VO:
direct_link_volume(fd, (Volume *)id);
break;
+ case ID_SIM:
+ direct_link_simulation(fd, (Simulation *)id);
+ break;
}
return success;
@@ -9427,12 +9499,12 @@ static BHead *read_data_into_datamap(FileData *fd, BHead *bhead, const char *all
while (bhead && bhead->code == DATA) {
void *data;
#if 0
- /* XXX DUMB DEBUGGING OPTION TO GIVE NAMES for guarded malloc errors */
- short* sp = fd->filesdna->structs[bhead->SDNAnr];
- char* tmp = malloc(100);
- allocname = fd->filesdna->types[sp[0]];
- strcpy(tmp, allocname);
- data = read_struct(fd, bhead, tmp);
+ /* XXX DUMB DEBUGGING OPTION TO GIVE NAMES for guarded malloc errors */
+ short* sp = fd->filesdna->structs[bhead->SDNAnr];
+ char* tmp = malloc(100);
+ allocname = fd->filesdna->types[sp[0]];
+ strcpy(tmp, allocname);
+ data = read_struct(fd, bhead, tmp);
#else
data = read_struct(fd, bhead, allocname);
#endif
@@ -9660,7 +9732,7 @@ static bool read_libblock_undo_restore(
* this is only for do_version-like code), but for sake of consistency, and also because
* it will tell us which ID is re-used from old Main, and which one is actually new. */
/* Also do not add LIB_TAG_NEED_LINK, those IDs will never be re-liblinked, hence that tag will
- * never be cleared, leading to critical issue in link/appemd code. */
+ * never be cleared, leading to critical issue in link/append code. */
const int id_tag = tag | LIB_TAG_UNDO_OLD_ID_REUSED;
read_libblock_undo_restore_identical(fd, main, id, id_old, id_tag);
@@ -9936,6 +10008,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
blo_do_versions_260(fd, lib, main);
blo_do_versions_270(fd, lib, main);
blo_do_versions_280(fd, lib, main);
+ blo_do_versions_290(fd, lib, main);
blo_do_versions_cycles(fd, lib, main);
/* WATCH IT!!!: pointers from libdata have not been converted yet here! */
@@ -9958,6 +10031,7 @@ static void do_versions_after_linking(Main *main, ReportList *reports)
do_versions_after_linking_260(main);
do_versions_after_linking_270(main);
do_versions_after_linking_280(main, reports);
+ do_versions_after_linking_290(main, reports);
do_versions_after_linking_cycles(main);
main->is_locked_for_linking = false;
@@ -10115,6 +10189,9 @@ static void lib_link_all(FileData *fd, Main *bmain)
case ID_AC:
lib_link_action(fd, bmain, (bAction *)id);
break;
+ case ID_SIM:
+ lib_link_simulation(fd, bmain, (Simulation *)id);
+ break;
case ID_IP:
/* XXX deprecated... still needs to be maintained for version patches still. */
lib_link_ipo(fd, bmain, (Ipo *)id);
@@ -10502,7 +10579,7 @@ static BHead *find_previous_lib(FileData *fd, BHead *bhead)
static BHead *find_bhead(FileData *fd, void *old)
{
#if 0
- BHead* bhead;
+ BHead* bhead;
#endif
struct BHeadSort *bhs, bhs_s;
@@ -10522,11 +10599,11 @@ static BHead *find_bhead(FileData *fd, void *old)
}
#if 0
- for (bhead = blo_bhead_first(fd); bhead; bhead = blo_bhead_next(fd, bhead)) {
- if (bhead->old == old) {
- return bhead;
- }
- }
+ for (bhead = blo_bhead_first(fd); bhead; bhead = blo_bhead_next(fd, bhead)) {
+ if (bhead->old == old) {
+ return bhead;
+ }
+ }
#endif
return NULL;
@@ -10657,9 +10734,9 @@ 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);
- }
+ if (G.debug & G_DEBUG) {
+ printf("expand_doit: already linked: %s lib: %s\n", id->name, lib->name);
+ }
#endif
}
@@ -10966,10 +11043,51 @@ static void expand_key(FileData *fd, Main *mainvar, Key *key)
expand_doit(fd, mainvar, key->ipo); // XXX deprecated - old animation system
}
+static void expand_node_socket(FileData *fd, Main *mainvar, bNodeSocket *sock)
+{
+ expand_idprops(fd, mainvar, 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);
+ break;
+ }
+ case SOCK_IMAGE: {
+ bNodeSocketValueImage *default_value = sock->default_value;
+ expand_doit(fd, mainvar, default_value->value);
+ break;
+ }
+ case SOCK_FLOAT:
+ case SOCK_VECTOR:
+ case SOCK_RGBA:
+ case SOCK_BOOLEAN:
+ case SOCK_INT:
+ case SOCK_STRING:
+ case __SOCK_MESH:
+ case SOCK_CUSTOM:
+ case SOCK_SHADER:
+ case SOCK_EMITTERS:
+ case SOCK_EVENTS:
+ case SOCK_FORCES:
+ case SOCK_CONTROL_FLOW:
+ break;
+ }
+ }
+}
+
+static void expand_node_sockets(FileData *fd, Main *mainvar, ListBase *sockets)
+{
+ LISTBASE_FOREACH (bNodeSocket *, sock, sockets) {
+ expand_node_socket(fd, mainvar, sock);
+ }
+}
+
static void expand_nodetree(FileData *fd, Main *mainvar, bNodeTree *ntree)
{
bNode *node;
- bNodeSocket *sock;
if (ntree->gpd) {
expand_doit(fd, mainvar, ntree->gpd);
@@ -10982,20 +11100,12 @@ static void expand_nodetree(FileData *fd, Main *mainvar, bNodeTree *ntree)
expand_idprops(fd, mainvar, node->prop);
- for (sock = node->inputs.first; sock; sock = sock->next) {
- expand_idprops(fd, mainvar, sock->prop);
- }
- for (sock = node->outputs.first; sock; sock = sock->next) {
- expand_idprops(fd, mainvar, sock->prop);
- }
+ expand_node_sockets(fd, mainvar, &node->inputs);
+ expand_node_sockets(fd, mainvar, &node->outputs);
}
- for (sock = ntree->inputs.first; sock; sock = sock->next) {
- expand_idprops(fd, mainvar, sock->prop);
- }
- for (sock = ntree->outputs.first; sock; sock = sock->next) {
- expand_idprops(fd, mainvar, sock->prop);
- }
+ expand_node_sockets(fd, mainvar, &ntree->inputs);
+ expand_node_sockets(fd, mainvar, &ntree->outputs);
}
static void expand_texture(FileData *fd, Main *mainvar, Tex *tex)
@@ -11181,7 +11291,7 @@ static void expand_object(FileData *fd, Main *mainvar, Object *ob)
data.fd = fd;
data.mainvar = mainvar;
- modifiers_foreachIDLink(ob, expand_object_expandModifiers, (void *)&data);
+ BKE_modifiers_foreach_ID_link(ob, expand_object_expandModifiers, (void *)&data);
}
/* expand_object_expandModifier() */
@@ -11193,7 +11303,7 @@ static void expand_object(FileData *fd, Main *mainvar, Object *ob)
data.fd = fd;
data.mainvar = mainvar;
- BKE_gpencil_modifiers_foreachIDLink(ob, expand_object_expandModifiers, (void *)&data);
+ BKE_gpencil_modifiers_foreach_ID_link(ob, expand_object_expandModifiers, (void *)&data);
}
/* expand_object_expandShaderFx() */
@@ -11205,7 +11315,7 @@ static void expand_object(FileData *fd, Main *mainvar, Object *ob)
data.fd = fd;
data.mainvar = mainvar;
- BKE_shaderfx_foreachIDLink(ob, expand_object_expandModifiers, (void *)&data);
+ BKE_shaderfx_foreach_ID_link(ob, expand_object_expandModifiers, (void *)&data);
}
expand_pose(fd, mainvar, ob->pose);
@@ -11506,9 +11616,7 @@ static void expand_gpencil(FileData *fd, Main *mainvar, bGPdata *gpd)
static void expand_workspace(FileData *fd, Main *mainvar, WorkSpace *workspace)
{
- ListBase *layouts = BKE_workspace_layouts_get(workspace);
-
- LISTBASE_FOREACH (WorkSpaceLayout *, layout, layouts) {
+ LISTBASE_FOREACH (WorkSpaceLayout *, layout, &workspace->layouts) {
expand_doit(fd, mainvar, BKE_workspace_layout_screen_get(layout));
}
}
@@ -11546,6 +11654,13 @@ static void expand_volume(FileData *fd, Main *mainvar, Volume *volume)
}
}
+static void expand_simulation(FileData *fd, Main *mainvar, Simulation *simulation)
+{
+ if (simulation->adt) {
+ expand_animdata(fd, mainvar, simulation->adt);
+ }
+}
+
/**
* Set the callback func used over all ID data found by \a BLO_expand_main func.
*
@@ -11675,6 +11790,9 @@ void BLO_expand_main(void *fdhandle, Main *mainvar)
case ID_VO:
expand_volume(fd, mainvar, (Volume *)id);
break;
+ case ID_SIM:
+ expand_simulation(fd, mainvar, (Simulation *)id);
+ break;
default:
break;
}
@@ -11811,6 +11929,7 @@ static void add_collections_to_scene(Main *mainvar,
/* BKE_object_add(...) messes with the selection. */
Object *ob = BKE_object_add_only_object(bmain, OB_EMPTY, collection->id.name + 2);
ob->type = OB_EMPTY;
+ ob->empty_drawsize = U.collection_instance_empty_size;
BKE_collection_object_add(bmain, active_collection, ob);
Base *base = BKE_view_layer_base_find(view_layer, ob);
@@ -12481,9 +12600,9 @@ static void read_libraries(FileData *basefd, ListBase *mainlist)
/* Does this library have any more linked data-blocks we need to read? */
if (has_linked_ids_to_read(mainptr)) {
#if 0
- printf("Reading linked data-blocks from %s (%s)\n",
- mainptr->curlib->id.name,
- mainptr->curlib->name);
+ printf("Reading linked data-blocks from %s (%s)\n",
+ mainptr->curlib->id.name,
+ mainptr->curlib->name);
#endif
/* Open file if it has not been done yet. */