From 3240d50748bee27d4c2dfa0f97562b7a1a81df5d Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Wed, 11 Jun 2025 17:43:51 +0200 Subject: [PATCH] [cpp] 4.3 porting WIP --- .../spine-cpp/include/spine/EventTimeline.h | 12 ++++++++--- .../spine-cpp/src/spine/EventTimeline.cpp | 20 ++++++++++++------- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/spine-cpp/spine-cpp/include/spine/EventTimeline.h b/spine-cpp/spine-cpp/include/spine/EventTimeline.h index bd05a49dd..eb2459f54 100644 --- a/spine-cpp/spine-cpp/include/spine/EventTimeline.h +++ b/spine-cpp/spine-cpp/include/spine/EventTimeline.h @@ -33,6 +33,7 @@ #include namespace spine { + /// Fires an Event when specific animation times are reached. class SP_API EventTimeline : public Timeline { friend class SkeletonBinary; @@ -45,15 +46,20 @@ namespace spine { ~EventTimeline(); + /// Fires events for frames > lastTime and <= time. virtual void apply(Skeleton &skeleton, float lastTime, float time, Vector *pEvents, float alpha, MixBlend blend, - MixDirection direction); + MixDirection direction, bool appliedPose); - /// Sets the time and value of the specified keyframe. - void setFrame(size_t frame, Event *event); + size_t getFrameCount(); + /// The event for each frame. Vector &getEvents(); + /// Sets the time and event for the specified frame. + /// @param frame Between 0 and frameCount, inclusive. + void setFrame(size_t frame, Event *event); + private: Vector _events; }; diff --git a/spine-cpp/spine-cpp/src/spine/EventTimeline.cpp b/spine-cpp/spine-cpp/src/spine/EventTimeline.cpp index aa5986f3b..e2861a45f 100644 --- a/spine-cpp/spine-cpp/src/spine/EventTimeline.cpp +++ b/spine-cpp/spine-cpp/src/spine/EventTimeline.cpp @@ -56,7 +56,7 @@ EventTimeline::~EventTimeline() { } void EventTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector *pEvents, float alpha, - MixBlend blend, MixDirection direction) { + MixBlend blend, MixDirection direction, bool appliedPose) { if (pEvents == NULL) return; Vector &events = *pEvents; @@ -64,15 +64,15 @@ void EventTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector size_t frameCount = _frames.size(); if (lastTime > time) { - // Fire events after last time for looped animations. - apply(skeleton, lastTime, FLT_MAX, pEvents, alpha, blend, direction); + // Apply after lastTime for looped animations. + apply(skeleton, lastTime, FLT_MAX, pEvents, alpha, blend, direction, appliedPose); lastTime = -1.0f; } else if (lastTime >= _frames[frameCount - 1]) { - // Last time is after last i. + // Last time is after last frame. return; } - if (time < _frames[0]) return;// Time is before first i. + if (time < _frames[0]) return; // Time is before first frame. int i; if (lastTime < _frames[0]) { @@ -81,7 +81,7 @@ void EventTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector i = Animation::search(_frames, lastTime) + 1; float frameTime = _frames[i]; while (i > 0) { - // Fire multiple events with the same i. + // Fire multiple events with the same frame. if (_frames[i - 1] != frameTime) break; i--; } @@ -96,4 +96,10 @@ void EventTimeline::setFrame(size_t frame, Event *event) { _events[frame] = event; } -Vector &EventTimeline::getEvents() { return _events; } +size_t EventTimeline::getFrameCount() { + return _frames.size(); +} + +Vector &EventTimeline::getEvents() { + return _events; +}