Cleanup: Rename function, switch order of arguments

The function name was not very specific, this makes it clearer that it
works on instances rather than only real geometry. Also use `r_`
prefix for the return argument.
This commit is contained in:
Hans Goudey 2021-04-07 15:49:02 -05:00
parent 1a8db9ec04
commit 79ba4fde15
3 changed files with 18 additions and 16 deletions

View File

@ -55,9 +55,9 @@ struct AttributeKind {
* will contain the highest complexity data type and the highest priority domain among every
* attribute with the given name on all of the input components.
*/
void gather_attribute_info(Map<std::string, AttributeKind> &attributes,
Span<GeometryComponentType> component_types,
Span<bke::GeometryInstanceGroup> set_groups,
const Set<std::string> &ignored_attributes);
void geometry_set_gather_instances_attribute_info(Span<GeometryInstanceGroup> set_groups,
Span<GeometryComponentType> component_types,
const Set<std::string> &ignored_attributes,
Map<std::string, AttributeKind> &r_attributes);
} // namespace blender::bke

View File

@ -162,10 +162,10 @@ void geometry_set_gather_instances(const GeometrySet &geometry_set,
geometry_set_collect_recursive(geometry_set, unit_transform, r_instance_groups);
}
void gather_attribute_info(Map<std::string, AttributeKind> &attributes,
Span<GeometryComponentType> component_types,
Span<GeometryInstanceGroup> set_groups,
const Set<std::string> &ignored_attributes)
void geometry_set_gather_instances_attribute_info(Span<GeometryInstanceGroup> set_groups,
Span<GeometryComponentType> component_types,
const Set<std::string> &ignored_attributes,
Map<std::string, AttributeKind> &r_attributes)
{
for (const GeometryInstanceGroup &set_group : set_groups) {
const GeometrySet &set = set_group.geometry_set;
@ -189,7 +189,7 @@ void gather_attribute_info(Map<std::string, AttributeKind> &attributes,
{attribute_kind->data_type, meta_data.data_type});
};
attributes.add_or_modify(name, add_info, modify_info);
r_attributes.add_or_modify(name, add_info, modify_info);
return true;
});
}
@ -383,10 +383,11 @@ static void join_instance_groups_mesh(Span<GeometryInstanceGroup> set_groups,
/* Don't copy attributes that are stored directly in the mesh data structs. */
Map<std::string, AttributeKind> attributes;
gather_attribute_info(attributes,
component_types,
set_groups,
{"position", "material_index", "normal", "shade_smooth", "crease"});
geometry_set_gather_instances_attribute_info(
set_groups,
component_types,
{"position", "material_index", "normal", "shade_smooth", "crease"},
attributes);
join_attributes(
set_groups, component_types, attributes, static_cast<GeometryComponent &>(dst_component));
}
@ -410,7 +411,8 @@ static void join_instance_groups_pointcloud(Span<GeometryInstanceGroup> set_grou
PointCloud *pointcloud = BKE_pointcloud_new_nomain(totpoint);
dst_component.replace(pointcloud);
Map<std::string, AttributeKind> attributes;
gather_attribute_info(attributes, {GEO_COMPONENT_TYPE_POINT_CLOUD}, set_groups, {});
geometry_set_gather_instances_attribute_info(
set_groups, {GEO_COMPONENT_TYPE_POINT_CLOUD}, {}, attributes);
join_attributes(set_groups,
{GEO_COMPONENT_TYPE_POINT_CLOUD},
attributes,

View File

@ -716,8 +716,8 @@ static void geo_node_point_distribute_exec(GeoNodeExecParams params)
geometry_set_out.get_component_for_write<PointCloudComponent>();
Map<std::string, AttributeKind> attributes;
bke::gather_attribute_info(
attributes, {GEO_COMPONENT_TYPE_MESH}, set_groups, {"position", "normal", "id"});
bke::geometry_set_gather_instances_attribute_info(
set_groups, {GEO_COMPONENT_TYPE_MESH}, {"position", "normal", "id"}, attributes);
add_remaining_point_attributes(set_groups,
instance_start_offsets,
attributes,