summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomi Korpipaa <tomi.korpipaa@qt.io>2019-03-13 09:42:58 +0200
committerTomi Korpipää <tomi.korpipaa@qt.io>2019-03-15 07:10:41 +0000
commita3ec00073723cd8835a8be7bdad960b4bcc21a6c (patch)
tree9d615e4a4113d07abdc1873a9e711868d87259d9
parent3560fdfbc9314d591c1c605441ea40ad941e234b (diff)
Fix text alignment if text has rotation
Legacy text renderer did not take text rotation into account when translating text based on alignment. Task-number: QT3DS-3052 Change-Id: I21ef265e438c940727b91c3c3c3a884e8116bb5e Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io> Reviewed-by: Janne Kangas <janne.kangas@qt.io> Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io> Reviewed-by: Antti Määttä <antti.maatta@qt.io>
-rw-r--r--src/runtime/q3dsscenemanager.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/runtime/q3dsscenemanager.cpp b/src/runtime/q3dsscenemanager.cpp
index cb7c7d2..dffa07e 100644
--- a/src/runtime/q3dsscenemanager.cpp
+++ b/src/runtime/q3dsscenemanager.cpp
@@ -5530,6 +5530,10 @@ void Q3DSSceneManager::updateText(Q3DSTextNode *text3DS, bool needsNewImage)
if (textOffsetX != 0 || textOffsetY != 0) {
QVector3D pos = text3DS->position();
+ QVector3D rot = text3DS->rotation();
+ // Apply text rotation to the translation amount
+ textOffsetX *= qCos(qDegreesToRadians(rot.y()));
+ textOffsetY *= qCos(qDegreesToRadians(rot.x()));
data->transform->setTranslation(QVector3D(pos.x() + textOffsetX,
pos.y() + textOffsetY,
pos.z()));