Cleanup, move uv sculpt specific code to sculpt_uv.c. Also rename
authorAntony Riakiotakis <kalast@gmail.com>
Sun, 3 Mar 2013 16:33:39 +0000 (16:33 +0000)
committerAntony Riakiotakis <kalast@gmail.com>
Sun, 3 Mar 2013 16:33:39 +0000 (16:33 +0000)
brush_drawcursor to a more indicative of its users name until paint
cursor unification is done.

source/blender/editors/sculpt_paint/paint_image.c
source/blender/editors/sculpt_paint/paint_intern.h
source/blender/editors/sculpt_paint/sculpt_uv.c

index edeb66d..8cc290a 100644 (file)
@@ -4889,16 +4889,6 @@ static Brush *image_paint_brush(bContext *C)
        return paint_brush(&settings->imapaint.paint);
 }
 
-static Brush *uv_sculpt_brush(bContext *C)
-{
-       Scene *scene = CTX_data_scene(C);
-       ToolSettings *settings = scene->toolsettings;
-
-       if (!settings->uvsculpt)
-               return NULL;
-       return paint_brush(&settings->uvsculpt->paint);
-}
-
 static int image_paint_poll(bContext *C)
 {
        Object *obact = CTX_data_active_object(C);
@@ -4924,30 +4914,6 @@ static int image_paint_poll(bContext *C)
        return 0;
 }
 
-static int uv_sculpt_brush_poll(bContext *C)
-{
-       BMEditMesh *em;
-       int ret;
-       Object *obedit = CTX_data_edit_object(C);
-       SpaceImage *sima = CTX_wm_space_image(C);
-       Scene *scene = CTX_data_scene(C);
-       ToolSettings *toolsettings = scene->toolsettings;
-
-       if (!uv_sculpt_brush(C) || !obedit || obedit->type != OB_MESH)
-               return 0;
-
-       em = BMEdit_FromObject(obedit);
-       ret = EDBM_mtexpoly_check(em);
-
-       if (ret && sima) {
-               ARegion *ar = CTX_wm_region(C);
-               if ((toolsettings->use_uv_sculpt) && ar->regiontype == RGN_TYPE_WINDOW)
-                       return 1;
-       }
-
-       return 0;
-}
-
 static int image_paint_3d_poll(bContext *C)
 {
        if (CTX_wm_region_view3d(C))
@@ -5484,7 +5450,7 @@ static int get_imapaint_zoom(bContext *C, float *zoomx, float *zoomy)
 
 /************************ cursor drawing *******************************/
 
-static void brush_drawcursor(bContext *C, int x, int y, void *UNUSED(customdata))
+void brush_drawcursor_texpaint_uvsculpt(bContext *C, int x, int y, void *UNUSED(customdata))
 {
 #define PX_SIZE_FADE_MAX 12.0f
 #define PX_SIZE_FADE_MIN 4.0f
@@ -5560,7 +5526,8 @@ static void toggle_paint_cursor(bContext *C, int enable)
                settings->imapaint.paintcursor = NULL;
        }
        else if (enable)
-               settings->imapaint.paintcursor = WM_paint_cursor_activate(wm, image_paint_poll, brush_drawcursor, NULL);
+               settings->imapaint.paintcursor =
+                       WM_paint_cursor_activate(wm, image_paint_poll, brush_drawcursor_texpaint_uvsculpt, NULL);
 }
 
 /* enable the paint cursor if it isn't already.
@@ -5587,32 +5554,11 @@ void ED_space_image_paint_update(wmWindowManager *wm, ToolSettings *settings)
                if (!imapaint->paintcursor) {
                        imapaint->paintcursor =
                                WM_paint_cursor_activate(wm, image_paint_poll,
-                                                        brush_drawcursor, NULL);
+                                                        brush_drawcursor_texpaint_uvsculpt, NULL);
                }
        }
 }
 
-
-void ED_space_image_uv_sculpt_update(wmWindowManager *wm, ToolSettings *settings)
-{
-       if (settings->use_uv_sculpt) {
-               if (!settings->uvsculpt) {
-                       settings->uvsculpt = MEM_callocN(sizeof(*settings->uvsculpt), "UV Smooth paint");
-                       settings->uv_sculpt_tool = UV_SCULPT_TOOL_GRAB;
-                       settings->uv_sculpt_settings = UV_SCULPT_LOCK_BORDERS | UV_SCULPT_ALL_ISLANDS;
-                       settings->uv_relax_method = UV_SCULPT_TOOL_RELAX_LAPLACIAN;
-               }
-
-               BKE_paint_init(&settings->uvsculpt->paint, PAINT_CURSOR_SCULPT);
-
-               WM_paint_cursor_activate(wm, uv_sculpt_brush_poll,
-                                        brush_drawcursor, NULL);
-       }
-       else {
-               if (settings->uvsculpt)
-                       settings->uvsculpt->paint.flags &= ~PAINT_SHOW_BRUSH;
-       }
-}
 /************************ grab clone operator ************************/
 
 typedef struct GrabClone {
@@ -5937,11 +5883,6 @@ int image_texture_paint_poll(bContext *C)
        return (texture_paint_poll(C) || image_paint_poll(C));
 }
 
