Mesh: Store BMEditMesh in shared pointer #120276

Merged
Hans Goudey merged 5 commits from HooglyBoogly/blender:mesh-edit-mesh-shared-ptr into main 2024-04-18 13:52:32 +02:00

5 Commits

Author SHA1 Message Date
Hans Goudey 7206f7955c Avoid copying BMEditMesh in BKE_mesh_wrapper_from_editmesh 2024-04-15 12:22:40 -04:00
Hans Goudey 3b8e16450e Remove now-unnecessary BKE_mesh_eval_delete
This has the same behavior as BKE_id_free now because the edit mesh
pointers don't have to be cleared.
2024-04-15 12:14:34 -04:00
Hans Goudey b9e3058a1c Merge branch 'main' into mesh-edit-mesh-shared-ptr 2024-04-15 11:42:53 -04:00
Hans Goudey b3baf11de8 Merge branch 'main' into mesh-edit-mesh-shared-ptr 2024-04-10 14:24:20 -04:00
Hans Goudey a2b0628521 Mesh: Store BMEditMesh in shared pointer
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
The main motivation for this is that it's part of a fix for #113377,
where I want to propagate the edit mesh pointers through copied mesh
in the modifier stack and geometry nodes, instead of just setting the
mesh's edit mesh pointer at the end of the modifier stack. That would
have two main benefits:
1. We avoid the need to write to the evaluated mesh, which means it
   can be shared directly among evaluated objects.
2. When an object's mesh is completely replaced by the mesh from another
   object during evaluation (with the object info node), the final edit
   mesh pointer will not be incorrect, allowing us to skip index-mapped
   GPU data extraction.

Beyond that, using a shared pointer just makes things more automatic.
Handling of edit mesh data is already complicated enough, this way some
of the worry and complexity can be handled by RAII.

One thing to keep in mind is that the edit mesh's BMesh is still freed
manually with `EDBM_mesh_free_data` when leaving edit mode. I figured
that was a more conservative approach for now. Maybe eventually that
could be handled automatically with RAII too.
2024-04-04 17:49:31 -04:00