Cleanup: COM_convert_data_types parameters.

This commit is contained in:
Jeroen Bakker 2021-03-05 10:54:29 +01:00
parent b12be5a872
commit a592f7e6cb
3 changed files with 13 additions and 11 deletions

View File

@ -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();
}

View File

@ -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.

View File

@ -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);