From 6d6bb9685672f1aa48a961311ef1e213a5f17682 Mon Sep 17 00:00:00 2001 From: MrStevns Date: Mon, 23 Sep 2024 18:46:16 +0200 Subject: [PATCH] iss: #1877 - Fix import image using camera transform not working --- app/src/importpositiondialog.cpp | 32 ++++++++--------------------- core_lib/src/interface/editor.cpp | 7 ------- core_lib/src/managers/viewmanager.h | 5 ----- 3 files changed, 9 insertions(+), 35 deletions(-) diff --git a/app/src/importpositiondialog.cpp b/app/src/importpositiondialog.cpp index e0b67291ab..eb3dcf3551 100644 --- a/app/src/importpositiondialog.cpp +++ b/app/src/importpositiondialog.cpp @@ -64,39 +64,25 @@ void ImportPositionDialog::didChangeComboBoxIndex(const int index) void ImportPositionDialog::changeImportView() { - mEditor->view()->setImportFollowsCamera(false); QTransform transform; if (mImportOption == ImportPosition::Type::CenterOfView) { QPointF centralPoint = mEditor->getScribbleArea()->getCentralPoint(); transform = transform.fromTranslate(centralPoint.x(), centralPoint.y()); - mEditor->view()->setImportView(transform); - QSettings settings(PENCIL2D, PENCIL2D); - settings.setValue(IMPORT_REPOSITION_TYPE, ui->cbImagePosition->currentIndex()); - return; } - else if (mImportOption == ImportPosition::Type::CenterOfCanvas) - { - transform = transform.fromTranslate(0, 0); - mEditor->view()->setImportView(transform); - QSettings settings(PENCIL2D, PENCIL2D); - settings.setValue(IMPORT_REPOSITION_TYPE, ui->cbImagePosition->currentIndex()); - return; - } - else if (mImportOption == ImportPosition::Type::CenterOfCamera) + else if (mImportOption == ImportPosition::Type::CenterOfCamera || mImportOption == ImportPosition::Type::CenterOfCameraFollowed) { LayerCamera* layerCam = static_cast(mEditor->layers()->getCameraLayerBelow(mEditor->currentLayerIndex())); Q_ASSERT(layerCam); - QRectF cameraRect = layerCam->getViewRect(); - transform = transform.fromTranslate(cameraRect.center().x(), cameraRect.center().y()); - mEditor->view()->setImportView(transform); - QSettings settings(PENCIL2D, PENCIL2D); - settings.setValue(IMPORT_REPOSITION_TYPE, ui->cbImagePosition->currentIndex()); - return; - } - Q_ASSERT(mImportOption == ImportPosition::Type::CenterOfCameraFollowed); - mEditor->view()->setImportFollowsCamera(true); + if (mImportOption == ImportPosition::Type::CenterOfCamera) { + KeyFrame* camKey = layerCam->getKeyFrameAt(mEditor->currentFrame()); + transform = layerCam->getViewAtFrame(camKey->pos()).inverted(); + } else { + transform = layerCam->getViewAtFrame(mEditor->currentFrame()).inverted(); + } + } + mEditor->view()->setImportView(transform); QSettings settings(PENCIL2D, PENCIL2D); settings.setValue(IMPORT_REPOSITION_TYPE, ui->cbImagePosition->currentIndex()); } diff --git a/core_lib/src/interface/editor.cpp b/core_lib/src/interface/editor.cpp index b997168995..49106c3795 100644 --- a/core_lib/src/interface/editor.cpp +++ b/core_lib/src/interface/editor.cpp @@ -1015,13 +1015,6 @@ Status Editor::importImage(const QString& filePath) DebugDetails dd; dd << QString("Raw file path: %1").arg(filePath); - if (view()->getImportFollowsCamera()) - { - LayerCamera* camera = static_cast(layers()->getLastCameraLayer()); - Q_ASSERT(camera); - QTransform transform = camera->getViewAtFrame(currentFrame()); - view()->setImportView(transform); - } switch (layer->type()) { case Layer::BITMAP: diff --git a/core_lib/src/managers/viewmanager.h b/core_lib/src/managers/viewmanager.h index 1c0009c4d5..3bd9cebd66 100644 --- a/core_lib/src/managers/viewmanager.h +++ b/core_lib/src/managers/viewmanager.h @@ -94,9 +94,6 @@ class ViewManager : public BaseManager QTransform getImportView() { return mImportView; } void setImportView(const QTransform& newView) { mImportView = newView; } - void setImportFollowsCamera(bool b) { mImportFollowsCamera = b; } - bool getImportFollowsCamera() { return mImportFollowsCamera; } - void forceUpdateViewTransform(); signals: @@ -126,8 +123,6 @@ class ViewManager : public BaseManager bool mOverlayThirds = false; bool mOverlayGoldenRatio = false; bool mOverlaySafeAreas = false; - - bool mImportFollowsCamera = false; }; #endif // VIEWMANAGER_H