[Bf-blender-cvs] [a592f7e6cbd] master: Cleanup: COM_convert_data_types parameters.

Jeroen Bakker noreply at git.blender.org
Fri Mar 5 14:06:33 CET 2021


Commit: a592f7e6cbd30c65360cdeb912bc29afb40a7daf
Author: Jeroen Bakker
Date:   Fri Mar 5 10:54:29 2021 +0100
Branches: master
https://developer.blender.org/rBa592f7e6cbd30c65360cdeb912bc29afb40a7daf

Cleanup: COM_convert_data_types parameters.

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

M	source/blender/compositor/intern/COM_Converter.cpp
M	source/blender/compositor/intern/COM_Converter.h
M	source/blender/compositor/intern/COM_NodeOperationBuilder.cpp

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

diff --git a/source/blender/compositor/intern/COM_Converter.cpp b/source/blender/compositor/intern/COM_Converter.cpp
index c8ac86ccd5b..7d897d29576 100644
--- a/source/blender/compositor/intern/COM_Converter.cpp
+++ b/source/blender/compositor/intern/COM_Converter.cpp
@@ -419,27 +419,28 @@ Node *COM_convert_bnode(bNode *b_node)
   return node;
 }
 
-NodeOperation *COM_convert_data_type(NodeOperationOutput *from, NodeOperationInput *to)
+/* TODO(jbakker): make this an std::optional<NodeOperation>. */
+NodeOperation *COM_convert_data_type(const NodeOperationOutput &from, const NodeOperationInput &to)
 {
-  DataType fromDatatype = from->getDataType();
-  DataType toDatatype = to->getDataType();
+  const DataType src_data_type = from.getDataType();
+  const DataType dst_data_type = to.getDataType();
 
-  if (fromDatatype == COM_DT_VALUE && toDatatype == COM_DT_COLOR) {
+  if (src_data_type == COM_DT_VALUE && dst_data_type == COM_DT_COLOR) {
     return new ConvertValueToColorOperation();
   }
-  if (fromDatatype == COM_DT_VALUE && toDatatype == COM_DT_VECTOR) {
+  if (src_data_type == COM_DT_VALUE && dst_data_type == COM_DT_VECTOR) {
     return new ConvertValueToVectorOperation();
   }
-  if (fromDatatype == COM_DT_COLOR && toDatatype == COM_DT_VALUE) {
+  if (src_data_type == COM_DT_COLOR && dst_data_type == COM_DT_VALUE) {
     return new ConvertColorToValueOperation();
   }
-  if (fromDatatype == COM_DT_COLOR && toDatatype == COM_DT_VECTOR) {
+  if (src_data_type == COM_DT_COLOR && dst_data_type == COM_DT_VECTOR) {
     return new ConvertColorToVectorOperation();
   }
-  if (fromDatatype == COM_DT_VECTOR && toDatatype == COM_DT_VALUE) {
+  if (src_data_type == COM_DT_VECTOR && dst_data_type == COM_DT_VALUE) {
     return new ConvertVectorToValueOperation();
   }
-  if (fromDatatype == COM_DT_VECTOR && toDatatype == COM_DT_COLOR) {
+  if (src_data_type == COM_DT_VECTOR && dst_data_type == COM_DT_COLOR) {
     return new ConvertVectorToColorOperation();
   }
 
diff --git a/source/blender/compositor/intern/COM_Converter.h b/source/blender/compositor/intern/COM_Converter.h
index f110cc99c62..59be34bf0e3 100644
--- a/source/blender/compositor/intern/COM_Converter.h
+++ b/source/blender/compositor/intern/COM_Converter.h
@@ -53,7 +53,8 @@ bool COM_bnode_is_fast_node(const bNode &b_node);
  * \brief This function will add a datetype conversion rule when the to-socket does not support the
  * from-socket actual data type.
  */
-NodeOperation *COM_convert_data_type(NodeOperationOutput *from, NodeOperationInput *to);
+NodeOperation *COM_convert_data_type(const NodeOperationOutput &from,
+                                     const NodeOperationInput &to);
 
 /**
  * \brief This function will add a resolution rule based on the settings of the NodeInput.
diff --git a/source/blender/compositor/intern/COM_NodeOperationBuilder.cpp b/source/blender/compositor/intern/COM_NodeOperationBuilder.cpp
index 769d1342819..37d8d44ec72 100644
--- a/source/blender/compositor/intern/COM_NodeOperationBuilder.cpp
+++ b/source/blender/compositor/intern/COM_NodeOperationBuilder.cpp
@@ -288,7 +288,7 @@ void NodeOperationBuilder::add_datatype_conversions()
   }
   for (Links::const_iterator it = convert_links.begin(); it != convert_links.end(); ++it) {
     const Link &link = *it;
-    NodeOperation *converter = COM_convert_data_type(link.from(), link.to());
+    NodeOperation *converter = COM_convert_data_type(*link.from(), *link.to());
     if (converter) {
       addOperation(converter);



More information about the Bf-blender-cvs mailing list