summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Suhren <suhren.stefan@fh-swf.de>2015-12-14 17:39:25 +0100
committerStefan Suhren <suhren.stefan@fh-swf.de>2015-12-14 17:39:25 +0100
commit5b10b57badf1b28f3cebed1f045764ba212466e7 (patch)
treec035b87657fc4aafc173b544c3e833351b69a88c
parentca49968016ef47289c4350ce676e444ac33b8180 (diff)
downloadMultimedia-5b10b57badf1b28f3cebed1f045764ba212466e7.tar.gz
Multimedia-5b10b57badf1b28f3cebed1f045764ba212466e7.zip
Fix top hit detection
-rw-r--r--src/gldisc.cpp6
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)
{