diff options
author | Miikka Heikkinen <miikka.heikkinen@qt.io> | 2016-06-06 13:34:11 +0300 |
---|---|---|
committer | Miikka Heikkinen <miikka.heikkinen@qt.io> | 2016-06-06 11:38:41 +0000 |
commit | 0c85e4bb7158e53ed518eb2216e0a4b44192cfe0 (patch) | |
tree | 32040b827186f708aada3aeb9975f021a2835aec /editorlib/src/editorscene.cpp | |
parent | 54f4bf2d05ce80ce866f6c786d58fcf9eb4f8033 (diff) |
Fix selection box and drag scaling for off-center custom meshes
Change-Id: Ic122846cdc7e82166a46e5846665f9fdf19821b5
Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
Reviewed-by: Titta Heikkala <titta.heikkala@qt.io>
Diffstat (limited to 'editorlib/src/editorscene.cpp')
-rw-r--r-- | editorlib/src/editorscene.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/editorlib/src/editorscene.cpp b/editorlib/src/editorscene.cpp index 8533394..a5b09c2 100644 --- a/editorlib/src/editorscene.cpp +++ b/editorlib/src/editorscene.cpp @@ -944,9 +944,12 @@ void EditorScene::dragScaleSelectedEntity(const QPoint &newPos, bool shiftDown, // Calculate the translate needed to keep opposite corner anchored QMatrix4x4 ancestralTransform = EditorUtils::totalAncestralTransform(m_selectedEntity); - QVector3D newHandleCornerTranslation = - EditorUtils::totalAncestralScale(m_selectedEntity) - * m_lockToAxisScale * m_dragHandleCornerTranslation; + QVector3D ancestralScale = + EditorUtils::totalAncestralScale(m_selectedEntity) * m_lockToAxisScale; + QVector3D newHandleCornerTranslation = ancestralScale * m_dragHandleCornerTranslation; + EditorSceneItem *selectedItem = m_sceneItems.value(m_selectedEntity->id(), nullptr); + if (selectedItem) + newHandleCornerTranslation -= ancestralScale * selectedItem->entityMeshCenter(); QVector3D newTranslation = ancestralTransform.inverted() * m_dragInitialHandleMatrix * (newHandleCornerTranslation - m_dragInitialHandleCornerTranslation); |