| 8340 | } |
| 8341 | |
| 8342 | void map::build_map_cache( const int zlev, bool skip_lightmap ) |
| 8343 | { |
| 8344 | const int minz = zlevels ? -OVERMAP_DEPTH : zlev; |
| 8345 | const int maxz = zlevels ? OVERMAP_HEIGHT : zlev; |
| 8346 | bool seen_cache_dirty = false; |
| 8347 | for( int z = minz; z <= maxz; z++ ) { |
| 8348 | // trigger FOV recalculation only when there is a change on the player's level or if fov_3d is enabled |
| 8349 | const bool affects_seen_cache = z == zlev || fov_3d; |
| 8350 | build_outside_cache( z ); |
| 8351 | build_transparency_cache( z ); |
| 8352 | bool floor_cache_was_dirty = build_floor_cache( z ); |
| 8353 | seen_cache_dirty |= ( floor_cache_was_dirty && affects_seen_cache ); |
| 8354 | if( floor_cache_was_dirty && z > -OVERMAP_DEPTH ) { |
| 8355 | get_cache( z - 1 ).r_up_cache->invalidate(); |
| 8356 | } |
| 8357 | seen_cache_dirty |= get_cache( z ).seen_cache_dirty && affects_seen_cache; |
| 8358 | } |
| 8359 | // needs a separate pass as it changes the caches on neighbour z-levels (e.g. floor_cache); |
| 8360 | // otherwise such changes might be overwritten by main cache-building logic |
| 8361 | for( int z = minz; z <= maxz; z++ ) { |
| 8362 | do_vehicle_caching( z ); |
| 8363 | } |
| 8364 | |
| 8365 | seen_cache_dirty |= build_vision_transparency_cache( zlev ); |
| 8366 | |
| 8367 | if( seen_cache_dirty ) { |
| 8368 | skew_vision_cache.clear(); |
| 8369 | } |
| 8370 | // Initial value is illegal player position. |
| 8371 | const tripoint p = get_player_character().pos(); |
| 8372 | static tripoint player_prev_pos; |
| 8373 | if( seen_cache_dirty || player_prev_pos != p ) { |
| 8374 | build_seen_cache( p, zlev ); |
| 8375 | player_prev_pos = p; |
| 8376 | } |
| 8377 | if( !skip_lightmap ) { |
| 8378 | generate_lightmap( zlev ); |
| 8379 | } |
| 8380 | } |
| 8381 | |
| 8382 | ////////// |
| 8383 | ///// coordinate helpers |