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

cpShapeType cannot be queried anymore #219

Open
mcclure opened this issue Mar 1, 2022 · 0 comments
Open

cpShapeType cannot be queried anymore #219

mcclure opened this issue Mar 1, 2022 · 0 comments

Comments

@mcclure
Copy link

mcclure commented Mar 1, 2022

cpShapes may be of several underlying types (cpPolyShape, cpCircleShape, etc). There are methods that only work with the appropriate type and, per the documentation, throw an assert if called on an inappropriate shape. But there is no way to determine whether a cpShape is a poly shape, circle shape, or something else. In old Chipmunk you could get a cpShapeType out of the cpShape structure, but now structures are opaque.

This could create a problem if, for example, you were writing a generic debugDraw() callback for use with cpShapeEach that draws a polygon for polygon shapes, a circle for circle shapes etc. Unless you layered on application-level metadata about what kind of shape each object is, such a generic callback would not be possible.

Expected behavior: There should be either a cpShapeGetType() returning an enum, or a set of cpShapeIsPoly()/cpShapeIsCircle() functions that identify when a shape is safe to promote. I am considering patching in the cpShapeIsPoly() solution myself and could submit a PR.

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

1 participant