Skip to content

Circle collidepolygon() and Polygon collidecircle() #189

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

Merged
merged 18 commits into from
Jul 6, 2023

Conversation

itzpr3d4t0r
Copy link
Member

@itzpr3d4t0r itzpr3d4t0r commented Jan 22, 2023

Should close #180 and #175.

Added:

  • Circle collidepolygon() function, with optional only_edges param (only does edge collision) defaulting to False
  • Polygon collidecircle() function, with optional only_edges param (only does edge collision) defaulting to False
  • Internal pgCollision_CirclePolygon and _pgCollision_PolygonPoint_opt helper (faster version of
    pgCollision_PolygonPoint that assumes the point passed not to be one of the polygon's vertices)
  • Docs and tests
  • Python example program

Changed:

  • geometry.pyi Coordinate from Union[Tuple[float, float], Sequence[float], Vector2, Tuple[int, int]] to Union[Sequence[float, float], Vector2, Sequence[int, int]]

Removed

  • 6 c_api slots in geometry.c needlessly occupied by pgCollision_LineLine, pgIntersection_LineLine, pgCollision_LineCircle, pgCollision_CircleCircle, pgCollision_RectLine, pgCollision_RectCircle

This PR is also a nice example of how to use the newly added Polygon internal functionality for working with polygons outside the polygon module.
A screenshot from the example:
image

@itzpr3d4t0r itzpr3d4t0r marked this pull request as draft January 22, 2023 21:54
@itzpr3d4t0r itzpr3d4t0r linked an issue Jan 23, 2023 that may be closed by this pull request
@itzpr3d4t0r itzpr3d4t0r marked this pull request as ready for review January 23, 2023 14:16
@itzpr3d4t0r itzpr3d4t0r merged commit f975e04 into main Jul 6, 2023
@itzpr3d4t0r itzpr3d4t0r deleted the circle_collidepolygon branch July 6, 2023 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Circle collide_polygon() Add Polygon collide_circle()
1 participant