Fix #137654: Cryptomatte only works with first layer

The Cryptomatte node only works with the first view layer in a setup
where a view later is called ViewLayer and another called ViewLayer.001.
This is because the code used a prefix check to match the view layer to
the Cryptomatte type name, and since ViewLayer is a prefix of the other
ViewLayer.001, the check always matches the first ViewLayer.

To fix this, we just remove that guard condition and rely on later
checks.

Pull Request: https://projects.blender.org/blender/blender/pulls/137659
This commit is contained in:
Omar Emara
2025-04-17 13:15:34 +02:00
committed by Omar Emara
parent f442c86197
commit 520afd8998

View File

@@ -701,12 +701,8 @@ class CryptoMatteOperation : public BaseCryptoMatteOperation {
int view_layer_index = 0;
LISTBASE_FOREACH_INDEX (ViewLayer *, view_layer, &scene->view_layers, view_layer_index) {
/* Not the viewer layer used by the node. */
if (!StringRef(type_name).startswith(view_layer->name)) {
continue;
}
/* Find out which type of Cryptomatte layer the node uses. */
/* Find out which type of Cryptomatte layer the node uses, if non matched, then this is not
* the view layer used by the node and we check other view layers. */
const char *cryptomatte_type = nullptr;
const std::string layer_prefix = std::string(view_layer->name) + ".";
if (type_name == layer_prefix + RE_PASSNAME_CRYPTOMATTE_OBJECT) {
@@ -719,8 +715,9 @@ class CryptoMatteOperation : public BaseCryptoMatteOperation {
cryptomatte_type = RE_PASSNAME_CRYPTOMATTE_MATERIAL;
}
/* Not the view layer used by the node. */
if (!cryptomatte_type) {
return layers;
continue;
}
/* Each layer stores two ranks/levels, so do ceiling division by two. */