Skip to content

OpenToonz - An open-source full-featured 2D animation creation software

C

Get actual pixel size instead of hard-coding to 1.0.

Martin van Zijl696695065a54
diff --git a/toonz/sources/toonzlib/stagevisitor.cpp b/toonz/sources/toonzlib/stagevisitor.cpp
index be747c3bf..9f45f5173 100644
--- a/toonz/sources/toonzlib/stagevisitor.cpp
+++ b/toonz/sources/toonzlib/stagevisitor.cpp
@@ -253,7 +253,10 @@ void Picker::onImage(const Stage::Player &player) {
else if (vi->getNearestStroke(point, w, strokeIndex, dist2)) {
// based on TTool::Viewer::doPickGuideStroke
- double pixelSize = 1.0; // TODO: Get actual pixel size from viewer.
+ // m_minDist2 seems to be the pixel size to the power 4, so take the
+ // square root of the square root.
+ // Use abs() just in case m_minDist2 is negative, to avoid math errors.
+ double pixelSize = sqrt(sqrt(abs(m_minDist2)));
double maxDist = 5 * pixelSize;
double maxDist2 = maxDist * maxDist;
double checkDist = maxDist2 * 4;