kdrnic / box2dweb

Automatically exported from code.google.com/p/box2dweb
0 stars 1 forks source link

QueryAABB only returns one overlapping fixture #39

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create multiple single-fixture rectangular bodies (using SetAsBox) in the 
world.
2. Call QueryAABB, passing it a callback and an AABB centred at the location of 
one of the bodies and with a size sufficient to overlap several bodies.
3. The callback is only called once for the first overlapping fixture found, no 
matter how many fixtures are intersecting with the defined AABB.

What is the expected output? What do you see instead?

I'm expecting the callback to be called once for each fixture that the AABB 
overlaps.

What version of the product are you using? On what operating system?
2.1a.3 on OSX

Please provide any additional information below.

If I manually loop through the bodies and do the AABB check myself, everything 
works as I expect. I'm not sure what is going on with the QueryAABB function.

Original issue reported on code.google.com by michael....@verold.com on 26 Mar 2013 at 6:59

GoogleCodeExporter commented 9 years ago
For run callback function for each found object, you must return true in your 
callback function.

Example for me (JavaScript):
world.QueryAABB(function(fixture) {
    // Some code
}, aabb);
In this example, callback function will be called only once (but i know that i 
have two bodies at this point)

world.QueryAABB(function(fixture) {
    // Some code
   return true;
}, aabb);
// If we put return true in callback, this function will be called again for 
each found object. In my example function was called second times because i 
have two bodies.

Original comment by v.za...@wippo.md on 9 Jul 2015 at 10:42