-
-
Notifications
You must be signed in to change notification settings - Fork 21.1k
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
Create intermediate segments in ConcavePolygonShape2D. #32979
Conversation
I tagged this PR as "breaks compat" since I'm not sure if existing point arrays would work fine with the new changes. I guess that zero-length segments could be filtered out so that well-formed old-format arrays of points continue to work optimally? |
@bojidar-bg The "breaks compat" is valid; since the ConcavePolygonShape2D could have been used to create discontiguous collections of segments, which would now be linked together. However this would only apply to those using this unexpected behaviour as a feature. On your second point, I did look at removing zero length segments, but the problem was the edge case of one point. With only one point, one zero length segment is created that loops back to itself. Deleting this segment deletes the only segment and hence the one point. This prevents the array size from being incremented from 0. Since the original only removed duplicated points not zero length segments, I chose to keep it simple and not add this. |
d1fb2b7
to
afafe06
Compare
Rebased following #36311. |
afafe06
to
8cc6af2
Compare
Rebased following rename of |
8cc6af2
to
9bd68c1
Compare
Rebased following #38738. |
Would be really nice to have this merged now, trying to draw a |
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.
Tested for simple scene with static and rigid bodies (both inside and outside the static collider).
My feeling with this APIs is that they should take a bit more pre-munched data, otherwise the servers need to generate the support structures, like BVH for concave, and the list of triangles/vertices/edges for the convex stuff instead of this high level stuff. I was thinking of breaking compat more towards this discretion in the 4.0 branch.. then leave the previous API more of as a helper if you want to pass simpler data |
If most of the physics stuff is going to be rewritten in 4.1 or so, then yeah I don't see much point in breaking compat this way. But from what I see in this PR, this is mainly just a consistency fix for what a user can expect from both concave and convex polygon shapes in terms of input. To each problem, its own solution, and this PR does fix some. One small step for 4.0, one giant leap for 4.1. 🙂 |
Is this still relevant for the current CC @godotengine/physics |
9bd68c1
to
564aa95
Compare
564aa95
to
aad1b12
Compare
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.
I can confirm it fixes both issues (although the first one is rather vague) and breaks compat. Can't say much about the code.
This change makes ConcavePolygonShape2D basically the same as CollisionPolygon2D; at least interface-wise (minus the editor), but maybe the collision checks work differently internally, idk.
Not in favor myself of this change. It only limits the API and removes the ability to use multiple shapes (currently used by Sprite2D -> collision generation) as well as open shapes (say terrain) with this API. Instead, what we could do is rename this resource to MultiSegmentShape2D, which is more faithful to what it is. |
Is there any advantage of using it, over multiple polygons? |
Closing as we didn't go ahead with this approach. |
Fixes #19353, fixes #29320.
A ConcavePolygonShape2D is expected to be similar to a ConvexPolygonShape2D. The description for ConcavePolygonShape2D states:
This patch makes them similar by using the points in the PoolVector2Array associated with a ConcavePolygonShape2D to create a contiguous, closed-loop of segments instead of requiring and grouping them into pairs of discontiguous segments, which leaves unexpected holes between the pairs.