[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [56816] trunk/blender/source/blender/ editors: Fix part of #35372: distorted strokes when painting zoomed out with a small brush

Brecht Van Lommel brechtvanlommel at pandora.be
Wed May 15 13:16:01 CEST 2013


Revision: 56816
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=56816
Author:   blendix
Date:     2013-05-15 11:16:01 +0000 (Wed, 15 May 2013)
Log Message:
-----------
Fix part of #35372: distorted strokes when painting zoomed out with a small brush
size. Interpolated mouse coordinates should not get rounded to integers.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/include/UI_view2d.h
    trunk/blender/source/blender/editors/interface/view2d.c
    trunk/blender/source/blender/editors/sculpt_paint/paint_image.c
    trunk/blender/source/blender/editors/sculpt_paint/paint_image_2d.c
    trunk/blender/source/blender/editors/sculpt_paint/paint_image_proj.c
    trunk/blender/source/blender/editors/sculpt_paint/paint_intern.h

Modified: trunk/blender/source/blender/editors/include/UI_view2d.h
===================================================================
--- trunk/blender/source/blender/editors/include/UI_view2d.h	2013-05-15 11:10:59 UTC (rev 56815)
+++ trunk/blender/source/blender/editors/include/UI_view2d.h	2013-05-15 11:16:01 UTC (rev 56816)
@@ -189,7 +189,7 @@
                                       int *row_min, int *row_max);
 
 /* coordinate conversion */
-void UI_view2d_region_to_view(struct View2D *v2d, int x, int y, float *viewx, float *viewy);
+void UI_view2d_region_to_view(struct View2D *v2d, float x, float y, float *viewx, float *viewy);
 void UI_view2d_view_to_region(struct View2D *v2d, float x, float y, int *regionx, int *regiony);
 void UI_view2d_to_region_no_clip(struct View2D *v2d, float x, float y, int *regionx, int *region_y);
 

Modified: trunk/blender/source/blender/editors/interface/view2d.c
===================================================================
--- trunk/blender/source/blender/editors/interface/view2d.c	2013-05-15 11:10:59 UTC (rev 56815)
+++ trunk/blender/source/blender/editors/interface/view2d.c	2013-05-15 11:16:01 UTC (rev 56816)
@@ -1961,7 +1961,7 @@
  *	- x,y           = coordinates to convert
  *	- viewx,viewy		= resultant coordinates
  */
-void UI_view2d_region_to_view(View2D *v2d, int x, int y, float *r_viewx, float *r_viewy)
+void UI_view2d_region_to_view(View2D *v2d, float x, float y, float *r_viewx, float *r_viewy)
 {
 	float div, ofs;
 

Modified: trunk/blender/source/blender/editors/sculpt_paint/paint_image.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/paint_image.c	2013-05-15 11:10:59 UTC (rev 56815)
+++ trunk/blender/source/blender/editors/sculpt_paint/paint_image.c	2013-05-15 11:16:01 UTC (rev 56816)
@@ -446,7 +446,7 @@
 
 	void *custom_paint;
 
-	int prevmouse[2];
+	float prevmouse[2];
 	double starttime;
 
 	ViewContext vc;
@@ -545,13 +545,11 @@
 	float startsize = BKE_brush_size_get(scene, brush);
 	float startalpha = BKE_brush_alpha_get(scene, brush);
 
-	float mousef[2];
+	float mouse[2];
 	float pressure;
-	int mouse[2], redraw, eraser;
+	int redraw, eraser;
 
-	RNA_float_get_array(itemptr, "mouse", mousef);
-	mouse[0] = (int)(mousef[0]);
-	mouse[1] = (int)(mousef[1]);
+	RNA_float_get_array(itemptr, "mouse", mouse);
 	pressure = RNA_float_get(itemptr, "pressure");
 	eraser = RNA_boolean_get(itemptr, "pen_flip");
 

Modified: trunk/blender/source/blender/editors/sculpt_paint/paint_image_2d.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/paint_image_2d.c	2013-05-15 11:10:59 UTC (rev 56815)
+++ trunk/blender/source/blender/editors/sculpt_paint/paint_image_2d.c	2013-05-15 11:16:01 UTC (rev 56816)
@@ -1016,7 +1016,7 @@
 		image_undo_remove_masks();
 }
 
