summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJari Karppinen <jari.karppinen@qt.io>2019-05-06 14:14:34 +0300
committerAapo Keskimolo <aapo.keskimolo@qt.io>2019-05-07 07:14:20 +0000
commitcb78fce1c96b469a1e064e76e81ae10e1834cb11 (patch)
tree7d014ea99790ac09c7419958d69c98299e80483d
parent2c2f18ec68e90713b8e4cd169987aa10d726b352 (diff)
Fix camera lookAt in OpenGL Runtime
Convert radians to degrees as in Qt3D Runtime. Task-number: QT3DS-3349 Change-Id: Icc4935a07ce3b9e246b13b179646714267d23956 Reviewed-by: Jere Tuliniemi <jere.tuliniemi@qt.io> Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io> Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
-rw-r--r--src/Runtime/Source/runtime/q3dsqmlscript.cpp7
1 files changed, 2 insertions, 5 deletions
diff --git a/src/Runtime/Source/runtime/q3dsqmlscript.cpp b/src/Runtime/Source/runtime/q3dsqmlscript.cpp
index b73417e6..91963804 100644
--- a/src/Runtime/Source/runtime/q3dsqmlscript.cpp
+++ b/src/Runtime/Source/runtime/q3dsqmlscript.cpp
@@ -38,6 +38,7 @@
#include "Qt3DSQmlElementHelper.h"
#include "Qt3DSHash.h"
#include "Qt3DSEulerAngles.h"
+#include "Qt3DSMathUtils.h"
using namespace Q3DStudio;
@@ -347,15 +348,11 @@ QMatrix4x4 Q3DSQmlScript::calculateGlobalTransform(const QString &handle)
QVector3D Q3DSQmlScript::lookAt(const QVector3D &target)
{
- RuntimeVector3 rotation;
-
FLOAT theMag = ::sqrtf(target.x() * target.x() + target.z() * target.z());
FLOAT thePitch = -::atan2f(target.y(), theMag);
FLOAT theYaw = ::atan2f(target.x(), target.z());
- rotation.Set(thePitch, theYaw, 0.0f);
-
- return QVector3D(rotation.m_X, rotation.m_Y, rotation.m_Z);
+ return QVector3D(radToDeg(thePitch), radToDeg(theYaw), 0.0f);
}
QVector3D Q3DSQmlScript::matrixToEuler(const QMatrix4x4 &matrix)