diff --git a/toonz/sources/include/tools/inputmanager.h b/toonz/sources/include/tools/inputmanager.h index 5b6d677..3f6f51a 100644 --- a/toonz/sources/include/tools/inputmanager.h +++ b/toonz/sources/include/tools/inputmanager.h @@ -83,7 +83,7 @@ public: m_lock = lock; if (m_savePoint) { m_savePoint->hold(); - if (m_lock) savePoint->lock(); + if (m_lock) savePoint->lock(); } } else if (m_lock != lock) { @@ -97,10 +97,12 @@ public: inline void reset() { set(NULL, false); } + inline void setLock(bool lock) + { set(m_savePoint, lock); } inline void lock() - { set(m_savePoint, true); } + { setLock(true); } inline void unlock() - { set(m_savePoint, false); } + { setLock(false); } inline TInputSavePoint* savePoint() const { return m_savePoint; } diff --git a/toonz/sources/include/tools/tool.h b/toonz/sources/include/tools/tool.h index b6aff1b..0701889 100644 --- a/toonz/sources/include/tools/tool.h +++ b/toonz/sources/include/tools/tool.h @@ -625,6 +625,11 @@ public: } //!< Gets the viewer's current view affine (ie the transform from //!< starting to current world view <\I>) + virtual TAffine4 get3dViewMatrix() const { + return TAffine4(getViewMatrix()); + } //!< Gets the viewer's current view affine 3d (ie the transform from + //!< starting to current world view <\I>) + //! return the column index of the drawing intersecting point \b p //! (window coordinate, pixels, bottom-left origin) virtual int posToColumnIndex(const TPointD &p, double distance, diff --git a/toonz/sources/tnztools/modifiers/modifierassistants.cpp b/toonz/sources/tnztools/modifiers/modifierassistants.cpp index 0385fa3..fb0af74 100644 --- a/toonz/sources/tnztools/modifiers/modifierassistants.cpp +++ b/toonz/sources/tnztools/modifiers/modifierassistants.cpp @@ -11,6 +11,7 @@ #include #include #include +#include // TnzCore includes #include @@ -111,8 +112,13 @@ TModifierAssistants::modifyTrack( if (TInputHandler *handler = manager->getHandler()) if (TTool *tool = handler->getTool()) if (TToolViewer *viewer = tool->getViewer()) { - TAffine trackToScreen = manager->toolToWorld() - * viewer->get3dViewMatrix().get2d().inv(); + TAffine trackToScreen = tool->getMatrix(); + if (tool->getToolType() & TTool::LevelTool) + if (TObjectHandle *objHandle = TTool::getApplication()->getCurrentObject()) + if (!objHandle->isSpline()) + trackToScreen *= TScale(viewer->getDpiScale().x, viewer->getDpiScale().y); + trackToScreen *= viewer->get3dViewMatrix().get2d().inv(); + TGuidelineP guideline = TGuideline::findBest(modifier->guidelines, track, trackToScreen, longEnough); if (guideline != modifier->guidelines.front()) for(int i = 1; i < (int)modifier->guidelines.size(); ++i) @@ -122,7 +128,7 @@ TModifierAssistants::modifyTrack( break; } } - if (longEnough) modifier->savePoint.unlock(); else modifier->savePoint.lock(); + modifier->savePoint.setLock(!longEnough); } else { modifier->savePoint.reset(); } diff --git a/toonz/sources/toonz/sceneviewer.cpp b/toonz/sources/toonz/sceneviewer.cpp index fdf2e08..f65e6e7 100644 --- a/toonz/sources/toonz/sceneviewer.cpp +++ b/toonz/sources/toonz/sceneviewer.cpp @@ -2257,6 +2257,37 @@ TRect SceneViewer::getActualClipRect(const TAffine &aff) { //----------------------------------------------------------------------------- +TAffine4 SceneViewer::get3dViewMatrix() const { + if (is3DView()) { + TXsheet *xsh = TApp::instance()->getCurrentXsheet()->getXsheet(); + TStageObjectId cameraId = xsh->getStageObjectTree()->getCurrentCameraId(); + double z = xsh->getStageObject(cameraId)->getZ( + TApp::instance()->getCurrentFrame()->getFrame()); + + TAffine4 affine; + affine *= TAffine4::translation(m_pan3D.x, m_pan3D.y, z); + affine *= TAffine4::scale(m_zoomScale3D, m_zoomScale3D, m_zoomScale3D); + affine *= TAffine4::rotationX(M_PI_180*m_theta3D); + affine *= TAffine4::rotationY(M_PI_180*m_phi3D); + return affine; + } + + int viewMode = TApp::instance()->getCurrentFrame()->isEditingLevel() + ? LEVEL_VIEWMODE + : SCENE_VIEWMODE; + + if (m_referenceMode == CAMERA_REFERENCE) { + int frame = TApp::instance()->getCurrentFrame()->getFrame(); + TXsheet *xsh = TApp::instance()->getCurrentXsheet()->getXsheet(); + TAffine aff = xsh->getCameraAff(frame); + return TAffine4(m_viewAff[viewMode] * aff.inv()); + } + + return TAffine4(m_viewAff[viewMode]); +} + +//----------------------------------------------------------------------------- + TAffine SceneViewer::getViewMatrix() const { int viewMode = TApp::instance()->getCurrentFrame()->isEditingLevel() ? LEVEL_VIEWMODE diff --git a/toonz/sources/toonz/sceneviewer.h b/toonz/sources/toonz/sceneviewer.h index bf1fbe6..e93cfd3 100644 --- a/toonz/sources/toonz/sceneviewer.h +++ b/toonz/sources/toonz/sceneviewer.h @@ -232,6 +232,8 @@ public: //! The view matrix is a matrix contained in \b m_viewAff TAffine getSceneMatrix() const; + TAffine4 get3dViewMatrix() const override; + void setViewMatrix(const TAffine &aff, int viewMode); int getFPS() { return m_FPS; }