[go: nahoru, domu]

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

feature request: real circles (not just many-sided polygons) #301

Open
jaredly opened this issue Oct 6, 2016 · 1 comment
Open

feature request: real circles (not just many-sided polygons) #301

jaredly opened this issue Oct 6, 2016 · 1 comment

Comments

@jaredly
Copy link
jaredly commented Oct 6, 2016

Currently circles are just many-sided polygons, which works a lot of the time, but sometimes it really breaks down. Especially with small circles, the way they collide / interact with other objects makes it clear it's just a 13gon etc.

What would be involved in supporting circles? Digging into the source code a little, the Body is all about vertices. It would be annoying to have an isCircle flag or something that would then need to be checked in all of the Body.___ functions. But maybe that's the best way?

@liabru
Copy link
Owner
liabru commented Oct 11, 2016

What would be involved in supporting circles?

The bulk of the work would be implementing circle-polygon collisions in SAT. This requires a special case, but it can be done. It's a feature that should be added for sure.

It would be annoying to have an isCircle flag or something that would then need to be checked in all of the Body.___ functions. But maybe that's the best way?

Exactly and there actually already is the (undocumented) body.circleRadius property which is currently only used for rendering but was intended to be used for real circles when they're implemented.

An important thing to know is that Bodies.circle automatically decides a number of sides and it doesn't do a great job for very small circles (this needs improving).

Instead try using Bodies.polygon with a high number of sides (e.g. 50) and you should get better results even with a small radius.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants