aboutsummaryrefslogtreecommitdiff
path: root/engines/wintermute/graphics
diff options
context:
space:
mode:
Diffstat (limited to 'engines/wintermute/graphics')
-rw-r--r--engines/wintermute/graphics/transform_tools.cpp26
-rw-r--r--engines/wintermute/graphics/transform_tools.h2
2 files changed, 21 insertions, 7 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;
diff --git a/engines/wintermute/graphics/transform_tools.h b/engines/wintermute/graphics/transform_tools.h
index c92b81fd11..9a73e3b69f 100644
--- a/engines/wintermute/graphics/transform_tools.h
+++ b/engines/wintermute/graphics/transform_tools.h
@@ -34,7 +34,7 @@ public:
/**
* Basic transform (scale + rotate) for a single point
*/
- static FloatPoint transformPoint(const FloatPoint &point, const float rotate, const Point32 &zoom, const bool mirrorX = false, const bool mirrorY = false);
+ static FloatPoint transformPoint(FloatPoint point, const float rotate, const Point32 &zoom, const bool mirrorX = false, const bool mirrorY = false);
/**
* @param &point the point on which the transform is to be applied