This prevents UV layer mix up in MeshBatchCache.cd_used/cd_needed/cd_used_over_time which depends on the extraction method.
One object's mesh can be accessed with MR_EXTRACT_MESH, another object that uses the same mesh can use MR_EXTRACT_BMESH based on (Object.mode & OB_MODE_EDIT), this causes a problem as the edit-mesh and the mesh aren't always in sync, the custom data layers wont necessarily match up, causing T77359.
Note that this effectively reverts rBd09646a40b19: Fix T73095: Edit Mode Overlay Linked Mesh, a behavior that seems reasonable, however it doesn't work well with mesh-cache at the moment.
With this patch the same edit-mesh is shown on all linked objects, the modified object doesn't show edit-data overlays.
Alternatives Solutions
- Have multiple caches, so BMEditMesh and Mesh don't conflict, add another me->runtime.batch_cache.
- Have multiple custom data struct members (track cd_used, cd_needed... etc for different mesh types).
I looked into this option, however it's complicated by not always knowing the extraction method being used when this struct member is accessed, it also seems more error prone as every access must take care to reference the correct extraction method. - Workaround the crash by checking the layer exists when it's used, although I don't think this is a good option as we'll need to do this for all custom-data layer use, and it's going to cause odd behavior when the custom-data layers don't match, even if it's not crashing.