diff options
author | Lukas Toenne <lukas.toenne@googlemail.com> | 2012-03-01 11:56:15 +0400 |
---|---|---|
committer | Lukas Toenne <lukas.toenne@googlemail.com> | 2012-03-01 11:56:15 +0400 |
commit | 2eb29e4788008c1346b3a757cccec503b73c9b90 (patch) | |
tree | 8b27a7524ad45b8cfcadff31cfa17d2885a0f18b /source/blender/blenloader | |
parent | 1d5a3886a175da808df1872f161e4eb8848ab358 (diff) |
A number of improvements for the file output node(s).
1) Old CMP_NODE_OUTPUT_FILE and CMP_NODE_OUTPUT_MULTI_FILE have been merged,
only CMP_NODE_OUTPUT_FILE remains. All functions renamed accordingly.
2) do_versions code for converting single-file output nodes into multi-file
output nodes. If a Z buffer input is used, the node is made into a multilayer
exr with two inputs. (see below). Also re-identifies multi-file output nodes
with the CMP_NODE_OUTPUT_FILE type.
3) "Global" format is stored in node now. By default this overrides any
per-socket settings.
4) Multilayer EXR output implemented. When M.EXR format is selected for node
format, all socket format details are ignored. Socket names are used for layer
names.
5) Input buffer types are used as-is when possible, i.e. stored as B/W, RGB or
RGBA. In regular file output the format dictates the number of actual channels,
so the CompBuf is typechecked to the right type first. For multilayer EXR the
number of channels is more flexible, so an input buffer will store only the
channels it actually uses.
6) The editor socket type is updated from linked sockets as an indicator of the
actual data written to files. This may not be totally accurate for regular file
output though, due to restrictions of format setting.
Diffstat (limited to 'source/blender/blenloader')
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 86 | ||||
-rw-r--r-- | source/blender/blenloader/intern/writefile.c | 2 |
2 files changed, 87 insertions, 1 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 180ccaddb0a..8abdc974488 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -7685,6 +7685,77 @@ static void do_versions_nodetree_socket_auto_hidden_flags_2_62(bNodeTree *ntree) } } +static void do_versions_nodetree_multi_file_output_format_2_62_1(Scene *sce, bNodeTree *ntree) +{ + bNode *node; + bNodeSocket *sock; + + for (node=ntree->nodes.first; node; node=node->next) { + if (node->type==CMP_NODE_OUTPUT_FILE) { + /* previous CMP_NODE_OUTPUT_FILE nodes get converted to multi-file outputs */ + NodeImageFile *old_data = node->storage; + NodeImageMultiFile *nimf= MEM_callocN(sizeof(NodeImageMultiFile), "node image multi file"); + bNodeSocket *old_image = BLI_findlink(&node->inputs, 0); + bNodeSocket *old_z = BLI_findlink(&node->inputs, 1); + bNodeSocket *sock; + + node->storage= nimf; + + BLI_strncpy(nimf->base_path, old_data->name, sizeof(nimf->base_path)); + nimf->format = old_data->im_format; + + /* if z buffer is saved, change the image type to multilayer exr. + * XXX this is slightly messy, Z buffer was ignored before for anything but EXR and IRIS ... + * i'm just assuming here that IRIZ means IRIS with z buffer ... + */ + if (ELEM(old_data->im_format.imtype, R_IMF_IMTYPE_IRIZ, R_IMF_IMTYPE_OPENEXR)) { + nimf->format.imtype = R_IMF_IMTYPE_MULTILAYER; + sock = ntreeCompositOutputFileAddSocket(ntree, node, old_image->name, &nimf->format); + if (old_image->link) { + old_image->link->tosock = sock; + sock->link = old_image->link; + } + sock = ntreeCompositOutputFileAddSocket(ntree, node, old_z->name, &nimf->format); + if (old_z->link) { + old_z->link->tosock = sock; + sock->link = old_z->link; + } + } + else { + /* saves directly to base path, which is the old image output path */ + sock = ntreeCompositOutputFileAddSocket(ntree, node, "", &nimf->format); + if (old_image->link) { + old_image->link->tosock = sock; + sock->link = old_image->link; + } + } + + nodeRemoveSocket(ntree, node, old_image); + nodeRemoveSocket(ntree, node, old_z); + MEM_freeN(old_data); + } + else if (node->type==CMP_NODE_OUTPUT_MULTI_FILE__DEPRECATED) { + NodeImageMultiFile *nimf = node->storage; + + /* CMP_NODE_OUTPUT_MULTI_FILE has been redeclared as CMP_NODE_OUTPUT_FILE */ + node->type = CMP_NODE_OUTPUT_FILE; + + /* initialize the node-wide image format from render data, if available */ + if (sce) + nimf->format = sce->r.im_format; + + /* transfer render format toggle to node format toggle */ + for (sock=node->inputs.first; sock; sock=sock->next) { + NodeImageMultiFileSocket *simf = sock->storage; + simf->use_node_format = simf->use_render_format; + } + + /* we do have preview now */ + node->flag |= NODE_PREVIEW; + } + } +} + static void do_versions(FileData *fd, Library *lib, Main *main) { /* WATCH IT!!!: pointers from libdata have not been converted */ @@ -13164,6 +13235,21 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } } + if (main->versionfile < 262 || (main->versionfile == 262 && main->subversionfile < 1)) + { + /* update use flags for node sockets (was only temporary before) */ + Scene *sce; + bNodeTree *ntree; + + for (sce=main->scene.first; sce; sce=sce->id.next) + if (sce->nodetree) + do_versions_nodetree_multi_file_output_format_2_62_1(sce, sce->nodetree); + + /* XXX can't associate with scene for group nodes, image format will stay uninitialized */ + for (ntree=main->nodetree.first; ntree; ntree=ntree->id.next) + do_versions_nodetree_multi_file_output_format_2_62_1(NULL, ntree); + } + /* WATCH IT!!!: pointers from libdata have not been converted yet here! */ /* WATCH IT 2!: Userdef struct init has to be in editors/interface/resources.c! */ diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index d5ed3096c79..b063a1656ab 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -727,7 +727,7 @@ static void write_nodetree(WriteData *wd, bNodeTree *ntree) writestruct(wd, DATA, node->typeinfo->storagename, 1, node->storage); } - if (node->type==CMP_NODE_OUTPUT_MULTI_FILE) { + if (node->type==CMP_NODE_OUTPUT_FILE) { /* inputs have own storage data */ for (sock=node->inputs.first; sock; sock=sock->next) writestruct(wd, DATA, "NodeImageMultiFileSocket", 1, sock->storage); |