Try fixing modifier keys not working correctly for uv sculpting.
authorAntony Riakiotakis <kalast@gmail.com>
Fri, 20 Jan 2012 18:03:55 +0000 (18:03 +0000)
committerAntony Riakiotakis <kalast@gmail.com>
Fri, 20 Jan 2012 18:03:55 +0000 (18:03 +0000)
source/blender/editors/sculpt_paint/paint_ops.c
source/blender/editors/sculpt_paint/sculpt_uv.c

index 0ff0f278f171ac65c03ddf329ce0e51337d825d9..c2026b30ab26a4752dba2657adae79f234b56792 100644 (file)
@@ -663,9 +663,9 @@ void ED_keymap_paint(wmKeyConfig *keyconf)
        kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", QKEY, KM_PRESS, 0, 0);
        RNA_string_set(kmi->ptr, "data_path", "tool_settings.use_uv_sculpt");
 
-       WM_keymap_add_item(keymap, "SCULPT_OT_uv_sculpt_stroke", LEFTMOUSE, KM_PRESS, 0, 0);
-       RNA_boolean_set(WM_keymap_add_item(keymap, "SCULPT_OT_uv_sculpt_stroke", LEFTMOUSE, KM_PRESS, KM_CTRL, 0)->ptr, "invert", 1);
-       RNA_boolean_set(WM_keymap_add_item(keymap, "SCULPT_OT_uv_sculpt_stroke", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "temp_relax", 1);
+       RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_uv_sculpt_stroke", LEFTMOUSE, KM_PRESS, 0,        0)->ptr, "mode", BRUSH_STROKE_NORMAL);
+       RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_uv_sculpt_stroke", LEFTMOUSE, KM_PRESS, KM_CTRL,  0)->ptr, "mode", BRUSH_STROKE_INVERT);
+       RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_uv_sculpt_stroke", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", BRUSH_STROKE_SMOOTH);
 
        ed_keymap_paint_brush_size(keymap, "tool_settings.uv_sculpt.brush.size");
        ed_keymap_paint_brush_radial_control(keymap, "uv_sculpt", 0);
index 4023797b11a0d0111d4885882c9cdb8bb17eff82..bf8cb58a2f521b5af86a6b0933b77d97c6e5e6b4 100644 (file)
@@ -121,24 +121,30 @@ typedef struct UvSculptData{
        /* Edges used for adjacency info, used with laplacian smoothing */
        UvEdge *uvedges;
 
-       /* Need I say more? */
+       /* need I say more? */
        int totalUvEdges;
 
        /* data for initial stroke, used by tools like grab */
        UVInitialStroke *initial_stroke;
 
-       /* Timer to be used for airbrush-type brush */
+       /* timer to be used for airbrush-type brush */
        wmTimer *timer;
 
-       /* To determine quickly adjacent uvs */
+       /* to determine quickly adjacent uvs */
        UvElementMap *elementMap;
 
        /* uvsmooth Paint for fast reference */
        Paint *uvsculpt;
+       
+       /* tool to use. duplicating here to change if modifier keys are pressed */
+       char tool;
+
+       /* store invert flag here */
+       char invert;
 }UvSculptData;
 
 /*********** Improved Laplacian Relaxation Operator ************************/
-/* Original code by Raul Fernandez Hernandez "farsthary"                   *
+/* original code by Raul Fernandez Hernandez "farsthary"                   *
  * adapted to uv smoothing by Antony Riakiatakis                           *
  ***************************************************************************/
 
@@ -292,9 +298,8 @@ static void uv_sculpt_stroke_apply(bContext *C, wmOperator *op, wmEvent *event,
        float alpha, zoomx, zoomy;
        Brush *brush = paint_brush(sculptdata->uvsculpt);
        ToolSettings *toolsettings = CTX_data_tool_settings(C);
-       tool = RNA_boolean_get(op->ptr, "temp_relax")? UV_SCULPT_TOOL_RELAX : toolsettings->uv_sculpt_tool;
-
-       invert = RNA_boolean_get(op->ptr, "invert")? -1 : 1;
+       tool = sculptdata->tool;
+       invert = sculptdata->invert? -1 : 1;
        alpha = brush_alpha(scene, brush);
        UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &co[0], &co[1]);
 
@@ -463,6 +468,8 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, wmEvent
                int island_index = 0;
                /* Holds, for each UvElement in elementMap, a pointer to its unique uv.*/
                int *uniqueUv;
+               data->tool = (RNA_enum_get(op->ptr, "mode") == BRUSH_STROKE_SMOOTH)? UV_SCULPT_TOOL_RELAX : ts->uv_sculpt_tool;
+               data->invert = (RNA_enum_get(op->ptr, "mode") == BRUSH_STROKE_INVERT)? 1 : 0;
 
                data->uvsculpt = &ts->uvsculpt->paint;
 
@@ -632,7 +639,7 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, wmEvent
                }
 
                /* Allocate initial selection for grab tool */
-               if(ts->uv_sculpt_tool == UV_SCULPT_TOOL_GRAB){
+               if(data->tool){
                        float radius, radius_root;
                        UvSculptData *sculptdata = (UvSculptData *)op->customdata;
                        SpaceImage *sima;
@@ -748,6 +755,13 @@ static int uv_sculpt_stroke_modal(bContext *C, wmOperator *op, wmEvent *event)
 
 void SCULPT_OT_uv_sculpt_stroke(wmOperatorType *ot)
 {
+       static EnumPropertyItem stroke_mode_items[] = {
+               {BRUSH_STROKE_NORMAL, "NORMAL", 0, "Normal", "Apply brush normally"},
+               {BRUSH_STROKE_INVERT, "INVERT", 0, "Invert", "Invert action of brush for duration of stroke"},
+               {BRUSH_STROKE_SMOOTH, "RELAX", 0, "Relax", "Switch brush to relax mode for duration of stroke"},
+               {0}
+       };
+
        /* identifiers */
        ot->name = "Sculpt UVs";
        ot->description = "Sculpt UVs using a brush";
@@ -762,6 +776,5 @@ void SCULPT_OT_uv_sculpt_stroke(wmOperatorType *ot)
        ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
 
        /* props */
-       RNA_def_boolean(ot->srna, "invert", 0, "Invert", "Inverts the operator");
-       RNA_def_boolean(ot->srna, "temp_relax", 0, "Relax", "Relax Tool");
+       RNA_def_enum(ot->srna, "mode", stroke_mode_items, BRUSH_STROKE_NORMAL, "Mode", "Stroke Mode");
 }