Author: cjhopman
Date: Thu May 7 20:08:51 2009
New Revision: 35474
URL: http://svn.gna.org/viewcvs/wesnoth?rev=35474&view=rev
Log:
undo delete of get_rect_union
Modified:
trunk/src/sdl_utils.cpp
trunk/src/sdl_utils.hpp
Modified: trunk/src/sdl_utils.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/sdl_utils.cpp?rev=35474&r1=35473&r2=35474&view=diff
==============================================================================
--- trunk/src/sdl_utils.cpp (original)
+++ trunk/src/sdl_utils.cpp Thu May 7 20:08:51 2009
@@ -96,7 +96,27 @@
return result;
}
-
+SDL_Rect get_rect_union(SDL_Rect const &rect1, SDL_Rect const& rect2) {
+ const int left_side = std::max(rect1.x, rect2.x);
+ const int right_side = std::min(rect1.x + rect1.w, rect2.x + rect2.w);
+ if(left_side > right_side) {
+ return empty_rect;
+ }
+
+ const int top_side = std::max(rect1.y, rect2.y);
+ const int bottom_side = std::min(rect1.y + rect1.h, rect2.y + rect2.h);
+ if(top_side > bottom_side) {
+ return empty_rect;
+ }
+
+ SDL_Rect result = {
+ left_side,
+ top_side,
+ right_side - left_side,
+ bottom_side - top_side};
+
+ return result;
+}
SDL_Rect create_rect(const int x, const int y, const int w, const int h)
{
SDL_Rect rect = { x, y, w, h };
Modified: trunk/src/sdl_utils.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/sdl_utils.hpp?rev=35474&r1=35473&r2=35474&view=diff
==============================================================================
--- trunk/src/sdl_utils.hpp (original)
+++ trunk/src/sdl_utils.hpp Thu May 7 20:08:51 2009
@@ -67,6 +67,15 @@
*/
SDL_Rect union_rects(const SDL_Rect& rect1, const SDL_Rect& rect2);
+/**
+ * Returns the intersection of two rectangles...
+ *
+ * @param rect1 The first rectangle.
+ * @param rect2 The second rectangle.
+ *
+ * @returns The intersection of the two rectangles
+ */
+SDL_Rect get_rect_union(const SDL_Rect& rect1, const SDL_Rect& rect2);
/**
* Creates an empty SDL_Rect.
*
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits