mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
[lua] Ported IKConstraint fix.
This commit is contained in:
parent
75041ab65e
commit
5f1431c397
@ -216,21 +216,24 @@ function IkConstraint:apply2 (parent, child, targetX, targetY, bendDir, alpha)
|
|||||||
local maxX = l1 + a
|
local maxX = l1 + a
|
||||||
local maxDist = maxX * maxX
|
local maxDist = maxX * maxX
|
||||||
local maxY = 0
|
local maxY = 0
|
||||||
local angle = math_acos(-a * l1 / (aa - bb))
|
c = -a * l1 / (aa - bb)
|
||||||
x = a * math_cos(angle) + l1
|
if (c >= -1 and c <= 1) then
|
||||||
y = b * math_sin(angle)
|
c = math_acos(c)
|
||||||
d = x * x + y * y
|
x = a * math_cos(c) + l1
|
||||||
if d < minDist then
|
y = b * math_sin(c)
|
||||||
minAngle = angle
|
d = x * x + y * y
|
||||||
minDist = d
|
if d < minDist then
|
||||||
minX = x
|
minAngle = c
|
||||||
minY = y
|
minDist = d
|
||||||
end
|
minX = x
|
||||||
if d > maxDist then
|
minY = y
|
||||||
maxAngle = angle
|
end
|
||||||
maxDist = d
|
if d > maxDist then
|
||||||
maxX = x
|
maxAngle = c
|
||||||
maxY = y
|
maxDist = d
|
||||||
|
maxX = x
|
||||||
|
maxY = y
|
||||||
|
end
|
||||||
end
|
end
|
||||||
if dd <= (minDist + maxDist) / 2 then
|
if dd <= (minDist + maxDist) / 2 then
|
||||||
a1 = ta - math_atan2(minY * bendDir, minX)
|
a1 = ta - math_atan2(minY * bendDir, minX)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user