From 52bc4206588b85c24473bc5ad12ebf9b8451c114 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Tue, 22 Mar 2022 11:09:37 +0100 Subject: Fix T96420: Set ID node not working for instances Previously, instances used the point domain, but now there is a special domain for instance attributes that the node has to use. --- source/blender/nodes/geometry/nodes/node_geo_set_id.cc | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/source/blender/nodes/geometry/nodes/node_geo_set_id.cc b/source/blender/nodes/geometry/nodes/node_geo_set_id.cc index 110b8206944..92433059c97 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_set_id.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_set_id.cc @@ -30,8 +30,11 @@ static void set_id_in_component(GeometryComponent &component, const Field &selection_field, const Field &id_field) { - GeometryComponentFieldContext field_context{component, ATTR_DOMAIN_POINT}; - const int domain_size = component.attribute_domain_size(ATTR_DOMAIN_POINT); + const AttributeDomain domain = (component.type() == GEO_COMPONENT_TYPE_INSTANCES) ? + ATTR_DOMAIN_INSTANCE : + ATTR_DOMAIN_POINT; + GeometryComponentFieldContext field_context{component, domain}; + const int domain_size = component.attribute_domain_size(domain); if (domain_size == 0) { return; } @@ -44,7 +47,7 @@ static void set_id_in_component(GeometryComponent &component, * the field. However, as an optimization, use a faster code path when it already exists. */ if (component.attribute_exists("id")) { OutputAttribute_Typed id_attribute = component.attribute_try_get_for_output_only( - "id", ATTR_DOMAIN_POINT); + "id", domain); evaluator.add_with_destination(id_field, id_attribute.varray()); evaluator.evaluate(); id_attribute.save(); @@ -55,7 +58,7 @@ static void set_id_in_component(GeometryComponent &component, const IndexMask selection = evaluator.get_evaluated_selection_as_mask(); const VArray &result_ids = evaluator.get_evaluated(0); OutputAttribute_Typed id_attribute = component.attribute_try_get_for_output_only( - "id", ATTR_DOMAIN_POINT); + "id", domain); result_ids.materialize(selection, id_attribute.as_span()); id_attribute.save(); } -- cgit v1.2.3