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

PGS_ShapeBoolean.union(PShape, PShape) returns shape identical to input argument #62

Closed
puebloDeLaMuerte opened this issue Jul 3, 2022 · 4 comments

Comments

@puebloDeLaMuerte
Copy link

Hi,

i have an array of many PShapes created from tiling an initial square repeatedly using PGS_Processing.slice(). Within that array i pick two neigbouring shapes for unision via the PGS_ShapeBoolean.union(PShape,PShape) function. This works like a charm most of the time and returns a PShape that combines the areas of the two input shapes. Sometimes it doesen't want to do so and instead just returns a PShape that is identical to the second input argument of union(PShape,PShape).

What's confusing is that i cannot tell the difference between cases where it works and where it doesnt. The input shapes look valid to me in both cases...

Not shure if this is a bug or if you can point me towards common issues with unision that i should look into...

Thx for a reply and thanks for sharing this awesome library!

@micycle1
Copy link
Owner

micycle1 commented Jul 3, 2022

Can you certify that the coordinates of the two slice shapes overlap perfectly? I'm guessing this isn't the case somehow. If so, you could put the tiles through PGS_Conversion.roundVertexCoords() first, and see whether that leads to the expected output.

Perhaps after having been sliced, the adjacent slices sometimes have very slight differences in their coordinates -- a small gap which means they cannot be unioned.

@micycle1 micycle1 changed the title PGS_ShapeBoolean.union(PShape,PShape) returns shape identical to input argument PGS_ShapeBoolean.union(PShape, PShape) returns shape identical to input argument Jul 3, 2022
@puebloDeLaMuerte
Copy link
Author

Thx for your reply!
Not shure how i would check if the shapes overlap perfectly. I did check for Vertices being very close but not exacly in the same spot, but that doesn't produce meaningful results in cases where the touching corners of one shape don't lie on the corners of the other but instead lie on the connecting lines between two points of the other shape. (Not touching corners, but corners touching the side of another shape).

I did try using PGS_Conversion.roundVertexCoords() which seems to help in some cases, making the non-unision more rare, but not completely go away.

Just thought i'd share my findings - not shure what to try next... thx anyways!

@micycle1
Copy link
Owner

Can you share code?

@micycle1
Copy link
Owner

micycle1 commented Nov 1, 2022

Closed -- stale.
Further, union() should always reproduce both shapes even if they do not intersect (in this case they become a single group shape having 2 disjoint child shapes).

@micycle1 micycle1 closed this as completed Nov 1, 2022
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

No branches or pull requests

2 participants