[Bf-blender-cvs] [ceaa787e425] master: Fix T96420: Set ID node not working for instances

Jacques Lucke noreply at git.blender.org
Tue Mar 22 11:10:06 CET 2022


Commit: ceaa787e425afab55cad51d40a62bff7f4fd9a07
Author: Jacques Lucke
Date:   Tue Mar 22 11:09:37 2022 +0100
Branches: master
https://developer.blender.org/rBceaa787e425afab55cad51d40a62bff7f4fd9a07

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.

===================================================================

M	source/blender/nodes/geometry/nodes/node_geo_set_id.cc

===================================================================

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();
   }



More information about the Bf-blender-cvs mailing list