mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-10 03:40:25 +00:00
d8ef15acc2
Both the animation components/tracks and the chores itself keep track of the current time independently: animation component: - AnimationStateEmi::_time - initialized with 0 - after the first update() call, _time is advanced by the frametime chores: - Costume::_currTime - initialized with -1 - during the first update() call, _currTime is set first to 0 - during the next update() call, _currTime is advanced by the frametime EMICostume::update() updates first the chore and then all components with the same frame time. This has the effect, that the internal time base of the chore and the animation has always an initial offset (the value of the frametime of the first update() call). For some costumes, the chore will pause the animation by setting the according key for that animation at the end of the animation. However, since the animation component has a different time base, it has already reached that point and may have already disabled itself entirely (instead of just being paused by the chore). This bug fix let the animation set _time to 0 in the first update() call, too. Any consecutive update() call will advance the time by the frametime. This will keep the two time bases of the chore and the animation component in sync.
113 lines
2.7 KiB
C++
113 lines
2.7 KiB
C++
/* ResidualVM - A 3D game interpreter
|
|
*
|
|
* ResidualVM is the legal property of its developers, whose names
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
* file distributed with this source distribution.
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License
|
|
* as published by the Free Software Foundation; either version 2
|
|
* of the License, or (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
*
|
|
*/
|
|
|
|
#ifndef GRIM_ANIMATIONEMI_H
|
|
#define GRIM_ANIMATIONEMI_H
|
|
|
|
#include "common/str.h"
|
|
#include "math/mathfwd.h"
|
|
#include "math/quat.h"
|
|
#include "engines/grim/animation.h"
|
|
#include "engines/grim/object.h"
|
|
#include "engines/grim/emi/skeleton.h"
|
|
|
|
namespace Grim {
|
|
|
|
struct AnimRotation {
|
|
Math::Quaternion _quat;
|
|
float _time;
|
|
};
|
|
|
|
struct AnimTranslation {
|
|
Math::Vector3d _vec;
|
|
float _time;
|
|
};
|
|
|
|
struct Bone {
|
|
Common::String _boneName;
|
|
int _operation;
|
|
int _priority;
|
|
int _c;
|
|
int _count;
|
|
AnimRotation *_rotations;
|
|
AnimTranslation *_translations;
|
|
Joint *_target;
|
|
Bone() : _rotations(NULL), _translations(NULL), _boneName(""), _operation(0), _target(NULL) {}
|
|
~Bone();
|
|
void loadBinary(Common::SeekableReadStream *data);
|
|
};
|
|
|
|
class AnimationEmi : public Object {
|
|
void loadAnimation(Common::SeekableReadStream *data);
|
|
public:
|
|
Common::String _name;
|
|
Common::String _fname;
|
|
float _duration;
|
|
int _numBones;
|
|
Bone *_bones;
|
|
AnimationEmi(const Common::String &filename, Common::SeekableReadStream *data);
|
|
~AnimationEmi();
|
|
|
|
const Common::String &getFilename() const { return _fname; }
|
|
};
|
|
|
|
class AnimationStateEmi {
|
|
public:
|
|
AnimationStateEmi(const Common::String &anim);
|
|
~AnimationStateEmi();
|
|
|
|
void update(uint time);
|
|
void computeWeights();
|
|
void animate();
|
|
void play();
|
|
void stop();
|
|
void setPaused(bool paused);
|
|
void setLooping(bool loop);
|
|
void setSkeleton(Skeleton *skel);
|
|
void fade(Animation::FadeMode mode, int fadeLength);
|
|
void advance(uint msecs);
|
|
void saveState(SaveGame *state);
|
|
void restoreState(SaveGame *state);
|
|
|
|
private:
|
|
void activate();
|
|
void deactivate();
|
|
|
|
friend class Skeleton;
|
|
|
|
Skeleton *_skel;
|
|
ObjectPtr<AnimationEmi> _anim;
|
|
bool _looping;
|
|
bool _active;
|
|
bool _paused;
|
|
int _time;
|
|
float _fade;
|
|
float _startFade;
|
|
Animation::FadeMode _fadeMode;
|
|
int _fadeLength;
|
|
int *_boneJoints;
|
|
};
|
|
|
|
} // end of namespace Grim
|
|
|
|
#endif
|