[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [45018] trunk/blender/source/blender/ blenkernel/intern/mesh.c: fix [#30583] very old blend files are loading post-bmesh with no face/uv information, just wires
Campbell Barton
ideasman42 at gmail.com
Tue Mar 20 06:05:06 CET 2012
Revision: 45018
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=45018
Author: campbellbarton
Date: 2012-03-20 05:04:51 +0000 (Tue, 20 Mar 2012)
Log Message:
-----------
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.
Modified Paths:
--------------
trunk/blender/source/blender/blenkernel/intern/mesh.c
Modified: trunk/blender/source/blender/blenkernel/intern/mesh.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/mesh.c 2012-03-20 04:27:14 UTC (rev 45017)
+++ trunk/blender/source/blender/blenkernel/intern/mesh.c 2012-03-20 05:04:51 UTC (rev 45018)
@@ -305,26 +305,34 @@
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);
+ }
}
}
More information about the Bf-blender-cvs
mailing list