Inheritance: IConstraint
コード例 #1
0
        /// <summary>Sets the bones and constraints to their setup pose values.</summary>
        public void SetBonesToSetupPose()
        {
            var bones = this.bones.Items;

            for (int i = 0, n = this.bones.Count; i < n; i++)
            {
                bones[i].SetToSetupPose();
            }

            var ikConstraints = this.ikConstraints.Items;

            for (int i = 0, n = this.ikConstraints.Count; i < n; i++)
            {
                IkConstraint     constraint = ikConstraints[i];
                IkConstraintData data       = constraint.data;
                constraint.mix           = data.mix;
                constraint.softness      = data.softness;
                constraint.bendDirection = data.bendDirection;
                constraint.compress      = data.compress;
                constraint.stretch       = data.stretch;
            }

            var transformConstraints = this.transformConstraints.Items;

            for (int i = 0, n = this.transformConstraints.Count; i < n; i++)
            {
                TransformConstraint     constraint = transformConstraints[i];
                TransformConstraintData data       = constraint.data;
                constraint.mixRotate = data.mixRotate;
                constraint.mixX      = data.mixX;
                constraint.mixY      = data.mixY;
                constraint.mixScaleX = data.mixScaleX;
                constraint.mixScaleY = data.mixScaleY;
                constraint.mixShearY = data.mixShearY;
            }

            var pathConstraints = this.pathConstraints.Items;

            for (int i = 0, n = this.pathConstraints.Count; i < n; i++)
            {
                PathConstraint     constraint = pathConstraints[i];
                PathConstraintData data       = constraint.data;
                constraint.position  = data.position;
                constraint.spacing   = data.spacing;
                constraint.mixRotate = data.mixRotate;
                constraint.mixX      = data.mixX;
                constraint.mixY      = data.mixY;
            }
        }
コード例 #2
0
ファイル: SkeletonExtensions.cs プロジェクト: mrdivdiz/bpvita
 public static void SetToSetupPose(this Timeline timeline, Skeleton skeleton)
 {
     if (timeline != null)
     {
         if (timeline is RotateTimeline)
         {
             Bone bone = skeleton.bones.Items[((RotateTimeline)timeline).boneIndex];
             bone.rotation = bone.data.rotation;
         }
         else if (timeline is TranslateTimeline)
         {
             Bone bone2 = skeleton.bones.Items[((TranslateTimeline)timeline).boneIndex];
             bone2.x = bone2.data.x;
             bone2.y = bone2.data.y;
         }
         else if (timeline is ScaleTimeline)
         {
             Bone bone3 = skeleton.bones.Items[((ScaleTimeline)timeline).boneIndex];
             bone3.scaleX = bone3.data.scaleX;
             bone3.scaleY = bone3.data.scaleY;
         }
         else if (timeline is DeformTimeline)
         {
             Slot slot = skeleton.slots.Items[((DeformTimeline)timeline).slotIndex];
             slot.attachmentVertices.Clear(false);
         }
         else if (timeline is AttachmentTimeline)
         {
             skeleton.SetSlotAttachmentToSetupPose(((AttachmentTimeline)timeline).slotIndex);
         }
         else if (timeline is ColorTimeline)
         {
             skeleton.slots.Items[((ColorTimeline)timeline).slotIndex].SetColorToSetupPose();
         }
         else if (timeline is IkConstraintTimeline)
         {
             IkConstraintTimeline ikConstraintTimeline = (IkConstraintTimeline)timeline;
             IkConstraint         ikConstraint         = skeleton.ikConstraints.Items[ikConstraintTimeline.ikConstraintIndex];
             IkConstraintData     data = ikConstraint.data;
             ikConstraint.bendDirection = data.bendDirection;
             ikConstraint.mix           = data.mix;
         }
         else if (timeline is DrawOrderTimeline)
         {
             skeleton.SetDrawOrderToSetupPose();
         }
     }
 }
