-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
New #resolveCrossing() does not handle 'nonzero' fill-rule properly. #869
Comments
@iconexperience I am going to compare it with the old #reorient() now to spot the differences. |
The change happened here: a3a3a2e |
Interesting! Your code does this: path.setClockwise((counter % 2 === 0) === clockwise); The old code was doing this: path.setClockwise((counter % 2 === 0) && clockwise); And that works! So the comparison is different based on the rule. |
Yes, that seems to be a problem. My thought behind the change was that the rule will not work if the first child is anti-clockwise. I still think that this is a prolem, but it looks like my solution is not working well. |
Yeah if I switch to the old way, then your example isn't working anymore. :/ |
But why isn't this example working? it's only two children, already alternating orientation, the first one is clockwise, nothing special at all. It should work. |
I think the outer path is not clockwise, that's why... |
Here some debug logging for the child:
|
Wow, the interior point of the second child is not inside the first one: |
Watch out though, you're running on an old library... But I do get |
Oh, the inner path is child zero, the outer child one. |
yes, just realized the same : ) |
Here's what I propose: After sorting the children, we set the first one to clockwise always. We do the same already for normal paths anyway:
|
This works like a charm, with your example as well as all my other tests: Sketch |
Hmm, what if we use the original orientation from before |
I don't think that will improve the situation. With the example above, the first child is the inside of the path, which is completely strange. And we've always set If we allow the main path to be counter clockwise, then subtracting it will actually add it... |
Or maybe I'm wrong about that last assumption. |
It works with this example:smile: I see a problem if for two overlapping compound paths one of them changes orientation. I do not know how realistic this scenario is in a real world scenario. |
I'm happy to preserve orientation if there's a way to actually make it work with this example. I don't think your suggestion would fix it. |
Oh wait, yes the first child is clockwise... Hmmm. |
Ok, I have it: Updated Sketch I need to start with the winding number for the first child as the starting counter, and then just use |
Here is another sketch where the larger circles are stacked on top of the smaller ones. Your change works, but give me ten minutes to see if I find a way to keep the original orientation. |
And actually, |
I'm sorry, I'm tired. I forgot to remove that line... Now here's the up-to-date version, with |
There are some cases where it fails. Just press "run" several times and watch the circles at the bottom. This is tricky. |
Yeah I just saw that too... I'm giving up for the day, brain fried. Setting clockwise to |
Yes, but give me time until tomorrow afternoon to see if there is an easy way to keep orientation. You did some amazing work today. |
Here is a version that keeps the orientation of the original first child. But does it make sense at all to keep the orientation of the first child? Or should we keep the orientation of the bottom child(ren)? I will think about it after some sleep. |
And here is a version that keeps the original orientation of the bottom children (the ones that have no containing, larger child). Currently I like this one best, but let's sleep first. Note that in the last two examples we iterate through all children (including the largest). |
Very cool! What about this one, then? |
If you start from index 1, you certainly have to add the first child to the items previously. Does it still not work? And the difference now is that all the bottom children (the ones that are not contained in another child) will have the same orientation. Maybe that's the right way to go. |
This solves some regressions, e.g. #869 (comment)
Perform a handle bounds check before calculating winding, as described by @iconexperience in #869
This solves some regressions, e.g. #869 (comment)
@lehni var cp = new CompoundPath();
cp.addChild(new Path.Circle(100, 100, 50));
cp.addChild(new Path.Circle(100, 100, 30));
cp.addChild(new Path.Circle(200, 100, 20));
cp.fullySelected = true; It looks like this (I have added the index that the children have after sorting in What is happening is this: To solve this, we have to set ``clockwise = first.isClockwise()` for each child, not only once at the beginning. Solving this should also solve issue #877. |
Yes that makes sense! But I discovered some other issues that are linked to this change, mainly: Sketch Both paths have counter-clockwise orientation and now they both remain counter-clockwise. I wonder if that's the reason why the |
Hmm but are you sure that solves it? Doesn't seem to a my end... |
It works on my side. I pull the |
Not for me, on the |
Oh, I see now. Your example has an error and I fixed it wrongly. |
Regarding the issue described in #869 (comment) It turns out that this is simply a bezier clipping problem again, as some intersections aren't found when the paths are oriented the other way. And like with all the others, this one too gets fixed by #863 @iconexperience this has me wondering why we're not just merging that one in? I really haven't come across a situation that it doesn't handle yet. |
I'm proposing that because I keep ending up in situations where I spend time debugging a case that would already be solved if this was merged in. And merging it in doesn't mean you can't keep improving fat-line clipping in parallel! : ) |
Yes, I was about to propose the same. I can then test with the new code. Basically, what I expected to find were some edge cases that take extraordinarily long time to solve with fat line clipping. If you take any curve, divide it somewhere and then try to find the intersections, fat line clipping will theoretically iterate forever at the point where the curve was divided. But there seem to be other cases that fill the whole tree (or a huge part of it), which is 2^24=16,777,216 calls to Alright, let's merge the sucker and I will then try to find these elusive cases without pressure. |
Perform a handle bounds check before calculating winding, as described by @iconexperience in #869
This solves some regressions, e.g. #869 (comment)
@iconexperience oh fuck merging #864 in seems to have messed tons of things up now. I get all these commit messages twice now, see above... |
You broke the intenet!!! 😄 Unfortunately there is nothing I can do for you in this case. Creating a pull request is my highest achievement in Git so far. |
I don't really understand it either... Now I'm worried something else is missing. Argh. |
I think it's because I accidentally did a rebase instead of a merge. Oh well, should be all there. |
Example:
Result:
The text was updated successfully, but these errors were encountered: