Fix loading animation events

This commit is contained in:
Vsevolod Kremianskii 2021-05-04 21:07:20 +07:00
parent 7814b61ec7
commit 7a77cabf4c
2 changed files with 3 additions and 1 deletions

View file

@ -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; });
}

View file

@ -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);
}
}