RootMotion.FinalIK.IKSolver.HierarchyIsValid C# (CSharp) Method

HierarchyIsValid() public static method

public static HierarchyIsValid ( IKSolver bones ) : bool
bones IKSolver
return bool
		public static bool HierarchyIsValid(IKSolver.Bone[] bones) {
			for (int i = 1; i < bones.Length; i++) {
				// If parent bone is not an ancestor of bone, the hierarchy is invalid
				if (!Hierarchy.IsAncestor(bones[i].transform, bones[i - 1].transform)) {
					return false;
				}
			}
			return true;
		}

Usage Example

        public override bool IsValid(ref string message)
        {
            if (this.bones.Length == 0)
            {
                message = "IK chain has no Bones.";
                return(false);
            }
            if (this.bones.Length < this.minBones)
            {
                message = "IK chain has less than " + this.minBones + " Bones.";
                return(false);
            }
            IKSolver.Bone[] array = this.bones;
            for (int i = 0; i < array.Length; i++)
            {
                if (array[i].transform == null)
                {
                    message = "One of the Bones is null.";
                    return(false);
                }
            }
            Transform transform = IKSolver.ContainsDuplicateBone(this.bones);

            if (transform != null)
            {
                message = transform.name + " is represented multiple times in the Bones.";
                return(false);
            }
            if (!this.allowCommonParent && !IKSolver.HierarchyIsValid(this.bones))
            {
                message = "Invalid bone hierarchy detected. IK requires for it's bones to be parented to each other in descending order.";
                return(false);
            }
            if (!this.boneLengthCanBeZero)
            {
                for (int j = 0; j < this.bones.Length - 1; j++)
                {
                    if ((this.bones[j].transform.position - this.bones[j + 1].transform.position).magnitude == 0f)
                    {
                        message = "Bone " + j + " length is zero.";
                        return(false);
                    }
                }
            }
            return(true);
        }
All Usage Examples Of RootMotion.FinalIK.IKSolver::HierarchyIsValid