Page MenuHome

Fix T77359: Crash adding UV's in edit-mode with linked duplicates
AbandonedPublic

Authored by Campbell Barton (campbellbarton) on Aug 20 2020, 12:08 AM.

Details

Summary

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.

Diff Detail

Repository
rB Blender
Branch
TEMP-T77359-FIX (branched from master)
Build Status
Buildable 9667
Build 9667: arc lint + arc unit

Event Timeline

Campbell Barton (campbellbarton) created this revision.
Campbell Barton (campbellbarton) retitled this revision from Fix T77359: Crash adding UV's in edit-mode to Fix T77359: Crash adding UV's in edit-mode with linked duplicates.Aug 20 2020, 1:18 AM

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.

I'm confused by this description. From what I see testing the patch, the only thing that changed is that the other object shows with the same modifiers as the active object, rather than its own modifiers.

The overlays showing or not is unchanged. Or am I missing something?

If the behavior is as I described, it's not ideal but I also don't immediately have a better solution.

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.

I'm confused by this description. From what I see testing the patch, the only thing that changed is that the other object shows with the same modifiers as the active object, rather than its own modifiers.

The overlays showing or not is unchanged. Or am I missing something?

If the behavior is as I described, it's not ideal but I also don't immediately have a better solution.

My intention was to use the same edit-mesh cage on both, I didn't consider the case where the modifiers from the edit-mesh would be displayed on the other objects.

I don't like this so much since it's not just showing less information, it's showing the wrong information.

This patch P1596 makes some changes to this one, so it shows the edit-mesh without modifiers for other objects.

While I couldn't get it to crash when adding/removing UV's, vertex colors etc... I can't be completely sure that there wont be some discrepancy between the edit-mesh and the final-mesh used for displaying the active edit object.

P1596 seems fine to me. And in testing I couldn't find issues, but it's difficult to know all the corner cases are ok.