-int paint_2d_stroke(void *ps, const int prev_mval[2], const int mval[2], int eraser)
+int paint_2d_stroke(void *ps, const float prev_mval[2], const float mval[2], int eraser)
 {
 	float newuv[2], olduv[2];
 	int redraw = 0;

Modified: trunk/blender/source/blender/editors/sculpt_paint/paint_image_proj.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/paint_image_proj.c	2013-05-15 11:10:59 UTC (rev 56815)
+++ trunk/blender/source/blender/editors/sculpt_paint/paint_image_proj.c	2013-05-15 11:16:01 UTC (rev 56816)
@@ -3206,7 +3206,7 @@
 	BLI_linklist_free(image_LinkList, NULL);
 }
 
-static void paint_proj_begin_clone(ProjPaintState *ps, const int mouse[2])
+static void paint_proj_begin_clone(ProjPaintState *ps, const float mouse[2])
 {
 	/* setup clone offset */
 	if (ps->tool == PAINT_TOOL_CLONE) {
@@ -4044,23 +4044,17 @@
 }
 
 
-int paint_proj_stroke(bContext *C, void *pps, const int prevmval_i[2], const int mval_i[2])
+int paint_proj_stroke(bContext *C, void *pps, const float prev_pos[2], const float pos[2])
 {
 	ProjPaintState *ps = pps;
 	int a, redraw;
-	float pos[2], prev_pos[2];
 
-	pos[0] = (float)(mval_i[0]);
-	pos[1] = (float)(mval_i[1]);
-
-	prev_pos[0] = (float)(prevmval_i[0]);
-	prev_pos[1] = (float)(prevmval_i[1]);
-
 	/* clone gets special treatment here to avoid going through image initialization */
 	if (ps->tool == PAINT_TOOL_CLONE && ps->mode == BRUSH_STROKE_INVERT) {
 		Scene *scene = ps->scene;
 		View3D *v3d = ps->v3d;
 		float *cursor = give_cursor(scene, v3d);
+		int mval_i[2] = {(int)pos[0], (int)pos[1]};
 
 		view3d_operator_needs_opengl(C);
 
@@ -4160,7 +4154,7 @@
 	return;
 }
 
-void *paint_proj_new_stroke(bContext *C, Object *ob, const int mouse[2], int mode)
+void *paint_proj_new_stroke(bContext *C, Object *ob, const float mouse[2], int mode)
 {
 	ProjPaintState *ps = MEM_callocN(sizeof(ProjPaintState), "ProjectionPaintState");
 	project_state_init(C, ob, ps, mode);

Modified: trunk/blender/source/blender/editors/sculpt_paint/paint_intern.h
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/paint_intern.h	2013-05-15 11:10:59 UTC (rev 56815)
+++ trunk/blender/source/blender/editors/sculpt_paint/paint_intern.h	2013-05-15 11:16:01 UTC (rev 56816)
@@ -141,9 +141,9 @@
 void *paint_2d_new_stroke(struct bContext *, struct wmOperator *);
 void paint_2d_redraw(const bContext *C, void *ps, int final);
 void paint_2d_stroke_done(void *ps);
-int paint_2d_stroke(void *ps, const int prev_mval[2], const int mval[2], int eraser);
-void *paint_proj_new_stroke(struct bContext *C, struct Object *ob, const int mouse[2], int mode);
-int paint_proj_stroke(struct bContext *C, void *ps, const int prevmval_i[2], const int mval_i[2]);
+int paint_2d_stroke(void *ps, const float prev_mval[2], const float mval[2], int eraser);
+void *paint_proj_new_stroke(struct bContext *C, struct Object *ob, const float mouse[2], int mode);
+int paint_proj_stroke(struct bContext *C, void *ps, const float prevmval_i[2], const float mval_i[2]);
 void paint_proj_stroke_done(void *ps);
 void paint_brush_init_tex(struct Brush *brush);
 void paint_brush_exit_tex(struct Brush *brush);




More information about the Bf-blender-cvs mailing list