=trunk=
authorJoseph Eagar <joeedh@gmail.com>
Tue, 3 May 2011 01:48:15 +0000 (01:48 +0000)
committerJoseph Eagar <joeedh@gmail.com>
Tue, 3 May 2011 01:48:15 +0000 (01:48 +0000)
Recommitted eltopo collision code (but disabled by default)
with Genscher's permission.

To use, you need to install liblapack and libblas

release/scripts/startup/bl_ui/space_userpref.py
source/blender/editors/mesh/loopcut.c
source/blender/editors/mesh/mesh_ops.c
source/blender/editors/transform/transform.c
source/blender/editors/transform/transform_ops.c
source/blender/makesdna/DNA_userdef_types.h
source/blender/makesdna/DNA_windowmanager_types.h
source/blender/makesrna/intern/rna_userdef.c
source/blender/windowmanager/intern/wm_operators.c

index 7ae2efb369694b203c7bf3a860b5cb2cc30769ed..a8d8c4120631c4142ab425af968fa1a651c2a0b4 100644 (file)
@@ -795,6 +795,9 @@ class USERPREF_PT_input(InputKeyMapPanel):
 
         sub.separator()
 
+        sub.label(text="Loop Cut:")
+        sub.prop(inputs, "loopcut_finish_on_release")
+        
         sub.label(text="Orbit Style:")
         sub.row().prop(inputs, "view_rotate_method", expand=True)
 
index 0ec356a88ae5839a6dd3bdfc88bfe01db887b37e..2e06d8385d445585574b258785598296976c4635 100644 (file)
@@ -100,6 +100,7 @@ typedef struct tringselOpData {
 
        int extend;
        int do_cut;
+       wmTimer *timer;
 } tringselOpData;
 
 /* modal loop selection drawing callback */
@@ -315,10 +316,13 @@ static void ringsel_finish(bContext *C, wmOperator *op)
 }
 
 /* called when modal loop selection is done... */
-static void ringsel_exit(wmOperator *op)
+static void ringsel_exit(bContext *C, wmOperator *op)
 {
        tringselOpData *lcd= op->customdata;
 
+       if (lcd->timer)
+               WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), lcd->timer);
+
        /* deactivate the extra drawing stuff in 3D-View */
        ED_region_draw_cb_exit(lcd->ar->type, lcd->draw_handle);
        
@@ -354,10 +358,10 @@ static int ringsel_init (bContext *C, wmOperator *op, int do_cut)
        return 1;
 }
 
-static int ringcut_cancel (bContext *UNUSED(C), wmOperator *op)
+static int ringcut_cancel (bContext *C, wmOperator *op)
 {
        /* this is just a wrapper around exit() */
-       ringsel_exit(op);
+       ringsel_exit(C, op);
        return OPERATOR_CANCELLED;
 }
 
@@ -375,7 +379,7 @@ static int ringsel_invoke (bContext *C, wmOperator *op, wmEvent *evt)
        lcd = op->customdata;
        
        if (lcd->em->selectmode == SCE_SELECT_FACE) {
-               ringsel_exit(op);
+               ringsel_exit(C, op);
                WM_operator_name_call(C, "MESH_OT_loop_select", WM_OP_INVOKE_REGION_WIN, NULL);
                return OPERATOR_CANCELLED;
        }
@@ -385,7 +389,7 @@ static int ringsel_invoke (bContext *C, wmOperator *op, wmEvent *evt)
        
        edge = findnearestedge(&lcd->vc, &dist);
        if(!edge) {
-               ringsel_exit(op);
+               ringsel_exit(C, op);
                return OPERATOR_CANCELLED;
        }
 
@@ -393,7 +397,7 @@ static int ringsel_invoke (bContext *C, wmOperator *op, wmEvent *evt)
        ringsel_find_edge(lcd, 1);
 
        ringsel_finish(C, op);
-       ringsel_exit(op);
+       ringsel_exit(C, op);
 
        return OPERATOR_FINISHED;
 }
