Fix loading animation events
This commit is contained in:
parent
7814b61ec7
commit
7a77cabf4c
2 changed files with 3 additions and 1 deletions
|
@ -1207,10 +1207,12 @@ unique_ptr<Animation> MdlReader::readAnimation(uint32_t offset) {
|
|||
|
||||
vector<Animation::Event> events;
|
||||
if (eventArrayDef.count > 0) {
|
||||
seek(kMdlDataOffset + eventArrayDef.offset);
|
||||
for (uint32_t i = 0; i < eventArrayDef.count; ++i) {
|
||||
Animation::Event event;
|
||||
event.time = readFloat();
|
||||
event.name = boost::to_lower_copy(readCString(32));
|
||||
events.push_back(move(event));
|
||||
}
|
||||
sort(events.begin(), events.end(), [](auto &left, auto &right) { return left.time < right.time; });
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@ void AnimationChannel::update(float dt, bool visible) {
|
|||
|
||||
// Signal animation events between the previous time and the current time
|
||||
for (auto &event : _animation->events()) {
|
||||
if (_time < event.time && event.time <= newTime) {
|
||||
if (event.time > _time && event.time <= newTime) {
|
||||
_sceneNode->signalEvent(event.name);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue