wip spline support, needs tons of optimizations and testing

This commit is contained in:
jill 2021-03-05 00:07:00 +03:00
parent 4fda77379f
commit 41dbd8a376
Signed by: oat
GPG Key ID: DD83A9617A252385
1 changed files with 115 additions and 0 deletions

115
plugins/mirinda_spline.xml Normal file
View File

@ -0,0 +1,115 @@
<Mods LoadCommand = "%xero(function(self)
local maxindex = 39 -- probably best not to change, but if youre getting massive performance issues go ahead
local validparams = {'x', 'y', 'z', 'rotx', 'roty', 'rotz', 'size', 'stealth', 'skew'}
local parambindings = {
x = 'XSpline',
y = 'YSpline',
z = 'ZSpline',
rotx = 'RotXSpline',
roty = 'RotYSpline',
rotz = 'RotZSpline',
size = 'SizeSpline',
skew = 'SkewSpline',
stealth = 'StealthSpline',
}
mirinda_splinetable = {}
-- spline {name, function(a, ..., y, column, pn)}
function spline(self)
if type(self) ~= 'table' then
screen_error('curly braces expected', 0, 'spline')
return node
end
local name = self[1]
local funct = self[2]
local names = {name, name .. 0, name .. 1, name .. 2, name .. 3}
for _,n in ipairs(names) do
aux {n}
mirinda_splinetable[n] = {}
for pn = 1, 8 do
mirinda_splinetable[n][pn] = {}
end
end
node {name, function(a, pn)
for c = 1, 4 do
for i = 0, maxindex do
local res = funct(a, i/maxindex, c, pn)
if res ~= nil then
for mod,b in pairs(res) do
mirinda_splinetable[name][pn][mod] = mirinda_splinetable[name][pn][mod] or {}
mirinda_splinetable[name][pn][mod][c] = mirinda_splinetable[name][pn][mod][c] or {}
mirinda_splinetable[name][pn][mod][c][i] = b
end
end
end
end
end}
for c = 1, 4 do
local c = c
local name = name .. (c - 1)
print(name)
node {name, function(a, pn)
for i = 0, maxindex do
local res = funct(a, i/maxindex, c, pn)
if res ~= nil then
for mod,b in pairs(res) do
mirinda_splinetable[name][pn][mod] = mirinda_splinetable[name][pn][mod] or {}
mirinda_splinetable[name][pn][mod][c] = mirinda_splinetable[name][pn][mod][c] or {}
mirinda_splinetable[name][pn][mod][c][i] = b
end
end
end
end}
end
end
local usedsplines = {}
local modinuse = {}
func {0, 9e9, function(beat, poptions)
-- reset splines
for name,m in pairs(parambindings) do
for pn = 1, 8 do
if usedsplines[pn] and usedsplines[pn][name] then P[pn]['Reset' .. m .. 's'](P[pn], -1) end
usedsplines[pn] = usedsplines[pn] or {}
usedsplines[pn][name] = false
end
end
-- recombine and apply
local combined = {}
for pn = 1, 8 do
for mod,bind in pairs(parambindings) do
for c = 1, 4 do
for name,n in pairs(mirinda_splinetable) do
if poptions[pn][name] ~= 0 then
usedsplines[pn] = usedsplines[pn] or {}
usedsplines[pn][mod] = true
if mirinda_splinetable[name][pn][mod] and mirinda_splinetable[name][pn][mod][c] then
combined[name] = combined[name] or {}
combined[name][pn] = combined[name][pn] or {}
combined[name][pn][mod] = combined[name][pn][mod] or {}
combined[name][pn][mod][c] = combined[name][pn][mod][c] or {}
for i = 0, maxindex do
combined[name][pn][mod][c][i] = (combined[name][pn][mod][c][i] or 0) + mirinda_splinetable[name][pn][mod][c][i]
P[pn]['Set' .. bind](P[pn], i, c - 1, combined[name][pn][mod][c][i], (i / maxindex) * 100 * 10, -1)
end
end
end
end
end
end
end
end}
end)"
Type = "ActorFrame"/>