diff options
-rw-r--r-- | source/blender/blenkernel/intern/mesh.c | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 52dc3ff8d84..e376134b26b 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -305,26 +305,34 @@ const char *mesh_cmp(Mesh *me1, Mesh *me2, float thresh) static void mesh_ensure_tessellation_customdata(Mesh *me) { - const int tottex_original = CustomData_number_of_layers(&me->pdata, CD_MTEXPOLY); - const int totcol_original = CustomData_number_of_layers(&me->ldata, CD_MLOOPCOL); + if (UNLIKELY((me->totface != 0) && (me->totpoly == 0))) { + /* Pass, otherwise this function clears 'mface' before + * versioning 'mface -> mpoly' code kicks in [#30583] + * + * Callers could also check but safer to do here - campbell */ + } + else { + const int tottex_original = CustomData_number_of_layers(&me->pdata, CD_MTEXPOLY); + const int totcol_original = CustomData_number_of_layers(&me->ldata, CD_MLOOPCOL); - const int tottex_tessface = CustomData_number_of_layers(&me->fdata, CD_MTFACE); - const int totcol_tessface = CustomData_number_of_layers(&me->fdata, CD_MCOL); + const int tottex_tessface = CustomData_number_of_layers(&me->fdata, CD_MTFACE); + const int totcol_tessface = CustomData_number_of_layers(&me->fdata, CD_MCOL); - if (tottex_tessface != tottex_original || - totcol_tessface != totcol_original ) - { - BKE_mesh_tessface_clear(me); + if (tottex_tessface != tottex_original || + totcol_tessface != totcol_original ) + { + BKE_mesh_tessface_clear(me); - CustomData_from_bmeshpoly(&me->fdata, &me->pdata, &me->ldata, me->totface); + CustomData_from_bmeshpoly(&me->fdata, &me->pdata, &me->ldata, me->totface); - /* note: this warning may be un-called for if we are inirializing the mesh for the - * first time from bmesh, rather then giving a warning about this we could be smarter - * and check if there was any data to begin with, for now just print the warning with - * some info to help troubleshoot whats going on - campbell */ - printf("%s: warning! Tessellation uvs or vcol data got out of sync, " - "had to reset!\n CD_MTFACE: %d != CD_MTEXPOLY: %d || CD_MCOL: %d != CD_MLOOPCOL: %d\n", - __func__, tottex_tessface, tottex_original, totcol_tessface, totcol_original); + /* note: this warning may be un-called for if we are inirializing the mesh for the + * first time from bmesh, rather then giving a warning about this we could be smarter + * and check if there was any data to begin with, for now just print the warning with + * some info to help troubleshoot whats going on - campbell */ + printf("%s: warning! Tessellation uvs or vcol data got out of sync, " + "had to reset!\n CD_MTFACE: %d != CD_MTEXPOLY: %d || CD_MCOL: %d != CD_MLOOPCOL: %d\n", + __func__, tottex_tessface, tottex_original, totcol_tessface, totcol_original); + } } } |