From 7a77cabf4c2b73e29a2a595f24c0b6927d8cfc4d Mon Sep 17 00:00:00 2001 From: Vsevolod Kremianskii Date: Tue, 4 May 2021 21:07:20 +0700 Subject: [PATCH] Fix loading animation events --- src/render/model/mdlreader.cpp | 2 ++ src/scene/animation/channel.cpp | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/render/model/mdlreader.cpp b/src/render/model/mdlreader.cpp index 02013b98..64cc0cab 100644 --- a/src/render/model/mdlreader.cpp +++ b/src/render/model/mdlreader.cpp @@ -1207,10 +1207,12 @@ unique_ptr MdlReader::readAnimation(uint32_t offset) { vector 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; }); } diff --git a/src/scene/animation/channel.cpp b/src/scene/animation/channel.cpp index fdb83192..4d757e9d 100644 --- a/src/scene/animation/channel.cpp +++ b/src/scene/animation/channel.cpp @@ -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); } }