Kruptein / PlanarAlly

A companion tool for when you travel into the planes.
https://www.planarally.io/
MIT License
400 stars 73 forks source link

feat(DrawTool): Reduce the number of points when using brush mode #1269

Closed Kruptein closed 1 year ago

Kruptein commented 1 year ago

I'm unsure whether I would classify this as a change or a bugfix :D.

The brush mode in the draw tool has been an eye sore for a loong time. It exists, but is a performance hog which means you probably should avoid it at almost all times.

The reason for that performance issue was with how the shape is stored internally. Behind the scenes it's exactly the same kind of structure as a shape drawn with the polygon tool, but the difference is in their creation. In polygon mode, you dictate the points with clicks, whereas in brush mode your mouse drag dictates the polygon.

Long story short, the mouse drag was adding a lot of points. This PR implements an algorithm that will during a drag simplify the polygon by trying to remove points that contribute close to nothing to the actual shape.

Some small changes in the overall shape might occur, but they should be very subtle if any.