@@ -214,6 +214,7 @@ void RenderedTarget::setEngine(IEngine *newEngine)
214214 m_skin = nullptr ;
215215 m_texture = Texture ();
216216 m_oldTexture = Texture ();
217+ m_cpuTexture = Texture ();
217218 m_convexHullDirty = true ;
218219 clearGraphicEffects ();
219220 m_hullPoints.clear ();
@@ -547,6 +548,9 @@ const std::vector<QPoint> &RenderedTarget::hullPoints() const
547548
548549bool RenderedTarget::contains (const QPointF &point) const
549550{
551+ if (!m_costume || !m_cpuTexture.isValid ())
552+ return false ;
553+
550554 if (m_stageModel)
551555 return true ; // the stage contains any point within the scene
552556
@@ -555,7 +559,8 @@ bool RenderedTarget::contains(const QPointF &point) const
555559
556560 const std::vector<QPoint> &points = hullPoints ();
557561
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 ();
559564 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 ()); });
560565
561566 if (it == points.end ()) {
@@ -638,14 +643,15 @@ void RenderedTarget::calculateRotation()
638643void RenderedTarget::calculateSize ()
639644{
640645 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 ();
643648 m_texture = m_skin->getTexture (m_size * m_stageScale);
649+ m_cpuTexture = m_skin->getTexture (m_size);
644650 m_width = m_texture.width ();
645651 m_height = m_texture.height ();
646652 setScale (m_size * m_stageScale / m_skin->getTextureScale (m_texture) / m_costume->bitmapResolution ());
647653
648- if (wasValid && m_texture .handle () != oldTexture)
654+ if (wasValid && m_cpuTexture .handle () != oldTexture)
649655 m_convexHullDirty = true ;
650656 }
651657}
@@ -677,7 +683,7 @@ void RenderedTarget::updateHullPoints()
677683 return ;
678684 }
679685
680- m_hullPoints = textureManager ()->getTextureConvexHullPoints (m_texture );
686+ m_hullPoints = textureManager ()->getTextureConvexHullPoints (m_cpuTexture );
681687 // TODO: Apply graphic effects (#117)
682688}
683689
0 commit comments