コード例 #3
0
 static int FindIkConstraint(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         Spine.Skeleton     obj  = (Spine.Skeleton)ToLua.CheckObject <Spine.Skeleton>(L, 1);
         string             arg0 = ToLua.CheckString(L, 2);
         Spine.IkConstraint o    = obj.FindIkConstraint(arg0);
         ToLua.PushObject(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
コード例 #4
0
ファイル: Skeleton.cs プロジェクト: DeStiCap/Dim-Mind
        /// <summary>Sets the bones and constraints to their setup pose values.</summary>
        public void SetBonesToSetupPose()
        {
            var bonesItems = this.bones.Items;

            for (int i = 0, n = bones.Count; i < n; i++)
            {
                bonesItems[i].SetToSetupPose();
            }

            var ikConstraintsItems = this.ikConstraints.Items;

            for (int i = 0, n = ikConstraints.Count; i < n; i++)
            {
                IkConstraint constraint = ikConstraintsItems[i];
                constraint.mix           = constraint.data.mix;
                constraint.softness      = constraint.data.softness;
                constraint.bendDirection = constraint.data.bendDirection;
                constraint.compress      = constraint.data.compress;
                constraint.stretch       = constraint.data.stretch;
            }

            var transformConstraintsItems = this.transformConstraints.Items;

            for (int i = 0, n = transformConstraints.Count; i < n; i++)
            {
                TransformConstraint     constraint     = transformConstraintsItems[i];
                TransformConstraintData constraintData = constraint.data;
                constraint.rotateMix    = constraintData.rotateMix;
                constraint.translateMix = constraintData.translateMix;
                constraint.scaleMix     = constraintData.scaleMix;
                constraint.shearMix     = constraintData.shearMix;
            }

            var pathConstraintItems = this.pathConstraints.Items;

            for (int i = 0, n = pathConstraints.Count; i < n; i++)
            {
                PathConstraint     constraint     = pathConstraintItems[i];
                PathConstraintData constraintData = constraint.data;
                constraint.position     = constraintData.position;
                constraint.spacing      = constraintData.spacing;
                constraint.rotateMix    = constraintData.rotateMix;
                constraint.translateMix = constraintData.translateMix;
            }
        }
コード例 #5
0
        public void apply()
        {
            Bone bone = this.target;
            ExposedList <Bone> exposedList = this.bones;
            int count = exposedList.Count;

            if (count != 1)
            {
                if (count == 2)
                {
                    IkConstraint.apply(exposedList.Items[0], exposedList.Items[1], bone.worldX, bone.worldY, this.bendDirection, this.mix);
                }
            }
            else
            {
                IkConstraint.apply(exposedList.Items[0], bone.worldX, bone.worldY, this.mix);
            }
        }
コード例 #6
0
        public void SetBonesToSetupPose()
        {
            List <Bone> bones = this.bones;

            for (int i = 0, n = bones.Count; i < n; i++)
            {
                bones[i].SetToSetupPose();
            }

            List <IkConstraint> ikConstraints = this.ikConstraints;

            for (int i = 0, n = ikConstraints.Count; i < n; i++)
            {
                IkConstraint ikConstraint = ikConstraints[i];
                ikConstraint.bendDirection = ikConstraint.data.bendDirection;
                ikConstraint.mix           = ikConstraint.data.mix;
            }
        }
コード例 #7
0
ファイル: Skeleton.cs プロジェクト: rickymm3/explorers-mobile
        /// <returns>May be null.</returns>
        public IkConstraint FindIkConstraint(string constraintName)
        {
            if (constraintName == null)
            {
                throw new ArgumentNullException("constraintName", "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);
        }
コード例 #8
0
        public void SetBonesToSetupPose()
        {
            Bone[] items = bones.Items;
            int    i     = 0;

            for (int count = bones.Count; i < count; i++)
            {
                items[i].SetToSetupPose();
            }
            IkConstraint[] items2 = ikConstraints.Items;
            int            j      = 0;

            for (int count2 = ikConstraints.Count; j < count2; j++)
            {
                IkConstraint ikConstraint = items2[j];
                ikConstraint.bendDirection = ikConstraint.data.bendDirection;
                ikConstraint.mix           = ikConstraint.data.mix;
            }
            TransformConstraint[] items3 = transformConstraints.Items;
            int k = 0;

            for (int count3 = transformConstraints.Count; k < count3; k++)
            {
                TransformConstraint     transformConstraint     = items3[k];
                TransformConstraintData transformConstraintData = transformConstraint.data;
                transformConstraint.rotateMix    = transformConstraintData.rotateMix;
                transformConstraint.translateMix = transformConstraintData.translateMix;
                transformConstraint.scaleMix     = transformConstraintData.scaleMix;
                transformConstraint.shearMix     = transformConstraintData.shearMix;
            }
            PathConstraint[] items4 = pathConstraints.Items;
            int l = 0;

            for (int count4 = pathConstraints.Count; l < count4; l++)
            {
                PathConstraint     pathConstraint     = items4[l];
                PathConstraintData pathConstraintData = pathConstraint.data;
                pathConstraint.position     = pathConstraintData.position;
                pathConstraint.spacing      = pathConstraintData.spacing;
                pathConstraint.rotateMix    = pathConstraintData.rotateMix;
                pathConstraint.translateMix = pathConstraintData.translateMix;
            }
        }
コード例 #9
0
ファイル: Skeleton.cs プロジェクト: renruoyu1989/rougelikeman
        public IkConstraint FindIkConstraint(string constraintName)
        {
            if (constraintName == null)
            {
                throw new ArgumentNullException("constraintName", "constraintName cannot be null.");
            }
            ExposedList <IkConstraint> ikConstraints = this.ikConstraints;
            int index = 0;
            int count = ikConstraints.Count;

            while (index < count)
            {
                IkConstraint constraint = ikConstraints.Items[index];
                if (constraint.data.name == constraintName)
                {
                    return(constraint);
                }
                index++;
            }
            return(null);
        }
コード例 #10
0
        public IkConstraint FindIkConstraint(string ikConstraintName)
        {
            if (ikConstraintName == null)
            {
                throw new ArgumentNullException("ikConstraintName cannot be null.");
            }
            ExposedList <IkConstraint> exposedList = this.ikConstraints;
            int i     = 0;
            int count = exposedList.Count;

            while (i < count)
            {
                IkConstraint ikConstraint = exposedList.Items[i];
                if (ikConstraint.data.name == ikConstraintName)
                {
                    return(ikConstraint);
                }
                i++;
            }
            return(null);
        }
コード例 #11
0
ファイル: Skeleton.cs プロジェクト: renruoyu1989/rougelikeman
        private void SortIkConstraint(IkConstraint constraint)
        {
            Bone target = constraint.target;

            this.SortBone(target);
            ExposedList <Bone> bones = constraint.bones;
            Bone bone = bones.Items[0];

            this.SortBone(bone);
            if (bones.Count > 1)
            {
                Bone item = bones.Items[bones.Count - 1];
                if (!this.updateCache.Contains(item))
                {
                    this.updateCacheReset.Add(item);
                }
            }
            this.updateCache.Add(constraint);
            SortReset(bone.children);
            bones.Items[bones.Count - 1].sorted = true;
        }
コード例 #12
0
        private void SortIkConstraint(IkConstraint constraint)
        {
            Bone target = constraint.target;

            SortBone(target);
            ExposedList <Bone> exposedList = constraint.bones;
            Bone bone = exposedList.Items[0];

            SortBone(bone);
            if (exposedList.Count > 1)
            {
                Bone item = exposedList.Items[exposedList.Count - 1];
                if (!updateCache.Contains(item))
                {
                    updateCacheReset.Add(item);
                }
            }
            updateCache.Add(constraint);
            SortReset(bone.children);
            exposedList.Items[exposedList.Count - 1].sorted = true;
        }
コード例 #13
0
ファイル: IkConstraint.cs プロジェクト: Phamdat210/HayDayFarm
 /// <summary>Copy constructor.</summary>
 public IkConstraint(IkConstraint constraint, Skeleton skeleton)
 {
     if (constraint == null)
     {
         throw new ArgumentNullException("constraint cannot be null.");
     }
     if (skeleton == null)
     {
         throw new ArgumentNullException("skeleton cannot be null.");
     }
     data  = constraint.data;
     bones = new ExposedList <Bone>(constraint.Bones.Count);
     foreach (Bone bone in constraint.Bones)
     {
         bones.Add(skeleton.Bones.Items[bone.data.index]);
     }
     target        = skeleton.Bones.Items[constraint.target.data.index];
     mix           = constraint.mix;
     bendDirection = constraint.bendDirection;
     compress      = constraint.compress;
     stretch       = constraint.stretch;
 }
コード例 #14
0
ファイル: Skeleton.cs プロジェクト: kenshin122/fortfolio
        /// <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;
                    }
                }
            }
        }