@@ -404,7 +408,11 @@ static int ringcut_invoke (bContext *C, wmOperator *op, wmEvent *evt)
        tringselOpData *lcd;
        EditEdge *edge;
        int dist = 75;
-
+       
+       /*if we're in the cut-n-slide macro, set release_confirm based on user pref*/
+       if (op->opm)
+               RNA_boolean_set(op->next->ptr, "release_confirm", U.loopcut_finish_on_release);
+       
        if(modifiers_isDeformedByLattice(obedit) || modifiers_isDeformedByArmature(obedit))
                BKE_report(op->reports, RPT_WARNING, "Loop cut doesn't work well on deformed edit mesh display");
        
@@ -437,22 +445,34 @@ static int ringcut_modal (bContext *C, wmOperator *op, wmEvent *event)
 
        view3d_operator_needs_opengl(C);
 
-
        switch (event->type) {
                case LEFTMOUSE: /* confirm */ // XXX hardcoded
-                       if (event->val == KM_PRESS) {
+                       if (event->val == KM_RELEASE) {
                                /* finish */
                                ED_region_tag_redraw(lcd->ar);
                                
                                ringsel_finish(C, op);
-                               ringsel_exit(op);
+                               ringsel_exit(C, op);
                                ED_area_headerprint(CTX_wm_area(C), NULL);
                                
-                               return OPERATOR_FINISHED;
+                               return OPERATOR_FINISHED|OPERATOR_ABORT_MACRO;
+                       }else {
+                               lcd->timer = WM_event_add_timer(CTX_wm_manager(C), CTX_wm_window(C), TIMER2, 0.12);
                        }
                        
                        ED_region_tag_redraw(lcd->ar);
                        break;
+                       
+               case TIMER2: 
+                       /* finish */
+                       ED_region_tag_redraw(lcd->ar);
+                       
+                       ringsel_finish(C, op);
+                       ringsel_exit(C, op);
+                       
+                       ED_area_headerprint(CTX_wm_area(C), NULL);
+
+                       return OPERATOR_FINISHED;
                case RIGHTMOUSE: /* abort */ // XXX hardcoded
                case ESCKEY:
                        if (event->val == KM_RELEASE) {
index d95c71b68bacf0b919549ea6ba6c8a6ae244c903..6d8dd4e9a2ee45b9116e396fd78d8997d1f6e1ba 100644 (file)
@@ -175,8 +175,10 @@ void ED_operatormacros_mesh(void)
        ot= WM_operatortype_append_macro("MESH_OT_loopcut_slide", "Loop Cut and Slide", OPTYPE_UNDO|OPTYPE_REGISTER);
        ot->description = "Cut mesh loop and slide it";
        WM_operatortype_macro_define(ot, "MESH_OT_loopcut");
-       WM_operatortype_macro_define(ot, "TRANSFORM_OT_edge_slide");
-
+       otmacro= WM_operatortype_macro_define(ot, "TRANSFORM_OT_edge_slide");
+       RNA_boolean_set(otmacro->ptr, "release_confirm", 1);
+       RNA_int_set(otmacro->ptr, "launch_event", LEFTMOUSE);
+       
        ot= WM_operatortype_append_macro("MESH_OT_duplicate_move", "Add Duplicate", OPTYPE_UNDO|OPTYPE_REGISTER);
        ot->description = "Duplicate mesh and move";
        WM_operatortype_macro_define(ot, "MESH_OT_duplicate");
index 614b048e0b81403dd73ad272c50e1b772bc84dce..701b8affac23e790ef6485935f22e642218cab08 100644 (file)
@@ -1521,7 +1521,9 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int
        t->mode = mode;
 
        t->launch_event = event ? event->type : -1;
-
+       if (RNA_property_is_set(op->ptr, "launch_event"))
+               t->launch_event = RNA_int_get(op->ptr, "launch_event");
+       
        if (t->launch_event == EVT_TWEAK_R)
        {
                t->launch_event = RIGHTMOUSE;
index 4edaabb9508c3bd933f2db00c00fc40ae5003475..565ff769ccba94e0f6da9e8dd40d3cf0deed053f 100644 (file)
@@ -495,10 +495,11 @@ void Transform_Properties(struct wmOperatorType *ot, int flags)
        {
                RNA_def_boolean(ot->srna, "texture_space", 0, "Edit Object data texture space", "");
        }
-
+       
        // Add confirm method all the time. At the end because it's not really that important and should be hidden only in log, not in keymap edit
        /*prop =*/ RNA_def_boolean(ot->srna, "release_confirm", 0, "Confirm on Release", "Always confirm operation when releasing button");
        //RNA_def_property_flag(prop, PROP_HIDDEN);
+       RNA_def_int(ot->srna, "launch_event", 0, 0, INT_MAX, "Launch Event", "", 0, INT_MAX);
 }
 
 void TRANSFORM_OT_translate(struct wmOperatorType *ot)
@@ -742,7 +743,7 @@ void TRANSFORM_OT_edge_slide(struct wmOperatorType *ot)
        ot->poll   = ED_operator_editmesh;
 
        RNA_def_float_factor(ot->srna, "value", 0, -1.0f, 1.0f, "Factor", "", -1.0f, 1.0f);
-
+       
        Transform_Properties(ot, P_MIRROR|P_SNAP);
 }
 
index 1be67a4501b1443ded4755a8ee4c031525102375..f91c0ac26f8b6adb3eb2acdc855492739af75c49 100644 (file)
@@ -383,13 +383,13 @@ typedef struct UserDef {
        short autokey_mode;             /* autokeying mode */
        short autokey_flag;             /* flags for autokeying */
        
-       short text_render, pad9;                /*options for text rendering*/
+       short text_render, dsm_maxmem;          /*options for text rendering*/
        float pad10;
 
        struct ColorBand coba_weight;   /* from texture.h */
 
        float sculpt_paint_overlay_col[3];
-       int pad3;
+       int loopcut_finish_on_release;
 
        char author[80];        /* author name for file formats supporting it */
 } UserDef;
index 3072c2c343006d9b9aa8b5594b86209368869c9f..48e585426f59c28f36070d4f510f4f51e48a57da 100644 (file)
@@ -312,6 +312,7 @@ typedef struct wmOperator {
 #define OPERATOR_PASS_THROUGH  8
 /* in case operator got executed outside WM code... like via fileselect */
 #define OPERATOR_HANDLED               16
+#define OPERATOR_ABORT_MACRO   32
 
 /* wmOperator flag */
 #define OP_GRAB_POINTER                        1
index a914d87549000717668890f8580d920867e019f5..421a48e68d012777efc260c0534665bbbd27f184 100644 (file)
@@ -2676,6 +2676,10 @@ static void rna_def_userdef_input(BlenderRNA *brna)
        RNA_def_property_enum_items(prop, view_zoom_axes);
        RNA_def_property_ui_text(prop, "Zoom Axis", "Axis of mouse movement to zoom in or out on");
        
+       prop= RNA_def_property(srna, "loopcut_finish_on_release", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "loopcut_finish_on_release", 1);
+       RNA_def_property_ui_text(prop, "End Loopcut Slide On Release", "End Loopcut Slide On Mouse Release, a 'click-drag-and-hold' workflow");
+
        prop= RNA_def_property(srna, "invert_mouse_zoom", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "uiflag", USER_ZOOM_INVERT);
        RNA_def_property_ui_text(prop, "Invert Zoom Direction", "Invert the axis of mouse movement for zooming");
index 534e1f219f66bd4a4477f2b3fb13098c84ba0673..d1db5a5d0d4a1c5d006f46cc0033d09465b09340 100644 (file)
@@ -214,6 +214,9 @@ static int wm_macro_exec(bContext *C, wmOperator *op)
                        } else {
                                break; /* operator didn't finish, end macro */
                        }
+                       
+                       if (retval & OPERATOR_ABORT_MACRO)
+                               break;
                }
        }
        
