Check for bodies within a specific circle in Box2D

Posted by ltjax on Game Development See other posts from Game Development or by ltjax
Published on 2012-04-13T11:51:11Z Indexed on 2012/04/13 17:43 UTC
Read the original article Hit count: 298

Filed under:
|
|

I'm trying to find positions to insert new bodies into my world. For that, I'd like to have a "free" spot where this body wouldn't overlap with anything else. So my plan was to sample "random" positions and check whether they overlap with my "potential" new body. Since my bodies are always circular, I'd need to test within a given circle. So far, the only way to use box2d for this seems to use b2World::QueryAABB around my circle and manually doing an overlap test with all the fixtures it gives me (Box2D doesn't event seem to allow me to tap into its overlapping tests?!). It seems to me like Box2D should already provide such functionality - is there a way that lets me do this without reinventing most of the wheel again?

© Game Development or respective owner

Related posts about c++

Related posts about collision-detection