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/writefile.c')
-rw-r--r--source/blender/blenloader/intern/writefile.c179
1 files changed, 70 insertions, 109 deletions
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index 24075a1fe58..3c6e646fe9c 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -1804,7 +1804,7 @@ static void write_meshs(WriteData *wd, ListBase *idbase)
if (!save_for_old_blender) {
#ifdef USE_BMESH_SAVE_WITHOUT_MFACE
- Mesh backup_mesh = {{0}};
+ Mesh backup_mesh = {{NULL}};
/* cache only - don't write */
backup_mesh.mface = mesh->mface;
mesh->mface = NULL;
@@ -1847,7 +1847,7 @@ static void write_meshs(WriteData *wd, ListBase *idbase)
#ifdef USE_BMESH_SAVE_AS_COMPAT
- Mesh backup_mesh = {{0}};
+ Mesh backup_mesh = {{NULL}};
/* backup */
backup_mesh.mpoly = mesh->mpoly;
@@ -2799,114 +2799,69 @@ static void write_nodetrees(WriteData *wd, ListBase *idbase)
}
#ifdef USE_NODE_COMPAT_CUSTOMNODES
-static void customnodes_add_deprecated_nodetree_data(bNodeTree *ntree)
-{
- bNodeLink *link, *last_link = ntree->links.last;
- /* Forward compatibility for group nodes: add links to node tree interface sockets.
- * These links are invalid by new rules (missing node pointer)!
- * They will be removed again in customnodes_free_deprecated_data,
- * cannot do this directly lest bNodeLink pointer mapping becomes ambiguous.
- * When loading files with such links in a new Blender version
- * they will be removed as well.
- */
- for (link = ntree->links.first; link; link = link->next) {
- bNode *fromnode = link->fromnode, *tonode = link->tonode;
- bNodeSocket *fromsock = link->fromsock, *tosock = link->tosock;
+static void customnodes_add_deprecated_data(Main *mainvar)
+{
+ FOREACH_NODETREE(mainvar, ntree, id) {
+ bNodeLink *link, *last_link = ntree->links.last;
- /* check both sides of the link, to handle direct input-to-output links */
- if (fromnode->type == NODE_GROUP_INPUT) {
- fromnode = NULL;
- fromsock = ntreeFindSocketInterface(ntree, SOCK_IN, fromsock->identifier);
- }
- /* only the active output node defines links */
- if (tonode->type == NODE_GROUP_OUTPUT && (tonode->flag & NODE_DO_OUTPUT)) {
- tonode = NULL;
- tosock = ntreeFindSocketInterface(ntree, SOCK_OUT, tosock->identifier);
- }
+ /* only do this for node groups */
+ if (id != &ntree->id)
+ continue;
- if (!fromnode || !tonode) {
- /* Note: not using nodeAddLink here, it asserts existing node pointers */
- bNodeLink *tlink = MEM_callocN(sizeof(bNodeLink), "group node link");
- tlink->fromnode = fromnode;
- tlink->fromsock = fromsock;
- tlink->tonode = tonode;
- tlink->tosock= tosock;
- tosock->link = tlink;
- tlink->flag |= NODE_LINK_VALID;
- BLI_addtail(&ntree->links, tlink);
+ /* Forward compatibility for group nodes: add links to node tree interface sockets.
+ * These links are invalid by new rules (missing node pointer)!
+ * They will be removed again in customnodes_free_deprecated_data,
+ * cannot do this directly lest bNodeLink pointer mapping becomes ambiguous.
+ * When loading files with such links in a new Blender version
+ * they will be removed as well.
+ */
+ for (link = ntree->links.first; link; link = link->next) {
+ bNode *fromnode = link->fromnode, *tonode = link->tonode;
+ bNodeSocket *fromsock = link->fromsock, *tosock = link->tosock;
+
+ /* check both sides of the link, to handle direct input-to-output links */
+ if (fromnode->type == NODE_GROUP_INPUT) {
+ fromnode = NULL;
+ fromsock = ntreeFindSocketInterface(ntree, SOCK_IN, fromsock->identifier);
+ }
+ /* only the active output node defines links */
+ if (tonode->type == NODE_GROUP_OUTPUT && (tonode->flag & NODE_DO_OUTPUT)) {
+ tonode = NULL;
+ tosock = ntreeFindSocketInterface(ntree, SOCK_OUT, tosock->identifier);
+ }
+
+ if (!fromnode || !tonode) {
+ /* Note: not using nodeAddLink here, it asserts existing node pointers */
+ bNodeLink *tlink = MEM_callocN(sizeof(bNodeLink), "group node link");
+ tlink->fromnode = fromnode;
+ tlink->fromsock = fromsock;
+ tlink->tonode = tonode;
+ tlink->tosock= tosock;
+ tosock->link = tlink;
+ tlink->flag |= NODE_LINK_VALID;
+ BLI_addtail(&ntree->links, tlink);
+ }
+
+ /* don't check newly created compatibility links */
+ if (link == last_link)
+ break;
}
-
- /* don't check newly created compatibility links */
- if (link == last_link)
- break;
- }
-}
-
-static void customnodes_add_deprecated_data(Main *mainvar)
-{
- bNodeTree *ntree;
- Scene *scene;
- Material *mat;
- World *world;
- Lamp *lamp;
- Tex *tex;
-
- for (ntree = mainvar->nodetree.first; ntree; ntree = ntree->id.next)
- customnodes_add_deprecated_nodetree_data(ntree);
- for (scene = mainvar->scene.first; scene; scene = scene->id.next)
- if (scene->nodetree)
- customnodes_add_deprecated_nodetree_data(scene->nodetree);
- for (mat = mainvar->mat.first; mat; mat = mat->id.next)
- if (mat->nodetree)
- customnodes_add_deprecated_nodetree_data(mat->nodetree);
- for (world = mainvar->world.first; world; world = world->id.next)
- if (world->nodetree)
- customnodes_add_deprecated_nodetree_data(world->nodetree);
- for (lamp = mainvar->lamp.first; lamp; lamp = lamp->id.next)
- if (lamp->nodetree)
- customnodes_add_deprecated_nodetree_data(lamp->nodetree);
- for (tex = mainvar->tex.first; tex; tex = tex->id.next)
- if (tex->nodetree)
- customnodes_add_deprecated_nodetree_data(tex->nodetree);
-}
-
-static void customnodes_free_deprecated_nodetree_data(bNodeTree *ntree)
-{
- bNodeLink *link, *next_link;
-
- for (link = ntree->links.first; link; link = next_link) {
- next_link = link->next;
- if (link->fromnode == NULL || link->tonode == NULL)
- nodeRemLink(ntree, link);
}
+ FOREACH_NODETREE_END
}
static void customnodes_free_deprecated_data(Main *mainvar)
{
- bNodeTree *ntree;
- Scene *scene;
- Material *mat;
- World *world;
- Lamp *lamp;
- Tex *tex;
-
- for (ntree = mainvar->nodetree.first; ntree; ntree = ntree->id.next)
- customnodes_free_deprecated_nodetree_data(ntree);
- for (scene = mainvar->scene.first; scene; scene = scene->id.next)
- if (scene->nodetree)
- customnodes_free_deprecated_nodetree_data(scene->nodetree);
- for (mat = mainvar->mat.first; mat; mat = mat->id.next)
- if (mat->nodetree)
- customnodes_free_deprecated_nodetree_data(mat->nodetree);
- for (world = mainvar->world.first; world; world = world->id.next)
- if (world->nodetree)
- customnodes_free_deprecated_nodetree_data(world->nodetree);
- for (lamp = mainvar->lamp.first; lamp; lamp = lamp->id.next)
- if (lamp->nodetree)
- customnodes_free_deprecated_nodetree_data(lamp->nodetree);
- for (tex = mainvar->tex.first; tex; tex = tex->id.next)
- if (tex->nodetree)
- customnodes_free_deprecated_nodetree_data(tex->nodetree);
+ FOREACH_NODETREE(mainvar, ntree, id) {
+ bNodeLink *link, *next_link;
+
+ for (link = ntree->links.first; link; link = next_link) {
+ next_link = link->next;
+ if (link->fromnode == NULL || link->tonode == NULL)
+ nodeRemLink(ntree, link);
+ }
+ }
+ FOREACH_NODETREE_END
}
#endif
@@ -3323,8 +3278,11 @@ static int write_file_handle(Main *mainvar, int handle, MemFile *compare, MemFil
#endif
#ifdef USE_NODE_COMPAT_CUSTOMNODES
- /* deprecated forward compat data is freed again below */
- customnodes_add_deprecated_data(mainvar);
+ /* don't write compatibility data on undo */
+ if (!current) {
+ /* deprecated forward compat data is freed again below */
+ customnodes_add_deprecated_data(mainvar);
+ }
#endif
sprintf(buf, "BLENDER%c%c%.3d", (sizeof(void*)==8)?'-':'_', (ENDIAN_ORDER==B_ENDIAN)?'V':'v', BLENDER_VERSION);
@@ -3374,11 +3332,14 @@ static int write_file_handle(Main *mainvar, int handle, MemFile *compare, MemFil
writedata(wd, DNA1, wd->sdna->datalen, wd->sdna->data);
#ifdef USE_NODE_COMPAT_CUSTOMNODES
- /* Ugly, forward compatibility code generates deprecated data during writing,
- * this has to be freed again. Can not be done directly after writing, otherwise
- * the data pointers could be reused and not be mapped correctly.
- */
- customnodes_free_deprecated_data(mainvar);
+ /* compatibility data not created on undo */
+ if (!current) {
+ /* Ugly, forward compatibility code generates deprecated data during writing,
+ * this has to be freed again. Can not be done directly after writing, otherwise
+ * the data pointers could be reused and not be mapped correctly.
+ */
+ customnodes_free_deprecated_data(mainvar);
+ }
#endif
/* end of file */