Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/geometry_component_instances.cc
| Show First 20 Lines • Show All 122 Lines • ▼ Show 20 Lines | |||||
| static blender::Array<int> generate_unique_instance_ids(Span<int> original_ids) | static blender::Array<int> generate_unique_instance_ids(Span<int> original_ids) | ||||
| { | { | ||||
| using namespace blender; | using namespace blender; | ||||
| Array<int> unique_ids(original_ids.size()); | Array<int> unique_ids(original_ids.size()); | ||||
| Set<int> used_unique_ids; | Set<int> used_unique_ids; | ||||
| used_unique_ids.reserve(original_ids.size()); | used_unique_ids.reserve(original_ids.size()); | ||||
| Vector<int> instances_with_id_collision; | Vector<int> instances_with_id_collision; | ||||
| for (const int instance_index : original_ids.index_range()) { | for (const int instance_index : iter_indices(original_ids)) { | ||||
| const int original_id = original_ids[instance_index]; | const int original_id = original_ids[instance_index]; | ||||
| if (used_unique_ids.add(original_id)) { | if (used_unique_ids.add(original_id)) { | ||||
| /* The original id has not been used by another instance yet. */ | /* The original id has not been used by another instance yet. */ | ||||
| unique_ids[instance_index] = original_id; | unique_ids[instance_index] = original_id; | ||||
| } | } | ||||
| else { | else { | ||||
| /* The original id of this instance collided with a previous instance, it needs to be looked | /* The original id of this instance collided with a previous instance, it needs to be looked | ||||
| * at again in a second pass. Don't generate a new random id here, because this might collide | * at again in a second pass. Don't generate a new random id here, because this might collide | ||||
| ▲ Show 20 Lines • Show All 46 Lines • Show Last 20 Lines | |||||