Extend types in GetClampedCoords.

This commit is contained in:
Alex 2023-01-15 11:54:02 +05:00
parent 1df81b10e6
commit 8c6eb4ce22
1 changed files with 6 additions and 6 deletions

View File

@ -152,21 +152,21 @@ VECTOR2<ret_type> GetClampedCoords( const VECTOR2<in_type>& aCoords, pad_type aP
{ {
typedef std::numeric_limits<int> coord_limits; typedef std::numeric_limits<int> coord_limits;
long max = coord_limits::max() - aPadding; long long max = long long( coord_limits::max() ) - aPadding;
long min = -max; long long min = -max;
in_type x = aCoords.x; in_type x = aCoords.x;
in_type y = aCoords.y; in_type y = aCoords.y;
if( x < min ) if( x < min )
x = min; x = in_type( min );
else if( x > max ) else if( x > max )
x = max; x = in_type( max );
if( y < min ) if( y < min )
y = min; y = in_type( min );
else if( y > max ) else if( y > max )
y = max; y = in_type( max );
if( !std::is_integral<in_type>() && std::is_integral<ret_type>() ) if( !std::is_integral<in_type>() && std::is_integral<ret_type>() )
return VECTOR2<ret_type>( KiROUND( x ), KiROUND( y ) ); return VECTOR2<ret_type>( KiROUND( x ), KiROUND( y ) );