diff options
Diffstat (limited to 'source/blender/nodes/composite/nodes/node_composite_cryptomatte.c')
-rw-r--r-- | source/blender/nodes/composite/nodes/node_composite_cryptomatte.c | 157 |
1 files changed, 0 insertions, 157 deletions
diff --git a/source/blender/nodes/composite/nodes/node_composite_cryptomatte.c b/source/blender/nodes/composite/nodes/node_composite_cryptomatte.c deleted file mode 100644 index f5308fe2671..00000000000 --- a/source/blender/nodes/composite/nodes/node_composite_cryptomatte.c +++ /dev/null @@ -1,157 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2018 Blender Foundation. - * All rights reserved. - */ - -/** \file - * \ingroup cmpnodes - */ - -#include "BLI_assert.h" -#include "BLI_dynstr.h" -#include "BLI_hash_mm3.h" -#include "BLI_utildefines.h" -#include "node_composite_util.h" - -static CryptomatteEntry *cryptomatte_find(NodeCryptomatte *n, float encoded_hash) -{ - LISTBASE_FOREACH (CryptomatteEntry *, entry, &n->entries) { - if (entry->encoded_hash == encoded_hash) { - return entry; - } - } - return NULL; -} - -static void cryptomatte_add(NodeCryptomatte *n, float f) -{ - /* Check if entry already exist. */ - if (cryptomatte_find(n, f) != NULL) { - return; - } - CryptomatteEntry *entry = MEM_callocN(sizeof(CryptomatteEntry), __func__); - entry->encoded_hash = f; - BLI_addtail(&n->entries, entry); -} - -static void cryptomatte_remove(NodeCryptomatte *n, float f) -{ - CryptomatteEntry *entry = cryptomatte_find(n, f); - if (entry == NULL) { - return; - } - - BLI_remlink(&n->entries, entry); - MEM_freeN(entry); -} - -static bNodeSocketTemplate outputs[] = { - {SOCK_RGBA, N_("Image")}, - {SOCK_FLOAT, N_("Matte")}, - {SOCK_RGBA, N_("Pick")}, - {-1, ""}, -}; - -void ntreeCompositCryptomatteSyncFromAdd(bNodeTree *UNUSED(ntree), bNode *node) -{ - NodeCryptomatte *n = node->storage; - if (n->add[0] != 0.0f) { - cryptomatte_add(n, n->add[0]); - n->add[0] = 0.0f; - n->add[1] = 0.0f; - n->add[2] = 0.0f; - } -} - -void ntreeCompositCryptomatteSyncFromRemove(bNodeTree *UNUSED(ntree), bNode *node) -{ - NodeCryptomatte *n = node->storage; - if (n->remove[0] != 0.0f) { - cryptomatte_remove(n, n->remove[0]); - n->remove[0] = 0.0f; - n->remove[1] = 0.0f; - n->remove[2] = 0.0f; - } -} - -bNodeSocket *ntreeCompositCryptomatteAddSocket(bNodeTree *ntree, bNode *node) -{ - NodeCryptomatte *n = node->storage; - char sockname[32]; - n->num_inputs++; - BLI_snprintf(sockname, sizeof(sockname), "Crypto %.2d", n->num_inputs - 1); - bNodeSocket *sock = nodeAddStaticSocket( - ntree, node, SOCK_IN, SOCK_RGBA, PROP_NONE, NULL, sockname); - return sock; -} - -int ntreeCompositCryptomatteRemoveSocket(bNodeTree *ntree, bNode *node) -{ - NodeCryptomatte *n = node->storage; - if (n->num_inputs < 2) { - return 0; - } - bNodeSocket *sock = node->inputs.last; - nodeRemoveSocket(ntree, node, sock); - n->num_inputs--; - return 1; -} - -static void init(bNodeTree *ntree, bNode *node) -{ - NodeCryptomatte *user = MEM_callocN(sizeof(NodeCryptomatte), "cryptomatte user"); - node->storage = user; - - nodeAddStaticSocket(ntree, node, SOCK_IN, SOCK_RGBA, PROP_NONE, "image", "Image"); - - /* Add three inputs by default, as recommended by the Cryptomatte specification. */ - ntreeCompositCryptomatteAddSocket(ntree, node); - ntreeCompositCryptomatteAddSocket(ntree, node); - ntreeCompositCryptomatteAddSocket(ntree, node); -} - -static void node_free_cryptomatte(bNode *node) -{ - NodeCryptomatte *nc = node->storage; - - if (nc) { - BLI_freelistN(&nc->entries); - MEM_freeN(nc); - } -} - -static void node_copy_cryptomatte(bNodeTree *UNUSED(dest_ntree), - bNode *dest_node, - const bNode *src_node) -{ - NodeCryptomatte *src_nc = src_node->storage; - NodeCryptomatte *dest_nc = MEM_dupallocN(src_nc); - - BLI_duplicatelist(&dest_nc->entries, &src_nc->entries); - dest_node->storage = dest_nc; -} - -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, NULL, outputs); - node_type_init(&ntype, init); - node_type_storage(&ntype, "NodeCryptomatte", node_free_cryptomatte, node_copy_cryptomatte); - nodeRegisterType(&ntype); -} |