OSDN Git Service

brushlib: fix bug with smudge_length=0
authorMartin Renold <martinxyz@gmx.ch>
Fri, 28 Oct 2011 17:25:17 +0000 (19:25 +0200)
committerMartin Renold <martinxyz@gmx.ch>
Fri, 28 Oct 2011 17:34:56 +0000 (19:34 +0200)
For brushes with smudge_length=0 (eg. in Ramon's concept art brushset)
smudging was broken by my optimization 5dd46ce. For performance reasons
we force smudge_length to be greater than 0.01 now.

Ramon's concept art brushset uses a tiny smudge radius, so neither
this commit nor my previous one affects their performance.

Reminder to brush creators: increasing smudge_length does improve
brush performance with the new code. Instead of using a tiny
smudge radius (which can result in faster-than-expected smudge
color changes) you can use a normal smudge radius and increase
smudge_length instead to get performance.

brushlib/brush.hpp

index fc761d6..20d4109 100644 (file)
@@ -456,14 +456,15 @@ private:
         (settings_value[BRUSH_SMUDGE] != 0.0 or not settings[BRUSH_SMUDGE]->is_constant())) {
 
       float fac = settings_value[BRUSH_SMUDGE_LENGTH];
-      if (fac < 0.0) fac = 0;
+      if (fac < 0.01) fac = 0.01;
       int px, py;
       px = ROUND(x);
       py = ROUND(y);
 
       // Calling get_color() is almost as expensive as rendering a
       // dab. Because of this we use the previous value if it is not
-      // expected to hurt quality too much.
+      // expected to hurt quality too much. We call it at most every
+      // second dab.
       float r, g, b, a;
       states[STATE_LAST_GETCOLOR_RECENTNESS] *= fac;
       if (states[STATE_LAST_GETCOLOR_RECENTNESS] < 0.5*fac) {