-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Fixed inner miter point adjustment when on opposite side of corner #6545
Conversation
Codecov Report
@@ Coverage Diff @@
## dev #6545 +/- ##
=======================================
Coverage 82.38% 82.38%
=======================================
Files 38 38
Lines 1902 1902
=======================================
Hits 1567 1567
Misses 335 335 Continue to review full report at Codecov.
|
Better, but seems like the square in the lower-left is busted now: https://pixijs.io/examples/?v=fix-6543#/graphics/advanced.js https://pixijs.io/examples/?v=v5.2.1#/graphics/advanced.js Here's a fiddle with just the broken bit: |
@bigtimebuddy Was the square busted before this PR too? Or is it because of this change? |
Looks like because of this change. |
@SukantPal any ideas? |
@bigtimebuddy I know where the problem is coming from. The math is incorrect. I’ll get this sorted tomorrow. It is because of the code where I prevent the inner miter point from being on the opposite side of the corner. |
@bigtimebuddy I also want to present a formal (mathematical) proof that my fix will work and why. |
Proofs are good things, but please do make refs , where those formulas exist in other renderers. Nothing bad in peeking at other people stuff to check for possible mistakes and places where you are actually smarter ;) Refs are also important for math articles! |
@ivanpopelyshev I'll try. |
@bigtimebuddy Why are the tests failing in CI? Something related to |
Okay, this bug was related to the code that "prevented the inner miter point from being on the opposite side of the corner". By doing so, you eliminate a rare class of bugs that arise at high line widths. This animation will show you what happens when the width gets to large eventually: https://jsfiddle.net/ShukantPal/fhkd2r85/. Specifically, focus on the "inner" point of the joint. It rapidly rises up, as you would expect, however, it overshoots the first & last points, looking like this: Let me take an example in a Cartesian plane (no y-inversion): connect the points (0, 0), (10, 100), (20, 0) with a variable line width.
I have setup a guide showing the math behind this here: https://www.desmos.com/calculator/gtyqjkoad6 |
To prevent the inner miter joint from going onto the other side, we can take check for "same-sidedness" of the it and the joint (p1) w.r.t the line joining p0 & p2. This guide explains how that works: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me: https://jsfiddle.net/bigtimebuddy/g739qveb/
#6543