diff options
author | Hans Goudey <h.goudey@me.com> | 2021-12-01 17:27:27 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2021-12-01 17:27:27 +0300 |
commit | f8dd03d3dd1b2d7f0ade7c209092212098c75cb4 (patch) | |
tree | 5d9f9d32f342607063924cefe0b593538d07ba85 /source/blender/nodes | |
parent | fd8418385c2e3b0cc9ff8a254c3f3e408d0565f9 (diff) |
Cleanup: Store instances id attribute with other attributes
Now that we can store any dynamic attribute on the instances component,
we don't need the special case for `id`, it can just be handled by the
generic attribute storage. Mostly this just allows removing a bunch
of redundant code.
I had to add a null check for `update_custom_data_pointers` because
the instances component doesn't have any pointers to inside of
custom data.
Differential Revision: https://developer.blender.org/D13430
Diffstat (limited to 'source/blender/nodes')
-rw-r--r-- | source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_point_instance.cc | 6 | ||||
-rw-r--r-- | source/blender/nodes/geometry/nodes/node_geo_instance_on_points.cc | 11 |
2 files changed, 5 insertions, 12 deletions
diff --git a/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_point_instance.cc b/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_point_instance.cc index be8294cda90..ef35bef96aa 100644 --- a/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_point_instance.cc +++ b/source/blender/nodes/geometry/nodes/legacy/node_geo_legacy_point_instance.cc @@ -186,7 +186,9 @@ static void add_instances_from_component(InstancesComponent &instances, instances.resize(start_len + domain_size); MutableSpan<int> handles = instances.instance_reference_handles().slice(start_len, domain_size); MutableSpan<float4x4> transforms = instances.instance_transforms().slice(start_len, domain_size); - MutableSpan<int> instance_ids = instances.instance_ids_ensure().slice(start_len, domain_size); + OutputAttribute_Typed<int> instance_id_attribute = + instances.attribute_try_get_for_output_only<int>("id", ATTR_DOMAIN_INSTANCE); + MutableSpan<int> instance_ids = instance_id_attribute.as_span(); /* Skip all of the randomness handling if there is only a single possible instance * (anything except for collection mode with "Whole Collection" turned off). */ @@ -213,6 +215,8 @@ static void add_instances_from_component(InstancesComponent &instances, } }); } + + instance_id_attribute.save(); } static void node_geo_exec(GeoNodeExecParams params) diff --git a/source/blender/nodes/geometry/nodes/node_geo_instance_on_points.cc b/source/blender/nodes/geometry/nodes/node_geo_instance_on_points.cc index 637c2c59da6..4e75f1f60d9 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_instance_on_points.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_instance_on_points.cc @@ -158,17 +158,6 @@ static void add_instances_from_component( } }); - VArray<int> ids = src_component - .attribute_try_get_for_read("id", ATTR_DOMAIN_POINT, CD_PROP_INT32) - .typed<int>(); - if (ids) { - VArray_Span<int> ids_span{ids}; - MutableSpan<int> dst_ids = dst_component.instance_ids_ensure(); - for (const int64_t i : selection.index_range()) { - dst_ids[i] = ids_span[selection[i]]; - } - } - if (pick_instance.is_single()) { if (pick_instance.get_internal_single()) { if (instance.has_realized_data()) { |