From 99faf30ff674edd9323459b2778e5a85f1bc52fa Mon Sep 17 00:00:00 2001 From: Charles Dang Date: Wed, 5 Jul 2017 22:13:07 +1100 Subject: [PATCH] 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. --- src/actions/move.cpp | 3 -- src/display.cpp | 20 ------------- src/units/animation.cpp | 49 ------------------------------- src/units/animation.hpp | 4 +-- src/units/animation_component.cpp | 28 ------------------ src/units/animation_component.hpp | 3 -- src/whiteboard/manager.cpp | 10 +------ 7 files changed, 2 insertions(+), 115 deletions(-) diff --git a/src/actions/move.cpp b/src/actions/move.cpp index b7ee7ef79b00..dbb3755ff9f1 100644 --- a/src/actions/move.cpp +++ b/src/actions/move.cpp @@ -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). std::pair move_result = diff --git a/src/display.cpp b/src/display.cpp index 16f79966408b..edee4ada48f4 100644 --- a/src/display.cpp +++ b/src/display.cpp @@ -2409,26 +2409,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::add_arrow(arrow& arrow) diff --git a/src/units/animation.cpp b/src/units/animation.cpp index c3ee345b8105..c58312370570 100644 --- a/src/units/animation.cpp +++ b/src/units/animation.cpp @@ -267,9 +267,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()); } @@ -291,9 +289,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()); @@ -1081,9 +1077,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); @@ -1102,48 +1095,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 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; diff --git a/src/units/animation.hpp b/src/units/animation.hpp index 7e72d3d1b078..6c26c9be6223 100644 --- a/src/units/animation.hpp +++ b/src/units/animation.hpp @@ -104,7 +104,7 @@ class unit_animation } 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 @@ class unit_animation map_location src_; map_location dst_; // optimization - bool invalidated_; bool play_offscreen_; - std::set overlaped_hex_; }; class unit_animator diff --git a/src/units/animation_component.cpp b/src/units/animation_component.cpp index 2bb4d9383d93..b4e8b9aa608b 100644 --- a/src/units/animation_component.cpp +++ b/src/units/animation_component.cpp @@ -155,34 +155,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(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) { diff --git a/src/units/animation_component.hpp b/src/units/animation_component.hpp index cea701e72e06..b28f63eab388 100644 --- a/src/units/animation_component.hpp +++ b/src/units/animation_component.hpp @@ -86,9 +86,6 @@ class unit_animation_component 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(); diff --git a/src/whiteboard/manager.cpp b/src/whiteboard/manager.cpp index 96b8cbabb97b..be25a5fea13b 100644 --- a/src/whiteboard/manager.cpp +++ b/src/whiteboard/manager.cpp @@ -724,7 +724,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); } @@ -734,9 +733,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); @@ -745,11 +742,6 @@ void manager::create_temp_move() void manager::erase_temp_move() { move_arrows_.clear(); - for(fake_unit_ptr const& tmp : fake_units_) { - if(tmp) { - tmp->anim_comp().invalidate(*game_display::get_singleton()); - } - } fake_units_.clear(); route_.reset(); temp_move_unit_underlying_id_ = 0;