/// <summary> /// Updates the parent <see cref="SkeletonAnimation"/> that this modifier modifies. /// </summary> /// <param name="src">Source root <see cref="SkeletonNode"/>.</param> /// <param name="dest">Destination root <see cref="SkeletonNode"/>.</param> static void RecursiveUpdateParent(SkeletonNode src, SkeletonNode dest) { // Update modified values if (src.IsModifier && dest.Parent != null) { dest.SetAngle(src.GetAngle()); } // Update the child nodes (if there is any) for (var i = 0; i < src.internalNodes.Count; i++) { RecursiveUpdateParent(src.internalNodes[i], dest.internalNodes[i]); } }
/// <summary> /// Recursively updates all the children of a node. /// </summary> /// <param name="srcA">Source skeleton node for the current frame.</param> /// <param name="srcB">Source skeleton node for the next frame.</param> /// <param name="srcP">Parent skeleton node (use null if theres no parent).</param> /// <param name="dest">Destination skeleton node to have the two sources applied to.</param> /// <param name="framePercent">A value between 0.0 and 1.0 stating how far along the animation is /// from the current frame.</param> void RecursiveUpdate(SkeletonNode srcA, SkeletonNode srcB, SkeletonNode srcP, SkeletonNode dest, float framePercent) { // Set the position Vector2 vA; Vector2 vB; if (_scale == 1.0f) { vA = srcA.Position; vB = srcB.Position; } else { vA = srcA.Position * _scale; vB = srcB.Position * _scale; } dest.Position = Vector2.Lerp(vA, vB, framePercent); // Check if the node is part of a modifier animation if (srcP == null) { // Set the length dest.SetLength(srcA.GetLength() * _scale); } else { // This is a modifier so check for inheriting node values dest.SetLength(srcP.GetLength()); if (!srcP.IsModifier && srcP.Parent != null) { dest.SetAngle(srcP.GetAngle()); } } // Update the child nodes (if there is any) for (var i = 0; i < srcA.internalNodes.Count; i++) { var nextSrcP = (srcP == null ? null : srcP.internalNodes[i]); RecursiveUpdate(srcA.internalNodes[i], srcB.internalNodes[i], nextSrcP, dest.internalNodes[i], framePercent); } }
/// <summary> /// Updates the parent <see cref="SkeletonAnimation"/> that this modifier modifies. /// </summary> /// <param name="src">Source root <see cref="SkeletonNode"/>.</param> /// <param name="dest">Destination root <see cref="SkeletonNode"/>.</param> static void RecursiveUpdateParent(SkeletonNode src, SkeletonNode dest) { // Update modified values if (src.IsModifier && dest.Parent != null) dest.SetAngle(src.GetAngle()); // Update the child nodes (if there is any) for (var i = 0; i < src.internalNodes.Count; i++) { RecursiveUpdateParent(src.internalNodes[i], dest.internalNodes[i]); } }
/// <summary> /// Recursively updates all the children of a node. /// </summary> /// <param name="srcA">Source skeleton node for the current frame.</param> /// <param name="srcB">Source skeleton node for the next frame.</param> /// <param name="srcP">Parent skeleton node (use null if theres no parent).</param> /// <param name="dest">Destination skeleton node to have the two sources applied to.</param> /// <param name="framePercent">A value between 0.0 and 1.0 stating how far along the animation is /// from the current frame.</param> void RecursiveUpdate(SkeletonNode srcA, SkeletonNode srcB, SkeletonNode srcP, SkeletonNode dest, float framePercent) { // Set the position Vector2 vA; Vector2 vB; if (_scale == 1.0f) { vA = srcA.Position; vB = srcB.Position; } else { vA = srcA.Position * _scale; vB = srcB.Position * _scale; } dest.Position = Vector2.Lerp(vA, vB, framePercent); // Check if the node is part of a modifier animation if (srcP == null) { // Set the length dest.SetLength(srcA.GetLength() * _scale); } else { // This is a modifier so check for inheriting node values dest.SetLength(srcP.GetLength()); if (!srcP.IsModifier && srcP.Parent != null) dest.SetAngle(srcP.GetAngle()); } // Update the child nodes (if there is any) for (var i = 0; i < srcA.internalNodes.Count; i++) { var nextSrcP = (srcP == null ? null : srcP.internalNodes[i]); RecursiveUpdate(srcA.internalNodes[i], srcB.internalNodes[i], nextSrcP, dest.internalNodes[i], framePercent); } }