Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <mont29>2022-07-07 17:20:27 +0300
committerBastien Montagne <bastien@blender.org>2022-07-07 17:25:34 +0300
commitfcf1a9ff71e20e4af56815c4db1816d786298c3f (patch)
tree51bad6dbb1b27d29e0226e38172d828040a54667 /source/blender/makesrna/intern/rna_meta.c
parentc76e1ecac6d6611269f15b5fd229ca726bde0337 (diff)
Fix T99256: Regression: Meta balls segfaulting copy-to-selected.
Revealed by rB43167a2c251b, but actuall issue is the `rna_MetaBall_update_data` function expecting a never-NULL `scene` pointer, which is not guaranteed. This lead to refactoring the duo `rna_MetaBall_update_data`/`BKE_mball_properties_copy`, since it was doing a very sub-optimal O(n^2) process, new code is O(2n) now (n being the number of Objects). Not sure why the objects were processed through the existing bases of the existing scene in the first place, this could miss a lot of affected objects (e.g. in case said objects are in an excluded collection, etc.). Also noticed that both old and new implementation can fail to fully propagate changes to all affected meta-balls in some specific corner cases, added a comment about it in the code. Reviewed By: sergey Maniphest Tasks: T99256 Differential Revision: https://developer.blender.org/D15338
Diffstat (limited to 'source/blender/makesrna/intern/rna_meta.c')
-rw-r--r--source/blender/makesrna/intern/rna_meta.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/source/blender/makesrna/intern/rna_meta.c b/source/blender/makesrna/intern/rna_meta.c
index e6cf743e167..898208e0ba1 100644
--- a/source/blender/makesrna/intern/rna_meta.c
+++ b/source/blender/makesrna/intern/rna_meta.c
@@ -81,18 +81,17 @@ static void rna_MetaBall_redraw_data(Main *UNUSED(bmain), Scene *UNUSED(scene),
WM_main_add_notifier(NC_GEOM | ND_DATA, id);
}
-static void rna_MetaBall_update_data(Main *bmain, Scene *scene, PointerRNA *ptr)
+static void rna_MetaBall_update_data(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
{
MetaBall *mb = (MetaBall *)ptr->owner_id;
Object *ob;
- /* cheating way for importers to avoid slow updates */
+ /* NOTE: The check on the number of users allows to avoid many repetitive (slow) updates in some
+ * cases, like e.g. importers. Calling `BKE_mball_properties_copy` on an obdata with no users
+ * would be meaningless anyway, as by definition it would not be used by any object, so not part
+ * of any meta-ball group. */
if (mb->id.us > 0) {
- for (ob = bmain->objects.first; ob; ob = ob->id.next) {
- if (ob->data == mb) {
- BKE_mball_properties_copy(scene, ob);
- }
- }
+ BKE_mball_properties_copy(bmain, mb);
DEG_id_tag_update(&mb->id, 0);
WM_main_add_notifier(NC_GEOM | ND_DATA, mb);