Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacques Lucke <jacques@blender.org>2021-11-09 18:43:14 +0300
committerJacques Lucke <jacques@blender.org>2021-11-09 18:46:04 +0300
commitcc949f0a40237d38c3f57b7bd6e15415dcdab1bd (patch)
tree9b9482a969c4a3c04dbeb12e5f1ecda05c4afe41
parent368d7944073ed022047ec4ff48eab7c272d5e750 (diff)
Fix: wrong attribute propagation in Distribute node
Currently the Distribute Points on Faces node does not propagate non-point attributes correctly. That is because it first interpolates the attributes to the point domain on the input mesh, and then propagates them. Differential Revision: https://developer.blender.org/D13148
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_distribute_points_on_faces.cc29
1 files changed, 12 insertions, 17 deletions
diff --git a/source/blender/nodes/geometry/nodes/node_geo_distribute_points_on_faces.cc b/source/blender/nodes/geometry/nodes/node_geo_distribute_points_on_faces.cc
index fa439b04da0..115ad09a9e6 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_distribute_points_on_faces.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_distribute_points_on_faces.cc
@@ -295,6 +295,12 @@ BLI_NOINLINE static void propagate_existing_attributes(
for (Map<AttributeIDRef, AttributeKind>::Item entry : attributes.items()) {
const AttributeIDRef attribute_id = entry.key;
const CustomDataType output_data_type = entry.value.data_type;
+
+ ReadAttributeLookup source_attribute = mesh_component.attribute_try_get_for_read(attribute_id);
+ if (!source_attribute) {
+ continue;
+ }
+
/* The output domain is always #ATTR_DOMAIN_POINT, since we are creating a point cloud. */
OutputAttribute attribute_out = point_component.attribute_try_get_for_output_only(
attribute_id, ATTR_DOMAIN_POINT, output_data_type);
@@ -303,23 +309,12 @@ BLI_NOINLINE static void propagate_existing_attributes(
}
GMutableSpan out_span = attribute_out.as_span();
-
- std::optional<AttributeMetaData> attribute_info = point_component.attribute_get_meta_data(
- attribute_id);
- if (!attribute_info) {
- continue;
- }
-
- const AttributeDomain source_domain = attribute_info->domain;
- GVArrayPtr source_attribute = mesh_component.attribute_get_for_read(
- attribute_id, source_domain, output_data_type, nullptr);
- if (!source_attribute) {
- continue;
- }
-
- interpolate_attribute(
- mesh, bary_coords, looptri_indices, source_domain, *source_attribute, out_span);
-
+ interpolate_attribute(mesh,
+ bary_coords,
+ looptri_indices,
+ source_attribute.domain,
+ *source_attribute.varray,
+ out_span);
attribute_out.save();
}
}