Use same rule to touch as to elide

This commit is contained in:
Pyrex 2022-12-19 18:13:18 -08:00
parent 74ac91fdeb
commit d62cb15547

View File

@ -986,17 +986,17 @@ function rope:draw(artificial_dx,artificial_dy)
end end
end end
--[[
for i=0,#self.ancs+1 do for i=0,#self.ancs+1 do
p=self:_anc(i) p=self:_anc(i)
local c=12 local c=12
if (p.dirty) c=13 if (p.dirty) c=13
rectfill(p.x-1,p.y-1,p.x+1,p.y+1,c) rectfill(p.x-1,p.y-1,p.x+1,p.y+1,c)
print(tostr(p.id)..":"..p.x..","..p.y..","..#p.todo,0,-8+i*8,9) print(tostr(p.id)..":"..p.x..","..p.y..","..#p.todo,0,i*8,9)
end end
for _,p in pairs(level._anch) do for _,p in pairs(level._anch) do
pset(p.x,p.y,11) pset(p.x,p.y,11)
end end
--[[
print("dirty:"..tostr(self.dirty),32,0,9) print("dirty:"..tostr(self.dirty),32,0,9)
print("busy:"..tostr(self:busy()),32,7,9) print("busy:"..tostr(self:busy()),32,7,9)
print("state:"..tostr(self.state.name),32,14,9) print("state:"..tostr(self.state.name),32,14,9)
@ -1168,6 +1168,7 @@ function rope:_find_needed_anchors(i,busy)
end end
end end
local ELIDE_POINT=0.01
function rope:_find_touched_anchors(i) function rope:_find_touched_anchors(i)
if (i<=0) return false if (i<=0) return false
if (#self.ancs<i) return false if (#self.ancs<i) return false
@ -1182,7 +1183,7 @@ function rope:_find_touched_anchors(i)
local a1=level:point_anchor(bx,by) local a1=level:point_anchor(bx,by)
if if
a1!=nil and not _point_eq(a0,a1) and not _point_eq(a1,a2) a1!=nil and not _point_eq(a0,a1) and not _point_eq(a1,a2)
and _linedist(a0,a1,a2) == 0.0 and _linedist(a0,a1,a2)<ELIDE_POINT
-- and self:_can_stretch(p,a2) -- and self:_can_stretch(p,a2)
then then
local id=self.id local id=self.id
@ -1207,7 +1208,7 @@ function rope:_elide_point(i,busy)
if _point_eq(a0,a1) or _point_eq(a1,a2) or (not busy and level_anc==nil) then if _point_eq(a0,a1) or _point_eq(a1,a2) or (not busy and level_anc==nil) then
-- do it unconditionally -- do it unconditionally
else else
if _linedist(a0,a1,a2) < 0.01 then if _linedist(a0,a1,a2) < ELIDE_POINT then
return false return false
end end