diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-03-16 18:18:32 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-03-16 18:18:32 +0400 |
commit | a7b83837db63c799c05b257c67db9d980a1650eb (patch) | |
tree | fad78df7761ba852b62d290e1c2b2413b86b9290 /source/blender/editors | |
parent | 5bea78301dcb0af8b6298abc5554643364c667dc (diff) |
fix for crash when using BM_face_calc_tessellation(), its not ensured that all tris will be filled in.
(effected knife project and laplacian smooth).
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/mesh/editmesh_knife.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c index c10e03100f3..b5b6a92cbf5 100644 --- a/source/blender/editors/mesh/editmesh_knife.c +++ b/source/blender/editors/mesh/editmesh_knife.c @@ -3312,15 +3312,17 @@ void MESH_OT_knife_tool(wmOperatorType *ot) */ static void edvm_mesh_knife_face_point(BMFace *f, float r_cent[3]) { - const int tottri = f->len - 2; + int tottri = f->len - 2; BMLoop **loops = BLI_array_alloca(loops, f->len); int (*index)[3] = BLI_array_alloca(index, tottri); int j; float const *best_co[3] = {NULL}; float best_area = -1.0f; + bool ok = false; - BM_face_calc_tessellation(f, loops, index); + tottri = BM_face_calc_tessellation(f, loops, index); + BLI_assert(tottri <= f->len - 2); for (j = 0; j < tottri; j++) { const float *p1 = loops[index[j][0]]->v->co; @@ -3336,10 +3338,16 @@ static void edvm_mesh_knife_face_point(BMFace *f, float r_cent[3]) best_co[1] = p2; best_co[2] = p3; best_area = area; + ok = true; } } - mid_v3_v3v3v3(r_cent, best_co[0], best_co[1], best_co[2]); + if (ok) { + mid_v3_v3v3v3(r_cent, best_co[0], best_co[1], best_co[2]); + } + else { + mid_v3_v3v3v3(r_cent, loops[0]->v->co, loops[1]->v->co, loops[2]->v->co); + } } static bool edbm_mesh_knife_face_isect(ARegion *ar, LinkNode *polys, BMFace *f, float projmat[4][4]) |