[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [54995] trunk/blender/source/blender/ editors/sculpt_paint: Cleanup, move uv sculpt specific code to sculpt_uv.c.

Antony Riakiotakis kalast at gmail.com
Sun Mar 3 17:33:39 CET 2013


Revision: 54995
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=54995
Author:   psy-fi
Date:     2013-03-03 16:33:39 +0000 (Sun, 03 Mar 2013)
Log Message:
-----------
Cleanup, move uv sculpt specific code to sculpt_uv.c. Also rename
brush_drawcursor to a more indicative of its users name until paint
cursor unification is done.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/sculpt_paint/paint_image.c
    trunk/blender/source/blender/editors/sculpt_paint/paint_intern.h
    trunk/blender/source/blender/editors/sculpt_paint/sculpt_uv.c

Modified: trunk/blender/source/blender/editors/sculpt_paint/paint_image.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/paint_image.c	2013-03-03 15:07:49 UTC (rev 54994)
+++ trunk/blender/source/blender/editors/sculpt_paint/paint_image.c	2013-03-03 16:33:39 UTC (rev 54995)
@@ -4889,16 +4889,6 @@
 	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 @@
 	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 @@
 
 /************************ 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 @@
 		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 @@
 		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 @@
 	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));

Modified: trunk/blender/source/blender/editors/sculpt_paint/paint_intern.h
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/paint_intern.h	2013-03-03 15:07:49 UTC (rev 54994)
+++ trunk/blender/source/blender/editors/sculpt_paint/paint_intern.h	2013-03-03 16:33:39 UTC (rev 54995)
@@ -144,6 +144,7 @@
 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);

Modified: trunk/blender/source/blender/editors/sculpt_paint/sculpt_uv.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/sculpt_uv.c	2013-03-03 15:07:49 UTC (rev 54994)
+++ trunk/blender/source/blender/editors/sculpt_paint/sculpt_uv.c	2013-03-03 16:33:39 UTC (rev 54995)
@@ -144,6 +144,69 @@
 	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                           *




More information about the Bf-blender-cvs mailing list