diff options
author | Hans Goudey <h.goudey@me.com> | 2022-01-03 22:19:04 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2022-01-03 22:19:04 +0300 |
commit | c6069c439c8fb28d62700b21587f3f66ea3cd239 (patch) | |
tree | a47f6487f9f09b90af2b0f28a3c012bcad820f81 /source/blender/blenkernel/intern | |
parent | a42e972e1b9354911d9403840e137915a6c17b15 (diff) |
Fix T94581: Incorrect geometry delete behavior with instances
Compare the start of the range to zero to figure out whether the
indices for the instances to keep starts at zero. Also rename the
selection argument, since it made it seem like the selected indices
should be removed rather than kept.
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/geometry_component_instances.cc | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/source/blender/blenkernel/intern/geometry_component_instances.cc b/source/blender/blenkernel/intern/geometry_component_instances.cc index a7e3c5b60dc..b411c793298 100644 --- a/source/blender/blenkernel/intern/geometry_component_instances.cc +++ b/source/blender/blenkernel/intern/geometry_component_instances.cc @@ -148,27 +148,27 @@ static void copy_data_based_on_mask(Span<T> src, MutableSpan<T> dst, IndexMask m }); } -void InstancesComponent::remove_instances(const IndexMask selection) +void InstancesComponent::remove_instances(const IndexMask mask) { using namespace blender; - if (selection.is_range() && selection.index_range().first() == 0) { + if (mask.is_range() && mask.as_range().start() == 0) { /* Deleting from the end of the array can be much faster since no data has to be shifted. */ - this->resize(selection.size()); + this->resize(mask.size()); this->remove_unused_references(); return; } - Vector<int> new_handles(selection.size()); - copy_data_based_on_mask<int>(this->instance_reference_handles(), new_handles, selection); + Vector<int> new_handles(mask.size()); + copy_data_based_on_mask<int>(this->instance_reference_handles(), new_handles, mask); instance_reference_handles_ = std::move(new_handles); - Vector<float4x4> new_transforms(selection.size()); - copy_data_based_on_mask<float4x4>(this->instance_transforms(), new_transforms, selection); + Vector<float4x4> new_transforms(mask.size()); + copy_data_based_on_mask<float4x4>(this->instance_transforms(), new_transforms, mask); instance_transforms_ = std::move(new_transforms); const bke::CustomDataAttributes &src_attributes = attributes_; bke::CustomDataAttributes dst_attributes; - dst_attributes.reallocate(selection.size()); + dst_attributes.reallocate(mask.size()); src_attributes.foreach_attribute( [&](const bke::AttributeIDRef &id, const AttributeMetaData &meta_data) { @@ -182,7 +182,7 @@ void InstancesComponent::remove_instances(const IndexMask selection) attribute_math::convert_to_static_type(src.type(), [&](auto dummy) { using T = decltype(dummy); - copy_data_based_on_mask<T>(src.typed<T>(), dst.typed<T>(), selection); + copy_data_based_on_mask<T>(src.typed<T>(), dst.typed<T>(), mask); }); return true; }, |