aboutsummaryrefslogtreecommitdiff
path: root/engines/wintermute/graphics/transform_tools.cpp
diff options
context:
space:
mode:
authorWillem Jan Palenstijn2013-10-06 14:14:01 +0200
committerWillem Jan Palenstijn2013-10-06 17:34:19 +0200
commit14cb1f09c0bc2cace830eaa793227f195acb06bc (patch)
tree5faee1b31f854ffd741c287fd78c6f43154191f8 /engines/wintermute/graphics/transform_tools.cpp
parentfa51ef214c2c57114a8b56906576e0b72ddfc139 (diff)
downloadscummvm-rg350-14cb1f09c0bc2cace830eaa793227f195acb06bc.tar.gz
scummvm-rg350-14cb1f09c0bc2cace830eaa793227f195acb06bc.tar.bz2
scummvm-rg350-14cb1f09c0bc2cace830eaa793227f195acb06bc.zip
WINTERMUTE: Partially fix rotoscale coordinate confusion
This fixes two issues: * The rendering rectangle was not rotated, causing garbage to be drawn if the rotated rectangle did not fully cover the unrotated rectangle, or sprites to be clipped in the opposite case. * The order of mirror/scale/rotation operations was inconsistent. This commit does scaling first, followed by rotation. (This is only an issue because scaling is specified separately in X and Y directions.) For now only FIXMEs are added for mirroring.
Diffstat (limited to 'engines/wintermute/graphics/transform_tools.cpp')
-rw-r--r--engines/wintermute/graphics/transform_tools.cpp26
1 files changed, 20 insertions, 6 deletions
diff --git a/engines/wintermute/graphics/transform_tools.cpp b/engines/wintermute/graphics/transform_tools.cpp
index ebf9092aaa..dc92cdbbfd 100644
--- a/engines/wintermute/graphics/transform_tools.cpp
+++ b/engines/wintermute/graphics/transform_tools.cpp
@@ -26,11 +26,23 @@
namespace Wintermute {
-FloatPoint TransformTools::transformPoint(const FloatPoint &point, const float rotate, const Point32 &zoom, const bool mirrorX, const bool mirrorY) {
+FloatPoint TransformTools::transformPoint(FloatPoint point, const float rotate, const Point32 &zoom, const bool mirrorX, const bool mirrorY) {
float rotateRad = rotate * M_PI / 180.0f;
+ float x = point.x;
+ float y = point.y;
+ x = (x * zoom.x) / kDefaultZoomX;
+ y = (y * zoom.y) / kDefaultZoomY;
+#if 0
+ // TODO: Mirroring should be done before rotation, but the blitting
+ // code does the inverse, so we match that for now.
+ if (mirrorX)
+ x *= -1;
+ if (mirrorY)
+ y *= -1;
+#endif
FloatPoint newPoint;
- newPoint.x = (point.x * cos(rotateRad) - point.y * sin(rotateRad)) * zoom.x / kDefaultZoomX;
- newPoint.y = (point.x * sin(rotateRad) + point.y * cos(rotateRad)) * zoom.y / kDefaultZoomY;
+ newPoint.x = x * cos(rotateRad) - y * sin(rotateRad);
+ newPoint.y = x * sin(rotateRad) + y * cos(rotateRad);
if (mirrorX) {
newPoint.x *= -1;
}
@@ -58,10 +70,12 @@ Rect32 TransformTools::newRect(const Rect32 &oldRect, const TransformStruct &tra
float left = MIN(nw1.x, MIN(ne1.x, MIN(sw1.x, se1.x)));
float right = MAX(nw1.x, MAX(ne1.x, MAX(sw1.x, se1.x)));
- Rect32 res;
- newHotspot->y = (uint32)(-floor(top));
- newHotspot->x = (uint32)(-floor(left));
+ if (newHotspot) {
+ newHotspot->y = (uint32)(-floor(top));
+ newHotspot->x = (uint32)(-floor(left));
+ }
+ Rect32 res;
res.top = (int32)(floor(top)) + transform._hotspot.y;
res.bottom = (int32)(ceil(bottom)) + transform._hotspot.y;
res.left = (int32)(floor(left)) + transform._hotspot.x;