[Scummvm-cvs-logs] CVS: scummvm/scumm sprite_he.cpp,1.55,1.56 wiz_he.cpp,2.4,2.5 wiz_he.h,2.4,2.5

kirben kirben at users.sourceforge.net
Fri Feb 25 03:29:55 CET 2005


Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6707/scumm

Modified Files:
	sprite_he.cpp wiz_he.cpp wiz_he.h 
Log Message:

Cleanup, reduce duplicate code.


Index: sprite_he.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/sprite_he.cpp,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -d -r1.55 -r1.56
--- sprite_he.cpp	25 Feb 2005 02:07:22 -0000	1.55
+++ sprite_he.cpp	25 Feb 2005 11:23:26 -0000	1.56
@@ -1222,28 +1222,15 @@
 						pts[j].y = pts[i].y * zoom / 256;
 					}
 				}
-				if (spi->flags & kSFRotated) {
-					double alpha = rot_angle * PI / 180.;
-					double cos_alpha = cos(alpha);
-					double sin_alpha = sin(alpha);
-					for (int j = 0; j < 4; ++j) {
-						int16 x = pts[j].x;
-						int16 y = pts[j].y;
-						pts[j].x = (int16)(x * cos_alpha - y * sin_alpha);
-						pts[j].y = (int16)(y * cos_alpha + x * sin_alpha);
-					}
-				}
+				if (spi->flags & kSFRotated)
+					_wiz.polygonRotatePoints(pts, 4, rot_angle);
 
 				for (int j = 0; j < 4; ++j) {
 					pts[j].x += wiz.img.x1;
 					pts[j].y += wiz.img.y1;
 				}
 
-				for (int j = 0; j < 4; j++) {
-					Common::Rect r(pts[j].x, pts[j].y, pts[j].x + 1, pts[j].y + 1);
-					spi->bbox.extend(r);
-				}
-
+				_wiz.polygonCalcBoundBox(pts, 4, spi->bbox);
 			}
 		} else {
 			bboxPtr->left = 1234;

Index: wiz_he.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/wiz_he.cpp,v
retrieving revision 2.4
retrieving revision 2.5
diff -u -d -r2.4 -r2.5
--- wiz_he.cpp	24 Feb 2005 20:20:35 -0000	2.4
+++ wiz_he.cpp	25 Feb 2005 11:23:26 -0000	2.5
@@ -88,18 +88,35 @@
 	wp->vert[4].x = vert1x;
 	wp->vert[4].y = vert1y;
 	wp->id = id;
-	wp->numVerts = 5;
+	wp->numVerts = 5;  
 	wp->flag = flag;	
 
-	wp->bound.left = 10000;
-	wp->bound.top = 10000;
-	wp->bound.right = -10000;
-	wp->bound.bottom = -10000;
+	polygonCalcBoundBox(wp->vert, wp->numVerts, wp->bound);
+}
+
+void Wiz::polygonRotatePoints(Common::Point *pts, int num, int angle) {
+	double alpha = angle * PI / 180.;
+	double cos_alpha = cos(alpha);
+	double sin_alpha = sin(alpha);
+
+	for (int i = 0; i < num; ++i) {
+		int16 x = pts[i].x;
+		int16 y = pts[i].y;
+		pts[i].x = (int16)(x * cos_alpha - y * sin_alpha);
+		pts[i].y = (int16)(y * cos_alpha + x * sin_alpha);
+	}
+}
+
+void Wiz::polygonCalcBoundBox(Common::Point *vert, int numVerts, Common::Rect &bound) {
+	bound.left = 10000;
+	bound.top = 10000;
+	bound.right = -10000;
+	bound.bottom = -10000;
 
 	// compute bounding box
-	for (int j = 0; j < wp->numVerts; j++) {
-		Common::Rect r(wp->vert[j].x, wp->vert[j].y, wp->vert[j].x + 1, wp->vert[j].y + 1);
-		wp->bound.extend(r);
+	for (int j = 0; j < numVerts; j++) {
+		Common::Rect r(vert[j].x, vert[j].y, vert[j].x + 1, vert[j].y + 1);
+		bound.extend(r);
 	}
 }
 
@@ -1163,21 +1180,14 @@
 			pts[i].y = pts[i].y * zoom / 256;
 		}
 	}
-	if (angle != 0) {
-		double alpha = angle * PI / 180.;
-		double cos_alpha = cos(alpha);
-		double sin_alpha = sin(alpha);
-		for (int i = 0; i < 4; ++i) {
-			int16 x = pts[i].x;
-			int16 y = pts[i].y;
-			pts[i].x = (int16)(x * cos_alpha - y * sin_alpha);
-			pts[i].y = (int16)(y * cos_alpha + x * sin_alpha);
-		}
-	}
+	if (angle)
+		_wiz.polygonRotatePoints(pts, 4, angle);
+
 	for (int i = 0; i < 4; ++i) {
 		pts[i].x += po_x;
 		pts[i].y += po_y;
 	}
+
 	// XXX drawWizPolygonPoints(resnum, state, pts, r, VAR(117));
 	warning("ScummEngine_v90he::drawWizComplexPolygon() partially implemented");
 }

Index: wiz_he.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/wiz_he.h,v
retrieving revision 2.4
retrieving revision 2.5
diff -u -d -r2.4 -r2.5
--- wiz_he.h	24 Feb 2005 20:20:35 -0000	2.4
+++ wiz_he.h	25 Feb 2005 11:23:27 -0000	2.5
@@ -103,11 +103,13 @@
 	void polygonClear();
 	void polygonLoad(const uint8 *polData);
 	void polygonStore(int id, bool flag, int vert1x, int vert1y, int vert2x, int vert2y, int vert3x, int vert3y, int vert4x, int vert4y);
+	void polygonCalcBoundBox(Common::Point *vert, int numVerts, Common::Rect & bound);
 	void polygonErase(int fromId, int toId);
 	int polygonHit(int id, int x, int y);
 	bool polygonDefined(int id);
 	bool polygonContains(const WizPolygon &pol, int x, int y);
-	
+	void polygonRotatePoints(Common::Point *pts, int num, int alpha);
+
 	static void copyAuxImage(uint8 *dst1, uint8 *dst2, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch);	
 	static void copyWizImage(uint8 *dst, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect);
 	static void copyRawWizImage(uint8 *dst, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int flags, const uint8 *palPtr, int transColor);





More information about the Scummvm-git-logs mailing list