diff options
author | Lukas Toenne <lukas.toenne@googlemail.com> | 2012-05-11 12:06:01 +0400 |
---|---|---|
committer | Lukas Toenne <lukas.toenne@googlemail.com> | 2012-05-11 12:06:01 +0400 |
commit | 9d91bc38d303e4937bb56dc75d95f11936de5ff9 (patch) | |
tree | 56ce4861cada738ce5f48bfdef35a32191c306ab /source/blender/blenloader | |
parent | ce17c35240a332038090628cda34d00a9996215d (diff) |
A couple more changes to the file and image nodes to improve access to layers that don't follow Blender's rlayer.rpass naming scheme.
--- Changes to File Output node ---
* Flat layer names in EXR multilayer files.
For a socket with name "AAA" the previous resulting EXR layer name would be "AAA.AAA", i.e. the render layer as well as render pass would use the socket name.
Now the "render_layer.render_pass" scheme is ignored in multilayer files, socket names are directly written to EXR layers (EXR layer name is "AAA" in this example). If sockets should have a notion of "render layer" this can still be achieved by explicitly adding a separator, e.g. "AAA.BBB". When loading such layers into a Blender Image struct, the name is interpreted as a "render_layer.render_pass" again (although the image node does not care about it, see below).
* Socket sub-paths (for singlelayer) or layer names (for multilayer) are stored in dedicated string variables in the socket storage data. This way the RNA can define precise string subtypes (PROP_FILEPATH) and length. The file/layer slots are defined as separate structs with own name properties in the RNA as well, so they can be used nicely with the list template.
* Ensure unique socket paths/layer names to prevent overwriting of files and layers respectively.
--- Changes to Image node ---
* Loading multilayer OpenEXR files has improved layer name splitting into render layer + render pass names now. This properly supports arbitrary EXR layer names now.
Example:
OpenEXR layer name: AAA.BBB.CCC
is split into
Render layer name: AAA.BBB
Render pass name: CCC
If the layer name has no '.' separators the render layer name is empty.
* Image node ignores the selected render layer in the image user data. Instead all existing layers are displayed at the same time by combining the render layer names with render pass names again, to reconstruct the original EXR layer name. This avoids the problem that render layers with empty name are not selectetable in the dropdown and allows using all image layers at the same time without duplicating the node.
Diffstat (limited to 'source/blender/blenloader')
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 66 | ||||
-rw-r--r-- | source/blender/blenloader/intern/writefile.c | 5 |
2 files changed, 71 insertions, 0 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 5bf2c8e53e2..c76261418f8 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -6840,6 +6840,52 @@ static void do_versions_nodetree_multi_file_output_path_2_64_0(bNodeTree *ntree) } } +static void do_versions_nodetree_file_output_layers_2_64_5(bNodeTree *ntree) +{ + bNode *node; + + for (node=ntree->nodes.first; node; node=node->next) { + if (node->type==CMP_NODE_OUTPUT_FILE) { + bNodeSocket *sock; + for (sock=node->inputs.first; sock; sock=sock->next) { + NodeImageMultiFileSocket *input = sock->storage; + + /* multilayer names are stored as separate strings now, + * used the path string before, so copy it over. + */ + BLI_strncpy(input->layer, input->path, sizeof(input->layer)); + + /* paths/layer names also have to be unique now, initial check */ + ntreeCompositOutputFileUniquePath(&node->inputs, sock, input->path, '_'); + ntreeCompositOutputFileUniqueLayer(&node->inputs, sock, input->layer, '_'); + } + } + } +} + +static void do_versions_nodetree_image_layer_2_64_5(bNodeTree *ntree) +{ + bNode *node; + + for (node=ntree->nodes.first; node; node=node->next) { + if (node->type==CMP_NODE_IMAGE) { + ImageUser *iuser= (ImageUser *)node->storage; + bNodeSocket *sock; + for (sock=node->outputs.first; sock; sock=sock->next) { + NodeImageLayer *output = MEM_callocN(sizeof(NodeImageLayer), "node image layer"); + + /* take layer index from image user (this is ignored from now on) */ + output->layer_index = iuser->layer; + /* take pass index both from current storage ptr (actually an int) */ + output->pass_index = GET_INT_FROM_POINTER(sock->storage); + + /* replace socket data pointer */ + sock->storage = output; + } + } + } +} + static void do_versions(FileData *fd, Library *lib, Main *main) { /* WATCH IT!!!: pointers from libdata have not been converted */ @@ -7456,6 +7502,26 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } } + if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 5)) + { + { + /* file output node paths are now stored in the file info struct instead socket name */ + Scene *sce; + bNodeTree *ntree; + + for (sce = main->scene.first; sce; sce=sce->id.next) { + if (sce->nodetree) { + do_versions_nodetree_file_output_layers_2_64_5(sce->nodetree); + do_versions_nodetree_image_layer_2_64_5(sce->nodetree); + } + } + for (ntree = main->nodetree.first; ntree; ntree=ntree->id.next) { + do_versions_nodetree_file_output_layers_2_64_5(ntree); + do_versions_nodetree_image_layer_2_64_5(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 27ecf25fa91..f065ae238a6 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -734,6 +734,11 @@ static void write_nodetree(WriteData *wd, bNodeTree *ntree) for (sock=node->inputs.first; sock; sock=sock->next) writestruct(wd, DATA, "NodeImageMultiFileSocket", 1, sock->storage); } + if (node->type==CMP_NODE_IMAGE) { + /* write extra socket info */ + for (sock=node->outputs.first; sock; sock=sock->next) + writestruct(wd, DATA, "NodeImageLayer", 1, sock->storage); + } } for (link= ntree->links.first; link; link= link->next) |