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:
authorHans Goudey <h.goudey@me.com>2021-11-02 23:16:52 +0300
committerHans Goudey <h.goudey@me.com>2021-11-02 23:16:52 +0300
commit18392cef17ddb40857fdb2462d8bad50f389029b (patch)
treef0fad510f46ce175ab9dd63529b4f06a726205f2 /source/blender/blenkernel/intern/geometry_set_instances.cc
parent7aa311e5396bca5d65ba9cd00060d61bafbf28e9 (diff)
Fix T92652: Joining curves breaks point attribute order
Currently the curve to mesh node relies on the order of attributes being the same on every spline. This is a worthwhile assumption, because it will allow removing the attribute name storage duplication on every spline in the future. However, the join geometry node broke this order, since it just created new attributes without any regard to the order. To fix this, I added a "reorder" step after all the merged attributes have been created, the types have been joined, etc. It should be possible to change this code so that the attributes are added with the right order in the first place, but I would like to do that after refactoring spline attribute storage, and not for 3.0. Differential Revision: https://developer.blender.org/D13074
Diffstat (limited to 'source/blender/blenkernel/intern/geometry_set_instances.cc')
-rw-r--r--source/blender/blenkernel/intern/geometry_set_instances.cc19
1 files changed, 19 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/geometry_set_instances.cc b/source/blender/blenkernel/intern/geometry_set_instances.cc
index 35c6a7df2c7..82fc14e7772 100644
--- a/source/blender/blenkernel/intern/geometry_set_instances.cc
+++ b/source/blender/blenkernel/intern/geometry_set_instances.cc
@@ -530,6 +530,24 @@ static void join_instance_groups_volume(Span<GeometryInstanceGroup> set_groups,
}
}
+/**
+ * Curve point domain attributes must be in the same order on every spline. The order might have
+ * been different on separate instances, so ensure that all splines have the same order. Note that
+ * because #Map is used, the order is not necessarily consistent every time, but it is the same for
+ * every spline, and that's what matters.
+ */
+static void sort_curve_point_attributes(const Map<AttributeIDRef, AttributeKind> &info,
+ MutableSpan<SplinePtr> splines)
+{
+ Vector<AttributeIDRef> new_order;
+ for (const AttributeIDRef attribute_id : info.keys()) {
+ new_order.append(attribute_id);
+ }
+ for (SplinePtr &spline : splines) {
+ spline->attributes.reorder(new_order);
+ }
+}
+
static void join_instance_groups_curve(Span<GeometryInstanceGroup> set_groups, GeometrySet &result)
{
CurveEval *curve = join_curve_splines_and_builtin_attributes(set_groups);
@@ -550,6 +568,7 @@ static void join_instance_groups_curve(Span<GeometryInstanceGroup> set_groups, G
{GEO_COMPONENT_TYPE_CURVE},
attributes,
static_cast<GeometryComponent &>(dst_component));
+ sort_curve_point_attributes(attributes, curve->splines());
}
GeometrySet geometry_set_realize_instances(const GeometrySet &geometry_set)