[Bf-blender-cvs] [aa6f0f3d1fd] master: Depsgraph: remove mesh edit-mode pointer duplication

Campbell Barton noreply at git.blender.org
Fri May 21 08:24:05 CEST 2021


Commit: aa6f0f3d1fddb276391f384d0a69e509c927341f
Author: Campbell Barton
Date:   Fri May 21 16:02:05 2021 +1000
Branches: master
https://developer.blender.org/rBaa6f0f3d1fddb276391f384d0a69e509c927341f

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.

===================================================================

M	source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc

===================================================================

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;
 }



More information about the Bf-blender-cvs mailing list