Update to current project state #1

Merged
kistaro merged 6 commits from pyrex/chameleonic:main into main 2022-12-17 22:16:05 +00:00
Showing only changes of commit a20ad44f75 - Show all commits

View File

@ -214,6 +214,17 @@ function level:anchor_points()
return pairs(self._anch) return pairs(self._anch)
end end
function level:anchors_in(px0,py0,px1,py1)
ancs={}
for ax=px0\4,(px1+3)\4 do
for ay=py0\4,(py1+3)\4 do
local anc=self._anch[_amix(ax,ay)]
if (anc!=nil) add(ancs, anc)
end
end
return ancs
end
function level:point_anchor(px,py) function level:point_anchor(px,py)
local ax,ay=self:p2a(px,py) local ax,ay=self:p2a(px,py)
local anc=self._anch[_amix(ax,ay)] local anc=self._anch[_amix(ax,ay)]
@ -762,15 +773,9 @@ function rope:_find_needed_anchors(i)
local anchors_bydist={} local anchors_bydist={}
local x0,x2=_mnmx(a0.x,a2.x) local x0,x2=_mnmx(a0.x,a2.x)
local y0,y2=_mnmx(a0.y,a2.y) local y0,y2=_mnmx(a0.y,a2.y)
for _,a1 in level:anchor_points() do for a1 in all(level:anchors_in(x0-1,y0-1,x2+1,y2+1)) do
-- the new anchor point must be in the bounding box
-- of the old line
-- note: this fudge never turned out necessary
-- i just would be ok with it
if x0-1<=a1.x and a1.x<=x2+1 and y0-1<=a1.y and a1.y<=y2+1 then
add(anchors_bydist,{el=a1,key=_linedist(a0,a1,a2)}) add(anchors_bydist,{el=a1,key=_linedist(a0,a1,a2)})
end end
end
shellsort(anchors_bydist) shellsort(anchors_bydist)
for a1 in all(anchors_bydist) do for a1 in all(anchors_bydist) do