[Bf-blender-cvs] [71cb0bdc433] master: Fix: File output uses incorrect resolution when first socket unused.

Jeroen Bakker noreply at git.blender.org
Mon Apr 12 10:14:05 CEST 2021


Commit: 71cb0bdc43368c5041daac5565697b36d54d5186
Author: Jeroen Bakker
Date:   Mon Apr 12 09:44:37 2021 +0200
Branches: master
https://developer.blender.org/rB71cb0bdc43368c5041daac5565697b36d54d5186

Fix: File output uses incorrect resolution when first socket unused.

File output node always received the resolution from the first socket.
When that socket didn't had a link it would use a resolution of 0,0.
What lead to not saving the file at all.

This only effected Multi layer OpenEXR files.
This change would go over all the links to find the first valid
resolution.

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

M	source/blender/compositor/intern/COM_NodeOperation.cc
M	source/blender/compositor/intern/COM_NodeOperation.h
M	source/blender/compositor/operations/COM_OutputFileOperation.cc

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

diff --git a/source/blender/compositor/intern/COM_NodeOperation.cc b/source/blender/compositor/intern/COM_NodeOperation.cc
index 35e7f1adc7d..0bb8e0ef674 100644
--- a/source/blender/compositor/intern/COM_NodeOperation.cc
+++ b/source/blender/compositor/intern/COM_NodeOperation.cc
@@ -62,15 +62,29 @@ void NodeOperation::addOutputSocket(DataType datatype)
 void NodeOperation::determineResolution(unsigned int resolution[2],
                                         unsigned int preferredResolution[2])
 {
-  if (m_resolutionInputSocketIndex < m_inputs.size()) {
+  unsigned int used_resolution_index = 0;
+  if (m_resolutionInputSocketIndex == RESOLUTION_INPUT_ANY) {
+    for (NodeOperationInput &input : m_inputs) {
+      unsigned int any_resolution[2] = {0, 0};
+      input.determineResolution(any_resolution, preferredResolution);
+      if (any_resolution[0] * any_resolution[1] > 0) {
+        resolution[0] = any_resolution[0];
+        resolution[1] = any_resolution[1];
+        break;
+      }
+      used_resolution_index += 1;
+    }
+  }
+  else if (m_resolutionInputSocketIndex < m_inputs.size()) {
     NodeOperationInput &input = m_inputs[m_resolutionInputSocketIndex];
     input.determineResolution(resolution, preferredResolution);
+    used_resolution_index = m_resolutionInputSocketIndex;
   }
   unsigned int temp2[2] = {resolution[0], resolution[1]};
 
   unsigned int temp[2];
   for (unsigned int index = 0; index < m_inputs.size(); index++) {
-    if (index == this->m_resolutionInputSocketIndex) {
+    if (index == used_resolution_index) {
       continue;
     }
     NodeOperationInput &input = m_inputs[index];
diff --git a/source/blender/compositor/intern/COM_NodeOperation.h b/source/blender/compositor/intern/COM_NodeOperation.h
index d0bfe3c1311..baf3a0878b9 100644
--- a/source/blender/compositor/intern/COM_NodeOperation.h
+++ b/source/blender/compositor/intern/COM_NodeOperation.h
@@ -43,6 +43,13 @@ class WriteBufferOperation;
 class NodeOperation;
 typedef NodeOperation SocketReader;
 
+/**
+ * RESOLUTION_INPUT_ANY is a wildcard when any resolution of an input can be used.
+ * This solves the issue that the FileInputNode in a group node cannot find the
+ * correct resolution.
+ */
+static constexpr unsigned int RESOLUTION_INPUT_ANY = 999999;
+
 /**
  * \brief Resize modes of inputsockets
  * How are the input and working resolutions matched
diff --git a/source/blender/compositor/operations/COM_OutputFileOperation.cc b/source/blender/compositor/operations/COM_OutputFileOperation.cc
index 5184cd42b9e..1ee749b1a49 100644
--- a/source/blender/compositor/operations/COM_OutputFileOperation.cc
+++ b/source/blender/compositor/operations/COM_OutputFileOperation.cc
@@ -323,6 +323,7 @@ OutputOpenExrMultiLayerOperation::OutputOpenExrMultiLayerOperation(const Scene *
   this->m_exr_codec = exr_codec;
   this->m_exr_half_float = exr_half_float;
   this->m_viewName = viewName;
+  this->setResolutionInputSocketIndex(RESOLUTION_INPUT_ANY);
 }
 
 void OutputOpenExrMultiLayerOperation::add_layer(const char *name,



More information about the Bf-blender-cvs mailing list