Page MenuHomeWildfire Games

Update the mini-map properly when the water height changes
ClosedPublic

Authored by Sandarac on Apr 16 2017, 7:18 PM.

Details

Summary

Currently the mini-map does not update when the water height changes (outside of Atlas) - this is noticeable when testing D229, which adds a random map with a script that slowly raises the water height. It is very disorienting and misleading as the mini-map never changes the water height from its original state at the beginning of the game. Also, in the future, there could be more map scripts added that change the water height dynamically like this (maybe a river that floods periodically and then subsides or something).

Test Plan

Whenever a map's water height changes, the mini-map will update accordingly. The map at D229 can be used to test this.

Diff Detail

Repository
rP 0 A.D. Public Repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

Sandarac created this revision.Apr 16 2017, 7:18 PM
vladislavbelov added inline comments.
source/gui/MiniMap.cpp
412 ↗(On Diff #1288)

Shouldn't be there some small EPS, to prevent the recalculating of all data each frame if water is always rising?

Also how much the recalculation does cost?

Vulcan added a subscriber: Vulcan.Apr 16 2017, 8:03 PM

Build is green

Updating workspaces.
Build (release)...
Build (debug)...
Running release tests...
Running cxxtest tests (305 tests).................................................................................................................................................................................................................................................................................................................OK!
Running debug tests...
Running cxxtest tests (305 tests).................................................................................................................................................................................................................................................................................................................OK!

http://jw:8080/job/phabricator/790/ for more details.

Also how much the recalculation does cost?

The recalculation seems to take a negligible amount of time - at least on my system (with PROFILE2 the function seems to take around ~300us).

There is no clean way to listen to the MT_WaterChanged messages sent in the simulation, mainly because the Minimap component is not a system component.

source/gui/MiniMap.cpp
412 ↗(On Diff #1288)

The recalculation is not done on every frame even if the water is always rising - in this function RebuildTerrainTexture() is only called at most 2 times a second.

elexis accepted this revision.Apr 17 2017, 12:08 AM

Awesome patch!!
I was too busy looking into the Minimap code, but this really fixes it nicely and the result looks really great with extinct volcano. Thumbs up!

source/gui/MiniMap.cpp
68 ↗(On Diff #1288)

Can be initialized with 0 since it is rebuilt anyway (appears a bit less arbitrary than 1)

This revision is now accepted and ready to land.Apr 17 2017, 12:09 AM
vladislavbelov accepted this revision.Apr 17 2017, 12:09 AM
This revision was automatically updated to reflect the committed changes.