[cpp] Added TrackEntry::getAnimationState(), wired up when TrackEntry is obtained from pool in AnimatinState::newTrackEntry

This commit is contained in:
Mario Zechner 2025-07-29 23:15:38 +02:00
parent 0e5de94529
commit fe5e25c3a0
2 changed files with 12 additions and 1 deletions

View File

@ -326,6 +326,15 @@ namespace spine {
return _next != NULL && _nextTrackLast - _next->_delay >= 0;
}
// The AnimationState this track entry belongs to. May be NULL if TrackEntry is directly instantiated.
AnimationState *getAnimationState() {
return _state;
}
void setAnimationState(AnimationState *state) {
_state = state;
}
private:
Animation *_animation;
TrackEntry *_previous;
@ -345,6 +354,7 @@ namespace spine {
Array<float> _timelinesRotation;
AnimationStateListener _listener;
AnimationStateListenerObject *_listenerObject;
AnimationState *_state;
void reset();
};

View File

@ -58,7 +58,7 @@ TrackEntry::TrackEntry()
_reverse(false), _shortestRotation(false), _eventThreshold(0), _mixAttachmentThreshold(0), _alphaAttachmentThreshold(0),
_mixDrawOrderThreshold(0), _animationStart(0), _animationEnd(0), _animationLast(0), _nextAnimationLast(0), _delay(0), _trackTime(0),
_trackLast(0), _nextTrackLast(0), _trackEnd(0), _timeScale(1.0f), _alpha(0), _mixTime(0), _mixDuration(0), _interruptAlpha(0), _totalAlpha(0),
_mixBlend(MixBlend_Replace), _listener(dummyOnAnimationEventFunc), _listenerObject(NULL) {
_mixBlend(MixBlend_Replace), _listener(dummyOnAnimationEventFunc), _listenerObject(NULL), _state(NULL) {
}
TrackEntry::~TrackEntry() {
@ -1074,6 +1074,7 @@ TrackEntry *AnimationState::expandToIndex(size_t index) {
TrackEntry *AnimationState::newTrackEntry(size_t trackIndex, Animation *animation, bool loop, TrackEntry *last) {
TrackEntry *entryP = _trackEntryPool.obtain();// Pooling
TrackEntry &entry = *entryP;
entry.setAnimationState(this);
entry._trackIndex = (int) trackIndex;
entry._animation = animation;