From d7e835684687770bafe3584b6a2485d692deeb15 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 1 May 2013 19:50:37 +0000 Subject: Fix 2D painting gave squares rather than a disk for the "Max" curve falloff shape. --- source/blender/blenkernel/intern/brush.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'source/blender/blenkernel/intern/brush.c') diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index f69b11135c5..621c41c3df7 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -845,7 +845,7 @@ void BKE_brush_imbuf_new(const Scene *scene, Brush *brush, bool use_float, xy[1] = y + yoff; if (fill == BRUSH_IMBUF_MASK) { - alpha_f = alpha * BKE_brush_curve_strength(brush, len_v2(xy), radius); + alpha_f = alpha * BKE_brush_curve_strength_clamp(brush, len_v2(xy), radius); dst[0] = crgb[0]; dst[1] = crgb[1]; @@ -1067,15 +1067,17 @@ void BKE_brush_randomize_texture_coordinates(UnifiedPaintSettings *ups, bool mas /* Uses the brush curve control to find a strength value between 0 and 1 */ float BKE_brush_curve_strength_clamp(Brush *br, float p, const float len) { + float strength; + if (p >= len) return 0; else p = p / len; curvemapping_initialize(br->curve); - p = curvemapping_evaluateF(br->curve, 0, p); + strength = curvemapping_evaluateF(br->curve, 0, p); + + CLAMP(strength, 0.0f, 1.0f); - if (p < 0.0f) p = 0.0f; - else if (p > 1.0f) p = 1.0f; - return p; + return strength; } /* same as above but can return negative values if the curve enables * used for sculpt only */ -- cgit v1.2.3