-
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
CompoundPath children are lost after a Unite #1281
Comments
@iconexperience I believe this is an issue for you. I used the Not surprisingly, the squares with winding 0 in all segments all disappear... But why do they get these values, while the others don't? |
And with that information, here now an even more simplified case that has only one such square with wrong winding: |
@iconexperience so after looking a bit more into https://github.com/paperjs/paper.js/blob/develop/src/path/PathItem.Boolean.js#L572 // TODO: Determine how to handle quality when curve is crossed
// at starting point. Do we always need to set to 0?
quality = 0; It is time to address that I've tried just removing it, but that produces one failing test. I've also tried moving this code outside of its condition block: https://github.com/paperjs/paper.js/blob/develop/src/path/PathItem.Boolean.js#L545 // Determine the quality of the winding calculation. Reduce the
// quality with every crossing of the ray very close to the
// path. This means that if the point is on or near multiple
// curves, the quality becomes less than 0.5.
if (a > pa - qualityEpsilon && a < pa + qualityEpsilon)
quality /= 2; That actually worked and produced no failing tests, but then the quality of all windings in that square is 0.25, which I don't think is right... |
We should probably also look into why this happens on some of the squares and not on others? That's very bizarre... |
@iconexperience I've spoken too quickly. By slightly rotating the square, I can get the approach described above to produce wrong windings too: The problem with the slightly rotate square is that in |
@lehni The quality factor should not be relevant in this case, because it is meant to handle cases where two curves are very close and detection of intersections is not reliable. It's quite possible that the quality factor causes this bug, but that only shows that the implementation is not correct. In my opinion in the example we should get a correct winding result for all tested points. If that was the case, the quality factor should be irrelevant. But I agree, we should urgently settle this, or at least have a clear documentation for the quality factor. But first I will try to find out why some points give an incorrect winding result. |
Alright, this is the old problem with corners. Here is an example where the winding calculates incorrectly: The grey line is the vertical ray. The winding left and right (here up and down) are zero, which is correct. But we need a special handling of these cases. For I think long time ago we simple assinged So how to determine the correct winding in these cases? I think by calculating the "on-path winding". This can still lead to incorrect results if the overlapping curves are not fully identical, but those cases should get a bad quality factor. Welcome back "on-path winding"! |
BTW, this is a perfect example to show why I selected odd values for |
@iconexperience thanks for looking into this! I agree with you, but I think we need an implementation that can handle these offsets because there will always be a shape that will be able to trigger this error otherwise. I was basically hoping to hit these errors eventually that you were addressing by shifting the factors : ) |
Yes, I agree, this should be our goal. There are several approaches that I thought of, but all have their problems.
|
@iconexperience just quickly, regarding 3: Aren't we already doing this in https://github.com/paperjs/paper.js/blob/develop/src/path/PathItem.Boolean.js#L718? Your'e proposing to use |
@iconexperience I've just brought the on-path winding handling back in 48e9ef6, and it looks like together with another change I made earlier, both rotated and not rotated squares are now handled correctly. I haven't addressed 1. & 3. of your suggestions above at all yet. |
@iconexperience: Regarding suggestion 3: The problem is that we'd need to physically be Regarding 1: How would we determine we're on a corner inside |
This has been long fixed, since around |
@lehni I have an interesting use case for you ;-)
Sometimes, when I try to unite a CompoundPath with a Path, some subpaths are "lost".
Like here when I try to unite the CompoundPath in black with a Path in red. The resulting Path in blue is missing some subpaths.
The text was updated successfully, but these errors were encountered: