forked from organicmaps/organicmaps
Correct ClampPoint (do not use double->uint32_t conversion).
This commit is contained in:
parent
688034aaf8
commit
adc6929a8d
1 changed files with 6 additions and 4 deletions
|
@ -11,12 +11,14 @@
|
|||
|
||||
namespace
|
||||
{
|
||||
template <typename T>
|
||||
inline m2::PointU ClampPoint(m2::PointU const & maxPoint, m2::Point<T> const & point)
|
||||
inline m2::PointU ClampPoint(m2::PointU const & maxPoint, m2::Point<double> const & point)
|
||||
{
|
||||
typedef m2::PointU::value_type uvalue_t;
|
||||
return m2::PointU(my::clamp(static_cast<uvalue_t>(point.x), static_cast<uvalue_t>(0), maxPoint.x),
|
||||
my::clamp(static_cast<uvalue_t>(point.y), static_cast<uvalue_t>(0), maxPoint.y));
|
||||
//return m2::PointU(my::clamp(static_cast<uvalue_t>(point.x), static_cast<uvalue_t>(0), maxPoint.x),
|
||||
// my::clamp(static_cast<uvalue_t>(point.y), static_cast<uvalue_t>(0), maxPoint.y));
|
||||
|
||||
return m2::PointU(static_cast<uvalue_t>(my::clamp(point.x, 0.0, static_cast<double>(maxPoint.x))),
|
||||
static_cast<uvalue_t>(my::clamp(point.y, 0.0, static_cast<double>(maxPoint.y))));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue