Merge branch 'blender-v5.0-release'

This commit is contained in:
Omar Emara
2025-10-10 14:53:43 +03:00
2 changed files with 13 additions and 1 deletions

View File

@@ -110,7 +110,8 @@ class MultiFunctionProcedureOperation : public PixelOperation {
/* Convert the given variable to the given expected type. This is done by adding an implicit
* conversion function whose output variable will be returned. If no conversion is needed, the
* given variable is returned as is. */
* given variable is returned as is. If conversion is not possible, a fallback default variable
* will b returned. */
mf::Variable *convert_variable(mf::Variable *variable, const mf::DataType expected_type);
/* Returns true if the operation operates on single values, that is, all of its inputs are single

View File

@@ -444,6 +444,7 @@ void MultiFunctionProcedureOperation::populate_operation_result(DOutputSocket ou
mf::Variable *MultiFunctionProcedureOperation::convert_variable(mf::Variable *variable,
const mf::DataType expected_type)
{
/* Conversion not needed. */
const mf::DataType variable_type = variable->data_type();
if (variable_type == expected_type) {
return variable;
@@ -453,6 +454,16 @@ mf::Variable *MultiFunctionProcedureOperation::convert_variable(mf::Variable *va
const mf::MultiFunction *function = conversion_table.get_conversion_multi_function(
variable_type, expected_type);
/* Conversion is not possible, return a default variable instead. */
if (!function) {
const mf::MultiFunction &constant_function =
procedure_.construct_function<mf::CustomMF_GenericConstant>(
expected_type.single_type(), expected_type.single_type().default_value(), false);
mf::Variable *constant_variable = procedure_builder_.add_call<1>(constant_function)[0];
implicit_variables_.append(constant_variable);
return constant_variable;
}
mf::Variable *converted_variable = procedure_builder_.add_call<1>(*function, {variable})[0];
implicit_variables_.append(converted_variable);
return converted_variable;