diff options
author | Jacques Lucke <jacques@blender.org> | 2021-06-28 14:13:52 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2021-06-28 14:16:32 +0300 |
commit | 7d281a4f7d354d270fc9c9f3c7a65b4409362aa0 (patch) | |
tree | 6a749a4833bdf543a10d95881fcca52ba310248b /source/blender/nodes | |
parent | f7e2559fd649610881b1749b6d30cc2ba9fcbdb6 (diff) |
Functions: improve CPPType
* Reduce code duplication.
* Give methods more standardized names (e.g. `move_to_initialized` -> `move_assign`).
* Support wrapping arbitrary C++ types, even those that e.g. are not copyable.
Diffstat (limited to 'source/blender/nodes')
7 files changed, 12 insertions, 11 deletions
diff --git a/source/blender/nodes/geometry/node_geometry_exec.cc b/source/blender/nodes/geometry/node_geometry_exec.cc index a24a6d7ad21..8bf7680c835 100644 --- a/source/blender/nodes/geometry/node_geometry_exec.cc +++ b/source/blender/nodes/geometry/node_geometry_exec.cc @@ -17,7 +17,7 @@ #include "FN_cpp_type_make.hh" #include "NOD_geometry_exec.hh" -MAKE_CPP_TYPE(GeometrySet, GeometrySet); +MAKE_CPP_TYPE(GeometrySet, GeometrySet, CPPTypeFlags::Printable); namespace blender::nodes { diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_convert.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_convert.cc index 7b40456b180..60b5b91db19 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_attribute_convert.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_convert.cc @@ -130,7 +130,7 @@ static void attribute_convert_calc(GeometryComponent &component, const CPPType *cpp_type = bke::custom_data_type_to_cpp_type(result_type); BLI_assert(cpp_type != nullptr); - cpp_type->copy_to_initialized_n(source_span.data(), result_span.data(), result_span.size()); + cpp_type->copy_assign_n(source_span.data(), result_span.data(), result_span.size()); result_attribute.save(); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_randomize.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_randomize.cc index eeb77abd624..15d419a003a 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_attribute_randomize.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_randomize.cc @@ -189,6 +189,7 @@ Array<uint32_t> get_geometry_element_ids_as_uints(const GeometryComponent &compo if (hash_attribute) { BLI_assert(hashes.size() == hash_attribute->size()); const CPPType &cpp_type = hash_attribute->type(); + BLI_assert(cpp_type.is_hashable()); GVArray_GSpan items{*hash_attribute}; threading::parallel_for(hashes.index_range(), 512, [&](IndexRange range) { for (const int i : range) { diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc index 2725c625913..e37822bd262 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc @@ -298,7 +298,7 @@ static void copy_spline_domain_attributes(const CurveComponent &curve_component, if (size != 0) { BUFFER_FOR_CPP_TYPE_VALUE(type, buffer); spline_attribute->get(i, buffer); - type.fill_initialized(buffer, result[offset], size); + type.fill_assign_n(buffer, result[offset], size); } } diff --git a/source/blender/nodes/geometry/nodes/node_geo_join_geometry.cc b/source/blender/nodes/geometry/nodes/node_geo_join_geometry.cc index bc758b59987..730cf08feaa 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_join_geometry.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_join_geometry.cc @@ -208,7 +208,7 @@ static void fill_new_attribute(Span<const GeometryComponent *> src_components, GVArray_GSpan src_span{*read_attribute}; const void *src_buffer = src_span.data(); void *dst_buffer = dst_span[offset]; - cpp_type->copy_to_initialized_n(src_buffer, dst_buffer, domain_size); + cpp_type->copy_assign_n(src_buffer, dst_buffer, domain_size); offset += domain_size; } @@ -353,7 +353,7 @@ static void ensure_control_point_attribute(const StringRef name, BUFFER_FOR_CPP_TYPE_VALUE(type, buffer); current_curve_attribute->get(spline_index_in_component, buffer); - type.fill_initialized(buffer, new_attribute->data(), new_attribute->size()); + type.fill_assign_n(buffer, new_attribute->data(), new_attribute->size()); } } @@ -392,7 +392,7 @@ static void ensure_spline_attribute(const StringRef name, GVArray_GSpan src_span{*read_attribute}; const void *src_buffer = src_span.data(); - type.copy_to_initialized_n(src_buffer, result_attribute[offset], size); + type.copy_assign_n(src_buffer, result_attribute[offset], size); offset += size; } diff --git a/source/blender/nodes/intern/node_socket.cc b/source/blender/nodes/intern/node_socket.cc index d00bf636e15..9f0a145ace2 100644 --- a/source/blender/nodes/intern/node_socket.cc +++ b/source/blender/nodes/intern/node_socket.cc @@ -662,10 +662,10 @@ static bNodeSocketType *make_socket_type_string() return socktype; } -MAKE_CPP_TYPE(Object, Object *) -MAKE_CPP_TYPE(Collection, Collection *) -MAKE_CPP_TYPE(Texture, Tex *) -MAKE_CPP_TYPE(Material, Material *) +MAKE_CPP_TYPE(Object, Object *, CPPTypeFlags::BasicType) +MAKE_CPP_TYPE(Collection, Collection *, CPPTypeFlags::BasicType) +MAKE_CPP_TYPE(Texture, Tex *, CPPTypeFlags::BasicType) +MAKE_CPP_TYPE(Material, Material *, CPPTypeFlags::BasicType) static bNodeSocketType *make_socket_type_object() { diff --git a/source/blender/nodes/intern/type_conversions.cc b/source/blender/nodes/intern/type_conversions.cc index 220e5ea9046..1a71a3418a5 100644 --- a/source/blender/nodes/intern/type_conversions.cc +++ b/source/blender/nodes/intern/type_conversions.cc @@ -231,7 +231,7 @@ void DataTypeConversions::convert_to_uninitialized(const CPPType &from_type, void *to_value) const { if (from_type == to_type) { - from_type.copy_to_uninitialized(from_value, to_value); + from_type.copy_construct(from_value, to_value); return; } |