Fix #109583: Avoid non-threadsafe writing to custom normals data #112055

Merged

1 Commits

Author SHA1 Message Date
Hans Goudey e85c10b43a Fix #109583: Avoid non-threadsafe writing to custom normals data
buildbot/vexp-code-patch-coordinator Build done. Details
Currently, while calculating face corner normals, Blender retrieves
custom normal data with write access. When the the custom normals in a
single smooth corner fan don't match, they are reset to the average
value.

This behavior is very old, but it comes from when Blender didn't have a
strong idea of const correctness. Indeed, modifying custom normal data
while calculating normals isn't threadsafe, which is important because
normals are calculated for viewport drawing, for example. And in the
future, properly caching face corner normals (see #93551) will require
the ability to calculate normals on a properly const mesh.

The fix is to still use the average of custom normals in a fan, but
not write that back to the custom data array. In my testing the results
are the same. Setting custom normals still fills the same value for all
corners in a fan.

Pull Request: #110478
2023-09-06 15:43:41 -04:00