Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-03-20 09:04:51 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-03-20 09:04:51 +0400
commit65a71a1bbf0fd91738f2a35da4acb756993d39b5 (patch)
tree674bee9a365cdfd22079cc63ba3d15dcb37208a1 /source/blender/blenkernel/intern/mesh.c
parentbe116242d43c58ddf08b5d28379cdb0a26b6bb5c (diff)
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.
Diffstat (limited to 'source/blender/blenkernel/intern/mesh.c')
-rw-r--r--source/blender/blenkernel/intern/mesh.c40
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);
+ }
}
}