mypaint / libmypaint

libmypaint, a.k.a. "brushlib", is a library for making brushstrokes which is used by MyPaint and other projects.
http://mypaint.org
Other
307 stars 87 forks source link

Brush sampling skipping cause brush to restart in undo stack #173

Closed ChengduLittleA closed 4 years ago

ChengduLittleA commented 4 years ago

This is a bug for brush undo.

Description of the problem

if the brush's tracking noise is set (like the default oil brush), then one stroke can be separated into many strokes if the stylus is moving slow, e.g. during the sharp direction change there's often a stroke split. This cause the undo stack being filled up rapidly within one stroke.

Basic system details

MyPaint version: 2.1.0-alpha+git.984ded6a

Steps to reproduce

  1. Start MyPaint
  2. Choose the oil brush, or any brush but set the "tracking noise" to non-zero value.
  3. Draw some zig-zag lines.
  4. ctrl-z for several times, you will see the stroke gets broken up on the corners.
  5. it also breaks up if you draw very slowly.

My hack

in int mypaint_brush_stroke_to() function, change this part:

    if (self->skip > 0.001 && !(dtime > max_dtime || self->reset_requested))
      return FALSE; // <------ this used to be TRUE (which means to split a stroke)

Now the brush still follow the skip stuff logically, but the stroke will keep as one stroke, so the noise doesn't over fill the undo-stack.

jplloyd commented 4 years ago

As far as I'm concerned, your hack is the correct fix. I think when #83 was merged, the relevant brushes weren't actually tested (only 17 of the 177 standard brushes use the tracking_noise setting and none of the old experimental offset brushes used it).

I've noticed (and been annoyed by) this issue before, but didn't put the time in to find the cause. Thank you very much for figuring it out!

Do you mind if I make you the author (git commit --author="... <...>") of the commit fixing this?

jplloyd commented 4 years ago

Forgot to close this, it was fixed in: ce42f5120c93919292e5e1e25881aa4f243f2c55 (0c1c7cd90df771cb8447c329301508da9ec81019 in the libmypaint-v1.5.x branch)

ChengduLittleA commented 4 years ago

Oh Thanks for the help! I see it was fixed. :D