Optimization of big or misaligned off-screen sprite
Prevent them to be affected by adjacent hexes, because overlapping is irrelevant when not visible on screen (with a tiny optimization of this after an invalidate_all) Also remove an unused function
This commit is contained in:
parent
0ba4ffa078
commit
e8633ebb3e
2 changed files with 9 additions and 13 deletions
|
@ -2336,10 +2336,17 @@ bool display::invalidate_locations_in_rect(const SDL_Rect& rect)
|
|||
|
||||
bool display::rectangle_need_update(const SDL_Rect& rect) const
|
||||
{
|
||||
SDL_Rect visible_rect = intersect_rects(map_area(), rect);
|
||||
|
||||
// check if rectangle is visible
|
||||
if(visible_rect.w <=0 || visible_rect.h <=0)
|
||||
return false;
|
||||
|
||||
// invalidateAll_ is about visible hexes, so only check if visible
|
||||
if(invalidateAll_)
|
||||
return true;
|
||||
|
||||
rect_of_hexes hexes = hexes_under_rect(rect);
|
||||
rect_of_hexes hexes = hexes_under_rect(visible_rect);
|
||||
rect_of_hexes::iterator i = hexes.begin(), end = hexes.end();
|
||||
for (;i != end; ++i) {
|
||||
if(invalidated_.find(*i) != invalidated_.end())
|
||||
|
@ -2349,14 +2356,6 @@ bool display::rectangle_need_update(const SDL_Rect& rect) const
|
|||
return false;
|
||||
}
|
||||
|
||||
bool display::hex_need_update(const map_location& loc) const
|
||||
{
|
||||
if(invalidateAll_)
|
||||
return true;
|
||||
|
||||
return invalidated_.find(loc) != invalidated_.end();
|
||||
}
|
||||
|
||||
void display::invalidate_animations() {
|
||||
if (preferences::animate_map()) {
|
||||
rect_of_hexes hexes = get_visible_hexes();
|
||||
|
|
|
@ -273,12 +273,9 @@ public:
|
|||
bool invalidate_locations_in_rect(const SDL_Rect& rect);
|
||||
bool invalidate_visible_locations_in_rect(const SDL_Rect& rect);
|
||||
|
||||
/** check if an hexes under the rectangle is invalidated */
|
||||
/** check if visible hexes under the rectangle is invalidated */
|
||||
bool rectangle_need_update(const SDL_Rect& rect) const;
|
||||
|
||||
/** check if an hex is invalidated */
|
||||
bool hex_need_update(const map_location& loc) const;
|
||||
|
||||
/**
|
||||
* Function to invalidate animated terrains which may have changed.
|
||||
*/
|
||||
|
|
Loading…
Add table
Reference in a new issue