diff options
| -rw-r--r-- | src/gldisc.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/gldisc.cpp b/src/gldisc.cpp index 5afa4d4..ee0a06b 100644 --- a/src/gldisc.cpp +++ b/src/gldisc.cpp @@ -89,6 +89,7 @@ bool GLDisc::isHit(QVector3D p1, QVector3D p2) QVector3D lineVector = p2 - p1; + // Calculate intersection point with the xy plane QVector3D vecBottom = p1 + lineVector * (-p1.z() / lineVector.z()); if (vecBottom.length() < m_circleRadius) @@ -96,7 +97,10 @@ bool GLDisc::isHit(QVector3D p1, QVector3D p2) return true; } - QVector3D vecTop = p1 + lineVector * ((m_height - p1.z()) / lineVector.z()); + // Calculate intersection point with the xy + m_heigth plane + // Then drop z so that we get a projection onto the xy plane + QVector3D vecTop = (p1 + lineVector * ((m_height - p1.z()) / + lineVector.z())).toVector2D(); if (vecTop.length() < m_circleRadius) { |
