mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-26 11:46:54 +00:00
Cleanup, reduce duplicate code.
svn-id: r16911
This commit is contained in:
parent
51391279cc
commit
563b271224
@ -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;
|
||||
|
@ -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");
|
||||
}
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user