From deaff945d0b965d1e588cdecd084080b07db2e1f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 25 May 2020 20:16:42 +1000 Subject: Mesh: skip conversion from edit-mesh to mesh in edit-mode This resolves a performance regression in 2.8x where every edit-mode update performed an edit-mesh to mesh conversion. Now the conversion will be lazily initialized if/when it's required. New BKE_mesh_wrapper_* functions abstract over mesh data access. Currently only edit-mesh and regular meshes are supported. In the future sub-surface meshes may be supported too. --- source/blender/makesdna/DNA_mesh_types.h | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'source/blender/makesdna') diff --git a/source/blender/makesdna/DNA_mesh_types.h b/source/blender/makesdna/DNA_mesh_types.h index dc1a2b5ff1d..029352f3d85 100644 --- a/source/blender/makesdna/DNA_mesh_types.h +++ b/source/blender/makesdna/DNA_mesh_types.h @@ -112,7 +112,20 @@ typedef struct Mesh_Runtime { * In the future we may leave the mesh-data empty * since its not needed if we can use edit-mesh data. */ char is_original; - char _pad[6]; + + /** #eMeshWrapperType and others. */ + char wrapper_type; + /** + * A type mask from wrapper_type, + * in case there are differences in finalizing logic between types. + */ + char wrapper_type_finalize; + + char _pad[4]; + + /** Needed in case we need to lazily initialize the mesh. */ + CustomData_MeshMasks cd_mask_extra; + } Mesh_Runtime; typedef struct Mesh { @@ -228,6 +241,15 @@ typedef struct TFace { /* **************** MESH ********************* */ +/** #Mesh_Runtime.wrapper_type */ +typedef enum eMeshWrapperType { + /** Use mesh data (#Mesh.mvert,#Mesh.medge, #Mesh.mloop, #Mesh.mpoly). */ + ME_WRAPPER_TYPE_MDATA = 0, + /** Use edit-mesh data (#Mesh.#edit_mesh, #Mesh_Runtime.edit_data). */ + ME_WRAPPER_TYPE_BMESH = 1, + /* ME_WRAPPER_TYPE_SUBD = 2, */ /* TODO */ +} eMeshWrapperType; + /* texflag */ enum { ME_AUTOSPACE = 1, -- cgit v1.2.3