Ejemplo n.º 1
0
        /** @return May be null. */
        public IkConstraint FindIkConstraint(String constraintName)
        {
            if (constraintName == null)
            {
                throw new ArgumentNullException("constraintName cannot be null.");
            }
            ExposedList <IkConstraint> ikConstraints = this.ikConstraints;

            for (int i = 0, n = ikConstraints.Count; i < n; i++)
            {
                IkConstraint ikConstraint = ikConstraints.Items[i];
                if (ikConstraint.data.name == constraintName)
                {
                    return(ikConstraint);
                }
            }
            return(null);
        }
Ejemplo n.º 2
0
        /// <summary>Caches information about bones and constraints. Must be called if bones or constraints are added
        /// or removed.</summary>
        public void UpdateCache()
        {
            ExposedList <Bone>                bones                = this.bones;
            ExposedList <IUpdatable>          updateCache          = this.updateCache;
            ExposedList <IkConstraint>        ikConstraints        = this.ikConstraints;
            ExposedList <TransformConstraint> transformConstraints = this.transformConstraints;
            int ikConstraintsCount        = ikConstraints.Count;
            int transformConstraintsCount = transformConstraints.Count;

            updateCache.Clear();
            for (int i = 0, n = bones.Count; i < n; i++)
            {
                Bone bone = bones.Items[i];
                updateCache.Add(bone);
                for (int ii = 0; ii < ikConstraintsCount; ii++)
                {
                    IkConstraint ikConstraint = ikConstraints.Items[ii];
                    if (bone == ikConstraint.bones.Items[ikConstraint.bones.Count - 1])
                    {
                        updateCache.Add(ikConstraint);
                        break;
                    }
                }
            }

            for (int i = 0; i < transformConstraintsCount; i++)
            {
                TransformConstraint transformConstraint = transformConstraints.Items[i];
                for (int ii = updateCache.Count - 1; i >= 0; ii--)
                {
                    IUpdatable updateable = updateCache.Items[ii];
                    if (updateable == transformConstraint.bone || updateable == transformConstraint.target)
                    {
                        updateCache.Insert(ii + 1, transformConstraint);
                        break;
                    }
                }
            }
        }