@@ -367,6 +367,8 @@ Rect RenderedTarget::getBounds() const
367367 const double originX = m_costume->rotationCenterX () * m_size / m_costume->bitmapResolution () - width / 2 ;
368368 const double originY = -m_costume->rotationCenterY () * m_size / m_costume->bitmapResolution () + height / 2 ;
369369 const double rot = -rotation () * pi / 180 ;
370+ const double sinRot = std::sin (rot);
371+ const double cosRot = std::cos (rot);
370372 double left = std::numeric_limits<double >::infinity ();
371373 double top = -std::numeric_limits<double >::infinity ();
372374 double right = -std::numeric_limits<double >::infinity ();
@@ -375,7 +377,7 @@ Rect RenderedTarget::getBounds() const
375377 const std::vector<QPoint> &points = hullPoints ();
376378
377379 for (const QPointF &point : points) {
378- QPointF transformed = transformPoint (point.x () - width / 2 , height / 2 - point.y (), originX, originY, rot );
380+ QPointF transformed = transformPoint (point.x () - width / 2 , height / 2 - point.y (), originX, originY, sinRot, cosRot );
379381 const double x = transformed.x () * (m_mirrorHorizontally ? -1 : 1 );
380382 const double y = transformed.y ();
381383
@@ -425,11 +427,13 @@ Rect RenderedTarget::getFastBounds() const
425427 const double originX = m_costume->rotationCenterX () * m_size / m_costume->bitmapResolution () - width / 2 ;
426428 const double originY = -m_costume->rotationCenterY () * m_size / m_costume->bitmapResolution () + height / 2 ;
427429 const double rot = -rotation () * pi / 180 ;
430+ const double sinRot = std::sin (rot);
431+ const double cosRot = std::cos (rot);
428432
429- QPointF topLeft = transformPoint (-width / 2 , height / 2 , originX, originY, rot );
430- QPointF topRight = transformPoint (width / 2 , height / 2 , originX, originY, rot );
431- QPointF bottomRight = transformPoint (width / 2 , -height / 2 , originX, originY, rot );
432- QPointF bottomLeft = transformPoint (-width / 2 , -height / 2 , originX, originY, rot );
433+ QPointF topLeft = transformPoint (-width / 2 , height / 2 , originX, originY, sinRot, cosRot );
434+ QPointF topRight = transformPoint (width / 2 , height / 2 , originX, originY, sinRot, cosRot );
435+ QPointF bottomRight = transformPoint (width / 2 , -height / 2 , originX, originY, sinRot, cosRot );
436+ QPointF bottomLeft = transformPoint (-width / 2 , -height / 2 , originX, originY, sinRot, cosRot );
433437
434438 if (m_mirrorHorizontally) {
435439 topLeft.setX (-topLeft.x ());
@@ -747,8 +751,11 @@ void RenderedTarget::updateHullPoints()
747751
748752QPointF RenderedTarget::transformPoint (double scratchX, double scratchY, double originX, double originY, double rot) const
749753{
750- const double cosRot = std::cos (rot);
751- const double sinRot = std::sin (rot);
754+ return transformPoint (scratchX, scratchY, originX, originY, std::sin (rot), std::cos (rot));
755+ }
756+
757+ QPointF RenderedTarget::transformPoint (double scratchX, double scratchY, double originX, double originY, double sinRot, double cosRot) const
758+ {
752759 const double x = (scratchX - originX) * cosRot - (scratchY - originY) * sinRot;
753760 const double y = (scratchX - originX) * sinRot + (scratchY - originY) * cosRot;
754761 return QPointF (x, y);
0 commit comments