diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-06-06 12:43:17 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-06-06 12:43:17 +0400 |
commit | 2f5c7623b08027a7bb0d433333ad62c787c05cbf (patch) | |
tree | ffa390dd11831fcefe82c07e2ec4e0fedcdb50ed /source | |
parent | 7b9eabb6f202e116e11341f1b6f1c703823a941e (diff) |
fix/workaround [#27559] Color picker fails with a very small brush
fade out small brushes so the brush wont interfere with the color directly under the cursor.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_image.c | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index db0d2314ad0..e0877fafbaa 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -5012,31 +5012,45 @@ static int get_imapaint_zoom(bContext *C, float *zoomx, float *zoomy) static void brush_drawcursor(bContext *C, int x, int y, void *UNUSED(customdata)) { +#define PX_SIZE_FADE_MAX 12.0f +#define PX_SIZE_FADE_MIN 4.0f + Brush *brush= image_paint_brush(C); Paint *paint= paint_get_active(CTX_data_scene(C)); - if(paint && brush) { + if(paint && brush && paint->flags & PAINT_SHOW_BRUSH) { float zoomx, zoomy; + const float size= (float)brush_size(brush); + const short use_zoom= get_imapaint_zoom(C, &zoomx, &zoomy); + const float pixel_size= MAX2(size * zoomx, size * zoomy); + float alpha= 0.5f; - if(!(paint->flags & PAINT_SHOW_BRUSH)) + /* fade out the brush (cheap trick to work around brush interfearing with sampling [#])*/ + if(pixel_size < PX_SIZE_FADE_MIN) { return; + } + else if (pixel_size < PX_SIZE_FADE_MAX) { + alpha *= (pixel_size - PX_SIZE_FADE_MIN) / (PX_SIZE_FADE_MAX - PX_SIZE_FADE_MIN); + } glPushMatrix(); glTranslatef((float)x, (float)y, 0.0f); - if(get_imapaint_zoom(C, &zoomx, &zoomy)) + if(use_zoom) glScalef(zoomx, zoomy, 1.0f); - glColor4f(brush->add_col[0], brush->add_col[1], brush->add_col[2], 0.5f); + glColor4f(brush->add_col[0], brush->add_col[1], brush->add_col[2], alpha); glEnable( GL_LINE_SMOOTH ); glEnable(GL_BLEND); - glutil_draw_lined_arc(0, (float)(M_PI*2.0), (float)brush_size(brush), 40); + glutil_draw_lined_arc(0, (float)(M_PI*2.0), size, 40); glDisable(GL_BLEND); glDisable( GL_LINE_SMOOTH ); glPopMatrix(); } +#undef PX_SIZE_FADE_MAX +#undef PX_SIZE_FADE_MIN } static void toggle_paint_cursor(bContext *C, int enable) |