diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2014-01-22 22:49:14 +0400 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2014-01-22 22:56:21 +0400 |
commit | 28ca299d4dfc392462efd598f14b825ba8bd21ea (patch) | |
tree | e4e114d007363d7d4ec4b8e0e0abbcfbda0466c6 /source/blender/blenkernel/intern/DerivedMesh.c | |
parent | c2fbec7bf1e0ec07f96f3f65a28a5afc1a71595d (diff) |
Fix T38316: Half of a Face is Missing on Newly Created Cubes or Cylinders.
Own bug from rBc691551249f3. Now at least I understand why `test_index_face()` is needed for tessellated quads!
Added a bunch of comments to explain the issue, as it's far from an obvious one...
We loose some performances, but it's still much quicker than org code.
Diffstat (limited to 'source/blender/blenkernel/intern/DerivedMesh.c')
-rw-r--r-- | source/blender/blenkernel/intern/DerivedMesh.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index c1424381ce6..49147db3323 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -424,7 +424,7 @@ void DM_ensure_tessface(DerivedMesh *dm) /* NOTE: Assumes dm has valid tessellated data! */ void DM_update_tessface_data(DerivedMesh *dm) { - MFace *mf = dm->getTessFaceArray(dm); + MFace *mf, *mface = dm->getTessFaceArray(dm); MPoly *mp = dm->getPolyArray(dm); MLoop *ml = dm->getLoopArray(dm); @@ -451,7 +451,7 @@ void DM_update_tessface_data(DerivedMesh *dm) { loopindex = MEM_mallocN(sizeof(*loopindex) * totface, __func__); - for (mf_idx = 0; mf_idx < totface; mf_idx++, mf++) { + for (mf_idx = 0, mf = mface; mf_idx < totface; mf_idx++, mf++) { const int mf_len = mf->v4 ? 4 : 3; unsigned int *ml_idx = loopindex[mf_idx]; int i, not_done; @@ -465,12 +465,14 @@ void DM_update_tessface_data(DerivedMesh *dm) not_done--; } } - if (mf_len == 3) { - ml_idx[3] = 0; - } } - BKE_mesh_loops_to_tessdata(fdata, ldata, pdata, polyindex, loopindex, totface); + /* NOTE: quad detection issue - forth vertidx vs forth loopidx: + * Here, our tfaces' forth vertex index is never 0 for a quad. However, we know our forth loop index may be + * 0 for quads (because our quads may have been rotated compared to their org poly, see tessellation code). + * So we pass the MFace's, and BKE_mesh_loops_to_tessdata will use MFace->v4 index as quad test. + */ + BKE_mesh_loops_to_tessdata(fdata, ldata, pdata, mface, polyindex, loopindex, totface); MEM_freeN(loopindex); } |