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.
This commit is contained in:
parent
c1909770e7
commit
ceaa787e42
Notes:
blender-bot
2023-02-14 19:45:25 +01:00
Referenced by issue #96420, Set ID for Instances not work in Blender 3.1 Referenced by issue #96241, 3.1: Potential candidates for corrective releases
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue