
function initDebug()
    db = regGetBool('world.debugMode')
end

function dbw(str, value) if db then DebugWatch(str, value) end end
function dbp(str, newLine) if db then DebugPrint(str .. ternary(newLine, '\n', '')) print(str .. ternary(newLine, '\n', '')) end end
function dbpt(p1, c1, c2, c3, a) if db then DebugCross(p1, c1, c2, c3, a) end end
function dbl(p1, p2, c1, c2, c3, a) if db then DebugLine(p1, p2, c1, c2, c3, a) end end
function dbdd(pos,w,l,r,g,b,a,dt) DrawDot(pos,w,l,r,g,b,a,dt) end
function ddc(transform, radius, sides, info)
    if db then
        radius = radius or 1
        sides = sides or 100
        visual.drawpolygon( transform, radius, nil, sides, info, true)
    end
end
function dds(transform, radius, sides, info)
    if db then
        radius = radius or 1
        sides = sides or 100
        visual.drawpolygon( transform, radius, nil, sides, info, true)
        local tr2 = transform
        tr2.rot = QuatRotateQuat(tr2.rot, QuatEuler(0, 90, 0))
        visual.drawpolygon( tr2, radius, nil, sides, info, true)
        local tr3 = transform
        tr3.rot = QuatRotateQuat(tr3.rot, QuatEuler(0, 0, 90))
        visual.drawpolygon( tr3, radius, nil, sides, info, true)
    end
end

function debugMod()
    db = regGetBool('world.debugMode')
    debugWorld()
end

function debugWorld()
    if db then
        local shapes = FindShapes("generatedFloor", true)
        for i=1, #shapes do
            local min, max = GetShapeBounds(shapes[i])
            AabbDraw(min, max, 1, 1, 1, 1)
        end
        local shapes = FindShapes("generatedWall", true)
        for i=1, #shapes do
            local min, max = GetShapeBounds(shapes[i])
            AabbDraw(min, max, 0, 1, 0, 1)
        end
        local shapes = FindShapes("generatedCeiling", true)
        for i=1, #shapes do
            local min, max = GetShapeBounds(shapes[i])
            AabbDraw(min, max, 0.5, 0.5, 1, 1)
        end
    end
end
