Also, i got an idea for "fast" way to calculate the global heatmap:
Code:
for (int y = 0; y < map.height; ++y)
for (int x = 0; x < map.width; ++x) {
double height_sum = map[y * map.height + x];
int di = y < map.height / 2 ? -1 : 1;
for (int i = map.height / 2; i != y; i += di)
height_sum += map[i * map.height + x];
heatmap[y * map.height + x] = 1.0 / height_sum;
}
On a flat map this would result a hot belt on equator and cold at the "poles". A mountain will block the progress of heat towards the "poles" just like it does now. Finishing touch would be to run an aggressive gaussian blur on the heatmap.
With one simple optimization this method would require just width*height operations per coordinate to get the raw heatmap and after that the blur would require something like blur_width*blur_height*width*height operations to finish it off. For a 512*512 map and 4*4 blur this would mean 512*512+4*4*512*512=4456448 operations i.e. roughly 2 milliseconds (of which 94% comes from the blur). However, i haven't tested the idea in practice so i can't guarantee good results.