merge with/from trunk at r35190
[blender.git] / source / blender / editors / mesh / knifetool.c
index e66d8d5df2f2fe1aa6b250183ca55e785da61d50..60910497fad1813cee3d1f85264a6a5c777ec1b8 100755 (executable)
@@ -803,7 +803,7 @@ BMEdgeHit *knife_edge_tri_isect(knifetool_opdata *kcd, BMBVHTree *bmtree, float
        return edges;
 }
 
-knife_bgl_get_mats(knifetool_opdata *kcd, bglMats *mats)
+void knife_bgl_get_mats(knifetool_opdata *kcd, bglMats *mats)
 {
        bgl_get_mats(mats);
        //copy_m4_m4(mats->modelview, kcd->vc.rv3d->viewmat);
@@ -1291,6 +1291,24 @@ void knifenet_fill_faces(knifetool_opdata *kcd)
                        BMO_ClearFlag(bm, e, MARK);
        }
 
+       BM_ITER(f, &bmiter, bm, BM_FACES_OF_MESH, NULL) {
+               BMIter eiter;
+               
+               if (!BMO_TestFlag(bm, f, DEL))
+                       continue;
+               
+               BM_ITER(e, &eiter, bm, BM_EDGES_OF_FACE, f) {
+                       BMIter liter;
+                       BMLoop *l;
+                       
+                       BMO_SetFlag(bm, e, MARK);
+                       
+                       BM_ITER(l, &liter, bm, BM_LOOPS_OF_EDGE, e) {
+                               BMINDEX_SET(e, BMINDEX_GET(e)|BMINDEX_GET(l->f));
+                       }
+               }
+       }
+
        BMO_Flag_To_Slot(bm, &bmop, "edges", MARK, BM_EDGE);
        BMO_Flag_To_Slot(bm, &bmop, "excludefaces", DEL, BM_FACE);
        
@@ -1564,7 +1582,16 @@ static int knifetool_invoke (bContext *C, wmOperator *op, wmEvent *evt)
 
 static int knifetool_modal (bContext *C, wmOperator *op, wmEvent *event)
 {
+       Object *obedit;
        knifetool_opdata *kcd= op->customdata;
+       
+       if (!C) {
+               return OPERATOR_FINISHED;
+       }
+       
+       obedit = CTX_data_edit_object(C);
+       if (!obedit || obedit->type != OB_MESH || ((Mesh*)obedit->data)->edit_btmesh != kcd->em)
+               return OPERATOR_FINISHED;
 
        view3d_operator_needs_opengl(C);