diff options
author | Jacques Lucke <jacques@blender.org> | 2021-07-28 15:04:14 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2021-07-28 15:04:14 +0300 |
commit | f95214e9aebc4c14a2c15dc56b2e5b4ca849fd04 (patch) | |
tree | 997c2902f90264229a2ba1d31ca2df8c7bf79300 /source/blender/modifiers/intern | |
parent | dde42e19e39d9b4fec382a0e2249eca10b87c86f (diff) |
support implicit conversion of fields
Diffstat (limited to 'source/blender/modifiers/intern')
-rw-r--r-- | source/blender/modifiers/intern/MOD_nodes_evaluator.cc | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/source/blender/modifiers/intern/MOD_nodes_evaluator.cc b/source/blender/modifiers/intern/MOD_nodes_evaluator.cc index ebe92a53381..298931fd1a2 100644 --- a/source/blender/modifiers/intern/MOD_nodes_evaluator.cc +++ b/source/blender/modifiers/intern/MOD_nodes_evaluator.cc @@ -1341,7 +1341,21 @@ class GeometryNodesEvaluator { void *buffer = allocator.allocate(to_type.size(), to_type.alignment()); GMutablePointer value{to_type, buffer}; - if (conversions_.is_convertible(from_type, to_type)) { + const bke::FieldRefCPPType *from_field_type = dynamic_cast<const bke::FieldRefCPPType *>( + &from_type); + const bke::FieldRefCPPType *to_field_type = dynamic_cast<const bke::FieldRefCPPType *>( + &to_type); + + if (from_field_type != nullptr && to_field_type != nullptr && + conversions_.is_convertible(from_field_type->field_type(), to_field_type->field_type())) { + const MultiFunction &fn = *conversions_.get_conversion_multi_function( + MFDataType::ForSingle(from_field_type->field_type()), + MFDataType::ForSingle(to_field_type->field_type())); + FieldPtr old_field = from_field_type->get_field(value_to_forward.get()); + FieldPtr new_field = new bke::MultiFunctionField({old_field}, fn, 1); + to_field_type->construct(buffer, std::move(new_field)); + } + else if (conversions_.is_convertible(from_type, to_type)) { /* Do the conversion if possible. */ conversions_.convert_to_uninitialized(from_type, to_type, value_to_forward.get(), buffer); } |