diff options
author | Hans Goudey <h.goudey@me.com> | 2022-06-02 23:26:34 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2022-06-02 23:26:34 +0300 |
commit | 4a72b64c7b36ec82f416fed7e12b6fb6b6a2b352 (patch) | |
tree | b5fa1539542e9b8299bfbebde143385fa897d8f2 /source/blender | |
parent | 545b9ddc34da54a04f50e40cd0993ee88c4d56de (diff) |
Cleanup: Split large block of versioning code to separate function
Large blocks of versioning code should be separate to keep
`blo_do_versions_300` more readable.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenloader/intern/versioning_300.c | 486 |
1 files changed, 245 insertions, 241 deletions
diff --git a/source/blender/blenloader/intern/versioning_300.c b/source/blender/blenloader/intern/versioning_300.c index 98c860792b2..76d12cc1109 100644 --- a/source/blender/blenloader/intern/versioning_300.c +++ b/source/blender/blenloader/intern/versioning_300.c @@ -1371,6 +1371,250 @@ static void version_liboverride_rnacollections_insertion_animdata(ID *id) } } +static void versioning_replace_legacy_combined_and_separate_color_nodes(bNodeTree *ntree) +{ + /* In geometry nodes, replace shader combine/separate color nodes with function nodes */ + if (ntree->type == NTREE_GEOMETRY) { + version_node_input_socket_name(ntree, SH_NODE_COMBRGB_LEGACY, "R", "Red"); + version_node_input_socket_name(ntree, SH_NODE_COMBRGB_LEGACY, "G", "Green"); + version_node_input_socket_name(ntree, SH_NODE_COMBRGB_LEGACY, "B", "Blue"); + version_node_output_socket_name(ntree, SH_NODE_COMBRGB_LEGACY, "Image", "Color"); + + version_node_output_socket_name(ntree, SH_NODE_SEPRGB_LEGACY, "R", "Red"); + version_node_output_socket_name(ntree, SH_NODE_SEPRGB_LEGACY, "G", "Green"); + version_node_output_socket_name(ntree, SH_NODE_SEPRGB_LEGACY, "B", "Blue"); + version_node_input_socket_name(ntree, SH_NODE_SEPRGB_LEGACY, "Image", "Color"); + + LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { + switch (node->type) { + case SH_NODE_COMBRGB_LEGACY: { + node->type = FN_NODE_COMBINE_COLOR; + NodeCombSepColor *storage = (NodeCombSepColor *)MEM_callocN(sizeof(NodeCombSepColor), + __func__); + storage->mode = NODE_COMBSEP_COLOR_RGB; + strcpy(node->idname, "FunctionNodeCombineColor"); + node->storage = storage; + break; + } + case SH_NODE_SEPRGB_LEGACY: { + node->type = FN_NODE_SEPARATE_COLOR; + NodeCombSepColor *storage = (NodeCombSepColor *)MEM_callocN(sizeof(NodeCombSepColor), + __func__); + storage->mode = NODE_COMBSEP_COLOR_RGB; + strcpy(node->idname, "FunctionNodeSeparateColor"); + node->storage = storage; + break; + } + } + } + } + + /* In compositing nodes, replace combine/separate RGBA/HSVA/YCbCrA/YCCA nodes with + * combine/separate color */ + if (ntree->type == NTREE_COMPOSIT) { + version_node_input_socket_name(ntree, CMP_NODE_COMBRGBA_LEGACY, "R", "Red"); + version_node_input_socket_name(ntree, CMP_NODE_COMBRGBA_LEGACY, "G", "Green"); + version_node_input_socket_name(ntree, CMP_NODE_COMBRGBA_LEGACY, "B", "Blue"); + version_node_input_socket_name(ntree, CMP_NODE_COMBRGBA_LEGACY, "A", "Alpha"); + + version_node_input_socket_name(ntree, CMP_NODE_COMBHSVA_LEGACY, "H", "Red"); + version_node_input_socket_name(ntree, CMP_NODE_COMBHSVA_LEGACY, "S", "Green"); + version_node_input_socket_name(ntree, CMP_NODE_COMBHSVA_LEGACY, "V", "Blue"); + version_node_input_socket_name(ntree, CMP_NODE_COMBHSVA_LEGACY, "A", "Alpha"); + + version_node_input_socket_name(ntree, CMP_NODE_COMBYCCA_LEGACY, "Y", "Red"); + version_node_input_socket_name(ntree, CMP_NODE_COMBYCCA_LEGACY, "Cb", "Green"); + version_node_input_socket_name(ntree, CMP_NODE_COMBYCCA_LEGACY, "Cr", "Blue"); + version_node_input_socket_name(ntree, CMP_NODE_COMBYCCA_LEGACY, "A", "Alpha"); + + version_node_input_socket_name(ntree, CMP_NODE_COMBYUVA_LEGACY, "Y", "Red"); + version_node_input_socket_name(ntree, CMP_NODE_COMBYUVA_LEGACY, "U", "Green"); + version_node_input_socket_name(ntree, CMP_NODE_COMBYUVA_LEGACY, "V", "Blue"); + version_node_input_socket_name(ntree, CMP_NODE_COMBYUVA_LEGACY, "A", "Alpha"); + + version_node_output_socket_name(ntree, CMP_NODE_SEPRGBA_LEGACY, "R", "Red"); + version_node_output_socket_name(ntree, CMP_NODE_SEPRGBA_LEGACY, "G", "Green"); + version_node_output_socket_name(ntree, CMP_NODE_SEPRGBA_LEGACY, "B", "Blue"); + version_node_output_socket_name(ntree, CMP_NODE_SEPRGBA_LEGACY, "A", "Alpha"); + + version_node_output_socket_name(ntree, CMP_NODE_SEPHSVA_LEGACY, "H", "Red"); + version_node_output_socket_name(ntree, CMP_NODE_SEPHSVA_LEGACY, "S", "Green"); + version_node_output_socket_name(ntree, CMP_NODE_SEPHSVA_LEGACY, "V", "Blue"); + version_node_output_socket_name(ntree, CMP_NODE_SEPHSVA_LEGACY, "A", "Alpha"); + + version_node_output_socket_name(ntree, CMP_NODE_SEPYCCA_LEGACY, "Y", "Red"); + version_node_output_socket_name(ntree, CMP_NODE_SEPYCCA_LEGACY, "Cb", "Green"); + version_node_output_socket_name(ntree, CMP_NODE_SEPYCCA_LEGACY, "Cr", "Blue"); + version_node_output_socket_name(ntree, CMP_NODE_SEPYCCA_LEGACY, "A", "Alpha"); + + version_node_output_socket_name(ntree, CMP_NODE_SEPYUVA_LEGACY, "Y", "Red"); + version_node_output_socket_name(ntree, CMP_NODE_SEPYUVA_LEGACY, "U", "Green"); + version_node_output_socket_name(ntree, CMP_NODE_SEPYUVA_LEGACY, "V", "Blue"); + version_node_output_socket_name(ntree, CMP_NODE_SEPYUVA_LEGACY, "A", "Alpha"); + + LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { + switch (node->type) { + case CMP_NODE_COMBRGBA_LEGACY: { + node->type = CMP_NODE_COMBINE_COLOR; + NodeCMPCombSepColor *storage = (NodeCMPCombSepColor *)MEM_callocN( + sizeof(NodeCMPCombSepColor), __func__); + storage->mode = CMP_NODE_COMBSEP_COLOR_RGB; + strcpy(node->idname, "CompositorNodeCombineColor"); + node->storage = storage; + break; + } + case CMP_NODE_COMBHSVA_LEGACY: { + node->type = CMP_NODE_COMBINE_COLOR; + NodeCMPCombSepColor *storage = (NodeCMPCombSepColor *)MEM_callocN( + sizeof(NodeCMPCombSepColor), __func__); + storage->mode = CMP_NODE_COMBSEP_COLOR_HSV; + strcpy(node->idname, "CompositorNodeCombineColor"); + node->storage = storage; + break; + } + case CMP_NODE_COMBYCCA_LEGACY: { + node->type = CMP_NODE_COMBINE_COLOR; + NodeCMPCombSepColor *storage = (NodeCMPCombSepColor *)MEM_callocN( + sizeof(NodeCMPCombSepColor), __func__); + storage->mode = CMP_NODE_COMBSEP_COLOR_YCC; + storage->ycc_mode = node->custom1; + strcpy(node->idname, "CompositorNodeCombineColor"); + node->storage = storage; + break; + } + case CMP_NODE_COMBYUVA_LEGACY: { + node->type = CMP_NODE_COMBINE_COLOR; + NodeCMPCombSepColor *storage = (NodeCMPCombSepColor *)MEM_callocN( + sizeof(NodeCMPCombSepColor), __func__); + storage->mode = CMP_NODE_COMBSEP_COLOR_YUV; + strcpy(node->idname, "CompositorNodeCombineColor"); + node->storage = storage; + break; + } + case CMP_NODE_SEPRGBA_LEGACY: { + node->type = CMP_NODE_SEPARATE_COLOR; + NodeCMPCombSepColor *storage = (NodeCMPCombSepColor *)MEM_callocN( + sizeof(NodeCMPCombSepColor), __func__); + storage->mode = CMP_NODE_COMBSEP_COLOR_RGB; + strcpy(node->idname, "CompositorNodeSeparateColor"); + node->storage = storage; + break; + } + case CMP_NODE_SEPHSVA_LEGACY: { + node->type = CMP_NODE_SEPARATE_COLOR; + NodeCMPCombSepColor *storage = (NodeCMPCombSepColor *)MEM_callocN( + sizeof(NodeCMPCombSepColor), __func__); + storage->mode = CMP_NODE_COMBSEP_COLOR_HSV; + strcpy(node->idname, "CompositorNodeSeparateColor"); + node->storage = storage; + break; + } + case CMP_NODE_SEPYCCA_LEGACY: { + node->type = CMP_NODE_SEPARATE_COLOR; + NodeCMPCombSepColor *storage = (NodeCMPCombSepColor *)MEM_callocN( + sizeof(NodeCMPCombSepColor), __func__); + storage->mode = CMP_NODE_COMBSEP_COLOR_YCC; + storage->ycc_mode = node->custom1; + strcpy(node->idname, "CompositorNodeSeparateColor"); + node->storage = storage; + break; + } + case CMP_NODE_SEPYUVA_LEGACY: { + node->type = CMP_NODE_SEPARATE_COLOR; + NodeCMPCombSepColor *storage = (NodeCMPCombSepColor *)MEM_callocN( + sizeof(NodeCMPCombSepColor), __func__); + storage->mode = CMP_NODE_COMBSEP_COLOR_YUV; + strcpy(node->idname, "CompositorNodeSeparateColor"); + node->storage = storage; + break; + } + } + } + } + + /* In texture nodes, replace combine/separate RGBA with combine/separate color */ + if (ntree->type == NTREE_TEXTURE) { + LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { + switch (node->type) { + case TEX_NODE_COMPOSE_LEGACY: { + node->type = TEX_NODE_COMBINE_COLOR; + node->custom1 = NODE_COMBSEP_COLOR_RGB; + strcpy(node->idname, "TextureNodeCombineColor"); + break; + } + case TEX_NODE_DECOMPOSE_LEGACY: { + node->type = TEX_NODE_SEPARATE_COLOR; + node->custom1 = NODE_COMBSEP_COLOR_RGB; + strcpy(node->idname, "TextureNodeSeparateColor"); + break; + } + } + } + } + + /* In shader nodes, replace combine/separate RGB/HSV with combine/separate color */ + if (ntree->type == NTREE_SHADER) { + version_node_input_socket_name(ntree, SH_NODE_COMBRGB_LEGACY, "R", "Red"); + version_node_input_socket_name(ntree, SH_NODE_COMBRGB_LEGACY, "G", "Green"); + version_node_input_socket_name(ntree, SH_NODE_COMBRGB_LEGACY, "B", "Blue"); + version_node_output_socket_name(ntree, SH_NODE_COMBRGB_LEGACY, "Image", "Color"); + + version_node_input_socket_name(ntree, SH_NODE_COMBHSV_LEGACY, "H", "Red"); + version_node_input_socket_name(ntree, SH_NODE_COMBHSV_LEGACY, "S", "Green"); + version_node_input_socket_name(ntree, SH_NODE_COMBHSV_LEGACY, "V", "Blue"); + + version_node_output_socket_name(ntree, SH_NODE_SEPRGB_LEGACY, "R", "Red"); + version_node_output_socket_name(ntree, SH_NODE_SEPRGB_LEGACY, "G", "Green"); + version_node_output_socket_name(ntree, SH_NODE_SEPRGB_LEGACY, "B", "Blue"); + version_node_input_socket_name(ntree, SH_NODE_SEPRGB_LEGACY, "Image", "Color"); + + version_node_output_socket_name(ntree, SH_NODE_SEPHSV_LEGACY, "H", "Red"); + version_node_output_socket_name(ntree, SH_NODE_SEPHSV_LEGACY, "S", "Green"); + version_node_output_socket_name(ntree, SH_NODE_SEPHSV_LEGACY, "V", "Blue"); + + LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { + switch (node->type) { + case SH_NODE_COMBRGB_LEGACY: { + node->type = SH_NODE_COMBINE_COLOR; + NodeCombSepColor *storage = (NodeCombSepColor *)MEM_callocN(sizeof(NodeCombSepColor), + __func__); + storage->mode = NODE_COMBSEP_COLOR_RGB; + strcpy(node->idname, "ShaderNodeCombineColor"); + node->storage = storage; + break; + } + case SH_NODE_COMBHSV_LEGACY: { + node->type = SH_NODE_COMBINE_COLOR; + NodeCombSepColor *storage = (NodeCombSepColor *)MEM_callocN(sizeof(NodeCombSepColor), + __func__); + storage->mode = NODE_COMBSEP_COLOR_HSV; + strcpy(node->idname, "ShaderNodeCombineColor"); + node->storage = storage; + break; + } + case SH_NODE_SEPRGB_LEGACY: { + node->type = SH_NODE_SEPARATE_COLOR; + NodeCombSepColor *storage = (NodeCombSepColor *)MEM_callocN(sizeof(NodeCombSepColor), + __func__); + storage->mode = NODE_COMBSEP_COLOR_RGB; + strcpy(node->idname, "ShaderNodeSeparateColor"); + node->storage = storage; + break; + } + case SH_NODE_SEPHSV_LEGACY: { + node->type = SH_NODE_SEPARATE_COLOR; + NodeCombSepColor *storage = (NodeCombSepColor *)MEM_callocN(sizeof(NodeCombSepColor), + __func__); + storage->mode = NODE_COMBSEP_COLOR_HSV; + strcpy(node->idname, "ShaderNodeSeparateColor"); + node->storage = storage; + break; + } + } + } + } +} + /* NOLINTNEXTLINE: readability-function-size */ void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain) { @@ -2789,248 +3033,8 @@ void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain) { /* Keep this block, even when empty. */ - /* Replace legacy combine/separate color nodes */ FOREACH_NODETREE_BEGIN (bmain, ntree, id) { - /* In geometry nodes, replace shader combine/separate color nodes with function nodes */ - if (ntree->type == NTREE_GEOMETRY) { - version_node_input_socket_name(ntree, SH_NODE_COMBRGB_LEGACY, "R", "Red"); - version_node_input_socket_name(ntree, SH_NODE_COMBRGB_LEGACY, "G", "Green"); - version_node_input_socket_name(ntree, SH_NODE_COMBRGB_LEGACY, "B", "Blue"); - version_node_output_socket_name(ntree, SH_NODE_COMBRGB_LEGACY, "Image", "Color"); - - version_node_output_socket_name(ntree, SH_NODE_SEPRGB_LEGACY, "R", "Red"); - version_node_output_socket_name(ntree, SH_NODE_SEPRGB_LEGACY, "G", "Green"); - version_node_output_socket_name(ntree, SH_NODE_SEPRGB_LEGACY, "B", "Blue"); - version_node_input_socket_name(ntree, SH_NODE_SEPRGB_LEGACY, "Image", "Color"); - - LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { - switch (node->type) { - case SH_NODE_COMBRGB_LEGACY: { - node->type = FN_NODE_COMBINE_COLOR; - NodeCombSepColor *storage = (NodeCombSepColor *)MEM_callocN(sizeof(NodeCombSepColor), - __func__); - storage->mode = NODE_COMBSEP_COLOR_RGB; - strcpy(node->idname, "FunctionNodeCombineColor"); - node->storage = storage; - break; - } - case SH_NODE_SEPRGB_LEGACY: { - node->type = FN_NODE_SEPARATE_COLOR; - NodeCombSepColor *storage = (NodeCombSepColor *)MEM_callocN(sizeof(NodeCombSepColor), - __func__); - storage->mode = NODE_COMBSEP_COLOR_RGB; - strcpy(node->idname, "FunctionNodeSeparateColor"); - node->storage = storage; - break; - } - } - } - } - - /* In compositing nodes, replace combine/separate RGBA/HSVA/YCbCrA/YCCA nodes with - * combine/separate color */ - if (ntree->type == NTREE_COMPOSIT) { - version_node_input_socket_name(ntree, CMP_NODE_COMBRGBA_LEGACY, "R", "Red"); - version_node_input_socket_name(ntree, CMP_NODE_COMBRGBA_LEGACY, "G", "Green"); - version_node_input_socket_name(ntree, CMP_NODE_COMBRGBA_LEGACY, "B", "Blue"); - version_node_input_socket_name(ntree, CMP_NODE_COMBRGBA_LEGACY, "A", "Alpha"); - - version_node_input_socket_name(ntree, CMP_NODE_COMBHSVA_LEGACY, "H", "Red"); - version_node_input_socket_name(ntree, CMP_NODE_COMBHSVA_LEGACY, "S", "Green"); - version_node_input_socket_name(ntree, CMP_NODE_COMBHSVA_LEGACY, "V", "Blue"); - version_node_input_socket_name(ntree, CMP_NODE_COMBHSVA_LEGACY, "A", "Alpha"); - - version_node_input_socket_name(ntree, CMP_NODE_COMBYCCA_LEGACY, "Y", "Red"); - version_node_input_socket_name(ntree, CMP_NODE_COMBYCCA_LEGACY, "Cb", "Green"); - version_node_input_socket_name(ntree, CMP_NODE_COMBYCCA_LEGACY, "Cr", "Blue"); - version_node_input_socket_name(ntree, CMP_NODE_COMBYCCA_LEGACY, "A", "Alpha"); - - version_node_input_socket_name(ntree, CMP_NODE_COMBYUVA_LEGACY, "Y", "Red"); - version_node_input_socket_name(ntree, CMP_NODE_COMBYUVA_LEGACY, "U", "Green"); - version_node_input_socket_name(ntree, CMP_NODE_COMBYUVA_LEGACY, "V", "Blue"); - version_node_input_socket_name(ntree, CMP_NODE_COMBYUVA_LEGACY, "A", "Alpha"); - - version_node_output_socket_name(ntree, CMP_NODE_SEPRGBA_LEGACY, "R", "Red"); - version_node_output_socket_name(ntree, CMP_NODE_SEPRGBA_LEGACY, "G", "Green"); - version_node_output_socket_name(ntree, CMP_NODE_SEPRGBA_LEGACY, "B", "Blue"); - version_node_output_socket_name(ntree, CMP_NODE_SEPRGBA_LEGACY, "A", "Alpha"); - - version_node_output_socket_name(ntree, CMP_NODE_SEPHSVA_LEGACY, "H", "Red"); - version_node_output_socket_name(ntree, CMP_NODE_SEPHSVA_LEGACY, "S", "Green"); - version_node_output_socket_name(ntree, CMP_NODE_SEPHSVA_LEGACY, "V", "Blue"); - version_node_output_socket_name(ntree, CMP_NODE_SEPHSVA_LEGACY, "A", "Alpha"); - - version_node_output_socket_name(ntree, CMP_NODE_SEPYCCA_LEGACY, "Y", "Red"); - version_node_output_socket_name(ntree, CMP_NODE_SEPYCCA_LEGACY, "Cb", "Green"); - version_node_output_socket_name(ntree, CMP_NODE_SEPYCCA_LEGACY, "Cr", "Blue"); - version_node_output_socket_name(ntree, CMP_NODE_SEPYCCA_LEGACY, "A", "Alpha"); - - version_node_output_socket_name(ntree, CMP_NODE_SEPYUVA_LEGACY, "Y", "Red"); - version_node_output_socket_name(ntree, CMP_NODE_SEPYUVA_LEGACY, "U", "Green"); - version_node_output_socket_name(ntree, CMP_NODE_SEPYUVA_LEGACY, "V", "Blue"); - version_node_output_socket_name(ntree, CMP_NODE_SEPYUVA_LEGACY, "A", "Alpha"); - - LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { - switch (node->type) { - case CMP_NODE_COMBRGBA_LEGACY: { - node->type = CMP_NODE_COMBINE_COLOR; - NodeCMPCombSepColor *storage = (NodeCMPCombSepColor *)MEM_callocN( - sizeof(NodeCMPCombSepColor), __func__); - storage->mode = CMP_NODE_COMBSEP_COLOR_RGB; - strcpy(node->idname, "CompositorNodeCombineColor"); - node->storage = storage; - break; - } - case CMP_NODE_COMBHSVA_LEGACY: { - node->type = CMP_NODE_COMBINE_COLOR; - NodeCMPCombSepColor *storage = (NodeCMPCombSepColor *)MEM_callocN( - sizeof(NodeCMPCombSepColor), __func__); - storage->mode = CMP_NODE_COMBSEP_COLOR_HSV; - strcpy(node->idname, "CompositorNodeCombineColor"); - node->storage = storage; - break; - } - case CMP_NODE_COMBYCCA_LEGACY: { - node->type = CMP_NODE_COMBINE_COLOR; - NodeCMPCombSepColor *storage = (NodeCMPCombSepColor *)MEM_callocN( - sizeof(NodeCMPCombSepColor), __func__); - storage->mode = CMP_NODE_COMBSEP_COLOR_YCC; - storage->ycc_mode = node->custom1; - strcpy(node->idname, "CompositorNodeCombineColor"); - node->storage = storage; - break; - } - case CMP_NODE_COMBYUVA_LEGACY: { - node->type = CMP_NODE_COMBINE_COLOR; - NodeCMPCombSepColor *storage = (NodeCMPCombSepColor *)MEM_callocN( - sizeof(NodeCMPCombSepColor), __func__); - storage->mode = CMP_NODE_COMBSEP_COLOR_YUV; - strcpy(node->idname, "CompositorNodeCombineColor"); - node->storage = storage; - break; - } - case CMP_NODE_SEPRGBA_LEGACY: { - node->type = CMP_NODE_SEPARATE_COLOR; - NodeCMPCombSepColor *storage = (NodeCMPCombSepColor *)MEM_callocN( - sizeof(NodeCMPCombSepColor), __func__); - storage->mode = CMP_NODE_COMBSEP_COLOR_RGB; - strcpy(node->idname, "CompositorNodeSeparateColor"); - node->storage = storage; - break; - } - case CMP_NODE_SEPHSVA_LEGACY: { - node->type = CMP_NODE_SEPARATE_COLOR; - NodeCMPCombSepColor *storage = (NodeCMPCombSepColor *)MEM_callocN( - sizeof(NodeCMPCombSepColor), __func__); - storage->mode = CMP_NODE_COMBSEP_COLOR_HSV; - strcpy(node->idname, "CompositorNodeSeparateColor"); - node->storage = storage; - break; - } - case CMP_NODE_SEPYCCA_LEGACY: { - node->type = CMP_NODE_SEPARATE_COLOR; - NodeCMPCombSepColor *storage = (NodeCMPCombSepColor *)MEM_callocN( - sizeof(NodeCMPCombSepColor), __func__); - storage->mode = CMP_NODE_COMBSEP_COLOR_YCC; - storage->ycc_mode = node->custom1; - strcpy(node->idname, "CompositorNodeSeparateColor"); - node->storage = storage; - break; - } - case CMP_NODE_SEPYUVA_LEGACY: { - node->type = CMP_NODE_SEPARATE_COLOR; - NodeCMPCombSepColor *storage = (NodeCMPCombSepColor *)MEM_callocN( - sizeof(NodeCMPCombSepColor), __func__); - storage->mode = CMP_NODE_COMBSEP_COLOR_YUV; - strcpy(node->idname, "CompositorNodeSeparateColor"); - node->storage = storage; - break; - } - } - } - } - - /* In texture nodes, replace combine/separate RGBA with combine/separate color */ - if (ntree->type == NTREE_TEXTURE) { - LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { - switch (node->type) { - case TEX_NODE_COMPOSE_LEGACY: { - node->type = TEX_NODE_COMBINE_COLOR; - node->custom1 = NODE_COMBSEP_COLOR_RGB; - strcpy(node->idname, "TextureNodeCombineColor"); - break; - } - case TEX_NODE_DECOMPOSE_LEGACY: { - node->type = TEX_NODE_SEPARATE_COLOR; - node->custom1 = NODE_COMBSEP_COLOR_RGB; - strcpy(node->idname, "TextureNodeSeparateColor"); - break; - } - } - } - } - - /* In shader nodes, replace combine/separate RGB/HSV with combine/separate color */ - if (ntree->type == NTREE_SHADER) { - version_node_input_socket_name(ntree, SH_NODE_COMBRGB_LEGACY, "R", "Red"); - version_node_input_socket_name(ntree, SH_NODE_COMBRGB_LEGACY, "G", "Green"); - version_node_input_socket_name(ntree, SH_NODE_COMBRGB_LEGACY, "B", "Blue"); - version_node_output_socket_name(ntree, SH_NODE_COMBRGB_LEGACY, "Image", "Color"); - - version_node_input_socket_name(ntree, SH_NODE_COMBHSV_LEGACY, "H", "Red"); - version_node_input_socket_name(ntree, SH_NODE_COMBHSV_LEGACY, "S", "Green"); - version_node_input_socket_name(ntree, SH_NODE_COMBHSV_LEGACY, "V", "Blue"); - - version_node_output_socket_name(ntree, SH_NODE_SEPRGB_LEGACY, "R", "Red"); - version_node_output_socket_name(ntree, SH_NODE_SEPRGB_LEGACY, "G", "Green"); - version_node_output_socket_name(ntree, SH_NODE_SEPRGB_LEGACY, "B", "Blue"); - version_node_input_socket_name(ntree, SH_NODE_SEPRGB_LEGACY, "Image", "Color"); - - version_node_output_socket_name(ntree, SH_NODE_SEPHSV_LEGACY, "H", "Red"); - version_node_output_socket_name(ntree, SH_NODE_SEPHSV_LEGACY, "S", "Green"); - version_node_output_socket_name(ntree, SH_NODE_SEPHSV_LEGACY, "V", "Blue"); - - LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { - switch (node->type) { - case SH_NODE_COMBRGB_LEGACY: { - node->type = SH_NODE_COMBINE_COLOR; - NodeCombSepColor *storage = (NodeCombSepColor *)MEM_callocN(sizeof(NodeCombSepColor), - __func__); - storage->mode = NODE_COMBSEP_COLOR_RGB; - strcpy(node->idname, "ShaderNodeCombineColor"); - node->storage = storage; - break; - } - case SH_NODE_COMBHSV_LEGACY: { - node->type = SH_NODE_COMBINE_COLOR; - NodeCombSepColor *storage = (NodeCombSepColor *)MEM_callocN(sizeof(NodeCombSepColor), - __func__); - storage->mode = NODE_COMBSEP_COLOR_HSV; - strcpy(node->idname, "ShaderNodeCombineColor"); - node->storage = storage; - break; - } - case SH_NODE_SEPRGB_LEGACY: { - node->type = SH_NODE_SEPARATE_COLOR; - NodeCombSepColor *storage = (NodeCombSepColor *)MEM_callocN(sizeof(NodeCombSepColor), - __func__); - storage->mode = NODE_COMBSEP_COLOR_RGB; - strcpy(node->idname, "ShaderNodeSeparateColor"); - node->storage = storage; - break; - } - case SH_NODE_SEPHSV_LEGACY: { - node->type = SH_NODE_SEPARATE_COLOR; - NodeCombSepColor *storage = (NodeCombSepColor *)MEM_callocN(sizeof(NodeCombSepColor), - __func__); - storage->mode = NODE_COMBSEP_COLOR_HSV; - strcpy(node->idname, "ShaderNodeSeparateColor"); - node->storage = storage; - break; - } - } - } - } + versioning_replace_legacy_combined_and_separate_color_nodes(ntree); } FOREACH_NODETREE_END; |