Tracer bug?

I’m experiencing a bug with the use of the Chain physics body, I made a map with the use of chain for the floor. The problem is the tracer is going through the floor sometimes, shown in this video: http://www.youtube.com/watch?v=kvnf6AxF3WQ

Ill paste the code for the vertices and floor, and the tracer function.
Floor:

function changeLevel()
    if floor then
        for k,v in pairs(floor) do
            v:destroy()
            v = nil
        end
    end
    levverts = {}
    floor = {}
    levimg = nil
end
function Level1()
    changeLevel()
    
    levimg = readImage("Documents:level1new")
    
    levverts[1] = {vec2(656.25,188),vec2(210.938,188),vec2(210.938,380),vec2(93.75,380),
vec2(93.75,428),vec2(726.562,428),vec2(726.562,740),vec2(187.5,740),vec2(187.5,596),
vec2(164.062,596),vec2(164.062,740),vec2(-281.25,740),vec2(-281.25,476),vec2(-140.625,476),
vec2(-140.625,116),vec2(-164.062,116),vec2(-164.062,452),vec2(-281.25,452),vec2(-281.25,68),
vec2(-304.688,68),vec2(-304.688,740),vec2(-726.562,740),vec2(-726.562,548),vec2(-609.375,548),
vec2(-609.375,524),vec2(-726.562,524),vec2(-726.562,20),vec2(-515.625,20),vec2(-515.625,68),
vec2(-492.188,68),vec2(-492.188,20),vec2(-375,20),vec2(-375,-4.00002),vec2(-492.188,-4.00002),
vec2(-492.188,-28),vec2(-515.625,-28),vec2(-515.625,-4.00002),vec2(-726.562,-4.00002),
vec2(-726.562,-676),vec2(-164.062,-676),vec2(-164.062,-364),vec2(-140.625,-364),
vec2(-140.625,-532),vec2(23.4375,-532),vec2(23.4375,-196),vec2(-281.25,-196),vec2(-281.25,-316),
vec2(-515.625,-316),vec2(-515.625,-532),vec2(-281.25,-532),vec2(-281.25,-556),
vec2(-539.062,-556),vec2(-539.062,-292),vec2(-304.688,-292),vec2(-304.688,20),vec2(-281.25,20),
vec2(-281.25,-52),vec2(23.4375,-52),vec2(23.4375,188),vec2(-46.875,188),vec2(-46.875,572),
vec2(-117.188,572),vec2(-117.188,596),vec2(23.4375,596),vec2(23.4375,572),vec2(-23.4375,572),
vec2(-23.4375,308),vec2(0,308),vec2(0,260),vec2(23.4375,260),vec2(23.4375,212),vec2(46.875,212),
vec2(46.875,-676),vec2(164.062,-676),vec2(164.062,20),vec2(562.5,20),vec2(562.5,-4.00002),
vec2(187.5,-4.00002),vec2(187.5,-172),vec2(281.25,-172),vec2(281.25,-484),vec2(726.562,-484),vec2(726.562,-220),vec2(351.562,-220),vec2(351.562,-172),vec2(656.25,-172),vec2(656.25,188)}

    levverts[2] = {vec2(-375,116),vec2(-515.625,116),vec2(-515.625,308),vec2(-632.812,308),
vec2(-632.812,332),vec2(-515.625,332),vec2(-515.625,596),vec2(-375,596),vec2(-375,116)}
    
    for k,v in pairs(levverts) do
        floor[k] = physics.body(CHAIN,false,unpack(v))
        floor[k].categories = {0}
    end
end

function Player:shoot(x,y)
    local rb = physics.raycast(self.bl.body.position,self.bl.body.position+vec2(x,y):normalize()*700,1,0)
    if rn == nil then return end
    if rb and rb.body ~= self.companion then self.laserpoint = rb.point else self.laserpoint = self.bl.body.position+vec2(x,y) end
    if not rb then return end
    local w,h
    if math.abs(rb.normal.x) > 0.5 then
        w,h = 0,130
    else
        w,h = 130,0
    end
    local rd = physics.raycast(rb.point+rb.normal*5,rb.point+rb.normal*5+vec2(w,h)*0.5,1,0)
    local rv = physics.raycast(rb.point+rb.normal*5,rb.point+rb.normal*5+vec2(w,h)*-0.5,1,0)
    local rc = physics.raycast(rb.point+rb.normal*5,rb.point+rb.normal*80,1,0)
    if self.p1 and self.p1.portal and self.rb.body == self.p1.portal then return end
    if self.p2 and self.p2.portal and self.rb.body == self.p2.portal then return end
    
    if rb and not rd and not rv and not rc then
        self.port = rb.point
        self.normal = rb.normal
    end
end
body.sleepingAllowed = false

I think that will fix it, but I can’t check if that’s the exact variable because my dad took his iPad while he’s away on a business trip.

Edit: Wait, sorry, that’s not it. I misunderstood the problem, I thought you meant the character was falling through the floor.

No the tracer is going through the floor as shown in the video, I don’t understand why though…

So would anyone like to help?

I’d love to help, sadly its waaaaaay over my head right now. Sorry

I’m sure some clever person will help.

When you have some problem like ‘sometimes the object goes through…’ the usual solution is to set the field ‘bullet’ to true: object.bullet = true. That could do it.

This isn’t an object its a physics.raycast that is ignoring the first wall at a certain angle and going through to the wall behind it.

I think it has something to do with the categories, I’ve changed the walls to polygons and took away the filtering on the tracer and it doesn’t seem to be doing it, the problem with this is that the tracer doesn’t go through the player without focussing on one category

@Luatee, is this the same problem you are having?

http://twolivesleft.com/Codea/Talk/discussion/2444/problem-with-physics-raycast/p1

Because that one appears to have been solved, so maybe the same solution will work for you

It is similar to that problem except I’ve only noticed it happening when I use the category filters in the raycast function, I need to filter out the body category though otherwise the raycast won’t work, the solution on that post didnt help, I had searched the forum previously

Appears to be internal, box2d is receiving the wrong callback so I switched to raycastAll and got the closest body