From 03f451f2f18cccd80d0d56391c4836da34641a60 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 23 Apr 2012 23:01:03 +0000 Subject: fix own error with subdivision (broke icosphere), also noticed icosphere vanished at subd-5 which didnt happen before bmesh. --- source/blender/bmesh/intern/bmesh_mesh_conv.c | 6 ++++-- source/blender/bmesh/operators/bmo_subdivide.c | 10 +++++----- 2 files changed, 9 insertions(+), 7 deletions(-) (limited to 'source/blender/bmesh') diff --git a/source/blender/bmesh/intern/bmesh_mesh_conv.c b/source/blender/bmesh/intern/bmesh_mesh_conv.c index e247a69f1e9..f72efe8ab5f 100644 --- a/source/blender/bmesh/intern/bmesh_mesh_conv.c +++ b/source/blender/bmesh/intern/bmesh_mesh_conv.c @@ -484,12 +484,14 @@ static int bm_to_mesh_shape_layer_index_from_kb(BMesh *bm, KeyBlock *currkey) BLI_INLINE void bmesh_quick_edgedraw_flag(MEdge *med, BMEdge *e) { /* this is a cheap way to set the edge draw, its not precise and will - * pick the first 2 faces an edge uses */ + * pick the first 2 faces an edge uses. + * The dot comparison is a little arbitrary, but set so that a 5 subd + * IcoSphere won't vanish but subd 6 will (as with pre-bmesh blender) */ if ( /* (med->flag & ME_EDGEDRAW) && */ /* assume to be true */ (e->l && (e->l != e->l->radial_next)) && - (dot_v3v3(e->l->f->no, e->l->radial_next->f->no) > 0.998f)) + (dot_v3v3(e->l->f->no, e->l->radial_next->f->no) > 0.9995f)) { med->flag &= ~ME_EDGEDRAW; } diff --git a/source/blender/bmesh/operators/bmo_subdivide.c b/source/blender/bmesh/operators/bmo_subdivide.c index d5f46ebfc85..7da02a594d5 100644 --- a/source/blender/bmesh/operators/bmo_subdivide.c +++ b/source/blender/bmesh/operators/bmo_subdivide.c @@ -109,7 +109,11 @@ static void alter_co(BMesh *bm, BMVert *v, BMEdge *UNUSED(origed), const SubDPar copy_v3_v3(co, v->co); copy_v3_v3(prev_co, co); - if (params->use_smooth) { + if (UNLIKELY(params->use_sphere)) { /* subdivide sphere */ + normalize_v3(co); + mul_v3_fl(co, params->smooth); + } + else if (params->use_smooth) { /* we calculate an offset vector vec1[], to be added to *co */ float len, nor[3], nor1[3], nor2[3], smooth = params->smooth; @@ -134,10 +138,6 @@ static void alter_co(BMesh *bm, BMVert *v, BMEdge *UNUSED(origed), const SubDPar add_v3_v3(co, tvec); } - else if (params->use_sphere) { /* subdivide sphere */ - normalize_v3(co); - mul_v3_fl(co, params->smooth); - } if (params->use_fractal) { float len = len_v3v3(vsta->co, vend->co); -- cgit v1.2.3