The current method to update the normals does the following:
- Allocate an array the same size of mverts regardless of the normals
that need to be updated
- Loop over the faces to accumulate the normals using an atomic_add into
the array
- Loop again over vertices to normalize the accumulated normal and store
in in the vertex
- Free the array
If the SculptSession already contains a pmap that vertices to polys, all
these steps can be skiped and the accumulation can be do in a single
loop over the affected vertices.
Using the scale mesh filter in a Threadripper 3990X to modify an entire
mesh with different vertex counts I get the following results:
Note: I left the timer code in case you want to check if this
improvement also applies in other hardware. In order to test, just run
the mesh filter after entering sculpt mode to use the current update
method, then use smooth to allocate the pmap and run the test again.