model/blend: bone / path split ends at the first unescaped '"]' (constraint paths kept whole in path)
This commit is contained in:
1 parent
888ff212c3
commit
d64adc978f
10 files changed
+475
-391
No files matched your search
@@ -497,11 +497,29 @@ function Anim.range(curves: { Curve }): (number, number)
|
||||
return lo, hi
|
||||
end
|
||||
|
||||
-- RNA path 'kind["name"].rest': name ends at the first unescaped '"]', rest may hold more subscripts
|
||||
function Anim.split(path: string): (string?, string?, string)
|
||||
local kind, name, rest = string.match(path, '^(%w[%w_%.]-)%["(.-)"%]%.([%w_]+)$')
|
||||
if kind and name and rest then
|
||||
name = string.gsub(name, '\\(.)', "%1")
|
||||
return kind, name, rest
|
||||
local kind, at = string.match(path, '^(%w[%w_%.]-)%["()')
|
||||
if kind then
|
||||
local i = at :: number
|
||||
while true do
|
||||
local q = string.find(path, '"', i, true)
|
||||
if not q then
|
||||
break
|
||||
end
|
||||
local bs = 0
|
||||
while q - bs - 1 >= at and string.byte(path, q - bs - 1) == 92 do
|
||||
bs += 1
|
||||
end
|
||||
if bs % 2 == 0 then
|
||||
if string.sub(path, q + 1, q + 2) == "]." and q + 3 <= #path then
|
||||
local name = string.gsub(string.sub(path, at, q - 1), '\\(.)', "%1")
|
||||
return kind, name, string.sub(path, q + 3)
|
||||
end
|
||||
break
|
||||
end
|
||||
i = q + 1
|
||||
end
|
||||
end
|
||||
return nil, nil, path
|
||||
end
|
||||
|
||||
@@ -860,8 +860,8 @@ local function animations(ctx: Ctx)
|
||||
local tracks = {}
|
||||
local touched = {}
|
||||
for _, c in j.curves do
|
||||
local kind, who = Anim.split(c.path)
|
||||
if kind == "pose.bones" and who and info.names[who] then
|
||||
local kind, who, rest = Anim.split(c.path)
|
||||
if kind == "pose.bones" and who and info.names[who] and string.find(rest, "^[%w_]+$") then
|
||||
touched[info.names[who]] = true
|
||||
end
|
||||
end
|
||||
|
||||
Reference in new issue
Block a user