Redraw invalidated hexes once, not twice
This halves the CPU usage cost of animations, which is useful especially in water-heavy scenarios such as Dead Water. I was worried about the possibility of regressions, but I didn't find any in my playtesting: moved and killed units disappear from their hexes like they should.
This commit is contained in:
parent
49bf9debbf
commit
3692cfa86b
4 changed files with 5 additions and 13 deletions
|
@ -52,6 +52,8 @@ Version 1.13.8+dev:
|
|||
* Fixed delay or clients gettings stuck when starting a mp game (Bug #1674)
|
||||
* Performance:
|
||||
* Rewrote the FPS cap implementation. This greatly improves smoothness ingame.
|
||||
* Each invalidated hex is now only redrawn once, not twice. This almost halves CPU
|
||||
usage ingame.
|
||||
* Implemented GUI canvas caching. It speeds up multiple areas, but especially
|
||||
the story screen.
|
||||
* Units:
|
||||
|
|
|
@ -35,6 +35,8 @@ Version 1.13.8+dev:
|
|||
|
||||
* Performance:
|
||||
* Rewrote the FPS cap implementation. This greatly improves smoothness ingame.
|
||||
* Each invalidated hex is now only redrawn once, not twice. This almost halves CPU
|
||||
usage ingame.
|
||||
* Implemented GUI canvas caching. It speeds up multiple areas, but especially
|
||||
the story screen.
|
||||
|
||||
|
|
|
@ -189,7 +189,6 @@ display::display(const display_context * dc, CVideo& video, std::weak_ptr<wb::ma
|
|||
menu_buttons_(),
|
||||
action_buttons_(),
|
||||
invalidated_(),
|
||||
previous_invalidated_(),
|
||||
mouseover_hex_overlay_(nullptr),
|
||||
tod_hex_mask1(nullptr),
|
||||
tod_hex_mask2(nullptr),
|
||||
|
@ -2441,17 +2440,7 @@ void display::draw(bool update,bool force) {
|
|||
pre_draw();
|
||||
// invalidate all that needs to be invalidated
|
||||
invalidate_animations();
|
||||
// at this stage we have everything that needs to be invalidated for this redraw
|
||||
// save it as the previous invalidated, and merge with the previous invalidated_
|
||||
// we merge with the previous redraw because if a hex had a unit last redraw but
|
||||
// not this one, nobody will tell us to redraw (cleanup)
|
||||
previous_invalidated_.swap(invalidated_);
|
||||
invalidated_.insert(previous_invalidated_.begin(),previous_invalidated_.end());
|
||||
// these new invalidations cannot cause any propagation because
|
||||
// if a hex was invalidated last turn but not this turn, then
|
||||
// * case of no unit in neighbor hex=> no propagation
|
||||
// * case of unit in hex but was there last turn=>its hexes are invalidated too
|
||||
// * case of unit in hex not there last turn => it moved, so was invalidated previously
|
||||
|
||||
if(!get_map().empty()) {
|
||||
//int simulate_delay = 0;
|
||||
|
||||
|
|
|
@ -750,7 +750,6 @@ protected:
|
|||
std::map<std::string, config> reports_;
|
||||
std::vector<std::shared_ptr<gui::button>> menu_buttons_, action_buttons_;
|
||||
std::set<map_location> invalidated_;
|
||||
std::set<map_location> previous_invalidated_;
|
||||
surface mouseover_hex_overlay_;
|
||||
// If we're transitioning from one time of day to the next,
|
||||
// then we will use these two masks on top of all hexes when we blit.
|
||||
|
|
Loading…
Add table
Reference in a new issue