Author: alink
Date: Mon May 11 03:57:35 2009
New Revision: 35564
URL: http://svn.gna.org/viewcvs/wesnoth?rev=35564&view=rev
Log:
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
Modified:
trunk/src/display.cpp
trunk/src/display.hpp
Modified: trunk/src/display.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/display.cpp?rev=35564&r1=35563&r2=35564&view=diff
==============================================================================
--- trunk/src/display.cpp (original)
+++ trunk/src/display.cpp Mon May 11 03:57:35 2009
@@ -2336,10 +2336,17 @@
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())
@@ -2347,14 +2354,6 @@
}
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() {
Modified: trunk/src/display.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/display.hpp?rev=35564&r1=35563&r2=35564&view=diff
==============================================================================
--- trunk/src/display.hpp (original)
+++ trunk/src/display.hpp Mon May 11 03:57:35 2009
@@ -273,11 +273,8 @@
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.
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits