@@ -214,6 +214,7 @@ void RenderedTarget::setEngine(IEngine *newEngine)
214
214
m_skin = nullptr ;
215
215
m_texture = Texture ();
216
216
m_oldTexture = Texture ();
217
+ m_cpuTexture = Texture ();
217
218
m_convexHullDirty = true ;
218
219
clearGraphicEffects ();
219
220
m_hullPoints.clear ();
@@ -547,6 +548,9 @@ const std::vector<QPoint> &RenderedTarget::hullPoints() const
547
548
548
549
bool RenderedTarget::contains (const QPointF &point) const
549
550
{
551
+ if (!m_costume || !m_cpuTexture.isValid ())
552
+ return false ;
553
+
550
554
if (m_stageModel)
551
555
return true ; // the stage contains any point within the scene
552
556
@@ -555,7 +559,8 @@ bool RenderedTarget::contains(const QPointF &point) const
555
559
556
560
const std::vector<QPoint> &points = hullPoints ();
557
561
558
- QPoint intPoint = point.toPoint ();
562
+ const double scaleRatio = m_skin->getTextureScale (m_texture) / m_skin->getTextureScale (m_cpuTexture);
563
+ QPoint intPoint = (point / scaleRatio).toPoint ();
559
564
auto it = std::lower_bound (points.begin (), points.end (), intPoint, [](const QPointF &lhs, const QPointF &rhs) { return (lhs.y () < rhs.y ()) || (lhs.y () == rhs.y () && lhs.x () < rhs.x ()); });
560
565
561
566
if (it == points.end ()) {
@@ -638,14 +643,15 @@ void RenderedTarget::calculateRotation()
638
643
void RenderedTarget::calculateSize ()
639
644
{
640
645
if (m_skin && m_costume) {
641
- GLuint oldTexture = m_texture .handle ();
642
- bool wasValid = m_texture .isValid ();
646
+ GLuint oldTexture = m_cpuTexture .handle ();
647
+ bool wasValid = m_cpuTexture .isValid ();
643
648
m_texture = m_skin->getTexture (m_size * m_stageScale);
649
+ m_cpuTexture = m_skin->getTexture (m_size);
644
650
m_width = m_texture.width ();
645
651
m_height = m_texture.height ();
646
652
setScale (m_size * m_stageScale / m_skin->getTextureScale (m_texture) / m_costume->bitmapResolution ());
647
653
648
- if (wasValid && m_texture .handle () != oldTexture)
654
+ if (wasValid && m_cpuTexture .handle () != oldTexture)
649
655
m_convexHullDirty = true ;
650
656
}
651
657
}
@@ -677,7 +683,7 @@ void RenderedTarget::updateHullPoints()
677
683
return ;
678
684
}
679
685
680
- m_hullPoints = textureManager ()->getTextureConvexHullPoints (m_texture );
686
+ m_hullPoints = textureManager ()->getTextureConvexHullPoints (m_cpuTexture );
681
687
// TODO: Apply graphic effects (#117)
682
688
}
683
689
0 commit comments