Add a new function propagate_invalidation()
Not used yet but meant to replace the slower set_intersection in unit_animation.cpp
This commit is contained in:
parent
04bbccfde2
commit
dd2f0d6dd1
2 changed files with 32 additions and 0 deletions
|
@ -2329,6 +2329,32 @@ bool display::invalidate(const std::set<map_location>& locs)
|
|||
return ret;
|
||||
}
|
||||
|
||||
bool display::propagate_invalidation(const std::set<map_location>& locs)
|
||||
{
|
||||
if(invalidateAll_)
|
||||
return false;
|
||||
|
||||
bool has_inval = false;
|
||||
std::set<map_location>::const_iterator i = locs.begin();
|
||||
for(; i != locs.end() && !has_inval; ++i) {
|
||||
has_inval = invalidated_.count(*i);
|
||||
}
|
||||
|
||||
// if no invalidation or one but nothing to propagate, return false
|
||||
if (!has_inval || locs.size()<=1)
|
||||
return false;
|
||||
|
||||
// propagate invalidation (but skip the already invalidated hex)
|
||||
bool res = false;
|
||||
std::set<map_location>::const_iterator j = locs.begin();
|
||||
for(; j != locs.end(); ++j) {
|
||||
if(j != i)
|
||||
res |= invalidated_.insert(*j).second;
|
||||
}
|
||||
|
||||
return res; // always true, but cleaner like that
|
||||
}
|
||||
|
||||
bool display::invalidate_visible_locations_in_rect(const SDL_Rect& rect)
|
||||
{
|
||||
return invalidate_locations_in_rect(intersect_rects(map_area(),rect));
|
||||
|
|
|
@ -269,6 +269,12 @@ public:
|
|||
|
||||
bool invalidate(const std::set<map_location>& locs);
|
||||
|
||||
/**
|
||||
* If this set is partially invalidated, invalidate all its hexes.
|
||||
* Returns if any new invalidation was needed
|
||||
*/
|
||||
bool propagate_invalidation(const std::set<map_location>& locs);
|
||||
|
||||
/** invalidate all hexes under the rectangle rect (in screen coordinates) */
|
||||
bool invalidate_locations_in_rect(const SDL_Rect& rect);
|
||||
bool invalidate_visible_locations_in_rect(const SDL_Rect& rect);
|
||||
|
|
Loading…
Add table
Reference in a new issue