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

Implement RegularPolygon colliders with a custom shape #367

Merged
merged 5 commits into from
Jun 10, 2024

Conversation

Jondolf
Copy link
Owner

@Jondolf Jondolf commented Jun 10, 2024

Objective

Currently, regular polygons don't have their own collider shape. Instead, the From<RegularPolygon> implementation computes the convex hull and creates a convex polygon from that. This may not be the most efficient approach however, as some computations can be simpler and more efficient if the polygon is known to be regular.

This PR adds a custom shape implementation for the 2D RegularPolygon primitive.

Solution

Add a RegularPolygonWrapper type that is used as the internal representation for the custom regular polygon shape. The custom shape uses the ID 2.


Migration Guide

If you had a custom Parry shape using the ID 2, you might need to change it, because the ID is used for regular polygons.

@Jondolf Jondolf added C-Enhancement New feature or request A-Collision Relates to the broad phase, narrow phase, colliders, or other collision functionality labels Jun 10, 2024
@Nul-led
Copy link

Nul-led commented Jun 10, 2024

lgtm

@Jondolf Jondolf merged commit 49e6fe0 into main Jun 10, 2024
4 checks passed
@Jondolf Jondolf deleted the custom-regular-polygon branch June 10, 2024 18:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Collision Relates to the broad phase, narrow phase, colliders, or other collision functionality C-Enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants