Cleanup: Remove unused update custom data pointers in attribute API

Unused after 05952aa94d, 410a6efb74, and e9f82d3dc7.
This commit is contained in:
Hans Goudey 2022-09-06 09:43:32 -05:00
parent e3afead9aa
commit 3484c6d4f1
Notes: blender-bot 2023-02-14 08:06:33 +01:00
Referenced by commit ced56dbc53, Fix: Restore fix for empty attributes after recent commit
7 changed files with 25 additions and 87 deletions

View File

@ -308,43 +308,17 @@ 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) {
else {
data = CustomData_duplicate_referenced_layer(custom_data, stored_type_, element_num);
}
if (data == nullptr) {
return {};
}
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;
}
}
std::function<void()> tag_modified_fn;
if (update_on_change_ != nullptr) {
tag_modified_fn = [owner, update = update_on_change_]() { update(owner); };
@ -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 (CustomData_get_layer(custom_data, stored_type_) != nullptr) {
/* Exists already. */
return false;
}
if (success) {
if (custom_data_access_.update_custom_data_pointers) {
custom_data_access_.update_custom_data_pointers(owner);
}
}
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;
}
}

View File

@ -23,7 +23,6 @@ struct CustomDataAccessInfo {
CustomDataGetter get_custom_data;
ConstCustomDataGetter get_const_custom_data;
GetElementNum get_element_num;
UpdateCustomDataPointers update_custom_data_pointers;
};
/**

View File

@ -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);

View File

@ -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,

View File

@ -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

View File

@ -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

View File

@ -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,