some animation optimisations, some more work to do, but...
...that should be quite helpfull already
This commit is contained in:
parent
38aa1e661e
commit
9bdf079ac8
3 changed files with 20 additions and 9 deletions
|
@ -265,7 +265,11 @@ void game_display::pre_draw() {
|
|||
previous_invalidated_.swap(invalidated_);
|
||||
invalidated_.insert(previous_invalidated_.begin(),previous_invalidated_.end());
|
||||
// call invalidate_animation again to deal with new conflict arising from the merge
|
||||
invalidate_animations();
|
||||
// no conflict, if a hex was invalidated last turn but not this turn, then
|
||||
// * case of no unit in neighbour hex=> no propagation
|
||||
// * case of unit in hex but was there last turn=>its hexes are invalidated too
|
||||
// * case of unit inhex not there last turn => it moved, so was invalidated previously
|
||||
// invalidate_animations();
|
||||
process_reachmap_changes();
|
||||
/**
|
||||
* @todo FIXME: must modify changed, but best to do it at the
|
||||
|
|
|
@ -632,7 +632,8 @@ unit_animation::particule::particule(
|
|||
accelerate(true),
|
||||
parameters_(cfg,frame_string),
|
||||
halo_id_(0),
|
||||
last_frame_begin_time_(0)
|
||||
last_frame_begin_time_(0),
|
||||
invalidated_(false)
|
||||
{
|
||||
config::const_child_itors range = cfg.child_range(frame_string+"frame");
|
||||
config::const_child_iterator itor;
|
||||
|
@ -767,11 +768,11 @@ void unit_animation::redraw(const frame_parameters& value)
|
|||
anim_itor->second.redraw( value,src_,dst_);
|
||||
}
|
||||
}
|
||||
bool unit_animation::invalidate(const frame_parameters& value) const
|
||||
bool unit_animation::invalidate(const frame_parameters& value)
|
||||
{
|
||||
|
||||
bool result = false;
|
||||
std::map<std::string,particule>::const_iterator anim_itor =sub_anims_.begin();
|
||||
std::map<std::string,particule>::iterator anim_itor =sub_anims_.begin();
|
||||
result |= unit_anim_.invalidate(value,src_,dst_,true);
|
||||
for( /*null*/; anim_itor != sub_anims_.end() ; anim_itor++) {
|
||||
result |= anim_itor->second.invalidate(value,src_,dst_);
|
||||
|
@ -780,6 +781,7 @@ bool unit_animation::invalidate(const frame_parameters& value) const
|
|||
}
|
||||
void unit_animation::particule::redraw(const frame_parameters& value,const map_location &src, const map_location &dst, const bool primary)
|
||||
{
|
||||
invalidated_=false;
|
||||
const unit_frame& current_frame= get_current_frame();
|
||||
const frame_parameters default_val = parameters_.parameters(get_animation_time() -get_begin_time());
|
||||
if(get_current_frame_begin_time() != last_frame_begin_time_ ) {
|
||||
|
@ -789,11 +791,13 @@ void unit_animation::particule::redraw(const frame_parameters& value,const map_l
|
|||
current_frame.redraw(get_current_frame_time(),false,src,dst,&halo_id_,default_val,value,primary);
|
||||
}
|
||||
}
|
||||
bool unit_animation::particule::invalidate(const frame_parameters& value,const map_location &src, const map_location &dst, const bool primary ) const
|
||||
bool unit_animation::particule::invalidate(const frame_parameters& value,const map_location &src, const map_location &dst, const bool primary )
|
||||
{
|
||||
if(invalidated_) return false;
|
||||
const unit_frame& current_frame= get_current_frame();
|
||||
const frame_parameters default_val = parameters_.parameters(get_animation_time() -get_begin_time());
|
||||
return current_frame.invalidate(need_update(),get_current_frame_time(),src,dst,default_val,value,primary);
|
||||
invalidated_ = current_frame.invalidate(need_update(),get_current_frame_time(),src,dst,default_val,value,primary);
|
||||
return invalidated_;
|
||||
}
|
||||
|
||||
unit_animation::particule::~particule()
|
||||
|
|
|
@ -59,7 +59,7 @@ class unit_animation
|
|||
void restart_animation();
|
||||
int get_current_frame_begin_time() const{ return unit_anim_.get_current_frame_begin_time() ; };
|
||||
void redraw(const frame_parameters& value);
|
||||
bool invalidate(const frame_parameters& value ) const;
|
||||
bool invalidate(const frame_parameters& value );
|
||||
|
||||
friend class unit;
|
||||
protected:
|
||||
|
@ -77,14 +77,15 @@ class unit_animation
|
|||
accelerate(true),
|
||||
parameters_(),
|
||||
halo_id_(0),
|
||||
last_frame_begin_time_(0)
|
||||
last_frame_begin_time_(0),
|
||||
invalidated_(false)
|
||||
{};
|
||||
explicit particule(const config& cfg,const std::string frame_string ="frame");
|
||||
virtual ~particule();
|
||||
bool need_update() const;
|
||||
void override(int start_time,const std::string highlight="", const std::string blend_ratio ="",Uint32 blend_color = 0,const std::string offset="");
|
||||
void redraw( const frame_parameters& value,const map_location &src, const map_location &dst, const bool primary=false);
|
||||
bool invalidate(const frame_parameters& value,const map_location &src, const map_location &dst, const bool primary = false) const;
|
||||
bool invalidate(const frame_parameters& value,const map_location &src, const map_location &dst, const bool primary = false);
|
||||
void start_animation(int start_time, bool cycles=false);
|
||||
const frame_parameters parameters(const frame_parameters & default_val,bool primary) const { return get_current_frame().merge_parameters(get_current_frame_time(),parameters_.parameters(get_animation_time()-get_begin_time()),default_val,primary); };
|
||||
bool accelerate;
|
||||
|
@ -94,6 +95,8 @@ class unit_animation
|
|||
frame_builder parameters_;
|
||||
int halo_id_;
|
||||
int last_frame_begin_time_;
|
||||
// optimisation
|
||||
bool invalidated_;
|
||||
|
||||
};
|
||||
t_translation::t_list terrain_types_;
|
||||
|
|
Loading…
Add table
Reference in a new issue