[Bf-blender-cvs] [77698f6] master: Fix T43556 clamp brush size before setting it after division by DPI, avoids nasty zero size brushes.

Antony Riakiotakis noreply at git.blender.org
Thu Feb 5 19:15:42 CET 2015


Commit: 77698f601021eb557be38945ed74706a325b1c57
Author: Antony Riakiotakis
Date:   Thu Feb 5 19:11:00 2015 +0100
Branches: master
https://developer.blender.org/rB77698f601021eb557be38945ed74706a325b1c57

Fix T43556 clamp brush size before setting it after division by DPI,
avoids nasty zero size brushes.

===================================================================

M	source/blender/blenkernel/intern/brush.c
M	source/blender/editors/sculpt_paint/paint_image_proj.c
M	source/blender/editors/sculpt_paint/paint_ops.c

===================================================================

diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index 082a4cf..10d7792 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -810,6 +810,9 @@ void BKE_brush_size_set(Scene *scene, Brush *brush, int size)
 	
 	size = (int)((float)size / U.pixelsize);
 	
+	/* make sure range is sane */
+	CLAMP(size, 1, MAX_BRUSH_PIXEL_RADIUS);
+
 	if (ups->flag & UNIFIED_PAINT_SIZE)
 		ups->size = size;
 	else
diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c
index 91cabca..1216983 100644
--- a/source/blender/editors/sculpt_paint/paint_image_proj.c
+++ b/source/blender/editors/sculpt_paint/paint_image_proj.c
@@ -4923,7 +4923,7 @@ void *paint_proj_new_stroke(bContext *C, Object *ob, const float mouse[2], int m
 
 	/* Don't allow brush size below 2 */
 	if (BKE_brush_size_get(ps->scene, ps->brush) < 2)
-		BKE_brush_size_set(ps->scene, ps->brush, 2);
+		BKE_brush_size_set(ps->scene, ps->brush, 2 * U.pixelsize);
 
 	/* allocate and initialize spatial data structures */
 	project_paint_begin(ps);
@@ -5042,7 +5042,7 @@ static int texture_paint_camera_project_exec(bContext *C, wmOperator *op)
 	ps.is_maskbrush = false;
 	ps.do_masking = false;
 	orig_brush_size = BKE_brush_size_get(scene, ps.brush);
-	BKE_brush_size_set(scene, ps.brush, 32); /* cover the whole image */
+	BKE_brush_size_set(scene, ps.brush, 32 * U.pixelsize); /* cover the whole image */
 
 	ps.tool = PAINT_TOOL_DRAW; /* so pixels are initialized with minimal info */
 
diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c
index 46d7b47..09c3047 100644
--- a/source/blender/editors/sculpt_paint/paint_ops.c
+++ b/source/blender/editors/sculpt_paint/paint_ops.c
@@ -106,15 +106,14 @@ static int brush_scale_size_exec(bContext *C, wmOperator *op)
 			const int old_size = BKE_brush_size_get(scene, brush);
 			int size = (int)(scalar * old_size);
 
-			if (old_size == size) {
+			if (fabs(old_size - size) < U.pixelsize) {
 				if (scalar > 1) {
-					size++;
+					size += U.pixelsize;
 				}
 				else if (scalar < 1) {
-					size--;
+					size -= U.pixelsize;
 				}
 			}
-			CLAMP(size, 1, MAX_BRUSH_PIXEL_RADIUS); // XXX magic number, same as max for RNA
 
 			BKE_brush_size_set(scene, brush, size);
 		}




More information about the Bf-blender-cvs mailing list