Fix T43556 clamp brush size before setting it after division by DPI,

avoids nasty zero size brushes.
This commit is contained in:
Antonis Ryakiotakis 2015-02-05 19:11:00 +01:00
parent a1ec1b3974
commit 77698f6010
Notes: blender-bot 2023-02-14 09:31:59 +01:00
Referenced by issue #43556, Brush radius getting stuck when 8 pixels or smaller (retina display, Yosemite)
3 changed files with 8 additions and 6 deletions

View File

@ -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

View File

@ -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 */

View File

@ -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);
}