using System.Collections.Generic; using UniGLTF.Utils; using UnityEngine; namespace UniVRM10 { internal sealed class NodeTransformBindingMerger { IReadOnlyDictionary _clipMap; Transform _root; IReadOnlyDictionary _initPose; Dictionary _weightMap = new(); public NodeTransformBindingMerger( IReadOnlyDictionary clipMap, Transform root, IReadOnlyDictionary initPose) { _clipMap = clipMap; _root = root; _initPose = initPose; } public void AccumulateValue(ExpressionKey key, float value) { _weightMap[key] = value; } public void Apply() { foreach (var (k, weight) in _weightMap) { if (_clipMap.TryGetValue(k, out var clip)) { foreach (var b in clip.NodeTransformBindings) { var node = _root.GetFromPath(b.RelativePath); if (node != null) { if (_initPose.TryGetValue(node, out var init)) { b.Apply(node, init, weight); } } } } } } } }