Giter Site home page Giter Site logo

Comments (2)

sysl-dev avatar sysl-dev commented on August 25, 2024
function World:queryCircleArea(x, y, radius, collision_class_names)
    if not collision_class_names then collision_class_names = {'All'} end
    if self.query_debug_drawing_enabled then table.insert(self.query_debug_draw, {type = 'circle', x = x, y = y, r = radius, frames = self.draw_query_for_n_frames}) end

    local colliders = self:_queryBoundingBox(x-radius, y-radius, x+radius, y+radius)
    local outs = {}
    for _, collider in ipairs(colliders) do
        if self:collisionClassInCollisionClassesList(collider.collision_class, collision_class_names) then
            for _, fixture in ipairs(collider.body:getFixtures()) do
                local does_this_have = fixture:getShape()
                if does_this_have.getPoints then
                    if self.wf.Math.polygon.getCircleIntersection(x, y, radius, {collider.body:getWorldPoints(fixture:getShape():getPoints())}) then
                        table.insert(outs, collider)
                        break
                    end
                else -- It's a Circle Collider, which the original library NEVER CHECKS FOR.
                    local cx, cy = collider.body:getWorldPoints(fixture:getShape():getPoint())
                    local cr = does_this_have:getRadius()
                    if self.wf.Math.circle.getCircleIntersection(x, y, radius, cx, cy, cr) then
                        table.insert(outs, collider)
                        break
                    end
                end
            end
        end
    end
    return outs
end

This is what I did to patch it, you can do the same with the other queries.

from windfield.

Fogoid avatar Fogoid commented on August 25, 2024

Thanks! It works ^^

from windfield.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.