-int uv_sculpt_poll(bContext *C)
-{
-       return uv_sculpt_brush_poll(C);
-}
-
 int facemask_paint_poll(bContext *C)
 {
        return paint_facesel_test(CTX_data_active_object(C));
index e7c3ddd..a75d98f 100644 (file)
@@ -144,6 +144,7 @@ float paint_calc_object_space_radius(struct ViewContext *vc, const float center[
 float paint_get_tex_pixel(struct Brush *br, float u, float v, struct ImagePool *pool);
 int imapaint_pick_face(struct ViewContext *vc, const int mval[2], unsigned int *index, unsigned int totface);
 void imapaint_pick_uv(struct Scene *scene, struct Object *ob, unsigned int faceindex, const int xy[2], float uv[2]);
+void brush_drawcursor_texpaint_uvsculpt(struct bContext *C, int x, int y, void *customdata);
 
 void paint_sample_color(const struct bContext *C, struct ARegion *ar, int x, int y);
 void BRUSH_OT_curve_preset(struct wmOperatorType *ot);
index 0bcccd9..3baf5d8 100644 (file)
@@ -144,6 +144,69 @@ typedef struct UvSculptData {
        char invert;
 } UvSculptData;
 
+
+static Brush *uv_sculpt_brush(bContext *C)
+{
+       Scene *scene = CTX_data_scene(C);
+       ToolSettings *settings = scene->toolsettings;
+
+       if (!settings->uvsculpt)
+               return NULL;
+       return paint_brush(&settings->uvsculpt->paint);
+}
+
+
+static int uv_sculpt_brush_poll(bContext *C)
+{
+       BMEditMesh *em;
+       int ret;
+       Object *obedit = CTX_data_edit_object(C);
+       SpaceImage *sima = CTX_wm_space_image(C);
+       Scene *scene = CTX_data_scene(C);
+       ToolSettings *toolsettings = scene->toolsettings;
+
+       if (!uv_sculpt_brush(C) || !obedit || obedit->type != OB_MESH)
+               return 0;
+
+       em = BMEdit_FromObject(obedit);
+       ret = EDBM_mtexpoly_check(em);
+
+       if (ret && sima) {
+               ARegion *ar = CTX_wm_region(C);
+               if ((toolsettings->use_uv_sculpt) && ar->regiontype == RGN_TYPE_WINDOW)
+                       return 1;
+       }
+
+       return 0;
+}
+
+
+void ED_space_image_uv_sculpt_update(wmWindowManager *wm, ToolSettings *settings)
+{
+       if (settings->use_uv_sculpt) {
+               if (!settings->uvsculpt) {
+                       settings->uvsculpt = MEM_callocN(sizeof(*settings->uvsculpt), "UV Smooth paint");
+                       settings->uv_sculpt_tool = UV_SCULPT_TOOL_GRAB;
+                       settings->uv_sculpt_settings = UV_SCULPT_LOCK_BORDERS | UV_SCULPT_ALL_ISLANDS;
+                       settings->uv_relax_method = UV_SCULPT_TOOL_RELAX_LAPLACIAN;
+               }
+
+               BKE_paint_init(&settings->uvsculpt->paint, PAINT_CURSOR_SCULPT);
+
+               WM_paint_cursor_activate(wm, uv_sculpt_brush_poll,
+                                        brush_drawcursor_texpaint_uvsculpt, NULL);
+       }
+       else {
+               if (settings->uvsculpt)
+                       settings->uvsculpt->paint.flags &= ~PAINT_SHOW_BRUSH;
+       }
+}
+
+int uv_sculpt_poll(bContext *C)
+{
+       return uv_sculpt_brush_poll(C);
+}
+
 /*********** Improved Laplacian Relaxation Operator ************************/
 /* original code by Raul Fernandez Hernandez "farsthary"                   *
  * adapted to uv smoothing by Antony Riakiatakis                           *