Vertex normals are now deterministic, meaning the result values will
be the same every time they are calculated. This is important for
making renders match exactly when none of the geometry changes.
This commit uses the `SharedCache` concept to keep a cached map from
mesh vertices to polygons available on a mesh as necessary. The map
is split into two caches internally, since the same offsets can be
reused for a potential vertex to face corner map in the future
(though that may be a bit preemptive).
Such a cache (or similar) is often used in topology-changing operations,
and in the future it can be updated as necessary. For now it's simply
calculated as necessary though, since it may take time to validate the
choice of cached map. For example, it could make sense to cache
a vertex to corner and a corner to face map instead.
This allows avoiding recalculations of mesh normals even when meshes
are copied, if the positions and topology are unchanged. Face corner
normals aren't affected yet though.
The BKE_mesh_vert_normals_for_write behavior is quite hacky,
it may need a better solution in the future.
A few places already calculated vertex normals with better contextual
information to improve performance. To allow abstracting the storage
of vertex normals more, change some code from "get normals, set values"
to "make array, set values, give to mesh". This makes the API less
awkward too, since previously the "get for write" and "clear dirty"
calls always had to be separated.