#ifndef DUST3D_MOUSE_PICKER_H #define DUST3D_MOUSE_PICKER_H #include #include #include #include #include #include "outcome.h" #include "paintmode.h" class MousePicker : public QObject { Q_OBJECT public: MousePicker(const Outcome &outcome, const QVector3D &mouseRayNear, const QVector3D &mouseRayFar); void setRadius(float radius); void setPaintImages(const std::map &paintImages); void setPaintMode(PaintMode paintMode); void setMaskNodeIds(const std::set &nodeIds); const std::map &resultPaintImages(); const std::set &changedPartIds(); ~MousePicker(); const QVector3D &targetPosition(); signals: void finished(); public slots: void process(); void pick(); private: float m_radius = 0.0; std::map m_paintImages; PaintMode m_paintMode = PaintMode::None; std::set m_changedPartIds; std::set m_mousePickMaskNodeIds; bool m_enablePaint = false; Outcome m_outcome; QVector3D m_mouseRayNear; QVector3D m_mouseRayFar; QVector3D m_targetPosition; static bool intersectSegmentAndPlane(const QVector3D &segmentPoint0, const QVector3D &segmentPoint1, const QVector3D &pointOnPlane, const QVector3D &planeNormal, QVector3D *intersection=nullptr); static bool intersectSegmentAndTriangle(const QVector3D &segmentPoint0, const QVector3D &segmentPoint1, const std::vector &triangle, const QVector3D &triangleNormal, QVector3D *intersection=nullptr); bool calculateMouseModelPosition(QVector3D &mouseModelPosition); void paintToImage(const QUuid &partId, float x, float y, float radius, bool inverted=false); }; #endif