HierarchyIsValid() public static method

public static HierarchyIsValid ( IKSolver bones ) : bool
bones IKSolver
return bool
        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);
        }
示例#2
0
        public override bool IsValid(bool log)
        {
            if (this.bones.Length == 0)
            {
                if (log)
                {
                    base.LogWarning("IK chain has no bones. Can not initiate solver.");
                }
                return(false);
            }
            if (this.bones.Length < this.minBones)
            {
                if (log)
                {
                    base.LogWarning("IK chain has less than " + this.minBones + " bones. Can not initiate solver.");
                }
                return(false);
            }
            IKSolver.Bone[] array = this.bones;
            for (int i = 0; i < array.Length; i++)
            {
                IKSolver.Bone bone = array[i];
                if (bone.transform == null)
                {
                    if (log)
                    {
                        base.LogWarning("Bone transform is null in IK chain. Can not initiate solver.");
                    }
                    return(false);
                }
            }
            if (!this.allowCommonParent && !IKSolver.HierarchyIsValid(this.bones))
            {
                if (log)
                {
                    base.LogWarning("IK requires for it's bones to be parented to each other. Invalid bone hierarchy detected.");
                }
                return(false);
            }
            Transform transform = IKSolver.ContainsDuplicateBone(this.bones);

            if (transform != null)
            {
                if (log)
                {
                    base.LogWarning(transform.name + " is represented multiple times in a single IK chain. Can nott initiate solver.");
                }
                return(false);
            }
            if (!this.boneLengthCanBeZero)
            {
                for (int j = 0; j < this.bones.Length - 1; j++)
                {
                    float magnitude = (this.bones[j].transform.position - this.bones[j + 1].transform.position).magnitude;
                    if (magnitude == 0f)
                    {
                        if (log)
                        {
                            base.LogWarning("Bone " + j + " length is zero. Can nott initiate solver.");
                        }
                        return(false);
                    }
                }
            }
            return(true);
        }