My fat bresenham implementation is really slow
This commit is contained in:
parent
a20ad44f75
commit
13e6c382be
@ -967,34 +967,27 @@ function rope:_rast(
|
|||||||
if (y0<y1) sy=1
|
if (y0<y1) sy=1
|
||||||
|
|
||||||
local done=false,err
|
local done=false,err
|
||||||
local queue={}
|
|
||||||
if dx>dy then
|
if dx>dy then
|
||||||
err=dx/2.0
|
err=dx/2.0
|
||||||
return function()
|
return function()
|
||||||
if (queue==nil) return
|
if (done) return
|
||||||
if (x==x1) queue=nil return x1,y1
|
if (x==x1) done=true return x1,y1
|
||||||
if #queue==0 then
|
local oldx,oldy=x,y
|
||||||
add(queue,{x,y})
|
|
||||||
err-=dy
|
err-=dy
|
||||||
if (err<0) y+=sy add(queue,{x,y}) err+=dx
|
if (err<0) y+=sy err+=dx
|
||||||
x+=sx
|
x+=sx
|
||||||
end
|
return oldx,oldy
|
||||||
return unpack(deli(queue,1))
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
err=dy/2.0
|
err=dy/2.0
|
||||||
return function()
|
return function()
|
||||||
if (queue==nil) return
|
if (done) return
|
||||||
if (y==y1) queue=nil return x1,y1
|
if (y==y1) done=true return x1,y1
|
||||||
if #queue==0 then
|
|
||||||
add(queue,{x,y})
|
|
||||||
|
|
||||||
local oldx,oldy=x,y
|
local oldx,oldy=x,y
|
||||||
err-=dx
|
err-=dx
|
||||||
if (err<0) x+=sx add(queue,{x,y}) err+=dy
|
if (err<0) x+=sx err+=dy
|
||||||
y+=sy
|
y+=sy
|
||||||
end
|
return oldx,oldy
|
||||||
return unpack(deli(queue,1))
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user