[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [55084] trunk/blender/source/blender: Support position jittering on new texpaint code using the stroke system.

Antony Riakiotakis kalast at gmail.com
Wed Mar 6 23:54:45 CET 2013


Revision: 55084
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=55084
Author:   psy-fi
Date:     2013-03-06 22:54:44 +0000 (Wed, 06 Mar 2013)
Log Message:
-----------
Support position jittering on new texpaint code using the stroke system.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/BKE_paint.h
    trunk/blender/source/blender/blenkernel/intern/paint.c
    trunk/blender/source/blender/editors/sculpt_paint/paint_image.c
    trunk/blender/source/blender/editors/sculpt_paint/paint_image_proj.c
    trunk/blender/source/blender/editors/sculpt_paint/paint_stroke.c

Modified: trunk/blender/source/blender/blenkernel/BKE_paint.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_paint.h	2013-03-06 20:55:04 UTC (rev 55083)
+++ trunk/blender/source/blender/blenkernel/BKE_paint.h	2013-03-06 22:54:44 UTC (rev 55084)
@@ -54,6 +54,16 @@
 extern const char PAINT_CURSOR_WEIGHT_PAINT[3];
 extern const char PAINT_CURSOR_TEXTURE_PAINT[3];
 
+typedef enum {
+	PAINT_SCULPT,
+	PAINT_VERTEX,
+	PAINT_WEIGHT,
+	PAINT_TEXTURE_PROJECTIVE,
+	PAINT_TEXTURE_2D,
+	PAINT_SCULPT_UV,
+	PAINT_INVALID
+} PaintMode;
+
 void BKE_paint_init(struct Paint *p, const char col[3]);
 void BKE_paint_free(struct Paint *p);
 void BKE_paint_copy(struct Paint *src, struct Paint *tar);
@@ -61,6 +71,7 @@
 /* TODO, give these BKE_ prefix too */
 struct Paint *paint_get_active(struct Scene *sce);
 struct Paint *paint_get_active_from_context(const struct bContext *C);
+PaintMode paintmode_get_active_from_context(const struct bContext *C);
 struct Brush *paint_brush(struct Paint *paint);
 void paint_brush_set(struct Paint *paint, struct Brush *br);
 

Modified: trunk/blender/source/blender/blenkernel/intern/paint.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/paint.c	2013-03-06 20:55:04 UTC (rev 55083)
+++ trunk/blender/source/blender/blenkernel/intern/paint.c	2013-03-06 22:54:44 UTC (rev 55084)
@@ -137,6 +137,55 @@
 	return NULL;
 }
 
