2.5
authorTon Roosendaal <ton@blender.org>
Thu, 19 Feb 2009 19:03:53 +0000 (19:03 +0000)
committerTon Roosendaal <ton@blender.org>
Thu, 19 Feb 2009 19:03:53 +0000 (19:03 +0000)
- Mesh Rip back (Vkey). For those who keep wondering how
  it works: just put mouse cursor somewhere close to the
  selection, press V and mouse mouse away from it. Feels
  like real rip!

- Made extrude sorta work, no menu/options yet though.
  But it does transform!

- Added an short event->mval[2] with region coords,
  easier coding for the guys :)

- Fill operator standard delivers 'beauty' now

source/blender/editors/include/ED_view3d.h
source/blender/editors/mesh/editmesh_add.c
source/blender/editors/mesh/editmesh_mods.c
source/blender/editors/mesh/editmesh_tools.c
source/blender/editors/mesh/mesh_intern.h
source/blender/editors/mesh/mesh_ops.c
source/blender/editors/space_view3d/view3d_intern.h
source/blender/editors/space_view3d/view3d_select.c
source/blender/editors/space_view3d/vpaint.c
source/blender/windowmanager/WM_types.h
source/blender/windowmanager/intern/wm_event_system.c

index 6434bcb606ad3b26e1c595ca3aa2447d21543d31..f26f6b7460db2eea683f0fe009b76751abd7a4b0 100644 (file)
@@ -90,6 +90,8 @@ void viewline(struct ARegion *ar, struct View3D *v3d, short mval[2], float ray_s
 void viewray(struct ARegion *ar, struct View3D *v3d, short mval[2], float ray_start[3], float ray_normal[3]);
 
 int get_view3d_viewplane(struct View3D *v3d, struct RegionView3D *rv3d, int winxi, int winyi, rctf *viewplane, float *clipsta, float *clipend, float *pixsize);
+void view3d_get_object_project_mat(struct RegionView3D *v3d, struct Object *ob, float pmat[4][4], float vmat[4][4]);
+void view3d_project_float(struct ARegion *a, float *vec, float *adr, float mat[4][4]);
 
 /* drawobject.c itterators */
 void mesh_foreachScreenVert(struct ViewContext *vc, void (*func)(void *userData, struct EditVert *eve, int x, int y, int index), void *userData, int clipVerts);
index c5c30e32cd1c05106ec8c1a025eaff1a1c6ef226..15b64a25321b784d6a2fb652e974b4f5966dd306 100644 (file)
@@ -124,13 +124,9 @@ static int dupli_extrude_cursor(bContext *C, wmOperator *op, wmEvent *event)
        EditVert *eve, *v1;
        float min[3], max[3];
        int done= 0;
-       short mval[2];
        
        em_setup_viewcontext(C, &vc);
        
-       mval[0]= event->x - vc.ar->winrct.xmin;
-       mval[1]= event->y - vc.ar->winrct.ymin;
-       
        INIT_MINMAX(min, max);
        
        for(v1= vc.em->verts.first;v1; v1=v1->next) {
@@ -164,7 +160,7 @@ static int dupli_extrude_cursor(bContext *C, wmOperator *op, wmEvent *event)
                VECCOPY(min, cent);
                
                Mat4MulVecfl(vc.obedit->obmat, min);    // view space
-               view3d_get_view_aligned_coordinate(&vc, min, mval);
+               view3d_get_view_aligned_coordinate(&vc, min, event->mval);
                Mat4Invert(vc.obedit->imat, vc.obedit->obmat); 
                Mat4MulVecfl(vc.obedit->imat, min); // back in object space
                
@@ -206,7 +202,7 @@ static int dupli_extrude_cursor(bContext *C, wmOperator *op, wmEvent *event)
                float *curs= give_cursor(vc.scene, vc.v3d);
                
                VECCOPY(min, curs);
-               view3d_get_view_aligned_coordinate(&vc, min, mval);
+               view3d_get_view_aligned_coordinate(&vc, min, event->mval);
                
                eve= addvertlist(vc.em, 0, NULL);
 
index 650f2af22b81dc79d73b27184d6fdb3c59b84b0f..f6215f5120b5ca441456b849417a6c5beba0ecff 100644 (file)
@@ -2024,15 +2024,10 @@ static void mouse_mesh_loop(bContext *C, short mval[2], short extend, short ring
 
 static int mesh_loop_select_invoke(bContext *C, wmOperator *op, wmEvent *event)
 {
-       ARegion *ar= CTX_wm_region(C);
-       short mval[2];  
-       
-       mval[0]= event->x - ar->winrct.xmin;
-       mval[1]= event->y - ar->winrct.ymin;
        
        view3d_operator_needs_opengl(C);
        
-       mouse_mesh_loop(C, mval, RNA_boolean_get(op->ptr, "extend"),
+       mouse_mesh_loop(C, event->mval, RNA_boolean_get(op->ptr, "extend"),
                                        RNA_boolean_get(op->ptr, "ring"));
        
        /* cannot do tweaks for as long this keymap is after transform map */
@@ -2130,15 +2125,10 @@ static void mouse_mesh_shortest_path(bContext *C, short mval[2])
 
 static int mesh_shortest_path_select_invoke(bContext *C, wmOperator *op, wmEvent *event)
 {
-       ARegion *ar= CTX_wm_region(C);
-       short mval[2];  
-       
-       mval[0]= event->x - ar->winrct.xmin;
-       mval[1]= event->y - ar->winrct.ymin;
        
        view3d_operator_needs_opengl(C);
 
-       mouse_mesh_shortest_path(C, mval);
+       mouse_mesh_shortest_path(C, event->mval);
        
        return OPERATOR_FINISHED;
 }
@@ -2365,8 +2355,8 @@ static int select_linked_pick_invoke(bContext *C, wmOperator *op, wmEvent *event
        
        if(vc.em->edges.first==0) return OPERATOR_CANCELLED;
        
-       vc.mval[0]= event->x - vc.ar->winrct.xmin;
-       vc.mval[1]= event->y - vc.ar->winrct.ymin;
+       vc.mval[0]= event->mval[0];
+       vc.mval[1]= event->mval[1];
        
        /* return warning! */
        if(limit) {
index 4c886c4b58f03954129aa1e7a935d352b0af182c..945015263c4c2f464a1e3ce8dda669844550ba32 100644 (file)
@@ -88,6 +88,7 @@ editmesh_tool.c: UI called tools for editmesh, geometry changes here, otherwise
 #include "ED_view3d.h"
 #include "ED_util.h"
 #include "ED_screen.h"
+#include "BIF_transform.h"
 
 #include "UI_interface.h"
 
@@ -632,26 +633,26 @@ void extrude_mesh(Object *obedit, EditMesh *em, wmOperator *op)
                else if(em->totvertsel==1) nr= 4;
                else if(em->totedgesel==0) nr= 4;
                else if(em->totfacesel==0) 
-                       nr= pupmenu("Extrude %t|Only Edges%x3|Only Vertices%x4");
+                       nr= 3; // pupmenu("Extrude %t|Only Edges%x3|Only Vertices%x4");
                else if(em->totfacesel==1)
-                       nr= pupmenu("Extrude %t|Region %x1|Only Edges%x3|Only Vertices%x4");
+                       nr= 1; // pupmenu("Extrude %t|Region %x1|Only Edges%x3|Only Vertices%x4");
                else 
-                       nr= pupmenu("Extrude %t|Region %x1||Individual Faces %x2|Only Edges%x3|Only Vertices%x4");
+                       nr= 1; // pupmenu("Extrude %t|Region %x1||Individual Faces %x2|Only Edges%x3|Only Vertices%x4");
        }
        else if(em->selectmode & SCE_SELECT_EDGE) {
                if (em->totedgesel==0) nr = 0;
                else if (em->totedgesel==1) nr = 3;
                else if(em->totfacesel==0) nr = 3;
                else if(em->totfacesel==1)
-                       nr= pupmenu("Extrude %t|Region %x1|Only Edges%x3");
+                       nr= 1; // pupmenu("Extrude %t|Region %x1|Only Edges%x3");
                else
-                       nr= pupmenu("Extrude %t|Region %x1||Individual Faces %x2|Only Edges%x3");
+                       nr= 1; // pupmenu("Extrude %t|Region %x1||Individual Faces %x2|Only Edges%x3");
        }
        else {
                if (em->totfacesel == 0) nr = 0;
                else if (em->totfacesel == 1) nr = 1;
                else
-                       nr= pupmenu("Extrude %t|Region %x1||Individual Faces %x2");
+                       nr= 1; // pupmenu("Extrude %t|Region %x1||Individual Faces %x2");
        }
                
        if(nr<1) return;
@@ -696,18 +697,35 @@ void extrude_mesh(Object *obedit, EditMesh *em, wmOperator *op)
 }
 
 // XXX should be a menu item
-static int mesh_extrude_exec(bContext *C, wmOperator *op)
+static int mesh_extrude_invoke(bContext *C, wmOperator *op, wmEvent *event)
 {
        Object *obedit= CTX_data_edit_object(C);
        EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
 
        extrude_mesh(obedit,em, op);
-               
+       
+       RNA_int_set(op->ptr, "mode", TFM_TRANSLATION);
+       WM_operator_name_call(C, "TFM_OT_transform", WM_OP_INVOKE_REGION_WIN, op->ptr);
+
+       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
+       
+       return OPERATOR_FINISHED;       
+}
+
+/* extrude without transform */
+static int mesh_extrude_exec(bContext *C, wmOperator *op)
+{
+       Object *obedit= CTX_data_edit_object(C);
+       EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
+       
+       extrude_mesh(obedit,em, op);
+       
        WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
        
        return OPERATOR_FINISHED;       
 }
 
+
 void MESH_OT_extrude(wmOperatorType *ot)
 {
        /* identifiers */
@@ -715,11 +733,15 @@ void MESH_OT_extrude(wmOperatorType *ot)
        ot->idname= "MESH_OT_extrude";
        
        /* api callbacks */
+       ot->invoke= mesh_extrude_invoke;
        ot->exec= mesh_extrude_exec;
        ot->poll= ED_operator_editmesh;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+
+       /* to give to transform */
+       RNA_def_int(ot->srna, "mode", TFM_TRANSLATION, 0, INT_MAX, "Mode", "", 0, INT_MAX);
 }
 
 static int split_mesh(bContext *C, wmOperator *op)
@@ -1258,87 +1280,6 @@ void MESH_OT_delete(wmOperatorType *ot)
        RNA_def_enum(ot->srna, "type", prop_mesh_delete_types, 10, "Type", "Method used for deleting mesh data");
 }
 
-/* Got this from scanfill.c. You will need to juggle around the
- * callbacks for the scanfill.c code a bit for this to work. */
-void fill_mesh(EditMesh *em)
-{
-       EditVert *eve,*v1;
-       EditEdge *eed,*e1,*nexted;
-       EditFace *efa,*nextvl, *efan;
-       short ok;
-
-       if(em==NULL) return;
-       waitcursor(1);
-
-       /* copy all selected vertices */
-       eve= em->verts.first;
-       while(eve) {
-               if(eve->f & SELECT) {
-                       v1= BLI_addfillvert(eve->co);
-                       eve->tmp.v= v1;
-                       v1->tmp.v= eve;
-                       v1->xs= 0;      // used for counting edges
-               }
-               eve= eve->next;
-       }
-       /* copy all selected edges */
-       eed= em->edges.first;
-       while(eed) {
-               if( (eed->v1->f & SELECT) && (eed->v2->f & SELECT) ) {
-                       e1= BLI_addfilledge(eed->v1->tmp.v, eed->v2->tmp.v);
-                       e1->v1->xs++; 
-                       e1->v2->xs++;
-               }
-               eed= eed->next;
-       }
-       /* from all selected faces: remove vertices and edges to prevent doubles */
-       /* all edges add values, faces subtract,
-          then remove edges with vertices ->xs<2 */
-       efa= em->faces.first;
-       ok= 0;
-       while(efa) {
-               nextvl= efa->next;
-               if( faceselectedAND(efa, 1) ) {
-                       efa->v1->tmp.v->xs--;
-                       efa->v2->tmp.v->xs--;
-                       efa->v3->tmp.v->xs--;
-                       if(efa->v4) efa->v4->tmp.v->xs--;
-                       ok= 1;
-                       
-               }
-               efa= nextvl;
-       }
-       if(ok) {        /* there are faces selected */
-               eed= filledgebase.first;
-               while(eed) {
-                       nexted= eed->next;
-                       if(eed->v1->xs<2 || eed->v2->xs<2) {
-                               BLI_remlink(&filledgebase,eed);
-                       }
-                       eed= nexted;
-               }
-       }
-
-       if(BLI_edgefill(0, em->mat_nr)) {
-               efa= fillfacebase.first;
-               while(efa) {
-                       /* normals default pointing up */
-                       efan= addfacelist(em, efa->v3->tmp.v, efa->v2->tmp.v, 
-                                                         efa->v1->tmp.v, 0, NULL, NULL);
-                       if(efan) EM_select_face(efan, 1);
-                       efa= efa->next;
-               }
-       }
-
-       BLI_end_edgefill();
-
-       // XXX option beautyfill */
-
-       WM_cursor_wait(0);
-       EM_select_flush(em);
-//     DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
-
-}
 
 /*GB*/
 /*-------------------------------------------------------------------------------*/
@@ -3104,172 +3045,6 @@ static void free_tagged_edges_faces(EditMesh *em, EditEdge *eed, EditFace *efa)
        }       
 }      
 
-/* note; the EM_selectmode_set() calls here illustrate how badly constructed it all is... from before the
-   edge/face flags, with very mixed results.... */
-void beauty_fill(EditMesh *em)
-{
-       EditVert *v1, *v2, *v3, *v4;
-       EditEdge *eed, *nexted;
-       EditEdge dia1, dia2;
-       EditFace *efa, *w;
-       // void **efaar, **efaa;
-       EVPTuple *efaar;
-       EVPtr *efaa;
-       float len1, len2, len3, len4, len5, len6, opp1, opp2, fac1, fac2;
-       int totedge, ok, notbeauty=8, onedone, vindex[4];
-       
-       /* - all selected edges with two faces
-               * - find the faces: store them in edges (using datablock)
-               * - per edge: - test convex
-               *                          - test edge: flip?
-               *                          - if true: remedge,  addedge, all edges at the edge get new face pointers
-               */
-       
-       EM_selectmode_set(em);  // makes sure in selectmode 'face' the edges of selected faces are selected too 
-
-       totedge = count_selected_edges(em->edges.first);
-       if(totedge==0) return;
-
-       /* temp block with face pointers */
-       efaar= (EVPTuple *) MEM_callocN(totedge * sizeof(EVPTuple), "beautyfill");
-
-       while (notbeauty) {
-               notbeauty--;
-
-               ok = collect_quadedges(efaar, em->edges.first, em->faces.first);
-
-               /* there we go */
-               onedone= 0;
-
-               eed= em->edges.first;
-               while(eed) {
-                       nexted= eed->next;
-                       
-                       /* f2 is set in collect_quadedges() */
-                       if(eed->f2==2 && eed->h==0) {
-
-                               efaa = (EVPtr *) eed->tmp.p;
-
-                               /* none of the faces should be treated before, nor be part of fgon */
-                               ok= 1;
-                               efa= efaa[0];
-                               if(efa->e1->f1 || efa->e2->f1 || efa->e3->f1) ok= 0;
-                               if(efa->fgonf) ok= 0;
-                               efa= efaa[1];
-                               if(efa->e1->f1 || efa->e2->f1 || efa->e3->f1) ok= 0;
-                               if(efa->fgonf) ok= 0;
-                               
-                               if(ok) {
-                                       /* test convex */
-                                       givequadverts(efaa[0], efaa[1], &v1, &v2, &v3, &v4, vindex);
-                                       if(v1 && v2 && v3 && v4) {
-                                               if( convex(v1->co, v2->co, v3->co, v4->co) ) {
-
-                                                       /* test edges */
-                                                       if( (v1) > (v3) ) {
-                                                               dia1.v1= v3;
-                                                               dia1.v2= v1;
-                                                       }
-                                                       else {
-                                                               dia1.v1= v1;
-                                                               dia1.v2= v3;
-                                                       }
-
-                                                       if( (v2) > (v4) ) {
-                                                               dia2.v1= v4;
-                                                               dia2.v2= v2;
-                                                       }
-                                                       else {
-                                                               dia2.v1= v2;
-                                                               dia2.v2= v4;
-                                                       }
-
-                                                       /* testing rule:
-                                                        * the area divided by the total edge lengths
-                                                        */
-
-                                                       len1= VecLenf(v1->co, v2->co);
-                                                       len2= VecLenf(v2->co, v3->co);
-                                                       len3= VecLenf(v3->co, v4->co);
-                                                       len4= VecLenf(v4->co, v1->co);
-                                                       len5= VecLenf(v1->co, v3->co);
-                                                       len6= VecLenf(v2->co, v4->co);
-
-                                                       opp1= AreaT3Dfl(v1->co, v2->co, v3->co);
-                                                       opp2= AreaT3Dfl(v1->co, v3->co, v4->co);
-
-                                                       fac1= opp1/(len1+len2+len5) + opp2/(len3+len4+len5);
-
-                                                       opp1= AreaT3Dfl(v2->co, v3->co, v4->co);
-                                                       opp2= AreaT3Dfl(v2->co, v4->co, v1->co);
-
-                                                       fac2= opp1/(len2+len3+len6) + opp2/(len4+len1+len6);
-
-                                                       ok= 0;
-                                                       if(fac1 > fac2) {
-                                                               if(dia2.v1==eed->v1 && dia2.v2==eed->v2) {
-                                                                       eed->f1= 1;
-                                                                       efa= efaa[0];
-                                                                       efa->f1= 1;
-                                                                       efa= efaa[1];
-                                                                       efa->f1= 1;
-
-                                                                       w= EM_face_from_faces(em, efaa[0], efaa[1],
-                                                                               vindex[0], vindex[1], 4+vindex[2], -1);
-                                                                       w->f |= SELECT;
-
-
-                                                                       w= EM_face_from_faces(em, efaa[0], efaa[1],
-                                                                               vindex[0], 4+vindex[2], 4+vindex[3], -1);
-                                                                       w->f |= SELECT;
-
-                                                                       onedone= 1;
-                                                               }
-                                                       }
-                                                       else if(fac1 < fac2) {
-                                                               if(dia1.v1==eed->v1 && dia1.v2==eed->v2) {
-                                                                       eed->f1= 1;
-                                                                       efa= efaa[0];
-                                                                       efa->f1= 1;
-                                                                       efa= efaa[1];
-                                                                       efa->f1= 1;
-
-
-                                                                       w= EM_face_from_faces(em, efaa[0], efaa[1],
-                                                                               vindex[1], 4+vindex[2], 4+vindex[3], -1);
-                                                                       w->f |= SELECT;
-
-
-                                                                       w= EM_face_from_faces(em, efaa[0], efaa[1],
-                                                                               vindex[0], 4+vindex[1], 4+vindex[3], -1);
-                                                                       w->f |= SELECT;
-
-                                                                       onedone= 1;
-                                                               }
-                                                       }
-                                               }
-                                       }
-                               }
-
-                       }
-                       eed= nexted;
-               }
-
-               free_tagged_edges_faces(em, em->edges.first, em->faces.first);
-
-               if(onedone==0) break;
-               
-               EM_selectmode_set(em);  // new edges/faces were added
-       }
-
-       MEM_freeN(efaar);
-
-       EM_select_flush(em);
-       
-//     DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
-
-}
-
 
 /* ******************** BEGIN TRIANGLE TO QUAD ************************************* */
 static float measure_facepair(EditVert *v1, EditVert *v2, EditVert *v3, EditVert *v4, float limit)
@@ -4923,13 +4698,15 @@ void mesh_set_smooth_faces(EditMesh *em, short event)
        
 }
 
+/* ********************** mesh rip ********************** */
+
 /* helper to find edge for edge_rip */
-static float mesh_rip_edgedist(float mat[][4], float *co1, float *co2, short *mval)
+static float mesh_rip_edgedist(ARegion *ar, float mat[][4], float *co1, float *co2, short *mval)
 {
        float vec1[3], vec2[3], mvalf[2];
        
-// XXX view3d_project_float(curarea, co1, vec1, mat);
-//     view3d_project_float(curarea, co2, vec2, mat);
+       view3d_project_float(ar, co1, vec1, mat);
+       view3d_project_float(ar, co2, vec2, mat);
        mvalf[0]= (float)mval[0];
        mvalf[1]= (float)mval[1];
        
@@ -4957,14 +4734,18 @@ static void mesh_rip_setface(EditMesh *em, EditFace *sefa)
 }
 
 /* based on mouse cursor position, it defines how is being ripped */
-void mesh_rip(EditMesh *em, wmOperator *op)
+static int mesh_rip_invoke(bContext *C, wmOperator *op, wmEvent *event)
 {
-       extern void faceloop_select(EditEdge *startedge, int select);
+       ARegion *ar= CTX_wm_region(C);
+       RegionView3D *rv3d= ar->regiondata;
+       Object *obedit= CTX_data_edit_object(C);
+       EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
        EditVert *eve, *nextve;
        EditEdge *eed, *seed= NULL;
        EditFace *efa, *sefa= NULL;
-       float projectMat[4][4], vec[3], dist, mindist; // viewMat[4][4],  XXX
-       short doit= 1, mval[2]; // XXX ,propmode,prop;
+       float projectMat[4][4], vec[3], dist, mindist, viewMat[4][4];
+       short doit= 1, *mval= event->mval; // XXX ,propmode,prop;
+       
        
 // XXX propmode = scene->prop_mode;
 //     scene->prop_mode = 0;
@@ -4974,8 +4755,7 @@ void mesh_rip(EditMesh *em, wmOperator *op)
        /* select flush... vertices are important */
        EM_selectmode_set(em);
        
-// XXX getmouseco_areawin(mval);
-//     view3d_get_object_project_mat(curarea, obedit, projectMat, viewMat);
+       view3d_get_object_project_mat(rv3d, obedit, projectMat, viewMat);
 
        /* find best face, exclude triangles and break on face select or faces with 2 edges select */
        mindist= 1000000.0f;
@@ -4992,7 +4772,7 @@ void mesh_rip(EditMesh *em, wmOperator *op)
                        
                        if(totsel>1)
                                break;
-//                     view3d_project_float(curarea, efa->cent, vec, projectMat);
+                       view3d_project_float(ar, efa->cent, vec, projectMat);
                        dist= sqrt( (vec[0]-mval[0])*(vec[0]-mval[0]) + (vec[1]-mval[1])*(vec[1]-mval[1]) );
                        if(dist<mindist) {
                                mindist= dist;
@@ -5003,11 +4783,11 @@ void mesh_rip(EditMesh *em, wmOperator *op)
        
        if(efa) {
                BKE_report(op->reports, RPT_ERROR, "Can't perform ripping with faces selected this way");
-               return;
+               return OPERATOR_CANCELLED;
        }
        if(sefa==NULL) {
                BKE_report(op->reports, RPT_ERROR, "No proper selection or faces included");
-               return;
+               return OPERATOR_CANCELLED;
        }
        
 
@@ -5032,7 +4812,7 @@ void mesh_rip(EditMesh *em, wmOperator *op)
        if(seed==NULL) {
                mindist= 1000000.0f;
                if(sefa->e1->v1->tmp.v || sefa->e1->v2->tmp.v) {
-                       dist = mesh_rip_edgedist(projectMat, 
+                       dist = mesh_rip_edgedist(ar, projectMat, 
                                                                         sefa->e1->v1->co, 
                                                                         sefa->e1->v2->co, mval);
                        if(dist<mindist) {
@@ -5041,7 +4821,7 @@ void mesh_rip(EditMesh *em, wmOperator *op)
                        }
                }
                if(sefa->e2->v1->tmp.v || sefa->e2->v2->tmp.v) {
-                       dist = mesh_rip_edgedist(projectMat,
+                       dist = mesh_rip_edgedist(ar, projectMat,
                                                                         sefa->e2->v1->co, 
                                                                         sefa->e2->v2->co, mval);
                        if(dist<mindist) {
@@ -5050,7 +4830,7 @@ void mesh_rip(EditMesh *em, wmOperator *op)
                        }
                }
                if(sefa->e3->v1->tmp.v || sefa->e3->v2->tmp.v) {
-                       dist= mesh_rip_edgedist(projectMat, 
+                       dist= mesh_rip_edgedist(ar, projectMat, 
                                                                        sefa->e3->v1->co, 
                                                                        sefa->e3->v2->co, mval);
                        if(dist<mindist) {
@@ -5059,7 +4839,7 @@ void mesh_rip(EditMesh *em, wmOperator *op)
                        }
                }
                if(sefa->e4 && (sefa->e4->v1->tmp.v || sefa->e4->v2->tmp.v)) {
-                       dist= mesh_rip_edgedist(projectMat, 
+                       dist= mesh_rip_edgedist(ar, projectMat, 
                                                                        sefa->e4->v1->co, 
                                                                        sefa->e4->v2->co, mval);
                        if(dist<mindist) {
@@ -5071,10 +4851,10 @@ void mesh_rip(EditMesh *em, wmOperator *op)
        
        if(seed==NULL) {        // never happens?
                BKE_report(op->reports, RPT_ERROR, "No proper edge found to start");
-               return;
+               return OPERATOR_CANCELLED;
        }
        
-       faceloop_select(seed, 2);       // tmp abuse for finding all edges that need duplicated, returns OK faces with f1
+       faceloop_select(em, seed, 2);   // tmp abuse for finding all edges that need duplicated, returns OK faces with f1
 
        /* duplicate edges in the loop, with at least 1 vertex selected, needed for selection flip */
        for(eed = em->edges.last; eed; eed= eed->prev) {
@@ -5085,8 +4865,9 @@ void mesh_rip(EditMesh *em, wmOperator *op)
                        newed= addedgelist(em, eed->v1->tmp.v?eed->v1->tmp.v:eed->v1, 
                                                           eed->v2->tmp.v?eed->v2->tmp.v:eed->v2, eed);
                        if(eed->f & SELECT) {
-                               eed->f &= ~SELECT;
-                               newed->f |= SELECT;
+                               EM_select_edge(eed, 0);
+                               EM_remove_selection(em, eed, EDITEDGE);
+                               EM_select_edge(newed, 1);
                        }
                        eed->tmp.v = (EditVert *)newed;
                }
@@ -5153,14 +4934,35 @@ void mesh_rip(EditMesh *em, wmOperator *op)
                }
        }
        
-//     BIF_TransformSetUndo("Rip");
-//     initTransform(TFM_TRANSLATION, 0);
-//     Transform();
-       
+       RNA_int_set(op->ptr, "mode", TFM_TRANSLATION);
+       WM_operator_name_call(C, "TFM_OT_transform", WM_OP_INVOKE_REGION_WIN, op->ptr);
+
 //     scene->prop_mode = propmode;
 // XXX scene->proportional = prop;
+
+       return OPERATOR_FINISHED;
 }
 
+void MESH_OT_rip(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Rip";
+       ot->idname= "MESH_OT_rip";
+       
+       /* api callbacks */
+       ot->invoke= mesh_rip_invoke;
+       ot->poll= ED_operator_editmesh; // XXX + v3d!
+       
+       /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+       
+       /* to give to transform */
+       RNA_def_int(ot->srna, "mode", TFM_TRANSLATION, 0, INT_MAX, "Mode", "", 0, INT_MAX);
+}
+
+
+/* ************************************** */
+
 void shape_propagate(Scene *scene, Object *obedit, EditMesh *em, wmOperator *op)
 {
        EditVert *ev = NULL;
@@ -6077,7 +5879,6 @@ static int region_to_loop(bContext *C, wmOperator *op)
 {
        Object *obedit= CTX_data_edit_object(C);
        EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
-
        EditEdge *eed;
        EditFace *efa;
        
@@ -6812,12 +6613,260 @@ void MESH_OT_subdivs(wmOperatorType *ot)
                
 }
 
+/* ************************************* */
+
+/* note; the EM_selectmode_set() calls here illustrate how badly constructed it all is... from before the
+edge/face flags, with very mixed results.... */
+static void beauty_fill(EditMesh *em)
+{
+       EditVert *v1, *v2, *v3, *v4;
+       EditEdge *eed, *nexted;
+       EditEdge dia1, dia2;
+       EditFace *efa, *w;
+       // void **efaar, **efaa;
+       EVPTuple *efaar;
+       EVPtr *efaa;
+       float len1, len2, len3, len4, len5, len6, opp1, opp2, fac1, fac2;
+       int totedge, ok, notbeauty=8, onedone, vindex[4];
+       
+       /* - all selected edges with two faces
+               * - find the faces: store them in edges (using datablock)
+               * - per edge: - test convex
+               *                          - test edge: flip?
+               *                          - if true: remedge,  addedge, all edges at the edge get new face pointers
+               */
+       
+       EM_selectmode_set(em);  // makes sure in selectmode 'face' the edges of selected faces are selected too 
+       
+       totedge = count_selected_edges(em->edges.first);
+       if(totedge==0) return;
+       
+       /* temp block with face pointers */
+       efaar= (EVPTuple *) MEM_callocN(totedge * sizeof(EVPTuple), "beautyfill");
+       
+       while (notbeauty) {
+               notbeauty--;
+               
+               ok = collect_quadedges(efaar, em->edges.first, em->faces.first);
+               
+               /* there we go */
+               onedone= 0;
+               
+               eed= em->edges.first;
+               while(eed) {
+                       nexted= eed->next;
+                       
+                       /* f2 is set in collect_quadedges() */
+                       if(eed->f2==2 && eed->h==0) {
+                               
+                               efaa = (EVPtr *) eed->tmp.p;
+                               
+                               /* none of the faces should be treated before, nor be part of fgon */
+                               ok= 1;
+                               efa= efaa[0];
+                               if(efa->e1->f1 || efa->e2->f1 || efa->e3->f1) ok= 0;
+                               if(efa->fgonf) ok= 0;
+                               efa= efaa[1];
+                               if(efa->e1->f1 || efa->e2->f1 || efa->e3->f1) ok= 0;
+                               if(efa->fgonf) ok= 0;
+                               
+                               if(ok) {
+                                       /* test convex */
+                                       givequadverts(efaa[0], efaa[1], &v1, &v2, &v3, &v4, vindex);
+                                       if(v1 && v2 && v3 && v4) {
+                                               if( convex(v1->co, v2->co, v3->co, v4->co) ) {
+                                                       
+                                                       /* test edges */
+                                                       if( (v1) > (v3) ) {
+                                                               dia1.v1= v3;
+                                                               dia1.v2= v1;
+                                                       }
+                                                       else {
+                                                               dia1.v1= v1;
+                                                               dia1.v2= v3;
+                                                       }
+                                                       
+                                                       if( (v2) > (v4) ) {
+                                                               dia2.v1= v4;
+                                                               dia2.v2= v2;
+                                                       }
+                                                       else {
+                                                               dia2.v1= v2;
+                                                               dia2.v2= v4;
+                                                       }
+                                                       
+                                                       /* testing rule:
+                                                       * the area divided by the total edge lengths
+                                                       */
+                                                       
+                                                       len1= VecLenf(v1->co, v2->co);
+                                                       len2= VecLenf(v2->co, v3->co);
+                                                       len3= VecLenf(v3->co, v4->co);
+                                                       len4= VecLenf(v4->co, v1->co);
+                                                       len5= VecLenf(v1->co, v3->co);
+                                                       len6= VecLenf(v2->co, v4->co);
+                                                       
+                                                       opp1= AreaT3Dfl(v1->co, v2->co, v3->co);
+                                                       opp2= AreaT3Dfl(v1->co, v3->co, v4->co);
+                                                       
+                                                       fac1= opp1/(len1+len2+len5) + opp2/(len3+len4+len5);
+                                                       
+                                                       opp1= AreaT3Dfl(v2->co, v3->co, v4->co);
+                                                       opp2= AreaT3Dfl(v2->co, v4->co, v1->co);
+                                                       
+                                                       fac2= opp1/(len2+len3+len6) + opp2/(len4+len1+len6);
+                                                       
+                                                       ok= 0;
+                                                       if(fac1 > fac2) {
+                                                               if(dia2.v1==eed->v1 && dia2.v2==eed->v2) {
+                                                                       eed->f1= 1;
+                                                                       efa= efaa[0];
+                                                                       efa->f1= 1;
+                                                                       efa= efaa[1];
+                                                                       efa->f1= 1;
+                                                                       
+                                                                       w= EM_face_from_faces(em, efaa[0], efaa[1],
+                                                                                                                 vindex[0], vindex[1], 4+vindex[2], -1);
+                                                                       w->f |= SELECT;
+                                                                       
+                                                                       
+                                                                       w= EM_face_from_faces(em, efaa[0], efaa[1],
+                                                                                                                 vindex[0], 4+vindex[2], 4+vindex[3], -1);
+                                                                       w->f |= SELECT;
+                                                                       
+                                                                       onedone= 1;
+                                                               }
+                                                       }
+                                                       else if(fac1 < fac2) {
+                                                               if(dia1.v1==eed->v1 && dia1.v2==eed->v2) {
+                                                                       eed->f1= 1;
+                                                                       efa= efaa[0];
+                                                                       efa->f1= 1;
+                                                                       efa= efaa[1];
+                                                                       efa->f1= 1;
+                                                                       
+                                                                       
+                                                                       w= EM_face_from_faces(em, efaa[0], efaa[1],
+                                                                                                                 vindex[1], 4+vindex[2], 4+vindex[3], -1);
+                                                                       w->f |= SELECT;
+                                                                       
+                                                                       
+                                                                       w= EM_face_from_faces(em, efaa[0], efaa[1],
+                                                                                                                 vindex[0], 4+vindex[1], 4+vindex[3], -1);
+                                                                       w->f |= SELECT;
+                                                                       
+                                                                       onedone= 1;
+                                                               }
+                                                       }
+                                               }
+                                       }
+                               }
+                               
+                       }
+                       eed= nexted;
+               }
+               
+               free_tagged_edges_faces(em, em->edges.first, em->faces.first);
+               
+               if(onedone==0) break;
+               
+               EM_selectmode_set(em);  // new edges/faces were added
+       }
+       
+       MEM_freeN(efaar);
+       
+       EM_select_flush(em);
+       
+}
+
+/* Got this from scanfill.c. You will need to juggle around the
+* callbacks for the scanfill.c code a bit for this to work. */
+static void fill_mesh(EditMesh *em)
+{
+       EditVert *eve,*v1;
+       EditEdge *eed,*e1,*nexted;
+       EditFace *efa,*nextvl, *efan;
+       short ok;
+       
+       if(em==NULL) return;
+       waitcursor(1);
+       
+       /* copy all selected vertices */
+       eve= em->verts.first;
+       while(eve) {
+               if(eve->f & SELECT) {
+                       v1= BLI_addfillvert(eve->co);
+                       eve->tmp.v= v1;
+                       v1->tmp.v= eve;
+                       v1->xs= 0;      // used for counting edges
+               }
+               eve= eve->next;
+       }
+       /* copy all selected edges */
+       eed= em->edges.first;
+       while(eed) {
+               if( (eed->v1->f & SELECT) && (eed->v2->f & SELECT) ) {
+                       e1= BLI_addfilledge(eed->v1->tmp.v, eed->v2->tmp.v);
+                       e1->v1->xs++; 
+                       e1->v2->xs++;
+               }
+               eed= eed->next;
+       }
+       /* from all selected faces: remove vertices and edges to prevent doubles */
+       /* all edges add values, faces subtract,
+               then remove edges with vertices ->xs<2 */
+       efa= em->faces.first;
+       ok= 0;
+       while(efa) {
+               nextvl= efa->next;
+               if( faceselectedAND(efa, 1) ) {
+                       efa->v1->tmp.v->xs--;
+                       efa->v2->tmp.v->xs--;
+                       efa->v3->tmp.v->xs--;
+                       if(efa->v4) efa->v4->tmp.v->xs--;
+                       ok= 1;
+                       
+               }
+               efa= nextvl;
+       }
+       if(ok) {        /* there are faces selected */
+               eed= filledgebase.first;
+               while(eed) {
+                       nexted= eed->next;
+                       if(eed->v1->xs<2 || eed->v2->xs<2) {
+                               BLI_remlink(&filledgebase,eed);
+                       }
+                       eed= nexted;
+               }
+       }
+
+       if(BLI_edgefill(0, em->mat_nr)) {
+               efa= fillfacebase.first;
+               while(efa) {
+                       /* normals default pointing up */
+                       efan= addfacelist(em, efa->v3->tmp.v, efa->v2->tmp.v, 
+                                                         efa->v1->tmp.v, 0, NULL, NULL);
+                       if(efan) EM_select_face(efan, 1);
+                       efa= efa->next;
+               }
+       }
+
+       BLI_end_edgefill();
+       beauty_fill(em);
+
+       WM_cursor_wait(0);
+       EM_select_flush(em);
+
+}
+
+
 static int fill_mesh_exec(bContext *C, wmOperator *op)
 {
        Object *obedit= CTX_data_edit_object(C);
        EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
        
        fill_mesh(em);
+       DAG_object_flush_update(CTX_data_scene(C), obedit, OB_RECALC_DATA);
        
        WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
        
@@ -6844,7 +6893,7 @@ static int beauty_fill_exec(bContext *C, wmOperator *op)
        Object *obedit= CTX_data_edit_object(C);
        EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
        
-        beauty_fill(em);
+       beauty_fill(em);
        
        WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
        
index 43ab0927ae67b1687bb7d85c982e311a56889c44..e89db4fabca421e338f7a0c131c58ddbfbb29a0d 100644 (file)
@@ -176,6 +176,7 @@ void editmesh_select_by_material(EditMesh *em, int index);
 void righthandfaces(EditMesh *em, int select); /* makes faces righthand turning */
 void EM_select_more(EditMesh *em);
 void selectconnected_mesh_all(EditMesh *em);
+void faceloop_select(EditMesh *em, EditEdge *startedge, int select);
 
 /**
  * findnearestvert
@@ -230,6 +231,7 @@ void MESH_OT_rotate_colors(struct wmOperatorType *ot);
 void MESH_OT_mirror_colors(struct wmOperatorType *ot);
 
 void MESH_OT_delete(struct wmOperatorType *ot);
+void MESH_OT_rip(struct wmOperatorType *ot);
 
 #endif // MESH_INTERN_H
 
index e82d6c432278bb0c06734952a9dd438e149f9fa0..bf69369b4603d2746357a856d1f3c62d2fb6d478 100644 (file)
@@ -179,6 +179,7 @@ void ED_operatortypes_mesh(void)
        WM_operatortype_append(MESH_OT_smooth_vertex);
        WM_operatortype_append(MESH_OT_flip_editnormals);
        WM_operatortype_append(MESH_OT_knife_cut);
+       WM_operatortype_append(MESH_OT_rip);
        
 }
 
@@ -223,17 +224,12 @@ void ED_keymap_mesh(wmWindowManager *wm)
        WM_keymap_add_item(keymap, "MESH_OT_mark_sharp", TWOKEY, KM_PRESS, KM_CTRL , 0);
        RNA_boolean_set(WM_keymap_add_item(keymap, "MESH_OT_mark_sharp", TWOKEY, KM_PRESS, KM_ALT , 0)->ptr,"set",1);
 
-       WM_keymap_add_item(keymap, "MESH_OT_smooth_vertex", THREEKEY, KM_PRESS, KM_CTRL , 0);
-
-       WM_keymap_add_item(keymap, "MESH_OT_flip_editnormals", THREEKEY, KM_PRESS, KM_ALT , 0);
-
        /* temp hotkeys! */
        WM_keymap_add_item(keymap, "MESH_OT_similar_vertex_select", GKEY, KM_PRESS, KM_SHIFT, 0);
        WM_keymap_add_item(keymap, "MESH_OT_similar_edge_select", GKEY, KM_PRESS, KM_SHIFT2|KM_CTRL, 0);
        WM_keymap_add_item(keymap, "MESH_OT_similar_face_select", GKEY, KM_PRESS, KM_SHIFT|KM_CTRL2, 0);
        
        /* selection mode */
-       
        WM_keymap_add_item(keymap, "MESH_OT_selection_type", TABKEY, KM_PRESS, KM_CTRL, 0);
        
        /* hide */
@@ -244,6 +240,8 @@ void ED_keymap_mesh(wmWindowManager *wm)
        /* tools */
        WM_keymap_add_item(keymap, "MESH_OT_consistant_normals", NKEY, KM_PRESS, KM_CTRL, 0);
        RNA_boolean_set(WM_keymap_add_item(keymap, "MESH_OT_consistant_normals", NKEY, KM_PRESS, KM_SHIFT|KM_CTRL, 0)->ptr, "inside", 1);
+       WM_keymap_add_item(keymap, "MESH_OT_smooth_vertex", THREEKEY, KM_PRESS, KM_CTRL , 0);
+       WM_keymap_add_item(keymap, "MESH_OT_flip_editnormals", THREEKEY, KM_PRESS, KM_ALT , 0);
        
        WM_keymap_add_item(keymap, "MESH_OT_subdivs", WKEY, KM_PRESS, 0, 0); // this is the menu
        /*WM_keymap_add_item(keymap, "MESH_OT_subdivide_multi", WKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0);
@@ -273,9 +271,8 @@ void ED_keymap_mesh(wmWindowManager *wm)
        WM_keymap_add_item(keymap, "MESH_OT_rotate_colors",EIGHTKEY, KM_PRESS, KM_CTRL, 0);
        WM_keymap_add_item(keymap, "MESH_OT_mirror_colors",EIGHTKEY, KM_PRESS, KM_ALT, 0);
 
-       
-       
-       
+       WM_keymap_add_item(keymap, "MESH_OT_rip",VKEY, KM_PRESS, 0, 0);
+
        /* add/remove */
        WM_keymap_add_item(keymap, "MESH_OT_add_edge_face", FKEY, KM_PRESS, 0, 0);
        WM_keymap_add_item(keymap, "MESH_OT_add_duplicate", DKEY, KM_PRESS, KM_SHIFT, 0);
index 5322f18c02dd0930b4280fb99cded6990cf3b120..bf393a966c9c7e4e8c082af808c08a78c5815fc5 100644 (file)
@@ -129,8 +129,6 @@ int boundbox_clip(RegionView3D *rv3d, float obmat[][4], struct BoundBox *bb);
 
 void view3d_project_short_clip(struct ARegion *ar, float *vec, short *adr, float projmat[4][4], float wmat[4][4]);
 void view3d_project_short_noclip(struct ARegion *ar, float *vec, short *adr, float mat[4][4]);
-void view3d_project_float(struct ARegion *a, float *vec, float *adr, float mat[4][4]);
-void view3d_get_object_project_mat(RegionView3D *v3d, struct Object *ob, float pmat[4][4], float vmat[4][4]);
 
 void centerview(struct ARegion *ar, View3D *v3d);
 
index 967fbfd26afcb414e476dfdc06a9a7a45eceadba..0348907820dc31d9dcb9ee7afe8a52ee9efaf860 100644 (file)
@@ -1544,29 +1544,24 @@ void VIEW3D_OT_borderselect(wmOperatorType *ot)
 
 static int view3d_select_invoke(bContext *C, wmOperator *op, wmEvent *event)
 {
-       ARegion *ar= CTX_wm_region(C);
        Object *obedit= CTX_data_edit_object(C);
        short extend= RNA_enum_is_equal(op->ptr, "type", "EXTEND");
-       short mval[2];  
-       
-       mval[0]= event->x - ar->winrct.xmin;
-       mval[1]= event->y - ar->winrct.ymin;
 
        view3d_operator_needs_opengl(C);
        
        if(obedit) {
                if(obedit->type==OB_MESH)
-                       mouse_mesh(C, mval, extend);
+                       mouse_mesh(C, event->mval, extend);
                else if(obedit->type==OB_ARMATURE)
-                       mouse_armature(C, mval, extend);
+                       mouse_armature(C, event->mval, extend);
                else if(obedit->type==OB_LATTICE)
-                       mouse_lattice(C, mval, extend);
+                       mouse_lattice(C, event->mval, extend);
                else if(ELEM(obedit->type, OB_CURVE, OB_SURF))
-                       mouse_nurb(C, mval, extend);
+                       mouse_nurb(C, event->mval, extend);
                        
        }
        else 
-               mouse_select(C, mval, extend, 0);
+               mouse_select(C, event->mval, extend, 0);
 
        /* allowing tweaks */
        return OPERATOR_PASS_THROUGH|OPERATOR_FINISHED;
index c0c3752d03a11226f302e1583334b0376de61101..1136518d4244c870c6ed00a5c012c11d4ca70ff9 100644 (file)
@@ -596,9 +596,6 @@ void sample_vpaint(Scene *scene, ARegion *ar)       /* frontbuf */
        if(x<0 || y<0) return;
        if(x>=ar->winx || y>=ar->winy) return;
        
-       x+= ar->winrct.xmin;
-       y+= ar->winrct.ymin;
-       
        glReadBuffer(GL_FRONT);
        glReadPixels(x, y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &col);
        glReadBuffer(GL_BACK);
@@ -1394,7 +1391,6 @@ static int wpaint_modal(bContext *C, wmOperator *op, wmEvent *event)
                        float paintweight= wp->weight;
                        int *indexar= wpd->indexar;
                        int totindex, index, alpha, totw;
-                       short mval[2];
                        
                        view3d_operator_needs_opengl(C);
                        
@@ -1405,15 +1401,12 @@ static int wpaint_modal(bContext *C, wmOperator *op, wmEvent *event)
                        
                        MTC_Mat4SwapMat4(wpd->vc.rv3d->persmat, mat);
                        
-                       mval[0]= event->x - vc->ar->winrct.xmin;
-                       mval[1]= event->y - vc->ar->winrct.ymin;
-                       
                        /* which faces are involved */
                        if(wp->flag & VP_AREA) {
-                               totindex= sample_backbuf_area(vc, indexar, me->totface, mval[0], mval[1], wp->size);
+                               totindex= sample_backbuf_area(vc, indexar, me->totface, event->mval[0], event->mval[1], wp->size);
                        }
                        else {
-                               indexar[0]= view3d_sample_backbuf(vc, mval[0], mval[1]);
+                               indexar[0]= view3d_sample_backbuf(vc, event->mval[0], event->mval[1]);
                                if(indexar[0]) totindex= 1;
                                else totindex= 0;
                        }
@@ -1488,7 +1481,7 @@ static int wpaint_modal(bContext *C, wmOperator *op, wmEvent *event)
                                        MFace *mface= me->mface + (indexar[index]-1);
                                        
                                        if((me->dvert+mface->v1)->flag) {
-                                               alpha= calc_vp_alpha_dl(wp, vc, wpd->wpimat, wpd->vertexcosnos+6*mface->v1, mval);
+                                               alpha= calc_vp_alpha_dl(wp, vc, wpd->wpimat, wpd->vertexcosnos+6*mface->v1, event->mval);
                                                if(alpha) {
                                                        do_weight_paint_vertex(wp, ob, mface->v1, alpha, paintweight, wpd->vgroup_mirror);
                                                }
@@ -1496,7 +1489,7 @@ static int wpaint_modal(bContext *C, wmOperator *op, wmEvent *event)
                                        }
                                        
                                        if((me->dvert+mface->v2)->flag) {
-                                               alpha= calc_vp_alpha_dl(wp, vc, wpd->wpimat, wpd->vertexcosnos+6*mface->v2, mval);
+                                               alpha= calc_vp_alpha_dl(wp, vc, wpd->wpimat, wpd->vertexcosnos+6*mface->v2, event->mval);
                                                if(alpha) {
                                                        do_weight_paint_vertex(wp, ob, mface->v2, alpha, paintweight, wpd->vgroup_mirror);
                                                }
@@ -1504,7 +1497,7 @@ static int wpaint_modal(bContext *C, wmOperator *op, wmEvent *event)
                                        }
                                        
                                        if((me->dvert+mface->v3)->flag) {
-                                               alpha= calc_vp_alpha_dl(wp, vc, wpd->wpimat, wpd->vertexcosnos+6*mface->v3, mval);
+                                               alpha= calc_vp_alpha_dl(wp, vc, wpd->wpimat, wpd->vertexcosnos+6*mface->v3, event->mval);
                                                if(alpha) {
                                                        do_weight_paint_vertex(wp, ob, mface->v3, alpha, paintweight, wpd->vgroup_mirror);
                                                }
@@ -1513,7 +1506,7 @@ static int wpaint_modal(bContext *C, wmOperator *op, wmEvent *event)
                                        
                                        if((me->dvert+mface->v4)->flag) {
                                                if(mface->v4) {
-                                                       alpha= calc_vp_alpha_dl(wp, vc, wpd->wpimat, wpd->vertexcosnos+6*mface->v4, mval);
+                                                       alpha= calc_vp_alpha_dl(wp, vc, wpd->wpimat, wpd->vertexcosnos+6*mface->v4, event->mval);
                                                        if(alpha) {
                                                                do_weight_paint_vertex(wp, ob, mface->v4, alpha, paintweight, wpd->vgroup_mirror);
                                                        }
@@ -1796,7 +1789,6 @@ static int vpaint_modal(bContext *C, wmOperator *op, wmEvent *event)
                        float mat[4][4];
                        int *indexar= vpd->indexar;
                        int totindex, index;
-                       short mval[2];
                        
                        view3d_operator_needs_opengl(C);
                        
@@ -1805,15 +1797,12 @@ static int vpaint_modal(bContext *C, wmOperator *op, wmEvent *event)
                        wmGetSingleMatrix(mat);
                        wmLoadMatrix(vc->rv3d->viewmat);
                        
-                       mval[0]= event->x - vc->ar->winrct.xmin;
-                       mval[1]= event->y - vc->ar->winrct.ymin;
-                               
                        /* which faces are involved */
                        if(vp->flag & VP_AREA) {
-                               totindex= sample_backbuf_area(vc, indexar, me->totface, mval[0], mval[1], vp->size);
+                               totindex= sample_backbuf_area(vc, indexar, me->totface, event->mval[0], event->mval[1], vp->size);
                        }
                        else {
-                               indexar[0]= view3d_sample_backbuf(vc, mval[0], mval[1]);
+                               indexar[0]= view3d_sample_backbuf(vc, event->mval[0], event->mval[1]);
                                if(indexar[0]) totindex= 1;
                                else totindex= 0;
                        }
@@ -1862,17 +1851,17 @@ static int vpaint_modal(bContext *C, wmOperator *op, wmEvent *event)
                                                
                                        }
                                        
-                                       alpha= calc_vp_alpha_dl(vp, vc, vpd->vpimat, vpd->vertexcosnos+6*mface->v1, mval);
+                                       alpha= calc_vp_alpha_dl(vp, vc, vpd->vpimat, vpd->vertexcosnos+6*mface->v1, event->mval);
                                        if(alpha) vpaint_blend(vp, mcol, mcolorig, vpd->paintcol, alpha);
                                        
-                                       alpha= calc_vp_alpha_dl(vp, vc, vpd->vpimat, vpd->vertexcosnos+6*mface->v2, mval);
+                                       alpha= calc_vp_alpha_dl(vp, vc, vpd->vpimat, vpd->vertexcosnos+6*mface->v2, event->mval);
                                        if(alpha) vpaint_blend(vp, mcol+1, mcolorig+1, vpd->paintcol, alpha);
                                        
-                                       alpha= calc_vp_alpha_dl(vp, vc, vpd->vpimat, vpd->vertexcosnos+6*mface->v3, mval);
+                                       alpha= calc_vp_alpha_dl(vp, vc, vpd->vpimat, vpd->vertexcosnos+6*mface->v3, event->mval);
                                        if(alpha) vpaint_blend(vp, mcol+2, mcolorig+2, vpd->paintcol, alpha);
                                        
                                        if(mface->v4) {
-                                               alpha= calc_vp_alpha_dl(vp, vc, vpd->vpimat, vpd->vertexcosnos+6*mface->v4, mval);
+                                               alpha= calc_vp_alpha_dl(vp, vc, vpd->vpimat, vpd->vertexcosnos+6*mface->v4, event->mval);
                                                if(alpha) vpaint_blend(vp, mcol+3, mcolorig+3, vpd->paintcol, alpha);
                                        }
                                }
index d67a31f9e426db962801c12dfd908134b5b1fd17..4dc62985f53af92510834089bdb1b0a9e1902579 100644 (file)
@@ -66,7 +66,8 @@ typedef struct wmEvent {
        
        short type;                     /* event code itself (short, is also in keymap) */
        short val;                      /* press, release, scrollvalue */
-       short x, y;                     /* mouse pointer position */
+       short x, y;                     /* mouse pointer position, screen coord */
+       short mval[2];          /* region mouse position, name convention pre 2.5 :) */
        short prevx, prevy;     /* previous mouse pointer position */
        short unicode;          /* future, ghost? */
        char ascii;                     /* from ghost */
index 9fe97f307c5636acfe564bcadedb5a15ce12da88..6eb71d3d314d6874898dfedbe7ccbbd242041b77 100644 (file)
@@ -322,6 +322,16 @@ static void wm_operator_print(wmOperator *op)
        MEM_freeN(buf);
 }
 
+static void wm_region_mouse_co(bContext *C, wmEvent *event)
+{
+       ARegion *ar= CTX_wm_region(C);
+       if(ar) {
+               /* compatibility convention */
+               event->mval[0]= event->x - ar->winrct.xmin;
+               event->mval[1]= event->y - ar->winrct.ymin;
+       }
+}
+
 static int wm_operator_invoke(bContext *C, wmOperatorType *ot, wmEvent *event, PointerRNA *properties)
 {
        wmWindowManager *wm= CTX_wm_manager(C);
@@ -333,8 +343,10 @@ static int wm_operator_invoke(bContext *C, wmOperatorType *ot, wmEvent *event, P
                if((G.f & G_DEBUG) && event && event->type!=MOUSEMOVE)
                        printf("handle evt %d win %d op %s\n", event?event->type:0, CTX_wm_screen(C)->subwinactive, ot->idname); 
                
-               if(op->type->invoke && event)
-                       retval= (*op->type->invoke)(C, op, event);
+               if(op->type->invoke && event) {
+                       wm_region_mouse_co(C, event);
+                       retval= op->type->invoke(C, op, event);
+               }
                else if(op->type->exec)
                        retval= op->type->exec(C, op);
                else
@@ -636,6 +648,7 @@ static int wm_handler_operator_call(bContext *C, ListBase *handlers, wmEventHand
                        
                        wm_handler_op_context(C, handler);
                        
+                       wm_region_mouse_co(C, event);
                        retval= ot->modal(C, op, event);
 
                        /* putting back screen context, reval can pass trough after modal failures! */