[Bf-blender-cvs] [4e8935c7b7b] temp-geometry-nodes-expandable-geometry-socket-prototype: Merge branch 'master' into temp-geometry-nodes-expandable-geometry-socket-prototype

Jacques Lucke noreply at git.blender.org
Tue Aug 3 10:50:23 CEST 2021


Commit: 4e8935c7b7bc4e2334f759609abbbe3a1c437f1b
Author: Jacques Lucke
Date:   Tue Aug 3 10:47:36 2021 +0200
Branches: temp-geometry-nodes-expandable-geometry-socket-prototype
https://developer.blender.org/rB4e8935c7b7bc4e2334f759609abbbe3a1c437f1b

Merge branch 'master' into temp-geometry-nodes-expandable-geometry-socket-prototype

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



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

diff --cc source/blender/modifiers/intern/MOD_nodes_evaluator.cc
index 8754aaed814,1391587fa7d..c405286f0df
--- a/source/blender/modifiers/intern/MOD_nodes_evaluator.cc
+++ b/source/blender/modifiers/intern/MOD_nodes_evaluator.cc
@@@ -1430,17 -1374,29 +1405,48 @@@ class GeometryNodesEvaluator 
      if (type == required_type) {
        return {type, buffer};
      }
-     if (conversions_.is_convertible(type, required_type)) {
-       /* Convert the loaded value to the required type if possible. */
-       void *converted_buffer = allocator.allocate(required_type.size(), required_type.alignment());
-       conversions_.convert_to_uninitialized(type, required_type, buffer, converted_buffer);
-       type.destruct(buffer);
-       return {required_type, converted_buffer};
+     void *converted_buffer = allocator.allocate(required_type.size(), required_type.alignment());
+     this->convert_value(type, required_type, buffer, converted_buffer);
+     return {required_type, converted_buffer};
+   }
+ 
+   void convert_value(const CPPType &from_type,
+                      const CPPType &to_type,
+                      const void *from_value,
+                      void *to_value)
+   {
+     if (from_type == to_type) {
+       from_type.copy_construct(from_value, to_value);
+       return;
+     }
+ 
 -    if (conversions_.is_convertible(from_type, to_type)) {
++    const ArrayCPPType *from_array_type = dynamic_cast<const ArrayCPPType *>(&from_type);
++    const ArrayCPPType *to_array_type = dynamic_cast<const ArrayCPPType *>(&to_type);
++
++    if (from_array_type != nullptr && to_array_type != nullptr &&
++        conversions_.is_convertible(from_array_type->element_type(),
++                                    to_array_type->element_type())) {
++      const MultiFunction &fn = *conversions_.get_conversion_multi_function(
++          MFDataType::ForSingle(from_array_type->element_type()),
++          MFDataType::ForSingle(to_array_type->element_type()));
++      GSpan from_span = from_array_type->array_span(from_value);
++      const int array_size = from_span.size();
++      GMutableSpan to_span = to_array_type->array_construct_uninitialized(to_value, array_size);
++
++      MFParamsBuilder params{fn, array_size};
++      params.add_readonly_single_input(from_span);
++      params.add_uninitialized_single_output(to_span);
++      MFContextBuilder context;
++      fn.call(IndexRange(array_size), params, context);
++    }
++    else if (conversions_.is_convertible(from_type, to_type)) {
+       /* Do the conversion if possible. */
+       conversions_.convert_to_uninitialized(from_type, to_type, from_value, to_value);
+     }
+     else {
+       /* Cannot convert, use default value instead. */
+       to_type.copy_construct(to_type.default_value(), to_value);
      }
-     /* Use a default fallback value when the loaded type is not compatible. */
-     void *default_buffer = allocator.allocate(required_type.size(), required_type.alignment());
-     required_type.copy_construct(required_type.default_value(), default_buffer);
-     return {required_type, default_buffer};
    }
  
    NodeState &get_node_state(const DNode node)



More information about the Bf-blender-cvs mailing list