コード例 #15
0
        public void SetBonesToSetupPose()
        {
            ExposedList <Bone> exposedList = this.bones;
            int i     = 0;
            int count = exposedList.Count;

            while (i < count)
            {
                exposedList.Items[i].SetToSetupPose();
                i++;
            }
            ExposedList <IkConstraint> exposedList2 = this.ikConstraints;
            int j      = 0;
            int count2 = exposedList2.Count;

            while (j < count2)
            {
                IkConstraint ikConstraint = exposedList2.Items[j];
                ikConstraint.bendDirection = ikConstraint.data.bendDirection;
                ikConstraint.mix           = ikConstraint.data.mix;
                j++;
            }
        }
コード例 #16
0
        public void UpdateCache()
        {
            ExposedList <IUpdatable> exposedList = updateCache;

            exposedList.Clear();
            updateCacheReset.Clear();
            ExposedList <Bone> exposedList2 = bones;
            int i = 0;

            for (int count = exposedList2.Count; i < count; i++)
            {
                exposedList2.Items[i].sorted = false;
            }
            ExposedList <IkConstraint>        exposedList3 = ikConstraints;
            ExposedList <TransformConstraint> exposedList4 = transformConstraints;
            ExposedList <PathConstraint>      exposedList5 = pathConstraints;
            int count2 = IkConstraints.Count;
            int count3 = exposedList4.Count;
            int count4 = exposedList5.Count;
            int num    = count2 + count3 + count4;

            for (int j = 0; j < num; j++)
            {
                int num2 = 0;
                while (true)
                {
                    if (num2 < count2)
                    {
                        IkConstraint ikConstraint = exposedList3.Items[num2];
                        if (ikConstraint.data.order == j)
                        {
                            SortIkConstraint(ikConstraint);
                            break;
                        }
                        num2++;
                        continue;
                    }
                    int num3 = 0;
                    while (true)
                    {
                        if (num3 < count3)
                        {
                            TransformConstraint transformConstraint = exposedList4.Items[num3];
                            if (transformConstraint.data.order == j)
                            {
                                SortTransformConstraint(transformConstraint);
                                break;
                            }
                            num3++;
                            continue;
                        }
                        for (int k = 0; k < count4; k++)
                        {
                            PathConstraint pathConstraint = exposedList5.Items[k];
                            if (pathConstraint.data.order == j)
                            {
                                SortPathConstraint(pathConstraint);
                                break;
                            }
                        }
                        break;
                    }
                    break;
                }
            }
            int l = 0;

            for (int count5 = exposedList2.Count; l < count5; l++)
            {
                SortBone(exposedList2.Items[l]);
            }
        }
