mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-20 09:16:01 +08:00
[lua] Fix modulo usage in AnimationState, closes #798
This commit is contained in:
parent
e2d76037d8
commit
168186f170
@ -38,6 +38,7 @@ local math_abs = math.abs
|
||||
local math_signum = utils.signum
|
||||
local math_floor = math.floor
|
||||
local math_ceil = math.ceil
|
||||
local math_mod = utils.mod
|
||||
|
||||
local function zlen(array)
|
||||
return #array + 1
|
||||
@ -442,7 +443,7 @@ function AnimationState:applyRotateTimeline (timeline, skeleton, time, alpha, se
|
||||
if math_abs(lastTotal) > 180 then lastTotal = lastTotal + 360 * math_signum(lastTotal) end
|
||||
dir = current
|
||||
end
|
||||
total = diff + lastTotal - math_ceil(lastTotal / 360 - 0.5) * 360 -- FIXME used to be %360, store loops as part of lastTotal.
|
||||
total = diff + lastTotal - math_mod(lastTotal, 360) -- FIXME used to be %360, store loops as part of lastTotal.
|
||||
if dir ~= current then total = total + 360 * math_signum(lastTotal) end
|
||||
timelinesRotation[i] = total
|
||||
end
|
||||
|
||||
@ -138,4 +138,14 @@ function utils.signum (value)
|
||||
end
|
||||
end
|
||||
|
||||
-- Implements Java float modulo
|
||||
function utils.mod(a, b)
|
||||
if b < 0 then b = -b end
|
||||
if a < 0 then
|
||||
return -(-a % b)
|
||||
else
|
||||
return a % b
|
||||
end
|
||||
end
|
||||
|
||||
return utils
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user