ws-game: model/smd (Valve SMD read + write: skeleton, skin, weights links, frames as animation, animation SMDs); Rig.influences merges a joint listed twice
This commit is contained in:
1 parent
f14d5ac4ef
commit
08045ba813
9 files changed
+938
-2
No files matched your search
@@ -198,15 +198,24 @@ function Rig.skeleton(scene: Types.Scene, joints: { Joint }, space: "local" | "w
|
||||
end
|
||||
|
||||
-- influences(lists) -> JOINTS_0 (u16 x4), WEIGHTS_0 (f32 x4): lists[v] = { joint, weight, joint, weight, ... } with
|
||||
-- 0-based joint indices (into the skin's joints); the four largest weights are kept and normalised to sum 1.
|
||||
-- 0-based joint indices (into the skin's joints; a joint listed twice adds up); the four largest weights are kept
|
||||
-- and normalised to sum 1.
|
||||
function Rig.influences(lists: { { number } }): (Types.Accessor, Types.Accessor)
|
||||
local n = #lists
|
||||
local jb, wb = buffer.create(n * 8), buffer.create(n * 16)
|
||||
for v, l in lists do
|
||||
local pairs_: { { number } } = {}
|
||||
local at: { [number]: { number } } = {}
|
||||
for k = 1, #l - 1, 2 do
|
||||
if l[k + 1] > 0 then
|
||||
table.insert(pairs_, { l[k], l[k + 1] })
|
||||
local same = at[l[k]]
|
||||
if same then
|
||||
same[2] += l[k + 1] -- the same joint twice: one influence
|
||||
else
|
||||
local e = { l[k], l[k + 1] }
|
||||
at[l[k]] = e
|
||||
table.insert(pairs_, e)
|
||||
end
|
||||
end
|
||||
end
|
||||
table.sort(pairs_, function(a: { number }, b: { number }): boolean
|
||||
|
||||
Reference in new issue
Block a user