QueryAABB - categories

Hello.

I’m trying to use physics.queryAABB with the category filters mentioned in the reference. I can’t get it to work - any call to queryAABB with more than 2 arguments returns nil.

I circumvented the problem, but I’m curious - did I do something wrong? Sample code below:

physics.gravity(vec2(0,0))
square=physics.body(POLYGON,vec2(-10,-10),vec2(10,10),vec2(-10,10),vec2(10,-10))
square.x=150
square.y=150
square.categories={1}
circle=physics.body(CIRCLE, 30)
circle.x=150
circle.y=100
circle.categories={2}

local query=physics.queryAABB(vec2(100,100),vec2(200,200),1,2)
print(#query)

@Fktor Getting rid of the categories, this returns 3 entries, but two are duplicates. Why 3, I don’t know. Supposedly using the categories ignores physics.objects.


function setup()
    square=physics.body(POLYGON,vec2(-10,-10),vec2(10,10),vec2(-10,10),vec2(10,-10))
    square.x=150
    square.y=150

    circle=physics.body(CIRCLE, 30)
    circle.x=150
    circle.y=100

    query=physics.queryAABB(vec2(100,100),vec2(200,200))
    for a,b in pairs(query) do
        print(a,b)
    end
end

Looking through the code it seems like the category filtering isn’t working at the moment because it doesn’t exist. So the documentation is wrong in that sense.

As for duplicates, this is a bug due to the way non-convex polygons are decomposed into a series of convex polygons, meaning you can get the same “body” twice. I’m planning to fix these issues along with the problems with raycast in the next update.

Okey, thanks for the answer :slight_smile: