diff options
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_cursor.c | 8 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_image.c | 65 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_intern.h | 1 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_stroke.c | 25 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_vertex.c | 10 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/sculpt_uv.c | 44 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_scene_types.h | 2 |
7 files changed, 62 insertions, 93 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c index 97c2a5bdee6..97c1a994629 100644 --- a/source/blender/editors/sculpt_paint/paint_cursor.c +++ b/source/blender/editors/sculpt_paint/paint_cursor.c @@ -597,7 +597,7 @@ static void paint_draw_tex_overlay(UnifiedPaintSettings *ups, Brush *brush, /* scale based on tablet pressure */ if (primary && ups->stroke_active && BKE_brush_use_size_pressure(vc->scene, brush)) { glTranslatef(0.5f, 0.5f, 0); - glScalef(1.0f / ups->pressure_value, 1.0f / ups->pressure_value, 1); + glScalef(1.0f / ups->size_pressure_value, 1.0f / ups->size_pressure_value, 1); glTranslatef(-0.5f, -0.5f, 0); } @@ -725,7 +725,7 @@ static void paint_draw_cursor_overlay(UnifiedPaintSettings *ups, Brush *brush, glPushMatrix(); glLoadIdentity(); glTranslatef(center[0], center[1], 0); - glScalef(ups->pressure_value, ups->pressure_value, 1); + glScalef(ups->size_pressure_value, ups->size_pressure_value, 1); glTranslatef(-center[0], -center[1], 0); } @@ -815,7 +815,7 @@ static void paint_cursor_on_hit(UnifiedPaintSettings *ups, Brush *brush, ViewCon /* scale 3D brush radius by pressure */ if (ups->stroke_active && BKE_brush_use_size_pressure(vc->scene, brush)) - unprojected_radius *= ups->pressure_value; + unprojected_radius *= ups->size_pressure_value; /* set cached value in either Brush or UnifiedPaintSettings */ BKE_brush_unprojected_radius_set(vc->scene, brush, unprojected_radius); @@ -910,7 +910,7 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused)) /* draw an inner brush */ if (ups->stroke_active && BKE_brush_use_size_pressure(scene, brush)) { /* inner at full alpha */ - glutil_draw_lined_arc(0.0, M_PI * 2.0, final_radius * ups->pressure_value, 40); + glutil_draw_lined_arc(0.0, M_PI * 2.0, final_radius * ups->size_pressure_value, 40); /* outer at half alpha */ glColor4f(outline_col[0], outline_col[1], outline_col[2], outline_alpha * 0.5f); } diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 2f4caeeef1b..69610645228 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -718,71 +718,6 @@ int get_imapaint_zoom(bContext *C, float *zoomx, float *zoomy) /************************ cursor drawing *******************************/ -void brush_drawcursor_texpaint_uvsculpt(bContext *C, int x, int y, void *UNUSED(customdata)) -{ -#define PX_SIZE_FADE_MAX 12.0f -#define PX_SIZE_FADE_MIN 4.0f - - Scene *scene = CTX_data_scene(C); - //Brush *brush = image_paint_brush(C); - Paint *paint = BKE_paint_get_active_from_context(C); - Brush *brush = BKE_paint_brush(paint); - - if (paint && brush && paint->flags & PAINT_SHOW_BRUSH) { - float zoomx, zoomy; - const float size = (float)BKE_brush_size_get(scene, brush); - short use_zoom; - float pixel_size; - float alpha = 0.5f; - - use_zoom = get_imapaint_zoom(C, &zoomx, &zoomy); - - if (use_zoom) { - pixel_size = size * max_ff(zoomx, zoomy); - } - else { - pixel_size = size; - } - - /* fade out the brush (cheap trick to work around brush interfering 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); - - /* No need to scale for uv sculpting, on the contrary it might be useful to keep un-scaled */ - if (use_zoom) - glScalef(zoomx, zoomy, 1.0f); - - glColor4f(brush->add_col[0], brush->add_col[1], brush->add_col[2], alpha); - glEnable(GL_LINE_SMOOTH); - glEnable(GL_BLEND); - { - UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings; - /* hrmf, duplicate paint_draw_cursor logic here */ - if (ups->stroke_active && BKE_brush_use_size_pressure(scene, brush)) { - /* inner at full alpha */ - glutil_draw_lined_arc(0, (float)(M_PI * 2.0), size * ups->pressure_value, 40); - /* outer at half alpha */ - glColor4f(brush->add_col[0], brush->add_col[1], brush->add_col[2], alpha * 0.5f); - } - } - 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) { wmWindowManager *wm = CTX_wm_manager(C); diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h index 0c3cdc7a205..bdb1c88c0ce 100644 --- a/source/blender/editors/sculpt_paint/paint_intern.h +++ b/source/blender/editors/sculpt_paint/paint_intern.h @@ -201,7 +201,6 @@ void paint_calc_redraw_planes(float planes[4][4], float paint_calc_object_space_radius(struct ViewContext *vc, const float center[3], float pixel_radius); float paint_get_tex_pixel(struct MTex *mtex, float u, float v, struct ImagePool *pool, int thread); void paint_get_tex_pixel_col(struct MTex *mtex, float u, float v, float rgba[4], struct ImagePool *pool, int thread, bool convert, struct ImBuf *ibuf); -void brush_drawcursor_texpaint_uvsculpt(struct bContext *C, int x, int y, void *customdata); void paint_sample_color(const struct bContext *C, struct ARegion *ar, int x, int y); void BRUSH_OT_curve_preset(struct wmOperatorType *ot); diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c index 15f21cc44c8..a8f3a6cbc72 100644 --- a/source/blender/editors/sculpt_paint/paint_stroke.c +++ b/source/blender/editors/sculpt_paint/paint_stroke.c @@ -98,7 +98,7 @@ typedef struct PaintStroke { bool brush_init; float initial_mouse[2]; /* cached_pressure stores initial pressure for size pressure influence mainly */ - float cached_pressure; + float cached_size_pressure; /* last pressure will store last pressure value for use in interpolation for space strokes */ float last_pressure; @@ -166,22 +166,30 @@ static void paint_brush_update(bContext *C, Brush *brush, PaintMode mode, * brush coord/pressure/etc. * It's more an events design issue, which doesn't split coordinate/pressure/angle * changing events. We should avoid this after events system re-design */ - if (paint_supports_dynamic_size(brush, mode) || !stroke->brush_init) { + if(!stroke->brush_init) { copy_v2_v2(stroke->initial_mouse, mouse); + copy_v2_v2(ups->last_rake, mouse); copy_v2_v2(ups->tex_mouse, mouse); copy_v2_v2(ups->mask_tex_mouse, mouse); - stroke->cached_pressure = pressure; + stroke->cached_size_pressure = pressure; + stroke->brush_init = true; + } + + if (paint_supports_dynamic_size(brush, mode)) { + copy_v2_v2(ups->tex_mouse, mouse); + copy_v2_v2(ups->mask_tex_mouse, mouse); + stroke->cached_size_pressure = pressure; } /* Truly temporary data that isn't stored in properties */ ups->stroke_active = true; - ups->pressure_value = stroke->cached_pressure; + ups->size_pressure_value = stroke->cached_size_pressure; ups->pixel_radius = BKE_brush_size_get(scene, brush); if (BKE_brush_use_size_pressure(scene, brush) && paint_supports_dynamic_size(brush, mode)) { - ups->pixel_radius *= stroke->cached_pressure; + ups->pixel_radius *= stroke->cached_size_pressure; } if (paint_supports_dynamic_tex_coords(brush, mode)) { @@ -251,13 +259,8 @@ static void paint_brush_update(bContext *C, Brush *brush, PaintMode mode, ups->draw_anchored = true; } else if (brush->flag & BRUSH_RAKE) { - if (!stroke->brush_init) - copy_v2_v2(ups->last_rake, mouse); - else - paint_calculate_rake_rotation(ups, mouse); + paint_calculate_rake_rotation(ups, mouse); } - - stroke->brush_init = true; } diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index d90f9a80b37..1d127cd5f4e 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -2496,11 +2496,6 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P swap_m4m4(vc->rv3d->persmat, mat); - { - UnifiedPaintSettings *ups = &ts->unified_paint_settings; - ups->pressure_value = pressure; - } - DAG_id_tag_update(ob->data, 0); ED_region_tag_redraw(vc->ar); } @@ -3017,11 +3012,6 @@ static void vpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P do_shared_vertexcol(me, vpd->mlooptag, vpd->mfacetag, do_tessface); } - { - UnifiedPaintSettings *ups = &ts->unified_paint_settings; - ups->pressure_value = pressure; - } - ED_region_tag_redraw(vc->ar); if (vpd->use_fast_update == false) { diff --git a/source/blender/editors/sculpt_paint/sculpt_uv.c b/source/blender/editors/sculpt_paint/sculpt_uv.c index da2b62bce8b..c064612a551 100644 --- a/source/blender/editors/sculpt_paint/sculpt_uv.c +++ b/source/blender/editors/sculpt_paint/sculpt_uv.c @@ -68,6 +68,9 @@ #include "paint_intern.h" #include "uvedit_intern.h" +#include "BIF_gl.h" +#include "BIF_glutil.h" + #include "UI_view2d.h" #define MARK_BOUNDARY 1 @@ -185,6 +188,45 @@ static int uv_sculpt_brush_poll(bContext *C) return 0; } +static void brush_drawcursor_uvsculpt(bContext *C, int x, int y, void *UNUSED(customdata)) +{ +#define PX_SIZE_FADE_MAX 12.0f +#define PX_SIZE_FADE_MIN 4.0f + + Scene *scene = CTX_data_scene(C); + //Brush *brush = image_paint_brush(C); + Paint *paint = BKE_paint_get_active_from_context(C); + Brush *brush = BKE_paint_brush(paint); + + if (paint && brush && paint->flags & PAINT_SHOW_BRUSH) { + const float size = (float)BKE_brush_size_get(scene, brush); + float alpha = 0.5f; + + /* fade out the brush (cheap trick to work around brush interfering with sampling [#])*/ + if (size < PX_SIZE_FADE_MIN) { + return; + } + else if (size < PX_SIZE_FADE_MAX) { + alpha *= (size - PX_SIZE_FADE_MIN) / (PX_SIZE_FADE_MAX - PX_SIZE_FADE_MIN); + } + + glPushMatrix(); + + glTranslatef((float)x, (float)y, 0.0f); + + 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), size, 40); + glDisable(GL_BLEND); + glDisable(GL_LINE_SMOOTH); + + glPopMatrix(); + } +#undef PX_SIZE_FADE_MAX +#undef PX_SIZE_FADE_MIN +} + void ED_space_image_uv_sculpt_update(wmWindowManager *wm, ToolSettings *settings) { @@ -201,7 +243,7 @@ void ED_space_image_uv_sculpt_update(wmWindowManager *wm, ToolSettings *settings BKE_paint_init(&settings->uvsculpt->paint, PAINT_CURSOR_SCULPT); WM_paint_cursor_activate(wm, uv_sculpt_brush_poll, - brush_drawcursor_texpaint_uvsculpt, NULL); + brush_drawcursor_uvsculpt, NULL); } else { if (settings->uvsculpt) diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index b92aafd610b..aada838fce5 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -941,7 +941,7 @@ typedef struct UnifiedPaintSettings { int stroke_active; /* drawing pressure */ - float pressure_value; + float size_pressure_value; /* position of mouse, used to sample the texture */ float tex_mouse[2]; |