diff options
author | Campbell Barton <ideasman42@gmail.com> | 2021-05-21 09:02:05 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2021-05-21 09:23:42 +0300 |
commit | aa6f0f3d1fddb276391f384d0a69e509c927341f (patch) | |
tree | 68100a978a2b9d80e62a8aacc68af46504976070 /source/blender/depsgraph/intern/eval | |
parent | 12a91f7f5da52f7e361904005ffc8a46f234f05d (diff) |
Depsgraph: remove mesh edit-mode pointer duplication
Share the pointer with the original mesh instead, this matches behavior
of all other objects edit-mode data.
Duplicating the edit-mesh pointer makes updates to edit-mesh require
a COPY_ON_WRITE update, which is currently an expensive operation
(copying the entire mesh).
Notes:
- This change is from 802027f3f8f9a83a77134a2b104a25ff3a4ac013
so the edit-meshes object pointer `BMEditMesh.ob` referenced the COW
version of the object. This pointer has since been removed, so the
copy is no longer needed.
- Having a separate edit-mesh pointer could be used so linked duplicates
could have their own generated meshes. For this to be supported,
many other changes would be needed: see D10920.
Diffstat (limited to 'source/blender/depsgraph/intern/eval')
-rw-r--r-- | source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc | 15 |
1 files changed, 1 insertions, 14 deletions
diff --git a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc index 43bcb23a38a..e5d7bd70214 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc +++ b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc @@ -606,20 +606,12 @@ void update_lattice_edit_mode_pointers(const Depsgraph * /*depsgraph*/, void update_mesh_edit_mode_pointers(const ID *id_orig, ID *id_cow) { - /* For meshes we need to update edit_mesh to make it to point - * to the CoW version of object. - * - * This is kind of confusing, because actual bmesh is not owned by - * the CoW object, so need to be accurate about using link from - * edit_mesh to object. */ const Mesh *mesh_orig = (const Mesh *)id_orig; Mesh *mesh_cow = (Mesh *)id_cow; if (mesh_orig->edit_mesh == nullptr) { return; } - mesh_cow->edit_mesh = (BMEditMesh *)MEM_dupallocN(mesh_orig->edit_mesh); - mesh_cow->edit_mesh->mesh_eval_cage = nullptr; - mesh_cow->edit_mesh->mesh_eval_final = nullptr; + mesh_cow->edit_mesh = mesh_orig->edit_mesh; } /* Edit data is stored and owned by original datablocks, copied ones @@ -1001,11 +993,6 @@ void discard_lattice_edit_mode_pointers(ID *id_cow) void discard_mesh_edit_mode_pointers(ID *id_cow) { Mesh *mesh_cow = (Mesh *)id_cow; - if (mesh_cow->edit_mesh == nullptr) { - return; - } - BKE_editmesh_free_derivedmesh(mesh_cow->edit_mesh); - MEM_freeN(mesh_cow->edit_mesh); mesh_cow->edit_mesh = nullptr; } |