+PaintMode paintmode_get_active_from_context(const bContext *C)
+{
+	Scene *sce = CTX_data_scene(C);
+	SpaceImage *sima;
+
+	if (sce) {
+		ToolSettings *ts = sce->toolsettings;
+		Object *obact = NULL;
+
+		if (sce->basact && sce->basact->object)
+			obact = sce->basact->object;
+
+		if ((sima = CTX_wm_space_image(C)) != NULL) {
+			if (obact && obact->mode == OB_MODE_EDIT) {
+				if (sima->mode == SI_MODE_PAINT)
+					return PAINT_TEXTURE_2D;
+				else if (ts->use_uv_sculpt)
+					return PAINT_SCULPT_UV;
+			}
+			else {
+				return PAINT_TEXTURE_2D;
+			}
+		}
+		else if (obact) {
+			switch (obact->mode) {
+				case OB_MODE_SCULPT:
+					return PAINT_SCULPT;
+				case OB_MODE_VERTEX_PAINT:
+					return PAINT_VERTEX;
+				case OB_MODE_WEIGHT_PAINT:
+					return PAINT_WEIGHT;
+				case OB_MODE_TEXTURE_PAINT:
+					return PAINT_TEXTURE_PROJECTIVE;
+				case OB_MODE_EDIT:
+					if (ts->use_uv_sculpt)
+						return PAINT_SCULPT_UV;
+					else
+						return PAINT_TEXTURE_2D;
+			}
+		}
+		else {
+			/* default to image paint */
+			return PAINT_TEXTURE_2D;
+		}
+	}
+
+	return PAINT_INVALID;
+}
+
 Brush *paint_brush(Paint *p)
 {
 	return p ? p->brush : NULL;

Modified: trunk/blender/source/blender/editors/sculpt_paint/paint_image.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/paint_image.c	2013-03-06 20:55:04 UTC (rev 55083)
+++ trunk/blender/source/blender/editors/sculpt_paint/paint_image.c	2013-03-06 22:54:44 UTC (rev 55084)
@@ -4936,14 +4936,14 @@
 
 /************************ paint operator ************************/
 
-typedef enum PaintMode {
+typedef enum TexPaintMode {
 	PAINT_MODE_2D,
 	PAINT_MODE_3D,
 	PAINT_MODE_3D_PROJECT
-} PaintMode;
+} TexPaintMode;
 
 typedef struct PaintOperation {
-	PaintMode mode;
+	TexPaintMode mode;
 
 	BrushPainter *painter;
 	ImagePaintState s;

Modified: trunk/blender/source/blender/editors/sculpt_paint/paint_image_proj.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/paint_image_proj.c	2013-03-06 20:55:04 UTC (rev 55083)
+++ trunk/blender/source/blender/editors/sculpt_paint/paint_image_proj.c	2013-03-06 22:54:44 UTC (rev 55084)
@@ -4803,13 +4803,13 @@
 
 /************************ paint operator ************************/
 
-typedef enum PaintMode {
+typedef enum TexPaintMode {
 	PAINT_MODE_2D,
 	PAINT_MODE_3D_PROJECT
-} PaintMode;
+} TexPaintMode;
 
 typedef struct PaintOperation {
-	PaintMode mode;
+	TexPaintMode mode;
 
 	BrushPainter *painter;
 	ImagePaintState s;
@@ -5060,10 +5060,10 @@
 	mouse[1] = (int)(mousef[1]);
 	pressure = RNA_float_get(itemptr, "pressure");
 
-	if (pop->first)
-		project_paint_begin_clone(&pop->ps, mouse);
+	if (pop->mode == PAINT_MODE_3D_PROJECT) {
+		if (pop->first)
+			project_paint_begin_clone(&pop->ps, mouse);
 
-	if (pop->mode == PAINT_MODE_3D_PROJECT) {
 		redraw = project_paint_stroke(&pop->ps, pop->prevmouse, mouse, pressure);
 		pop->prevmouse[0] = mouse[0];
 		pop->prevmouse[1] = mouse[1];

Modified: trunk/blender/source/blender/editors/sculpt_paint/paint_stroke.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/paint_stroke.c	2013-03-06 20:55:04 UTC (rev 55083)
+++ trunk/blender/source/blender/editors/sculpt_paint/paint_stroke.c	2013-03-06 22:54:44 UTC (rev 55084)
@@ -143,6 +143,7 @@
 {
 	Scene *scene = CTX_data_scene(C);
 	Paint *paint = paint_get_active_from_context(C);
+	PaintMode mode = paintmode_get_active_from_context(C);
 	Brush *brush = paint_brush(paint);
 	PaintStroke *stroke = op->customdata;
 	float mouse_out[2];
@@ -156,7 +157,7 @@
 
 	/* TODO: as sculpt and other paint modes are unified, this
 	 * separation will go away */
-	if (stroke->vc.obact->sculpt) {
+	if (ELEM(mode, PAINT_SCULPT, PAINT_TEXTURE_PROJECTIVE)) {
 		float delta[2];
 
 		BKE_brush_jitter_pos(scene, brush, mouse_in, mouse_out);




More information about the Bf-blender-cvs mailing list