diff options
author | Hans Goudey <h.goudey@me.com> | 2022-09-06 17:43:32 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2022-09-06 17:43:32 +0300 |
commit | 3484c6d4f116409ca55cdc46325f4703d21c20c8 (patch) | |
tree | f77c24701c5aa844236e6300a72d83d752950c98 | |
parent | e3afead9aa4677ea91e3c41bbaf814533361cec2 (diff) |
Cleanup: Remove unused update custom data pointers in attribute API
Unused after 05952aa94d33eeb, 410a6efb747f188, and e9f82d3dc7eebad.
7 files changed, 25 insertions, 87 deletions
diff --git a/source/blender/blenkernel/intern/attribute_access.cc b/source/blender/blenkernel/intern/attribute_access.cc index e39c6d11fa9..e144e65ced6 100644 --- a/source/blender/blenkernel/intern/attribute_access.cc +++ b/source/blender/blenkernel/intern/attribute_access.cc @@ -308,41 +308,15 @@ GAttributeWriter BuiltinCustomDataLayerProvider::try_get_for_write(void *owner) const int element_num = custom_data_access_.get_element_num(owner); void *data = nullptr; - bool found_attribute = false; - for (const CustomDataLayer &layer : Span(custom_data->layers, custom_data->totlayer)) { - if (stored_as_named_attribute_) { - if (layer.name == name_) { - data = layer.data; - found_attribute = true; - break; - } - } - else if (layer.type == stored_type_) { - data = layer.data; - found_attribute = true; - break; - } + if (stored_as_named_attribute_) { + data = CustomData_duplicate_referenced_layer_named( + custom_data, stored_type_, name_.c_str(), element_num); } - if (!found_attribute) { - return {}; + else { + data = CustomData_duplicate_referenced_layer(custom_data, stored_type_, element_num); } - - if (data != nullptr) { - void *new_data; - if (stored_as_named_attribute_) { - new_data = CustomData_duplicate_referenced_layer_named( - custom_data, stored_type_, name_.c_str(), element_num); - } - else { - new_data = CustomData_duplicate_referenced_layer(custom_data, stored_type_, element_num); - } - - if (data != new_data) { - if (custom_data_access_.update_custom_data_pointers) { - custom_data_access_.update_custom_data_pointers(owner); - } - data = new_data; - } + if (data == nullptr) { + return {}; } std::function<void()> tag_modified_fn; @@ -372,9 +346,6 @@ bool BuiltinCustomDataLayerProvider::try_delete(void *owner) const const int element_num = custom_data_access_.get_element_num(owner); if (stored_as_named_attribute_) { if (CustomData_free_layer_named(custom_data, name_.c_str(), element_num)) { - if (custom_data_access_.update_custom_data_pointers) { - custom_data_access_.update_custom_data_pointers(owner); - } update(); return true; } @@ -383,9 +354,6 @@ bool BuiltinCustomDataLayerProvider::try_delete(void *owner) const const int layer_index = CustomData_get_layer_index(custom_data, stored_type_); if (CustomData_free_layer(custom_data, stored_type_, element_num, layer_index)) { - if (custom_data_access_.update_custom_data_pointers) { - custom_data_access_.update_custom_data_pointers(owner); - } update(); return true; } @@ -405,29 +373,21 @@ bool BuiltinCustomDataLayerProvider::try_create(void *owner, } const int element_num = custom_data_access_.get_element_num(owner); - bool success; if (stored_as_named_attribute_) { if (CustomData_get_layer_named(custom_data, data_type_, name_.c_str())) { /* Exists already. */ return false; } - success = add_custom_data_layer_from_attribute_init( + return add_custom_data_layer_from_attribute_init( name_, *custom_data, stored_type_, element_num, initializer); } - else { - if (CustomData_get_layer(custom_data, stored_type_) != nullptr) { - /* Exists already. */ - return false; - } - success = add_builtin_type_custom_data_layer_from_init( - *custom_data, stored_type_, element_num, initializer); - } - if (success) { - if (custom_data_access_.update_custom_data_pointers) { - custom_data_access_.update_custom_data_pointers(owner); - } + + if (CustomData_get_layer(custom_data, stored_type_) != nullptr) { + /* Exists already. */ + return false; } - return success; + return add_builtin_type_custom_data_layer_from_init( + *custom_data, stored_type_, element_num, initializer); } bool BuiltinCustomDataLayerProvider::exists(const void *owner) const @@ -589,15 +549,9 @@ GAttributeWriter NamedLegacyCustomDataProvider::try_get_for_write( if (layer.type == stored_type_) { if (custom_data_layer_matches_attribute_id(layer, attribute_id)) { const int element_num = custom_data_access_.get_element_num(owner); - void *data_old = layer.data; - void *data_new = CustomData_duplicate_referenced_layer_named( + void *data = CustomData_duplicate_referenced_layer_named( custom_data, stored_type_, layer.name, element_num); - if (data_old != data_new) { - if (custom_data_access_.update_custom_data_pointers) { - custom_data_access_.update_custom_data_pointers(owner); - } - } - return {as_write_attribute_(layer.data, element_num), domain_}; + return {as_write_attribute_(data, element_num), domain_}; } } } @@ -617,9 +571,6 @@ bool NamedLegacyCustomDataProvider::try_delete(void *owner, if (custom_data_layer_matches_attribute_id(layer, attribute_id)) { const int element_num = custom_data_access_.get_element_num(owner); CustomData_free_layer(custom_data, stored_type_, element_num, i); - if (custom_data_access_.update_custom_data_pointers) { - custom_data_access_.update_custom_data_pointers(owner); - } return true; } } diff --git a/source/blender/blenkernel/intern/attribute_access_intern.hh b/source/blender/blenkernel/intern/attribute_access_intern.hh index 9b784d02115..d8550c596f2 100644 --- a/source/blender/blenkernel/intern/attribute_access_intern.hh +++ b/source/blender/blenkernel/intern/attribute_access_intern.hh @@ -23,7 +23,6 @@ struct CustomDataAccessInfo { CustomDataGetter get_custom_data; ConstCustomDataGetter get_const_custom_data; GetElementNum get_element_num; - UpdateCustomDataPointers update_custom_data_pointers; }; /** diff --git a/source/blender/blenkernel/intern/geometry_component_curve.cc b/source/blender/blenkernel/intern/geometry_component_curve.cc index 56a7e38b2fc..8e482e4c691 100644 --- a/source/blender/blenkernel/intern/geometry_component_curve.cc +++ b/source/blender/blenkernel/intern/geometry_component_curve.cc @@ -1351,8 +1351,7 @@ static ComponentAttributeProviders create_attribute_providers_for_curve() [](const void *owner) -> int { const CurveEval *curve = static_cast<const CurveEval *>(owner); return curve->splines().size(); - }, - nullptr}; + }}; static CustomDataAttributeProvider spline_custom_data(ATTR_DOMAIN_CURVE, spline_custom_data_access); diff --git a/source/blender/blenkernel/intern/geometry_component_curves.cc b/source/blender/blenkernel/intern/geometry_component_curves.cc index 596c8e0bfc7..83a35534c01 100644 --- a/source/blender/blenkernel/intern/geometry_component_curves.cc +++ b/source/blender/blenkernel/intern/geometry_component_curves.cc @@ -339,8 +339,7 @@ static ComponentAttributeProviders create_attribute_providers_for_curve() [](const void *owner) -> int { const CurvesGeometry &curves = *static_cast<const CurvesGeometry *>(owner); return curves.curves_num(); - }, - [](void * /*owner*/) {}}; + }}; static CustomDataAccessInfo point_access = { [](void *owner) -> CustomData * { CurvesGeometry &curves = *static_cast<CurvesGeometry *>(owner); @@ -353,8 +352,7 @@ static ComponentAttributeProviders create_attribute_providers_for_curve() [](const void *owner) -> int { const CurvesGeometry &curves = *static_cast<const CurvesGeometry *>(owner); return curves.points_num(); - }, - [](void * /*owner*/) {}}; + }}; static BuiltinCustomDataLayerProvider position("position", ATTR_DOMAIN_POINT, diff --git a/source/blender/blenkernel/intern/geometry_component_instances.cc b/source/blender/blenkernel/intern/geometry_component_instances.cc index c16311945ba..3a065c3576b 100644 --- a/source/blender/blenkernel/intern/geometry_component_instances.cc +++ b/source/blender/blenkernel/intern/geometry_component_instances.cc @@ -444,8 +444,7 @@ static ComponentAttributeProviders create_attribute_providers_for_instances() [](const void *owner) -> int { const InstancesComponent &inst = *static_cast<const InstancesComponent *>(owner); return inst.instances_num(); - }, - nullptr}; + }}; /** * IDs of the instances. They are used for consistency over multiple frames for things like diff --git a/source/blender/blenkernel/intern/geometry_component_mesh.cc b/source/blender/blenkernel/intern/geometry_component_mesh.cc index f5f667a02eb..d0bfc5f5499 100644 --- a/source/blender/blenkernel/intern/geometry_component_mesh.cc +++ b/source/blender/blenkernel/intern/geometry_component_mesh.cc @@ -1158,8 +1158,6 @@ class NormalAttributeProvider final : public BuiltinAttributeProvider { */ static ComponentAttributeProviders create_attribute_providers_for_mesh() { - static auto update_custom_data_pointers = [](void * /*owner*/) {}; - #define MAKE_MUTABLE_CUSTOM_DATA_GETTER(NAME) \ [](void *owner) -> CustomData * { \ Mesh *mesh = static_cast<Mesh *>(owner); \ @@ -1178,20 +1176,16 @@ static ComponentAttributeProviders create_attribute_providers_for_mesh() static CustomDataAccessInfo corner_access = {MAKE_MUTABLE_CUSTOM_DATA_GETTER(ldata), MAKE_CONST_CUSTOM_DATA_GETTER(ldata), - MAKE_GET_ELEMENT_NUM_GETTER(totloop), - update_custom_data_pointers}; + MAKE_GET_ELEMENT_NUM_GETTER(totloop)}; static CustomDataAccessInfo point_access = {MAKE_MUTABLE_CUSTOM_DATA_GETTER(vdata), MAKE_CONST_CUSTOM_DATA_GETTER(vdata), - MAKE_GET_ELEMENT_NUM_GETTER(totvert), - update_custom_data_pointers}; + MAKE_GET_ELEMENT_NUM_GETTER(totvert)}; static CustomDataAccessInfo edge_access = {MAKE_MUTABLE_CUSTOM_DATA_GETTER(edata), MAKE_CONST_CUSTOM_DATA_GETTER(edata), - MAKE_GET_ELEMENT_NUM_GETTER(totedge), - update_custom_data_pointers}; + MAKE_GET_ELEMENT_NUM_GETTER(totedge)}; static CustomDataAccessInfo face_access = {MAKE_MUTABLE_CUSTOM_DATA_GETTER(pdata), MAKE_CONST_CUSTOM_DATA_GETTER(pdata), - MAKE_GET_ELEMENT_NUM_GETTER(totpoly), - update_custom_data_pointers}; + MAKE_GET_ELEMENT_NUM_GETTER(totpoly)}; #undef MAKE_CONST_CUSTOM_DATA_GETTER #undef MAKE_MUTABLE_CUSTOM_DATA_GETTER diff --git a/source/blender/blenkernel/intern/geometry_component_pointcloud.cc b/source/blender/blenkernel/intern/geometry_component_pointcloud.cc index 4953da8a5ee..238854c987e 100644 --- a/source/blender/blenkernel/intern/geometry_component_pointcloud.cc +++ b/source/blender/blenkernel/intern/geometry_component_pointcloud.cc @@ -111,7 +111,6 @@ namespace blender::bke { */ static ComponentAttributeProviders create_attribute_providers_for_point_cloud() { - static auto update_custom_data_pointers = [](void * /*owner*/) {}; static CustomDataAccessInfo point_access = { [](void *owner) -> CustomData * { PointCloud *pointcloud = static_cast<PointCloud *>(owner); @@ -124,8 +123,7 @@ static ComponentAttributeProviders create_attribute_providers_for_point_cloud() [](const void *owner) -> int { const PointCloud *pointcloud = static_cast<const PointCloud *>(owner); return pointcloud->totpoint; - }, - update_custom_data_pointers}; + }}; static BuiltinCustomDataLayerProvider position("position", ATTR_DOMAIN_POINT, |