Slightly optimize SEG::NearestPoint.

This commit is contained in:
Alex Shvartzkop
2024-06-20 04:25:33 +03:00
parent 62fb5697b4
commit ec271c20db
+3 -2
View File
@@ -268,8 +268,9 @@ bool SEG::Contains( const VECTOR2I& aP ) const
const VECTOR2I SEG::NearestPoint( const VECTOR2I& aP ) const
{
VECTOR2I d = B - A;
ecoord l_squared = d.Dot( d );
// Inlined for performance reasons
VECTOR2L d( B.x - A.x, B.y - A.y );
ecoord l_squared( d.x * d.x + d.y * d.y );
if( l_squared == 0 )
return A;