Here is the my current work on adding the new Poisson scattering method.
(This should close T83230 and T83228)
I've also added a Seed input so the user can change the random seed if they wish.
There are still some things that needs to be done:
- How should proceed with the 3rd party header library I pulled in.
I've only picked out a small subset of this library: https://github.com/cemyuksel/cyCodeBase/
The library is heavily templated so I could see it used in some other parts of blender in the future.
But for the functionality we need for this case, we could easily just write our own code as the algorithm is quite simple.
- Fix the doversion code. Older files with connections to the "Density" socket will have this connection lost.
I've tried to figure out how to properly fix this before my vacation started, but couldn't do it within that time frame.
- There might be some optimization/multithreading that could be done.
Sadly for the slowest part (the Poisson distribution algorithm), some clever work would have to be done to make it multi threaded.
The two slow parts is the weight assignment to the points and then the point elimination.
From my tests, they have nearly the same execution time.
For the point weight assignment this could easily be multi threaded by just running all points in parallel (the points individual weight does not depend on the other points weight), so we could have a massive speed up here.
The point elimination is a bit trickier though as the point with the highest weight is removed first. Because the point is removed, all points in its vicinity will have to update their weight values. We could probably do some clever multi threading by slicing the point distribution up and eliminating points within those slices. It would probably work the same way as with particle physics sims where you make sure you only calculate solutions in parallel for points that can't influence each other.