**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.
This has potential performance benefits, since normals don't have to be
constantly converted between short and float. It also allows using
normals as a contiguous array, which has other benefits.
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.
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 more efficient. Accessing
a cotiguous `float3` array can be much more efficient than abstracting
the storage. It also means less memory needs to be loaded to read
mesh positions. 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
should retrieve normals if they are needed.
- 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.