[Bf-blender-cvs] [520e80d9ccb] temp-T96710-pbvh-pixels: Fix T97123: Applying modifier to multi-user: other objects were also converted

Dalai Felinto noreply at git.blender.org
Fri Apr 8 11:07:48 CEST 2022


Commit: 520e80d9ccb96bc9c22ca7ccbca946357ad6243b
Author: Dalai Felinto
Date:   Thu Apr 7 14:51:59 2022 +0200
Branches: temp-T96710-pbvh-pixels
https://developer.blender.org/rB520e80d9ccb96bc9c22ca7ccbca946357ad6243b

Fix T97123: Applying modifier to multi-user: other objects were also converted

The first element of the iterator was not being tested against the flag.
So in some cases it would lead to more objects been made into
single-user than the active (or selected) ones.

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

M	source/blender/blenkernel/intern/collection.c

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

diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c
index c215321bc30..939f7c7b3ff 100644
--- a/source/blender/blenkernel/intern/collection.c
+++ b/source/blender/blenkernel/intern/collection.c
@@ -1929,6 +1929,26 @@ void BKE_scene_objects_iterator_begin(BLI_Iterator *iter, void *data_in)
   scene_objects_iterator_begin(iter, scene, NULL);
 }
 
+static void scene_objects_iterator_skip_invalid_flag(BLI_Iterator *iter)
+{
+  if (!iter->valid) {
+    return;
+  }
+
+  /* Unpack the data. */
+  SceneObjectsIteratorExData *data = iter->data;
+  iter->data = data->iter_data;
+
+  Object *ob = iter->current;
+  if (ob && (ob->flag & data->flag) == 0) {
+    iter->skip = true;
+  }
+
+  /* Pack the data. */
+  data->iter_data = iter->data;
+  iter->data = data;
+}
+
 void BKE_scene_objects_iterator_begin_ex(BLI_Iterator *iter, void *data_in)
 {
   SceneObjectsIteratorExData *data = data_in;
@@ -1938,6 +1958,8 @@ void BKE_scene_objects_iterator_begin_ex(BLI_Iterator *iter, void *data_in)
   /* Pack the data. */
   data->iter_data = iter->data;
   iter->data = data_in;
+
+  scene_objects_iterator_skip_invalid_flag(iter);
 }
 
 void BKE_scene_objects_iterator_next_ex(struct BLI_Iterator *iter)
@@ -1948,14 +1970,11 @@ void BKE_scene_objects_iterator_next_ex(struct BLI_Iterator *iter)
 
   BKE_scene_objects_iterator_next(iter);
 
-  Object *ob = iter->current;
-  if (ob && (ob->flag & data->flag) == 0) {
-    iter->skip = true;
-  }
-
   /* Pack the data. */
   data->iter_data = iter->data;
   iter->data = data;
+
+  scene_objects_iterator_skip_invalid_flag(iter);
 }
 
 void BKE_scene_objects_iterator_end_ex(struct BLI_Iterator *iter)



More information about the Bf-blender-cvs mailing list