Commit: 5d611ded11fbe3e31a20aa00eb71c3514c3801e2
Author: Stefan Werner
Date:   Tue Apr 25 21:37:18 2017 +0200
Branches: temp_cryptomatte
https://developer.blender.org/rB5d611ded11fbe3e31a20aa00eb71c3514c3801e2

Cryptomatte: Some code style fixes

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

M       source/blender/compositor/nodes/COM_CryptomatteNode.cpp
M       source/blender/compositor/operations/COM_CryptomatteOperation.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 bb0ca14e63b..d0d3529c3bb 100644
--- a/source/blender/compositor/nodes/COM_CryptomatteNode.cpp
+++ b/source/blender/compositor/nodes/COM_CryptomatteNode.cpp
@@ -188,10 +188,10 @@ static inline float hash_to_float(uint32_t hash) {
 extern "C" void cryptomatte_add(NodeCryptomatte* n, float f)
 {
        static char number[64];
-       std::snprintf(number, sizeof(number), "<%.9g>", f);
-       if(::strnlen(n->matte_id, sizeof(n->matte_id)) == 0)
+       BLI_snprintf(number, sizeof(number), "<%.9g>", f);
+       if(BLI_strnlen(n->matte_id, sizeof(n->matte_id)) == 0)
        {
-               std::strncpy(n->matte_id, number, sizeof(n->matte_id));
+               BLI_strncpy(n->matte_id, number, sizeof(n->matte_id));
                return;
        }
        
diff --git a/source/blender/compositor/operations/COM_CryptomatteOperation.cpp 
b/source/blender/compositor/operations/COM_CryptomatteOperation.cpp
index c27c56fdd0e..6f911591268 100644
--- a/source/blender/compositor/operations/COM_CryptomatteOperation.cpp
+++ b/source/blender/compositor/operations/COM_CryptomatteOperation.cpp
@@ -39,7 +39,7 @@ void CryptomatteOperation::initExecution()
 
 void CryptomatteOperation::addObjectIndex(float objectIndex)
 {
-       if (objectIndex != 0.f) {
+       if (objectIndex != 0.0f) {
                m_objectIndex.push_back(objectIndex);
        }
 }
@@ -62,10 +62,12 @@ void CryptomatteOperation::executePixel(float output[4],
                        output[2] = ((float) ((m3hash << 16)) / (float) 
UINT32_MAX);
                }
                for(float f : m_objectIndex) {
-                       if (f == input[0])
+                       if (f == input[0]) {
                                output[3] += input[1];
-                       if (f == input[2])
+                       }
+                       if (f == input[2]) {
                                output[3] += input[3];
+                       }
                }
        }
 }
diff --git a/source/blender/nodes/composite/nodes/node_composite_cryptomatte.c 
b/source/blender/nodes/composite/nodes/node_composite_cryptomatte.c
index 5881f0b919f..c514ac59bb0 100644
--- a/source/blender/nodes/composite/nodes/node_composite_cryptomatte.c
+++ b/source/blender/nodes/composite/nodes/node_composite_cryptomatte.c
@@ -35,12 +35,6 @@
 extern void cryptomatte_add(NodeCryptomatte* n, float f);
 extern void cryptomatte_remove(NodeCryptomatte*n, float f);
 
-static bNodeSocketTemplate inputs[] = {
-       {       SOCK_RGBA, 1, N_("Image"),                      1.0f, 1.0f, 
1.0f, 1.0f},
-       {       SOCK_RGBA, 1, N_("Pass 1"),                     0.0f, 0.0f, 
0.0f, 1.0f},
-       {       SOCK_RGBA, 1, N_("Pass 2"),                     0.0f, 0.0f, 
0.0f, 1.0f},
-       {       -1, 0, ""       }
-};
 static bNodeSocketTemplate outputs[] = {
        {       SOCK_RGBA,      0, N_("Image")},
        {       SOCK_FLOAT, 0, N_("Matte")},
@@ -51,22 +45,22 @@ static bNodeSocketTemplate outputs[] = {
 void ntreeCompositCryptomatteSyncFromAdd(bNodeTree *UNUSED(ntree), bNode *node)
 {
        NodeCryptomatte *n = node->storage;
-       if(n->add[0] != 0.f) {
+       if(n->add[0] != 0.0f) {
                cryptomatte_add(n, n->add[0]);
-               n->add[0] = 0.f;
-               n->add[1] = 0.f;
-               n->add[2] = 0.f;
+               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.f) {
+       if(n->remove[0] != 0.0f) {
                cryptomatte_remove(n, n->remove[0]);
-               n->remove[0] = 0.f;
-               n->remove[1] = 0.f;
-               n->remove[2] = 0.f;
+               n->remove[0] = 0.0f;
+               n->remove[1] = 0.0f;
+               n->remove[2] = 0.0f;
        }
 }
 
@@ -98,7 +92,7 @@ static void init(bNodeTree *ntree, bNode *node)
        node->storage = user;
 
 
-       bNodeSocket *sock = nodeAddStaticSocket(ntree, node, SOCK_IN, 
SOCK_RGBA, PROP_NONE, "image", "Image");
+       nodeAddStaticSocket(ntree, node, SOCK_IN, SOCK_RGBA, PROP_NONE, 
"image", "Image");
 
        /* add two inputs by default */
        ntreeCompositCryptomatteAddSocket(ntree, node);
@@ -110,7 +104,6 @@ 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, NULL, outputs);
        node_type_init(&ntype, init);
        node_type_storage(&ntype, "NodeCryptomatte", 
node_free_standard_storage, node_copy_standard_storage);

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

Reply via email to