internal NodeTemplate(Schema2.Node srcNode, int parentIdx, int[] childIndices, bool isolateMemory) { _LogicalSourceIndex = srcNode.LogicalIndex; _ParentIndex = parentIdx; _ChildIndices = childIndices; Name = srcNode.Name; _LocalMatrix = srcNode.LocalMatrix; _LocalTransform = srcNode.LocalTransform; _Scale = new AnimatableProperty <Vector3>(_LocalTransform.Scale); _Rotation = new AnimatableProperty <Quaternion>(_LocalTransform.Rotation); _Translation = new AnimatableProperty <Vector3>(_LocalTransform.Translation); var mw = Transforms.SparseWeight8.Create(srcNode.MorphWeights); _Morphing = new AnimatableProperty <Transforms.SparseWeight8>(mw); foreach (var anim in srcNode.LogicalParent.LogicalAnimations) { var index = anim.LogicalIndex; var name = anim.Name; var scaAnim = anim.FindScaleSampler(srcNode)?.CreateCurveSampler(isolateMemory); if (scaAnim != null) { _Scale.AddCurve(index, name, scaAnim); } var rotAnim = anim.FindRotationSampler(srcNode)?.CreateCurveSampler(isolateMemory); if (rotAnim != null) { _Rotation.AddCurve(index, name, rotAnim); } var traAnim = anim.FindTranslationSampler(srcNode)?.CreateCurveSampler(isolateMemory); if (traAnim != null) { _Translation.AddCurve(index, name, traAnim); } var mrpAnim = anim.FindSparseMorphSampler(srcNode)?.CreateCurveSampler(isolateMemory); if (mrpAnim != null) { _Morphing.AddCurve(index, name, mrpAnim); } } _UsePrecomputed = !(_Scale.IsAnimated | _Rotation.IsAnimated | _Translation.IsAnimated); if (_UsePrecomputed) { _Scale = null; _Rotation = null; _Translation = null; } }
internal NodeTemplate(Schema2.Node srcNode, int parentIdx, int[] childIndices, RuntimeOptions options) { _LogicalSourceIndex = srcNode.LogicalIndex; _ParentIndex = parentIdx; _ChildIndices = childIndices; Name = srcNode.Name; Extras = RuntimeOptions.ConvertExtras(srcNode, options); _LocalTransform = srcNode.LocalTransform; if (_LocalTransform.TryDecompose(out TRANSFORM lxform)) { _Scale = new AnimatableProperty <Vector3>(lxform.Scale); _Rotation = new AnimatableProperty <Quaternion>(lxform.Rotation); _Translation = new AnimatableProperty <Vector3>(lxform.Translation); } var mw = Transforms.SparseWeight8.Create(srcNode.MorphWeights); _Morphing = new AnimatableProperty <Transforms.SparseWeight8>(mw); var isolateMemory = options?.IsolateMemory ?? false; foreach (var anim in srcNode.LogicalParent.LogicalAnimations) { var index = anim.LogicalIndex; var curves = srcNode.GetCurveSamplers(anim); _Scale.SetCurve(index, curves.Scale?.CreateCurveSampler(isolateMemory)); _Rotation.SetCurve(index, curves.Rotation?.CreateCurveSampler(isolateMemory)); _Translation.SetCurve(index, curves.Translation?.CreateCurveSampler(isolateMemory)); _Morphing.SetCurve(index, curves.GetMorphingSampler <Transforms.SparseWeight8>()?.CreateCurveSampler(isolateMemory)); } _UseAnimatedTransforms = _Scale.IsAnimated | _Rotation.IsAnimated | _Translation.IsAnimated; if (!_UseAnimatedTransforms) { _Scale = null; _Rotation = null; _Translation = null; } }