Fix knife bug exposed by valgrind.
authorHoward Trickey <howard.trickey@gmail.com>
Wed, 6 Nov 2013 15:27:19 +0000 (15:27 +0000)
committerHoward Trickey <howard.trickey@gmail.com>
Wed, 6 Nov 2013 15:27:19 +0000 (15:27 +0000)
Was reading cage coordinate from those of existing
BMVerts even for newly created verts that don't
have cage coordinates there.

source/blender/editors/mesh/editmesh_knife.c

index f961b6aefe9a501f94a5c50adc6dbfade1eca622..32d17f6c599bec7ae6dc28be4f437eed4c542c9c 100644 (file)
@@ -348,12 +348,17 @@ static KnifeVert *new_knife_vert(KnifeTool_OpData *kcd, const float co[3], const
 static KnifeVert *get_bm_knife_vert(KnifeTool_OpData *kcd, BMVert *v)
 {
        KnifeVert *kfv = BLI_ghash_lookup(kcd->origvertmap, v);
+       const float *cageco;
 
        if (!kfv) {
                BMIter bmiter;
                BMFace *f;
 
-               kfv = new_knife_vert(kcd, v->co, kcd->cagecos[BM_elem_index_get(v)]);
+               if (BM_elem_index_get(v) >= 0)
+                       cageco = kcd->cagecos[BM_elem_index_get(v)];
+               else
+                       cageco = v->co;
+               kfv = new_knife_vert(kcd, v->co, cageco);
                kfv->v = v;
                BLI_ghash_insert(kcd->origvertmap, v, kfv);
                BM_ITER_ELEM (f, &bmiter, v, BM_FACES_OF_VERT) {