[Bf-blender-cvs] [d8db5cb6003] master: Fix: upward compatibility of cryptomatte matte id.

Jeroen Bakker noreply at git.blender.org
Tue Dec 15 12:20:14 CET 2020


Commit: d8db5cb6003c84594f5c2f6a85a02f60bafe72c1
Author: Jeroen Bakker
Date:   Tue Dec 15 12:17:31 2020 +0100
Branches: master
https://developer.blender.org/rBd8db5cb6003c84594f5c2f6a85a02f60bafe72c1

Fix: upward compatibility of cryptomatte matte id.

The matte_id is stored in a different structure in 2.92. This patch will
write the old matte_id field so the files can be opened correctly in
older versions.

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

M	source/blender/blenkernel/intern/node.c

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

diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c
index 75f2fca1096..87997198334 100644
--- a/source/blender/blenkernel/intern/node.c
+++ b/source/blender/blenkernel/intern/node.c
@@ -60,6 +60,7 @@
 #include "BKE_anim_data.h"
 #include "BKE_animsys.h"
 #include "BKE_colortools.h"
+#include "BKE_cryptomatte.h"
 #include "BKE_global.h"
 #include "BKE_idprop.h"
 #include "BKE_idtype.h"
@@ -491,6 +492,10 @@ void ntreeBlendWrite(BlendWriter *writer, bNodeTree *ntree)
       }
       else if ((ntree->type == NTREE_COMPOSIT) && (node->type == CMP_NODE_CRYPTOMATTE)) {
         NodeCryptomatte *nc = (NodeCryptomatte *)node->storage;
+        /* Update the matte_id so the files can be opened in versions that don't
+         * use `CryptomatteEntry`. */
+        MEM_SAFE_FREE(nc->matte_id);
+        nc->matte_id = BKE_cryptomatte_entries_to_matte_id(nc);
         if (nc->matte_id) {
           BLO_write_string(writer, nc->matte_id);
         }
@@ -498,6 +503,7 @@ void ntreeBlendWrite(BlendWriter *writer, bNodeTree *ntree)
           BLO_write_struct(writer, CryptomatteEntry, entry);
         }
         BLO_write_struct_by_name(writer, node->typeinfo->storagename, node->storage);
+        MEM_SAFE_FREE(nc->matte_id);
       }
       else if (node->typeinfo != &NodeTypeUndefined) {
         BLO_write_struct_by_name(writer, node->typeinfo->storagename, node->storage);



More information about the Bf-blender-cvs mailing list