main #21

Closed
kistaro wants to merge 76 commits from main into some_level
Showing only changes of commit 71b150cb33 - Show all commits

View File

@ -1053,8 +1053,6 @@ function rope:relax()
local n1=n0.next local n1=n0.next
if (not n1) break if (not n1) break
local n2=n1.next local n2=n1.next
if n0.ax==n1.ax and n0.ay==n1.ay then if n0.ax==n1.ax and n0.ay==n1.ay then
n0.next=n2 n0.next=n2
if (n2) n2.prev=n0 if (n2) n2.prev=n0
@ -1160,8 +1158,6 @@ function would_stick(anchor,x0,y0,x1,y1,x2,y2)
x1,y1=x1 or anchor.ax,y1 or anchor.ay x1,y1=x1 or anchor.ax,y1 or anchor.ay
local dx,dy=x2-x0,y2-y0 local dx,dy=x2-x0,y2-y0
if (x1==x0 and y1==y0) return
if (x1==x2 and y1==y2) return
local function switch_ends() local function switch_ends()
dx,dy,x0,y0,x2,y2=-dx,-dy,x2,y2,x0,y0 dx,dy,x0,y0,x2,y2=-dx,-dy,x2,y2,x0,y0
@ -1259,57 +1255,44 @@ function rope:_be_pushed_by1(ax_old,ay_old,ax_new,ay_new,anch)
end end
function rope:_drag(n1,ax1_new,ay1_new,ax_removing,ay_removing) function rope:_drag(n1,ax1_new,ay1_new,ax_removing,ay_removing)
local function _sweep_radar(ax_lhs,ay_lhs,ax_rhs,ay_rhs,ax_pivot,ay_pivot,ax_far0,ay_far0,ax_far1,ay_far1) local function _sweep_radar(ax_lhs,ay_lhs,ax_rhs,ay_rhs,ax_pivot,ay_pivot,ax_src,ay_src,ax_dst,ay_dst)
if (ax_src==ax_dst and ay_src==ay_dst) return
local function _uncreatable(anchor) local function _uncreatable(anchor)
return (anchor.ax==ax_lhs and anchor.ay==ay_lhs) or return anchor.ax==ax_lhs and anchor.ay==ay_lhs or
(anchor.ax==ax_rhs and anchor.ay==ay_rhs) or anchor.ax==ax_rhs and anchor.ay==ay_rhs or
(anchor.ax==ax_removing and anchor.ay==ay_removing) anchor.ax==ax_removing and anchor.ay==ay_removing
end end
if (ax_far0==ax_far1 and ay_far0==ay_far1) return local function _sweep(extent_old,extent_new,cb_in_bounds,cb_would_stick,cb_side)
for extent_new in _stepfrom(extent_old, extent_new) do
if ax_far0==ax_far1 then
local ax_far=ax_far0
local ax0,ax1=_mnmx(ax_pivot,ax_far)
ay_far_old=ay_far0
for ay_far_new in _stepfrom(ay_far0,ay_far1) do
for anchor in level:anchor_points() do for anchor in level:anchor_points() do
if if not _uncreatable(anchor) and cb_in_bounds(anchor) and
not _uncreatable(anchor) and cb_would_stick(anchor,extent_new) and
(ax0<=anchor.ax and anchor.ax<=ax1) and cb_side(anchor,extent_old)!=cb_side(anchor,extent_new)
would_stick(anchor,ax_pivot,ay_pivot,nil,nil,ax_far,ay_far_new) and
(
_which_side(anchor.ax,anchor.ay,ax_pivot,ay_pivot,ax_far,ay_far_old) !=
_which_side(anchor.ax,anchor.ay,ax_pivot,ay_pivot,ax_far,ay_far_new)
)
then then
return anchor return anchor
end end
end end
ay_far_old=ay_far_new extent_old=extent_new
end end
elseif ay_far0==ay_far1 then end
local ay_far=ay_far0
local ay0,ay1=_mnmx(ay_pivot,ay_far)
ax_far_old=ax_far0 if ax_src==ax_dst then
for ax_far_new in _stepfrom(ax_far0,ax_far1) do return _sweep(
for anchor in level:anchor_points() do ay_src,ay_dst,
if function(anchor) return mid(ax_pivot,anchor.ax,ax_dst)==anchor.ax end,
not _uncreatable(anchor) and function(anchor,ay) return would_stick(anchor,ax_pivot,ay_pivot,nil,nil,ax_dst,ay) end,
(ay0<=anchor.ay and anchor.ay<=ay1) and function(anchor,ay) return _which_side(anchor.ax,anchor.ay,ax_pivot,ay_pivot,ax_dst,ay) end
would_stick(anchor,ax_pivot,ay_pivot,nil,nil,ax_far_new,ay_far) and )
( else
_which_side(anchor.ax,anchor.ay,ax_pivot,ay_pivot,ax_far_old,ay_far) != assert(ay_src==ay_dst)
_which_side(anchor.ax,anchor.ay,ax_pivot,ay_pivot,ax_far_new,ay_far) return _sweep(
) ax_src,ax_dst,
then function(anchor) return mid(ay_pivot,anchor.ay,ay_dst)==anchor.ay end,
return anchor function(anchor,ax) return would_stick(anchor,ax_pivot,ay_pivot,nil,nil,ax,ay_dst) end,
end function(anchor,ax) return _which_side(anchor.ax,anchor.ay,ax_pivot,ay_pivot,ax,ay_dst) end
end )
ax_far_old=ax_far_new
end
end end
end end