public void Drain() { if (drainDisabled) { return; } drainDisabled = true; var entries = this.eventQueueEntries; var entriesItems = entries.Items; AnimationState state = this.state; for (int i = 0, n = entries.Count; i < n; i++) { var queueEntry = entriesItems[i]; TrackEntry trackEntry = queueEntry.entry; switch (queueEntry.type) { case EventType.Start: trackEntry.OnStart(); state.OnStart(trackEntry); break; case EventType.Interrupt: trackEntry.OnInterrupt(); state.OnInterrupt(trackEntry); break; case EventType.End: trackEntry.OnEnd(); state.OnEnd(trackEntry); goto case EventType.Dispose; // Fall through. (C#) case EventType.Dispose: trackEntry.OnDispose(); state.OnDispose(trackEntry); break; case EventType.Complete: trackEntry.OnComplete(); state.OnComplete(trackEntry); break; case EventType.Event: trackEntry.OnEvent(queueEntry.e); state.OnEvent(trackEntry, queueEntry.e); break; } } eventQueueEntries.Clear(); drainDisabled = false; }
public void Reset() { next = null; mixingFrom = null; animation = null; timelineData.Clear(); timelineDipMix.Clear(); timelinesRotation.Clear(); this.Start = null; this.Interrupt = null; this.End = null; this.Dispose = null; this.Complete = null; this.Event = null; }
/// <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; } } } }
static int Clear(IntPtr L) { try { int count = LuaDLL.lua_gettop(L); if (count == 1) { Spine.ExposedList <Spine.Animation> obj = (Spine.ExposedList <Spine.Animation>)ToLua.CheckObject <Spine.ExposedList <Spine.Animation> >(L, 1); obj.Clear(); return(0); } else if (count == 2) { Spine.ExposedList <Spine.Animation> obj = (Spine.ExposedList <Spine.Animation>)ToLua.CheckObject <Spine.ExposedList <Spine.Animation> >(L, 1); bool arg0 = LuaDLL.luaL_checkboolean(L, 2); obj.Clear(arg0); return(0); } else { return(LuaDLL.luaL_throw(L, "invalid arguments to method: Spine.ExposedList<Spine.Animation>.Clear")); } } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
public void ClearTracks() { for (int i = 0, n = tracks.Count; i < n; i++) { ClearTrack(i); } tracks.Clear(); }
/// <summary> /// Clears any previous polygons, finds all visible bounding box attachments, /// and computes the world vertices for each bounding box's polygon.</summary> /// <param name="skeleton">The skeleton.</param> /// <param name="updateAabb"> /// If true, the axis aligned bounding box containing all the polygons is computed. /// If false, the SkeletonBounds AABB methods will always return true. /// </param> public void Update(Skeleton skeleton, bool updateAabb) { ExposedList <BoundingBoxAttachment> boundingBoxes = BoundingBoxes; ExposedList <Polygon> polygons = Polygons; ExposedList <Slot> slots = skeleton.slots; int slotCount = slots.Count; boundingBoxes.Clear(); for (int i = 0, n = polygons.Count; i < n; i++) { polygonPool.Add(polygons.Items[i]); } polygons.Clear(); for (int i = 0; i < slotCount; i++) { Slot slot = slots.Items[i]; BoundingBoxAttachment boundingBox = slot.attachment as BoundingBoxAttachment; if (boundingBox == null) { continue; } boundingBoxes.Add(boundingBox); Polygon polygon = null; int poolCount = polygonPool.Count; if (poolCount > 0) { polygon = polygonPool.Items[poolCount - 1]; polygonPool.RemoveAt(poolCount - 1); } else { polygon = new Polygon(); } polygons.Add(polygon); int count = boundingBox.worldVerticesLength; polygon.Count = count; if (polygon.Vertices.Length < count) { polygon.Vertices = new float[count]; } boundingBox.ComputeWorldVertices(slot, polygon.Vertices); } if (updateAabb) { AabbCompute(); } else { minX = int.MinValue; minY = int.MinValue; maxX = int.MaxValue; maxY = int.MaxValue; } }
/// <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 OnDestroy() { animation = null; assetPath = string.Empty; stateData = null; animations.Clear(); Object.DestroyImmediate(goRole); goRole = null; }
public void Apply(Skeleton skeleton, float lastTime, float time, ExposedList <Event> firedEvents, float alpha, MixPose pose, MixDirection direction) { ExposedList <Slot> drawOrder = skeleton.drawOrder; ExposedList <Slot> slots = skeleton.slots; if ((direction == MixDirection.Out) && (pose == MixPose.Setup)) { Array.Copy(slots.Items, 0, drawOrder.Items, 0, slots.Count); } else { float[] frames = this.frames; if (time < frames[0]) { if (pose == MixPose.Setup) { Array.Copy(slots.Items, 0, drawOrder.Items, 0, slots.Count); } } else { int num; if (time >= frames[frames.Length - 1]) { num = frames.Length - 1; } else { num = Animation.BinarySearch(frames, time) - 1; } int[] numArray2 = this.drawOrders[num]; if (numArray2 == null) { drawOrder.Clear(true); int index = 0; int count = slots.Count; while (index < count) { drawOrder.Add(slots.Items[index]); index++; } } else { Slot[] items = drawOrder.Items; Slot[] slotArray2 = slots.Items; int index = 0; int length = numArray2.Length; while (index < length) { items[index] = slotArray2[numArray2[index]]; index++; } } } } }
public static void SetDrawOrderToSetupPose(this Skeleton skeleton) { Slot[] items = skeleton.slots.Items; int count = skeleton.slots.Count; ExposedList <Slot> drawOrder = skeleton.drawOrder; drawOrder.Clear(false); drawOrder.GrowIfNeeded(count); Array.Copy(items, drawOrder.Items, count); }
/// <summary> /// Removes all animations from all tracks, leaving skeletons in their previous pose. /// It may be desired to use <see cref="AnimationState.SetEmptyAnimations(float)"/> to mix the skeletons back to the setup pose, /// rather than leaving them in their previous pose.</summary> public void ClearTracks() { queue.drainDisabled = true; for (int i = 0, n = tracks.Count; i < n; i++) { ClearTrack(i); } tracks.Clear(); queue.drainDisabled = false; queue.Drain(); }
public void ClipEnd() { if (clipAttachment == null) { return; } clipAttachment = null; clippingPolygons = null; clippedVertices.Clear(); clippedTriangles.Clear(); clippingPolygon.Clear(); }
public void Update(Skeleton skeleton, bool updateAabb) { ExposedList <BoundingBoxAttachment> boundingBoxes = BoundingBoxes; ExposedList <Polygon> polygons = Polygons; ExposedList <Slot> slots = skeleton.slots; int count = slots.Count; boundingBoxes.Clear(); int i = 0; for (int count2 = polygons.Count; i < count2; i++) { polygonPool.Add(polygons.Items[i]); } polygons.Clear(); for (int j = 0; j < count; j++) { Slot slot = slots.Items[j]; BoundingBoxAttachment boundingBoxAttachment = slot.attachment as BoundingBoxAttachment; if (boundingBoxAttachment != null) { boundingBoxes.Add(boundingBoxAttachment); Polygon polygon = null; int count3 = polygonPool.Count; if (count3 > 0) { polygon = polygonPool.Items[count3 - 1]; polygonPool.RemoveAt(count3 - 1); } else { polygon = new Polygon(); } polygons.Add(polygon); int num = polygon.Count = boundingBoxAttachment.worldVerticesLength; if (polygon.Vertices.Length < num) { polygon.Vertices = new float[num]; } boundingBoxAttachment.ComputeWorldVertices(slot, polygon.Vertices); } } if (updateAabb) { AabbCompute(); return; } minX = -2.14748365E+09f; minY = -2.14748365E+09f; maxX = 2.14748365E+09f; maxY = 2.14748365E+09f; }
public void Update(Skeleton skeleton, bool updateAabb) { ExposedList <BoundingBoxAttachment> boundingBoxes = this.BoundingBoxes; ExposedList <Polygon> polygons = this.Polygons; ExposedList <Slot> slots = skeleton.slots; int count = slots.Count; boundingBoxes.Clear(true); int i = 0; int count2 = polygons.Count; while (i < count2) { this.polygonPool.Add(polygons.Items[i]); i++; } polygons.Clear(true); for (int j = 0; j < count; j++) { Slot slot = slots.Items[j]; BoundingBoxAttachment boundingBoxAttachment = slot.attachment as BoundingBoxAttachment; if (boundingBoxAttachment != null) { boundingBoxes.Add(boundingBoxAttachment); int count3 = this.polygonPool.Count; Polygon polygon; if (count3 > 0) { polygon = this.polygonPool.Items[count3 - 1]; this.polygonPool.RemoveAt(count3 - 1); } else { polygon = new Polygon(); } polygons.Add(polygon); int num = boundingBoxAttachment.Vertices.Length; polygon.Count = num; if (polygon.Vertices.Length < num) { polygon.Vertices = new float[num]; } boundingBoxAttachment.ComputeWorldVertices(slot, polygon.Vertices); } } if (updateAabb) { this.aabbCompute(); } }
public void ClearTracks() { bool drainDisabled = queue.drainDisabled; queue.drainDisabled = true; int i = 0; for (int count = tracks.Count; i < count; i++) { ClearTrack(i); } tracks.Clear(); queue.drainDisabled = drainDisabled; queue.Drain(); }
public void SetSlotsToSetupPose() { ExposedList <Slot> slots = this.slots; drawOrder.Clear(); for (int i = 0, n = slots.Count; i < n; i++) { drawOrder.Add(slots.Items[i]); } for (int i = 0, n = slots.Count; i < n; i++) { slots.Items[i].SetToSetupPose(i); } }
public void SetSlotsToSetupPose() { var slots = this.slots; var slotsItems = slots.Items; drawOrder.Clear(); for (int i = 0, n = slots.Count; i < n; i++) { drawOrder.Add(slotsItems[i]); } for (int i = 0, n = slots.Count; i < n; i++) { slotsItems[i].SetToSetupPose(); } }
public void Apply(Skeleton skeleton, float lastTime, float time, ExposedList <Event> firedEvents, float alpha) { float[] array = this.frames; if (time < array[0]) { return; } int num; if (time >= array[array.Length - 1]) { num = array.Length - 1; } else { num = Animation.binarySearch(array, time) - 1; } ExposedList <Slot> drawOrder = skeleton.drawOrder; ExposedList <Slot> slots = skeleton.slots; int[] array2 = this.drawOrders[num]; if (array2 == null) { drawOrder.Clear(true); int i = 0; int count = slots.Count; while (i < count) { drawOrder.Add(slots.Items[i]); i++; } } else { int j = 0; int num2 = array2.Length; while (j < num2) { drawOrder.Items[j] = slots.Items[array2[j]]; j++; } } }
public void SetSlotsToSetupPose() { ExposedList <Slot> exposedList = slots; Slot[] items = exposedList.Items; drawOrder.Clear(); int i = 0; for (int count = exposedList.Count; i < count; i++) { drawOrder.Add(items[i]); } int j = 0; for (int count2 = exposedList.Count; j < count2; j++) { items[j].SetToSetupPose(); } }
public void Apply(Skeleton skeleton, float lastTime, float time, ExposedList <Event> firedEvents, float alpha, MixPose pose, MixDirection direction) { ExposedList <Slot> drawOrder = skeleton.drawOrder; ExposedList <Slot> slots = skeleton.slots; if (direction == MixDirection.Out && pose == MixPose.Setup) { Array.Copy(slots.Items, 0, drawOrder.Items, 0, slots.Count); return; } float[] array = frames; if (time < array[0]) { if (pose == MixPose.Setup) { Array.Copy(slots.Items, 0, drawOrder.Items, 0, slots.Count); } return; } int num = (!(time >= array[array.Length - 1])) ? (Animation.BinarySearch(array, time) - 1) : (array.Length - 1); int[] array2 = drawOrders[num]; if (array2 == null) { drawOrder.Clear(); int i = 0; for (int count = slots.Count; i < count; i++) { drawOrder.Add(slots.Items[i]); } return; } Slot[] items = drawOrder.Items; Slot[] items2 = slots.Items; int j = 0; for (int num2 = array2.Length; j < num2; j++) { items[j] = items2[array2[j]]; } }
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. } int frame; if (time >= frames[frames.Length - 1]) // Time is after last frame. { frame = frames.Length - 1; } else { frame = Animation.binarySearch(frames, time) - 1; } ExposedList <Slot> drawOrder = skeleton.drawOrder; ExposedList <Slot> slots = skeleton.slots; int[] drawOrderToSetupIndex = drawOrders[frame]; if (drawOrderToSetupIndex == null) { drawOrder.Clear(); for (int i = 0, n = slots.Count; i < n; i++) { drawOrder.Add(slots.Items[i]); } } else { var drawOrderItems = drawOrder.Items; var slotsItems = slots.Items; for (int i = 0, n = drawOrderToSetupIndex.Length; i < n; i++) { drawOrderItems[i] = slotsItems[drawOrderToSetupIndex[i]]; } } }
public void Apply(Skeleton skeleton) { ExposedList <Event> exposedList = this.events; for (int i = 0; i < this.tracks.Count; i++) { TrackEntry trackEntry = this.tracks.Items[i]; if (trackEntry != null) { exposedList.Clear(true); float num = trackEntry.time; bool loop = trackEntry.loop; if (!loop && num > trackEntry.endTime) { num = trackEntry.endTime; } TrackEntry previous = trackEntry.previous; if (previous == null) { if (trackEntry.mix == 1f) { trackEntry.animation.Apply(skeleton, trackEntry.lastTime, num, loop, exposedList); } else { trackEntry.animation.Mix(skeleton, trackEntry.lastTime, num, loop, exposedList, trackEntry.mix); } } else { float num2 = previous.time; if (!previous.loop && num2 > previous.endTime) { num2 = previous.endTime; } previous.animation.Apply(skeleton, previous.lastTime, num2, previous.loop, null); previous.lastTime = num2; float num3 = trackEntry.mixTime / trackEntry.mixDuration * trackEntry.mix; if (num3 >= 1f) { num3 = 1f; trackEntry.previous = null; } trackEntry.animation.Mix(skeleton, trackEntry.lastTime, num, loop, exposedList, num3); } int j = 0; int count = exposedList.Count; while (j < count) { Event e = exposedList.Items[j]; trackEntry.OnEvent(this, i, e); if (this.Event != null) { this.Event(this, i, e); } j++; } trackEntry.lastTime = trackEntry.time; } } }
/** Clips the input triangle against the convex, clockwise clipping area. If the triangle lies entirely within the clipping * area, false is returned. The clipping area must duplicate the first vertex at the end of the vertices list. */ internal bool Clip(float x1, float y1, float x2, float y2, float x3, float y3, ExposedList <float> clippingArea, ExposedList <float> output) { var originalOutput = output; var clipped = false; // Avoid copy at the end. ExposedList <float> input = null; if (clippingArea.Count % 4 >= 2) { input = output; output = scratch; } else { input = scratch; } input.Clear(); input.Add(x1); input.Add(y1); input.Add(x2); input.Add(y2); input.Add(x3); input.Add(y3); input.Add(x1); input.Add(y1); output.Clear(); float[] clippingVertices = clippingArea.Items; int clippingVerticesLast = clippingArea.Count - 4; for (int i = 0; ; i += 2) { float edgeX = clippingVertices[i], edgeY = clippingVertices[i + 1]; float edgeX2 = clippingVertices[i + 2], edgeY2 = clippingVertices[i + 3]; float deltaX = edgeX - edgeX2, deltaY = edgeY - edgeY2; float[] inputVertices = input.Items; int inputVerticesLength = input.Count - 2, outputStart = output.Count; for (int ii = 0; ii < inputVerticesLength; ii += 2) { float inputX = inputVertices[ii], inputY = inputVertices[ii + 1]; float inputX2 = inputVertices[ii + 2], inputY2 = inputVertices[ii + 3]; bool side2 = deltaX * (inputY2 - edgeY2) - deltaY * (inputX2 - edgeX2) > 0; if (deltaX * (inputY - edgeY2) - deltaY * (inputX - edgeX2) > 0) { if (side2) // v1 inside, v2 inside { output.Add(inputX2); output.Add(inputY2); continue; } // v1 inside, v2 outside float c0 = inputY2 - inputY, c2 = inputX2 - inputX; float ua = (c2 * (edgeY - inputY) - c0 * (edgeX - inputX)) / (c0 * (edgeX2 - edgeX) - c2 * (edgeY2 - edgeY)); output.Add(edgeX + (edgeX2 - edgeX) * ua); output.Add(edgeY + (edgeY2 - edgeY) * ua); } else if (side2) // v1 outside, v2 inside { float c0 = inputY2 - inputY, c2 = inputX2 - inputX; float ua = (c2 * (edgeY - inputY) - c0 * (edgeX - inputX)) / (c0 * (edgeX2 - edgeX) - c2 * (edgeY2 - edgeY)); output.Add(edgeX + (edgeX2 - edgeX) * ua); output.Add(edgeY + (edgeY2 - edgeY) * ua); output.Add(inputX2); output.Add(inputY2); } clipped = true; } if (outputStart == output.Count) // All edges outside. { originalOutput.Clear(); return(true); } output.Add(output.Items[0]); output.Add(output.Items[1]); if (i == clippingVerticesLast) { break; } var temp = output; output = input; output.Clear(); input = temp; } if (originalOutput != output) { originalOutput.Clear(); for (int i = 0, n = output.Count - 2; i < n; i++) { originalOutput.Add(output.Items[i]); } } else { originalOutput.Resize(originalOutput.Count - 2); } return(clipped); }
public void ClipTriangles(float[] vertices, int verticesLength, int[] triangles, int trianglesLength, float[] uvs) { ExposedList <float> clipOutput = this.clipOutput, clippedVertices = this.clippedVertices; var clippedTriangles = this.clippedTriangles; var polygons = clippingPolygons.Items; int polygonsCount = clippingPolygons.Count; int index = 0; clippedVertices.Clear(); clippedUVs.Clear(); clippedTriangles.Clear(); //outer: for (int i = 0; i < trianglesLength; i += 3) { int vertexOffset = triangles[i] << 1; float x1 = vertices[vertexOffset], y1 = vertices[vertexOffset + 1]; float u1 = uvs[vertexOffset], v1 = uvs[vertexOffset + 1]; vertexOffset = triangles[i + 1] << 1; float x2 = vertices[vertexOffset], y2 = vertices[vertexOffset + 1]; float u2 = uvs[vertexOffset], v2 = uvs[vertexOffset + 1]; vertexOffset = triangles[i + 2] << 1; float x3 = vertices[vertexOffset], y3 = vertices[vertexOffset + 1]; float u3 = uvs[vertexOffset], v3 = uvs[vertexOffset + 1]; for (int p = 0; p < polygonsCount; p++) { int s = clippedVertices.Count; if (Clip(x1, y1, x2, y2, x3, y3, polygons[p], clipOutput)) { int clipOutputLength = clipOutput.Count; if (clipOutputLength == 0) { continue; } float d0 = y2 - y3, d1 = x3 - x2, d2 = x1 - x3, d4 = y3 - y1; float d = 1 / (d0 * d2 + d1 * (y1 - y3)); int clipOutputCount = clipOutputLength >> 1; float[] clipOutputItems = clipOutput.Items; float[] clippedVerticesItems = clippedVertices.Resize(s + clipOutputCount * 2).Items; float[] clippedUVsItems = clippedUVs.Resize(s + clipOutputCount * 2).Items; for (int ii = 0; ii < clipOutputLength; ii += 2) { float x = clipOutputItems[ii], y = clipOutputItems[ii + 1]; clippedVerticesItems[s] = x; clippedVerticesItems[s + 1] = y; float c0 = x - x3, c1 = y - y3; float a = (d0 * c0 + d1 * c1) * d; float b = (d4 * c0 + d2 * c1) * d; float c = 1 - a - b; clippedUVsItems[s] = u1 * a + u2 * b + u3 * c; clippedUVsItems[s + 1] = v1 * a + v2 * b + v3 * c; s += 2; } s = clippedTriangles.Count; int[] clippedTrianglesItems = clippedTriangles.Resize(s + 3 * (clipOutputCount - 2)).Items; clipOutputCount--; for (int ii = 1; ii < clipOutputCount; ii++) { clippedTrianglesItems[s] = index; clippedTrianglesItems[s + 1] = index + ii; clippedTrianglesItems[s + 2] = index + ii + 1; s += 3; } index += clipOutputCount + 1; } else { float[] clippedVerticesItems = clippedVertices.Resize(s + 3 * 2).Items; float[] clippedUVsItems = clippedUVs.Resize(s + 3 * 2).Items; clippedVerticesItems[s] = x1; clippedVerticesItems[s + 1] = y1; clippedVerticesItems[s + 2] = x2; clippedVerticesItems[s + 3] = y2; clippedVerticesItems[s + 4] = x3; clippedVerticesItems[s + 5] = y3; clippedUVsItems[s] = u1; clippedUVsItems[s + 1] = v1; clippedUVsItems[s + 2] = u2; clippedUVsItems[s + 3] = v2; clippedUVsItems[s + 4] = u3; clippedUVsItems[s + 5] = v3; s = clippedTriangles.Count; int[] clippedTrianglesItems = clippedTriangles.Resize(s + 3).Items; clippedTrianglesItems[s] = index; clippedTrianglesItems[s + 1] = index + 1; clippedTrianglesItems[s + 2] = index + 2; index += 3; break; //continue outer; } } } }
public override void Apply(Skeleton skeleton, float lastTime, float time, ExposedList <Event> firedEvents, float alpha, MixPose pose, MixDirection direction) { Slot slot = skeleton.slots.Items[this.slotIndex]; VertexAttachment attachment = slot.attachment as VertexAttachment; if ((attachment != null) && attachment.ApplyDeform(this.attachment)) { float[] items; ExposedList <float> attachmentVertices = slot.attachmentVertices; if (attachmentVertices.Count == 0) { alpha = 1f; } float[][] frameVertices = this.frameVertices; int length = frameVertices[0].Length; float[] frames = this.frames; if (time < frames[0]) { if (pose != MixPose.Setup) { if (pose != MixPose.Current) { return; } } else { attachmentVertices.Clear(true); return; } if (alpha == 1f) { attachmentVertices.Clear(true); } else { if (attachmentVertices.Capacity < length) { attachmentVertices.Capacity = length; } attachmentVertices.Count = length; items = attachmentVertices.Items; if (attachment.bones == null) { float[] vertices = attachment.vertices; for (int i = 0; i < length; i++) { items[i] += (vertices[i] - items[i]) * alpha; } } else { alpha = 1f - alpha; for (int i = 0; i < length; i++) { items[i] *= alpha; } } } } else { if (attachmentVertices.Capacity < length) { attachmentVertices.Capacity = length; } attachmentVertices.Count = length; items = attachmentVertices.Items; if (time >= frames[frames.Length - 1]) { float[] sourceArray = frameVertices[frames.Length - 1]; if (alpha == 1f) { Array.Copy(sourceArray, 0, items, 0, length); } else if (pose == MixPose.Setup) { if (attachment.bones == null) { float[] vertices = attachment.vertices; for (int i = 0; i < length; i++) { float num5 = vertices[i]; items[i] = num5 + ((sourceArray[i] - num5) * alpha); } } else { for (int i = 0; i < length; i++) { items[i] = sourceArray[i] * alpha; } } } else { for (int i = 0; i < length; i++) { items[i] += (sourceArray[i] - items[i]) * alpha; } } } else { int index = Animation.BinarySearch(frames, time); float[] numArray7 = frameVertices[index - 1]; float[] numArray8 = frameVertices[index]; float num9 = frames[index]; float curvePercent = base.GetCurvePercent(index - 1, 1f - ((time - num9) / (frames[index - 1] - num9))); if (alpha == 1f) { for (int i = 0; i < length; i++) { float num12 = numArray7[i]; items[i] = num12 + ((numArray8[i] - num12) * curvePercent); } } else if (pose == MixPose.Setup) { if (attachment.bones == null) { float[] vertices = attachment.vertices; for (int i = 0; i < length; i++) { float num14 = numArray7[i]; float num15 = vertices[i]; items[i] = num15 + (((num14 + ((numArray8[i] - num14) * curvePercent)) - num15) * alpha); } } else { for (int i = 0; i < length; i++) { float num17 = numArray7[i]; items[i] = (num17 + ((numArray8[i] - num17) * curvePercent)) * alpha; } } } else { for (int i = 0; i < length; i++) { float num19 = numArray7[i]; items[i] += ((num19 + ((numArray8[i] - num19) * curvePercent)) - items[i]) * alpha; } } } } } }
/// <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]); } }
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++; } }
public ExposedList <int> Triangulate(ExposedList <float> verticesArray) { float[] items = verticesArray.Items; int newSize = verticesArray.Count >> 1; ExposedList <int> indicesArray = this.indicesArray; indicesArray.Clear(true); int[] indices = indicesArray.Resize(newSize).Items; for (int i = 0; i < newSize; i++) { indices[i] = i; } ExposedList <bool> isConcaveArray = this.isConcaveArray; bool[] flagArray = isConcaveArray.Resize(newSize).Items; int index = 0; int num4 = newSize; while (index < num4) { flagArray[index] = IsConcave(index, newSize, items, indices); index++; } ExposedList <int> triangles = this.triangles; triangles.Clear(true); triangles.EnsureCapacity(Math.Max(0, newSize - 2) << 2); while (newSize > 3) { int num5 = newSize - 1; int num6 = 0; int num7 = 1; Label_00B9: if (!flagArray[num6]) { int num8 = indices[num5] << 1; int num9 = indices[num6] << 1; int num10 = indices[num7] << 1; float num11 = items[num8]; float num12 = items[num8 + 1]; float num13 = items[num9]; float num14 = items[num9 + 1]; float num15 = items[num10]; float num16 = items[num10 + 1]; for (int j = (num7 + 1) % newSize; j != num5; j = (j + 1) % newSize) { if (flagArray[j]) { int num18 = indices[j] << 1; float num19 = items[num18]; float num20 = items[num18 + 1]; if ((PositiveArea(num15, num16, num11, num12, num19, num20) && PositiveArea(num11, num12, num13, num14, num19, num20)) && PositiveArea(num13, num14, num15, num16, num19, num20)) { goto Label_0194; } } } goto Label_01D2; } Label_0194: if (num7 == 0) { do { if (!flagArray[num6]) { break; } num6--; }while (num6 > 0); } else { num5 = num6; num6 = num7; num7 = (num7 + 1) % newSize; goto Label_00B9; } Label_01D2: triangles.Add(indices[((newSize + num6) - 1) % newSize]); triangles.Add(indices[num6]); triangles.Add(indices[(num6 + 1) % newSize]); indicesArray.RemoveAt(num6); isConcaveArray.RemoveAt(num6); newSize--; int num21 = ((newSize + num6) - 1) % newSize; int num22 = (num6 != newSize) ? num6 : 0; flagArray[num21] = IsConcave(num21, newSize, items, indices); flagArray[num22] = IsConcave(num22, newSize, items, indices); } if (newSize == 3) { triangles.Add(indices[2]); triangles.Add(indices[0]); triangles.Add(indices[1]); } return(triangles); }
public ExposedList <ExposedList <float> > Decompose(ExposedList <float> verticesArray, ExposedList <int> triangles) { float[] items = verticesArray.Items; ExposedList <ExposedList <float> > convexPolygons = this.convexPolygons; int index = 0; int count = convexPolygons.Count; while (index < count) { this.polygonPool.Free(convexPolygons.Items[index]); index++; } convexPolygons.Clear(true); ExposedList <ExposedList <int> > convexPolygonsIndices = this.convexPolygonsIndices; int num3 = 0; int num4 = convexPolygonsIndices.Count; while (num3 < num4) { this.polygonIndicesPool.Free(convexPolygonsIndices.Items[num3]); num3++; } convexPolygonsIndices.Clear(true); ExposedList <int> item = this.polygonIndicesPool.Obtain(); item.Clear(true); ExposedList <float> list4 = this.polygonPool.Obtain(); list4.Clear(true); int num5 = -1; int num6 = 0; int[] numArray2 = triangles.Items; int num7 = 0; int num8 = triangles.Count; while (num7 < num8) { int num9 = numArray2[num7] << 1; int num10 = numArray2[num7 + 1] << 1; int num11 = numArray2[num7 + 2] << 1; float num12 = items[num9]; float num13 = items[num9 + 1]; float num14 = items[num10]; float num15 = items[num10 + 1]; float num16 = items[num11]; float num17 = items[num11 + 1]; bool flag = false; if (num5 == num9) { int num18 = list4.Count - 4; float[] numArray3 = list4.Items; int num19 = Winding(numArray3[num18], numArray3[num18 + 1], numArray3[num18 + 2], numArray3[num18 + 3], num16, num17); int num20 = Winding(num16, num17, numArray3[0], numArray3[1], numArray3[2], numArray3[3]); if ((num19 == num6) && (num20 == num6)) { list4.Add(num16); list4.Add(num17); item.Add(num11); flag = true; } } if (!flag) { if (list4.Count > 0) { convexPolygons.Add(list4); convexPolygonsIndices.Add(item); } else { this.polygonPool.Free(list4); this.polygonIndicesPool.Free(item); } list4 = this.polygonPool.Obtain(); list4.Clear(true); list4.Add(num12); list4.Add(num13); list4.Add(num14); list4.Add(num15); list4.Add(num16); list4.Add(num17); item = this.polygonIndicesPool.Obtain(); item.Clear(true); item.Add(num9); item.Add(num10); item.Add(num11); num6 = Winding(num12, num13, num14, num15, num16, num17); num5 = num9; } num7 += 3; } if (list4.Count > 0) { convexPolygons.Add(list4); convexPolygonsIndices.Add(item); } int num21 = 0; int num22 = convexPolygons.Count; while (num21 < num22) { item = convexPolygonsIndices.Items[num21]; if (item.Count != 0) { int num23 = item.Items[0]; int num24 = item.Items[item.Count - 1]; list4 = convexPolygons.Items[num21]; int num25 = list4.Count - 4; float[] numArray4 = list4.Items; float num26 = numArray4[num25]; float num27 = numArray4[num25 + 1]; float num28 = numArray4[num25 + 2]; float num29 = numArray4[num25 + 3]; float num30 = numArray4[0]; float num31 = numArray4[1]; float num32 = numArray4[2]; float num33 = numArray4[3]; int num34 = Winding(num26, num27, num28, num29, num30, num31); for (int j = 0; j < num22; j++) { if (j != num21) { ExposedList <int> list5 = convexPolygonsIndices.Items[j]; if (list5.Count == 3) { int num36 = list5.Items[0]; int num37 = list5.Items[1]; int num38 = list5.Items[2]; ExposedList <float> list6 = convexPolygons.Items[j]; float num39 = list6.Items[list6.Count - 2]; float num40 = list6.Items[list6.Count - 1]; if ((num36 == num23) && (num37 == num24)) { int num41 = Winding(num26, num27, num28, num29, num39, num40); int num42 = Winding(num39, num40, num30, num31, num32, num33); if ((num41 == num34) && (num42 == num34)) { list6.Clear(true); list5.Clear(true); list4.Add(num39); list4.Add(num40); item.Add(num38); num26 = num28; num27 = num29; num28 = num39; num29 = num40; j = 0; } } } } } } num21++; } for (int i = convexPolygons.Count - 1; i >= 0; i--) { list4 = convexPolygons.Items[i]; if (list4.Count == 0) { convexPolygons.RemoveAt(i); this.polygonPool.Free(list4); item = convexPolygonsIndices.Items[i]; convexPolygonsIndices.RemoveAt(i); this.polygonIndicesPool.Free(item); } } return(convexPolygons); }
public void Apply(Skeleton skeleton) { ExposedList <Event> events = this.events; for (int i = 0; i < tracks.Count; i++) { TrackEntry current = tracks.Items[i]; if (current == null) { continue; } events.Clear(); float time = current.time; bool loop = current.loop; if (!loop && time > current.endTime) { time = current.endTime; } TrackEntry previous = current.previous; if (previous == null) { if (current.mix == 1) { current.animation.Apply(skeleton, current.lastTime, time, loop, events); } else { current.animation.Mix(skeleton, current.lastTime, time, loop, events, current.mix); } } else { float previousTime = previous.time; if (!previous.loop && previousTime > previous.endTime) { previousTime = previous.endTime; } previous.animation.Apply(skeleton, previous.lastTime, previousTime, previous.loop, null); // Remove the line above, and uncomment the line below, to allow previous animations to fire events during mixing. //previous.animation.Apply(skeleton, previous.lastTime, previousTime, previous.loop, events); previous.lastTime = previousTime; float alpha = current.mixTime / current.mixDuration * current.mix; if (alpha >= 1) { alpha = 1; current.previous = null; } current.animation.Mix(skeleton, current.lastTime, time, loop, events, alpha); } for (int ii = 0, nn = events.Count; ii < nn; ii++) { Event e = events.Items[ii]; current.OnEvent(this, i, e); if (Event != null) { Event(this, i, e); } } current.lastTime = current.time; } }