[[Animation fixes]]
- update the anim before rendering it (but continue to avoid skipping frames) This fix a off-by-one frame bug in few cases where the update is not automatic (e.g. last frame of idle anim was sometimes missed) - now a starting anim is considered as a change and so in need_update state - fix some inconsitencies with the use of update_last_draw_time()
This commit is contained in:
parent
24935ba641
commit
1181a44579
4 changed files with 13 additions and 5 deletions
|
@ -104,6 +104,7 @@ private:
|
|||
|
||||
bool does_not_change_; // Optimization for 1-frame permanent animations
|
||||
bool started_;
|
||||
bool need_first_update_;
|
||||
std::vector<frame> frames_;
|
||||
|
||||
// These are only valid when anim is started
|
||||
|
|
|
@ -47,6 +47,7 @@ animated<T,T_void_value>::animated(int start_time) :
|
|||
starting_frame_time_(start_time),
|
||||
does_not_change_(true),
|
||||
started_(false),
|
||||
need_first_update_(false),
|
||||
start_tick_(0),
|
||||
cycles_(false),
|
||||
acceleration_(1),
|
||||
|
@ -61,6 +62,7 @@ animated<T,T_void_value>::animated(const std::vector<std::pair<int,T> > &cfg, in
|
|||
starting_frame_time_(start_time),
|
||||
does_not_change_(true),
|
||||
started_(false),
|
||||
need_first_update_(false),
|
||||
start_tick_(0),
|
||||
cycles_(false),
|
||||
acceleration_(1),
|
||||
|
@ -102,7 +104,8 @@ void animated<T,T_void_value>::start_animation(int start_time, bool cycles, doub
|
|||
acceleration_ = acceleration;
|
||||
if(acceleration_ <=0) acceleration_ = 1;
|
||||
current_frame_key_= 0;
|
||||
update_last_draw_time();
|
||||
need_first_update_ = !frames_.empty();
|
||||
//update_last_draw_time();
|
||||
// need to force last frame key in the case of starting anim...
|
||||
last_frame_key_ = -1;
|
||||
}
|
||||
|
@ -113,6 +116,10 @@ void animated<T,T_void_value>::update_last_draw_time()
|
|||
{
|
||||
last_update_tick_ = current_ticks;
|
||||
last_frame_key_ = current_frame_key_;
|
||||
if (need_first_update_) {
|
||||
need_first_update_ = false;
|
||||
return;
|
||||
}
|
||||
if(does_not_change_)
|
||||
return;
|
||||
|
||||
|
@ -141,6 +148,9 @@ void animated<T,T_void_value>::update_last_draw_time()
|
|||
template<typename T, typename T_void_value>
|
||||
bool animated<T,T_void_value>::need_update() const
|
||||
{
|
||||
if(need_first_update_) {
|
||||
return true;
|
||||
}
|
||||
if(does_not_change_) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -107,9 +107,6 @@ effect::effect(int xpos, int ypos, const animated<std::string>::anim_description
|
|||
|
||||
images_.start_animation(0,infinite);
|
||||
|
||||
if(!images_.animation_finished()) {
|
||||
images_.update_last_draw_time();
|
||||
}
|
||||
}
|
||||
|
||||
void effect::set_location(int x, int y)
|
||||
|
|
|
@ -1681,6 +1681,7 @@ void unit::redraw_unit(game_display& disp, const gamemap::location& loc)
|
|||
if(!anim_) {
|
||||
set_standing(disp,loc);
|
||||
}
|
||||
anim_->update_last_draw_time();
|
||||
|
||||
if(frame_begin_time_ != anim_->get_current_frame_begin_time()) {
|
||||
frame_begin_time_ = anim_->get_current_frame_begin_time();
|
||||
|
@ -1877,7 +1878,6 @@ void unit::redraw_unit(game_display& disp, const gamemap::location& loc)
|
|||
|
||||
anim_->redraw();
|
||||
refreshing_ = false;
|
||||
anim_->update_last_draw_time();
|
||||
}
|
||||
|
||||
void unit::clear_haloes()
|
||||
|
|
Loading…
Add table
Reference in a new issue