diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2013-05-01 23:50:37 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2013-05-01 23:50:37 +0400 |
commit | d7e835684687770bafe3584b6a2485d692deeb15 (patch) | |
tree | b6e899a3e2de055d6087759a4794aaaf6135d845 | |
parent | 9fe63e82c38b9f4ea28929ab7bc144f6d4089d31 (diff) |
Fix 2D painting gave squares rather than a disk for the "Max" curve falloff shape.
-rw-r--r-- | source/blender/blenkernel/intern/brush.c | 12 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_cursor.c | 4 |
2 files changed, 8 insertions, 8 deletions
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 */ diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c index b72a284864c..8574d6b8a8f 100644 --- a/source/blender/editors/sculpt_paint/paint_cursor.c +++ b/source/blender/editors/sculpt_paint/paint_cursor.c @@ -377,10 +377,8 @@ static int load_tex_cursor(Brush *br, ViewContext *vc, float zoom) len = sqrtf(x * x + y * y); if (len <= 1) { - float avg = BKE_brush_curve_strength(br, len, 1.0f); /* Falloff curve */ + float avg = BKE_brush_curve_strength_clamp(br, len, 1.0f); /* Falloff curve */ - /* clamp to avoid precision overflow */ - CLAMP(avg, 0.0f, 1.0f); buffer[index] = 255 - (GLubyte)(255 * avg); } |