Commit: 8aa5fcbf2636d3fbd209ed572271ba3e8b1ad584
Author: Stefan Werner
Date:   Wed Apr 19 13:33:31 2017 +0200
Branches: temp_cryptomatte
https://developer.blender.org/rB8aa5fcbf2636d3fbd209ed572271ba3e8b1ad584

Compositing: Cryptomatte node now saves/loads correctly with custom number of 
inputs

===================================================================

M       source/blender/compositor/nodes/COM_CryptomatteNode.cpp
M       source/blender/nodes/composite/nodes/node_composite_cryptomatte.c

===================================================================

diff --git a/source/blender/compositor/nodes/COM_CryptomatteNode.cpp 
b/source/blender/compositor/nodes/COM_CryptomatteNode.cpp
index 03e403ca29d..bb0ca14e63b 100644
--- a/source/blender/compositor/nodes/COM_CryptomatteNode.cpp
+++ b/source/blender/compositor/nodes/COM_CryptomatteNode.cpp
@@ -268,7 +268,8 @@ void CryptomatteNode::convertToOperations(NodeConverter 
&converter, const Compos
 
        bNode *node = this->getbNode();
        NodeCryptomatte *cryptoMatteSettings = (NodeCryptomatte *)node->storage;
-       CryptomatteOperation *operation = new 
CryptomatteOperation(cryptoMatteSettings->num_inputs);
+
+       CryptomatteOperation *operation = new 
CryptomatteOperation(getNumberOfInputSockets()-1);
        if (cryptoMatteSettings) {
                std::string input = cryptoMatteSettings->matte_id;
                if (!input.empty()) {
@@ -294,7 +295,7 @@ void CryptomatteNode::convertToOperations(NodeConverter 
&converter, const Compos
 
        converter.addOperation(operation);
 
-       for (int i = 0; i < cryptoMatteSettings->num_inputs; i++) {
+       for (int i = 0; i < getNumberOfInputSockets()-1; i++) {
                converter.mapInputSocket(this->getInputSocket(i + 1), 
operation->getInputSocket(i));
        }
        
diff --git a/source/blender/nodes/composite/nodes/node_composite_cryptomatte.c 
b/source/blender/nodes/composite/nodes/node_composite_cryptomatte.c
index 60fd83f2630..5881f0b919f 100644
--- a/source/blender/nodes/composite/nodes/node_composite_cryptomatte.c
+++ b/source/blender/nodes/composite/nodes/node_composite_cryptomatte.c
@@ -92,11 +92,17 @@ int ntreeCompositCryptomatteRemoveSocket(bNodeTree *ntree, 
bNode *node)
        return 1;
 }
 
-static void init(bNodeTree *UNUSED(ntree), bNode *node)
+static void init(bNodeTree *ntree, bNode *node)
 {
        NodeCryptomatte *user = MEM_callocN(sizeof(NodeCryptomatte), 
"cryptomatte user");
-       user->num_inputs = 2;
        node->storage = user;
+
+
+       bNodeSocket *sock = nodeAddStaticSocket(ntree, node, SOCK_IN, 
SOCK_RGBA, PROP_NONE, "image", "Image");
+
+       /* add two inputs by default */
+       ntreeCompositCryptomatteAddSocket(ntree, node);
+       ntreeCompositCryptomatteAddSocket(ntree, node);
 }
 
 void register_node_type_cmp_cryptomatte(void)
@@ -104,7 +110,8 @@ void register_node_type_cmp_cryptomatte(void)
        static bNodeType ntype;
 
        cmp_node_type_base(&ntype, CMP_NODE_CRYPTOMATTE, "Cryptomatte", 
NODE_CLASS_CONVERTOR, 0);
-       node_type_socket_templates(&ntype, inputs, outputs);
+       //node_type_socket_templates(&ntype, inputs, outputs);
+       node_type_socket_templates(&ntype, NULL, outputs);
        node_type_init(&ntype, init);
        node_type_storage(&ntype, "NodeCryptomatte", 
node_free_standard_storage, node_copy_standard_storage);
        nodeRegisterType(&ntype);

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to