Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RVPaint fix segment edge intersection when path has variable widths #439

Conversation

markreidvfx
Copy link
Contributor

This fixes an issue when using the annotation tools and having strokes with variable widths.

Variable widths happen when you use a stylus/wacom tablet with pen pressure. When widths can vary, it is possible for the widths of the stroke be just right so that the extruded edges become nearly parallel. This case currently isn't being handled. This creates "spikes" on your brush stroke that can seemly appear at random.

Example Of The Spikes Occurring

321366638-4e34798a-e64f-40a8-a400-9209c8c5c0e0.1.mp4

Isolated Case

Here is a minimal isolated case of the issue happening spike_isolated.rv.

image

I also graphed the polygons in desmos so its easier to see
https://www.desmos.com/calculator/gxmkrpdr2o

The issue occurs when the point of intersection is calculated between line segments AB and CD.
image

As we can see the two lines are is nearly parallel.
image

When intersection point is calculated, away we go!
image

The Solution

To fix this issue, I changed the code to perform the intersection as if the line has a constant width. This was the simplest thing I could think of. The spikes never seem to happen with constant width strokes.

Signed-off-by: Mark Reid <mark.reid@animallogic.ca>
Copy link
Contributor

@bernie-laberge bernie-laberge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm afraid I don't have anything better to propose so your proposed change looks good to me.
Many thanks for the fix and for such a nice PR description !

@bernie-laberge bernie-laberge merged commit 950ec03 into AcademySoftwareFoundation:main May 23, 2024
2 checks passed
chxmberland pushed a commit to chxmberland/OpenRV that referenced this pull request May 28, 2024
…cademySoftwareFoundation#439)

This fixes an issue when using the annotation tools and having strokes
with variable widths.

Variable widths happen when you use a stylus/wacom tablet with pen
pressure. When widths can vary, it is possible for the widths of the
stroke be just right so that the extruded edges become nearly parallel.
This case currently isn't being handled. This creates "spikes" on your
brush stroke that can seemly appear at random.

## Example Of The Spikes Occurring

https://github.com/AcademySoftwareFoundation/OpenRV/assets/814966/b7f1dd3f-1eee-4d62-97ec-add94ac12e11

## Isolated Case
Here is a minimal isolated case of the issue happening
[spike_isolated.rv.](https://github.com/AcademySoftwareFoundation/OpenRV/files/14950061/spike_isolated.rv.zip)

![image](https://github.com/AcademySoftwareFoundation/OpenRV/assets/814966/81f53ac9-2775-439d-b3e7-493e1b0ddf1f)

I also graphed the polygons in desmos so its easier to see
https://www.desmos.com/calculator/gxmkrpdr2o

The issue occurs when the point of intersection is calculated between
line segments AB and CD.

![image](https://github.com/AcademySoftwareFoundation/OpenRV/assets/814966/a6963e34-5377-45a9-a33d-dc64e0416e84)

As we can see the two lines are is nearly parallel.

![image](https://github.com/AcademySoftwareFoundation/OpenRV/assets/814966/55ebb6e0-5099-41ff-9a20-c4180924615f)

When intersection point is calculated, away we go!

![image](https://github.com/AcademySoftwareFoundation/OpenRV/assets/814966/033dfef3-c2d5-4cf1-8cf1-cb6864c0b3a1)

## The Solution

To fix this issue, I changed the code to perform the intersection as if
the line has a constant width. This was the simplest thing I could think
of. The spikes never seem to happen with constant width strokes.

Signed-off-by: Mark Reid <mark.reid@animallogic.ca>
Co-authored-by: Bernard Laberge <117092886+bernie-laberge@users.noreply.github.com>
Signed-off-by: Ben Chamberland <becha9260@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants