Fix fuzzy comparison in QGeoCameraTiles
The QGeoCameraTilesPrivate::tilesFromPolygon() method uses fuzzy
comparison a lot.
As pointed out in the previous patch, the fact that it has lines like
x = static_cast<int>(p.x()) % m_sideLength;
lets us assume that m_sideLength != 0, so all fuzzy comparison that
uses this constant is fine.
In the condition
!qFuzzyCompare(p.x(), 1.0 * x) && qFuzzyCompare(p.x(), 1.0 * (x + 1))
both p.x() and x can be zeros, so the first qFuzzyCompare() should be
replaced with QtPrivate::fuzzyCompare().
The logic for the second comparison is a bit more tricky.
The qFuzzyCompare() function provides incorrect results when both
arguments are close to zero. In this case, I do not see a way for both
p.x() and (x + 1) to be close to zero at the same time:
* if p.x() is close to zero, then x is also zero, but x + 1 is not.
So, the comparison will work fine.
* if p.x() is some negative number with abs(p.x()) > 1, x + 1 can be
equal to zero, but it will still be fine because p.x() is not close
to zero.
So, we can keep using qFuzzyCompare() for the second comparison.
Same logic is valid for the y-coordinate.
The other updated cases are trivial - we compare two FP values, where
both of them can be zero. So, use QtPrivate::fuzzyCompare().
It's hard to track the commits that originally introduced the code,
but all of it predates active branches.
Task-number: QTBUG-144282
Pick-to: 6.11 6.10 6.8 6.5
Change-Id: Id80a59d12003b7c14bebd3b10e48adb339ce375f
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>