From da849bbfc042a2f879031f3736974ade45348d6e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 16 Nov 2011 12:38:40 +0000 Subject: prepare for flagging the bmesh has having invalid index values, so we can skip looping over all elements if its already valid. - went over every BM_SetIndex call and added comments about its use, if its setting dirty values or correct ones. - replace loops over all elements _just_ to set index values, with a new function, BM_ElemIndex_Ensure(...), this will eventually only initialize values when they are dirty. --- source/blender/editors/util/crazyspace.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'source/blender/editors/util') diff --git a/source/blender/editors/util/crazyspace.c b/source/blender/editors/util/crazyspace.c index 8c5d7d6990b..26db6ff32ac 100644 --- a/source/blender/editors/util/crazyspace.c +++ b/source/blender/editors/util/crazyspace.c @@ -146,13 +146,8 @@ void crazyspace_set_quats_editmesh(BMEditMesh *em, float *origcos, float *mapped int *vert_table = MEM_callocN(sizeof(int)*em->bm->totvert, "vert_table"); int index = 0; - /* BMESH_TODO this should be valid now, leaving here until we can ensure this - campbell */ - BM_ITER(v, &iter, em->bm, BM_VERTS_OF_MESH, NULL) { - BM_SetIndex(v, index); - index++; - } - - index = 0; + BM_ElemIndex_Ensure(em->bm, BM_VERT); + BM_ITER(v, &iter, em->bm, BM_VERTS_OF_MESH, NULL) { if (!BM_TestHFlag(v, BM_SELECT) || BM_TestHFlag(v, BM_HIDDEN)) continue; @@ -179,17 +174,16 @@ void crazyspace_set_quats_editmesh(BMEditMesh *em, float *origcos, float *mapped } } - /* BMESH_TODO, don't overwrite invalid index info! */ - index = 0; BM_ITER(v, &iter, em->bm, BM_VERTS_OF_MESH, NULL) { if (vert_table[index] != 0) - BM_SetIndex(v, vert_table[index]-1); + BM_SetIndex(v, vert_table[index]-1); /* set_dirty! */ else - BM_SetIndex(v, -1); + BM_SetIndex(v, -1); /* set_dirty! */ index++; } + em->bm->elem_index_dirty |= BM_VERT; MEM_freeN(vert_table); #if 0 -- cgit v1.2.3