Move in bigger hops while dragging
This commit is contained in:
parent
29d86556ca
commit
770b952fe4
@ -586,7 +586,6 @@ function rope:_make_consistent()
|
|||||||
)
|
)
|
||||||
|
|
||||||
if #self.latch.rec.todo==0 then
|
if #self.latch.rec.todo==0 then
|
||||||
self:_tidy_up_gen()
|
|
||||||
for i=0,#self.ancs do
|
for i=0,#self.ancs do
|
||||||
local a0=self:_anc(i)
|
local a0=self:_anc(i)
|
||||||
local a1=self:_anc(i+1)
|
local a1=self:_anc(i+1)
|
||||||
@ -676,23 +675,25 @@ function rope:drag(
|
|||||||
i,x,y
|
i,x,y
|
||||||
)
|
)
|
||||||
local anc=self:_anc(i())
|
local anc=self:_anc(i())
|
||||||
for x,y in self:_rast(
|
local busy=self:busy()
|
||||||
anc.x,anc.y,x,y
|
|
||||||
|
for x,y in self:_rastn(
|
||||||
|
anc.x,anc.y,x,y,2,2
|
||||||
) do
|
) do
|
||||||
local a=self:_anc(i())
|
local a=self:_anc(i())
|
||||||
if not (_point_eq(a, {x=x,y=y})) then
|
if not (_point_eq(a,{x=x,y=y})) then
|
||||||
a.x=x
|
a.x=x
|
||||||
a.y=y
|
a.y=y
|
||||||
a.dirty=true
|
a.dirty=true
|
||||||
self:_tidy_up_gen()
|
self.dirty=true
|
||||||
|
if (not busy) self:_tidy_up_gen()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function rope:_tidy_up_gen()
|
function rope:_tidy_up_gen()
|
||||||
if (self:busy()) return
|
|
||||||
|
|
||||||
if (self.under_destruction) return
|
if (self.under_destruction) return
|
||||||
|
if (not self.dirty) return
|
||||||
|
|
||||||
local settled=true
|
local settled=true
|
||||||
local touched={}
|
local touched={}
|
||||||
@ -744,13 +745,13 @@ function rope:_tidy_up_gen()
|
|||||||
|
|
||||||
for a=0,#self.ancs+1,1 do
|
for a=0,#self.ancs+1,1 do
|
||||||
local anc=self:_anc(a)
|
local anc=self:_anc(a)
|
||||||
if anc.seen then
|
if (anc.seen) anc.dirty=anc.changed
|
||||||
anc.dirty=anc.changed
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if (settled) break
|
if (settled) break
|
||||||
end
|
end
|
||||||
|
|
||||||
|
self.dirty=false
|
||||||
end
|
end
|
||||||
|
|
||||||
function rope:_find_needed_anchors(i)
|
function rope:_find_needed_anchors(i)
|
||||||
@ -861,7 +862,7 @@ function rope:_can_move_midpoint(a0,a1_0,a1_1,a2)
|
|||||||
if not self:_can_stretch(a1_1,a2) then
|
if not self:_can_stretch(a1_1,a2) then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
for x,y in self:_rastm(a1_0.x,a1_0.y,a1_1.x,a1_1.y) do
|
for x,y in self:_rastn(a1_0.x,a1_0.y,a1_1.x,a1_1.y,8,8) do
|
||||||
local tm={x=x,y=y}
|
local tm={x=x,y=y}
|
||||||
if not self:_can_stretch(a0,tm) then
|
if not self:_can_stretch(a0,tm) then
|
||||||
return false
|
return false
|
||||||
@ -936,7 +937,7 @@ function rope:_can_stretch(
|
|||||||
if (level:pcoll(p2.x,p2.y)) return false
|
if (level:pcoll(p2.x,p2.y)) return false
|
||||||
|
|
||||||
local res=true
|
local res=true
|
||||||
for x,y in self:_rastm(p1.x,p1.y,p2.x,p2.y) do
|
for x,y in self:_rastn(p1.x,p1.y,p2.x,p2.y,8,8) do
|
||||||
if level:pcoll(x,y) then
|
if level:pcoll(x,y) then
|
||||||
res=false
|
res=false
|
||||||
break
|
break
|
||||||
@ -946,8 +947,8 @@ function rope:_can_stretch(
|
|||||||
return res
|
return res
|
||||||
end
|
end
|
||||||
|
|
||||||
function rope:_rastm(
|
function rope:_rastn(
|
||||||
x0,y0,x1,y1
|
x0,y0,x1,y1,dx,dy
|
||||||
)
|
)
|
||||||
-- todo: more optimized implementation?
|
-- todo: more optimized implementation?
|
||||||
local iter=self:_rast(x0,y0,x1,y1)
|
local iter=self:_rast(x0,y0,x1,y1)
|
||||||
@ -960,8 +961,8 @@ function rope:_rastm(
|
|||||||
|
|
||||||
if (x==nil) done=true return x1, y1
|
if (x==nil) done=true return x1, y1
|
||||||
|
|
||||||
local x8 = x\8
|
local x8 = x\dx
|
||||||
local y8 = y\8
|
local y8 = y\dy
|
||||||
if not (x8==prevx and y8==prevy) then
|
if not (x8==prevx and y8==prevy) then
|
||||||
prevx,prevy=x8,y8
|
prevx,prevy=x8,y8
|
||||||
return x,y
|
return x,y
|
||||||
@ -1080,6 +1081,7 @@ function rope:_tug()
|
|||||||
if force or not level:pcoll(x,y) then
|
if force or not level:pcoll(x,y) then
|
||||||
s.x=x
|
s.x=x
|
||||||
s.y=y
|
s.y=y
|
||||||
|
self.dirty=true
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
end}
|
end}
|
||||||
@ -1132,6 +1134,8 @@ function rope:_tug()
|
|||||||
mx0,my0,
|
mx0,my0,
|
||||||
dmx,dmy
|
dmx,dmy
|
||||||
)
|
)
|
||||||
|
-- be busy for 4 ticks while the crate moves
|
||||||
|
self:_anc(0).todo={{},{},{},{}}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user