https://bugs.kde.org/show_bug.cgi?id=485689

--- Comment #1 from stuff <seitr...@gmail.com> ---
I looked into this: KisTransformWorker::transform() reports its supposed
transform, though never uses this function itself.  This reported transform is
used for the vector layer's shape transforms and looks like:

    return TS.inverted() * S * TS * SC * R * T;

Whereas KisTransformUtils::MatricesPack::finalTransform() looks like:

    return TS * SC * S * projectedP * T;

Notice that SC and S are in a reverse order!

There are three different transforms in play
    1) the bounding box during free transform (uses MatricesPack)
    2) the rasterized result of KisTransformWorker, using its mathy inner
workings
    3) the vector layer result using KisTransformWorker::transform()
I think 1 and 2 currently agree, but 3 doesn't, so I suspect maybe
KisTransformWorker is just reporting its own transform wrong?

Through trial and error I've found this function, a slight modification from
the current one, seems to fix this problem.
QTransform KisTransformWorker::transform() const
{
    QTransform TS = QTransform::fromTranslate(m_xshearOrigin * m_xscale,
m_yshearOrigin * m_yscale);
    QTransform S; S.shear(0, m_yshear); S.shear(m_xshear, 0);
    QTransform SC = QTransform::fromScale(m_xscale, m_yscale);
    QTransform R; R.rotateRadians(m_rotation);
    QTransform T = QTransform::fromTranslate(m_xtranslate, m_ytranslate);

    return SC * TS.inverted() * S * TS * R * T;
}
where I've swapped the order of scale and shear and compensated for that in the
translation

Also, with this modified version, at the end of
KisTransformUtils::createTransformWorker, MatricesPack(args).finalTransform()
tends to be equal or nearly equal (within 1e-5 component-wise) to
transformWorker.transform(), where it definitely wasn't before.  There's a
comment explaining KisTransformWorker::transform that does match the current
code, though, so I'm not sure what's going on.

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to