fix [#30583] very old blend files are loading post-bmesh with no face/uv information, just wires
versioning code called a customdata update function which ended up clearing tessfaces - before converting polygons to tessfaces. Added check so tessfaces aren't cleared when there are no polygons.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user