コード例 #17
0
		private void SortIkConstraint (IkConstraint constraint) {
			Bone target = constraint.target;
			SortBone(target);

			var constrained = constraint.bones;
			Bone parent = constrained.Items[0];
			SortBone(parent);

			if (constrained.Count > 1) {
				Bone child = constrained.Items[constrained.Count - 1];
				if (!updateCache.Contains(child))
					updateCacheReset.Add(child);
			}

			updateCache.Add(constraint);

			SortReset(parent.children);
			constrained.Items[constrained.Count - 1].sorted = true;
		}
コード例 #18
0
        /// <summary>Caches information about bones and constraints. Must be called if bones, constraints or weighted path attachments are added
        /// or removed.</summary>
        public void UpdateCache()
        {
            ExposedList <IUpdatable> updateCache = this.updateCache;

            updateCache.Clear();

            ExposedList <Bone> bones = this.bones;

            for (int i = 0, n = bones.Count; i < n; i++)
            {
                bones.Items[i].sorted = false;
            }

            ExposedList <IkConstraint> ikConstraints = this.ikConstraintsSorted;

            ikConstraints.Clear();
            ikConstraints.AddRange(this.ikConstraints);
            int ikCount = ikConstraints.Count;

            for (int i = 0, level, n = ikCount; i < n; i++)
            {
                IkConstraint ik   = ikConstraints.Items[i];
                Bone         bone = ik.bones.Items[0].parent;
                for (level = 0; bone != null; level++)
                {
                    bone = bone.parent;
                }
                ik.level = level;
            }
            for (int i = 1, ii; i < ikCount; i++)
            {
                IkConstraint ik    = ikConstraints.Items[i];
                int          level = ik.level;
                for (ii = i - 1; ii >= 0; ii--)
                {
                    IkConstraint other = ikConstraints.Items[ii];
                    if (other.level < level)
                    {
                        break;
                    }
                    ikConstraints.Items[ii + 1] = other;
                }
                ikConstraints.Items[ii + 1] = ik;
            }
            for (int i = 0, n = ikConstraints.Count; i < n; i++)
            {
                IkConstraint constraint = ikConstraints.Items[i];
                Bone         target     = constraint.target;
                SortBone(target);

                ExposedList <Bone> constrained = constraint.bones;
                Bone parent = constrained.Items[0];
                SortBone(parent);

                updateCache.Add(constraint);

                SortReset(parent.children);
                constrained.Items[constrained.Count - 1].sorted = true;
            }

            ExposedList <PathConstraint> pathConstraints = this.pathConstraints;

            for (int i = 0, n = pathConstraints.Count; i < n; i++)
            {
                PathConstraint constraint = pathConstraints.Items[i];

                Slot slot      = constraint.target;
                int  slotIndex = slot.data.index;
                Bone slotBone  = slot.bone;
                if (skin != null)
                {
                    SortPathConstraintAttachment(skin, slotIndex, slotBone);
                }
                if (data.defaultSkin != null && data.defaultSkin != skin)
                {
                    SortPathConstraintAttachment(data.defaultSkin, slotIndex, slotBone);
                }
                for (int ii = 0, nn = data.skins.Count; ii < nn; ii++)
                {
                    SortPathConstraintAttachment(data.skins.Items[ii], slotIndex, slotBone);
                }

                PathAttachment attachment = slot.Attachment as PathAttachment;
                if (attachment != null)
                {
                    SortPathConstraintAttachment(attachment, slotBone);
                }

                ExposedList <Bone> constrained = constraint.bones;
                int boneCount = constrained.Count;
                for (int ii = 0; ii < boneCount; ii++)
                {
                    SortBone(constrained.Items[ii]);
                }

                updateCache.Add(constraint);

                for (int ii = 0; ii < boneCount; ii++)
                {
                    SortReset(constrained.Items[ii].children);
                }
                for (int ii = 0; ii < boneCount; ii++)
                {
                    constrained.Items[ii].sorted = true;
                }
            }

            ExposedList <TransformConstraint> transformConstraints = this.transformConstraints;

            for (int i = 0, n = transformConstraints.Count; i < n; i++)
            {
                TransformConstraint constraint = transformConstraints.Items[i];

                SortBone(constraint.target);

                ExposedList <Bone> constrained = constraint.bones;
                int boneCount = constrained.Count;
                for (int ii = 0; ii < boneCount; ii++)
                {
                    SortBone(constrained.Items[ii]);
                }

                updateCache.Add(constraint);

                for (int ii = 0; ii < boneCount; ii++)
                {
                    SortReset(constrained.Items[ii].children);
                }
                for (int ii = 0; ii < boneCount; ii++)
                {
                    constrained.Items[ii].sorted = true;
                }
            }

            for (int i = 0, n = bones.Count; i < n; i++)
            {
                SortBone(bones.Items[i]);
            }
        }
