vrld / HC

General purpose collision detection library for the use with LÖVE.
http://hc.readthedocs.org/
404 stars 48 forks source link

Collision Filters #42

Closed trommlbomml closed 8 years ago

trommlbomml commented 8 years ago

Would be really great, even to improve performance: Define groups and tell the world which groups can collide. for example i would not like to collide projectiles to each others but to collide with tanks.

vrld commented 8 years ago

HC used to have this feature, but with the immediate mode interface it is not necessary anymore. You can define your own group handling, e.g.:

for b in pairs(bullets)
    for other in pairs(HC.neighbors(b))
        if not other.isProjectile and other:collidesWith(b) then -- or if other.group ~= b.group then
            handleCollision(b, other)
        end
    end
end

Note that this is exactly how HC would implement it, so there is no performance gain putting this into the library.

trommlbomml commented 8 years ago

great, thank you!