=== The Change ===
As described in T91186, this patch moves mesh vertex normals into a
separate custom data layer, like how face normals are currently stored.
The normal array values are now stored as floats, in a contiguous array.
The patch also changes code to use on-demand calculation for vertex and
face normals. Vertex normals are retrieved with an "ensure" function,
and cached in vertex custom data storage. Face normals are handled in
the same way. The main interface is described in `BKE_mesh.c`.
Since the logical state of a mesh is now "has normals when necessary",
normals can be retrieved from a const mesh, protected by a mutex.
=== Benefits ===
This moves us closer to a SoA approach rather than the current AoS
paradigm. This makes accessing each value faster, since accessing
a contiguous `float3` array can be much more efficient than abstracting
the storage. It also means less memory needs to be loaded to read
mesh positions. And at the cost of more memory usage, normals now
don't have to be converted between float and short all the time.
The best example of this change is in `node_geo_input_normal.cc`.
In the future, the remaining items can be removed from `MVert`, and
we will just be left with `float3`, which has similar benefits.
This approach makes it much simpler to use lazy calculation of normals,
meaning we can easily defer calculation until it's actually needed.
This is especially important now that we have more opportunities for
temporary meshes in geometry nodes.
=== Tests ===
Some tests are failing now, for two reasons. First is that normals
are now dirty after the subdivision surface modifier. Even in current
master, the modifier creates different normals than the result
of the `Mesh` normal calculation. You can observe this by adding a
`BKE_mesh_calc_normals` call after the modifier in master.
The other test differences are small changes in the result from things
like the displace modifier, where storing normals in floats instead of
shorts gives a slightly different result.
Test results can be updated when the patch is committed.
=== Future improvements ===
- Remove `ModifierTypeInfo::dependsOnNormals`. Code in each modifier
already retrieves normals if they are needed anyway.
- Refactor mesh copying to only copy normals when they are not dirty.
- Make more areas use lazy instead of eager normal calculation.
- Remove `BKE_mesh_normals_tag_dirty` in more places since that is the
default state of a new mesh.