コード例 #19
0
        public void UpdateCache()
        {
            ExposedList <ExposedList <Bone> > exposedList  = this.boneCache;
            ExposedList <IkConstraint>        exposedList2 = this.ikConstraints;
            int count = exposedList2.Count;
            int num   = count + 1;

            if (exposedList.Count > num)
            {
                exposedList.RemoveRange(num, exposedList.Count - num);
            }
            int i      = 0;
            int count2 = exposedList.Count;

            while (i < count2)
            {
                exposedList.Items[i].Clear(true);
                i++;
            }
            while (exposedList.Count < num)
            {
                exposedList.Add(new ExposedList <Bone>());
            }
            ExposedList <Bone> exposedList3 = exposedList.Items[0];
            int j      = 0;
            int count3 = this.bones.Count;

            while (j < count3)
            {
                Bone bone  = this.bones.Items[j];
                Bone bone2 = bone;
                int  k;
                while (true)
                {
                    k = 0;
IL_143:
                    while (k < count)
                    {
                        IkConstraint ikConstraint = exposedList2.Items[k];
                        Bone         bone3        = ikConstraint.bones.Items[0];
                        Bone         bone4        = ikConstraint.bones.Items[ikConstraint.bones.Count - 1];
                        while (bone2 != bone4)
                        {
                            if (bone4 == bone3)
                            {
                                k++;
                                goto IL_143;
                            }
                            bone4 = bone4.parent;
                        }
                        goto Block_4;
                    }
                    bone2 = bone2.parent;
                    if (bone2 == null)
                    {
                        goto Block_7;
                    }
                }
IL_164:
                j++;
                continue;
Block_4:
                exposedList.Items[k].Add(bone);
                exposedList.Items[k + 1].Add(bone);
                goto IL_164;
Block_7:
                exposedList3.Add(bone);
                goto IL_164;
            }
        }
