[Scummvm-cvs-logs] CVS: scummvm/common rect.h,1.10,1.11

Max Horn fingolfin at users.sourceforge.net
Sun Jun 1 10:07:05 CEST 2003


Update of /cvsroot/scummvm/scummvm/common
In directory sc8-pr-cvs1:/tmp/cvs-serv32662

Modified Files:
	rect.h 
Log Message:
renamed&fixed contains(Rect) -> intersects(Rect); added extend() method

Index: rect.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/rect.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- rect.h	29 May 2003 16:37:49 -0000	1.10
+++ rect.h	1 Jun 2003 17:06:07 -0000	1.11
@@ -23,6 +23,7 @@
 #define COMMON_RECT_H
 
 #include "scummsys.h"
+#include "util.h"
 
 namespace ScummVM {
 
@@ -78,14 +79,25 @@
 		return (left <= p.x) && (p.x < right) && (top <= p.y) && (p.y < bottom);
 	}
 
-	/*!	@brief check if given rectangle is inside this rectangle
+	/*!	@brief check if given rectangle intersects with this rectangle
 		
 		@param r the rectangle to check
 		
 		@return true if the given rectangle is inside the rectangle, false otherwise
 	*/
-	bool contains(const Rect & r) const {
-		return (left <= r.right) && (r.left < right) && (top <= r.bottom) && (r.top < bottom);
+	bool intersects(const Rect & r) const {
+		return (left < r.right) && (r.left < right) && (top < r.bottom) && (r.top < bottom);
+	}
+
+	/*!	@brief extend this rectangle so that it contains r
+		
+		@param r the rectangle to extend by
+	*/
+	void extend(const Rect & r) {
+		left = MIN(left, r.left);
+		right = MAX(right, r.right);
+		top = MIN(top, r.top);
+		bottom = MAX(bottom, r.bottom);
 	}
 	
 	void grow(int16 offset) {





More information about the Scummvm-git-logs mailing list