diff options
author | Joseph Eagar <joeedh@gmail.com> | 2011-04-29 21:32:42 +0400 |
---|---|---|
committer | Joseph Eagar <joeedh@gmail.com> | 2011-04-29 21:32:42 +0400 |
commit | e0c83f2de94914eb7c2ac9cfa46d3b273a760673 (patch) | |
tree | 7be0960b63dd14a7727c0e328622c6547eb51c59 | |
parent | b85935cbbcbf21b96ff29c9bde2f2d87b5bccc91 (diff) |
=bmesh= made connected PET work better
-rw-r--r-- | source/blender/blenkernel/intern/mesh.c | 2 | ||||
-rw-r--r-- | source/blender/bmesh/operators/mesh_conv.c | 3 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_conversions.c | 89 |
3 files changed, 45 insertions, 49 deletions
diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 78e90184970..e51aa4624b9 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -1042,7 +1042,7 @@ static void make_edges_mdata(MVert *UNUSED(allvert), MFace *allface, MLoop *alll int v1, v2; v1 = mloop[b].v; - v2 = mloop[(b+1)%mpoly->loopstart].v; + v2 = mloop[(b+1)%mpoly->totloop].v; mloop[b].e = GET_INT_FROM_POINTER(BLI_edgehash_lookup(hash, v1, v2)); } } diff --git a/source/blender/bmesh/operators/mesh_conv.c b/source/blender/bmesh/operators/mesh_conv.c index 65a3fc8b543..9f8c421eb43 100644 --- a/source/blender/bmesh/operators/mesh_conv.c +++ b/source/blender/bmesh/operators/mesh_conv.c @@ -145,7 +145,8 @@ void mesh_to_bmesh_exec(BMesh *bm, BMOperator *op) { for (block=me->key->block.first, j=0; block; block=block->next, j++) { float *co = CustomData_bmesh_get_n(&bm->vdata, v->head.data, CD_SHAPEKEY, j); - VECCOPY(co, ((float*)block->data)+3*i); + if (co) + VECCOPY(co, ((float*)block->data)+3*i); } } } diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index e26638f97c9..25a3498403b 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -1832,7 +1832,7 @@ static void editmesh_set_connectivity_distance(BMEditMesh *em, float mtx[][3], f SmallHash svisit, *visit=&svisit; BMVert *v; BMIter viter; - int i; + int i, start; i = 0; BM_ITER(v, &viter, em->bm, BM_VERTS_OF_MESH, NULL) { @@ -1841,66 +1841,61 @@ static void editmesh_set_connectivity_distance(BMEditMesh *em, float mtx[][3], f i++; } + BLI_smallhash_init(visit); + BM_ITER(v, &viter, em->bm, BM_VERTS_OF_MESH, NULL) { - BMVert *v2; - int start; - if (BM_TestHFlag(v, BM_SELECT)==0 || BM_TestHFlag(v, BM_HIDDEN)) continue; - BLI_smallhash_init(visit); - - BLI_array_empty(queue); + + BLI_smallhash_insert(visit, (uintptr_t)v, NULL); BLI_array_append(queue, v); BLI_array_append(dqueue, 0.0f); dists[BMINDEX_GET(v)] = 0.0f; + } + + start = 0; + while (start < BLI_array_count(queue)) { + BMIter eiter; + BMEdge *e; + BMVert *v3, *v2; + float d, vec[3]; - BLI_smallhash_insert(visit, (uintptr_t)v, NULL); - start = 0; + v2 = queue[start]; + d = dqueue[start]; - while (start < BLI_array_count(queue)) { - BMIter eiter; - BMEdge *e; - BMVert *v3; - float d, d2, vec[3]; + BM_ITER(e, &eiter, em->bm, BM_EDGES_OF_VERT, v2) { + float d2; + v3 = BM_OtherEdgeVert(e, v2); - v2 = queue[start]; - d = dqueue[start]; + if (BM_TestHFlag(v3, BM_SELECT) || BM_TestHFlag(v3, BM_HIDDEN)) + continue; - BM_ITER(e, &eiter, em->bm, BM_EDGES_OF_VERT, v2) { - float d2; - v3 = BM_OtherEdgeVert(e, v2); - - if (BM_TestHFlag(v3, BM_SELECT) || BM_TestHFlag(v3, BM_HIDDEN)) - continue; - - sub_v3_v3v3(vec, v2->co, v3->co); - mul_m3_v3(mtx, vec); - - d2 = d + len_v3(vec); - - if (BLI_smallhash_haskey(visit, (uintptr_t)v3)) - continue; - - if (dists[BMINDEX_GET(v3)] != FLT_MAX) - dists[BMINDEX_GET(v3)] += d2; - else - dists[BMINDEX_GET(v3)] = d2; - - tots[BMINDEX_GET(v3)]++; - - if (!BLI_smallhash_haskey(visit, (uintptr_t)v3)) - BLI_smallhash_insert(visit, (uintptr_t)v3, NULL); - - BLI_array_append(queue, v3); - BLI_array_append(dqueue, d2); - } + sub_v3_v3v3(vec, v2->co, v3->co); + mul_m3_v3(mtx, vec); - start++; - } + d2 = d + len_v3(vec); + + if (dists[BMINDEX_GET(v3)] != FLT_MAX) + dists[BMINDEX_GET(v3)] = MIN2(d2, dists[BMINDEX_GET(v3)]); + else + dists[BMINDEX_GET(v3)] = d2; + + tots[BMINDEX_GET(v3)] = 1; - BLI_smallhash_release(visit); + if (BLI_smallhash_haskey(visit, (uintptr_t)v3)) + continue; + + BLI_smallhash_insert(visit, (uintptr_t)v3, NULL); + + BLI_array_append(queue, v3); + BLI_array_append(dqueue, d2); + } + + start++; } + + BLI_smallhash_release(visit); for (i=0; i<em->bm->totvert; i++) { if (tots[i]) |