From 8ab98d0ed7d21aef1f6a259b4dc9b907f2193c1b Mon Sep 17 00:00:00 2001 From: Germano Cavalcante Date: Thu, 17 Sep 2020 11:10:58 -0300 Subject: Add versioning for 2.90 files that may have invalid mesh rBf2d26409e83b fixed a serious problem with invalid mesh after an operation with the extrude manifold. Since BKE_mesh_validate_arrays is a slow operation, the chosen interval between versions is relatively small and also only the mentioned invalid mesh problem is tested. Differential Revision: https://developer.blender.org/D8898 --- source/blender/blenloader/intern/versioning_290.c | 30 +++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/source/blender/blenloader/intern/versioning_290.c b/source/blender/blenloader/intern/versioning_290.c index 84eee6c1d90..e7da180cb12 100644 --- a/source/blender/blenloader/intern/versioning_290.c +++ b/source/blender/blenloader/intern/versioning_290.c @@ -29,6 +29,8 @@ #include "DNA_genfile.h" #include "DNA_gpencil_modifier_types.h" #include "DNA_gpencil_types.h" +#include "DNA_mesh_types.h" +#include "DNA_meshdata_types.h" #include "DNA_modifier_types.h" #include "DNA_object_force_types.h" #include "DNA_object_types.h" @@ -41,6 +43,7 @@ #include "BKE_gpencil.h" #include "BKE_lib_id.h" #include "BKE_main.h" +#include "BKE_mesh.h" #include "BKE_node.h" #include "BLO_readfile.h" @@ -257,6 +260,33 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain) { UNUSED_VARS(fd); + if (MAIN_VERSION_ATLEAST(bmain, 290, 2) && MAIN_VERSION_OLDER(bmain, 291, 1)) { + /* In this range, the extrude manifold could generate meshes with degenerated face. */ + LISTBASE_FOREACH (Mesh *, me, &bmain->meshes) { + for (MPoly *mp = me->mpoly, *mp_end = mp + me->totpoly; mp < mp_end; mp++) { + if (mp->totloop == 2) { + bool changed; + BKE_mesh_validate_arrays(me, + me->mvert, + me->totvert, + me->medge, + me->totedge, + me->mface, + me->totface, + me->mloop, + me->totloop, + me->mpoly, + me->totpoly, + me->dvert, + false, + true, + &changed); + break; + } + } + } + } + /** Repair files from duplicate brushes added to blend files, see: T76738. */ if (!MAIN_VERSION_ATLEAST(bmain, 290, 2)) { { -- cgit v1.2.3