@@ -239,6 +242,9 @@ static int wm_macro_invoke_internal(bContext *C, wmOperator *op, wmEvent *event,
                } else {
                        break; /* operator didn't finish, end macro */
                }
+               
+               if (retval & OPERATOR_ABORT_MACRO)
+                       break;
        }
 
        return wm_macro_end(op, retval);
@@ -265,43 +271,45 @@ static int wm_macro_modal(bContext *C, wmOperator *op, wmEvent *event)
                        MacroData *md = op->customdata;
 
                        md->retval = OPERATOR_FINISHED; /* keep in mind that at least one operator finished */
-
-                       retval = wm_macro_invoke_internal(C, op, event, opm->next);
-
-                       /* if new operator is modal and also added its own handler */
-                       if (retval & OPERATOR_RUNNING_MODAL && op->opm != opm) {
-                               wmWindow *win = CTX_wm_window(C);
-                               wmEventHandler *handler = NULL;
-
-                               for (handler = win->modalhandlers.first; handler; handler = handler->next) {
-                                       /* first handler in list is the new one */
-                                       if (handler->op == op)
-                                               break;
-                               }
-
-                               if (handler) {
-                                       BLI_remlink(&win->modalhandlers, handler);
-                                       wm_event_free_handler(handler);
-                               }
-
-                               /* if operator is blocking, grab cursor
-                                * This may end up grabbing twice, but we don't care.
-                                * */
-                               if(op->opm->type->flag & OPTYPE_BLOCKING) {
-                                       int bounds[4] = {-1,-1,-1,-1};
-                                       int wrap = (U.uiflag & USER_CONTINUOUS_MOUSE) && ((op->opm->flag & OP_GRAB_POINTER) || (op->opm->type->flag & OPTYPE_GRAB_POINTER));
-
-                                       if(wrap) {
-                                               ARegion *ar= CTX_wm_region(C);
-                                               if(ar) {
-                                                       bounds[0]= ar->winrct.xmin;
-                                                       bounds[1]= ar->winrct.ymax;
-                                                       bounds[2]= ar->winrct.xmax;
-                                                       bounds[3]= ar->winrct.ymin;
+                       
+                       if (!(retval & OPERATOR_ABORT_MACRO)) {
+                               retval = wm_macro_invoke_internal(C, op, event, opm->next);
+       
+                               /* if new operator is modal and also added its own handler */
+                               if (retval & OPERATOR_RUNNING_MODAL && op->opm != opm) {
+                                       wmWindow *win = CTX_wm_window(C);
+                                       wmEventHandler *handler = NULL;
+       
+                                       for (handler = win->modalhandlers.first; handler; handler = handler->next) {
+                                               /* first handler in list is the new one */
+                                               if (handler->op == op)
+                                                       break;
+                                       }
+       
+                                       if (handler) {
+                                               BLI_remlink(&win->modalhandlers, handler);
+                                               wm_event_free_handler(handler);
+                                       }
+       
+                                       /* if operator is blocking, grab cursor
+                                        * This may end up grabbing twice, but we don't care.
+                                        * */
+                                       if(op->opm->type->flag & OPTYPE_BLOCKING) {
+                                               int bounds[4] = {-1,-1,-1,-1};
+                                               int wrap = (U.uiflag & USER_CONTINUOUS_MOUSE) && ((op->opm->flag & OP_GRAB_POINTER) || (op->opm->type->flag & OPTYPE_GRAB_POINTER));
+       
+                                               if(wrap) {
+                                                       ARegion *ar= CTX_wm_region(C);
+                                                       if(ar) {
+                                                               bounds[0]= ar->winrct.xmin;
+                                                               bounds[1]= ar->winrct.ymax;
+                                                               bounds[2]= ar->winrct.xmax;
+                                                               bounds[3]= ar->winrct.ymin;
+                                                       }
                                                }
+       
+                                               WM_cursor_grab(CTX_wm_window(C), wrap, FALSE, bounds);
                                        }
-
-                                       WM_cursor_grab(CTX_wm_window(C), wrap, FALSE, bounds);
                                }
                        }
                }