Removed animation invalidation code

This no longer actually does anything now that location invalidation is removed. If you follow the code
animation_component::invalidate called unit_animation::invalidate which was responsible for generating
the overlaped_hex_ set. Previously, this is what locations were invalidated. Now it didn't do anything.
This commit is contained in:
Charles Dang 2017-07-05 22:13:07 +11:00
parent c5be598cd0
commit 9850e47720
7 changed files with 2 additions and 115 deletions

View file

@ -516,9 +516,6 @@ namespace { // Private helpers for move_unit()
move_it_->set_movement(moves_left_.front(), true);
moves_left_.pop_front();
// Invalidate before moving so we invalidate neighbor hexes if needed.
move_it_->anim_comp().invalidate(disp);
// Attempt actually moving. Fails if *step_to is occupied.
unit_map::unit_iterator unit_it;
bool success = false;

View file

@ -2436,26 +2436,6 @@ void display::invalidate_animations()
open_mp_list[i]->anim_comp().refresh();
}
#endif
bool new_inval;
do {
new_inval = false;
#ifndef _OPENMP
for(const unit& u : dc_->units()) {
new_inval |= u.anim_comp().invalidate(*this);
}
for(const unit* u : *fake_unit_man_) {
new_inval |= u->anim_comp().invalidate(*this);
}
#else
#pragma omp parallel for reduction(| : new_inval) shared(open_mp_list)
for(int i = 0; i < omp_iterations; i++) {
new_inval |= open_mp_list[i]->anim_comp().invalidate(*this);
}
#endif
} while(new_inval);
}
void display::reset_standing_animations()

View file

@ -268,9 +268,7 @@ unit_animation::unit_animation(int start_time,
, unit_anim_(start_time,builder)
, src_()
, dst_()
, invalidated_(false)
, play_offscreen_(true)
, overlaped_hex_()
{
add_frame(frame.duration(),frame,!frame.does_not_change());
}
@ -292,9 +290,7 @@ unit_animation::unit_animation(const config& cfg,const std::string& frame_string
, unit_anim_(cfg,frame_string)
, src_()
, dst_()
, invalidated_(false)
, play_offscreen_(true)
, overlaped_hex_()
{
//if(!cfg["debug"].empty()) printf("DEBUG WML: FINAL\n%s\n\n",cfg.debug().c_str());
@ -1082,9 +1078,6 @@ void unit_animation::restart_animation()
void unit_animation::redraw(frame_parameters& value, halo::manager& halo_man)
{
invalidated_ = false;
overlaped_hex_.clear();
value.primary_frame = true;
unit_anim_.redraw(value,src_,dst_, halo_man);
@ -1103,48 +1096,6 @@ void unit_animation::clear_haloes()
}
}
// TODO: see if this function can be removed!
bool unit_animation::invalidate(frame_parameters& value)
{
if(invalidated_) return false;
display* disp = display::get_singleton();
const bool complete_redraw = disp->tile_nearly_on_screen(src_) || disp->tile_nearly_on_screen(dst_);
if(overlaped_hex_.empty()) {
if(complete_redraw) {
value.primary_frame = true;
overlaped_hex_ = unit_anim_.get_overlaped_hex(value, src_, dst_);
value.primary_frame = false;
for(auto& anim : sub_anims_) {
std::set<map_location> tmp = anim.second.get_overlaped_hex(value, src_, dst_);
overlaped_hex_.insert(tmp.begin(), tmp.end());
}
} else {
// Offscreen animations only invalidate their own hex, no propagation,
// but we still need this to play sounds
overlaped_hex_.insert(src_);
}
}
if(complete_redraw) {
if( need_update()) {
invalidated_ = true;
return true;
} else {
return invalidated_;
}
} else {
if(need_minimal_update()) {
invalidated_ = true;
return true;
} else {
return false;
}
}
}
std::string unit_animation::debug() const
{
std::ostringstream outstream;

View file

@ -104,7 +104,7 @@ public:
}
void redraw(frame_parameters& value, halo::manager& halo_man);
void clear_haloes();
bool invalidate(frame_parameters& value );
std::string debug() const;
friend std::ostream& operator << (std::ostream& outstream, const unit_animation& u_animation);
@ -187,9 +187,7 @@ private:
map_location src_;
map_location dst_;
// optimization
bool invalidated_;
bool play_offscreen_;
std::set<map_location> overlaped_hex_;
};
class unit_animator

View file

@ -156,34 +156,6 @@ void unit_animation_component::clear_haloes ()
if(anim_ ) anim_->clear_haloes();
}
bool unit_animation_component::invalidate (const display & disp)
{
bool result = false;
// Very early calls, anim not initialized yet
if(get_animation()) {
frame_parameters params;
const gamemap & map = disp.get_map();
const t_translation::terrain_code terrain = map.get_terrain(u_.loc_);
const terrain_type& terrain_info = map.get_terrain_info(terrain);
int height_adjust = static_cast<int>(terrain_info.unit_height_adjust() * disp.get_zoom_factor());
if (u_.is_flying() && height_adjust < 0) {
height_adjust = 0;
}
params.y -= height_adjust;
params.halo_y -= height_adjust;
params.image_mod = u_.image_mods();
params.halo_mod = u_.TC_image_mods();
params.image= u_.default_anim_image();
result |= get_animation()->invalidate(params);
}
return result;
}
void unit_animation_component::reset_after_advance(const unit_type * newtype)
{
if (newtype) {

View file

@ -86,9 +86,6 @@ public:
bool with_bars, const std::string &text = "",
color_t text_color = {}, STATE state = STATE_ANIM);
/** Invalidates an animation with respect to a display object, preparing it for redraw. */
bool invalidate(const display & disp);
/** Intermittently activates the idling animations in place of the standing animations. Used by display object. */
void refresh();

View file

@ -731,7 +731,6 @@ void manager::create_temp_move()
}
unit_display::move_unit(path, fake_unit.get_unit_ptr(), false); //get facing right
fake_unit->anim_comp().invalidate(*game_display::get_singleton());
fake_unit->set_location(*curr_itor);
fake_unit->anim_comp().set_ghosted(true);
}
@ -741,9 +740,7 @@ void manager::create_temp_move()
prev_itor = curr_itor;
}
}
//in case path shortens on next step and one ghosted unit has to be removed
int ind = fake_units_.size() - 1;
fake_units_[ind]->anim_comp().invalidate(*game_display::get_singleton());
//toss out old arrows and fake units
move_arrows_.resize(turn+1);
fake_units_.resize(turn+1);
@ -752,11 +749,6 @@ void manager::create_temp_move()
void manager::erase_temp_move()
{
move_arrows_.clear();
for(const fake_unit_ptr& tmp : fake_units_) {
if(tmp) {
tmp->anim_comp().invalidate(*game_display::get_singleton());
}
}
fake_units_.clear();
route_.reset();
temp_move_unit_underlying_id_ = 0;