diff options
author | Antony Riakiotakis <kalast@gmail.com> | 2015-02-05 21:11:00 +0300 |
---|---|---|
committer | Antony Riakiotakis <kalast@gmail.com> | 2015-02-05 21:11:00 +0300 |
commit | 77698f601021eb557be38945ed74706a325b1c57 (patch) | |
tree | f6c968732dca8b44c845ad177f03e34d5f480e0b /source | |
parent | a1ec1b3974e81108f5d017d0a1fdcede7419ee99 (diff) |
Fix T43556 clamp brush size before setting it after division by DPI,
avoids nasty zero size brushes.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/intern/brush.c | 3 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_image_proj.c | 4 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_ops.c | 7 |
3 files changed, 8 insertions, 6 deletions
diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index 082a4cf34c2..10d77921515 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 91cabcaee9f..1216983fec9 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 46d7b47adec..09c30479860 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); } |