コード例 #20
0
        public void UpdateCache()
        {
            ExposedList <IUpdatable> exposedList = this.updateCache;

            exposedList.Clear(true);
            ExposedList <Bone> exposedList2 = this.bones;
            int i     = 0;
            int count = exposedList2.Count;

            while (i < count)
            {
                exposedList2.Items[i].sorted = false;
                i++;
            }
            ExposedList <IkConstraint> exposedList3 = this.ikConstraintsSorted;

            exposedList3.Clear(true);
            exposedList3.AddRange(this.ikConstraints);
            int count2 = exposedList3.Count;
            int j      = 0;
            int num    = count2;

            while (j < num)
            {
                IkConstraint ikConstraint = exposedList3.Items[j];
                Bone         parent       = ikConstraint.bones.Items[0].parent;
                int          num2         = 0;
                while (parent != null)
                {
                    parent = parent.parent;
                    num2++;
                }
                ikConstraint.level = num2;
                j++;
            }
            for (int k = 1; k < count2; k++)
            {
                IkConstraint ikConstraint2 = exposedList3.Items[k];
                int          level         = ikConstraint2.level;
                int          l;
                for (l = k - 1; l >= 0; l--)
                {
                    IkConstraint ikConstraint3 = exposedList3.Items[l];
                    if (ikConstraint3.level < level)
                    {
                        break;
                    }
                    exposedList3.Items[l + 1] = ikConstraint3;
                }
                exposedList3.Items[l + 1] = ikConstraint2;
            }
            int m      = 0;
            int count3 = exposedList3.Count;

            while (m < count3)
            {
                IkConstraint ikConstraint4 = exposedList3.Items[m];
                Bone         target        = ikConstraint4.target;
                this.SortBone(target);
                ExposedList <Bone> exposedList4 = ikConstraint4.bones;
                Bone bone = exposedList4.Items[0];
                this.SortBone(bone);
                exposedList.Add(ikConstraint4);
                this.SortReset(bone.children);
                exposedList4.Items[exposedList4.Count - 1].sorted = true;
                m++;
            }
            ExposedList <PathConstraint> exposedList5 = this.pathConstraints;
            int n      = 0;
            int count4 = exposedList5.Count;

            while (n < count4)
            {
                PathConstraint pathConstraint = exposedList5.Items[n];
                Slot           target2        = pathConstraint.target;
                int            index          = target2.data.index;
                Bone           bone2          = target2.bone;
                if (this.skin != null)
                {
                    this.SortPathConstraintAttachment(this.skin, index, bone2);
                }
                if (this.data.defaultSkin != null && this.data.defaultSkin != this.skin)
                {
                    this.SortPathConstraintAttachment(this.data.defaultSkin, index, bone2);
                }
                int num3   = 0;
                int count5 = this.data.skins.Count;
                while (num3 < count5)
                {
                    this.SortPathConstraintAttachment(this.data.skins.Items[num3], index, bone2);
                    num3++;
                }
                PathAttachment pathAttachment = target2.Attachment as PathAttachment;
                if (pathAttachment != null)
                {
                    this.SortPathConstraintAttachment(pathAttachment, bone2);
                }
                ExposedList <Bone> exposedList6 = pathConstraint.bones;
                int count6 = exposedList6.Count;
                for (int num4 = 0; num4 < count6; num4++)
                {
                    this.SortBone(exposedList6.Items[num4]);
                }
                exposedList.Add(pathConstraint);
                for (int num5 = 0; num5 < count6; num5++)
                {
                    this.SortReset(exposedList6.Items[num5].children);
                }
                for (int num6 = 0; num6 < count6; num6++)
                {
                    exposedList6.Items[num6].sorted = true;
                }
                n++;
            }
            ExposedList <TransformConstraint> exposedList7 = this.transformConstraints;
            int num7   = 0;
            int count7 = exposedList7.Count;

            while (num7 < count7)
            {
                TransformConstraint transformConstraint = exposedList7.Items[num7];
                this.SortBone(transformConstraint.target);
                ExposedList <Bone> exposedList8 = transformConstraint.bones;
                int count8 = exposedList8.Count;
                for (int num8 = 0; num8 < count8; num8++)
                {
                    this.SortBone(exposedList8.Items[num8]);
                }
                exposedList.Add(transformConstraint);
                for (int num9 = 0; num9 < count8; num9++)
                {
                    this.SortReset(exposedList8.Items[num9].children);
                }
                for (int num10 = 0; num10 < count8; num10++)
                {
                    exposedList8.Items[num10].sorted = true;
                }
                num7++;
            }
            int num11  = 0;
            int count9 = exposedList2.Count;

            while (num11 < count9)
            {
                this.SortBone(exposedList2.Items[num11]);
                num11++;
            }
        }
コード例 #21
0
ファイル: Skeleton.cs プロジェクト: aazzxin/spine-runtimes
        /// <summary>Caches information about bones and constraints. Must be called if bones, constraints or weighted path attachments are added
        /// or removed.</summary>
        public void UpdateCache()
        {
            ExposedList <IUpdatable> updateCache = this.updateCache;

            updateCache.Clear();
            this.updateCacheReset.Clear();

            ExposedList <IkConstraint> ikConstraints = this.ikConstraints;
            var transformConstraints = this.transformConstraints;
            var pathConstraints = this.pathConstraints;
            int ikCount = IkConstraints.Count, transformCount = transformConstraints.Count, pathCount = pathConstraints.Count;
            int constraintCount = ikCount + transformCount + pathCount;

            ExposedList <Bone> bones = this.bones;

            //旧版的设置骨骼方式
            for (int i = 0, n = bones.Count; i < n; i++)
            {
                Bone bone = bones.Items[i];
                updateCache.Add(bone);
                for (int ii = 0; ii < ikCount; ii++)
                {
                    IkConstraint ikConstraint = ikConstraints.Items[ii];
                    if (bone == ikConstraint.bones.Items[ikConstraint.bones.Count - 1])
                    {
                        updateCache.Add(ikConstraint);
                        break;
                    }
                }
            }

            //outer:
            for (int i = 0; i < constraintCount; i++)
            {
                for (int ii = 0; ii < ikCount; ii++)
                {
                    IkConstraint constraint = ikConstraints.Items[ii];
                    if (constraint.data.order == i)
                    {
                        SortIkConstraint(constraint);
                        goto continue_outer;                         //continue outer;
                    }
                }
                for (int ii = 0; ii < transformCount; ii++)
                {
                    TransformConstraint constraint = transformConstraints.Items[ii];
                    if (constraint.data.order == i)
                    {
                        SortTransformConstraint(constraint);
                        goto continue_outer; //continue outer;
                    }
                }
                for (int ii = 0; ii < pathCount; ii++)
                {
                    PathConstraint constraint = pathConstraints.Items[ii];
                    if (constraint.data.order == i)
                    {
                        SortPathConstraint(constraint);
                        goto continue_outer;                         //continue outer;
                    }
                }
                continue_outer : {}
            }

            //3.6版本运行库使用的设置骨骼方式,这会使一些动画的某些部位异常(无动作)
            //for (int i = 0, n = bones.Count; i < n; i++)
            //	SortBone(bones.Items[i]);
        }
