[Bf-blender-cvs] [9b2879f8b38] master: Cleanup: Simplify logic, rename variables
Hans Goudey
noreply at git.blender.org
Fri Mar 25 04:29:39 CET 2022
Commit: 9b2879f8b38a4534993dc69d6af64c5969769ed1
Author: Hans Goudey
Date: Thu Mar 24 22:29:23 2022 -0500
Branches: master
https://developer.blender.org/rB9b2879f8b38a4534993dc69d6af64c5969769ed1
Cleanup: Simplify logic, rename variables
Return the map of gathered attributes directly, use simpler
naming for "attributes" and "gathered_attributes".
===================================================================
M source/blender/nodes/geometry/nodes/node_geo_duplicate_elements.cc
===================================================================
diff --git a/source/blender/nodes/geometry/nodes/node_geo_duplicate_elements.cc b/source/blender/nodes/geometry/nodes/node_geo_duplicate_elements.cc
index f46c5d3bee1..2aa768129cd 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_duplicate_elements.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_duplicate_elements.cc
@@ -60,18 +60,16 @@ struct IndexAttributes {
/** \name Utility Functions
* \{ */
-static void gather_attributes_without_id(const GeometrySet &geometry_set,
- const GeometryComponentType component_type,
- const Span<std::string> skip_attributes,
- const bool include_instances,
- Map<AttributeIDRef, AttributeKind> &r_gathered_attributes)
+static Map<AttributeIDRef, AttributeKind> gather_attributes_without_id(
+ const GeometrySet &geometry_set,
+ const GeometryComponentType component_type,
+ const bool include_instances)
{
+ Map<AttributeIDRef, AttributeKind> attributes;
geometry_set.gather_attributes_for_propagation(
- {component_type}, component_type, include_instances, r_gathered_attributes);
- for (const std::string &attribute : skip_attributes) {
- r_gathered_attributes.remove(attribute);
- }
- r_gathered_attributes.remove("id");
+ {component_type}, component_type, include_instances, attributes);
+ attributes.remove("id");
+ return attributes;
};
static IndexRange range_for_offsets_index(const Span<int> offsets, const int index)
@@ -141,11 +139,11 @@ static void threaded_id_offset_copy(const Span<int> offsets,
static void create_duplicate_index_attribute(GeometryComponent &component,
const AttributeDomain output_domain,
const IndexMask selection,
- const IndexAttributes &attributes,
+ const IndexAttributes &attribute_outputs,
const Span<int> offsets)
{
OutputAttribute_Typed<int> copy_attribute = component.attribute_try_get_for_output_only<int>(
- attributes.duplicate_index.get(), output_domain);
+ attribute_outputs.duplicate_index.get(), output_domain);
MutableSpan<int> duplicate_indices = copy_attribute.as_span();
for (const int i : IndexRange(selection.size())) {
const IndexRange range = range_for_offsets_index(offsets, i);
@@ -193,11 +191,10 @@ static void copy_point_attributes_without_id(GeometrySet &geometry_set,
const GeometryComponent &src_component,
GeometryComponent &dst_component)
{
- Map<AttributeIDRef, AttributeKind> gathered_attributes;
- gather_attributes_without_id(
- geometry_set, component_type, {}, include_instances, gathered_attributes);
+ Map<AttributeIDRef, AttributeKind> attributes = gather_attributes_without_id(
+ geometry_set, component_type, include_instances);
- for (const Map<AttributeIDRef, AttributeKind>::Item entry : gathered_attributes.items()) {
+ for (const Map<AttributeIDRef, AttributeKind>::Item entry : attributes.items()) {
const AttributeIDRef attribute_id = entry.key;
ReadAttributeLookup src_attribute = src_component.attribute_try_get_for_read(attribute_id);
if (!src_attribute || src_attribute.domain != ATTR_DOMAIN_POINT) {
@@ -239,12 +236,10 @@ static void copy_curve_attributes_without_id(const GeometrySet &geometry_set,
bke::CurvesGeometry &dst_curves,
CurveComponent &dst_component)
{
- Map<AttributeIDRef, AttributeKind> gathered_attributes;
- gather_attributes_without_id(
- geometry_set, GEO_COMPONENT_TYPE_CURVE, {}, false, gathered_attributes);
-
- for (const Map<AttributeIDRef, AttributeKind>::Item entry : gathered_attributes.items()) {
+ Map<AttributeIDRef, AttributeKind> attributes = gather_attributes_without_id(
+ geometry_set, GEO_COMPONENT_TYPE_CURVE, false);
+ for (const Map<AttributeIDRef, AttributeKind>::Item entry : attributes.items()) {
const AttributeIDRef attribute_id = entry.key;
ReadAttributeLookup src_attribute = src_component.attribute_try_get_for_read(attribute_id);
if (!src_attribute) {
@@ -332,7 +327,7 @@ static void copy_stable_id_curves(const bke::CurvesGeometry &src_curves,
static void duplicate_curves(GeometrySet &geometry_set,
const Field<int> &count_field,
const Field<bool> &selection_field,
- const IndexAttributes &attributes)
+ const IndexAttributes &attribute_outputs)
{
if (!geometry_set.has_curves()) {
geometry_set.keep_only({GEO_COMPONENT_TYPE_INSTANCES});
@@ -395,9 +390,9 @@ static void duplicate_curves(GeometrySet &geometry_set,
copy_stable_id_curves(
curves, selection, curve_offsets, src_component, new_curves, dst_component);
- if (attributes.duplicate_index) {
+ if (attribute_outputs.duplicate_index) {
create_duplicate_index_attribute(
- dst_component, ATTR_DOMAIN_CURVE, selection, attributes, curve_offsets);
+ dst_component, ATTR_DOMAIN_CURVE, selection, attribute_outputs, curve_offsets);
}
geometry_set.replace_curves(new_curves_id);
@@ -421,11 +416,10 @@ static void copy_face_attributes_without_id(GeometrySet &geometry_set,
const GeometryComponent &src_component,
GeometryComponent &dst_component)
{
- Map<AttributeIDRef, AttributeKind> gathered_attributes;
- gather_attributes_without_id(
- geometry_set, GEO_COMPONENT_TYPE_MESH, {}, false, gathered_attributes);
+ Map<AttributeIDRef, AttributeKind> attributes = gather_attributes_without_id(
+ geometry_set, GEO_COMPONENT_TYPE_MESH, false);
- for (const Map<AttributeIDRef, AttributeKind>::Item entry : gathered_attributes.items()) {
+ for (const Map<AttributeIDRef, AttributeKind>::Item entry : attributes.items()) {
const AttributeIDRef attribute_id = entry.key;
ReadAttributeLookup src_attribute = src_component.attribute_try_get_for_read(attribute_id);
if (!src_attribute) {
@@ -521,7 +515,7 @@ static void copy_stable_id_faces(const Mesh &mesh,
static void duplicate_faces(GeometrySet &geometry_set,
const Field<int> &count_field,
const Field<bool> &selection_field,
- const IndexAttributes &attributes)
+ const IndexAttributes &attribute_outputs)
{
if (!geometry_set.has_mesh()) {
geometry_set.keep_only({GEO_COMPONENT_TYPE_INSTANCES});
@@ -609,9 +603,9 @@ static void duplicate_faces(GeometrySet &geometry_set,
copy_stable_id_faces(mesh, selection, offsets, vert_mapping, src_component, dst_component);
- if (attributes.duplicate_index) {
+ if (attribute_outputs.duplicate_index) {
create_duplicate_index_attribute(
- dst_component, ATTR_DOMAIN_FACE, selection, attributes, offsets);
+ dst_component, ATTR_DOMAIN_FACE, selection, attribute_outputs, offsets);
}
geometry_set.replace_mesh(new_mesh);
@@ -633,11 +627,10 @@ static void copy_edge_attributes_without_id(GeometrySet &geometry_set,
const GeometryComponent &src_component,
GeometryComponent &dst_component)
{
- Map<AttributeIDRef, AttributeKind> gathered_attributes;
- gather_attributes_without_id(
- geometry_set, GEO_COMPONENT_TYPE_MESH, {}, false, gathered_attributes);
+ Map<AttributeIDRef, AttributeKind> attributes = gather_attributes_without_id(
+ geometry_set, GEO_COMPONENT_TYPE_MESH, false);
- for (const Map<AttributeIDRef, AttributeKind>::Item entry : gathered_attributes.items()) {
+ for (const Map<AttributeIDRef, AttributeKind>::Item entry : attributes.items()) {
const AttributeIDRef attribute_id = entry.key;
ReadAttributeLookup src_attribute = src_component.attribute_try_get_for_read(attribute_id);
if (!src_attribute) {
@@ -719,7 +712,7 @@ static void copy_stable_id_edges(const Mesh &mesh,
static void duplicate_edges(GeometrySet &geometry_set,
const Field<int> &count_field,
const Field<bool> &selection_field,
- const IndexAttributes &attributes)
+ const IndexAttributes &attribute_outputs)
{
if (!geometry_set.has_mesh()) {
geometry_set.keep_only({GEO_COMPONENT_TYPE_INSTANCES});
@@ -778,9 +771,9 @@ static void duplicate_edges(GeometrySet &geometry_set,
copy_stable_id_edges(mesh, selection, edge_offsets, src_component, dst_component);
- if (attributes.duplicate_index) {
+ if (attribute_outputs.duplicate_index) {
create_duplicate_index_attribute(
- dst_component, ATTR_DOMAIN_EDGE, selection, attributes, edge_offsets);
+ dst_component, ATTR_DOMAIN_EDGE, selection, attribute_outputs, edge_offsets);
}
geometry_set.replace_mesh(new_mesh);
@@ -795,7 +788,7 @@ static void duplicate_edges(GeometrySet &geometry_set,
static void duplicate_points_curve(GeometrySet &geometry_set,
const Field<int> &count_field,
const Field<bool> &selection_field,
- const IndexAttributes &attributes)
+ const IndexAttributes &attribute_outputs)
{
const CurveComponent &src_component = *geometry_set.get_component_for_read<CurveComponent>();
const Curves &src_curves_id = *src_component.get_for_read();
@@ -834,11 +827,10 @@ static void duplicate_points_curve(GeometrySet &geometry_set,
CurveComponent dst_component;
dst_component.replace(new_curves_id, GeometryOwnershipType::Editable);
- Map<AttributeIDRef, AttributeKind> gathered_attributes;
- gather_attributes_without_id(
- geometry_set, GEO_COMPONENT_TYPE_CURVE, {}, fals
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list