Cleanup, reduce duplicate code.

svn-id: r16911
This commit is contained in:
Travis Howell 2005-02-25 11:23:27 +00:00
parent 51391279cc
commit 563b271224
3 changed files with 35 additions and 36 deletions

View File

@ -1222,28 +1222,15 @@ void ScummEngine_v90he::spritesProcessWiz(bool arg) {
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;

View File

@ -88,18 +88,35 @@ void Wiz::polygonStore(int id, bool flag, int vert1x, int vert1y, int vert2x, in
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 @@ void ScummEngine_v90he::drawWizComplexPolygon(int resnum, int state, int po_x, i
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");
}

View File

@ -103,11 +103,13 @@ struct Wiz {
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);