コード例 #22
0
        internal static void SetPropertyToSetupPose(this Skeleton skeleton, int propertyID)
        {
            int          num          = propertyID >> 24;
            TimelineType timelineType = (TimelineType)num;
            int          num2         = propertyID - (num << 24);

            switch (timelineType)
            {
            case TimelineType.Event:
                break;

            case TimelineType.Rotate:
            {
                Bone bone = skeleton.bones.Items[num2];
                bone.rotation = bone.data.rotation;
                break;
            }

            case TimelineType.Translate:
            {
                Bone bone = skeleton.bones.Items[num2];
                bone.x = bone.data.x;
                bone.y = bone.data.y;
                break;
            }

            case TimelineType.Scale:
            {
                Bone bone = skeleton.bones.Items[num2];
                bone.scaleX = bone.data.scaleX;
                bone.scaleY = bone.data.scaleY;
                break;
            }

            case TimelineType.Shear:
            {
                Bone bone = skeleton.bones.Items[num2];
                bone.shearX = bone.data.shearX;
                bone.shearY = bone.data.shearY;
                break;
            }

            case TimelineType.Attachment:
                skeleton.SetSlotAttachmentToSetupPose(num2);
                break;

            case TimelineType.Color:
                skeleton.slots.Items[num2].SetColorToSetupPose();
                break;

            case TimelineType.TwoColor:
                skeleton.slots.Items[num2].SetColorToSetupPose();
                break;

            case TimelineType.Deform:
                skeleton.slots.Items[num2].attachmentVertices.Clear();
                break;

            case TimelineType.DrawOrder:
                skeleton.SetDrawOrderToSetupPose();
                break;

            case TimelineType.IkConstraint:
            {
                IkConstraint ikConstraint = skeleton.ikConstraints.Items[num2];
                ikConstraint.mix           = ikConstraint.data.mix;
                ikConstraint.bendDirection = ikConstraint.data.bendDirection;
                break;
            }

            case TimelineType.TransformConstraint:
            {
                TransformConstraint     transformConstraint = skeleton.transformConstraints.Items[num2];
                TransformConstraintData data = transformConstraint.data;
                transformConstraint.rotateMix    = data.rotateMix;
                transformConstraint.translateMix = data.translateMix;
                transformConstraint.scaleMix     = data.scaleMix;
                transformConstraint.shearMix     = data.shearMix;
                break;
            }

            case TimelineType.PathConstraintPosition:
            {
                PathConstraint pathConstraint = skeleton.pathConstraints.Items[num2];
                pathConstraint.position = pathConstraint.data.position;
                break;
            }

            case TimelineType.PathConstraintSpacing:
            {
                PathConstraint pathConstraint = skeleton.pathConstraints.Items[num2];
                pathConstraint.spacing = pathConstraint.data.spacing;
                break;
            }

            case TimelineType.PathConstraintMix:
            {
                PathConstraint pathConstraint = skeleton.pathConstraints.Items[num2];
                pathConstraint.rotateMix    = pathConstraint.data.rotateMix;
                pathConstraint.translateMix = pathConstraint.data.translateMix;
                break;
            }
            }
        }
