Revision: 42459
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=42459
Author: campbellbarton
Date: 2011-12-06 09:28:25 +0000 (Tue, 06 Dec 2011)
Log Message:
-----------
Quiet annoying warning:
Warning! Tesselation uvs or vcol data got out of sync, "had to reset!
This would happen on every editmode edit with UV's and wasn't too reassuring
that blender was handling uvs/vcols correctly.
>From looking into the problem I found that creating the undo mesh would act as
>if it was tessellating the existing mesh each time and complain that the data
>was out of sync, when infact the mesh was just created and being filled in.
Also, allocating uv and vcol customdata arrats for tessfaces isn't needed for
undo mesh, so save some memory and dont allocate these in the first place.
Modified Paths:
--------------
branches/bmesh/blender/source/blender/blenkernel/BKE_mesh.h
branches/bmesh/blender/source/blender/blenkernel/intern/DerivedMesh.c
branches/bmesh/blender/source/blender/blenkernel/intern/mesh.c
branches/bmesh/blender/source/blender/blenloader/intern/readfile.c
branches/bmesh/blender/source/blender/bmesh/operators/mesh_conv.c
branches/bmesh/blender/source/blender/editors/mesh/mesh_data.c
branches/bmesh/blender/source/blender/editors/mesh/meshtools.c
branches/bmesh/blender/source/blender/editors/sculpt_paint/paint_vertex.c
branches/bmesh/blender/source/blender/makesrna/intern/rna_mesh_utils.h
Modified: branches/bmesh/blender/source/blender/blenkernel/BKE_mesh.h
===================================================================
--- branches/bmesh/blender/source/blender/blenkernel/BKE_mesh.h 2011-12-06
09:27:18 UTC (rev 42458)
+++ branches/bmesh/blender/source/blender/blenkernel/BKE_mesh.h 2011-12-06
09:28:25 UTC (rev 42459)
@@ -91,7 +91,7 @@
void free_mesh(struct Mesh *me, int unlink);
struct Mesh *add_mesh(const char *name);
struct Mesh *copy_mesh(struct Mesh *me);
-void mesh_update_customdata_pointers(struct Mesh *me);
+void mesh_update_customdata_pointers(struct Mesh *me, const short
do_ensure_tess_cd);
void make_local_mesh(struct Mesh *me);
void boundbox_mesh(struct Mesh *me, float *loc, float *size);
Modified: branches/bmesh/blender/source/blender/blenkernel/intern/DerivedMesh.c
===================================================================
--- branches/bmesh/blender/source/blender/blenkernel/intern/DerivedMesh.c
2011-12-06 09:27:18 UTC (rev 42458)
+++ branches/bmesh/blender/source/blender/blenkernel/intern/DerivedMesh.c
2011-12-06 09:28:25 UTC (rev 42459)
@@ -424,11 +424,11 @@
}
/* yes, must be before _and_ after tesselate */
- mesh_update_customdata_pointers(&tmp);
+ mesh_update_customdata_pointers(&tmp, TRUE);
tmp.totface = mesh_recalcTesselation(&tmp.fdata, &tmp.ldata,
&tmp.pdata, tmp.mvert, tmp.totface, tmp.totloop, tmp.totpoly);
- mesh_update_customdata_pointers(&tmp);
+ mesh_update_customdata_pointers(&tmp, TRUE);
CustomData_free(&me->vdata, me->totvert);
Modified: branches/bmesh/blender/source/blender/blenkernel/intern/mesh.c
===================================================================
--- branches/bmesh/blender/source/blender/blenkernel/intern/mesh.c
2011-12-06 09:27:18 UTC (rev 42458)
+++ branches/bmesh/blender/source/blender/blenkernel/intern/mesh.c
2011-12-06 09:28:25 UTC (rev 42459)
@@ -307,13 +307,14 @@
static void mesh_ensure_tesselation_customdata(Mesh *me)
{
- int tottex, totcol;
+ const int tottex_original = CustomData_number_of_layers(&me->pdata,
CD_MTEXPOLY);
+ const int totcol_original = CustomData_number_of_layers(&me->ldata,
CD_MLOOPCOL);
- tottex = CustomData_number_of_layers(&me->fdata, CD_MTFACE);
- totcol = CustomData_number_of_layers(&me->fdata, CD_MCOL);
-
- if (tottex != CustomData_number_of_layers(&me->pdata, CD_MTEXPOLY) ||
- totcol != 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);
+
+ if (tottex_tessface != tottex_original ||
+ totcol_tessface != totcol_original )
{
CustomData_free(&me->fdata, me->totface);
@@ -325,25 +326,38 @@
memset(&me->fdata, 0, sizeof(&me->fdata));
CustomData_from_bmeshpoly(&me->fdata, &me->pdata, &me->ldata,
me->totface);
- printf("Warning! Tesselation uvs or vcol data got out of sync,
had to reset!\n");
+
+ /* 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! Tesselation 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);
}
}
-/*this ensures grouped customdata (e.g. mtexpoly and mloopuv and mtface, or
- mloopcol and mcol) have the same relative active/render/clone/mask indices.*/
-static void mesh_update_linked_customdata(Mesh *me)
+/* this ensures grouped customdata (e.g. mtexpoly and mloopuv and mtface, or
+ * mloopcol and mcol) have the same relative active/render/clone/mask indices.
+ *
+ * note that for undo mesh data we want to skip 'ensure_tess_cd' call since
+ * we dont want to store memory for tessface when its only used for older
+ * versions of the mesh. - campbell*/
+static void mesh_update_linked_customdata(Mesh *me, const short
do_ensure_tess_cd)
{
if (me->edit_btmesh)
BMEdit_UpdateLinkedCustomData(me->edit_btmesh);
- mesh_ensure_tesselation_customdata(me);
+ if (do_ensure_tess_cd) {
+ mesh_ensure_tesselation_customdata(me);
+ }
CustomData_bmesh_update_active_layers(&me->fdata, &me->pdata,
&me->ldata);
}
-void mesh_update_customdata_pointers(Mesh *me)
+void mesh_update_customdata_pointers(Mesh *me, const short do_ensure_tess_cd)
{
- mesh_update_linked_customdata(me);
+ mesh_update_linked_customdata(me, do_ensure_tess_cd);
me->mvert = CustomData_get_layer(&me->vdata, CD_MVERT);
me->dvert = CustomData_get_layer(&me->vdata, CD_MDEFORMVERT);
@@ -483,7 +497,7 @@
CustomData_copy(&me->fdata, &men->fdata, CD_MASK_MESH, CD_DUPLICATE,
men->totface);
CustomData_copy(&me->ldata, &men->ldata, CD_MASK_MESH, CD_DUPLICATE,
men->totloop);
CustomData_copy(&me->pdata, &men->pdata, CD_MASK_MESH, CD_DUPLICATE,
men->totpoly);
- mesh_update_customdata_pointers(men);
+ mesh_update_customdata_pointers(men, TRUE);
/* ensure indirect linked data becomes lib-extern */
for(i=0; i<me->fdata.totlayer; i++) {
@@ -1100,7 +1114,7 @@
&me->fdata, &me->ldata, &me->pdata,
me->mvert, me->totface, me->totloop, me->totpoly);
- mesh_update_customdata_pointers(me);
+ mesh_update_customdata_pointers(me, TRUE);
}
}
@@ -1927,7 +1941,7 @@
/* note, we dont convert FGons at all, these are not even real ngons,
* they have their own UV's, colors etc - its more an editing feature.
*/
- mesh_update_customdata_pointers(mesh);
+ mesh_update_customdata_pointers(mesh, TRUE);
BLI_edgehash_free(eh, NULL);
}
Modified: branches/bmesh/blender/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/bmesh/blender/source/blender/blenloader/intern/readfile.c
2011-12-06 09:27:18 UTC (rev 42458)
+++ branches/bmesh/blender/source/blender/blenloader/intern/readfile.c
2011-12-06 09:28:25 UTC (rev 42459)
@@ -3679,7 +3679,7 @@
&me->fdata, &me->ldata, &me->pdata,
me->mvert, me->totface, me->totloop,
me->totpoly);
- mesh_update_customdata_pointers(me);
+ mesh_update_customdata_pointers(me, TRUE);
me->id.flag -= LIB_NEEDLINK;
}
@@ -6570,7 +6570,7 @@
}
}
- mesh_update_customdata_pointers(me);
+ mesh_update_customdata_pointers(me, TRUE);
}
/*only copy render texface layer from active*/
Modified: branches/bmesh/blender/source/blender/bmesh/operators/mesh_conv.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/operators/mesh_conv.c
2011-12-06 09:27:18 UTC (rev 42458)
+++ branches/bmesh/blender/source/blender/bmesh/operators/mesh_conv.c
2011-12-06 09:28:25 UTC (rev 42459)
@@ -618,7 +618,7 @@
CustomData_add_layer(&me->fdata, CD_NORMAL, CD_ASSIGN,
facenors, me->totface);
CustomData_from_bmeshpoly(&me->fdata, &bm->pdata, &bm->ldata,
totface);
- mesh_update_customdata_pointers(me);
+ mesh_update_customdata_pointers(me, TRUE);
i = 0;
BM_ITER_INDEX(f, &iter, bm, BM_FACES_OF_MESH, NULL, j) {
@@ -769,7 +769,7 @@
if (vertMap) MEM_freeN(vertMap);
}
- mesh_update_customdata_pointers(me);
+ mesh_update_customdata_pointers(me, dotess);
{
BMEditSelection *selected;
Modified: branches/bmesh/blender/source/blender/editors/mesh/mesh_data.c
===================================================================
--- branches/bmesh/blender/source/blender/editors/mesh/mesh_data.c
2011-12-06 09:27:18 UTC (rev 42458)
+++ branches/bmesh/blender/source/blender/editors/mesh/mesh_data.c
2011-12-06 09:28:25 UTC (rev 42459)
@@ -113,7 +113,7 @@
}
else {
CustomData_free_layer_active(data, type, tot);
- mesh_update_customdata_pointers(me);
+ mesh_update_customdata_pointers(me, TRUE);
}
if(!CustomData_has_layer(data, type) && (type == CD_MLOOPCOL &&
(ob->mode & OB_MODE_VERTEX_PAINT)))
@@ -354,7 +354,7 @@
CustomData_set_layer_active(&me->fdata, CD_MTFACE,
layernum);
}
- mesh_update_customdata_pointers(me);
+ mesh_update_customdata_pointers(me, TRUE);
}
ED_mesh_uv_loop_reset(C, me);
@@ -434,7 +434,7 @@
CustomData_set_layer_active(&me->fdata, CD_MCOL,
layernum);
}
- mesh_update_customdata_pointers(me);
+ mesh_update_customdata_pointers(me, TRUE);
}
DAG_id_tag_update(&me->id, 0);
@@ -767,7 +767,7 @@
mesh->totloop,
mesh->totpoly);
- mesh_update_customdata_pointers(mesh);
+ mesh_update_customdata_pointers(mesh, TRUE);
polyindex = CustomData_get_layer(&mesh->fdata, CD_POLYINDEX);
/* add a normals layer for tesselated faces, a tessface normal will
@@ -809,7 +809,7 @@
CustomData_free(&mesh->vdata, mesh->totvert);
mesh->vdata= vdata;
- mesh_update_customdata_pointers(mesh);
+ mesh_update_customdata_pointers(mesh, FALSE);
/* scan the input list and insert the new vertices */
@@ -852,7 +852,7 @@
CustomData_free(&mesh->edata, mesh->totedge);
mesh->edata= edata;
- mesh_update_customdata_pointers(mesh);
+ mesh_update_customdata_pointers(mesh, FALSE); /* new edges dont change
tessellation */
/* set default flags */
medge= &mesh->medge[mesh->totedge];
@@ -882,7 +882,7 @@
CustomData_free(&mesh->fdata, mesh->totface);
mesh->fdata= fdata;
- mesh_update_customdata_pointers(mesh);
+ mesh_update_customdata_pointers(mesh, TRUE);
/* set default flags */
mface= &mesh->mface[mesh->totface];
@@ -911,7 +911,7 @@
CustomData_free(&mesh->ldata, mesh->totloop);
mesh->ldata= ldata;
- mesh_update_customdata_pointers(mesh);
+ mesh_update_customdata_pointers(mesh, TRUE);
mesh->totloop= totloop;
}
@@ -936,7 +936,7 @@
CustomData_free(&mesh->pdata, mesh->totpoly);
mesh->pdata= pdata;
- mesh_update_customdata_pointers(mesh);
+ mesh_update_customdata_pointers(mesh, TRUE);
/* set default flags */
mpoly= &mesh->mpoly[mesh->totpoly];
Modified: branches/bmesh/blender/source/blender/editors/mesh/meshtools.c
===================================================================
--- branches/bmesh/blender/source/blender/editors/mesh/meshtools.c
2011-12-06 09:27:18 UTC (rev 42458)
+++ branches/bmesh/blender/source/blender/editors/mesh/meshtools.c
2011-12-06 09:28:25 UTC (rev 42459)
@@ -522,7 +522,7 @@
me->ldata= ldata;
me->pdata= pdata;
- mesh_update_customdata_pointers(me);
@@ Diff output truncated at 10240 characters. @@
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs