public void UpdateCache() { this.updateCache.Clear(true); this.updateCacheReset.Clear(true); ExposedList <Bone> bones = this.bones; int index = 0; int count = bones.Count; while (index < count) { bones.Items[index].sorted = false; index++; } ExposedList <IkConstraint> ikConstraints = this.ikConstraints; ExposedList <TransformConstraint> transformConstraints = this.transformConstraints; ExposedList <PathConstraint> pathConstraints = this.pathConstraints; int num3 = this.IkConstraints.Count; int num4 = transformConstraints.Count; int num5 = pathConstraints.Count; int num6 = (num3 + num4) + num5; for (int i = 0; i < num6; i++) { for (int j = 0; j < num3; j++) { IkConstraint constraint = ikConstraints.Items[j]; if (constraint.data.order == i) { this.SortIkConstraint(constraint); continue; } } for (int k = 0; k < num4; k++) { TransformConstraint constraint = transformConstraints.Items[k]; if (constraint.data.order == i) { this.SortTransformConstraint(constraint); continue; } } for (int m = 0; m < num5; m++) { PathConstraint constraint = pathConstraints.Items[m]; if (constraint.data.order == i) { this.SortPathConstraint(constraint); break; } } } int num11 = 0; int num12 = bones.Count; while (num11 < num12) { this.SortBone(bones.Items[num11]); num11++; } }
/// <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 < transformConstraintsCount; ii++) { TransformConstraint transformConstraint = transformConstraints.Items[ii]; if (bone == transformConstraint.bone) { updateCache.Add(transformConstraint); break; } } 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; } } } }
private void SortTransformConstraint(TransformConstraint constraint) { SortBone(constraint.target); ExposedList <Bone> exposedList = constraint.bones; int count = exposedList.Count; if (constraint.data.local) { for (int i = 0; i < count; i++) { Bone bone = exposedList.Items[i]; SortBone(bone.parent); if (!updateCache.Contains(bone)) { updateCacheReset.Add(bone); } } } else { for (int j = 0; j < count; j++) { SortBone(exposedList.Items[j]); } } updateCache.Add(constraint); for (int k = 0; k < count; k++) { SortReset(exposedList.Items[k].children); } for (int l = 0; l < count; l++) { exposedList.Items[l].sorted = true; } }
override public void Apply(Skeleton skeleton, float lastTime, float time, ExposedList <Event> firedEvents, float alpha) { float[] frames = this.frames; if (time < frames[0]) { return; // Time is before first frame. } TransformConstraint constraint = skeleton.transformConstraints.Items[transformConstraintIndex]; if (time >= frames[frames.Length - ENTRIES]) // Time is after last frame. { int i = frames.Length; constraint.rotateMix += (frames[i + PREV_ROTATE] - constraint.rotateMix) * alpha; constraint.translateMix += (frames[i + PREV_TRANSLATE] - constraint.translateMix) * alpha; constraint.scaleMix += (frames[i + PREV_SCALE] - constraint.scaleMix) * alpha; constraint.shearMix += (frames[i + PREV_SHEAR] - constraint.shearMix) * alpha; return; } // Interpolate between the previous frame and the current frame. int frame = Animation.binarySearch(frames, time, ENTRIES); float frameTime = frames[frame]; float percent = GetCurvePercent(frame / ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + PREV_TIME] - frameTime)); float rotate = frames[frame + PREV_ROTATE]; float translate = frames[frame + PREV_TRANSLATE]; float scale = frames[frame + PREV_SCALE]; float shear = frames[frame + PREV_SHEAR]; constraint.rotateMix += (rotate + (frames[frame + ROTATE] - rotate) * percent - constraint.rotateMix) * alpha; constraint.translateMix += (translate + (frames[frame + TRANSLATE] - translate) * percent - constraint.translateMix) * alpha; constraint.scaleMix += (scale + (frames[frame + SCALE] - scale) * percent - constraint.scaleMix) * alpha; constraint.shearMix += (shear + (frames[frame + SHEAR] - shear) * percent - constraint.shearMix) * alpha; }
private void SortTransformConstraint(TransformConstraint constraint) { this.SortBone(constraint.target); ExposedList <Bone> bones = constraint.bones; int count = bones.Count; if (constraint.data.local) { for (int k = 0; k < count; k++) { Bone item = bones.Items[k]; this.SortBone(item.parent); if (!this.updateCache.Contains(item)) { this.updateCacheReset.Add(item); } } } else { for (int k = 0; k < count; k++) { this.SortBone(bones.Items[k]); } } this.updateCache.Add(constraint); for (int i = 0; i < count; i++) { SortReset(bones.Items[i].children); } for (int j = 0; j < count; j++) { bones.Items[j].sorted = true; } }
/// <summary>Sets the bones and constraints to their setup pose values.</summary> public void SetBonesToSetupPose() { ExposedList <Bone> bones = this.bones; for (int i = 0, n = bones.Count; i < n; i++) { bones.Items[i].SetToSetupPose(); } ExposedList <IkConstraint> ikConstraints = this.ikConstraints; for (int i = 0, n = ikConstraints.Count; i < n; i++) { IkConstraint constraint = ikConstraints.Items[i]; constraint.bendDirection = constraint.data.bendDirection; constraint.mix = constraint.data.mix; } ExposedList <TransformConstraint> transformConstraints = this.transformConstraints; for (int i = 0, n = transformConstraints.Count; i < n; i++) { TransformConstraint constraint = transformConstraints.Items[i]; constraint.translateMix = constraint.data.translateMix; constraint.x = constraint.data.x; constraint.y = constraint.data.y; } }
/// <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 <Bone> bones = this.bones; for (int i = 0, n = bones.Count; i < n; i++) { bones.Items[i].sorted = false; } 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; //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 outer; //continue outer; } } for (int ii = 0; ii < transformCount; ii++) { TransformConstraint constraint = transformConstraints.Items[ii]; if (constraint.data.order == i) { SortTransformConstraint(constraint); goto outer; //continue outer; } } for (int ii = 0; ii < pathCount; ii++) { PathConstraint constraint = pathConstraints.Items[ii]; if (constraint.data.order == i) { SortPathConstraint(constraint); goto outer; //continue outer; } } outer : {} } for (int i = 0, n = bones.Count; i < n; i++) { SortBone(bones.Items[i]); } }
public void SetBonesToSetupPose() { Bone[] items = this.bones.Items; int index = 0; int count = this.bones.Count; while (index < count) { items[index].SetToSetupPose(); index++; } IkConstraint[] constraintArray = this.ikConstraints.Items; int num3 = 0; int num4 = this.ikConstraints.Count; while (num3 < num4) { IkConstraint constraint = constraintArray[num3]; constraint.bendDirection = constraint.data.bendDirection; constraint.mix = constraint.data.mix; num3++; } TransformConstraint[] constraintArray2 = this.transformConstraints.Items; int num5 = 0; int num6 = this.transformConstraints.Count; while (num5 < num6) { TransformConstraint constraint2 = constraintArray2[num5]; TransformConstraintData data = constraint2.data; constraint2.rotateMix = data.rotateMix; constraint2.translateMix = data.translateMix; constraint2.scaleMix = data.scaleMix; constraint2.shearMix = data.shearMix; num5++; } PathConstraint[] constraintArray3 = this.pathConstraints.Items; int num7 = 0; int num8 = this.pathConstraints.Count; while (num7 < num8) { PathConstraint constraint3 = constraintArray3[num7]; PathConstraintData data = constraint3.data; constraint3.position = data.position; constraint3.spacing = data.spacing; constraint3.rotateMix = data.rotateMix; constraint3.translateMix = data.translateMix; num7++; } }
public void SetBonesToSetupPose() { Bone[] items = this.bones.Items; int i = 0; int count = this.bones.Count; while (i < count) { items[i].SetToSetupPose(); i++; } IkConstraint[] items2 = this.ikConstraints.Items; int j = 0; int count2 = this.ikConstraints.Count; while (j < count2) { IkConstraint ikConstraint = items2[j]; ikConstraint.bendDirection = ikConstraint.data.bendDirection; ikConstraint.mix = ikConstraint.data.mix; j++; } TransformConstraint[] items3 = this.transformConstraints.Items; int k = 0; int count3 = this.transformConstraints.Count; while (k < count3) { TransformConstraint transformConstraint = items3[k]; TransformConstraintData transformConstraintData = transformConstraint.data; transformConstraint.rotateMix = transformConstraintData.rotateMix; transformConstraint.translateMix = transformConstraintData.translateMix; transformConstraint.scaleMix = transformConstraintData.scaleMix; transformConstraint.shearMix = transformConstraintData.shearMix; k++; } PathConstraint[] items4 = this.pathConstraints.Items; int l = 0; int count4 = this.pathConstraints.Count; while (l < count4) { PathConstraint pathConstraint = items4[l]; PathConstraintData pathConstraintData = pathConstraint.data; pathConstraint.position = pathConstraintData.position; pathConstraint.spacing = pathConstraintData.spacing; pathConstraint.rotateMix = pathConstraintData.rotateMix; pathConstraint.translateMix = pathConstraintData.translateMix; l++; } }
/// <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; } }
static int FindTransformConstraint(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.TransformConstraint o = obj.FindTransformConstraint(arg0); ToLua.PushObject(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
private void SortTransformConstraint(TransformConstraint constraint) { constraint.active = constraint.target.active && (!constraint.data.skinRequired || (skin != null && skin.constraints.Contains(constraint.data))); if (!constraint.active) { return; } SortBone(constraint.target); var constrained = constraint.bones; int boneCount = constrained.Count; if (constraint.data.local) { for (int i = 0; i < boneCount; i++) { Bone child = constrained.Items[i]; SortBone(child.parent); if (!updateCache.Contains(child)) { updateCacheReset.Add(child); } } } else { for (int i = 0; i < boneCount; i++) { SortBone(constrained.Items[i]); } } updateCache.Add(constraint); for (int i = 0; i < boneCount; i++) { SortReset(constrained.Items[i].children); } for (int i = 0; i < boneCount; i++) { constrained.Items[i].sorted = true; } }
/// <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; } }
/// <returns>May be null.</returns> public TransformConstraint FindTransformConstraint(string constraintName) { if (constraintName == null) { throw new ArgumentNullException("constraintName", "constraintName cannot be null."); } ExposedList <TransformConstraint> transformConstraints = this.transformConstraints; for (int i = 0, n = transformConstraints.Count; i < n; i++) { TransformConstraint transformConstraint = transformConstraints.Items[i]; if (transformConstraint.data.name == constraintName) { return(transformConstraint); } } return(null); }
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; } }
public TransformConstraint FindTransformConstraint(string constraintName) { if (constraintName == null) { throw new ArgumentNullException("constraintName", "constraintName cannot be null."); } ExposedList <TransformConstraint> exposedList = this.transformConstraints; int i = 0; int count = exposedList.Count; while (i < count) { TransformConstraint transformConstraint = exposedList.Items[i]; if (transformConstraint.data.name == constraintName) { return(transformConstraint); } i++; } return(null); }
/// <summary>Copy constructor.</summary> public TransformConstraint(TransformConstraint 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]; rotateMix = constraint.rotateMix; translateMix = constraint.translateMix; scaleMix = constraint.scaleMix; shearMix = constraint.shearMix; }
private void SortTransformConstraint(TransformConstraint constraint) { SortBone(constraint.target); var constrained = constraint.bones; int boneCount = constrained.Count; if (constraint.data.local) { for (int i = 0; i < boneCount; i++) { Bone child = constrained.Items[i]; SortBone(child.parent); if (!updateCache.Contains(child)) { updateCacheReset.Add(child); } } } else { for (int i = 0; i < boneCount; i++) { SortBone(constrained.Items[i]); } } updateCache.Add(constraint); for (int i = 0; i < boneCount; i++) { SortReset(constrained.Items[i].children); } for (int i = 0; i < boneCount; i++) { constrained.Items[i].sorted = true; } }
private void SortTransformConstraint(TransformConstraint constraint) { SortBone(constraint.target); var 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; } }
/// <summary>Copy constructor.</summary> public TransformConstraint(TransformConstraint 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]; mixRotate = constraint.mixRotate; mixX = constraint.mixX; mixY = constraint.mixY; mixScaleX = constraint.mixScaleX; mixScaleY = constraint.mixScaleY; mixShearY = constraint.mixShearY; }
public override void Apply(Skeleton skeleton, float lastTime, float time, ExposedList <Event> firedEvents, float alpha, MixPose pose, MixDirection direction) { TransformConstraint constraint = skeleton.transformConstraints.Items[this.transformConstraintIndex]; float[] frames = this.frames; if (time < frames[0]) { TransformConstraintData data = constraint.data; if (pose != MixPose.Setup) { if (pose != MixPose.Current) { return; } } else { constraint.rotateMix = data.rotateMix; constraint.translateMix = data.translateMix; constraint.scaleMix = data.scaleMix; constraint.shearMix = data.shearMix; return; } constraint.rotateMix += (data.rotateMix - constraint.rotateMix) * alpha; constraint.translateMix += (data.translateMix - constraint.translateMix) * alpha; constraint.scaleMix += (data.scaleMix - constraint.scaleMix) * alpha; constraint.shearMix += (data.shearMix - constraint.shearMix) * alpha; } else { float num; float num2; float num3; float num4; if (time >= frames[frames.Length - 5]) { int length = frames.Length; num = frames[length + -4]; num2 = frames[length + -3]; num3 = frames[length + -2]; num4 = frames[length + -1]; } else { int index = Animation.BinarySearch(frames, time, 5); num = frames[index + -4]; num2 = frames[index + -3]; num3 = frames[index + -2]; num4 = frames[index + -1]; float num7 = frames[index]; float curvePercent = base.GetCurvePercent((index / 5) - 1, 1f - ((time - num7) / (frames[index + -5] - num7))); num += (frames[index + 1] - num) * curvePercent; num2 += (frames[index + 2] - num2) * curvePercent; num3 += (frames[index + 3] - num3) * curvePercent; num4 += (frames[index + 4] - num4) * curvePercent; } if (pose == MixPose.Setup) { TransformConstraintData data = constraint.data; constraint.rotateMix = data.rotateMix + ((num - data.rotateMix) * alpha); constraint.translateMix = data.translateMix + ((num2 - data.translateMix) * alpha); constraint.scaleMix = data.scaleMix + ((num3 - data.scaleMix) * alpha); constraint.shearMix = data.shearMix + ((num4 - data.shearMix) * alpha); } else { constraint.rotateMix += (num - constraint.rotateMix) * alpha; constraint.translateMix += (num2 - constraint.translateMix) * alpha; constraint.scaleMix += (num3 - constraint.scaleMix) * alpha; constraint.shearMix += (num4 - constraint.shearMix) * alpha; } } }
private void SortTransformConstraint (TransformConstraint constraint) { SortBone(constraint.target); var 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; }
/// <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]); } }
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; } }
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++; } }
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; } } }
/// <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]); }
/// <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]); } }
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]); } }