mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
[cpp] 4.3 porting WIP
This commit is contained in:
parent
0699f41696
commit
3240d50748
@ -33,6 +33,7 @@
|
|||||||
#include <spine/Timeline.h>
|
#include <spine/Timeline.h>
|
||||||
|
|
||||||
namespace spine {
|
namespace spine {
|
||||||
|
/// Fires an Event when specific animation times are reached.
|
||||||
class SP_API EventTimeline : public Timeline {
|
class SP_API EventTimeline : public Timeline {
|
||||||
friend class SkeletonBinary;
|
friend class SkeletonBinary;
|
||||||
|
|
||||||
@ -45,15 +46,20 @@ namespace spine {
|
|||||||
|
|
||||||
~EventTimeline();
|
~EventTimeline();
|
||||||
|
|
||||||
|
/// Fires events for frames > lastTime and <= time.
|
||||||
virtual void
|
virtual void
|
||||||
apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha, MixBlend blend,
|
apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha, MixBlend blend,
|
||||||
MixDirection direction);
|
MixDirection direction, bool appliedPose);
|
||||||
|
|
||||||
/// Sets the time and value of the specified keyframe.
|
size_t getFrameCount();
|
||||||
void setFrame(size_t frame, Event *event);
|
|
||||||
|
|
||||||
|
/// The event for each frame.
|
||||||
Vector<Event *> &getEvents();
|
Vector<Event *> &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:
|
private:
|
||||||
Vector<Event *> _events;
|
Vector<Event *> _events;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -56,7 +56,7 @@ EventTimeline::~EventTimeline() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void EventTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha,
|
void EventTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha,
|
||||||
MixBlend blend, MixDirection direction) {
|
MixBlend blend, MixDirection direction, bool appliedPose) {
|
||||||
if (pEvents == NULL) return;
|
if (pEvents == NULL) return;
|
||||||
|
|
||||||
Vector<Event *> &events = *pEvents;
|
Vector<Event *> &events = *pEvents;
|
||||||
@ -64,15 +64,15 @@ void EventTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector
|
|||||||
size_t frameCount = _frames.size();
|
size_t frameCount = _frames.size();
|
||||||
|
|
||||||
if (lastTime > time) {
|
if (lastTime > time) {
|
||||||
// Fire events after last time for looped animations.
|
// Apply after lastTime for looped animations.
|
||||||
apply(skeleton, lastTime, FLT_MAX, pEvents, alpha, blend, direction);
|
apply(skeleton, lastTime, FLT_MAX, pEvents, alpha, blend, direction, appliedPose);
|
||||||
lastTime = -1.0f;
|
lastTime = -1.0f;
|
||||||
} else if (lastTime >= _frames[frameCount - 1]) {
|
} else if (lastTime >= _frames[frameCount - 1]) {
|
||||||
// Last time is after last i.
|
// Last time is after last frame.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (time < _frames[0]) return;// Time is before first i.
|
if (time < _frames[0]) return; // Time is before first frame.
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
if (lastTime < _frames[0]) {
|
if (lastTime < _frames[0]) {
|
||||||
@ -81,7 +81,7 @@ void EventTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector
|
|||||||
i = Animation::search(_frames, lastTime) + 1;
|
i = Animation::search(_frames, lastTime) + 1;
|
||||||
float frameTime = _frames[i];
|
float frameTime = _frames[i];
|
||||||
while (i > 0) {
|
while (i > 0) {
|
||||||
// Fire multiple events with the same i.
|
// Fire multiple events with the same frame.
|
||||||
if (_frames[i - 1] != frameTime) break;
|
if (_frames[i - 1] != frameTime) break;
|
||||||
i--;
|
i--;
|
||||||
}
|
}
|
||||||
@ -96,4 +96,10 @@ void EventTimeline::setFrame(size_t frame, Event *event) {
|
|||||||
_events[frame] = event;
|
_events[frame] = event;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector<Event *> &EventTimeline::getEvents() { return _events; }
|
size_t EventTimeline::getFrameCount() {
|
||||||
|
return _frames.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector<Event *> &EventTimeline::getEvents() {
|
||||||
|
return _events;
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user