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>2022-03-22 13:09:37 +0300
committerJacques Lucke <jacques@blender.org>2022-03-22 13:09:53 +0300
commitceaa787e425afab55cad51d40a62bff7f4fd9a07 (patch)
treef0914c74db8523e89fee38c0a8ccb5e00b4abfd0
parentc1909770e7f192574ea62449dd14b4254637e604 (diff)
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.
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_set_id.cc11
1 files 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 543e57d38ad..0892e068ce2 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_set_id.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_set_id.cc
@@ -16,8 +16,11 @@ static void set_id_in_component(GeometryComponent &component,
const Field<bool> &selection_field,
const Field<int> &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;
}
@@ -30,7 +33,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<int> id_attribute = component.attribute_try_get_for_output_only<int>(
- "id", ATTR_DOMAIN_POINT);
+ "id", domain);
evaluator.add_with_destination(id_field, id_attribute.varray());
evaluator.evaluate();
id_attribute.save();
@@ -41,7 +44,7 @@ static void set_id_in_component(GeometryComponent &component,
const IndexMask selection = evaluator.get_evaluated_selection_as_mask();
const VArray<int> &result_ids = evaluator.get_evaluated<int>(0);
OutputAttribute_Typed<int> id_attribute = component.attribute_try_get_for_output_only<int>(
- "id", ATTR_DOMAIN_POINT);
+ "id", domain);
result_ids.materialize(selection, id_attribute.as_span());
id_attribute.save();
}