diff options
author | Bastien Montagne <mont29> | 2022-07-07 17:20:27 +0300 |
---|---|---|
committer | Bastien Montagne <bastien@blender.org> | 2022-07-07 17:25:34 +0300 |
commit | fcf1a9ff71e20e4af56815c4db1816d786298c3f (patch) | |
tree | 51bad6dbb1b27d29e0226e38172d828040a54667 /source/blender/makesrna | |
parent | c76e1ecac6d6611269f15b5fd229ca726bde0337 (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')
-rw-r--r-- | source/blender/makesrna/intern/rna_access.c | 1 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_meta.c | 13 |
2 files changed, 7 insertions, 7 deletions
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index a0b25cf60b2..cf4182243b9 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -2141,6 +2141,7 @@ void RNA_property_update(bContext *C, PointerRNA *ptr, PropertyRNA *prop) void RNA_property_update_main(Main *bmain, Scene *scene, PointerRNA *ptr, PropertyRNA *prop) { + BLI_assert(bmain != NULL); rna_property_update(NULL, bmain, scene, ptr, prop); } 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); |