Page MenuHome

Fix T99256: Regression: Meta balls segfaulting copy-to-selected.
ClosedPublic

Authored by Bastien Montagne (mont29) on Jul 1 2022, 1:51 PM.

Details

Summary

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 potentially O(n^2) process in worst case, new
code would be O(2n) in worst case (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.

Diff Detail

Repository
rB Blender

Event Timeline

Bastien Montagne (mont29) requested review of this revision.Jul 1 2022, 1:51 PM
Bastien Montagne (mont29) created this revision.

it was doing a very sub-optimal potentially O(n^2) process in worst case, new code would be O(2n) in worst case (n being the number of Objects).

This is a bit weird wording and formulation. The big-O notation is already describing the limiting behavior of a function. O(N^2) means that in the worst case the algorithm will take N operations to complete. So, saying potentially O(n^2) process in worst case is redundant. Typically you'll use wording like It was using a sub-optimal algorithm with the O(N^2) complexity.

The O(2*N) is another interesting one: O(2*N) = O(N), or, in general case O(k*f) = O(f) where k is a non-zero constant and f is the complexity function. In short: typically constant is not explicitly mentioned in the O-notation.


Those nerdy explanations aside the code seems fine :)

source/blender/blenkernel/intern/mball.c
458

Think here and later it should be the family.

This revision is now accepted and ready to land.Jul 7 2022, 11:59 AM