diff --git a/spine-cpp/spine-cpp/include/spine/AnimationState.h b/spine-cpp/spine-cpp/include/spine/AnimationState.h index 180103086..ad2783094 100644 --- a/spine-cpp/spine-cpp/include/spine/AnimationState.h +++ b/spine-cpp/spine-cpp/include/spine/AnimationState.h @@ -31,47 +31,188 @@ #ifndef Spine_AnimationState_h #define Spine_AnimationState_h +#include + namespace Spine { + class Animation; + /// State for the playback of an animation class TrackEntry { -// internal Animation animation; + public: + TrackEntry(); + + /// The index of the track where this entry is either current or queued. + int getTrackIndex(); + + /// The animation to apply for this track entry. + Animation* getAnimation(); + + /// + /// If true, the animation will repeat. If false, it will not, instead its last frame is applied if played beyond its duration. + bool getLoop(); + void setLoop(bool inValue); + + /// + /// Seconds to postpone playing the animation. When a track entry is the current track entry, delay postpones incrementing + /// the track time. When a track entry is queued, delay is the time from the start of the previous animation to when the + /// track entry will become the current track entry. + float getDelay(); + void setDelay(float inValue); + + /// + /// Current time in seconds this track entry has been the current track entry. The track time determines + /// TrackEntry.AnimationTime. The track time can be set to start the animation at a time other than 0, without affecting looping. + float getTrackTime(); + void setTrackTime(float inValue); + + /// + /// The track time in seconds when this animation will be removed from the track. Defaults to the animation duration for + /// non-looping animations and to int.MaxValue for looping animations. If the track end time is reached and no + /// other animations are queued for playback, and mixing from any previous animations is complete, properties keyed by the animation, + /// are set to the setup pose and the track is cleared. + /// + /// It may be desired to use AnimationState.addEmptyAnimation(int, float, float) to mix the properties back to the + /// setup pose over time, rather than have it happen instantly. + /// + float getTrackEnd(); + void setTrackEnd(float inValue); + + /// + /// Seconds when this animation starts, both initially and after looping. Defaults to 0. + /// + /// When changing the animation start time, it often makes sense to set TrackEntry.AnimationLast to the same value to + /// prevent timeline keys before the start time from triggering. + /// + float getAnimationStart(); + void setAnimationStart(float inValue); + + /// + /// Seconds for the last frame of this animation. Non-looping animations won't play past this time. Looping animations will + /// loop back to TrackEntry.AnimationStart at this time. Defaults to the animation duration. + float getAnimationEnd(); + void setAnimationEnd(float inValue); + + /// + /// The time in seconds this animation was last applied. Some timelines use this for one-time triggers. Eg, when this + /// animation is applied, event timelines will fire all events between the animation last time (exclusive) and animation time + /// (inclusive). Defaults to -1 to ensure triggers on frame 0 happen the first time this animation is applied. + float getAnimationLast(); + void setAnimationLast(float inValue); + + /// + /// Uses TrackEntry.TrackTime to compute the animation time between TrackEntry.AnimationStart. and + /// TrackEntry.AnimationEnd. When the track time is 0, the animation time is equal to the animation start time. + /// + float getAnimationTime(); + + /// + /// Multiplier for the delta time when the animation state is updated, causing time for this animation to play slower or + /// faster. Defaults to 1. + /// + float getTimeScale(); + void setTimeScale(float inValue); + + /// + /// Values less than 1 mix this animation with the last skeleton pose. Defaults to 1, which overwrites the last skeleton pose with + /// this animation. + /// + /// Typically track 0 is used to completely pose the skeleton, then alpha can be used on higher tracks. It doesn't make sense + /// to use alpha on track 0 if the skeleton pose is from the last frame render. + /// + float getAlpha(); + void setAlpha(float inValue); + + /// + /// When the mix percentage (mix time / mix duration) is less than the event threshold, event timelines for the animation + /// being mixed out will be applied. Defaults to 0, so event timelines are not applied for an animation being mixed out. + float getEventThreshold(); + void setEventThreshold(float inValue); + + /// + /// When the mix percentage (mix time / mix duration) is less than the attachment threshold, attachment timelines for the + /// animation being mixed out will be applied. Defaults to 0, so attachment timelines are not applied for an animation being + /// mixed out. + float getAttachmentThreshold(); + void setAttachmentThreshold(float inValue); + + /// + /// When the mix percentage (mix time / mix duration) is less than the draw order threshold, draw order timelines for the + /// animation being mixed out will be applied. Defaults to 0, so draw order timelines are not applied for an animation being + /// mixed out. + /// + float getDrawOrderThreshold(); + void setDrawOrderThreshold(float inValue); + + /// + /// The animation queued to start after this animation, or null. + TrackEntry* getNext(); + + /// + /// Returns true if at least one loop has been completed. + bool isComplete(); + + /// + /// Seconds from 0 to the mix duration when mixing from the previous animation to this animation. May be slightly more than + /// TrackEntry.MixDuration when the mix is complete. + float getMixTime(); + void setMixTime(float inValue); + + /// + /// Seconds for mixing from the previous animation to this animation. Defaults to the value provided by + /// AnimationStateData based on the animation before this animation (if any). + /// + /// The mix duration can be set manually rather than use the value from AnimationStateData.GetMix. + /// In that case, the mixDuration must be set before AnimationState.update(float) is next called. + /// + /// When using AnimationState::addAnimation(int, Animation, bool, float) with a delay + /// less than or equal to 0, note the Delay is set using the mix duration from the AnimationStateData + /// + /// + /// + float getMixDuration(); + void setMixDuration(float inValue); + + /// + /// The track entry for the previous animation when mixing from the previous animation to this animation, or null if no + /// mixing is currently occuring. When mixing from multiple animations, MixingFrom makes up a linked list. + TrackEntry* getMixingFrom(); + + /// + /// Resets the rotation directions for mixing this entry's rotate timelines. This can be useful to avoid bones rotating the + /// long way around when using alpha and starting animations on other tracks. + /// + /// Mixing involves finding a rotation between two others, which has two possible solutions: the short way or the long way around. + /// The two rotations likely change over time, so which direction is the short or long way also changes. + /// If the short way was always chosen, bones would flip to the other side when that direction became the long way. + /// TrackEntry chooses the short way the first time it is applied and remembers that direction. + void resetRotationDirections(); + + private: + Animation* _animation; + + TrackEntry* _next; + TrackEntry* _mixingFrom; + int _trackIndex; // -// internal TrackEntry next, mixingFrom; -// internal int trackIndex; -// -// internal bool loop; -// internal float eventThreshold, attachmentThreshold, drawOrderThreshold; -// internal float animationStart, animationEnd, animationLast, nextAnimationLast; -// internal float delay, trackTime, trackLast, nextTrackLast, trackEnd, timeScale = 1f; -// internal float alpha, mixTime, mixDuration, interruptAlpha, totalAlpha; -// internal readonly ExposedList timelineData = new ExposedList(); -// internal readonly ExposedList timelineDipMix = new ExposedList(); -// internal readonly ExposedList timelinesRotation = new ExposedList(); -// -// void reset () + bool _loop; + float _eventThreshold, _attachmentThreshold, _drawOrderThreshold; + float _animationStart, _animationEnd, _animationLast, _nextAnimationLast; + float _delay, _trackTime, _trackLast, _nextTrackLast, _trackEnd, _timeScale = 1.0f; + float _alpha, _mixTime, _mixDuration, _interruptAlpha, _totalAlpha; + Vector _timelineData; + Vector _timelineDipMix; + Vector _timelinesRotation; +// event AnimationState.TrackEntryDelegate Start, Interrupt, End, Dispose, Complete; +// event AnimationState.TrackEntryEventDelegate Event; + + /// Sets the timeline data. + /// @param to May be null. +// TrackEntry setTimelineData(TrackEntry* to, Vector mixingToArray, HashSet propertyIDs) // { -// next = null; -// mixingFrom = null; -// animation = null; -// timelineData.Clear(); -// timelineDipMix.Clear(); -// timelinesRotation.Clear(); -// -// Start = null; -// Interrupt = null; -// End = null; -// Dispose = null; -// Complete = null; -// Event = null; -// } -// -// /// Sets the timeline data. -// /// May be null. -// internal TrackEntry SetTimelineData (TrackEntry to, ExposedList mixingToArray, HashSet propertyIDs) { // if (to != null) mixingToArray.Add(to); -// var lastEntry = mixingFrom != null ? mixingFrom.SetTimelineData(this, mixingToArray, propertyIDs) : this; +// var lastEntry = mixingFrom != null ? mixingFrom.setTimelineData(this, mixingToArray, propertyIDs) : this; // if (to != null) mixingToArray.Pop(); // // var mixingTo = mixingToArray.Items; @@ -79,7 +220,7 @@ namespace Spine // var timelines = animation.timelines.Items; // int timelinesCount = animation.timelines.Count; // var timelineDataItems = timelineData.Resize(timelinesCount).Items; // timelineData.setSize(timelinesCount); -// timelineDipMix.Clear(); +// timelineDipMix.clear(); // var timelineDipMixItems = timelineDipMix.Resize(timelinesCount).Items; //timelineDipMix.setSize(timelinesCount); // // // outer: @@ -87,12 +228,12 @@ namespace Spine // int id = timelines[i].PropertyId; // if (!propertyIDs.Add(id)) { // timelineDataItems[i] = AnimationState.Subsequent; -// } else if (to == null || !to.HasTimeline(id)) { +// } else if (to == null || !to.hasTimeline(id)) { // timelineDataItems[i] = AnimationState.First; // } else { // for (int ii = mixingToLast; ii >= 0; ii--) { // var entry = mixingTo[ii]; -// if (!entry.HasTimeline(id)) { +// if (!entry.hasTimeline(id)) { // if (entry.mixDuration > 0) { // timelineDataItems[i] = AnimationState.DipMix; // timelineDipMixItems[i] = entry; @@ -107,176 +248,42 @@ namespace Spine // } // return lastEntry; // } -// -// bool HasTimeline (int id) { + + bool hasTimeline(int inId) + { // var timelines = animation.timelines.Items; -// for (int i = 0, n = animation.timelines.Count; i < n; i++) -// if (timelines[i].PropertyId == id) return true; -// return false; -// } -// -// /// The index of the track where this entry is either current or queued. -// public int TrackIndex { get { return trackIndex; } } -// -// /// The animation to apply for this track entry. -// public Animation Animation { get { return animation; } } -// -// /// -// /// If true, the animation will repeat. If false, it will not, instead its last frame is applied if played beyond its duration. -// public bool Loop { get { return loop; } set { loop = value; } } -// -// /// -// /// Seconds to postpone playing the animation. When a track entry is the current track entry, delay postpones incrementing -// /// the track time. When a track entry is queued, delay is the time from the start of the previous animation to when the -// /// track entry will become the current track entry. -// public float Delay { get { return delay; } set { delay = value; } } -// -// /// -// /// Current time in seconds this track entry has been the current track entry. The track time determines -// /// . The track time can be set to start the animation at a time other than 0, without affecting looping. -// public float TrackTime { get { return trackTime; } set { trackTime = value; } } -// -// /// -// /// The track time in seconds when this animation will be removed from the track. Defaults to the animation duration for -// /// non-looping animations and to for looping animations. If the track end time is reached and no -// /// other animations are queued for playback, and mixing from any previous animations is complete, properties keyed by the animation, -// /// are set to the setup pose and the track is cleared. -// /// -// /// It may be desired to use to mix the properties back to the -// /// setup pose over time, rather than have it happen instantly. -// /// -// public float TrackEnd { get { return trackEnd; } set { trackEnd = value; } } -// -// /// -// /// Seconds when this animation starts, both initially and after looping. Defaults to 0. -// /// -// /// When changing the animation start time, it often makes sense to set to the same value to -// /// prevent timeline keys before the start time from triggering. -// /// -// public float AnimationStart { get { return animationStart; } set { animationStart = value; } } -// -// /// -// /// Seconds for the last frame of this animation. Non-looping animations won't play past this time. Looping animations will -// /// loop back to at this time. Defaults to the animation duration. -// public float AnimationEnd { get { return animationEnd; } set { animationEnd = value; } } -// -// /// -// /// The time in seconds this animation was last applied. Some timelines use this for one-time triggers. Eg, when this -// /// animation is applied, event timelines will fire all events between the animation last time (exclusive) and animation time -// /// (inclusive). Defaults to -1 to ensure triggers on frame 0 happen the first time this animation is applied. -// public float AnimationLast { -// get { return animationLast; } -// set { -// animationLast = value; -// nextAnimationLast = value; -// } -// } -// -// /// -// /// Uses to compute the animation time between . and -// /// . When the track time is 0, the animation time is equal to the animation start time. -// /// -// public float AnimationTime { -// get { -// if (loop) { -// float duration = animationEnd - animationStart; -// if (duration == 0) return animationStart; -// return (trackTime % duration) + animationStart; +// for (int i = 0, n = animation.timelines.Count; i < n; ++i) +// { +// if (timelines[i].PropertyId == inId) +// { +// return true; // } -// return Math.Min(trackTime + animationStart, animationEnd); // } -// } + return false; + } + +// void onStart() { if (Start != null) Start(this); } +// void onInterrupt() { if (Interrupt != null) Interrupt(this); } +// void onEnd() { if (End != null) End(this); } +// void onDispose() { if (Dispose != null) Dispose(this); } +// void onComplete() { if (Complete != null) Complete(this); } +// void onEvent(Event& e) { if (Event != null) Event(this, e); } // -// /// -// /// Multiplier for the delta time when the animation state is updated, causing time for this animation to play slower or -// /// faster. Defaults to 1. -// /// -// public float TimeScale { get { return timeScale; } set { timeScale = value; } } +// void reset() +// { +// next = null; +// mixingFrom = null; +// animation = null; +// timelineData.clear(); +// timelineDipMix.clear(); +// timelinesRotation.clear(); // -// /// -// /// Values less than 1 mix this animation with the last skeleton pose. Defaults to 1, which overwrites the last skeleton pose with -// /// this animation. -// /// -// /// Typically track 0 is used to completely pose the skeleton, then alpha can be used on higher tracks. It doesn't make sense -// /// to use alpha on track 0 if the skeleton pose is from the last frame render. -// /// -// public float Alpha { get { return alpha; } set { alpha = value; } } -// -// /// -// /// When the mix percentage (mix time / mix duration) is less than the event threshold, event timelines for the animation -// /// being mixed out will be applied. Defaults to 0, so event timelines are not applied for an animation being mixed out. -// public float EventThreshold { get { return eventThreshold; } set { eventThreshold = value; } } -// -// /// -// /// When the mix percentage (mix time / mix duration) is less than the attachment threshold, attachment timelines for the -// /// animation being mixed out will be applied. Defaults to 0, so attachment timelines are not applied for an animation being -// /// mixed out. -// public float AttachmentThreshold { get { return attachmentThreshold; } set { attachmentThreshold = value; } } -// -// /// -// /// When the mix percentage (mix time / mix duration) is less than the draw order threshold, draw order timelines for the -// /// animation being mixed out will be applied. Defaults to 0, so draw order timelines are not applied for an animation being -// /// mixed out. -// /// -// public float DrawOrderThreshold { get { return drawOrderThreshold; } set { drawOrderThreshold = value; } } -// -// /// -// /// The animation queued to start after this animation, or null. -// public TrackEntry Next { get { return next; } } -// -// /// -// /// Returns true if at least one loop has been completed. -// public bool IsComplete { -// get { return trackTime >= animationEnd - animationStart; } -// } -// -// /// -// /// Seconds from 0 to the mix duration when mixing from the previous animation to this animation. May be slightly more than -// /// when the mix is complete. -// public float MixTime { get { return mixTime; } set { mixTime = value; } } -// -// /// -// /// Seconds for mixing from the previous animation to this animation. Defaults to the value provided by -// /// based on the animation before this animation (if any). -// /// -// /// The mix duration can be set manually rather than use the value from AnimationStateData.GetMix. -// /// In that case, the mixDuration must be set before is next called. -// /// -// /// When using with a -// /// delay less than or equal to 0, note the is set using the mix duration from the -// /// -// /// -// /// -// public float MixDuration { get { return mixDuration; } set { mixDuration = value; } } -// -// /// -// /// The track entry for the previous animation when mixing from the previous animation to this animation, or null if no -// /// mixing is currently occuring. When mixing from multiple animations, MixingFrom makes up a linked list. -// public TrackEntry MixingFrom { get { return mixingFrom; } } -// -// public event AnimationState.TrackEntryDelegate Start, Interrupt, End, Dispose, Complete; -// public event AnimationState.TrackEntryEventDelegate Event; -// internal void OnStart () { if (Start != null) Start(this); } -// internal void OnInterrupt () { if (Interrupt != null) Interrupt(this); } -// internal void OnEnd () { if (End != null) End(this); } -// internal void OnDispose () { if (Dispose != null) Dispose(this); } -// internal void OnComplete () { if (Complete != null) Complete(this); } -// internal void OnEvent (Event e) { if (Event != null) Event(this, e); } -// -// /// -// /// Resets the rotation directions for mixing this entry's rotate timelines. This can be useful to avoid bones rotating the -// /// long way around when using and starting animations on other tracks. -// /// -// /// Mixing involves finding a rotation between two others, which has two possible solutions: the short way or the long way around. -// /// The two rotations likely change over time, so which direction is the short or long way also changes. -// /// If the short way was always chosen, bones would flip to the other side when that direction became the long way. -// /// TrackEntry chooses the short way the first time it is applied and remembers that direction. -// public void ResetRotationDirections () { -// timelinesRotation.Clear(); -// } -// -// override public string ToString () { -// return animation == null ? "" : animation.name; +// Start = null; +// Interrupt = null; +// End = null; +// Dispose = null; +// Complete = null; +// Event = null; // } }; @@ -287,11 +294,11 @@ namespace Spine // // private readonly AnimationState state; // private readonly Pool trackEntryPool; -// internal event Action AnimationsChanged; +// internal event Action animationsChanged; // -// internal EventQueue (AnimationState state, Action HandleAnimationsChanged, Pool trackEntryPool) { +// internal EventQueue(AnimationState state, Action HandleanimationsChanged, Pool trackEntryPool) { // this.state = state; -// this.AnimationsChanged += HandleAnimationsChanged; +// this.animationsChanged += HandleanimationsChanged; // this.trackEntryPool = trackEntryPool; // } // @@ -300,7 +307,7 @@ namespace Spine // public TrackEntry entry; // public Event e; // -// public EventQueueEntry (EventType eventType, TrackEntry trackEntry, Event e = null) { +// public EventQueueEntry(EventType eventType, TrackEntry trackEntry, Event e = null) { // this.type = eventType; // this.entry = trackEntry; // this.e = e; @@ -311,113 +318,112 @@ namespace Spine // Start, Interrupt, End, Dispose, Complete, Event // } // -// internal void Start (TrackEntry entry) { +// internal void Start(TrackEntry entry) { // eventQueueEntries.Add(new EventQueueEntry(EventType.Start, entry)); -// if (AnimationsChanged != null) AnimationsChanged(); +// if (animationsChanged != null) animationsChanged(); // } // -// internal void Interrupt (TrackEntry entry) { +// internal void Interrupt(TrackEntry entry) { // eventQueueEntries.Add(new EventQueueEntry(EventType.Interrupt, entry)); // } // -// internal void End (TrackEntry entry) { +// internal void End(TrackEntry entry) { // eventQueueEntries.Add(new EventQueueEntry(EventType.End, entry)); -// if (AnimationsChanged != null) AnimationsChanged(); +// if (animationsChanged != null) animationsChanged(); // } // -// internal void Dispose (TrackEntry entry) { +// internal void Dispose(TrackEntry entry) { // eventQueueEntries.Add(new EventQueueEntry(EventType.Dispose, entry)); // } // -// internal void Complete (TrackEntry entry) { +// internal void Complete(TrackEntry entry) { // eventQueueEntries.Add(new EventQueueEntry(EventType.Complete, entry)); // } // -// internal void Event (TrackEntry entry, Event e) { +// internal void Event(TrackEntry entry, Event e) { // eventQueueEntries.Add(new EventQueueEntry(EventType.Event, entry, e)); // } // -// /// Raises all events in the queue and drains the queue. -// internal void Drain () { +// /// Raises all events in the queue and drains the queue. +// internal void drain() { // if (drainDisabled) return; // drainDisabled = true; // // var entries = this.eventQueueEntries; // AnimationState state = this.state; // -// // Don't cache entries.Count so callbacks can queue their own events (eg, call SetAnimation in AnimationState_Complete). +// // Don't cache entries.Count so callbacks can queue their own events (eg, call setAnimation in AnimationState_Complete). // for (int i = 0; i < entries.Count; i++) { // var queueEntry = entries[i]; // TrackEntry trackEntry = queueEntry.entry; // // switch (queueEntry.type) { // case EventType.Start: -// trackEntry.OnStart(); -// state.OnStart(trackEntry); +// trackEntry.onStart(); +// state.onStart(trackEntry); // break; // case EventType.Interrupt: -// trackEntry.OnInterrupt(); -// state.OnInterrupt(trackEntry); +// trackEntry.onInterrupt(); +// state.onInterrupt(trackEntry); // break; // case EventType.End: -// trackEntry.OnEnd(); -// state.OnEnd(trackEntry); -// goto case EventType.Dispose; // Fall through. (C#) +// trackEntry.onEnd(); +// state.onEnd(trackEntry); // case EventType.Dispose: -// trackEntry.OnDispose(); -// state.OnDispose(trackEntry); +// trackEntry.onDispose(); +// state.onDispose(trackEntry); // trackEntryPool.Free(trackEntry); // Pooling // break; // case EventType.Complete: -// trackEntry.OnComplete(); -// state.OnComplete(trackEntry); +// trackEntry.onComplete(); +// state.onComplete(trackEntry); // break; // case EventType.Event: -// trackEntry.OnEvent(queueEntry.e); -// state.OnEvent(trackEntry, queueEntry.e); +// trackEntry.onEvent(queueEntry.e); +// state.onEvent(trackEntry, queueEntry.e); // break; // } // } -// eventQueueEntries.Clear(); +// eventQueueEntries.clear(); // // drainDisabled = false; // } // -// internal void Clear () { -// eventQueueEntries.Clear(); +// internal void clear() { +// eventQueueEntries.clear(); // } }; class AnimationState { -// static readonly Animation EmptyAnimation = new Animation("", new ExposedList(), 0); +// static readonly Animation EmptyAnimation = new Animation("", new Vector(), 0); // internal const int Subsequent = 0, First = 1, Dip = 2, DipMix = 3; // // private AnimationStateData data; // // Pool trackEntryPool = new Pool(); -// private readonly ExposedList tracks = new ExposedList(); -// private readonly ExposedList events = new ExposedList(); +// private readonly Vector tracks = new Vector(); +// private readonly Vector events = new Vector(); // private readonly EventQueue queue; // Initialized by constructor. // // private readonly HashSet propertyIDs = new HashSet(); -// private readonly ExposedList mixingTo = new ExposedList(); +// private readonly Vector mixingTo = new Vector(); // private bool animationsChanged; // // private float timeScale = 1; // // public AnimationStateData Data { get { return data; } } -// /// A list of tracks that have animations, which may contain nulls. -// public ExposedList Tracks { get { return tracks; } } +// /// A list of tracks that have animations, which may contain nulls. +// public Vector Tracks { get { return tracks; } } // public float TimeScale { get { return timeScale; } set { timeScale = value; } } // -// public delegate void TrackEntryDelegate (TrackEntry trackEntry); +// public delegate void TrackEntryDelegate(TrackEntry trackEntry); // public event TrackEntryDelegate Start, Interrupt, End, Dispose, Complete; // -// public delegate void TrackEntryEventDelegate (TrackEntry trackEntry, Event e); +// public delegate void TrackEntryEventDelegate(TrackEntry trackEntry, Event e); // public event TrackEntryEventDelegate Event; // -// public AnimationState (AnimationStateData data) { +// public AnimationState(AnimationStateData data) { // if (data == null) throw new ArgumentNullException("data", "data cannot be null."); // this.data = data; // this.queue = new EventQueue( @@ -427,10 +433,10 @@ namespace Spine // ); // } // -// /// -// /// Increments the track entry times, setting queued animations as current if needed -// /// delta time -// public void Update (float delta) { +// /// +// /// Increments the track entry times, setting queued animations as current if needed +// /// @param delta delta time +// public void update(float delta) { // delta *= timeScale; // var tracksItems = tracks.Items; // for (int i = 0, n = tracks.Count; i < n; i++) { @@ -457,7 +463,7 @@ namespace Spine // next.delay = 0; // next.trackTime = nextTime + (delta * next.timeScale); // current.trackTime += currentDelta; -// SetCurrent(i, next, true); +// setCurrent(i, next, true); // while (next.mixingFrom != null) { // next.mixTime += currentDelta; // next = next.mixingFrom; @@ -465,14 +471,14 @@ namespace Spine // continue; // } // } else if (current.trackLast >= current.trackEnd && current.mixingFrom == null) { -// // Clear the track when there is no next entry, the track end time is reached, and there is no mixingFrom. +// // clear the track when there is no next entry, the track end time is reached, and there is no mixingFrom. // tracksItems[i] = null; // // queue.End(current); -// DisposeNext(current); +// disposeNext(current); // continue; // } -// if (current.mixingFrom != null && UpdateMixingFrom(current, delta)) { +// if (current.mixingFrom != null && updateMixingFrom(current, delta)) { // // End mixing from entries once all have completed. // var from = current.mixingFrom; // current.mixingFrom = null; @@ -485,15 +491,15 @@ namespace Spine // current.trackTime += currentDelta; // } // -// queue.Drain(); +// queue.drain(); // } // -// /// Returns true when all mixing from entries are complete. -// private bool UpdateMixingFrom (TrackEntry to, float delta) { +// /// Returns true when all mixing from entries are complete. +// private bool updateMixingFrom(TrackEntry to, float delta) { // TrackEntry from = to.mixingFrom; // if (from == null) return true; // -// bool finished = UpdateMixingFrom(from, delta); +// bool finished = updateMixingFrom(from, delta); // // // Require mixTime > 0 to ensure the mixing from entry was applied at least once. // if (to.mixTime > 0 && (to.mixTime >= to.mixDuration || to.timeScale == 0)) { @@ -513,12 +519,12 @@ namespace Spine // return false; // } // -// /// +// /// // /// Poses the skeleton using the track entry animations. There are no side effects other than invoking listeners, so the -// /// animation state can be applied to multiple skeletons to pose them identically. -// public bool Apply (Skeleton skeleton) { +// /// animation state can be applied to multiple skeletons to pose them identically. +// public bool apply(Skeleton skeleton) { // if (skeleton == null) throw new ArgumentNullException("skeleton", "skeleton cannot be null."); -// if (animationsChanged) AnimationsChanged(); +// if (animationsChanged) animationsChanged(); // // var events = this.events; // @@ -530,21 +536,21 @@ namespace Spine // applied = true; // MixPose currentPose = i == 0 ? MixPose.Current : MixPose.CurrentLayered; // -// // Apply mixing from entries first. +// // apply mixing from entries first. // float mix = current.alpha; // if (current.mixingFrom != null) -// mix *= ApplyMixingFrom(current, skeleton, currentPose); +// mix *= applyMixingFrom(current, skeleton, currentPose); // else if (current.trackTime >= current.trackEnd && current.next == null) // // mix = 0; // Set to setup pose the last time the entry will be applied. // -// // Apply current entry. +// // apply current entry. // float animationLast = current.animationLast, animationTime = current.AnimationTime; // int timelineCount = current.animation.timelines.Count; // var timelines = current.animation.timelines; // var timelinesItems = timelines.Items; // if (mix == 1) { // for (int ii = 0; ii < timelineCount; ii++) -// timelinesItems[ii].Apply(skeleton, animationLast, animationTime, events, 1, MixPose.Setup, MixDirection.In); +// timelinesItems[ii].apply(skeleton, animationLast, animationTime, events, 1, MixPose.Setup, MixDirection.In); // } else { // var timelineData = current.timelineData.Items; // @@ -557,24 +563,24 @@ namespace Spine // MixPose pose = timelineData[ii] >= AnimationState.First ? MixPose.Setup : currentPose; // var rotateTimeline = timeline as RotateTimeline; // if (rotateTimeline != null) -// ApplyRotateTimeline(rotateTimeline, skeleton, animationTime, mix, pose, timelinesRotation, ii << 1, firstFrame); +// applyRotateTimeline(rotateTimeline, skeleton, animationTime, mix, pose, timelinesRotation, ii << 1, firstFrame); // else -// timeline.Apply(skeleton, animationLast, animationTime, events, mix, pose, MixDirection.In); +// timeline.apply(skeleton, animationLast, animationTime, events, mix, pose, MixDirection.In); // } // } -// QueueEvents(current, animationTime); -// events.Clear(false); +// queueEvents(current, animationTime); +// events.clear(false); // current.nextAnimationLast = animationTime; // current.nextTrackLast = current.trackTime; // } // -// queue.Drain(); +// queue.drain(); // return applied; // } // -// private float ApplyMixingFrom (TrackEntry to, Skeleton skeleton, MixPose currentPose) { +// private float applyMixingFrom(TrackEntry to, Skeleton skeleton, MixPose currentPose) { // TrackEntry from = to.mixingFrom; -// if (from.mixingFrom != null) ApplyMixingFrom(from, skeleton, currentPose); +// if (from.mixingFrom != null) applyMixingFrom(from, skeleton, currentPose); // // float mix; // if (to.mixDuration == 0) { // Single frame mix to undo mixingFrom changes. @@ -627,27 +633,27 @@ namespace Spine // from.totalAlpha += alpha; // var rotateTimeline = timeline as RotateTimeline; // if (rotateTimeline != null) { -// ApplyRotateTimeline(rotateTimeline, skeleton, animationTime, alpha, pose, timelinesRotation, i << 1, firstFrame); +// applyRotateTimeline(rotateTimeline, skeleton, animationTime, alpha, pose, timelinesRotation, i << 1, firstFrame); // } else { -// timeline.Apply(skeleton, animationLast, animationTime, eventBuffer, alpha, pose, MixDirection.Out); +// timeline.apply(skeleton, animationLast, animationTime, eventBuffer, alpha, pose, MixDirection.Out); // } // } // -// if (to.mixDuration > 0) QueueEvents(from, animationTime); -// this.events.Clear(false); +// if (to.mixDuration > 0) queueEvents(from, animationTime); +// this.events.clear(false); // from.nextAnimationLast = animationTime; // from.nextTrackLast = from.trackTime; // // return mix; // } // -// static private void ApplyRotateTimeline (RotateTimeline rotateTimeline, Skeleton skeleton, float time, float alpha, MixPose pose, +// static private void applyRotateTimeline(RotateTimeline rotateTimeline, Skeleton skeleton, float time, float alpha, MixPose pose, // float[] timelinesRotation, int i, bool firstFrame) { // // if (firstFrame) timelinesRotation[i] = 0; // // if (alpha == 1) { -// rotateTimeline.Apply(skeleton, 0, time, null, 1, pose, MixDirection.In); +// rotateTimeline.apply(skeleton, 0, time, null, 1, pose, MixDirection.In); // return; // } // @@ -706,7 +712,7 @@ namespace Spine // bone.rotation = r1 - (16384 - (int)(16384.499999999996 - r1 / 360)) * 360; // } // -// private void QueueEvents (TrackEntry entry, float animationTime) { +// private void queueEvents(TrackEntry entry, float animationTime) { // float animationStart = entry.animationStart, animationEnd = entry.animationEnd; // float duration = animationEnd - animationStart; // float trackLastWrapped = entry.trackLast % duration; @@ -736,33 +742,33 @@ namespace Spine // } // } // -// /// +// /// // /// Removes all animations from all tracks, leaving skeletons in their previous pose. -// /// It may be desired to use to mix the skeletons back to the setup pose, -// /// rather than leaving them in their previous pose. -// public void ClearTracks () { -// bool oldDrainDisabled = queue.drainDisabled; +// /// It may be desired to use AnimationState.setEmptyAnimations(float) to mix the skeletons back to the setup pose, +// /// rather than leaving them in their previous pose. +// public void clearTracks() { +// bool olddrainDisabled = queue.drainDisabled; // queue.drainDisabled = true; // for (int i = 0, n = tracks.Count; i < n; i++) { -// ClearTrack(i); +// clearTrack(i); // } -// tracks.Clear(); -// queue.drainDisabled = oldDrainDisabled; -// queue.Drain(); +// tracks.clear(); +// queue.drainDisabled = olddrainDisabled; +// queue.drain(); // } // -// /// +// /// // /// Removes all animations from the tracks, leaving skeletons in their previous pose. -// /// It may be desired to use to mix the skeletons back to the setup pose, -// /// rather than leaving them in their previous pose. -// public void ClearTrack (int trackIndex) { +// /// It may be desired to use AnimationState.setEmptyAnimations(float) to mix the skeletons back to the setup pose, +// /// rather than leaving them in their previous pose. +// public void clearTrack(int trackIndex) { // if (trackIndex >= tracks.Count) return; // TrackEntry current = tracks.Items[trackIndex]; // if (current == null) return; // // queue.End(current); // -// DisposeNext(current); +// disposeNext(current); // // TrackEntry entry = current; // while (true) { @@ -775,12 +781,12 @@ namespace Spine // // tracks.Items[current.trackIndex] = null; // -// queue.Drain(); +// queue.drain(); // } // -// /// Sets the active TrackEntry for a given track number. -// private void SetCurrent (int index, TrackEntry current, bool interrupt) { -// TrackEntry from = ExpandToIndex(index); +// /// Sets the active TrackEntry for a given track number. +// private void setCurrent(int index, TrackEntry current, bool interrupt) { +// TrackEntry from = expandToIndex(index); // tracks.Items[index] = current; // // if (from != null) { @@ -792,80 +798,80 @@ namespace Spine // if (from.mixingFrom != null && from.mixDuration > 0) // current.interruptAlpha *= Math.Min(1, from.mixTime / from.mixDuration); // -// from.timelinesRotation.Clear(); // Reset rotation for mixing out, in case entry was mixed in. +// from.timelinesRotation.clear(); // Reset rotation for mixing out, in case entry was mixed in. // } // -// queue.Start(current); // triggers AnimationsChanged +// queue.Start(current); // triggers animationsChanged // } // // -// /// Sets an animation by name. -// public TrackEntry SetAnimation (int trackIndex, string animationName, bool loop) { +// /// Sets an animation by name. setAnimation(int, Animation, bool) +// public TrackEntry setAnimation(int trackIndex, string animationName, bool loop) { // Animation animation = data.skeletonData.FindAnimation(animationName); // if (animation == null) throw new ArgumentException("Animation not found: " + animationName, "animationName"); -// return SetAnimation(trackIndex, animation, loop); +// return setAnimation(trackIndex, animation, loop); // } // -// /// Sets the current animation for a track, discarding any queued animations. -// /// If true, the animation will repeat. +// /// Sets the current animation for a track, discarding any queued animations. +// /// @param loop If true, the animation will repeat. // /// If false, it will not, instead its last frame is applied if played beyond its duration. -// /// In either case determines when the track is cleared. -// /// +// /// In either case TrackEntry.TrackEnd determines when the track is cleared. +// /// @return // /// A track entry to allow further customization of animation playback. References to the track entry must not be kept -// /// after . -// public TrackEntry SetAnimation (int trackIndex, Animation animation, bool loop) { +// /// after AnimationState.Dispose. +// public TrackEntry setAnimation(int trackIndex, Animation animation, bool loop) { // if (animation == null) throw new ArgumentNullException("animation", "animation cannot be null."); // bool interrupt = true; -// TrackEntry current = ExpandToIndex(trackIndex); +// TrackEntry current = expandToIndex(trackIndex); // if (current != null) { // if (current.nextTrackLast == -1) { // // Don't mix from an entry that was never applied. // tracks.Items[trackIndex] = current.mixingFrom; // queue.Interrupt(current); // queue.End(current); -// DisposeNext(current); +// disposeNext(current); // current = current.mixingFrom; // interrupt = false; // } else { -// DisposeNext(current); +// disposeNext(current); // } // } -// TrackEntry entry = NewTrackEntry(trackIndex, animation, loop, current); -// SetCurrent(trackIndex, entry, interrupt); -// queue.Drain(); +// TrackEntry entry = newTrackEntry(trackIndex, animation, loop, current); +// setCurrent(trackIndex, entry, interrupt); +// queue.drain(); // return entry; // } // -// /// Queues an animation by name. -// /// -// public TrackEntry AddAnimation (int trackIndex, string animationName, bool loop, float delay) { +// /// Queues an animation by name. +// /// addAnimation(int, Animation, bool, float) +// public TrackEntry addAnimation(int trackIndex, string animationName, bool loop, float delay) { // Animation animation = data.skeletonData.FindAnimation(animationName); // if (animation == null) throw new ArgumentException("Animation not found: " + animationName, "animationName"); -// return AddAnimation(trackIndex, animation, loop, delay); +// return addAnimation(trackIndex, animation, loop, delay); // } // -// /// Adds an animation to be played delay seconds after the current or last queued animation -// /// for a track. If the track is empty, it is equivalent to calling . -// /// +// /// Adds an animation to be played delay seconds after the current or last queued animation +// /// for a track. If the track is empty, it is equivalent to calling setAnimation. +// /// @param delay // /// Seconds to begin this animation after the start of the previous animation. May be <= 0 to use the animation // /// duration of the previous track minus any mix duration plus the negative delay. -// /// -// /// A track entry to allow further customization of animation playback. References to the track entry must not be kept -// /// after -// public TrackEntry AddAnimation (int trackIndex, Animation animation, bool loop, float delay) { +// /// +// /// @return A track entry to allow further customization of animation playback. References to the track entry must not be kept +// /// after AnimationState.Dispose +// public TrackEntry addAnimation(int trackIndex, Animation animation, bool loop, float delay) { // if (animation == null) throw new ArgumentNullException("animation", "animation cannot be null."); // -// TrackEntry last = ExpandToIndex(trackIndex); +// TrackEntry last = expandToIndex(trackIndex); // if (last != null) { // while (last.next != null) // last = last.next; // } // -// TrackEntry entry = NewTrackEntry(trackIndex, animation, loop, last); +// TrackEntry entry = newTrackEntry(trackIndex, animation, loop, last); // // if (last == null) { -// SetCurrent(trackIndex, entry, true); -// queue.Drain(); +// setCurrent(trackIndex, entry, true); +// queue.drain(); // } else { // last.next = entry; // if (delay <= 0) { @@ -881,56 +887,56 @@ namespace Spine // return entry; // } // -// /// -// /// Sets an empty animation for a track, discarding any queued animations, and mixes to it over the specified mix duration. -// public TrackEntry SetEmptyAnimation (int trackIndex, float mixDuration) { -// TrackEntry entry = SetAnimation(trackIndex, AnimationState.EmptyAnimation, false); +// /// +// /// Sets an empty animation for a track, discarding any queued animations, and mixes to it over the specified mix duration. +// public TrackEntry setEmptyAnimation(int trackIndex, float mixDuration) { +// TrackEntry entry = setAnimation(trackIndex, AnimationState.EmptyAnimation, false); // entry.mixDuration = mixDuration; // entry.trackEnd = mixDuration; // return entry; // } // -// /// +// /// // /// Adds an empty animation to be played after the current or last queued animation for a track, and mixes to it over the -// /// specified mix duration. -// /// -// /// A track entry to allow further customization of animation playback. References to the track entry must not be kept after . -// /// -// /// Track number. -// /// Mix duration. -// /// Seconds to begin this animation after the start of the previous animation. May be <= 0 to use the animation -// /// duration of the previous track minus any mix duration plus the negative delay. -// public TrackEntry AddEmptyAnimation (int trackIndex, float mixDuration, float delay) { +// /// specified mix duration. +// /// @return +// /// A track entry to allow further customization of animation playback. References to the track entry must not be kept after AnimationState.Dispose. +// /// +// /// @param trackIndex Track number. +// /// @param mixDuration Mix duration. +// /// @param delay Seconds to begin this animation after the start of the previous animation. May be <= 0 to use the animation +// /// duration of the previous track minus any mix duration plus the negative delay. +// public TrackEntry addEmptyAnimation(int trackIndex, float mixDuration, float delay) { // if (delay <= 0) delay -= mixDuration; -// TrackEntry entry = AddAnimation(trackIndex, AnimationState.EmptyAnimation, false, delay); +// TrackEntry entry = addAnimation(trackIndex, AnimationState.EmptyAnimation, false, delay); // entry.mixDuration = mixDuration; // entry.trackEnd = mixDuration; // return entry; // } // -// /// -// /// Sets an empty animation for every track, discarding any queued animations, and mixes to it over the specified mix duration. -// public void SetEmptyAnimations (float mixDuration) { -// bool oldDrainDisabled = queue.drainDisabled; +// /// +// /// Sets an empty animation for every track, discarding any queued animations, and mixes to it over the specified mix duration. +// public void setEmptyAnimations(float mixDuration) { +// bool olddrainDisabled = queue.drainDisabled; // queue.drainDisabled = true; // for (int i = 0, n = tracks.Count; i < n; i++) { // TrackEntry current = tracks.Items[i]; -// if (current != null) SetEmptyAnimation(i, mixDuration); +// if (current != null) setEmptyAnimation(i, mixDuration); // } -// queue.drainDisabled = oldDrainDisabled; -// queue.Drain(); +// queue.drainDisabled = olddrainDisabled; +// queue.drain(); // } // -// private TrackEntry ExpandToIndex (int index) { +// private TrackEntry expandToIndex(int index) { // if (index < tracks.Count) return tracks.Items[index]; // while (index >= tracks.Count) // tracks.Add(null); // return null; // } // -// /// Object-pooling version of new TrackEntry. Obtain an unused TrackEntry from the pool and clear/initialize its values. -// /// May be null. -// private TrackEntry NewTrackEntry (int trackIndex, Animation animation, bool loop, TrackEntry last) { +// /// Object-pooling version of new TrackEntry. Obtain an unused TrackEntry from the pool and clear/initialize its values. +// /// @param last May be null. +// private TrackEntry newTrackEntry(int trackIndex, Animation animation, bool loop, TrackEntry last) { // TrackEntry entry = trackEntryPool.Obtain(); // Pooling // entry.trackIndex = trackIndex; // entry.animation = animation; @@ -959,8 +965,8 @@ namespace Spine // return entry; // } // -// /// Dispose all track entries queued after the given TrackEntry. -// private void DisposeNext (TrackEntry entry) { +// /// Dispose all track entries queued after the given TrackEntry. +// private void disposeNext(TrackEntry entry) { // TrackEntry next = entry.next; // while (next != null) { // queue.Dispose(next); @@ -969,42 +975,31 @@ namespace Spine // entry.next = null; // } // -// private void AnimationsChanged () { +// private void animationsChanged() { // animationsChanged = false; // // var propertyIDs = this.propertyIDs; -// propertyIDs.Clear(); +// propertyIDs.clear(); // var mixingTo = this.mixingTo; // // var tracksItems = tracks.Items; // for (int i = 0, n = tracks.Count; i < n; i++) { // var entry = tracksItems[i]; -// if (entry != null) entry.SetTimelineData(null, mixingTo, propertyIDs); +// if (entry != null) entry.setTimelineData(null, mixingTo, propertyIDs); // } // } // -// /// The track entry for the animation currently playing on the track, or null if no animation is currently playing. -// public TrackEntry GetCurrent (int trackIndex) { +// /// @return The track entry for the animation currently playing on the track, or null if no animation is currently playing. +// public TrackEntry getCurrent(int trackIndex) { // return (trackIndex >= tracks.Count) ? null : tracks.Items[trackIndex]; // } // -// override public string ToString () { -// var buffer = new System.Text.StringBuilder(); -// for (int i = 0, n = tracks.Count; i < n; i++) { -// TrackEntry entry = tracks.Items[i]; -// if (entry == null) continue; -// if (buffer.Length > 0) buffer.Append(", "); -// buffer.Append(entry.ToString()); -// } -// return buffer.Length == 0 ? "" : buffer.ToString(); -// } -// -// internal void OnStart (TrackEntry entry) { if (Start != null) Start(entry); } -// internal void OnInterrupt (TrackEntry entry) { if (Interrupt != null) Interrupt(entry); } -// internal void OnEnd (TrackEntry entry) { if (End != null) End(entry); } -// internal void OnDispose (TrackEntry entry) { if (Dispose != null) Dispose(entry); } -// internal void OnComplete (TrackEntry entry) { if (Complete != null) Complete(entry); } -// internal void OnEvent (TrackEntry entry, Event e) { if (Event != null) Event(entry, e); } +// internal void onStart(TrackEntry entry) { if (Start != null) Start(entry); } +// internal void onInterrupt(TrackEntry entry) { if (Interrupt != null) Interrupt(entry); } +// internal void onEnd(TrackEntry entry) { if (End != null) End(entry); } +// internal void onDispose(TrackEntry entry) { if (Dispose != null) Dispose(entry); } +// internal void onComplete(TrackEntry entry) { if (Complete != null) Complete(entry); } +// internal void onEvent(TrackEntry entry, Event e) { if (Event != null) Event(entry, e); } }; } diff --git a/spine-cpp/spine-cpp/include/spine/RegionAttachment.h b/spine-cpp/spine-cpp/include/spine/RegionAttachment.h index 5fd982652..3128fb8f6 100644 --- a/spine-cpp/spine-cpp/include/spine/RegionAttachment.h +++ b/spine-cpp/spine-cpp/include/spine/RegionAttachment.h @@ -124,7 +124,7 @@ namespace Spine static const int BRX; static const int BRY; - float _x, _y, _rotation, _scaleX = 1, _scaleY = 1, _width, _height; + float _x, _y, _rotation, _scaleX, _scaleY, _width, _height; float _regionOffsetX, _regionOffsetY, _regionWidth, _regionHeight, _regionOriginalWidth, _regionOriginalHeight; Vector _offset; Vector _uvs; diff --git a/spine-cpp/spine-cpp/src/spine/AnimationState.cpp b/spine-cpp/spine-cpp/src/spine/AnimationState.cpp index bb4d2ccfe..011f0b660 100644 --- a/spine-cpp/spine-cpp/src/spine/AnimationState.cpp +++ b/spine-cpp/spine-cpp/src/spine/AnimationState.cpp @@ -28,7 +28,99 @@ * POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ +#include + +#include + +#include + namespace Spine { - // TODO + TrackEntry::TrackEntry() + { + + } + + int TrackEntry::getTrackIndex() { return _trackIndex; } + + Animation* TrackEntry::getAnimation() { return _animation; } + + bool TrackEntry::getLoop() { return _loop; } + void TrackEntry::setLoop(bool inValue) { _loop = inValue; } + + float TrackEntry::getDelay() { return _delay; } + void TrackEntry::setDelay(float inValue) { _delay = inValue; } + + float TrackEntry::getTrackTime() { return _trackTime; } + void TrackEntry::setTrackTime(float inValue) { _trackTime = inValue; } + + float TrackEntry::getTrackEnd() { return _trackEnd; } + void TrackEntry::setTrackEnd(float inValue) { _trackEnd = inValue; } + + float TrackEntry::getAnimationStart() { return _animationStart; } + void TrackEntry::setAnimationStart(float inValue) { _animationStart = inValue; } + + float TrackEntry::getAnimationEnd() { return _animationEnd; } + void TrackEntry::setAnimationEnd(float inValue) { _animationEnd = inValue; } + + float TrackEntry::getAnimationLast() { return _animationLast; } + void TrackEntry::setAnimationLast(float inValue) + { + _animationLast = inValue; + _nextAnimationLast = inValue; + } + + float TrackEntry::getAnimationTime() + { + if (_loop) + { + float duration = _animationEnd - _animationStart; + if (duration == 0) + { + return _animationStart; + } + + return fmodf(_trackTime, duration) + _animationStart; + } + + return MIN(_trackTime + _animationStart, _animationEnd); + } + + float TrackEntry::getTimeScale() { return _timeScale; } + void TrackEntry::setTimeScale(float inValue) { _timeScale = inValue; } + + float TrackEntry::getAlpha() { return _alpha; } + void TrackEntry::setAlpha(float inValue) { _alpha = inValue; } + + float TrackEntry::getEventThreshold() { return _eventThreshold; } + void TrackEntry::setEventThreshold(float inValue) { _eventThreshold = inValue; } + + float TrackEntry::getAttachmentThreshold() { return _attachmentThreshold; } + void TrackEntry::setAttachmentThreshold(float inValue) { _attachmentThreshold = inValue; } + + float TrackEntry::getDrawOrderThreshold() { return _drawOrderThreshold; } + void TrackEntry::setDrawOrderThreshold(float inValue) { _drawOrderThreshold = inValue; } + + TrackEntry* TrackEntry::getNext() { return _next; } + + bool TrackEntry::isComplete() + { + return _trackTime >= _animationEnd - _animationStart; + } + + float TrackEntry::getMixTime() { return _mixTime; } + void TrackEntry::setMixTime(float inValue) { _mixTime = inValue; } + + float TrackEntry::getMixDuration() { return _mixDuration; } + void TrackEntry::setMixDuration(float inValue) { _mixDuration = inValue; } + + TrackEntry* TrackEntry::getMixingFrom() { return _mixingFrom; } + +// event AnimationState.TrackEntryDelegate Start, Interrupt, End, Dispose, Complete; +// event AnimationState.TrackEntryEventDelegate Event; + + void TrackEntry::resetRotationDirections() + { + _timelinesRotation.clear(); + } } diff --git a/spine-cpp/spine-cpp/src/spine/AnimationStateData.cpp b/spine-cpp/spine-cpp/src/spine/AnimationStateData.cpp index e1902824e..00dc79ced 100644 --- a/spine-cpp/spine-cpp/src/spine/AnimationStateData.cpp +++ b/spine-cpp/spine-cpp/src/spine/AnimationStateData.cpp @@ -35,7 +35,7 @@ namespace Spine { - AnimationStateData::AnimationStateData(SkeletonData& skeletonData) : _skeletonData(skeletonData) + AnimationStateData::AnimationStateData(SkeletonData& skeletonData) : _skeletonData(skeletonData), _defaultMix(0) { // Empty } diff --git a/spine-cpp/spine-cpp/src/spine/ClippingAttachment.cpp b/spine-cpp/spine-cpp/src/spine/ClippingAttachment.cpp index c87de561c..1f2f9dd2b 100644 --- a/spine-cpp/spine-cpp/src/spine/ClippingAttachment.cpp +++ b/spine-cpp/spine-cpp/src/spine/ClippingAttachment.cpp @@ -36,7 +36,7 @@ namespace Spine { RTTI_IMPL(ClippingAttachment, VertexAttachment); - ClippingAttachment::ClippingAttachment(std::string name) : VertexAttachment(name) + ClippingAttachment::ClippingAttachment(std::string name) : VertexAttachment(name), _endSlot(NULL) { // Empty } diff --git a/spine-cpp/spine-cpp/src/spine/PathAttachment.cpp b/spine-cpp/spine-cpp/src/spine/PathAttachment.cpp index 54bd9337b..28a06940b 100644 --- a/spine-cpp/spine-cpp/src/spine/PathAttachment.cpp +++ b/spine-cpp/spine-cpp/src/spine/PathAttachment.cpp @@ -34,7 +34,7 @@ namespace Spine { RTTI_IMPL(PathAttachment, VertexAttachment); - PathAttachment::PathAttachment(std::string name) : VertexAttachment(name) + PathAttachment::PathAttachment(std::string name) : VertexAttachment(name), _closed(false), _constantSpeed(false) { // Empty } diff --git a/spine-cpp/spine-cpp/src/spine/PointAttachment.cpp b/spine-cpp/spine-cpp/src/spine/PointAttachment.cpp index d309c8d48..693eb837c 100644 --- a/spine-cpp/spine-cpp/src/spine/PointAttachment.cpp +++ b/spine-cpp/spine-cpp/src/spine/PointAttachment.cpp @@ -38,7 +38,7 @@ namespace Spine { RTTI_IMPL(PointAttachment, Attachment); - PointAttachment::PointAttachment(std::string name) : Attachment(name) + PointAttachment::PointAttachment(std::string name) : Attachment(name), _x(0), _y(0), _rotation(0) { // Empty } diff --git a/spine-cpp/spine-cpp/src/spine/RegionAttachment.cpp b/spine-cpp/spine-cpp/src/spine/RegionAttachment.cpp index 310a4619b..de50ce6c4 100644 --- a/spine-cpp/spine-cpp/src/spine/RegionAttachment.cpp +++ b/spine-cpp/spine-cpp/src/spine/RegionAttachment.cpp @@ -49,7 +49,30 @@ namespace Spine const int RegionAttachment::BRX = 6; const int RegionAttachment::BRY = 7; - RegionAttachment::RegionAttachment(std::string name) : Attachment(name) + RegionAttachment::RegionAttachment(std::string name) : Attachment(name), + _x(0), + _y(0), + _rotation(0), + _scaleX(1), + _scaleY(1), + _width(0), + _height(0), + _regionOffsetX(0), + _regionOffsetY(0), + _regionWidth(0), + _regionHeight(0), + _regionOriginalWidth(0), + _regionOriginalHeight(0), + _rendererObject(NULL), + _path(), + _regionU(0), + _regionV(0), + _regionU2(0), + _regionV2(0), + _r(0), + _g(0), + _b(0), + _a(0) { _offset.reserve(NUM_UVS); _uvs.reserve(NUM_UVS); diff --git a/spine-cpp/spine-cpp/src/spine/SkeletonClipping.cpp b/spine-cpp/spine-cpp/src/spine/SkeletonClipping.cpp index 3ca3d9dbd..6a9f516a3 100644 --- a/spine-cpp/spine-cpp/src/spine/SkeletonClipping.cpp +++ b/spine-cpp/spine-cpp/src/spine/SkeletonClipping.cpp @@ -35,7 +35,7 @@ namespace Spine { - SkeletonClipping::SkeletonClipping() + SkeletonClipping::SkeletonClipping() : _clipAttachment(NULL) { _clipOutput.reserve(128); _clippedVertices.reserve(128); diff --git a/spine-cpp/spine-cpp/src/spine/TwoColorTimeline.cpp b/spine-cpp/spine-cpp/src/spine/TwoColorTimeline.cpp index 9003487b4..0232711c3 100644 --- a/spine-cpp/spine-cpp/src/spine/TwoColorTimeline.cpp +++ b/spine-cpp/spine-cpp/src/spine/TwoColorTimeline.cpp @@ -59,7 +59,7 @@ namespace Spine const int TwoColorTimeline::G2 = 6; const int TwoColorTimeline::B2 = 7; - TwoColorTimeline::TwoColorTimeline(int frameCount) : CurveTimeline(frameCount) + TwoColorTimeline::TwoColorTimeline(int frameCount) : CurveTimeline(frameCount), _slotIndex(0) { _frames.reserve(frameCount * ENTRIES); }