From 9fa304bf13e402405351a2c9bc14903c08b557e5 Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Tue, 26 Oct 2021 12:50:39 -0500 Subject: Geometry Nodes: Only create instance IDs when they exist Instance IDs serve no purpose for rendering when they aren't stable from one frame to the next, and if the index is used in the end anyway, there is no point in storing a vector of IDs and copying it around. This commit exposes the `id` attribute on the instances component, makes it optional-- only generated by default with the distribute points on faces node. Since the string to curves node only added the index as each instance's ID, I removed it. This means that it would be necessary to add the ID data manually if the initial index actually helps (when deleting only certain characters, for example). Differential Revision: https://developer.blender.org/D12980 --- source/blender/blenkernel/BKE_geometry_set.hh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel/BKE_geometry_set.hh') diff --git a/source/blender/blenkernel/BKE_geometry_set.hh b/source/blender/blenkernel/BKE_geometry_set.hh index 78ccefaed5c..429c37e9c9b 100644 --- a/source/blender/blenkernel/BKE_geometry_set.hh +++ b/source/blender/blenkernel/BKE_geometry_set.hh @@ -621,7 +621,9 @@ class InstancesComponent : public GeometryComponent { blender::Vector instance_transforms_; /** * IDs of the instances. They are used for consistency over multiple frames for things like - * motion blur. + * motion blur. Proper stable ID data that actually helps when rendering can only be generated + * in some situations, so this vector is allowed to be empty, in which case the index of each + * instance will be used for the final ID. */ blender::Vector instance_ids_; @@ -643,7 +645,7 @@ class InstancesComponent : public GeometryComponent { void resize(int capacity); int add_reference(const InstanceReference &reference); - void add_instance(int instance_handle, const blender::float4x4 &transform, const int id = -1); + void add_instance(int instance_handle, const blender::float4x4 &transform); blender::Span references() const; void remove_unused_references(); @@ -658,6 +660,9 @@ class InstancesComponent : public GeometryComponent { blender::MutableSpan instance_ids(); blender::Span instance_ids() const; + blender::MutableSpan instance_ids_ensure(); + void instance_ids_clear(); + int instances_amount() const; int references_amount() const; -- cgit v1.2.3