コード例 #23
0
        /// <summary>Caches information about bones and constraints. Must be called if the <see cref="Skin"/> is modified or if bones, constraints, or
        /// constraints, or weighted path attachments are added or removed.</summary>
        public void UpdateCache()
        {
            var updateCache = this.updateCache;

            updateCache.Clear();

            int boneCount = this.bones.Count;

            Bone[] bones = this.bones.Items;
            for (int i = 0; i < boneCount; i++)
            {
                Bone bone = bones[i];
                bone.sorted = bone.data.skinRequired;
                bone.active = !bone.sorted;
            }
            if (skin != null)
            {
                BoneData[] skinBones = skin.bones.Items;
                for (int i = 0, n = skin.bones.Count; i < n; i++)
                {
                    var bone = bones[skinBones[i].index];
                    do
                    {
                        bone.sorted = false;
                        bone.active = true;
                        bone        = bone.parent;
                    } while (bone != null);
                }
            }

            int ikCount = this.ikConstraints.Count, transformCount = this.transformConstraints.Count, pathCount = this.pathConstraints.Count;

            IkConstraint[]        ikConstraints        = this.ikConstraints.Items;
            TransformConstraint[] transformConstraints = this.transformConstraints.Items;
            PathConstraint[]      pathConstraints      = this.pathConstraints.Items;
            int constraintCount = ikCount + transformCount + pathCount;

            for (int i = 0; i < constraintCount; i++)
            {
                for (int ii = 0; ii < ikCount; ii++)
                {
                    IkConstraint constraint = ikConstraints[ii];
                    if (constraint.data.order == i)
                    {
                        SortIkConstraint(constraint);
                        goto continue_outer;
                    }
                }
                for (int ii = 0; ii < transformCount; ii++)
                {
                    TransformConstraint constraint = transformConstraints[ii];
                    if (constraint.data.order == i)
                    {
                        SortTransformConstraint(constraint);
                        goto continue_outer;
                    }
                }
                for (int ii = 0; ii < pathCount; ii++)
                {
                    PathConstraint constraint = pathConstraints[ii];
                    if (constraint.data.order == i)
                    {
                        SortPathConstraint(constraint);
                        goto continue_outer;
                    }
                }
                continue_outer : { }
            }

            for (int i = 0; i < boneCount; i++)
            {
                SortBone(bones[i]);
            }
        }
コード例 #24
0
        internal static void SetPropertyToSetupPose(this Skeleton skeleton, int propertyID)
        {
            Bone           bone;
            PathConstraint constraint2;
            int            num   = propertyID >> 0x18;
            TimelineType   type  = (TimelineType)num;
            int            index = propertyID - (num << 0x18);

            switch (type)
            {
            case TimelineType.Rotate:
                bone          = skeleton.bones.Items[index];
                bone.rotation = bone.data.rotation;
                break;

            case TimelineType.Translate:
                bone   = skeleton.bones.Items[index];
                bone.x = bone.data.x;
                bone.y = bone.data.y;
                break;

            case TimelineType.Scale:
                bone        = skeleton.bones.Items[index];
                bone.scaleX = bone.data.scaleX;
                bone.scaleY = bone.data.scaleY;
                break;

            case TimelineType.Shear:
                bone        = skeleton.bones.Items[index];
                bone.shearX = bone.data.shearX;
                bone.shearY = bone.data.shearY;
                break;

            case TimelineType.Attachment:
                skeleton.SetSlotAttachmentToSetupPose(index);
                break;

            case TimelineType.Color:
                skeleton.slots.Items[index].SetColorToSetupPose();
                break;

            case TimelineType.Deform:
                skeleton.slots.Items[index].attachmentVertices.Clear(true);
                break;

            case TimelineType.DrawOrder:
                skeleton.SetDrawOrderToSetupPose();
                break;

            case TimelineType.IkConstraint:
            {
                IkConstraint constraint = skeleton.ikConstraints.Items[index];
                constraint.mix           = constraint.data.mix;
                constraint.bendDirection = constraint.data.bendDirection;
                break;
            }

            case TimelineType.TransformConstraint:
            {
                TransformConstraint     constraint3 = skeleton.transformConstraints.Items[index];
                TransformConstraintData data        = constraint3.data;
                constraint3.rotateMix    = data.rotateMix;
                constraint3.translateMix = data.translateMix;
                constraint3.scaleMix     = data.scaleMix;
                constraint3.shearMix     = data.shearMix;
                break;
            }

            case TimelineType.PathConstraintPosition:
                constraint2          = skeleton.pathConstraints.Items[index];
                constraint2.position = constraint2.data.position;
                break;

            case TimelineType.PathConstraintSpacing:
                constraint2         = skeleton.pathConstraints.Items[index];
                constraint2.spacing = constraint2.data.spacing;
                break;

            case TimelineType.PathConstraintMix:
                constraint2              = skeleton.pathConstraints.Items[index];
                constraint2.rotateMix    = constraint2.data.rotateMix;
                constraint2.translateMix = constraint2.data.translateMix;
                break;

            case TimelineType.TwoColor:
                skeleton.slots.Items[index].SetColorToSetupPose();
                break;
            }
        }