forked from pyrex/chameleonic
catch up to latest developments #10
@ -1232,16 +1232,6 @@ function _linedist(x0,v,x1)
|
||||
return 100 * (sum_distance(x0,v,x1)-distance(x0,x1))/distance(x0,x1)
|
||||
end
|
||||
|
||||
function _vec_ang_diff(x0,y0,x1,y1)
|
||||
local ang0=atan2(x0,y0)
|
||||
local ang1=atan2(x1,y1)
|
||||
return _ang_diff(ang0,ang1)
|
||||
end
|
||||
|
||||
function _ang_diff(ang0,ang1)
|
||||
return abs((ang1-ang0+0.5)%1-0.5)
|
||||
end
|
||||
|
||||
function sum_distance(x,y,z)
|
||||
return distance(x,y) + distance(y,z)
|
||||
end
|
||||
@ -1514,8 +1504,6 @@ function rope:_tug(hypothetically)
|
||||
(dmx!=0 and sgn0(pull_dx)!=dmx) or
|
||||
(dmy!=0 and sgn0(pull_dy)!=dmy) or
|
||||
|
||||
_vec_ang_diff(pull_anc.x\8-mx0,pull_anc.y\8-my0,dmx,dmy) >= 0.135 or
|
||||
|
||||
sgn0(mx0-mxa)!=
|
||||
sgn0(mx0+dmx-mxa) or
|
||||
|
||||
@ -1547,11 +1535,6 @@ function rope:_calc_push(
|
||||
)
|
||||
local ops={}
|
||||
if (an==nil) return ops
|
||||
local pull_ang=atan2(
|
||||
a0.x\8-an.x\8,
|
||||
a0.y\8-an.y\8
|
||||
)
|
||||
local needs_good_pull=af==nil
|
||||
|
||||
if a0.x==a1.x then
|
||||
-- no far side applying pressure?
|
||||
@ -1564,16 +1547,10 @@ function rope:_calc_push(
|
||||
|
||||
local mx,dmx
|
||||
if a0.x%8==0 and a0.x>an.x+7 then
|
||||
needs_good_pull=needs_good_pull or af.x>=a1.x
|
||||
if (needs_good_pull and _ang_diff(pull_ang,0.0)>=0.165) return {}
|
||||
|
||||
-- push left
|
||||
mx=(a0.x-1)\8
|
||||
dmx=-1
|
||||
elseif a0.x%8==7 and a0.x<an.x-7 then
|
||||
needs_good_pull=needs_good_pull or af.x<=a1.x
|
||||
if (needs_good_pull and _ang_diff(pull_ang,0.5)>=0.165) return {}
|
||||
|
||||
-- push right
|
||||
mx=(a0.x+1)\8
|
||||
dmx=1
|
||||
@ -1596,17 +1573,11 @@ function rope:_calc_push(
|
||||
|
||||
local my,dmy
|
||||
if a0.y%8==0 and a0.y>an.y+6 then
|
||||
needs_good_pull=needs_good_pull or af.y>=a1.y
|
||||
if (needs_good_pull and _ang_diff(pull_ang,0.75)>=0.135) return {}
|
||||
|
||||
-- push up
|
||||
my=(a0.y-1)\8
|
||||
dmy=-1
|
||||
|
||||
elseif a0.y%8==7 and a0.y<an.y-6 then
|
||||
needs_good_pull=needs_good_pull or af.y<=a1.y
|
||||
if (needs_good_pull and _ang_diff(pull_ang,0.25)>=0.135) return {}
|
||||
|
||||
-- push down
|
||||
my=(a0.y+1)\8
|
||||
dmy=1
|
||||
|
Loading…
Reference in New Issue
Block a user